]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-6.8/drm-ttm-return-enospc-from-ttm_bo_mem_space-v3.patch
Fixes for 6.8
[thirdparty/kernel/stable-queue.git] / queue-6.8 / drm-ttm-return-enospc-from-ttm_bo_mem_space-v3.patch
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
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Christian König <christian.koenig@amd.com>
10
11 [ Upstream commit 28e5126718c7b306b8c29d2ae8f48417e9303aa1 ]
12
13 Only convert it to ENOMEM in ttm_bo_validate.
14
15 This allows ttm_bo_validate to distinguish between an out of memory
16 situation and just out of space in a placement domain.
17
18 v2: improve commit message
19 v3: fix kerneldoc typos
20
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>
26 ---
27 drivers/gpu/drm/ttm/ttm_bo.c | 7 +++++--
28 1 file changed, 5 insertions(+), 2 deletions(-)
29
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.
36 * Returns:
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.
42 */
43 @@ -830,7 +830,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
44 goto error;
45 }
46
47 - ret = -ENOMEM;
48 + ret = -ENOSPC;
49 if (!type_found) {
50 pr_err(TTM_PFX "No compatible memory type found\n");
51 ret = -EINVAL;
52 @@ -916,6 +916,9 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
53 return -EINVAL;
54
55 ret = ttm_bo_move_buffer(bo, placement, ctx);
56 + /* For backward compatibility with userspace */
57 + if (ret == -ENOSPC)
58 + return -ENOMEM;
59 if (ret)
60 return ret;
61
62 --
63 2.43.0
64