1 From 148a71ff2bcaa40142c21b22a5c25b075607a959 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Tue, 5 Dec 2023 16:40:40 +0100
4 Subject: drm/ttm: return ENOSPC from ttm_bo_mem_space v3
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 From: Christian König <christian.koenig@amd.com>
11 [ Upstream commit 28e5126718c7b306b8c29d2ae8f48417e9303aa1 ]
13 Only convert it to ENOMEM in ttm_bo_validate.
15 This allows ttm_bo_validate to distinguish between an out of memory
16 situation and just out of space in a placement domain.
18 v2: improve commit message
19 v3: fix kerneldoc typos
21 Signed-off-by: Christian König <christian.koenig@amd.com>
22 Reviewed-by: Zack Rusin <zack.rusin@broadcom.com>
23 Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
24 Link: https://patchwork.freedesktop.org/patch/msgid/20240112125158.2748-3-christian.koenig@amd.com
25 Signed-off-by: Sasha Levin <sashal@kernel.org>
27 drivers/gpu/drm/ttm/ttm_bo.c | 7 +++++--
28 1 file changed, 5 insertions(+), 2 deletions(-)
30 diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
31 index edf10618fe2b2..f95b0406ca995 100644
32 --- a/drivers/gpu/drm/ttm/ttm_bo.c
33 +++ b/drivers/gpu/drm/ttm/ttm_bo.c
34 @@ -770,7 +770,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
35 * This function may sleep while waiting for space to become available.
37 * -EBUSY: No space available (only if no_wait == 1).
38 - * -ENOMEM: Could not allocate memory for the buffer object, either due to
39 + * -ENOSPC: Could not allocate space for the buffer object, either due to
40 * fragmentation or concurrent allocators.
41 * -ERESTARTSYS: An interruptible sleep was interrupted by a signal.
43 @@ -830,7 +830,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
50 pr_err(TTM_PFX "No compatible memory type found\n");
52 @@ -916,6 +916,9 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
55 ret = ttm_bo_move_buffer(bo, placement, ctx);
56 + /* For backward compatibility with userspace */