Skip to content

Commit 425fe55

Browse files
author
Thomas Hellström
committed
drm/xe: Drop preempt-fences when destroying imported dma-bufs.
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
1 parent 5bf763e commit 425fe55

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
@@ -1526,7 +1526,7 @@ static bool xe_ttm_bo_lock_in_destructor(struct ttm_buffer_object *ttm_bo)
15261526
* always succeed here, as long as we hold the lru lock.
15271527
*/
15281528
spin_lock(&ttm_bo->bdev->lru_lock);
1529-
locked = dma_resv_trylock(ttm_bo->base.resv);
1529+
locked = dma_resv_trylock(&ttm_bo->base._resv);
15301530
spin_unlock(&ttm_bo->bdev->lru_lock);
15311531
xe_assert(xe, locked);
15321532

@@ -1546,13 +1546,6 @@ static void xe_ttm_bo_release_notify(struct ttm_buffer_object *ttm_bo)
15461546
bo = ttm_to_xe_bo(ttm_bo);
15471547
xe_assert(xe_bo_device(bo), !(bo->created && kref_read(&ttm_bo->base.refcount)));
15481548

1549-
/*
1550-
* Corner case where TTM fails to allocate memory and this BOs resv
1551-
* still points the VMs resv
1552-
*/
1553-
if (ttm_bo->base.resv != &ttm_bo->base._resv)
1554-
return;
1555-
15561549
if (!xe_ttm_bo_lock_in_destructor(ttm_bo))
15571550
return;
15581551

@@ -1562,22 +1555,22 @@ static void xe_ttm_bo_release_notify(struct ttm_buffer_object *ttm_bo)
15621555
* TODO: Don't do this for external bos once we scrub them after
15631556
* unbind.
15641557
*/
1565-
dma_resv_for_each_fence(&cursor, ttm_bo->base.resv,
1558+
dma_resv_for_each_fence(&cursor, &ttm_bo->base._resv,
15661559
DMA_RESV_USAGE_BOOKKEEP, fence) {
15671560
if (xe_fence_is_xe_preempt(fence) &&
15681561
!dma_fence_is_signaled(fence)) {
15691562
if (!replacement)
15701563
replacement = dma_fence_get_stub();
15711564

1572-
dma_resv_replace_fences(ttm_bo->base.resv,
1565+
dma_resv_replace_fences(&ttm_bo->base._resv,
15731566
fence->context,
15741567
replacement,
15751568
DMA_RESV_USAGE_BOOKKEEP);
15761569
}
15771570
}
15781571
dma_fence_put(replacement);
15791572

1580-
dma_resv_unlock(ttm_bo->base.resv);
1573+
dma_resv_unlock(&ttm_bo->base._resv);
15811574
}
15821575

15831576
static void xe_ttm_bo_delete_mem_notify(struct ttm_buffer_object *ttm_bo)

0 commit comments

Comments
 (0)