[PATCH v2] drm/ttm: Should to return the evict error

Chen, Xiaogang xiaogang.chen at amd.com
Wed May 28 21:14:44 UTC 2025


On 5/28/2025 1:19 AM, Deng, Emily wrote:
>
> [AMD Official Use Only - AMD Internal Distribution Only]
>
>
> *From:*amd-gfx <amd-gfx-bounces at lists.freedesktop.org> *On Behalf Of 
> *Deng, Emily
> *Sent:* Monday, May 26, 2025 9:51 AM
> *To:* Chen, Xiaogang <Xiaogang.Chen at amd.com>; 
> amd-gfx at lists.freedesktop.org
> *Subject:* RE: [PATCH v2] drm/ttm: Should to return the evict error
>
> [AMD Official Use Only - AMD Internal Distribution Only]
>
> [AMD Official Use Only - AMD Internal Distribution Only]
>
> *From:*Chen, Xiaogang <Xiaogang.Chen at amd.com>
> *Sent:* Friday, May 23, 2025 6:27 AM
> *To:* Deng, Emily <Emily.Deng at amd.com>; amd-gfx at lists.freedesktop.org
> *Subject:* Re: [PATCH v2] drm/ttm: Should to return the evict error
>
> On 5/21/2025 9:42 PM, Deng, Emily wrote:
>
>     [AMD Official Use Only - AMD Internal Distribution Only]
>
>     [AMD Official Use Only - AMD Internal Distribution Only]
>
>     Ping......
>
>     Emily Deng
>
>     Best Wishes
>
>         -----Original Message-----
>
>         From: Emily Deng<Emily.Deng at amd.com> <mailto:Emily.Deng at amd.com>
>
>         Sent: Wednesday, May 21, 2025 11:57 AM
>
>         To:amd-gfx at lists.freedesktop.org
>
>         Cc: Deng, Emily<Emily.Deng at amd.com> <mailto:Emily.Deng at amd.com>
>
>         Subject: [PATCH v2] drm/ttm: Should to return the evict error
>
>         For the evict fail case, the evict error should be returned.
>
>         v2: Consider ENOENT case.
>
>         Signed-off-by: Emily Deng<Emily.Deng at amd.com> <mailto:Emily.Deng at amd.com>
>
>         ---
>
>         drivers/gpu/drm/ttm/ttm_resource.c | 8 ++++----
>
>         1 file changed, 4 insertions(+), 4 deletions(-)
>
>         diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
>
>         index 097716bd248a..abf104ae9d35 100644
>
>         --- a/drivers/gpu/drm/ttm/ttm_resource.c
>
>         +++ b/drivers/gpu/drm/ttm/ttm_resource.c
>
>         @@ -511,12 +511,12 @@ int ttm_resource_manager_evict_all(struct ttm_device
>
>         *bdev,
>
>                        .force_alloc = true
>
>                };
>
>                struct dma_fence *fence;
>
>         -      int ret;
>
>         +      int ret, evict_ret = 0;
>
>                do {
>
>         -              ret = ttm_bo_evict_first(bdev, man, &ctx);
>
>         +              evict_ret = ttm_bo_evict_first(bdev, man, &ctx);
>
>                        cond_resched();
>
>         -      } while (!ret);
>
>         +      } while (!evict_ret);
>
>                spin_lock(&man->move_lock);
>
>                fence = dma_fence_get(man->move);
>
>         @@ -529,7 +529,7 @@ int ttm_resource_manager_evict_all(struct ttm_device *bdev,
>
>                                return ret;
>
>                }
>
>         -      return 0;
>
>         +      return (evict_ret == -ENOENT) ? 0 : evict_ret;
>
>         }
>
> Can you explain why you care ENOENT(No such file or directory) 
> specifically?
>
> Regards
>
> Xiaogang
>
> For ENOENT, it simply means the resource or file doesn't exist—it 
> doesn't indicate an error during eviction. We only need to focus on 
> actual eviction-related errors.
>
I think I know what you mean. But I have a different view on that. 
ttm_resource_manager_evict_all release all resources associated with a 
ttm_resource_manager(man). It is part of memory manager cleanup 
sequence. Even it fail(no matter what reason is) I think the following 
memory manager cleanup should still continue going, then the returned 
error value should not be used to stop following clean up.

I think @Christian König can give judgment on it.

Regards

Xiaogang

> Emily Deng
>
> Best Wishes
>
>         EXPORT_SYMBOL(ttm_resource_manager_evict_all);
>
>         --
>
>         2.34.1
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20250528/8aca2d40/attachment.htm>


More information about the amd-gfx mailing list