]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
drm/ttm: make ttm_bo_unpin more defensive
authorChristian König <christian.koenig@amd.com>
Fri, 12 Mar 2021 08:34:39 +0000 (09:34 +0100)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 8 Apr 2021 20:42:50 +0000 (15:42 -0500)
BugLink: https://bugs.launchpad.net/bugs/1923069
commit 6c5403173a13a08ff61dbdafa4c0ed4a9dedbfe0 upstream.

We seem to have some more driver bugs than thought.

Signed-off-by: Christian König <christian.koenig@amd.com>
Fixes: deb0814b43f3 ("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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
include/drm/ttm/ttm_bo_api.h

index 2564e66e67d747cfb07bb6b0b5e3cd4a6f4fe7f6..562cb5e455240f40077341dbe3f6fcb38da676fb 100644 (file)
@@ -612,8 +612,10 @@ static inline void ttm_bo_pin(struct ttm_buffer_object *bo)
 static inline void ttm_bo_unpin(struct ttm_buffer_object *bo)
 {
        dma_resv_assert_held(bo->base.resv);
-       WARN_ON_ONCE(!bo->pin_count);
-       --bo->pin_count;
+       if (bo->pin_count)
+               --bo->pin_count;
+       else
+               WARN_ON_ONCE(true);
 }
 
 int ttm_mem_evict_first(struct ttm_bo_device *bdev,