Skip to content

Commit 8d9df6d

Browse files
Thomas Hellströmgregkh
authored andcommitted
drm/xe: Drop preempt-fences when destroying imported dma-bufs.
commit fe3ccd2 upstream. When imported dma-bufs are destroyed, TTM is not fully individualizing the dma-resv, but it *is* copying the fences that need to be waited for before declaring idle. So in the case where the bo->resv != bo->_resv we can still drop the preempt-fences, but make sure we do that on bo->_resv which contains the fence-pointer copy. In the case where the copying fails, bo->_resv will typically not contain any fences pointers at all, so there will be nothing to drop. In that case, TTM would have ensured all fences that would have been copied are signaled, including any remaining preempt fences. Fixes: dd08ebf ("drm/xe: Introduce a new DRM driver for Intel GPUs") Fixes: fa0af72 ("drm/ttm: test private resv obj on release/destroy") Cc: Matthew Brost <matthew.brost@intel.com> Cc: <stable@vger.kernel.org> # v6.16+ Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Tested-by: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://patch.msgid.link/20251217093441.5073-1-thomas.hellstrom@linux.intel.com (cherry picked from commit 425fe55) Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e85d0e0 commit 8d9df6d

1 file changed

Lines changed: 4 additions & 11 deletions

File tree

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,7 @@ static bool xe_ttm_bo_lock_in_destructor(struct ttm_buffer_object *ttm_bo)
14801480
* always succeed here, as long as we hold the lru lock.
14811481
*/
14821482
spin_lock(&ttm_bo->bdev->lru_lock);
1483-
locked = dma_resv_trylock(ttm_bo->base.resv);
1483+
locked = dma_resv_trylock(&ttm_bo->base._resv);
14841484
spin_unlock(&ttm_bo->bdev->lru_lock);
14851485
xe_assert(xe, locked);
14861486

@@ -1500,13 +1500,6 @@ static void xe_ttm_bo_release_notify(struct ttm_buffer_object *ttm_bo)
15001500
bo = ttm_to_xe_bo(ttm_bo);
15011501
xe_assert(xe_bo_device(bo), !(bo->created && kref_read(&ttm_bo->base.refcount)));
15021502

1503-
/*
1504-
* Corner case where TTM fails to allocate memory and this BOs resv
1505-
* still points the VMs resv
1506-
*/
1507-
if (ttm_bo->base.resv != &ttm_bo->base._resv)
1508-
return;
1509-
15101503
if (!xe_ttm_bo_lock_in_destructor(ttm_bo))
15111504
return;
15121505

@@ -1516,22 +1509,22 @@ static void xe_ttm_bo_release_notify(struct ttm_buffer_object *ttm_bo)
15161509
* TODO: Don't do this for external bos once we scrub them after
15171510
* unbind.
15181511
*/
1519-
dma_resv_for_each_fence(&cursor, ttm_bo->base.resv,
1512+
dma_resv_for_each_fence(&cursor, &ttm_bo->base._resv,
15201513
DMA_RESV_USAGE_BOOKKEEP, fence) {
15211514
if (xe_fence_is_xe_preempt(fence) &&
15221515
!dma_fence_is_signaled(fence)) {
15231516
if (!replacement)
15241517
replacement = dma_fence_get_stub();
15251518

1526-
dma_resv_replace_fences(ttm_bo->base.resv,
1519+
dma_resv_replace_fences(&ttm_bo->base._resv,
15271520
fence->context,
15281521
replacement,
15291522
DMA_RESV_USAGE_BOOKKEEP);
15301523
}
15311524
}
15321525
dma_fence_put(replacement);
15331526

1534-
dma_resv_unlock(ttm_bo->base.resv);
1527+
dma_resv_unlock(&ttm_bo->base._resv);
15351528
}
15361529

15371530
static void xe_ttm_bo_delete_mem_notify(struct ttm_buffer_object *ttm_bo)

0 commit comments

Comments
 (0)