Message ID | 20210906011210.80327-2-xinhui.pan@amd.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,1/2] drm/ttm: Fix a deadlock if the target BO is not idle during swap | expand |
Which branch is this patch based on? Please rebase on top drm-misc-fixes and resend. Thanks, Christian. Am 06.09.21 um 03:12 schrieb xinhui pan: > 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@amd.com> > Reviewed-by: Christian König <christian.koenig@amd.com> > --- > drivers/gpu/drm/ttm/ttm_bo.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c > index 1fedd0eb67ba..f1367107925b 100644 > --- a/drivers/gpu/drm/ttm/ttm_bo.c > +++ b/drivers/gpu/drm/ttm/ttm_bo.c > @@ -1159,9 +1159,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_move_to_pinned(bo); > @@ -1215,7 +1215,7 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx, > 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)
[AMD Official Use Only] It is the internal staging drm-next. -----Original Message----- From: Koenig, Christian <Christian.Koenig@amd.com> Sent: 2021年9月6日 19:26 To: Pan, Xinhui <Xinhui.Pan@amd.com>; amd-gfx@lists.freedesktop.org Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; chenli@uniontech.com; dri-devel@lists.freedesktop.org Subject: Re: [PATCH v2 1/2] drm/ttm: Fix a deadlock if the target BO is not idle during swap Which branch is this patch based on? Please rebase on top drm-misc-fixes and resend. Thanks, Christian. Am 06.09.21 um 03:12 schrieb xinhui pan: > 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@amd.com> > Reviewed-by: Christian König <christian.koenig@amd.com> > --- > drivers/gpu/drm/ttm/ttm_bo.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c > b/drivers/gpu/drm/ttm/ttm_bo.c index 1fedd0eb67ba..f1367107925b 100644 > --- a/drivers/gpu/drm/ttm/ttm_bo.c > +++ b/drivers/gpu/drm/ttm/ttm_bo.c > @@ -1159,9 +1159,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_move_to_pinned(bo); > @@ -1215,7 +1215,7 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx, > 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)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 1fedd0eb67ba..f1367107925b 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1159,9 +1159,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_move_to_pinned(bo); @@ -1215,7 +1215,7 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx, 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)