diff mbox series

[3/7] drm/vmwgfx: start to phase out ttm_exec

Message ID 20241114153020.6209-4-christian.koenig@amd.com (mailing list archive)
State New, archived
Headers show
Series [1/7] drm/radeon: switch over to drm_exec v2 | expand

Commit Message

Christian König Nov. 14, 2024, 3:30 p.m. UTC
Start switching over vmwgfx to drm_exec as well. Replacing some
unnecessary complex calls with just just single BO dma_resv locking.

No intentional functional change, but only compile tested for now.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 49 ++++++++----------------
 1 file changed, 16 insertions(+), 33 deletions(-)

Comments

kernel test robot Nov. 17, 2024, 7:12 a.m. UTC | #1
Hi Christian,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-xe/drm-xe-next]
[also build test WARNING on drm/drm-next drm-exynos/exynos-drm-next linus/master drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-misc/drm-misc-next drm-tip/drm-tip v6.12-rc7 next-20241115]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Christian-K-nig/drm-qxl-switch-to-using-drm_exec-v2/20241115-014610
base:   https://gitlab.freedesktop.org/drm/xe/kernel.git drm-xe-next
patch link:    https://lore.kernel.org/r/20241114153020.6209-4-christian.koenig%40amd.com
patch subject: [PATCH 3/7] drm/vmwgfx: start to phase out ttm_exec
config: x86_64-rhel-8.3 (https://download.01.org/0day-ci/archive/20241117/202411171454.yXzqqhti-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241117/202411171454.yXzqqhti-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411171454.yXzqqhti-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/vmwgfx/vmwgfx_resource.c:521: warning: Function parameter or struct member 'bo' not described in 'vmw_resource_check_buffer'
>> drivers/gpu/drm/vmwgfx/vmwgfx_resource.c:521: warning: Excess function parameter 'val_buf' description in 'vmw_resource_check_buffer'


vim +521 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c

c0951b797e7d0f Thomas Hellstrom  2012-11-20  503  
c0951b797e7d0f Thomas Hellstrom  2012-11-20  504  /**
c0951b797e7d0f Thomas Hellstrom  2012-11-20  505   * vmw_resource_check_buffer - Check whether a backup buffer is needed
c0951b797e7d0f Thomas Hellstrom  2012-11-20  506   *                             for a resource and in that case, allocate
c0951b797e7d0f Thomas Hellstrom  2012-11-20  507   *                             one, reserve and validate it.
c0951b797e7d0f Thomas Hellstrom  2012-11-20  508   *
05436815fdb475 Tom Rix           2022-07-30  509   * @ticket:         The ww acquire context to use, or NULL if trylocking.
c0951b797e7d0f Thomas Hellstrom  2012-11-20  510   * @res:            The resource for which to allocate a backup buffer.
c0951b797e7d0f Thomas Hellstrom  2012-11-20  511   * @interruptible:  Whether any sleeps during allocation should be
c0951b797e7d0f Thomas Hellstrom  2012-11-20  512   *                  performed while interruptible.
c0951b797e7d0f Thomas Hellstrom  2012-11-20  513   * @val_buf:        On successful return contains data about the
c0951b797e7d0f Thomas Hellstrom  2012-11-20  514   *                  reserved and validated backup buffer.
c0951b797e7d0f Thomas Hellstrom  2012-11-20  515   */
ecff665f5e3f1c Maarten Lankhorst 2013-06-27  516  static int
19f976ab01a6bb Thomas Hellstrom  2018-06-19  517  vmw_resource_check_buffer(struct ww_acquire_ctx *ticket,
19f976ab01a6bb Thomas Hellstrom  2018-06-19  518  			  struct vmw_resource *res,
c0951b797e7d0f Thomas Hellstrom  2012-11-20  519  			  bool interruptible,
0b48fc98b52ea2 Christian König   2024-11-14  520  			  struct ttm_buffer_object **bo)
c0951b797e7d0f Thomas Hellstrom  2012-11-20 @521  {
19be5570107108 Christian König   2017-04-12  522  	struct ttm_operation_ctx ctx = { true, false };
c0951b797e7d0f Thomas Hellstrom  2012-11-20  523  	struct list_head val_list;
668b206601c5f5 Zack Rusin        2023-01-30  524  	bool guest_memory_dirty = false;
c0951b797e7d0f Thomas Hellstrom  2012-11-20  525  	int ret;
c0951b797e7d0f Thomas Hellstrom  2012-11-20  526  
668b206601c5f5 Zack Rusin        2023-01-30  527  	if (unlikely(!res->guest_memory_bo)) {
c0951b797e7d0f Thomas Hellstrom  2012-11-20  528  		ret = vmw_resource_buf_alloc(res, interruptible);
c0951b797e7d0f Thomas Hellstrom  2012-11-20  529  		if (unlikely(ret != 0))
c0951b797e7d0f Thomas Hellstrom  2012-11-20  530  			return ret;
c0951b797e7d0f Thomas Hellstrom  2012-11-20  531  	}
c0951b797e7d0f Thomas Hellstrom  2012-11-20  532  
c0951b797e7d0f Thomas Hellstrom  2012-11-20  533  	INIT_LIST_HEAD(&val_list);
668b206601c5f5 Zack Rusin        2023-01-30  534  	ttm_bo_get(&res->guest_memory_bo->tbo);
0b48fc98b52ea2 Christian König   2024-11-14  535  
0b48fc98b52ea2 Christian König   2024-11-14  536  	*bo = &res->guest_memory_bo->tbo;
0b48fc98b52ea2 Christian König   2024-11-14  537  	if (ticket)
0b48fc98b52ea2 Christian König   2024-11-14  538  		ww_acquire_init(ticket, &reservation_ww_class);
0b48fc98b52ea2 Christian König   2024-11-14  539  
0b48fc98b52ea2 Christian König   2024-11-14  540  	ret = ttm_bo_reserve(*bo, interruptible, (ticket == NULL), ticket);
c0951b797e7d0f Thomas Hellstrom  2012-11-20  541  	if (unlikely(ret != 0))
c0951b797e7d0f Thomas Hellstrom  2012-11-20  542  		goto out_no_reserve;
c0951b797e7d0f Thomas Hellstrom  2012-11-20  543  
668b206601c5f5 Zack Rusin        2023-01-30  544  	if (res->func->needs_guest_memory && !vmw_resource_mob_attached(res))
c0951b797e7d0f Thomas Hellstrom  2012-11-20  545  		return 0;
c0951b797e7d0f Thomas Hellstrom  2012-11-20  546  
668b206601c5f5 Zack Rusin        2023-01-30  547  	guest_memory_dirty = res->guest_memory_dirty;
668b206601c5f5 Zack Rusin        2023-01-30  548  	vmw_bo_placement_set(res->guest_memory_bo, res->func->domain,
39985eea5a6dd1 Zack Rusin        2023-01-30  549  			     res->func->busy_domain);
668b206601c5f5 Zack Rusin        2023-01-30  550  	ret = ttm_bo_validate(&res->guest_memory_bo->tbo,
668b206601c5f5 Zack Rusin        2023-01-30  551  			      &res->guest_memory_bo->placement,
19be5570107108 Christian König   2017-04-12  552  			      &ctx);
c0951b797e7d0f Thomas Hellstrom  2012-11-20  553  
c0951b797e7d0f Thomas Hellstrom  2012-11-20  554  	if (unlikely(ret != 0))
c0951b797e7d0f Thomas Hellstrom  2012-11-20  555  		goto out_no_validate;
c0951b797e7d0f Thomas Hellstrom  2012-11-20  556  
c0951b797e7d0f Thomas Hellstrom  2012-11-20  557  	return 0;
c0951b797e7d0f Thomas Hellstrom  2012-11-20  558  
c0951b797e7d0f Thomas Hellstrom  2012-11-20  559  out_no_validate:
0b48fc98b52ea2 Christian König   2024-11-14  560  	dma_resv_unlock((*bo)->base.resv);
0b48fc98b52ea2 Christian König   2024-11-14  561  	if (ticket)
0b48fc98b52ea2 Christian König   2024-11-14  562  		ww_acquire_fini(ticket);
c0951b797e7d0f Thomas Hellstrom  2012-11-20  563  out_no_reserve:
0b48fc98b52ea2 Christian König   2024-11-14  564  	ttm_bo_put(*bo);
668b206601c5f5 Zack Rusin        2023-01-30  565  	if (guest_memory_dirty)
91398b413d0366 Zack Rusin        2023-09-28  566  		vmw_user_bo_unref(&res->guest_memory_bo);
c0951b797e7d0f Thomas Hellstrom  2012-11-20  567  
c0951b797e7d0f Thomas Hellstrom  2012-11-20  568  	return ret;
c0951b797e7d0f Thomas Hellstrom  2012-11-20  569  }
c0951b797e7d0f Thomas Hellstrom  2012-11-20  570
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
index a73af8a355fb..793293b59d43 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -517,7 +517,7 @@  static int
 vmw_resource_check_buffer(struct ww_acquire_ctx *ticket,
 			  struct vmw_resource *res,
 			  bool interruptible,
-			  struct ttm_validate_buffer *val_buf)
+			  struct ttm_buffer_object **bo)
 {
 	struct ttm_operation_ctx ctx = { true, false };
 	struct list_head val_list;
@@ -532,10 +532,12 @@  vmw_resource_check_buffer(struct ww_acquire_ctx *ticket,
 
 	INIT_LIST_HEAD(&val_list);
 	ttm_bo_get(&res->guest_memory_bo->tbo);
-	val_buf->bo = &res->guest_memory_bo->tbo;
-	val_buf->num_shared = 0;
-	list_add_tail(&val_buf->head, &val_list);
-	ret = ttm_eu_reserve_buffers(ticket, &val_list, interruptible, NULL);
+
+	*bo = &res->guest_memory_bo->tbo;
+	if (ticket)
+		ww_acquire_init(ticket, &reservation_ww_class);
+
+	ret = ttm_bo_reserve(*bo, interruptible, (ticket == NULL), ticket);
 	if (unlikely(ret != 0))
 		goto out_no_reserve;
 
@@ -555,10 +557,11 @@  vmw_resource_check_buffer(struct ww_acquire_ctx *ticket,
 	return 0;
 
 out_no_validate:
-	ttm_eu_backoff_reservation(ticket, &val_list);
+	dma_resv_unlock((*bo)->base.resv);
+	if (ticket)
+		ww_acquire_fini(ticket);
 out_no_reserve:
-	ttm_bo_put(val_buf->bo);
-	val_buf->bo = NULL;
+	ttm_bo_put(*bo);
 	if (guest_memory_dirty)
 		vmw_user_bo_unref(&res->guest_memory_bo);
 
@@ -600,29 +603,6 @@  int vmw_resource_reserve(struct vmw_resource *res, bool interruptible,
 	return 0;
 }
 
-/**
- * vmw_resource_backoff_reservation - Unreserve and unreference a
- *                                    guest memory buffer
- *.
- * @ticket:         The ww acquire ctx used for reservation.
- * @val_buf:        Guest memory buffer information.
- */
-static void
-vmw_resource_backoff_reservation(struct ww_acquire_ctx *ticket,
-				 struct ttm_validate_buffer *val_buf)
-{
-	struct list_head val_list;
-
-	if (likely(val_buf->bo == NULL))
-		return;
-
-	INIT_LIST_HEAD(&val_list);
-	list_add_tail(&val_buf->head, &val_list);
-	ttm_eu_backoff_reservation(ticket, &val_list);
-	ttm_bo_put(val_buf->bo);
-	val_buf->bo = NULL;
-}
-
 /**
  * vmw_resource_do_evict - Evict a resource, and transfer its data
  *                         to a backup buffer.
@@ -642,7 +622,7 @@  static int vmw_resource_do_evict(struct ww_acquire_ctx *ticket,
 
 	val_buf.bo = NULL;
 	val_buf.num_shared = 0;
-	ret = vmw_resource_check_buffer(ticket, res, interruptible, &val_buf);
+	ret = vmw_resource_check_buffer(ticket, res, interruptible, &val_buf.bo);
 	if (unlikely(ret != 0))
 		return ret;
 
@@ -657,7 +637,10 @@  static int vmw_resource_do_evict(struct ww_acquire_ctx *ticket,
 	res->guest_memory_dirty = true;
 	res->res_dirty = false;
 out_no_unbind:
-	vmw_resource_backoff_reservation(ticket, &val_buf);
+	dma_resv_unlock(val_buf.bo->base.resv);
+	if (ticket)
+		ww_acquire_fini(ticket);
+	ttm_bo_put(val_buf.bo);
 
 	return ret;
 }