Skip to content

Commit 0492006

Browse files
ChristianKoenigAMDgregkh
authored andcommitted
drm/ttm: make ttm_bo_unpin more defensive
[ Upstream commit 6c54031 ] We seem to have some more driver bugs than thought. Signed-off-by: Christian König <christian.koenig@amd.com> Fixes: deb0814 ("drm/ttm: add ttm_bo_pin()/ttm_bo_unpin() v2") Acked-by: Matthew Auld <matthew.auld@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210312093810.2202-1-christian.koenig@amd.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7d09e97 commit 0492006

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎include/drm/ttm/ttm_bo_api.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,11 @@ static inline void ttm_bo_pin(struct ttm_buffer_object *bo)
613613
static inline void ttm_bo_unpin(struct ttm_buffer_object *bo)
614614
{
615615
dma_resv_assert_held(bo->base.resv);
616-
WARN_ON_ONCE(!bo->pin_count);
617616
WARN_ON_ONCE(!kref_read(&bo->kref));
618-
--bo->pin_count;
617+
if (bo->pin_count)
618+
--bo->pin_count;
619+
else
620+
WARN_ON_ONCE(true);
619621
}
620622

621623
int ttm_mem_evict_first(struct ttm_bo_device *bdev,

0 commit comments

Comments
 (0)