Skip to content

Commit 9a34b94

Browse files
Thomas Hellströmgregkh
authored andcommitted
drm/ttm: Convert -EAGAIN from dmem_cgroup_try_charge to -ENOSPC
commit 591711b32681a04b57d00c2a404658f8419a081c upstream. dmem_cgroup_try_charge() returns -EAGAIN when the cgroup limit is hit and the charge fails. TTM has no concept of -EAGAIN from resource allocation; -ENOSPC is the canonical error meaning "no space, try eviction". Convert at the source in ttm_resource_alloc() so no caller needs to handle an unexpected error code, and clean up the now-redundant -EAGAIN check in ttm_bo_alloc_resource(). Without this, -EAGAIN escaping ttm_resource_alloc() during an eviction walk causes the walk to terminate early instead of continuing to the next candidate. Cc: Friedrich Vock <friedrich.vock@gmx.de> Cc: Maarten Lankhorst <dev@lankhorst.se> Cc: Tejun Heo <tj@kernel.org> Cc: Maxime Ripard <mripard@kernel.org> Cc: Christian Koenig <christian.koenig@amd.com> Cc: dri-devel@lists.freedesktop.org Cc: <stable@vger.kernel.org> # v6.14+ Fixes: 2b624a2 ("drm/ttm: Handle cgroup based eviction in TTM") Assisted-by: GitHub_Copilot:claude-sonnet-4.6 Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Reviewed-by: Maarten Lankhorst <dev@lankhrost.se> Link: https://patch.msgid.link/20260508160920.230339-1-thomas.hellstrom@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 39fdac6 commit 9a34b94

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

drivers/gpu/drm/ttm/ttm_bo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ static int ttm_bo_alloc_resource(struct ttm_buffer_object *bo,
739739
may_evict = (force_space && place->mem_type != TTM_PL_SYSTEM);
740740
ret = ttm_resource_alloc(bo, place, res, force_space ? &limit_pool : NULL);
741741
if (ret) {
742-
if (ret != -ENOSPC && ret != -EAGAIN) {
742+
if (ret != -ENOSPC) {
743743
dmem_cgroup_pool_state_put(limit_pool);
744744
return ret;
745745
}

drivers/gpu/drm/ttm/ttm_resource.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,11 @@ int ttm_resource_alloc(struct ttm_buffer_object *bo,
384384

385385
if (man->cg) {
386386
ret = dmem_cgroup_try_charge(man->cg, bo->base.size, &pool, ret_limit_pool);
387-
if (ret)
387+
if (ret) {
388+
if (ret == -EAGAIN)
389+
ret = -ENOSPC;
388390
return ret;
391+
}
389392
}
390393

391394
ret = man->func->alloc(man, bo, place, res_ptr);

0 commit comments

Comments
 (0)