[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20241121212057.1526634-2-mtodorovac69@gmail.com>
Date: Thu, 21 Nov 2024 22:20:58 +0100
From: Mirsad Todorovac <mtodorovac69@...il.com>
To: Rodrigo Vivi <rodrigo.vivi@...el.com>,
intel-xe@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org
Cc: Lucas De Marchi <lucas.demarchi@...el.com>,
Thomas Hellström <thomas.hellstrom@...ux.intel.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>,
Mirsad Todorovac <mtodorovac69@...il.com>,
Matthew Brost <matthew.brost@...el.com>,
Matthew Auld <matthew.auld@...el.com>,
Matt Roper <matthew.d.roper@...el.com>,
Francois Dugast <francois.dugast@...el.com>,
Philippe Lecluse <philippe.lecluse@...el.com>,
Nirmoy Das <nirmoy.das@...el.com>,
Jani Nikula <jani.nikula@...el.com>,
José Roberto de Souza <jose.souza@...el.com>,
Faith Ekstrand <faith.ekstrand@...labora.com>,
Daniel Vetter <daniel.vetter@...ll.ch>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Akshata Jahagirdar <akshata.jahagirdar@...el.com>,
David Kershner <david.kershner@...el.com>
Subject: [PATCH v1 1/1] drm/xe: fix the ERR_PTR() returned on failure to allocate tiny pt
Running coccinelle spatch gave the following warning:
./drivers/gpu/drm/xe/tests/xe_migrate.c:226:5-11: inconsistent IS_ERR and PTR_ERR on line 228.
The code reports PTR_ERR(pt) when IS_ERR(tiny) is checked:
→ 211 pt = xe_bo_create_pin_map(xe, tile, m->q->vm, XE_PAGE_SIZE,
212 ttm_bo_type_kernel,
213 XE_BO_FLAG_VRAM_IF_DGFX(tile) |
214 XE_BO_FLAG_PINNED);
215 if (IS_ERR(pt)) {
216 KUNIT_FAIL(test, "Failed to allocate fake pt: %li\n",
217 PTR_ERR(pt));
218 goto free_big;
219 }
220
221 tiny = xe_bo_create_pin_map(xe, tile, m->q->vm,
→ 222 2 * SZ_4K,
223 ttm_bo_type_kernel,
224 XE_BO_FLAG_VRAM_IF_DGFX(tile) |
225 XE_BO_FLAG_PINNED);
→ 226 if (IS_ERR(tiny)) {
→ 227 KUNIT_FAIL(test, "Failed to allocate fake pt: %li\n",
→ 228 PTR_ERR(pt));
229 goto free_pt;
230 }
Now, the IS_ERR(tiny) and the corresponding PTR_ERR(pt) do not match.
Returning PTR_ERR(tiny), as the last failed function call, seems logical.
Fixes: dd08ebf6c3525 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
Cc: Matthew Brost <matthew.brost@...el.com>
Cc: Rodrigo Vivi <rodrigo.vivi@...el.com>
Cc: Matthew Auld <matthew.auld@...el.com>
Cc: Matt Roper <matthew.d.roper@...el.com>
Cc: "Thomas Hellström" <thomas.hellstrom@...ux.intel.com>
Cc: Francois Dugast <francois.dugast@...el.com>
Cc: Lucas De Marchi <lucas.demarchi@...el.com>
Cc: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>
Cc: Philippe Lecluse <philippe.lecluse@...el.com>
Cc: Nirmoy Das <nirmoy.das@...el.com>
Cc: Jani Nikula <jani.nikula@...el.com>
Cc: José Roberto de Souza <jose.souza@...el.com>
Cc: David Airlie <airlied@...il.com>
Cc: Maxime Ripard <mripard@...nel.org>
Cc: Faith Ekstrand <faith.ekstrand@...labora.com>
Cc: Daniel Vetter <daniel.vetter@...ll.ch>
Cc: Simona Vetter <simona@...ll.ch>
Cc: Mauro Carvalho Chehab <mchehab@...nel.org>
Cc: Thomas Zimmermann <tzimmermann@...e.de>
Cc: Akshata Jahagirdar <akshata.jahagirdar@...el.com>
Cc: David Kershner <david.kershner@...el.com>
Cc: intel-xe@...ts.freedesktop.org
Cc: dri-devel@...ts.freedesktop.org
Cc: linux-kernel@...r.kernel.org
Signed-off-by: Mirsad Todorovac <mtodorovac69@...il.com>
---
v1:
There is also the logical problem which this patch developer is not qualified to fix:
first the fake pt tries to allocate size of (1 << (XE_PT_SHIFT=12)) = 4096 bytes,
then "tiny pt" tries to allocate 2 * SZ_4K, twice as much. Is this what was meant
to accomplish?
drivers/gpu/drm/xe/xe_bo.h#L46:
#define XE_PTE_SHIFT 12
#define XE_PAGE_SIZE (1 << XE_PTE_SHIFT)
include/linux/sizes.h#L23:
#define SZ_4K 0x00001000
drivers/gpu/drm/xe/tests/xe_migrate.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/xe/tests/xe_migrate.c b/drivers/gpu/drm/xe/tests/xe_migrate.c
index 1a192a2a941b..3bbdb362d6f0 100644
--- a/drivers/gpu/drm/xe/tests/xe_migrate.c
+++ b/drivers/gpu/drm/xe/tests/xe_migrate.c
@@ -224,8 +224,8 @@ static void xe_migrate_sanity_test(struct xe_migrate *m, struct kunit *test)
XE_BO_FLAG_VRAM_IF_DGFX(tile) |
XE_BO_FLAG_PINNED);
if (IS_ERR(tiny)) {
- KUNIT_FAIL(test, "Failed to allocate fake pt: %li\n",
- PTR_ERR(pt));
+ KUNIT_FAIL(test, "Failed to allocate tiny fake pt: %li\n",
+ PTR_ERR(tiny));
goto free_pt;
}
--
2.43.0
Powered by blists - more mailing lists