Skip to content

Commit 28e5126

Browse files
drm/ttm: return ENOSPC from ttm_bo_mem_space v3
Only convert it to ENOMEM in ttm_bo_validate. This allows ttm_bo_validate to distinguish between an out of memory situation and just out of space in a placement domain. v2: improve commit message v3: fix kerneldoc typos Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Zack Rusin <zack.rusin@broadcom.com> Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240112125158.2748-3-christian.koenig@amd.com
1 parent bc77bde commit 28e5126

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/gpu/drm/ttm/ttm_bo.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
770770
* This function may sleep while waiting for space to become available.
771771
* Returns:
772772
* -EBUSY: No space available (only if no_wait == 1).
773-
* -ENOMEM: Could not allocate memory for the buffer object, either due to
773+
* -ENOSPC: Could not allocate space for the buffer object, either due to
774774
* fragmentation or concurrent allocators.
775775
* -ERESTARTSYS: An interruptible sleep was interrupted by a signal.
776776
*/
@@ -830,7 +830,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
830830
goto error;
831831
}
832832

833-
ret = -ENOMEM;
833+
ret = -ENOSPC;
834834
if (!type_found) {
835835
pr_err(TTM_PFX "No compatible memory type found\n");
836836
ret = -EINVAL;
@@ -916,6 +916,9 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
916916
return -EINVAL;
917917

918918
ret = ttm_bo_move_buffer(bo, placement, ctx);
919+
/* For backward compatibility with userspace */
920+
if (ret == -ENOSPC)
921+
return -ENOMEM;
919922
if (ret)
920923
return ret;
921924

0 commit comments

Comments
 (0)