Patch "drm/ttm: Fix a deadlock if the target BO is not idle during swap" has been added to the 5.14-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    drm/ttm: Fix a deadlock if the target BO is not idle during swap

to the 5.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     drm-ttm-fix-a-deadlock-if-the-target-bo-is-not-idle-.patch
and it can be found in the queue-5.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 096e02f7be910b6d1ec893e8247e6a84a67a9752
Author: xinhui pan <xinhui.pan@xxxxxxx>
Date:   Tue Sep 7 12:08:32 2021 +0800

    drm/ttm: Fix a deadlock if the target BO is not idle during swap
    
    [ Upstream commit 70982eef4d7eebb47a3b1ef25ec1bc742f3a21cf ]
    
    The ret value might be -EBUSY, caller will think lru lock is still
    locked but actually NOT. So return -ENOSPC instead. Otherwise we hit
    list corruption.
    
    ttm_bo_cleanup_refs might fail too if BO is not idle. If we return 0,
    caller(ttm_tt_populate -> ttm_global_swapout ->ttm_device_swapout) will
    be stuck as we actually did not free any BO memory. This usually happens
    when the fence is not signaled for a long time.
    
    Signed-off-by: xinhui pan <xinhui.pan@xxxxxxx>
    Reviewed-by: Christian König <christian.koenig@xxxxxxx>
    Fixes: ebd59851c796 ("drm/ttm: move swapout logic around v3")
    Link: https://patchwork.freedesktop.org/patch/msgid/20210907040832.1107747-1-xinhui.pan@xxxxxxx
    Signed-off-by: Christian König <christian.koenig@xxxxxxx>
    Signed-off-by: Dave Airlie <airlied@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 32202385073a..b47a5053eb85 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1157,9 +1157,9 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx,
 	}
 
 	if (bo->deleted) {
-		ttm_bo_cleanup_refs(bo, false, false, locked);
+		ret = ttm_bo_cleanup_refs(bo, false, false, locked);
 		ttm_bo_put(bo);
-		return 0;
+		return ret == -EBUSY ? -ENOSPC : ret;
 	}
 
 	ttm_bo_del_from_lru(bo);
@@ -1213,7 +1213,7 @@ out:
 	if (locked)
 		dma_resv_unlock(bo->base.resv);
 	ttm_bo_put(bo);
-	return ret;
+	return ret == -EBUSY ? -ENOSPC : ret;
 }
 
 void ttm_bo_tt_destroy(struct ttm_buffer_object *bo)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux