* [PATCH 1/3] drm/amdgpu: fix IB content read in the devcoredump
2026-12-02 22:34 [PATCH 0/3] drm/amdgpu: devcoredump and reset fixes Matt Turner
@ 2026-12-02 22:34 ` Matt Turner
2026-12-02 22:53 ` sashiko-bot
2026-12-02 22:34 ` [PATCH 2/3] drm/amdgpu: clear stale JPEG and VCN1 IP dump pointers Matt Turner
2026-12-02 22:34 ` [PATCH 3/3] drm/amdgpu: don't unmap legacy queues through MES during reset Matt Turner
2 siblings, 1 reply; 6+ messages in thread
From: Matt Turner @ 2026-12-02 22:34 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Pierre-Eric Pelloux-Prayer, Le Ma, Lijo Lazar
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner, Gregoire Pean
amdgpu_devcoredump_print_ibs() has several problems when reading the
contents of the IBs of the hung job:
- PRT mappings have a bo_va with no BO behind it, so an IB address that
falls into a PRT range dereferences a NULL BO in both the lock loop
and the copy loop.
- A BO without a resource (e.g. purged) is dereferenced via
tbo.resource->mem_type.
- The offset into the BO ignores mapping->offset, so for a mapping that
does not start at the beginning of its BO the wrong data is dumped.
- There is no check that the IB lies within the mapping, so a bogus IB
address or size from a misbehaving process reads outside the mapping,
possibly past the end of the BO.
- ttm_bo_kmap() maps the entire BO, which needlessly vmaps large BOs,
and the mapping is stored in abo->kmap, clobbering any kernel mapping
the driver already holds there.
- BOs with AMDGPU_GEM_CREATE_NO_CPU_ACCESS that have been moved to GTT
are skipped, while BOs in CPU invisible VRAM without that flag fail
in ttm_bo_kmap().
Skip mappings with no BO and BOs with no resource, honor
mapping->offset, and check that the IB lies within its mapping, which
amdgpu_vm_verify_parameters() already keeps within the BO. Read VRAM
through amdgpu_device_vram_access(), which uses the CPU visible
aperture where it can and MM_INDEX/MM_DATA for the rest, and kmap only
the pages covering the IB into a local map object for everything else.
Fixes: 7b15fc2d1f1a ("drm/amdgpu: dump job ibs in the devcoredump")
Suggested-by: Gregoire Pean <gpean@netflix.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 67 ++++++++++++++++--------
1 file changed, 46 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
index 30a8b4c5591d..0c6533b950f6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -209,6 +209,16 @@ static void amdgpu_devcoredump_fw_info(struct amdgpu_device *adev,
}
}
+static struct amdgpu_bo *
+amdgpu_devcoredump_mapping_bo(struct amdgpu_bo_va_mapping *mapping)
+{
+ /* PRT mappings have a bo_va with no BO behind it. */
+ if (!mapping || !mapping->bo_va)
+ return NULL;
+
+ return mapping->bo_va->base.bo;
+}
+
static void
amdgpu_devcoredump_print_ibs(struct drm_printer *p,
struct amdgpu_coredump_info *coredump,
@@ -259,10 +269,10 @@ amdgpu_devcoredump_print_ibs(struct drm_printer *p,
u64 addr = coredump->ibs[i].gpu_addr & AMDGPU_GMC_HOLE_MASK;
mapping = amdgpu_vm_bo_lookup_mapping(vm, addr);
- if (!mapping)
+ abo = amdgpu_devcoredump_mapping_bo(mapping);
+ if (!abo)
continue;
- abo = mapping->bo_va->base.bo;
r = drm_exec_lock_obj(&exec, &abo->tbo.base);
drm_exec_retry_on_contention(&exec);
if (r)
@@ -271,6 +281,7 @@ amdgpu_devcoredump_print_ibs(struct drm_printer *p,
}
for (int i = 0; i < coredump->num_ibs; i++) {
+ u64 size = (u64)coredump->ibs[i].ib_size_dw * 4;
bool emit_content = false;
ib_content = kvmalloc_array(coredump->ibs[i].ib_size_dw, 4,
@@ -280,41 +291,55 @@ amdgpu_devcoredump_print_ibs(struct drm_printer *p,
va_start = coredump->ibs[i].gpu_addr & AMDGPU_GMC_HOLE_MASK;
mapping = amdgpu_vm_bo_lookup_mapping(vm, va_start);
- if (!mapping)
+ abo = amdgpu_devcoredump_mapping_bo(mapping);
+ if (!abo || !abo->tbo.resource)
goto output_ib_content;
- abo = mapping->bo_va->base.bo;
- offset = va_start - mapping->start * AMDGPU_GPU_PAGE_SIZE;
+ if (va_start + size >
+ (mapping->last + 1) * AMDGPU_GPU_PAGE_SIZE)
+ goto output_ib_content;
- if (abo->flags & AMDGPU_GEM_CREATE_NO_CPU_ACCESS) {
+ offset = va_start - mapping->start * AMDGPU_GPU_PAGE_SIZE +
+ mapping->offset;
+
+ if (abo->tbo.resource->mem_type == TTM_PL_VRAM) {
struct amdgpu_res_cursor cursor;
off = 0;
-
- if (abo->tbo.resource->mem_type != TTM_PL_VRAM)
- goto output_ib_content;
-
- amdgpu_res_first(abo->tbo.resource, offset,
- coredump->ibs[i].ib_size_dw * 4, &cursor);
+ amdgpu_res_first(abo->tbo.resource, offset, size,
+ &cursor);
while (cursor.remaining) {
- amdgpu_device_mm_access(adev, cursor.start,
- &ib_content[off], cursor.size,
- false);
+ amdgpu_device_vram_access(adev, cursor.start,
+ &ib_content[off],
+ cursor.size, false);
off += cursor.size / 4;
amdgpu_res_next(&cursor, cursor.size);
}
emit_content = true;
} else {
- r = ttm_bo_kmap(&abo->tbo, 0, PFN_UP(abo->tbo.base.size),
- &abo->kmap);
+ struct ttm_bo_kmap_obj map;
+ unsigned long first = offset >> PAGE_SHIFT;
+ bool is_iomem;
+
+ /*
+ * Map only the pages backing the IB, into a local map
+ * object so a kernel mapping held in abo->kmap is left
+ * untouched.
+ */
+ r = ttm_bo_kmap(&abo->tbo, first,
+ PFN_UP(offset + size) - first, &map);
if (r)
goto output_ib_content;
- kptr = amdgpu_bo_kptr(abo);
- kptr += offset;
- memcpy(ib_content, kptr, coredump->ibs[i].ib_size_dw * 4);
+ kptr = ttm_kmap_obj_virtual(&map, &is_iomem);
+ kptr += offset_in_page(offset);
+ if (is_iomem)
+ memcpy_fromio(ib_content,
+ (void __iomem *)kptr, size);
+ else
+ memcpy(ib_content, kptr, size);
- amdgpu_bo_kunmap(abo);
+ ttm_bo_kunmap(&map);
emit_content = true;
}
--
2.56.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/3] drm/amdgpu: clear stale JPEG and VCN1 IP dump pointers
2026-12-02 22:34 [PATCH 0/3] drm/amdgpu: devcoredump and reset fixes Matt Turner
2026-12-02 22:34 ` [PATCH 1/3] drm/amdgpu: fix IB content read in the devcoredump Matt Turner
@ 2026-12-02 22:34 ` Matt Turner
2026-12-02 22:34 ` [PATCH 3/3] drm/amdgpu: don't unmap legacy queues through MES during reset Matt Turner
2 siblings, 0 replies; 6+ messages in thread
From: Matt Turner @ 2026-12-02 22:34 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Pierre-Eric Pelloux-Prayer, Le Ma, Lijo Lazar
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner, Jatin Kataria
amdgpu_jpeg_reg_dump_fini() and vcn_v1_0_sw_fini() free the IP dump
buffer but leave adev->jpeg.ip_dump and adev->vcn.ip_dump set. Clear
them, as amdgpu_vcn_reg_dump_fini() already does for the other VCN
versions, so that anything looking at them after teardown sees NULL
rather than a freed buffer.
Suggested-by: Jatin Kataria <jkataria@netflix.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c | 1 +
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c
index ec3833c79a01..9f31cb445aa5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c
@@ -501,6 +501,7 @@ int amdgpu_jpeg_reg_dump_init(struct amdgpu_device *adev,
static void amdgpu_jpeg_reg_dump_fini(struct amdgpu_device *adev)
{
kfree(adev->jpeg.ip_dump);
+ adev->jpeg.ip_dump = NULL;
adev->jpeg.reg_list = NULL;
adev->jpeg.reg_count = 0;
}
diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
index 897310d04f83..ee30cf1503ed 100644
--- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
@@ -233,6 +233,7 @@ static int vcn_v1_0_sw_fini(struct amdgpu_ip_block *ip_block)
amdgpu_vcn_sw_fini(adev, 0);
kfree(adev->vcn.ip_dump);
+ adev->vcn.ip_dump = NULL;
return 0;
}
--
2.56.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/3] drm/amdgpu: don't unmap legacy queues through MES during reset
2026-12-02 22:34 [PATCH 0/3] drm/amdgpu: devcoredump and reset fixes Matt Turner
2026-12-02 22:34 ` [PATCH 1/3] drm/amdgpu: fix IB content read in the devcoredump Matt Turner
2026-12-02 22:34 ` [PATCH 2/3] drm/amdgpu: clear stale JPEG and VCN1 IP dump pointers Matt Turner
@ 2026-12-02 22:34 ` Matt Turner
2026-12-02 22:48 ` sashiko-bot
2 siblings, 1 reply; 6+ messages in thread
From: Matt Turner @ 2026-12-02 22:34 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Pierre-Eric Pelloux-Prayer, Le Ma, Lijo Lazar
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner, Jatin Kataria
Commit 7b1ebbe856fc ("drm/amdgpu: Avoid kcq disable during reset")
made amdgpu_gfx_disable_kcq() and amdgpu_gfx_disable_kgq() skip the
KIQ unmap once a reset is in progress, since the reset tears down and
rebuilds the queues anyway. It did not cover the MES branch that
commit f7fb9d677faf ("drm/amdgpu/mes12: fix suspend issue") had added
to the same functions earlier.
When MES is hung, each of those unmap requests waits out the MES
submission timeout of about 2.1 seconds before failing, and the
failure is ignored, so recovery stalls for that long per queue for
nothing.
Skip the MES unmap during reset as well, matching the KIQ path.
Fixes: 7b1ebbe856fc ("drm/amdgpu: Avoid kcq disable during reset")
Suggested-by: Jatin Kataria <jkataria@netflix.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index c5a2dcff5058..0e9456b57577 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -586,6 +586,10 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id)
int j;
if (adev->enable_mes) {
+ /* As below for KIQ: the reset tears down and rebuilds the queues. */
+ if (amdgpu_in_reset(adev))
+ return 0;
+
for (i = 0; i < adev->gfx.num_compute_rings; i++) {
j = i + xcc_id * adev->gfx.num_compute_rings;
amdgpu_mes_unmap_legacy_queue(adev,
@@ -636,6 +640,10 @@ int amdgpu_gfx_disable_kgq(struct amdgpu_device *adev, int xcc_id)
int j;
if (adev->enable_mes) {
+ /* As below for KIQ: the reset tears down and rebuilds the queues. */
+ if (amdgpu_in_reset(adev))
+ return 0;
+
if (amdgpu_gfx_is_master_xcc(adev, xcc_id)) {
for (i = 0; i < adev->gfx.num_gfx_rings; i++) {
j = i + xcc_id * adev->gfx.num_gfx_rings;
--
2.56.1
^ permalink raw reply related [flat|nested] 6+ messages in thread