]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/ttm: return ENOSPC from ttm_bo_mem_space v3
authorChristian König <christian.koenig@amd.com>
Tue, 5 Dec 2023 15:40:40 +0000 (16:40 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 13 Apr 2024 11:07:34 +0000 (13:07 +0200)
[ Upstream commit 28e5126718c7b306b8c29d2ae8f48417e9303aa1 ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/ttm/ttm_bo.c

index e58b7e2498166af73a105f234ba4f9ec0fcc2195..b3e5185835c37efb15a5720e0bc08a9bffbd1dd9 100644 (file)
@@ -764,7 +764,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
  * This function may sleep while waiting for space to become available.
  * Returns:
  * -EBUSY: No space available (only if no_wait == 1).
- * -ENOMEM: Could not allocate memory for the buffer object, either due to
+ * -ENOSPC: Could not allocate space for the buffer object, either due to
  * fragmentation or concurrent allocators.
  * -ERESTARTSYS: An interruptible sleep was interrupted by a signal.
  */
@@ -824,7 +824,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
                        goto error;
        }
 
-       ret = -ENOMEM;
+       ret = -ENOSPC;
        if (!type_found) {
                pr_err(TTM_PFX "No compatible memory type found\n");
                ret = -EINVAL;
@@ -910,6 +910,9 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
                return -EINVAL;
 
        ret = ttm_bo_move_buffer(bo, placement, ctx);
+       /* For backward compatibility with userspace */
+       if (ret == -ENOSPC)
+               return -ENOMEM;
        if (ret)
                return ret;