From: Matthew Auld <matthew.auld@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: "Christian König" <christian.koenig@amd.com>,
dri-devel@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH 2/4] drm/qxl: handle NULL bo->resource in move callback
Date: Wed, 8 Feb 2023 14:53:17 +0000 [thread overview]
Message-ID: <20230208145319.397235-2-matthew.auld@intel.com> (raw)
In-Reply-To: <20230208145319.397235-1-matthew.auld@intel.com>
The ttm bo now initially has NULL bo->resource, and leaves the driver
the handle that. However it looks like we forgot to handle that for qxl.
It looks like this will just null-ptr-deref in qxl_bo_move(), if
bo->resource is NULL.
Fix this by calling move_null() if the new resource is TTM_PL_SYSTEM,
otherwise do the multi-hop sequence to ensure can safely call into
ttm_bo_move_memcpy(), since it might also need to clear the memory.
This should give the same behaviour as before.
Fixes: 180253782038 ("drm/ttm: stop allocating dummy resources during BO creation")
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/qxl/qxl_ttm.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index a92a5b0d4c25..1a82629bce3f 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -143,6 +143,17 @@ static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,
struct ttm_resource *old_mem = bo->resource;
int ret;
+ if (!old_mem) {
+ if (new_mem->mem_type != TTM_PL_SYSTEM) {
+ hop->mem_type = TTM_PL_SYSTEM;
+ hop->flags = TTM_PL_FLAG_TEMPORARY;
+ return -EMULTIHOP;
+ }
+
+ ttm_bo_move_null(bo, new_mem);
+ return 0;
+ }
+
qxl_bo_move_notify(bo, new_mem);
ret = ttm_bo_wait_ctx(bo, ctx);
--
2.39.1
next prev parent reply other threads:[~2023-02-08 14:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-08 14:53 [Intel-gfx] [PATCH 1/4] drm/gem-vram: handle NULL bo->resource in move callback Matthew Auld
2023-02-08 14:53 ` Matthew Auld [this message]
2023-02-08 14:53 ` [Intel-gfx] [PATCH 3/4] drm/vmwgfx: " Matthew Auld
2023-02-08 14:53 ` [Intel-gfx] [PATCH 4/4] drm/radeon: " Matthew Auld
2023-02-08 15:19 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for series starting with [1/4] drm/gem-vram: " Patchwork
2023-02-08 19:01 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-02-09 8:47 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2023-02-10 11:03 ` [Intel-gfx] [PATCH 1/4] " Christian König
2023-02-21 16:13 ` Matthew Auld
2023-02-21 16:17 ` Christian König
2023-02-21 16:26 ` Matthew Auld
2023-02-21 16:27 ` Christian König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230208145319.397235-2-matthew.auld@intel.com \
--to=matthew.auld@intel.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox