Skip to content

Commit a17aceb

Browse files
committed
drm/xe: Check empty pinned BO list with lock held.
Use lock that is meant to use for accessing the BO pin list. Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240528115408.22094-1-nirmoy.das@intel.com Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
1 parent fa171d4 commit a17aceb

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,11 +1758,10 @@ void xe_bo_unpin_external(struct xe_bo *bo)
17581758
xe_assert(xe, xe_bo_is_pinned(bo));
17591759
xe_assert(xe, xe_bo_is_user(bo));
17601760

1761-
if (bo->ttm.pin_count == 1 && !list_empty(&bo->pinned_link)) {
1762-
spin_lock(&xe->pinned.lock);
1761+
spin_lock(&xe->pinned.lock);
1762+
if (bo->ttm.pin_count == 1 && !list_empty(&bo->pinned_link))
17631763
list_del_init(&bo->pinned_link);
1764-
spin_unlock(&xe->pinned.lock);
1765-
}
1764+
spin_unlock(&xe->pinned.lock);
17661765

17671766
ttm_bo_unpin(&bo->ttm);
17681767

@@ -1785,9 +1784,8 @@ void xe_bo_unpin(struct xe_bo *bo)
17851784
struct ttm_place *place = &(bo->placements[0]);
17861785

17871786
if (mem_type_is_vram(place->mem_type)) {
1788-
xe_assert(xe, !list_empty(&bo->pinned_link));
1789-
17901787
spin_lock(&xe->pinned.lock);
1788+
xe_assert(xe, !list_empty(&bo->pinned_link));
17911789
list_del_init(&bo->pinned_link);
17921790
spin_unlock(&xe->pinned.lock);
17931791
}

0 commit comments

Comments
 (0)