Subject: linux-next: manual merge of the drm-misc-fixes tree with Linus' tree

From: Stephen Rothwell <[email-masked]>
Date: Fri, 6 Jun 2025 09:47:11 +1000

Hi all,

Today's linux-next merge of the drm-misc-fixes tree got a conflict in:

  drivers/accel/ivpu/ivpu_gem.c

between commit:

  835b14ce4ee3 ("accel/ivpu: s/drm_gem_shmem_v[un]map/drm_gem_shmem_v[un]map_locked/")

from Linus' tree and commit:

  98d3f772ca7d ("accel/ivpu: Use dma_resv_lock() instead of a custom mutex")

from the drm-misc-fixes tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/accel/ivpu/ivpu_gem.c
index e0d242d9f3e5,248bfebeaa22..000000000000
--- a/drivers/accel/ivpu/ivpu_gem.c
+++ b/drivers/accel/ivpu/ivpu_gem.c
@@@ -28,11 -28,21 +28,21 @@@ static inline void ivpu_dbg_bo(struct i
  {
  	ivpu_dbg(vdev, BO,
  		 "%6s: bo %8p vpu_addr %9llx size %8zu ctx %d has_pages %d dma_mapped %d mmu_mapped %d wc %d imported %d\n",
- 		 action, bo, bo->vpu_addr, ivpu_bo_size(bo), bo->ctx ? bo->ctx->id : 0,
+ 		 action, bo, bo->vpu_addr, ivpu_bo_size(bo), bo->ctx_id,
  		 (bool)bo->base.pages, (bool)bo->base.sgt, bo->mmu_mapped, bo->base.map_wc,
 -		 (bool)bo->base.base.import_attach);
 +		 (bool)drm_gem_is_imported(&bo->base.base));
  }
  
+ static inline int ivpu_bo_lock(struct ivpu_bo *bo)
+ {
+ 	return dma_resv_lock(bo->base.base.resv, NULL);
+ }
+ 
+ static inline void ivpu_bo_unlock(struct ivpu_bo *bo)
+ {
+ 	dma_resv_unlock(bo->base.base.resv);
+ }
+ 
  /*
   * ivpu_bo_pin() - pin the backing physical pages and map them to VPU.
   *
@@@ -122,10 -130,9 +130,9 @@@ static void ivpu_bo_unbind_locked(struc
  		bo->ctx = NULL;
  	}
  
 -	if (bo->base.base.import_attach)
 +	if (drm_gem_is_imported(&bo->base.base))
  		return;
  
- 	dma_resv_lock(bo->base.base.resv, NULL);
  	if (bo->base.sgt) {
  		dma_unmap_sgtable(vdev->drm.dev, bo->base.sgt, DMA_BIDIRECTIONAL, 0);
  		sg_free_table(bo->base.sgt);
@@@ -277,12 -285,16 +285,16 @@@ static void ivpu_gem_bo_free(struct drm
  	list_del(&bo->bo_list_node);
  	mutex_unlock(&vdev->bo_list_lock);
  
- 	drm_WARN_ON(&vdev->drm, !dma_resv_test_signaled(obj->resv, DMA_RESV_USAGE_READ));
+ 	drm_WARN_ON(&vdev->drm, !drm_gem_is_imported(&bo->base.base) &&
+ 		    !dma_resv_test_signaled(obj->resv, DMA_RESV_USAGE_READ));
+ 	drm_WARN_ON(&vdev->drm, ivpu_bo_size(bo) == 0);
+ 	drm_WARN_ON(&vdev->drm, bo->base.vaddr);
  
  	ivpu_bo_unbind_locked(bo);
- 	mutex_destroy(&bo->lock);
+ 	drm_WARN_ON(&vdev->drm, bo->mmu_mapped);
+ 	drm_WARN_ON(&vdev->drm, bo->ctx);
  
 -	drm_WARN_ON(obj->dev, bo->base.pages_use_count > 1);
 +	drm_WARN_ON(obj->dev, refcount_read(&bo->base.pages_use_count) > 1);
  	drm_gem_shmem_free(&bo->base);
  }
  
@@@ -361,9 -376,9 +376,9 @@@ ivpu_bo_create(struct ivpu_device *vdev
  		goto err_put;
  
  	if (flags & DRM_IVPU_BO_MAPPABLE) {
- 		dma_resv_lock(bo->base.base.resv, NULL);
+ 		ivpu_bo_lock(bo);
 -		ret = drm_gem_shmem_vmap(&bo->base, &map);
 +		ret = drm_gem_shmem_vmap_locked(&bo->base, &map);
- 		dma_resv_unlock(bo->base.base.resv);
+ 		ivpu_bo_unlock(bo);
  
  		if (ret)
  			goto err_put;
@@@ -386,9 -401,9 +401,9 @@@ void ivpu_bo_free(struct ivpu_bo *bo
  	struct iosys_map map = IOSYS_MAP_INIT_VADDR(bo->base.vaddr);
  
  	if (bo->flags & DRM_IVPU_BO_MAPPABLE) {
- 		dma_resv_lock(bo->base.base.resv, NULL);
+ 		ivpu_bo_lock(bo);
 -		drm_gem_shmem_vunmap(&bo->base, &map);
 +		drm_gem_shmem_vunmap_locked(&bo->base, &map);
- 		dma_resv_unlock(bo->base.base.resv);
+ 		ivpu_bo_unlock(bo);
  	}
  
  	drm_gem_object_put(&bo->base.base);