AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: validate the WPTR BO before handing its address to the MES
@ 2026-11-27 10:09 Jesse Zhang
  2026-11-27 10:37 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Jesse Zhang @ 2026-11-27 10:09 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alexander.Deucher, Christian Koenig, Sunil Khatri, Jesse Zhang

The unpinned WPTR BO can be evicted to SYSTEM before queue creation.
amdgpu_evf_mgr_attach_fence() skips validation when the eviction fence
is already signaled, leaving the BO in SYSTEM. Since resource->start
is zero, amdgpu_ttm_alloc_gart() also returns success without allocating
or binding GART space. mes_userq_create_wptr_mapping() then passes an
invalid GPU address to MES.

On Navi31, creating SDMA user queues during GTT eviction triggers:

  WARNING: amdgpu_object.c:1550 at amdgpu_bo_gpu_offset
   mes_userq_create_wptr_mapping
   mes_userq_mqd_create
   amdgpu_userq_ioctl

followed by page faults at address 0 and GPU resets.

Validate the BO into its allowed domains before allocating GART space,
as the restore path does. This removes the warning and address-zero
faults in the same test.

Fixes: 7264bc10c7c6 ("drm/amdgpu: dont pin wptr bo instead use eviction fence")
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
index 7abb9d95ef59..105c9866b2a3 100644
--- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
+++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c
@@ -37,6 +37,7 @@ mes_userq_create_wptr_mapping(struct amdgpu_device *adev,
 			      struct amdgpu_usermode_queue *queue,
 			      uint64_t wptr)
 {
+	struct ttm_operation_ctx ctx = { false, false };
 	struct amdgpu_bo_va_mapping *wptr_mapping;
 	struct amdgpu_userq_obj *wptr_obj = &queue->wptr_obj;
 	struct amdgpu_bo *obj;
@@ -84,6 +85,12 @@ mes_userq_create_wptr_mapping(struct amdgpu_device *adev,
 		goto fail_map;
 	}
 
+	/* The BO may have been evicted, it needs a GPU address for the MES */
+	amdgpu_bo_placement_from_domain(wptr_obj->obj, wptr_obj->obj->allowed_domains);
+	ret = ttm_bo_validate(&wptr_obj->obj->tbo, &wptr_obj->obj->placement, &ctx);
+	if (ret)
+		goto fail_map;
+
 	ret = amdgpu_ttm_alloc_gart(&wptr_obj->obj->tbo);
 	if (ret) {
 		DRM_ERROR("Failed to bind wptr bo to GART. ret %d\n", ret);
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-27 10:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 10:09 [PATCH] drm/amdgpu: validate the WPTR BO before handing its address to the MES Jesse Zhang
2026-11-27 10:37 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox