hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
....@@ -25,6 +25,9 @@
2525 *
2626 **************************************************************************/
2727
28
+#include <linux/dmapool.h>
29
+#include <linux/pci.h>
30
+
2831 #include <drm/ttm/ttm_bo_api.h>
2932
3033 #include "vmwgfx_drv.h"
....@@ -393,6 +396,7 @@
393396 __vmw_cmdbuf_header_free(entry);
394397 break;
395398 case SVGA_CB_STATUS_COMMAND_ERROR:
399
+ WARN_ONCE(true, "Command buffer error.\n");
396400 entry->cb_header->status = SVGA_CB_STATUS_NONE;
397401 list_add_tail(&entry->list, &man->error);
398402 schedule_work(&man->work);
....@@ -533,19 +537,20 @@
533537 global_block = true;
534538
535539 if (!vmw_cmd_describe(header, &error_cmd_size, &cmd_name)) {
536
- DRM_ERROR("Unknown command causing device error.\n");
537
- DRM_ERROR("Command buffer offset is %lu\n",
538
- (unsigned long) cb_hdr->errorOffset);
540
+ VMW_DEBUG_USER("Unknown command causing device error.\n");
541
+ VMW_DEBUG_USER("Command buffer offset is %lu\n",
542
+ (unsigned long) cb_hdr->errorOffset);
539543 __vmw_cmdbuf_header_free(entry);
540544 send_fence = true;
541545 continue;
542546 }
543547
544
- DRM_ERROR("Command \"%s\" causing device error.\n", cmd_name);
545
- DRM_ERROR("Command buffer offset is %lu\n",
546
- (unsigned long) cb_hdr->errorOffset);
547
- DRM_ERROR("Command size is %lu\n",
548
- (unsigned long) error_cmd_size);
548
+ VMW_DEBUG_USER("Command \"%s\" causing device error.\n",
549
+ cmd_name);
550
+ VMW_DEBUG_USER("Command buffer offset is %lu\n",
551
+ (unsigned long) cb_hdr->errorOffset);
552
+ VMW_DEBUG_USER("Command size is %lu\n",
553
+ (unsigned long) error_cmd_size);
549554
550555 new_start_offset = cb_hdr->errorOffset + error_cmd_size;
551556
....@@ -656,7 +661,7 @@
656661 {
657662 struct vmw_cmdbuf_header *cur = man->cur;
658663
659
- WARN_ON(!mutex_is_locked(&man->cur_mutex));
664
+ lockdep_assert_held_once(&man->cur_mutex);
660665
661666 if (!cur)
662667 return;
....@@ -761,7 +766,7 @@
761766
762767 if (info->done)
763768 return true;
764
-
769
+
765770 memset(info->node, 0, sizeof(*info->node));
766771 spin_lock(&man->lock);
767772 ret = drm_mm_insert_node(&man->mm, info->node, info->page_size);
....@@ -1041,7 +1046,7 @@
10411046 {
10421047 struct vmw_cmdbuf_header *cur = man->cur;
10431048
1044
- WARN_ON(!mutex_is_locked(&man->cur_mutex));
1049
+ lockdep_assert_held_once(&man->cur_mutex);
10451050
10461051 WARN_ON(size > cur->reserved);
10471052 man->cur_pos += size;
....@@ -1236,7 +1241,8 @@
12361241 * actually call into the already enabled manager, when
12371242 * binding the MOB.
12381243 */
1239
- if (!(dev_priv->capabilities & SVGA_CAP_DX))
1244
+ if (!(dev_priv->capabilities & SVGA_CAP_DX) ||
1245
+ !dev_priv->has_mob)
12401246 return -ENOMEM;
12411247
12421248 ret = ttm_bo_create(&dev_priv->bdev, size, ttm_bo_type_device,
....@@ -1272,8 +1278,10 @@
12721278 return 0;
12731279
12741280 out_no_map:
1275
- if (man->using_mob)
1276
- ttm_bo_unref(&man->cmd_space);
1281
+ if (man->using_mob) {
1282
+ ttm_bo_put(man->cmd_space);
1283
+ man->cmd_space = NULL;
1284
+ }
12771285
12781286 return ret;
12791287 }
....@@ -1376,7 +1384,8 @@
13761384 (void) vmw_cmdbuf_idle(man, false, 10*HZ);
13771385 if (man->using_mob) {
13781386 (void) ttm_bo_kunmap(&man->map_obj);
1379
- ttm_bo_unref(&man->cmd_space);
1387
+ ttm_bo_put(man->cmd_space);
1388
+ man->cmd_space = NULL;
13801389 } else {
13811390 dma_free_coherent(&man->dev_priv->dev->pdev->dev,
13821391 man->size, man->map, man->handle);