* [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump
@ 2026-12-02 22:36 Matt Turner
2026-12-02 22:36 ` [PATCH 01/14] drm/amdgpu: dump the IP state of each device in an XGMI hive Matt Turner
` (13 more replies)
0 siblings, 14 replies; 15+ messages in thread
From: Matt Turner @ 2026-12-02 22:36 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Sunil Khatri,
Trigger Huang
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner, Gregoire Pean
The amdgpu devcoredump often doesn't have enough in it to tell why a
job hung, and some of what it has describes the wrong moment. The IB
contents are read from the coredump worker, which runs concurrently
with recovery, so by then the process may have been killed or VRAM
lost, and a later hang or fault can replace the IP registers and the
VM fault info before the dump is formatted. Nothing in the dump shows
which part of a ring belongs to which submission, which BO an address
belongs to, or what the memory the IBs point at contained. When a dump
is dropped, nothing says so.
Patches 1 to 5 fix dumps that describe the wrong state or are missing.
An XGMI hive dumped only the requesting device, and dumped it again
after suspending it, and every device in the hive was given the hung
job. A second hang could overwrite the IP registers while the first
dump was being formatted. Resets done by a reset handler produced no
coredump. The VM fault info was read when the dump was formatted rather
than when the hang was detected.
Patch 6 adds CP_STAT to the gfx10, gfx11 and gfx12 IP dumps, and the
IB2 progress registers to the per gfx queue dumps of gfx11 and gfx12.
Patches 7 and 8 copy the IB contents before formatting, and then from
the job timeout handler itself, before soft recovery or a reset can
change them. That path is a dma_fence signaling critical section, so
everything there is trylocked, allocated with GFP_NOWAIT and read
without the slow MMIO path for CPU invisible VRAM, and at most 8 MiB is
copied there so as not to hold up recovery. What can't be copied is
retried from the worker and marked as such.
Patches 9 to 12 add the submitting thread of the hung job, the
unsignaled fences of each ring, a count of dropped dumps, and the VM
mappings of the hung job.
Patch 13 adds AMDGPU_VM_PAGE_DUMP, a mapping flag with which userspace
asks for the contents of a mapping to be included in the coredump,
subject to size limits. The RADV side is
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/47015.
Patch 14 bumps the coredump version, since the format has changed.
This series depends on "drm/amdgpu: fix IB content read in the
devcoredump" from the "drm/amdgpu: devcoredump and reset fixes"
series, and not on the other patches there.
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
Matt Turner (14):
drm/amdgpu: dump the IP state of each device in an XGMI hive
drm/amdgpu: only give the hung job to its own device's coredump
drm/amdgpu: don't overwrite the IP state while a coredump is formatted
drm/amdgpu: take a coredump before resets done by a reset handler
drm/amdgpu: copy the VM fault info when the hang is detected
drm/amdgpu/gfx10-12: dump CP_STAT and the IB2 state of each gfx queue
drm/amdgpu: copy the IB contents before formatting the devcoredump
drm/amdgpu: copy the IB contents when the hang is detected
drm/amdgpu: record the submitting thread of the hung job in the coredump
drm/amdgpu: dump the unsignaled fences of each ring in the coredump
drm/amdgpu: report dropped devcoredumps
drm/amdgpu: list the VM mappings of the hung job in the coredump
drm/amdgpu: add AMDGPU_VM_PAGE_DUMP to include BOs in the coredump
drm/amdgpu: bump the devcoredump version
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 +
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 5 +
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 980 ++++++++++++++++++++---
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h | 74 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 31 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 9 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 12 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 6 +
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 40 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 3 +
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 57 ++
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 5 +
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 1 +
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 5 +
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 5 +
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 1 +
include/uapi/drm/amdgpu_drm.h | 6 +
19 files changed, 1096 insertions(+), 155 deletions(-)
---
base-commit: 83558fcf83cc911e09962ea17c883add596766c0
change-id: 20261118-amdgpu-devcoredump-fd7a93c870e1
prerequisite-patch-id: f4f8e95c172ec46bce86f4a08b00117c7e8edd73
Best regards,
--
Matt Turner <mattst88@gmail.com>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 01/14] drm/amdgpu: dump the IP state of each device in an XGMI hive
2026-12-02 22:36 [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump Matt Turner
@ 2026-12-02 22:36 ` Matt Turner
2026-12-02 22:36 ` [PATCH 02/14] drm/amdgpu: only give the hung job to its own device's coredump Matt Turner
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Matt Turner @ 2026-12-02 22:36 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Sunil Khatri,
Trigger Huang
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner
amdgpu_device_pre_asic_reset() runs for every device in the reset list,
but dumps the IP state of reset_context->reset_req_dev rather than the
device it was called for. This was carried over from when the dump was
done once in amdgpu_do_asic_reset() for the first device in the list.
For an XGMI hive, the requesting device is first in the list, so the
dump for every later device dumps the requesting device again after its
IP blocks have been suspended, replacing its registers with the state
after suspend. The other devices are never dumped, yet
amdgpu_device_reinit_after_reset() emits a coredump for each of them.
Dump the device being prepared.
Fixes: 13d8850a3387 ("drm/amdgpu: trigger ip dump before suspend of IP's")
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index d0ed92761ef9..85a22af69ba4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -5133,7 +5133,6 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev,
{
struct amdgpu_job *job = NULL;
struct dma_fence *fence = NULL;
- struct amdgpu_device *tmp_adev = reset_context->reset_req_dev;
bool need_full_reset =
test_bit(AMDGPU_NEED_FULL_RESET, &reset_context->flags);
int i, r;
@@ -5199,13 +5198,13 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev,
need_full_reset = true;
if (!test_bit(AMDGPU_SKIP_COREDUMP, &reset_context->flags)) {
- dev_info(tmp_adev->dev, "Dumping IP State\n");
+ dev_info(adev->dev, "Dumping IP State\n");
/* Trigger ip dump before we reset the asic */
- for (i = 0; i < tmp_adev->num_ip_blocks; i++)
- if (tmp_adev->ip_blocks[i].version->funcs->dump_ip_state)
- tmp_adev->ip_blocks[i].version->funcs
- ->dump_ip_state((void *)&tmp_adev->ip_blocks[i]);
- dev_info(tmp_adev->dev, "Dumping IP State Completed\n");
+ for (i = 0; i < adev->num_ip_blocks; i++)
+ if (adev->ip_blocks[i].version->funcs->dump_ip_state)
+ adev->ip_blocks[i].version->funcs
+ ->dump_ip_state((void *)&adev->ip_blocks[i]);
+ dev_info(adev->dev, "Dumping IP State Completed\n");
}
if (need_full_reset)
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 02/14] drm/amdgpu: only give the hung job to its own device's coredump
2026-12-02 22:36 [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump Matt Turner
2026-12-02 22:36 ` [PATCH 01/14] drm/amdgpu: dump the IP state of each device in an XGMI hive Matt Turner
@ 2026-12-02 22:36 ` Matt Turner
2026-12-02 22:36 ` [PATCH 03/14] drm/amdgpu: don't overwrite the IP state while a coredump is formatted Matt Turner
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Matt Turner @ 2026-12-02 22:36 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Sunil Khatri,
Trigger Huang
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner
The job timeout handler takes a coredump for every device in an XGMI
hive and passes the hung job to each of them. The coredumps of the
other devices then name a ring of the requesting device as the one that
timed out, and include the IBs of a job that never ran on them.
Pass the job only to the coredump of the device it was submitted to.
amdgpu_device_reinit_after_reset() does the same, but cannot hit it
since commit c67db6a6a6be ("drm/amdgpu: Do core dump immediately when
job tmo"): the timeout handler is the only caller that gives
amdgpu_device_gpu_recover() a job, and it sets AMDGPU_SKIP_COREDUMP.
Change it too, so that it stays correct if another caller passes a job.
Fixes: 5e592956cc36 ("drm/amdgpu: add ring timeout information in devcoredump")
Fixes: c67db6a6a6be ("drm/amdgpu: Do core dump immediately when job tmo")
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++-
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 85a22af69ba4..4a98a667526d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -5262,7 +5262,9 @@ int amdgpu_device_reinit_after_reset(struct amdgpu_reset_context *reset_context)
vram_lost = amdgpu_device_check_vram_lost(tmp_adev);
if (!test_bit(AMDGPU_SKIP_COREDUMP, &reset_context->flags))
- amdgpu_coredump(tmp_adev, false, vram_lost, reset_context->job);
+ amdgpu_coredump(tmp_adev, false, vram_lost,
+ tmp_adev == reset_context->reset_req_dev ?
+ reset_context->job : NULL);
if (vram_lost) {
dev_info(
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
index 8689a3c933b2..fa13d7beba80 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
@@ -77,7 +77,7 @@ static void amdgpu_job_core_dump(struct amdgpu_device *adev,
/* Do the coredump for each device */
list_for_each_entry(tmp_adev, device_list_handle, reset_list)
- amdgpu_job_do_core_dump(tmp_adev, job);
+ amdgpu_job_do_core_dump(tmp_adev, tmp_adev == adev ? job : NULL);
if (hive) {
mutex_unlock(&hive->hive_lock);
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 03/14] drm/amdgpu: don't overwrite the IP state while a coredump is formatted
2026-12-02 22:36 [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump Matt Turner
2026-12-02 22:36 ` [PATCH 01/14] drm/amdgpu: dump the IP state of each device in an XGMI hive Matt Turner
2026-12-02 22:36 ` [PATCH 02/14] drm/amdgpu: only give the hung job to its own device's coredump Matt Turner
@ 2026-12-02 22:36 ` Matt Turner
2026-12-02 22:36 ` [PATCH 04/14] drm/amdgpu: take a coredump before resets done by a reset handler Matt Turner
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Matt Turner @ 2026-12-02 22:36 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Sunil Khatri,
Trigger Huang
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner
The IP blocks' dump_ip_state() saves their registers into per device
arrays, and the coredump worker prints them from there with
print_ip_state() while it formats the dump, concurrently with recovery.
A hang detected while the worker is still busy runs dump_ip_state()
again and overwrites the arrays under the worker, so the first dump can
mix the registers of two hangs. The second hang's coredump is then
dropped because the worker is busy, so the overwrite gains nothing.
Move the dump into amdgpu_coredump_dump_ip_state(), which skips it while
the worker is busy and records whether it ran. amdgpu_coredump() takes
that into the coredump and clears it, so if the worker finishes between
the two, the new dump says the IP state is unavailable instead of
showing the previous hang's registers. The callers all run on the reset
domain's workqueue, so no other dump can come in between.
Fixes: af8644121e3e ("drm/amdgpu: add ip dump for each ip in devcoredump")
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 +
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 56 +++++++++++++++++++++---
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h | 3 ++
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 ++---
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 10 +----
5 files changed, 59 insertions(+), 24 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 5dfb57e7c0b3..7eff62f4cdda 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -930,6 +930,8 @@ struct amdgpu_device {
#ifdef CONFIG_DEV_COREDUMP
struct amdgpu_coredump_info *coredump;
struct work_struct coredump_work;
+ /* the IP state was dumped for the next coredump */
+ bool coredump_ip_state_valid;
#endif
struct mutex benchmark_mutex;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
index 0c6533b950f6..0e235096977b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -29,6 +29,9 @@
#include "atom.h"
#ifndef CONFIG_DEV_COREDUMP
+void amdgpu_coredump_dump_ip_state(struct amdgpu_device *adev)
+{
+}
void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
bool vram_lost, struct amdgpu_job *job)
{
@@ -451,12 +454,17 @@ amdgpu_devcoredump_format(char *buffer, size_t count, struct amdgpu_coredump_inf
/* dump the ip state for each ip */
drm_printf(&p, "IP Dump\n");
- for (int i = 0; i < coredump->adev->num_ip_blocks; i++) {
- ip_block = &coredump->adev->ip_blocks[i];
- if (ip_block->version->funcs->print_ip_state) {
- drm_printf(&p, "IP: %s\n", ip_block->version->funcs->name);
- ip_block->version->funcs->print_ip_state(ip_block, &p);
- drm_printf(&p, "\n");
+ if (!coredump->ip_state_valid) {
+ drm_printf(&p, "unavailable\n\n");
+ } else {
+ for (int i = 0; i < coredump->adev->num_ip_blocks; i++) {
+ ip_block = &coredump->adev->ip_blocks[i];
+ if (ip_block->version->funcs->print_ip_state) {
+ drm_printf(&p, "IP: %s\n",
+ ip_block->version->funcs->name);
+ ip_block->version->funcs->print_ip_state(ip_block, &p);
+ drm_printf(&p, "\n");
+ }
}
}
@@ -566,6 +574,36 @@ static void amdgpu_devcoredump_deferred_work(struct work_struct *work)
adev->coredump = NULL;
}
+/**
+ * amdgpu_coredump_dump_ip_state - save the IP state for the next coredump
+ * @adev: amdgpu device pointer
+ *
+ * Run each IP block's dump_ip_state() so that the following amdgpu_coredump()
+ * can include the register state at the time of the hang.
+ *
+ * The coredump worker reads the saved registers while it formats a dump, so
+ * skip this while the worker is busy. Callers run on the reset domain's
+ * single threaded workqueue, so no other hang can be dumped in between.
+ */
+void amdgpu_coredump_dump_ip_state(struct amdgpu_device *adev)
+{
+ int i;
+
+ adev->coredump_ip_state_valid = false;
+
+ if (work_busy(&adev->coredump_work))
+ return;
+
+ dev_info(adev->dev, "Dumping IP State\n");
+ for (i = 0; i < adev->num_ip_blocks; i++)
+ if (adev->ip_blocks[i].version->funcs->dump_ip_state)
+ adev->ip_blocks[i].version->funcs
+ ->dump_ip_state((void *)&adev->ip_blocks[i]);
+ dev_info(adev->dev, "Dumping IP State Completed\n");
+
+ adev->coredump_ip_state_valid = true;
+}
+
void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
bool vram_lost, struct amdgpu_job *job)
{
@@ -575,8 +613,13 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
struct drm_sched_job *s_job;
u64 ring_count;
struct amdgpu_ring *ring;
+ bool ip_state_valid;
int i, idx;
+ /* Don't let a later coredump print this hang's IP state. */
+ ip_state_valid = adev->coredump_ip_state_valid;
+ adev->coredump_ip_state_valid = false;
+
/* No need to generate a new coredump if there's one in progress already. */
if (work_busy(&adev->coredump_work))
return;
@@ -590,6 +633,7 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
coredump->skip_vram_check = skip_vram_check;
coredump->reset_vram_lost = vram_lost;
+ coredump->ip_state_valid = ip_state_valid;
if (job && job->pasid) {
struct amdgpu_task_info *ti;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
index cb874d8c3394..54b323b007db 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
@@ -51,6 +51,8 @@ struct amdgpu_coredump_info {
bool skip_vram_check;
bool reset_vram_lost;
struct amdgpu_ring *ring;
+ /* the IP blocks' dump_ip_state() was run for this hang */
+ bool ip_state_valid;
struct amdgpu_coredump_ring *rings;
u32 num_rings;
@@ -68,6 +70,7 @@ struct amdgpu_coredump_info {
};
#endif
+void amdgpu_coredump_dump_ip_state(struct amdgpu_device *adev);
void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
bool vram_lost, struct amdgpu_job *job);
void amdgpu_coredump_init(struct amdgpu_device *adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 4a98a667526d..9b61589b891e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -5197,15 +5197,9 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev,
if (!amdgpu_sriov_vf(adev)) {
need_full_reset = true;
- if (!test_bit(AMDGPU_SKIP_COREDUMP, &reset_context->flags)) {
- dev_info(adev->dev, "Dumping IP State\n");
- /* Trigger ip dump before we reset the asic */
- for (i = 0; i < adev->num_ip_blocks; i++)
- if (adev->ip_blocks[i].version->funcs->dump_ip_state)
- adev->ip_blocks[i].version->funcs
- ->dump_ip_state((void *)&adev->ip_blocks[i]);
- dev_info(adev->dev, "Dumping IP State Completed\n");
- }
+ /* Trigger ip dump before we reset the asic */
+ if (!test_bit(AMDGPU_SKIP_COREDUMP, &reset_context->flags))
+ amdgpu_coredump_dump_ip_state(adev);
if (need_full_reset)
r = amdgpu_device_ip_suspend(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
index fa13d7beba80..e6d7514b0a02 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.c
@@ -36,15 +36,7 @@
static void amdgpu_job_do_core_dump(struct amdgpu_device *adev,
struct amdgpu_job *job)
{
- int i;
-
- dev_info(adev->dev, "Dumping IP State\n");
- for (i = 0; i < adev->num_ip_blocks; i++)
- if (adev->ip_blocks[i].version->funcs->dump_ip_state)
- adev->ip_blocks[i].version->funcs
- ->dump_ip_state((void *)&adev->ip_blocks[i]);
- dev_info(adev->dev, "Dumping IP State Completed\n");
-
+ amdgpu_coredump_dump_ip_state(adev);
amdgpu_coredump(adev, true, false, job);
}
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 04/14] drm/amdgpu: take a coredump before resets done by a reset handler
2026-12-02 22:36 [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump Matt Turner
` (2 preceding siblings ...)
2026-12-02 22:36 ` [PATCH 03/14] drm/amdgpu: don't overwrite the IP state while a coredump is formatted Matt Turner
@ 2026-12-02 22:36 ` Matt Turner
2026-12-02 22:36 ` [PATCH 05/14] drm/amdgpu: copy the VM fault info when the hang is detected Matt Turner
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Matt Turner @ 2026-12-02 22:36 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Sunil Khatri,
Trigger Huang
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner
With a reset handler, such as the mode2 handlers of aldebaran,
sienna_cichlid, SMU 13.0.10 and soc_v1_0, amdgpu_device_pre_asic_reset()
returns after the handler's prepare_hwcontext(), before dumping the IP
state. amdgpu_do_asic_reset() then returns after restore_hwcontext()
without calling amdgpu_device_reinit_after_reset(), where the default
reset method takes its coredump. So a recovery that is not started by a
job timeout, which takes its own coredump, produces no coredump when one
of these handlers does the reset.
Check whether a reset handler will be used, and if so dump the IP state
and take the coredump at the start of amdgpu_device_pre_asic_reset(),
before prepare_hwcontext() suspends the IP blocks and before the fences
are force completed, so that the dump still has the rings with
unsignaled fences. The VRAM lost check is not known yet, so it is
reported as skipped, as for the coredump taken on a job timeout.
Factor the handler lookup out of amdgpu_reset_prepare_hwcontext() for
the check, and use it in amdgpu_reset_perform_reset() as well, which
did not check for a get_reset_handler callback.
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 +++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c | 40 ++++++++++++++++++++++++------
drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h | 3 +++
3 files changed, 49 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 9b61589b891e..970669af110a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -5140,6 +5140,20 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev,
if (reset_context->reset_req_dev == adev)
job = reset_context->job;
+ /*
+ * A reset handler suspends the IP blocks itself in prepare_hwcontext()
+ * and restores them without amdgpu_device_reinit_after_reset(), which
+ * is where the coredump is taken for the default reset method. Take
+ * the coredump now, while the IP blocks still hold the state of the
+ * hang and before the fences are force completed.
+ */
+ if (!amdgpu_sriov_vf(adev) &&
+ !test_bit(AMDGPU_SKIP_COREDUMP, &reset_context->flags) &&
+ amdgpu_reset_has_handler(adev, reset_context)) {
+ amdgpu_coredump_dump_ip_state(adev);
+ amdgpu_coredump(adev, true, false, job);
+ }
+
if (amdgpu_sriov_vf(adev))
amdgpu_virt_pre_reset(adev);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c
index c8016fa55a92..43ca25081213 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.c
@@ -232,14 +232,40 @@ int amdgpu_reset_fini(struct amdgpu_device *adev)
return ret;
}
+static struct amdgpu_reset_handler *
+amdgpu_reset_get_handler(struct amdgpu_device *adev,
+ struct amdgpu_reset_context *reset_context)
+{
+ if (!adev->reset_cntl || !adev->reset_cntl->get_reset_handler)
+ return NULL;
+
+ return adev->reset_cntl->get_reset_handler(adev->reset_cntl,
+ reset_context);
+}
+
+/**
+ * amdgpu_reset_has_handler - check whether a reset handler will be used
+ * @adev: amdgpu device pointer
+ * @reset_context: the reset context
+ *
+ * Like amdgpu_reset_prepare_hwcontext(), this may choose the reset method and
+ * store it in @reset_context if none was requested.
+ *
+ * Return: true if the reset described by @reset_context is done by one of the
+ * device's reset handlers rather than by the default method.
+ */
+bool amdgpu_reset_has_handler(struct amdgpu_device *adev,
+ struct amdgpu_reset_context *reset_context)
+{
+ return amdgpu_reset_get_handler(adev, reset_context);
+}
+
int amdgpu_reset_prepare_hwcontext(struct amdgpu_device *adev,
struct amdgpu_reset_context *reset_context)
{
- struct amdgpu_reset_handler *reset_handler = NULL;
+ struct amdgpu_reset_handler *reset_handler;
- if (adev->reset_cntl && adev->reset_cntl->get_reset_handler)
- reset_handler = adev->reset_cntl->get_reset_handler(
- adev->reset_cntl, reset_context);
+ reset_handler = amdgpu_reset_get_handler(adev, reset_context);
if (!reset_handler)
return -EOPNOTSUPP;
@@ -251,11 +277,9 @@ int amdgpu_reset_perform_reset(struct amdgpu_device *adev,
struct amdgpu_reset_context *reset_context)
{
int ret;
- struct amdgpu_reset_handler *reset_handler = NULL;
+ struct amdgpu_reset_handler *reset_handler;
- if (adev->reset_cntl)
- reset_handler = adev->reset_cntl->get_reset_handler(
- adev->reset_cntl, reset_context);
+ reset_handler = amdgpu_reset_get_handler(adev, reset_context);
if (!reset_handler)
return -EOPNOTSUPP;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h
index c9f23a8e8db8..6dac886de9a9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_reset.h
@@ -145,6 +145,9 @@ struct amdgpu_reset_domain {
int amdgpu_reset_init(struct amdgpu_device *adev);
int amdgpu_reset_fini(struct amdgpu_device *adev);
+bool amdgpu_reset_has_handler(struct amdgpu_device *adev,
+ struct amdgpu_reset_context *reset_context);
+
int amdgpu_reset_prepare_hwcontext(struct amdgpu_device *adev,
struct amdgpu_reset_context *reset_context);
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 05/14] drm/amdgpu: copy the VM fault info when the hang is detected
2026-12-02 22:36 [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump Matt Turner
` (3 preceding siblings ...)
2026-12-02 22:36 ` [PATCH 04/14] drm/amdgpu: take a coredump before resets done by a reset handler Matt Turner
@ 2026-12-02 22:36 ` Matt Turner
2026-12-02 22:36 ` [PATCH 06/14] drm/amdgpu/gfx10-12: dump CP_STAT and the IB2 state of each gfx queue Matt Turner
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Matt Turner @ 2026-12-02 22:36 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Sunil Khatri,
Trigger Huang
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner
The devcoredump prints adev->vm_manager.fault_info from the coredump
worker, which runs concurrently with recovery. A fault taken after the
hang was detected, for example by the next job after a queue reset,
replaces the cached fault, so the dump can report a fault that has
nothing to do with the hang.
Copy it in amdgpu_coredump_dump_ip_state() instead, under the PASID
lock that amdgpu_vm_update_fault_cache() holds while updating it, so
the copy is not torn either, and have amdgpu_coredump() take the copy
into the dump. Every amdgpu_coredump() call is preceded by
amdgpu_coredump_dump_ip_state(), and for a full reset that runs before
the IP blocks are suspended, rather than after the reset and resume
where the coredump is taken.
Fixes: 583681d4a417 ("drm/amdgpu: add vm fault information to devcoredump")
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 13 +++++++++++--
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h | 3 +++
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 7eff62f4cdda..c8ca96ce5bdc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -932,6 +932,8 @@ struct amdgpu_device {
struct work_struct coredump_work;
/* the IP state was dumped for the next coredump */
bool coredump_ip_state_valid;
+ /* the last VM fault when the IP state was dumped */
+ struct amdgpu_vm_fault_info coredump_fault_info;
#endif
struct mutex benchmark_mutex;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
index 0e235096977b..4d1b89527545 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -446,7 +446,7 @@ amdgpu_devcoredump_format(char *buffer, size_t count, struct amdgpu_coredump_inf
}
/* Add page fault information */
- fault_info = &coredump->adev->vm_manager.fault_info;
+ fault_info = &coredump->fault_info;
drm_printf(&p, "\n[%s] Page fault observed\n",
fault_info->vmhub ? "mmhub" : "gfxhub");
drm_printf(&p, "Faulty page starting at address: 0x%016llx\n", fault_info->addr);
@@ -579,7 +579,9 @@ static void amdgpu_devcoredump_deferred_work(struct work_struct *work)
* @adev: amdgpu device pointer
*
* Run each IP block's dump_ip_state() so that the following amdgpu_coredump()
- * can include the register state at the time of the hang.
+ * can include the register state at the time of the hang. Also copy the last
+ * VM fault, which a fault taken during recovery could replace before
+ * amdgpu_coredump() runs after a full reset.
*
* The coredump worker reads the saved registers while it formats a dump, so
* skip this while the worker is busy. Callers run on the reset domain's
@@ -587,8 +589,14 @@ static void amdgpu_devcoredump_deferred_work(struct work_struct *work)
*/
void amdgpu_coredump_dump_ip_state(struct amdgpu_device *adev)
{
+ unsigned long flags;
int i;
+ /* amdgpu_vm_update_fault_cache() updates it under the PASID lock. */
+ amdgpu_pasid_lock(&flags);
+ adev->coredump_fault_info = adev->vm_manager.fault_info;
+ amdgpu_pasid_unlock(flags);
+
adev->coredump_ip_state_valid = false;
if (work_busy(&adev->coredump_work))
@@ -634,6 +642,7 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
coredump->skip_vram_check = skip_vram_check;
coredump->reset_vram_lost = vram_lost;
coredump->ip_state_valid = ip_state_valid;
+ coredump->fault_info = adev->coredump_fault_info;
if (job && job->pasid) {
struct amdgpu_task_info *ti;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
index 54b323b007db..6836f312b3f8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
@@ -54,6 +54,9 @@ struct amdgpu_coredump_info {
/* the IP blocks' dump_ip_state() was run for this hang */
bool ip_state_valid;
+ /* the last VM fault when the hang was detected */
+ struct amdgpu_vm_fault_info fault_info;
+
struct amdgpu_coredump_ring *rings;
u32 num_rings;
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 06/14] drm/amdgpu/gfx10-12: dump CP_STAT and the IB2 state of each gfx queue
2026-12-02 22:36 [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump Matt Turner
` (4 preceding siblings ...)
2026-12-02 22:36 ` [PATCH 05/14] drm/amdgpu: copy the VM fault info when the hang is detected Matt Turner
@ 2026-12-02 22:36 ` Matt Turner
2026-12-02 22:36 ` [PATCH 07/14] drm/amdgpu: copy the IB contents before formatting the devcoredump Matt Turner
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Matt Turner @ 2026-12-02 22:36 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Sunil Khatri,
Trigger Huang
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner, Gregoire Pean
Add CP_STAT to the GC IP dump, for which CP blocks are busy when the
hang is detected.
How far the CP has fetched into an IB is already in the dump, as
CP_IB1_CMD_BUFSZ minus CP_IB1_BUFSZ (and the same for IB2), but the per
gfx queue lists on gfx11 and gfx12 only have the IB1 state. Add the IB2
base and sizes there too, so the fetch point can be found for IB2 as
well. GC 12.1 has no gfx queues, so it only gets CP_STAT.
CP_IB1_OFFSET and CP_IB2_OFFSET are not added: on gfx1151 they read 0
even when the CP is part way through the IB, so they are not the fetch
point.
Suggested-by: Gregoire Pean <gpean@netflix.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 1 +
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 5 +++++
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 5 +++++
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 1 +
4 files changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
index b28dd5eaf1bb..61accb360589 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
@@ -320,6 +320,7 @@ static const struct amdgpu_hwip_reg_entry gc_reg_list_10_1[] = {
SOC15_REG_ENTRY_STR(GC, 0, mmCP_IB2_BASE_LO),
SOC15_REG_ENTRY_STR(GC, 0, mmCP_IB2_BASE_HI),
SOC15_REG_ENTRY_STR(GC, 0, mmCP_IB2_BUFSZ),
+ SOC15_REG_ENTRY_STR(GC, 0, mmCP_STAT),
SOC15_REG_ENTRY_STR(GC, 0, mmCPF_UTCL1_STATUS),
SOC15_REG_ENTRY_STR(GC, 0, mmCPC_UTCL1_STATUS),
SOC15_REG_ENTRY_STR(GC, 0, mmCPG_UTCL1_STATUS),
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
index 570f0f3a2ea5..76b80f243dd2 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
@@ -192,6 +192,7 @@ static const struct amdgpu_hwip_reg_entry gc_reg_list_11_0[] = {
SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_BASE_LO),
SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_BASE_HI),
SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_BUFSZ),
+ SOC15_REG_ENTRY_STR(GC, 0, regCP_STAT),
SOC15_REG_ENTRY_STR(GC, 0, regCPF_UTCL1_STATUS),
SOC15_REG_ENTRY_STR(GC, 0, regCPC_UTCL1_STATUS),
SOC15_REG_ENTRY_STR(GC, 0, regCPG_UTCL1_STATUS),
@@ -313,6 +314,10 @@ static const struct amdgpu_hwip_reg_entry gc_gfx_queue_reg_list_11[] = {
SOC15_REG_ENTRY_STR(GC, 0, regCP_IB1_BASE_HI),
SOC15_REG_ENTRY_STR(GC, 0, regCP_IB1_CMD_BUFSZ),
SOC15_REG_ENTRY_STR(GC, 0, regCP_IB1_BUFSZ),
+ SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_BASE_LO),
+ SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_BASE_HI),
+ SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_CMD_BUFSZ),
+ SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_BUFSZ),
/* cp header registers */
SOC15_REG_ENTRY_STR(GC, 0, regCP_PFP_HEADER_DUMP),
SOC15_REG_ENTRY_STR(GC, 0, regCP_PFP_HEADER_DUMP),
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
index 09a27c3f6921..b31b1778b918 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
@@ -113,6 +113,7 @@ static const struct amdgpu_hwip_reg_entry gc_reg_list_12_0[] = {
SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_BASE_LO),
SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_BASE_HI),
SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_BUFSZ),
+ SOC15_REG_ENTRY_STR(GC, 0, regCP_STAT),
SOC15_REG_ENTRY_STR(GC, 0, regCPF_UTCL1_STATUS),
SOC15_REG_ENTRY_STR(GC, 0, regCPC_UTCL1_STATUS),
SOC15_REG_ENTRY_STR(GC, 0, regCPG_UTCL1_STATUS),
@@ -231,6 +232,10 @@ static const struct amdgpu_hwip_reg_entry gc_gfx_queue_reg_list_12[] = {
SOC15_REG_ENTRY_STR(GC, 0, regCP_IB1_BASE_HI),
SOC15_REG_ENTRY_STR(GC, 0, regCP_IB1_CMD_BUFSZ),
SOC15_REG_ENTRY_STR(GC, 0, regCP_IB1_BUFSZ),
+ SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_BASE_LO),
+ SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_BASE_HI),
+ SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_CMD_BUFSZ),
+ SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_BUFSZ),
/* cp header registers */
SOC15_REG_ENTRY_STR(GC, 0, regCP_PFP_HEADER_DUMP),
SOC15_REG_ENTRY_STR(GC, 0, regCP_PFP_HEADER_DUMP),
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c b/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
index c5d9d0dea4da..284258e56de4 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c
@@ -104,6 +104,7 @@ static const struct amdgpu_hwip_reg_entry gc_reg_list_12_1[] = {
SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_BASE_LO),
SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_BASE_HI),
SOC15_REG_ENTRY_STR(GC, 0, regCP_IB2_BUFSZ),
+ SOC15_REG_ENTRY_STR(GC, 0, regCP_STAT),
SOC15_REG_ENTRY_STR(GC, 0, regCPF_UTCL1_STATUS),
SOC15_REG_ENTRY_STR(GC, 0, regCPC_UTCL1_STATUS),
SOC15_REG_ENTRY_STR(GC, 0, regCPG_UTCL1_STATUS),
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 07/14] drm/amdgpu: copy the IB contents before formatting the devcoredump
2026-12-02 22:36 [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump Matt Turner
` (5 preceding siblings ...)
2026-12-02 22:36 ` [PATCH 06/14] drm/amdgpu/gfx10-12: dump CP_STAT and the IB2 state of each gfx queue Matt Turner
@ 2026-12-02 22:36 ` Matt Turner
2026-12-02 22:36 ` [PATCH 08/14] drm/amdgpu: copy the IB contents when the hang is detected Matt Turner
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Matt Turner @ 2026-12-02 22:36 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Sunil Khatri,
Trigger Huang
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner, Gregoire Pean
The IB contents are read from inside the formatting function, which
runs twice: once to size the output and once to fill it. The sizing
pass does not lock the VM, so it prints a placeholder for every dword,
and only the second pass reads the BOs and finds out whether an IB is
readable. Nothing records why one could not be read.
Copy the IB contents once from the coredump worker before formatting,
into a buffer per IB along with an error code explaining why the
contents are missing. Both formatting passes then print the same data,
and the dump says why an IB is absent. This replaces the ttm_bo_kmap()
based read from "drm/amdgpu: fix IB content read in the devcoredump".
The copy only needs a GPU address and a size within one mapping, so
describe it with a struct amdgpu_coredump_blob, which later changes use
to copy other ranges of the VM.
Factor the BO read into a helper that does not allocate and does not
map the whole BO. VRAM is read through amdgpu_device_vram_access() 4 KiB
at a time, so that the MM_INDEX/MM_DATA fallback for CPU invisible VRAM
never keeps interrupts disabled for long. System memory is read one
page at a time with kmap_local_page() when the kernel's linear mapping
of the pages can be used: TTM only gives it the caching of the BO on
x86, and maps decrypted BOs with pgprot_decrypted(), so other BOs are
read through ttm_bo_kmap() of just the range being copied. BOs whose
pages are not resident are refused.
The copies are freed once the dump is formatted, since reading the
dump only uses the formatted text.
Suggested-by: Gregoire Pean <gpean@netflix.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 319 +++++++++++++++--------
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h | 11 +
2 files changed, 224 insertions(+), 106 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
index 4d1b89527545..c3f01acc0e8c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -25,6 +25,7 @@
#include <linux/devcoredump.h>
#include <linux/utsname.h>
#include <drm/drm_exec.h>
+#include <drm/ttm/ttm_tt.h>
#include "amdgpu_dev_coredump.h"
#include "atom.h"
@@ -222,38 +223,157 @@ amdgpu_devcoredump_mapping_bo(struct amdgpu_bo_va_mapping *mapping)
return mapping->bo_va->base.bo;
}
-static void
-amdgpu_devcoredump_print_ibs(struct drm_printer *p,
- struct amdgpu_coredump_info *coredump,
- bool sizing_pass)
+/*
+ * Whether the pages of @ttm can be read through the kernel's linear mapping.
+ * TTM only gives that mapping the caching of the BO on x86, and maps the pages
+ * of a decrypted BO with pgprot_decrypted(), so read anything else through
+ * ttm_bo_kmap() as TTM does.
+ */
+static bool amdgpu_devcoredump_tt_linear_ok(struct ttm_tt *ttm)
+{
+ if (ttm->page_flags & TTM_TT_FLAG_DECRYPTED)
+ return false;
+
+ return ttm->caching == ttm_cached || IS_ENABLED(CONFIG_X86);
+}
+
+/*
+ * Copy @size bytes at @offset in @abo to @dst. The caller holds the BO's
+ * reservation. VRAM is read 4 KiB at a time, which bounds how long the
+ * MM_INDEX/MM_DATA fallback for CPU invisible VRAM keeps interrupts disabled
+ * whatever the page size.
+ */
+static int amdgpu_devcoredump_read_bo(struct amdgpu_bo *abo, u64 offset,
+ void *dst, u64 size)
+{
+ struct amdgpu_device *adev = amdgpu_ttm_adev(abo->tbo.bdev);
+ struct ttm_resource *res = abo->tbo.resource;
+ struct ttm_tt *ttm = abo->tbo.ttm;
+ struct ttm_bo_kmap_obj map;
+ bool is_iomem;
+ int r;
+
+ if (!res)
+ return -ENODATA;
+
+ if (!IS_ALIGNED(offset, 4) || !IS_ALIGNED(size, 4))
+ return -EINVAL;
+
+ switch (res->mem_type) {
+ case TTM_PL_VRAM: {
+ struct amdgpu_res_cursor cursor;
+
+ amdgpu_res_first(res, offset, size, &cursor);
+ while (cursor.remaining) {
+ u64 len = min_t(u64, cursor.size, SZ_4K);
+
+ amdgpu_device_vram_access(adev, cursor.start, dst, len,
+ false);
+ dst += len;
+ amdgpu_res_next(&cursor, len);
+ cond_resched();
+ }
+ return 0;
+ }
+ case TTM_PL_SYSTEM:
+ case TTM_PL_TT:
+ case AMDGPU_PL_PREEMPT:
+ if (!ttm || !ttm->pages)
+ return -EOPNOTSUPP;
+
+ if (!ttm_tt_is_populated(ttm) ||
+ ttm->page_flags & (TTM_TT_FLAG_SWAPPED | TTM_TT_FLAG_BACKED_UP))
+ return -ENODATA;
+
+ if (!amdgpu_devcoredump_tt_linear_ok(ttm)) {
+ pgoff_t first = offset >> PAGE_SHIFT;
+
+ r = ttm_bo_kmap(&abo->tbo, first,
+ PFN_UP(offset + size) - first, &map);
+ if (r)
+ return r;
+ memcpy(dst, ttm_kmap_obj_virtual(&map, &is_iomem) +
+ offset_in_page(offset), size);
+ ttm_bo_kunmap(&map);
+ return 0;
+ }
+
+ while (size) {
+ pgoff_t idx = offset >> PAGE_SHIFT;
+ size_t pg_off = offset_in_page(offset);
+ size_t len = min_t(u64, size, PAGE_SIZE - pg_off);
+ void *src;
+
+ if (idx >= ttm->num_pages || !ttm->pages[idx])
+ return -ENODATA;
+
+ src = kmap_local_page(ttm->pages[idx]);
+ memcpy(dst, src + pg_off, len);
+ kunmap_local(src);
+
+ dst += len;
+ offset += len;
+ size -= len;
+ cond_resched();
+ }
+ return 0;
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
+/*
+ * Copy a range of GPU memory, which must lie within a single mapping, into a
+ * newly allocated buffer. The VM root PD and the BO behind the mapping must be
+ * reserved by the caller.
+ */
+static int amdgpu_devcoredump_copy_blob(struct amdgpu_vm *vm,
+ struct amdgpu_coredump_blob *blob)
+{
+ struct amdgpu_bo_va_mapping *mapping;
+ struct amdgpu_bo *abo;
+ u64 offset;
+ void *data;
+ int r;
+
+ mapping = amdgpu_vm_bo_lookup_mapping(vm, blob->va);
+ abo = amdgpu_devcoredump_mapping_bo(mapping);
+ if (!abo)
+ return -ENOENT;
+
+ if (blob->va + blob->size > (mapping->last + 1) * AMDGPU_GPU_PAGE_SIZE)
+ return -ERANGE;
+
+ offset = blob->va - mapping->start * AMDGPU_GPU_PAGE_SIZE +
+ mapping->offset;
+
+ /* amdgpu_device_vram_access() can fail without telling us. */
+ data = kvzalloc(blob->size, GFP_KERNEL | __GFP_NOWARN);
+ if (!data)
+ return -ENOMEM;
+
+ r = amdgpu_devcoredump_read_bo(abo, offset, data, blob->size);
+ if (r) {
+ kvfree(data);
+ return r;
+ }
+
+ blob->data = data;
+ return 0;
+}
+
+/*
+ * Copy the contents of the IBs of the hung job, blocking on the reservation
+ * locks as needed. This runs from the coredump worker, before formatting, so
+ * that both formatting passes see the same data.
+ */
+static void amdgpu_devcoredump_capture_vm(struct amdgpu_coredump_info *coredump)
{
- struct amdgpu_device *adev = coredump->adev;
struct amdgpu_bo_va_mapping *mapping;
struct amdgpu_bo *abo;
struct drm_exec exec;
struct amdgpu_vm *vm;
- u32 *ib_content;
- u64 va_start, offset;
- u8 *kptr;
- u32 off;
- int r;
-
- /*
- * On the sizing pass there is no VM to look up and no BO to lock; the
- * size estimate doesn't depend on whether the IB BOs are reachable.
- * Just emit the per-IB headers (the content is not written anywhere).
- */
- if (sizing_pass) {
- for (int i = 0; i < coredump->num_ibs; i++) {
- drm_printf(p, "\nIB #%d 0x%llx %d dw\n", i,
- coredump->ibs[i].gpu_addr,
- coredump->ibs[i].ib_size_dw);
-
- for (int j = 0; j < coredump->ibs[i].ib_size_dw; j++)
- drm_printf(p, "0xffffffff\n");
- }
- return;
- }
+ int r = 0;
/*
* Lock the VM root PD and every IB BO together in a single drm_exec
@@ -264,14 +384,18 @@ amdgpu_devcoredump_print_ibs(struct drm_printer *p,
*/
drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES, 1 + coredump->num_ibs);
drm_exec_until_all_locked(&exec) {
- vm = amdgpu_vm_lock_by_pasid(adev, coredump->pasid, &exec);
- if (!vm)
+ /* Don't keep an -EDEADLK from a previous pass. */
+ r = 0;
+ vm = amdgpu_vm_lock_by_pasid(coredump->adev, coredump->pasid,
+ &exec);
+ if (!vm) {
+ r = -ESRCH;
goto unlock;
+ }
for (int i = 0; i < coredump->num_ibs; i++) {
- u64 addr = coredump->ibs[i].gpu_addr & AMDGPU_GMC_HOLE_MASK;
-
- mapping = amdgpu_vm_bo_lookup_mapping(vm, addr);
+ mapping = amdgpu_vm_bo_lookup_mapping(vm,
+ coredump->ibs[i].blob.va);
abo = amdgpu_devcoredump_mapping_bo(mapping);
if (!abo)
continue;
@@ -284,80 +408,47 @@ 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;
+ struct amdgpu_coredump_blob *blob = &coredump->ibs[i].blob;
- ib_content = kvmalloc_array(coredump->ibs[i].ib_size_dw, 4,
- GFP_KERNEL);
- if (!ib_content)
- continue;
-
- va_start = coredump->ibs[i].gpu_addr & AMDGPU_GMC_HOLE_MASK;
- mapping = amdgpu_vm_bo_lookup_mapping(vm, va_start);
- abo = amdgpu_devcoredump_mapping_bo(mapping);
- if (!abo || !abo->tbo.resource)
- goto output_ib_content;
-
- if (va_start + size >
- (mapping->last + 1) * AMDGPU_GPU_PAGE_SIZE)
- goto output_ib_content;
-
- 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;
- amdgpu_res_first(abo->tbo.resource, offset, size,
- &cursor);
- while (cursor.remaining) {
- 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 {
- 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 = 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);
-
- ttm_bo_kunmap(&map);
- emit_content = true;
- }
-
-output_ib_content:
- drm_printf(p, "\nIB #%d 0x%llx %d dw\n", i,
- coredump->ibs[i].gpu_addr, coredump->ibs[i].ib_size_dw);
- if (emit_content) {
- for (int j = 0; j < coredump->ibs[i].ib_size_dw; j++)
- drm_printf(p, "0x%08x\n", ib_content[j]);
- }
- kvfree(ib_content);
+ blob->status = amdgpu_devcoredump_copy_blob(vm, blob);
}
unlock:
drm_exec_fini(&exec);
+
+ if (r) {
+ for (int i = 0; i < coredump->num_ibs; i++)
+ coredump->ibs[i].blob.status = r;
+ }
+}
+
+/* Print the contents of a blob, or why they are missing. */
+static void amdgpu_devcoredump_print_blob(struct drm_printer *p,
+ struct amdgpu_coredump_blob *blob)
+{
+ const u32 *dw = blob->data;
+
+ if (!blob->data) {
+ drm_printf(p, "contents unavailable: %pe\n",
+ ERR_PTR(blob->status));
+ return;
+ }
+
+ for (u64 i = 0; i < blob->size / 4; i++)
+ drm_printf(p, "0x%08x\n", dw[i]);
+}
+
+static void
+amdgpu_devcoredump_print_ibs(struct drm_printer *p,
+ struct amdgpu_coredump_info *coredump)
+{
+ for (int i = 0; i < coredump->num_ibs; i++) {
+ struct amdgpu_coredump_ib_info *ib = &coredump->ibs[i];
+
+ drm_printf(p, "\nIB #%d 0x%llx %d dw\n", i, ib->gpu_addr,
+ ib->ib_size_dw);
+ amdgpu_devcoredump_print_blob(p, &ib->blob);
+ }
}
static ssize_t
@@ -370,9 +461,7 @@ amdgpu_devcoredump_format(char *buffer, size_t count, struct amdgpu_coredump_inf
struct amdgpu_ring *ring;
int ver, i, j;
u32 ring_idx;
- bool sizing_pass;
- sizing_pass = buffer == NULL;
iter.data = buffer;
iter.start = 0;
iter.offset = 0;
@@ -503,7 +592,7 @@ amdgpu_devcoredump_format(char *buffer, size_t count, struct amdgpu_coredump_inf
drm_printf(&p, "VRAM is lost due to GPU reset!\n");
if (coredump->num_ibs)
- amdgpu_devcoredump_print_ibs(&p, coredump, sizing_pass);
+ amdgpu_devcoredump_print_ibs(&p, coredump);
return count - iter.remain;
}
@@ -531,12 +620,22 @@ amdgpu_devcoredump_read(char *buffer, loff_t offset, size_t count,
return byte_copied;
}
+/* Free the copied memory, which is only needed to format the dump. */
+static void amdgpu_devcoredump_free_blobs(struct amdgpu_coredump_info *coredump)
+{
+ for (int i = 0; i < coredump->num_ibs; i++) {
+ kvfree(coredump->ibs[i].blob.data);
+ coredump->ibs[i].blob.data = NULL;
+ }
+}
+
static void amdgpu_devcoredump_free(void *data)
{
struct amdgpu_coredump_info *coredump = data;
u32 i;
kvfree(coredump->formatted);
+ amdgpu_devcoredump_free_blobs(coredump);
for (i = 0; i < coredump->num_rings; i++)
kvfree(coredump->rings[i].ring_dw);
kvfree(coredump->rings);
@@ -551,6 +650,9 @@ static void amdgpu_devcoredump_deferred_work(struct work_struct *work)
if (!coredump)
goto end;
+ if (coredump->num_ibs)
+ amdgpu_devcoredump_capture_vm(coredump);
+
/* Do a one-time preparation of the coredump output because
* repeatingly calling drm_coredump_printer is very slow.
*/
@@ -563,6 +665,7 @@ static void amdgpu_devcoredump_deferred_work(struct work_struct *work)
}
amdgpu_devcoredump_format(coredump->formatted, coredump->formatted_size, coredump);
+ amdgpu_devcoredump_free_blobs(coredump);
/* If there's an existing coredump for this device, the free function will be
* called immediately so coredump might be invalid after the call to dev_coredumpm.
@@ -656,8 +759,12 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
coredump->vmid = job->vmid;
coredump->num_ibs = job->num_ibs;
for (i = 0; i < job->num_ibs; ++i) {
- coredump->ibs[i].gpu_addr = job->ibs[i].gpu_addr;
- coredump->ibs[i].ib_size_dw = job->ibs[i].length_dw;
+ struct amdgpu_coredump_ib_info *ib = &coredump->ibs[i];
+
+ ib->gpu_addr = job->ibs[i].gpu_addr;
+ ib->ib_size_dw = job->ibs[i].length_dw;
+ ib->blob.va = ib->gpu_addr & AMDGPU_GMC_HOLE_MASK;
+ ib->blob.size = (u64)ib->ib_size_dw * 4;
}
}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
index 6836f312b3f8..ffcb08428631 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
@@ -38,9 +38,20 @@ struct amdgpu_coredump_ring {
u32 ring_index;
};
+/* A range of GPU memory copied into the coredump */
+struct amdgpu_coredump_blob {
+ /* GPU VA with the hole bits masked off, and size in bytes */
+ u64 va;
+ u64 size;
+ /* contents, or NULL with the reason in status */
+ void *data;
+ int status;
+};
+
struct amdgpu_coredump_ib_info {
uint64_t gpu_addr;
u32 ib_size_dw;
+ struct amdgpu_coredump_blob blob;
};
struct amdgpu_coredump_info {
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 08/14] drm/amdgpu: copy the IB contents when the hang is detected
2026-12-02 22:36 [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump Matt Turner
` (6 preceding siblings ...)
2026-12-02 22:36 ` [PATCH 07/14] drm/amdgpu: copy the IB contents before formatting the devcoredump Matt Turner
@ 2026-12-02 22:36 ` Matt Turner
2026-12-02 22:36 ` [PATCH 09/14] drm/amdgpu: record the submitting thread of the hung job in the coredump Matt Turner
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Matt Turner @ 2026-12-02 22:36 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Sunil Khatri,
Trigger Huang
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner, Gregoire Pean
amdgpu_coredump() is called from the job timeout handler before soft
recovery and queue reset, but the IB contents are only read later from
the coredump worker, which runs concurrently with recovery. By then the
process may have been killed and its BOs freed or evicted, or a reset
may have lost VRAM, so the dump either has no IB contents or contents
that no longer match what the GPU was executing.
Copy the IBs from amdgpu_coredump() itself, after the ring contents.
The timeout and reset paths are dma_fence signaling critical sections,
so look up the VM with a new amdgpu_vm_trylock_by_pasid() that trylocks
the root PD under the PASID lock, trylock IB BOs that do not share its
reservation object, and allocate with GFP_NOWAIT. VRAM is only read
through the CPU visible aperture there, since reading CPU invisible
VRAM through MM_INDEX/MM_DATA would hold up recovery, and system pages
that would need ttm_bo_kmap() are not read either. IBs that cannot
be copied for any of these reasons are retried from the worker as
before, and are marked in the dump as captured after recovery started.
Skip IBs larger than 4 MiB, since a GFP_NOWAIT allocation that large
is unlikely to succeed anyway. The copy runs in the timeout handler and
delays recovery, and a job can have up to 192 IBs, so copy at most
8 MiB in total there and leave the rest to the worker.
Suggested-by: Gregoire Pean <gpean@netflix.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 168 ++++++++++++++++++++---
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h | 2 +
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 35 +++++
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 +
4 files changed, 186 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 c3f01acc0e8c..033e1b94fcd7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -47,6 +47,15 @@ void amdgpu_coredump_fini(struct amdgpu_device *adev)
#define AMDGPU_CORE_DUMP_SIZE_MAX (256 * 1024 * 1024)
+/* Larger IBs are not copied into the coredump. */
+#define AMDGPU_COREDUMP_IB_MAX_BYTES SZ_4M
+
+/*
+ * Copying at hang time delays recovery, so only this much is copied then. The
+ * rest is left for the worker.
+ */
+#define AMDGPU_COREDUMP_NOWAIT_MAX_BYTES SZ_8M
+
const char *hw_ip_names[MAX_HWIP] = {
[GC_HWIP] = "GC",
[HDP_HWIP] = "HDP",
@@ -242,9 +251,14 @@ static bool amdgpu_devcoredump_tt_linear_ok(struct ttm_tt *ttm)
* reservation. VRAM is read 4 KiB at a time, which bounds how long the
* MM_INDEX/MM_DATA fallback for CPU invisible VRAM keeps interrupts disabled
* whatever the page size.
+ *
+ * With @nowait, which the timeout and reset paths use, nothing sleeps, and
+ * VRAM is only read through the CPU visible aperture: reading CPU invisible
+ * VRAM a dword at a time would hold up recovery, so it fails with -EBUSY and
+ * is left for the worker, as do system pages that need ttm_bo_kmap().
*/
static int amdgpu_devcoredump_read_bo(struct amdgpu_bo *abo, u64 offset,
- void *dst, u64 size)
+ void *dst, u64 size, bool nowait)
{
struct amdgpu_device *adev = amdgpu_ttm_adev(abo->tbo.bdev);
struct ttm_resource *res = abo->tbo.resource;
@@ -267,11 +281,17 @@ static int amdgpu_devcoredump_read_bo(struct amdgpu_bo *abo, u64 offset,
while (cursor.remaining) {
u64 len = min_t(u64, cursor.size, SZ_4K);
- amdgpu_device_vram_access(adev, cursor.start, dst, len,
- false);
+ if (!nowait)
+ amdgpu_device_vram_access(adev, cursor.start, dst,
+ len, false);
+ else if (!adev->mman.aper_base_kaddr ||
+ amdgpu_device_aper_access(adev, cursor.start, dst,
+ len, false) != len)
+ return -EBUSY;
dst += len;
amdgpu_res_next(&cursor, len);
- cond_resched();
+ if (!nowait)
+ cond_resched();
}
return 0;
}
@@ -288,6 +308,9 @@ static int amdgpu_devcoredump_read_bo(struct amdgpu_bo *abo, u64 offset,
if (!amdgpu_devcoredump_tt_linear_ok(ttm)) {
pgoff_t first = offset >> PAGE_SHIFT;
+ if (nowait)
+ return -EBUSY;
+
r = ttm_bo_kmap(&abo->tbo, first,
PFN_UP(offset + size) - first, &map);
if (r)
@@ -314,7 +337,8 @@ static int amdgpu_devcoredump_read_bo(struct amdgpu_bo *abo, u64 offset,
dst += len;
offset += len;
size -= len;
- cond_resched();
+ if (!nowait)
+ cond_resched();
}
return 0;
default:
@@ -324,13 +348,16 @@ static int amdgpu_devcoredump_read_bo(struct amdgpu_bo *abo, u64 offset,
/*
* Copy a range of GPU memory, which must lie within a single mapping, into a
- * newly allocated buffer. The VM root PD and the BO behind the mapping must be
- * reserved by the caller.
+ * newly allocated buffer. The VM root PD must be reserved by the caller. With
+ * @nowait the BO behind the mapping is trylocked here unless it shares the
+ * root PD's reservation object; otherwise the caller must have reserved it.
*/
static int amdgpu_devcoredump_copy_blob(struct amdgpu_vm *vm,
- struct amdgpu_coredump_blob *blob)
+ struct amdgpu_coredump_blob *blob,
+ bool nowait)
{
struct amdgpu_bo_va_mapping *mapping;
+ struct dma_resv *resv = NULL;
struct amdgpu_bo *abo;
u64 offset;
void *data;
@@ -348,11 +375,24 @@ static int amdgpu_devcoredump_copy_blob(struct amdgpu_vm *vm,
mapping->offset;
/* amdgpu_device_vram_access() can fail without telling us. */
- data = kvzalloc(blob->size, GFP_KERNEL | __GFP_NOWARN);
+ data = kvzalloc(blob->size,
+ (nowait ? GFP_NOWAIT : GFP_KERNEL) | __GFP_NOWARN);
if (!data)
return -ENOMEM;
- r = amdgpu_devcoredump_read_bo(abo, offset, data, blob->size);
+ if (nowait && abo->tbo.base.resv != vm->root.bo->tbo.base.resv) {
+ if (!dma_resv_trylock(abo->tbo.base.resv)) {
+ kvfree(data);
+ return -EBUSY;
+ }
+ resv = abo->tbo.base.resv;
+ }
+
+ r = amdgpu_devcoredump_read_bo(abo, offset, data, blob->size, nowait);
+
+ if (resv)
+ dma_resv_unlock(resv);
+
if (r) {
kvfree(data);
return r;
@@ -363,18 +403,86 @@ static int amdgpu_devcoredump_copy_blob(struct amdgpu_vm *vm,
}
/*
- * Copy the contents of the IBs of the hung job, blocking on the reservation
- * locks as needed. This runs from the coredump worker, before formatting, so
- * that both formatting passes see the same data.
+ * Whether a capture that failed with @status, or with -EAGAIN was not tried
+ * yet, could succeed in the worker.
*/
-static void amdgpu_devcoredump_capture_vm(struct amdgpu_coredump_info *coredump)
+static bool amdgpu_devcoredump_status_retry(int status)
+{
+ return status == -EAGAIN || status == -EBUSY || status == -ENOMEM;
+}
+
+static bool amdgpu_devcoredump_blob_retry(struct amdgpu_coredump_blob *blob)
+{
+ return !blob->data && amdgpu_devcoredump_status_retry(blob->status);
+}
+
+/* Copy @blob at hang time if it fits in what is left of @budget. */
+static void amdgpu_devcoredump_copy_blob_nowait(struct amdgpu_vm *vm,
+ struct amdgpu_coredump_blob *blob,
+ u64 *budget)
+{
+ if (blob->status != -EAGAIN || blob->size > *budget)
+ return;
+
+ *budget -= blob->size;
+ blob->status = amdgpu_devcoredump_copy_blob(vm, blob, true);
+}
+
+/*
+ * Capture the state of the hung job's VM at the time the hang is detected,
+ * before soft recovery, queue reset or a full GPU reset change it. This runs
+ * in the job timeout or GPU reset path, which is a dma_fence signaling
+ * critical section, so it must not block on reservation locks or allocate
+ * memory that may wait on reclaim: everything is trylocked, and what cannot
+ * be copied here is retried from the worker.
+ */
+static void
+amdgpu_devcoredump_capture_vm_nowait(struct amdgpu_device *adev,
+ struct amdgpu_coredump_info *coredump)
+{
+ u64 budget = AMDGPU_COREDUMP_NOWAIT_MAX_BYTES;
+ struct amdgpu_vm *vm;
+
+ vm = amdgpu_vm_trylock_by_pasid(adev, coredump->pasid);
+ if (IS_ERR(vm)) {
+ for (int i = 0; i < coredump->num_ibs; i++) {
+ struct amdgpu_coredump_blob *blob = &coredump->ibs[i].blob;
+
+ if (blob->status == -EAGAIN)
+ blob->status = PTR_ERR(vm);
+ }
+ return;
+ }
+
+ for (int i = 0; i < coredump->num_ibs; i++)
+ amdgpu_devcoredump_copy_blob_nowait(vm, &coredump->ibs[i].blob,
+ &budget);
+
+ dma_resv_unlock(vm->root.bo->tbo.base.resv);
+}
+
+/*
+ * Retry what could not be captured at hang time, blocking on the reservation
+ * locks as needed. This runs from the coredump worker, by which point recovery
+ * may have modified or freed the memory, so the result is marked as captured
+ * late.
+ */
+static void
+amdgpu_devcoredump_capture_vm_late(struct amdgpu_coredump_info *coredump)
{
struct amdgpu_bo_va_mapping *mapping;
+ struct amdgpu_coredump_blob *blob;
struct amdgpu_bo *abo;
struct drm_exec exec;
struct amdgpu_vm *vm;
+ bool retry = false;
int r = 0;
+ for (int i = 0; i < coredump->num_ibs; i++)
+ retry |= amdgpu_devcoredump_blob_retry(&coredump->ibs[i].blob);
+ if (!retry)
+ return;
+
/*
* Lock the VM root PD and every IB BO together in a single drm_exec
* ticket. Reserving the IB BOs one by one while the root PD is held
@@ -394,8 +502,11 @@ static void amdgpu_devcoredump_capture_vm(struct amdgpu_coredump_info *coredump)
}
for (int i = 0; i < coredump->num_ibs; i++) {
- mapping = amdgpu_vm_bo_lookup_mapping(vm,
- coredump->ibs[i].blob.va);
+ blob = &coredump->ibs[i].blob;
+ if (!amdgpu_devcoredump_blob_retry(blob))
+ continue;
+
+ mapping = amdgpu_vm_bo_lookup_mapping(vm, blob->va);
abo = amdgpu_devcoredump_mapping_bo(mapping);
if (!abo)
continue;
@@ -408,17 +519,23 @@ static void amdgpu_devcoredump_capture_vm(struct amdgpu_coredump_info *coredump)
}
for (int i = 0; i < coredump->num_ibs; i++) {
- struct amdgpu_coredump_blob *blob = &coredump->ibs[i].blob;
+ blob = &coredump->ibs[i].blob;
+ if (!amdgpu_devcoredump_blob_retry(blob))
+ continue;
- blob->status = amdgpu_devcoredump_copy_blob(vm, blob);
+ blob->status = amdgpu_devcoredump_copy_blob(vm, blob, false);
+ blob->late = !blob->status;
}
unlock:
drm_exec_fini(&exec);
if (r) {
- for (int i = 0; i < coredump->num_ibs; i++)
- coredump->ibs[i].blob.status = r;
+ for (int i = 0; i < coredump->num_ibs; i++) {
+ blob = &coredump->ibs[i].blob;
+ if (amdgpu_devcoredump_blob_retry(blob))
+ blob->status = r;
+ }
}
}
@@ -434,6 +551,9 @@ static void amdgpu_devcoredump_print_blob(struct drm_printer *p,
return;
}
+ if (blob->late)
+ drm_printf(p, "contents captured after recovery started\n");
+
for (u64 i = 0; i < blob->size / 4; i++)
drm_printf(p, "0x%08x\n", dw[i]);
}
@@ -651,7 +771,7 @@ static void amdgpu_devcoredump_deferred_work(struct work_struct *work)
goto end;
if (coredump->num_ibs)
- amdgpu_devcoredump_capture_vm(coredump);
+ amdgpu_devcoredump_capture_vm_late(coredump);
/* Do a one-time preparation of the coredump output because
* repeatingly calling drm_coredump_printer is very slow.
@@ -765,6 +885,9 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
ib->ib_size_dw = job->ibs[i].length_dw;
ib->blob.va = ib->gpu_addr & AMDGPU_GMC_HOLE_MASK;
ib->blob.size = (u64)ib->ib_size_dw * 4;
+ ib->blob.status =
+ ib->blob.size > AMDGPU_COREDUMP_IB_MAX_BYTES ?
+ -EFBIG : -EAGAIN;
}
}
@@ -812,6 +935,9 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
coredump->num_rings = idx;
}
+ if (coredump->num_ibs)
+ amdgpu_devcoredump_capture_vm_nowait(adev, coredump);
+
coredump->adev = adev;
ktime_get_ts64(&coredump->reset_time);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
index ffcb08428631..d62031369e56 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
@@ -46,6 +46,8 @@ struct amdgpu_coredump_blob {
/* contents, or NULL with the reason in status */
void *data;
int status;
+ /* copied by the worker rather than when the hang was detected */
+ bool late;
};
struct amdgpu_coredump_ib_info {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index a627a3092990..b03f3ee4d78c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -3106,6 +3106,41 @@ struct amdgpu_vm *amdgpu_vm_lock_by_pasid(struct amdgpu_device *adev,
return vm;
}
+/**
+ * amdgpu_vm_trylock_by_pasid - look up a VM by PASID and trylock its root PD
+ * @adev: amdgpu device pointer
+ * @pasid: PASID of the VM
+ *
+ * Like amdgpu_vm_lock_by_pasid(), but never sleeps, so it can be used from
+ * the job timeout and GPU reset paths. The root PD is trylocked under the
+ * PASID lock, and holding its reservation keeps the VM alive without a
+ * reference: amdgpu_driver_postclose_kms() clears the PASID's owner before
+ * amdgpu_vm_fini() reserves the root PD to free it. On success the caller
+ * must unlock vm->root.bo with dma_resv_unlock().
+ *
+ * Return: the VM on success, ERR_PTR(-ESRCH) if the PASID has no VM, or
+ * ERR_PTR(-EBUSY) if the root PD is contended.
+ */
+struct amdgpu_vm *amdgpu_vm_trylock_by_pasid(struct amdgpu_device *adev,
+ u32 pasid)
+{
+ struct amdgpu_vm *vm = ERR_PTR(-ESRCH);
+ struct amdgpu_fpriv *fpriv;
+ unsigned long irqflags;
+
+ amdgpu_pasid_lock(&irqflags);
+ fpriv = amdgpu_pasid_get_fpriv_locked(pasid);
+ if (fpriv && fpriv->vm.root.bo) {
+ if (dma_resv_trylock(fpriv->vm.root.bo->tbo.base.resv))
+ vm = &fpriv->vm;
+ else
+ vm = ERR_PTR(-EBUSY);
+ }
+ amdgpu_pasid_unlock(irqflags);
+
+ return vm;
+}
+
/**
* amdgpu_vm_handle_fault - graceful handling of VM faults.
* @adev: amdgpu device pointer
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index f6285a9d9e98..10fd477f7765 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -529,6 +529,8 @@ bool amdgpu_vm_handle_fault(struct amdgpu_device *adev, u32 pasid,
struct amdgpu_vm *amdgpu_vm_lock_by_pasid(struct amdgpu_device *adev,
u32 pasid, struct drm_exec *exec);
+struct amdgpu_vm *amdgpu_vm_trylock_by_pasid(struct amdgpu_device *adev,
+ u32 pasid);
void amdgpu_vm_set_task_info(struct amdgpu_vm *vm);
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 09/14] drm/amdgpu: record the submitting thread of the hung job in the coredump
2026-12-02 22:36 [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump Matt Turner
` (7 preceding siblings ...)
2026-12-02 22:36 ` [PATCH 08/14] drm/amdgpu: copy the IB contents when the hang is detected Matt Turner
@ 2026-12-02 22:36 ` Matt Turner
2026-12-02 22:36 ` [PATCH 10/14] drm/amdgpu: dump the unsignaled fences of each ring " Matt Turner
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Matt Turner @ 2026-12-02 22:36 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Sunil Khatri,
Trigger Huang
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner, Gregoire Pean
The process and thread in the devcoredump header come from the VM's
task info, which amdgpu_vm_set_task_info() updates on every submission
to record the thread that last submitted to the VM. In a multithreaded
process that is not necessarily the thread that submitted the job that
hung.
Record the submitting thread and its process in the job at CS time, as
amdgpu_vm_set_task_info() does for the VM, and print them in the
coredump header in the same layout as the VM's task info.
Suggested-by: Gregoire Pean <gpean@netflix.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 5 +++++
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 16 ++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h | 4 ++++
drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 6 ++++++
4 files changed, 31 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 71e2b83faa12..858a723ed667 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -311,6 +311,11 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p,
GFP_KERNEL, &p->jobs[i]);
if (ret)
goto free_all_kdata;
+ p->jobs[i]->submit_tgid = current->tgid;
+ p->jobs[i]->submit_pid = current->pid;
+ get_task_comm(p->jobs[i]->submit_process_name,
+ current->group_leader);
+ get_task_comm(p->jobs[i]->submit_comm, current);
switch (p->adev->enforce_isolation[fpriv->xcp_id]) {
case AMDGPU_ENFORCE_ISOLATION_DISABLE:
default:
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
index 033e1b94fcd7..62a0ae0aff87 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -604,6 +604,16 @@ amdgpu_devcoredump_format(char *buffer, size_t count, struct amdgpu_coredump_inf
coredump->reset_task_info.task.comm,
coredump->reset_task_info.task.pid);
+ /*
+ * The VM's task info above is the last thread that submitted to the
+ * VM; this is the thread that submitted the hung job.
+ */
+ if (coredump->submit_pid)
+ drm_printf(&p,
+ "submitter process_name: %s TGID: %d thread: %s PID: %d\n",
+ coredump->submit_process_name, coredump->submit_tgid,
+ coredump->submit_comm, coredump->submit_pid);
+
/* SOC Information */
drm_printf(&p, "\nSOC Information\n");
drm_printf(&p, "SOC Device id: %d\n", coredump->adev->pdev->device);
@@ -877,6 +887,12 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
}
coredump->pasid = job->pasid;
coredump->vmid = job->vmid;
+ coredump->submit_tgid = job->submit_tgid;
+ coredump->submit_pid = job->submit_pid;
+ memcpy(coredump->submit_process_name, job->submit_process_name,
+ sizeof(coredump->submit_process_name));
+ memcpy(coredump->submit_comm, job->submit_comm,
+ sizeof(coredump->submit_comm));
coredump->num_ibs = job->num_ibs;
for (i = 0; i < job->num_ibs; ++i) {
struct amdgpu_coredump_ib_info *ib = &coredump->ibs[i];
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
index d62031369e56..c0192d0c583a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
@@ -81,6 +81,10 @@ struct amdgpu_coredump_info {
unsigned int pasid;
unsigned int vmid;
+ pid_t submit_tgid;
+ pid_t submit_pid;
+ char submit_process_name[TASK_COMM_LEN];
+ char submit_comm[TASK_COMM_LEN];
int num_ibs;
struct amdgpu_coredump_ib_info ibs[] __counted_by(num_ibs);
};
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
index 18e788f0e790..0a6263781387 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_job.h
@@ -100,6 +100,12 @@ struct amdgpu_job {
bool enforce_isolation;
bool run_cleaner_shader;
+ /* thread that submitted the job, for the devcoredump */
+ pid_t submit_tgid;
+ pid_t submit_pid;
+ char submit_process_name[TASK_COMM_LEN];
+ char submit_comm[TASK_COMM_LEN];
+
uint32_t num_ibs;
struct amdgpu_ib ibs[];
};
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 10/14] drm/amdgpu: dump the unsignaled fences of each ring in the coredump
2026-12-02 22:36 [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump Matt Turner
` (8 preceding siblings ...)
2026-12-02 22:36 ` [PATCH 09/14] drm/amdgpu: record the submitting thread of the hung job in the coredump Matt Turner
@ 2026-12-02 22:36 ` Matt Turner
2026-12-02 22:36 ` [PATCH 11/14] drm/amdgpu: report dropped devcoredumps Matt Turner
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Matt Turner @ 2026-12-02 22:36 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Sunil Khatri,
Trigger Huang
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner, Gregoire Pean
The coredump has the ring contents and read and write pointers, but
nothing to tell which part of the ring belongs to which submission, or
which submissions were queued behind the hung one.
For each ring in the dump, record the last signaled and last emitted
sequence numbers and, for every unsignaled fence, its fence context,
the ring position and size of its commands as recorded for queue
reset, and how long ago it was emitted. This is captured along with
the ring contents, reading the fences under the fence driver lock into
a GFP_NOWAIT allocation.
Emitting a fence reuses its slot without the fence driver lock, and
polled fences take a seq without a slot, so a slot whose fence has a
different seqno is skipped. amdgpu_ib_schedule() sets the size of a job's
commands after emitting its fence, so mark that store and the read
with WRITE_ONCE() and READ_ONCE().
Suggested-by: Gregoire Pean <gpean@netflix.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 84 +++++++++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h | 15 +++++
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 9 ++-
3 files changed, 104 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
index 62a0ae0aff87..3cb1927b0f47 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -571,6 +571,84 @@ amdgpu_devcoredump_print_ibs(struct drm_printer *p,
}
}
+/*
+ * Record the unsignaled fences of @ring: for each, where the job was written
+ * to the ring and how long ago it was emitted. Together with the ring
+ * contents this shows which submissions were queued behind the hung one.
+ */
+static void amdgpu_devcoredump_capture_fences(struct amdgpu_ring *ring,
+ struct amdgpu_coredump_ring *cdump)
+{
+ struct amdgpu_fence_driver *drv = &ring->fence_drv;
+ unsigned long flags;
+ u32 count, seq;
+
+ cdump->last_seq = atomic_read(&drv->last_seq);
+ cdump->sync_seq = READ_ONCE(drv->sync_seq);
+
+ count = min(cdump->sync_seq - cdump->last_seq, drv->num_fences_mask + 1);
+ if (!count)
+ return;
+
+ cdump->fences = kvzalloc_objs(struct amdgpu_coredump_fence, count,
+ GFP_NOWAIT | __GFP_NOWARN);
+ if (!cdump->fences)
+ return;
+
+ spin_lock_irqsave(&drv->lock, flags);
+ rcu_read_lock();
+ for (seq = cdump->sync_seq - count + 1; count--; seq++) {
+ struct amdgpu_coredump_fence *cf;
+ struct dma_fence *f;
+ struct amdgpu_fence *af;
+
+ /*
+ * drv->lock doesn't keep the slots from being reused, and
+ * polled fences take a seq without a slot, so the slot may
+ * hold an older or newer fence.
+ */
+ f = rcu_dereference(drv->fences[seq & drv->num_fences_mask]);
+ if (!f || f->seqno != seq || dma_fence_test_signaled_flag(f))
+ continue;
+
+ af = container_of(f, struct amdgpu_fence, base);
+ cf = &cdump->fences[cdump->num_fences++];
+ cf->seq = seq;
+ cf->context = af->context;
+ cf->ib_wptr = af->ib_wptr;
+ /* 0 while the job is still being written to the ring */
+ cf->ib_dw_size = READ_ONCE(af->ib_dw_size);
+ cf->skip_ib_dw_start = af->skip_ib_dw_start_offset;
+ cf->skip_ib_dw_end = af->skip_ib_dw_end_offset;
+ /* Set before the slot, so it is not after this ktime_get(). */
+ cf->age_us = ktime_us_delta(ktime_get(), af->start_timestamp);
+ }
+ rcu_read_unlock();
+ spin_unlock_irqrestore(&drv->lock, flags);
+}
+
+static void amdgpu_devcoredump_print_fences(struct drm_printer *p,
+ struct amdgpu_coredump_ring *cdump)
+{
+ drm_printf(p, "Signaled seq: 0x%08x Emitted seq: 0x%08x\n",
+ cdump->last_seq, cdump->sync_seq);
+
+ if (cdump->last_seq != cdump->sync_seq && !cdump->fences) {
+ drm_printf(p, "Unsignaled fences unavailable\n");
+ return;
+ }
+
+ for (u32 i = 0; i < cdump->num_fences; i++) {
+ struct amdgpu_coredump_fence *cf = &cdump->fences[i];
+
+ drm_printf(p,
+ "fence seq: 0x%08x context: %llu wptr: 0x%llx dw: %u skip: %u-%u age: %lld us\n",
+ cf->seq, cf->context, cf->ib_wptr, cf->ib_dw_size,
+ cf->skip_ib_dw_start, cf->skip_ib_dw_end,
+ cf->age_us);
+ }
+}
+
static ssize_t
amdgpu_devcoredump_format(char *buffer, size_t count, struct amdgpu_coredump_info *coredump)
{
@@ -701,6 +779,7 @@ amdgpu_devcoredump_format(char *buffer, size_t count, struct amdgpu_coredump_inf
ring->buf_mask);
drm_printf(&p, "Ring size in dwords: %d\n",
ring->ring_size / 4);
+ amdgpu_devcoredump_print_fences(&p, &coredump->rings[i]);
if (!coredump->rings[i].ring_dw) {
drm_printf(&p, "Ring contents unavailable\n");
@@ -766,8 +845,10 @@ static void amdgpu_devcoredump_free(void *data)
kvfree(coredump->formatted);
amdgpu_devcoredump_free_blobs(coredump);
- for (i = 0; i < coredump->num_rings; i++)
+ for (i = 0; i < coredump->num_rings; i++) {
kvfree(coredump->rings[i].ring_dw);
+ kvfree(coredump->rings[i].fences);
+ }
kvfree(coredump->rings);
kvfree(data);
}
@@ -946,6 +1027,7 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
cdump_ring->ring_index = ring->idx;
cdump_ring->rptr = amdgpu_ring_get_rptr(ring);
cdump_ring->wptr = amdgpu_ring_get_wptr(ring);
+ amdgpu_devcoredump_capture_fences(ring, cdump_ring);
idx++;
}
coredump->num_rings = idx;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
index c0192d0c583a..6a51fbe357dc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
@@ -31,11 +31,26 @@
#define AMDGPU_COREDUMP_VERSION "1"
+struct amdgpu_coredump_fence {
+ u64 context;
+ u64 ib_wptr;
+ s64 age_us;
+ u32 seq;
+ u32 ib_dw_size;
+ u32 skip_ib_dw_start;
+ u32 skip_ib_dw_end;
+};
+
struct amdgpu_coredump_ring {
u64 rptr;
u64 wptr;
u32 *ring_dw;
u32 ring_index;
+ u32 last_seq;
+ u32 sync_seq;
+ /* unsignaled fences, oldest first */
+ struct amdgpu_coredump_fence *fences;
+ u32 num_fences;
};
/* A range of GPU memory copied into the coredump */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
index ae028eeacaed..5d16d6f5f9da 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
@@ -199,8 +199,10 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job,
/* VM sequence */
vm_af->ib_wptr = ring->wptr;
amdgpu_vm_flush(ring, job, &need_pipe_sync, &emit_gds_needed);
- vm_af->ib_dw_size =
- amdgpu_ring_get_dw_distance(ring, vm_af->ib_wptr, ring->wptr);
+ /* The devcoredump reads it locklessly once the fence is emitted. */
+ WRITE_ONCE(vm_af->ib_dw_size,
+ amdgpu_ring_get_dw_distance(ring, vm_af->ib_wptr,
+ ring->wptr));
/* IB sequence */
af->ib_wptr = ring->wptr;
@@ -318,7 +320,8 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job,
amdgpu_ring_ib_end(ring);
- af->ib_dw_size = amdgpu_ring_get_dw_distance(ring, af->ib_wptr, ring->wptr);
+ WRITE_ONCE(af->ib_dw_size,
+ amdgpu_ring_get_dw_distance(ring, af->ib_wptr, ring->wptr));
amdgpu_ring_commit(ring);
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 11/14] drm/amdgpu: report dropped devcoredumps
2026-12-02 22:36 [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump Matt Turner
` (9 preceding siblings ...)
2026-12-02 22:36 ` [PATCH 10/14] drm/amdgpu: dump the unsignaled fences of each ring " Matt Turner
@ 2026-12-02 22:36 ` Matt Turner
2026-12-02 22:36 ` [PATCH 12/14] drm/amdgpu: list the VM mappings of the hung job in the coredump Matt Turner
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Matt Turner @ 2026-12-02 22:36 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Sunil Khatri,
Trigger Huang
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner, Gregoire Pean
amdgpu_coredump() silently returns when the worker is still formatting
the previous dump or when allocating the dump fails, and the worker
silently frees the dump when allocating the formatted output fails.
Someone looking at a dump, or waiting for one, has no way to tell that
hangs were missed.
Warn when amdgpu drops a dump, count the dropped dumps, and print the
count in the header of each dump. It is a running total rather than the
count since the previous dump: dev_coredumpm() discards a new dump
while an earlier one for the device has not been read yet, without
telling the driver, and a count carried in the discarded dump would be
lost. Those discarded dumps are not counted, for the same reason.
Suggested-by: Gregoire Pean <gpean@netflix.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 28 ++++++++++++++++++++----
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h | 1 +
3 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index c8ca96ce5bdc..f40b5f062fd9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -930,6 +930,8 @@ struct amdgpu_device {
#ifdef CONFIG_DEV_COREDUMP
struct amdgpu_coredump_info *coredump;
struct work_struct coredump_work;
+ /* coredumps dropped since the device was initialized */
+ atomic_t coredump_dropped;
/* the IP state was dumped for the next coredump */
bool coredump_ip_state_valid;
/* the last VM fault when the IP state was dumped */
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
index 3cb1927b0f47..19e3a47ded79 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -672,6 +672,8 @@ amdgpu_devcoredump_format(char *buffer, size_t count, struct amdgpu_coredump_inf
drm_printf(&p, "kernel: %s\n", init_utsname()->release);
drm_printf(&p, "module: " KBUILD_MODNAME "\n");
drm_printf(&p, "time: %ptSp\n", &coredump->reset_time);
+ if (coredump->dropped)
+ drm_printf(&p, "dropped coredumps: %u\n", coredump->dropped);
drm_printf(&p, "pasid: %u\n", coredump->pasid);
drm_printf(&p, "vmid: %u\n", coredump->vmid);
@@ -869,8 +871,13 @@ static void amdgpu_devcoredump_deferred_work(struct work_struct *work)
*/
coredump->formatted_size = amdgpu_devcoredump_format(
NULL, AMDGPU_CORE_DUMP_SIZE_MAX, coredump);
- coredump->formatted = kvzalloc(coredump->formatted_size, GFP_KERNEL);
+ coredump->formatted = kvzalloc(coredump->formatted_size,
+ GFP_KERNEL | __GFP_NOWARN);
if (!coredump->formatted) {
+ atomic_inc(&adev->coredump_dropped);
+ drm_warn(adev_to_drm(adev),
+ "failed to allocate %zd bytes for coredump\n",
+ coredump->formatted_size);
amdgpu_devcoredump_free(coredump);
goto end;
}
@@ -943,15 +950,28 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
adev->coredump_ip_state_valid = false;
/* No need to generate a new coredump if there's one in progress already. */
- if (work_busy(&adev->coredump_work))
+ if (work_busy(&adev->coredump_work)) {
+ atomic_inc(&adev->coredump_dropped);
+ drm_warn_ratelimited(dev,
+ "previous coredump still being processed, dropping this one\n");
return;
+ }
if (job && job->pasid)
size += sizeof(struct amdgpu_coredump_ib_info) * job->num_ibs;
- coredump = kvzalloc(size, GFP_NOWAIT);
- if (!coredump)
+ coredump = kvzalloc(size, GFP_NOWAIT | __GFP_NOWARN);
+ if (!coredump) {
+ atomic_inc(&adev->coredump_dropped);
+ drm_warn_ratelimited(dev, "failed to allocate coredump\n");
return;
+ }
+
+ /*
+ * A running total rather than the count since the previous dump, which
+ * would be lost if dev_coredumpm() discards this dump.
+ */
+ coredump->dropped = atomic_read(&adev->coredump_dropped);
coredump->skip_vram_check = skip_vram_check;
coredump->reset_vram_lost = vram_lost;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
index 6a51fbe357dc..97d5fbe8320e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
@@ -94,6 +94,7 @@ struct amdgpu_coredump_info {
ssize_t formatted_size;
char *formatted;
+ unsigned int dropped;
unsigned int pasid;
unsigned int vmid;
pid_t submit_tgid;
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 12/14] drm/amdgpu: list the VM mappings of the hung job in the coredump
2026-12-02 22:36 [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump Matt Turner
` (10 preceding siblings ...)
2026-12-02 22:36 ` [PATCH 11/14] drm/amdgpu: report dropped devcoredumps Matt Turner
@ 2026-12-02 22:36 ` Matt Turner
2026-12-02 22:36 ` [PATCH 13/14] drm/amdgpu: add AMDGPU_VM_PAGE_DUMP to include BOs " Matt Turner
2026-12-02 22:36 ` [PATCH 14/14] drm/amdgpu: bump the devcoredump version Matt Turner
13 siblings, 0 replies; 15+ messages in thread
From: Matt Turner @ 2026-12-02 22:36 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Sunil Khatri,
Trigger Huang
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner, Gregoire Pean
The coredump has the addresses of the IBs of the hung job, and the IP
dump has addresses the hardware was accessing, but nothing to tell
which BO those addresses belong to, or whether they were mapped at all.
At hang time, under the same root PD trylock used to copy the IBs,
record every mapping of the job's VM: its address range, offset into
the BO, AMDGPU_VM_PAGE_* flags, and the size and current placement of
the BO behind it. A BO with its own reservation object can move under
us, so its placement is only read if the BO can be trylocked. Userspace
decides how many mappings there are, so the list is capped at 1024
mappings, which bounds the GFP_NOWAIT allocation and how long the root
PD is held, and the dump says when mappings were left out. If the root
PD is contended or the allocation fails, the list is made by the
coredump worker instead and marked as made after recovery started.
Add amdgpu_vm_bo_next_mapping() to iterate over a VM's mappings from
outside amdgpu_vm.c.
Suggested-by: Gregoire Pean <gpean@netflix.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 179 ++++++++++++++++++++++-
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h | 19 +++
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 22 +++
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 3 +
4 files changed, 218 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
index 19e3a47ded79..8395e9d35f7e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -56,6 +56,14 @@ void amdgpu_coredump_fini(struct amdgpu_device *adev)
*/
#define AMDGPU_COREDUMP_NOWAIT_MAX_BYTES SZ_8M
+/* Only this many VM mappings are listed in the coredump. */
+#define AMDGPU_COREDUMP_MAX_MAPPINGS 1024
+
+/* Placement of a mapping without a BO or whose BO has no backing store */
+#define AMDGPU_COREDUMP_MEM_TYPE_NONE -1
+/* Placement of a mapping whose BO could not be locked to read it */
+#define AMDGPU_COREDUMP_MEM_TYPE_UNKNOWN -2
+
const char *hw_ip_names[MAX_HWIP] = {
[GC_HWIP] = "GC",
[HDP_HWIP] = "HDP",
@@ -416,6 +424,79 @@ static bool amdgpu_devcoredump_blob_retry(struct amdgpu_coredump_blob *blob)
return !blob->data && amdgpu_devcoredump_status_retry(blob->status);
}
+/*
+ * Read the placement of @abo. A BO that does not share the root PD's
+ * reservation object can be moved concurrently, so its placement is only read
+ * if it can be trylocked.
+ */
+static int amdgpu_devcoredump_bo_mem_type(struct amdgpu_vm *vm,
+ struct amdgpu_bo *abo)
+{
+ struct dma_resv *resv = abo->tbo.base.resv;
+ bool shared = resv == vm->root.bo->tbo.base.resv;
+ int mem_type;
+
+ if (!shared && !dma_resv_trylock(resv))
+ return AMDGPU_COREDUMP_MEM_TYPE_UNKNOWN;
+
+ mem_type = abo->tbo.resource ? abo->tbo.resource->mem_type :
+ AMDGPU_COREDUMP_MEM_TYPE_NONE;
+
+ if (!shared)
+ dma_resv_unlock(resv);
+
+ return mem_type;
+}
+
+/*
+ * Record the address, BO and flags of the mappings of @vm. The VM root PD
+ * must be reserved by the caller.
+ */
+static int amdgpu_devcoredump_capture_mappings(struct amdgpu_vm *vm,
+ struct amdgpu_coredump_info *coredump,
+ bool nowait)
+{
+ struct amdgpu_bo_va_mapping *mapping = NULL;
+ u32 count = 0, n = 0;
+
+ /*
+ * Userspace decides how many mappings the VM has, so don't walk more
+ * of them than are listed while the root PD is held.
+ */
+ while (count <= AMDGPU_COREDUMP_MAX_MAPPINGS &&
+ (mapping = amdgpu_vm_bo_next_mapping(vm, mapping)))
+ count++;
+
+ coredump->more_mappings = count > AMDGPU_COREDUMP_MAX_MAPPINGS;
+ count = min(count, AMDGPU_COREDUMP_MAX_MAPPINGS);
+ if (!count)
+ return 0;
+
+ coredump->mappings = kvzalloc_objs(struct amdgpu_coredump_mapping, count,
+ (nowait ? GFP_NOWAIT : GFP_KERNEL) |
+ __GFP_NOWARN);
+ if (!coredump->mappings)
+ return -ENOMEM;
+
+ mapping = NULL;
+ while (n < count && (mapping = amdgpu_vm_bo_next_mapping(vm, mapping))) {
+ struct amdgpu_coredump_mapping *m = &coredump->mappings[n++];
+ struct amdgpu_bo *abo = amdgpu_devcoredump_mapping_bo(mapping);
+
+ m->va = mapping->start * AMDGPU_GPU_PAGE_SIZE;
+ m->size = (mapping->last - mapping->start + 1) *
+ AMDGPU_GPU_PAGE_SIZE;
+ m->offset = mapping->offset;
+ m->flags = mapping->flags;
+ m->bo_size = abo ? amdgpu_bo_size(abo) : 0;
+ m->mem_type = abo ? amdgpu_devcoredump_bo_mem_type(vm, abo) :
+ AMDGPU_COREDUMP_MEM_TYPE_NONE;
+ }
+ coredump->num_mappings = n;
+
+ return 0;
+}
+
/* Copy @blob at hang time if it fits in what is left of @budget. */
static void amdgpu_devcoredump_copy_blob_nowait(struct amdgpu_vm *vm,
struct amdgpu_coredump_blob *blob,
@@ -451,6 +532,7 @@ amdgpu_devcoredump_capture_vm_nowait(struct amdgpu_device *adev,
if (blob->status == -EAGAIN)
blob->status = PTR_ERR(vm);
}
+ coredump->mappings_status = PTR_ERR(vm);
return;
}
@@ -458,14 +540,92 @@ amdgpu_devcoredump_capture_vm_nowait(struct amdgpu_device *adev,
amdgpu_devcoredump_copy_blob_nowait(vm, &coredump->ibs[i].blob,
&budget);
+ coredump->mappings_status =
+ amdgpu_devcoredump_capture_mappings(vm, coredump, true);
+
dma_resv_unlock(vm->root.bo->tbo.base.resv);
}
+static const char *amdgpu_devcoredump_mem_type_name(int mem_type)
+{
+ switch (mem_type) {
+ case AMDGPU_COREDUMP_MEM_TYPE_NONE:
+ return "none";
+ case AMDGPU_COREDUMP_MEM_TYPE_UNKNOWN:
+ return "unknown";
+ case TTM_PL_SYSTEM:
+ return "CPU";
+ case TTM_PL_TT:
+ return "GTT";
+ case TTM_PL_VRAM:
+ return "VRAM";
+ case AMDGPU_PL_GDS:
+ return "GDS";
+ case AMDGPU_PL_GWS:
+ return "GWS";
+ case AMDGPU_PL_OA:
+ return "OA";
+ case AMDGPU_PL_PREEMPT:
+ return "PREEMPT";
+ case AMDGPU_PL_DOORBELL:
+ return "DOORBELL";
+ case AMDGPU_PL_MMIO_REMAP:
+ return "MMIO_REMAP";
+ default:
+ return "other";
+ }
+}
+
+static void
+amdgpu_devcoredump_print_mappings(struct drm_printer *p,
+ struct amdgpu_coredump_info *coredump)
+{
+ struct amdgpu_device *adev = coredump->adev;
+
+ if (coredump->mappings_status) {
+ drm_printf(p, "\nVM mappings unavailable: %pe\n",
+ ERR_PTR(coredump->mappings_status));
+ return;
+ }
+
+ drm_printf(p, "\nVM mappings: %u\n", coredump->num_mappings);
+ if (coredump->mappings_late)
+ drm_printf(p, "mappings listed after recovery started\n");
+
+ for (u32 i = 0; i < coredump->num_mappings; i++) {
+ struct amdgpu_coredump_mapping *m = &coredump->mappings[i];
+
+ drm_printf(p,
+ "0x%016llx-0x%016llx offset: 0x%llx flags: 0x%x bo_size: 0x%llx domain: %s\n",
+ amdgpu_gmc_sign_extend(m->va),
+ amdgpu_gmc_sign_extend(m->va + m->size - 1),
+ m->offset, m->flags, m->bo_size,
+ amdgpu_devcoredump_mem_type_name(m->mem_type));
+ }
+
+ if (coredump->more_mappings)
+ drm_printf(p, "more VM mappings not listed\n");
+}
+
+/*
+ * List the VM mappings if that failed at hang time. The VM root PD must be
+ * reserved by the caller.
+ */
+static void amdgpu_devcoredump_list_vm_late(struct amdgpu_vm *vm,
+ struct amdgpu_coredump_info *coredump)
+{
+ if (amdgpu_devcoredump_status_retry(coredump->mappings_status)) {
+ coredump->mappings_status =
+ amdgpu_devcoredump_capture_mappings(vm, coredump, false);
+ coredump->mappings_late = !coredump->mappings_status;
+ }
+}
+
/*
* Retry what could not be captured at hang time, blocking on the reservation
* locks as needed. This runs from the coredump worker, by which point recovery
- * may have modified or freed the memory, so the result is marked as captured
- * late.
+ * may have modified or freed the memory or changed the mappings, so the result
+ * is marked as captured late.
*/
static void
amdgpu_devcoredump_capture_vm_late(struct amdgpu_coredump_info *coredump)
@@ -475,9 +635,10 @@ amdgpu_devcoredump_capture_vm_late(struct amdgpu_coredump_info *coredump)
struct amdgpu_bo *abo;
struct drm_exec exec;
struct amdgpu_vm *vm;
- bool retry = false;
+ bool retry;
int r = 0;
+ retry = amdgpu_devcoredump_status_retry(coredump->mappings_status);
for (int i = 0; i < coredump->num_ibs; i++)
retry |= amdgpu_devcoredump_blob_retry(&coredump->ibs[i].blob);
if (!retry)
@@ -501,6 +662,8 @@ amdgpu_devcoredump_capture_vm_late(struct amdgpu_coredump_info *coredump)
goto unlock;
}
+ amdgpu_devcoredump_list_vm_late(vm, coredump);
+
for (int i = 0; i < coredump->num_ibs; i++) {
blob = &coredump->ibs[i].blob;
if (!amdgpu_devcoredump_blob_retry(blob))
@@ -531,6 +694,8 @@ amdgpu_devcoredump_capture_vm_late(struct amdgpu_coredump_info *coredump)
drm_exec_fini(&exec);
if (r) {
+ if (amdgpu_devcoredump_status_retry(coredump->mappings_status))
+ coredump->mappings_status = r;
for (int i = 0; i < coredump->num_ibs; i++) {
blob = &coredump->ibs[i].blob;
if (amdgpu_devcoredump_blob_retry(blob))
@@ -802,6 +967,9 @@ amdgpu_devcoredump_format(char *buffer, size_t count, struct amdgpu_coredump_inf
else if (coredump->reset_vram_lost)
drm_printf(&p, "VRAM is lost due to GPU reset!\n");
+ if (coredump->pasid)
+ amdgpu_devcoredump_print_mappings(&p, coredump);
+
if (coredump->num_ibs)
amdgpu_devcoredump_print_ibs(&p, coredump);
@@ -846,6 +1014,7 @@ static void amdgpu_devcoredump_free(void *data)
u32 i;
kvfree(coredump->formatted);
+ kvfree(coredump->mappings);
amdgpu_devcoredump_free_blobs(coredump);
for (i = 0; i < coredump->num_rings; i++) {
kvfree(coredump->rings[i].ring_dw);
@@ -863,7 +1032,7 @@ static void amdgpu_devcoredump_deferred_work(struct work_struct *work)
if (!coredump)
goto end;
- if (coredump->num_ibs)
+ if (coredump->pasid)
amdgpu_devcoredump_capture_vm_late(coredump);
/* Do a one-time preparation of the coredump output because
@@ -1053,7 +1222,7 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
coredump->num_rings = idx;
}
- if (coredump->num_ibs)
+ if (coredump->pasid)
amdgpu_devcoredump_capture_vm_nowait(adev, coredump);
coredump->adev = adev;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
index 97d5fbe8320e..844fc87f386e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
@@ -71,6 +71,16 @@ struct amdgpu_coredump_ib_info {
struct amdgpu_coredump_blob blob;
};
+struct amdgpu_coredump_mapping {
+ u64 va;
+ u64 size;
+ u64 offset;
+ u64 bo_size;
+ u32 flags;
+ /* TTM_PL_* of the BO, or AMDGPU_COREDUMP_MEM_TYPE_* */
+ int mem_type;
+};
+
struct amdgpu_coredump_info {
struct amdgpu_device *adev;
struct amdgpu_task_info reset_task_info;
@@ -97,6 +107,15 @@ struct amdgpu_coredump_info {
unsigned int dropped;
unsigned int pasid;
unsigned int vmid;
+ /* VM mappings of the hung job, or NULL with the reason in status */
+ struct amdgpu_coredump_mapping *mappings;
+ u32 num_mappings;
+ /* the VM has more than AMDGPU_COREDUMP_MAX_MAPPINGS mappings */
+ bool more_mappings;
+ int mappings_status;
+ /* listed by the worker rather than when the hang was detected */
+ bool mappings_late;
+
pid_t submit_tgid;
pid_t submit_pid;
char submit_process_name[TASK_COMM_LEN];
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index b03f3ee4d78c..159a22406db7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2201,6 +2201,28 @@ struct amdgpu_bo_va_mapping *amdgpu_vm_bo_lookup_mapping(struct amdgpu_vm *vm,
return amdgpu_vm_it_iter_first(&vm->va, addr, addr);
}
+/**
+ * amdgpu_vm_bo_next_mapping - iterate over all mappings of a VM
+ *
+ * @vm: the requested VM
+ * @mapping: the previous mapping, or NULL to start
+ *
+ * The VM root PD must be reserved by the caller.
+ *
+ * Returns:
+ * The mapping following @mapping in address order, the first mapping if
+ * @mapping is NULL, or NULL at the end.
+ */
+struct amdgpu_bo_va_mapping *
+amdgpu_vm_bo_next_mapping(struct amdgpu_vm *vm,
+ struct amdgpu_bo_va_mapping *mapping)
+{
+ if (!mapping)
+ return amdgpu_vm_it_iter_first(&vm->va, 0, U64_MAX);
+
+ return amdgpu_vm_it_iter_next(mapping, 0, U64_MAX);
+}
+
/**
* amdgpu_vm_bo_trace_cs - trace all reserved mappings
*
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
index 10fd477f7765..e74077d25029 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h
@@ -504,6 +504,9 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
uint64_t saddr, uint64_t size);
struct amdgpu_bo_va_mapping *amdgpu_vm_bo_lookup_mapping(struct amdgpu_vm *vm,
uint64_t addr);
+struct amdgpu_bo_va_mapping *
+amdgpu_vm_bo_next_mapping(struct amdgpu_vm *vm,
+ struct amdgpu_bo_va_mapping *mapping);
void amdgpu_vm_bo_trace_cs(struct amdgpu_vm *vm, struct ww_acquire_ctx *ticket);
void amdgpu_vm_bo_del(struct amdgpu_device *adev,
struct amdgpu_bo_va *bo_va);
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 13/14] drm/amdgpu: add AMDGPU_VM_PAGE_DUMP to include BOs in the coredump
2026-12-02 22:36 [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump Matt Turner
` (11 preceding siblings ...)
2026-12-02 22:36 ` [PATCH 12/14] drm/amdgpu: list the VM mappings of the hung job in the coredump Matt Turner
@ 2026-12-02 22:36 ` Matt Turner
2026-12-02 22:36 ` [PATCH 14/14] drm/amdgpu: bump the devcoredump version Matt Turner
13 siblings, 0 replies; 15+ messages in thread
From: Matt Turner @ 2026-12-02 22:36 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Sunil Khatri,
Trigger Huang
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner, Gregoire Pean
The coredump has the IBs of the hung job, but a hang often depends on
memory the IBs only point at: descriptors, shader binaries, indirect
draw arguments, or the user's own state. The kernel can't tell which of
the VM's mappings matter, but the userspace driver can.
Add AMDGPU_VM_PAGE_DUMP, a mapping flag that only asks for the contents
of the mapping to be included in the coredump when a job of that VM
hangs, like DRM_XE_VM_BIND_FLAG_DUMPABLE does for xe. It is stored with
the mapping like the other flags and ignored by the PTE code, which
only tests the bits it knows about.
At hang time, under the root PD trylock already used for the IBs, copy
the start of each flagged mapping: at most 64 mappings, 4 MiB of each
and 32 MiB in total, so a careless flag can't make every coredump huge.
The dump gives how many of the flagged mappings it has and how much of
each, so it is clear when these limits left something out.
They are copied after the IBs and the mapping list, which matter more
if GFP_NOWAIT allocations start to fail. As with the IBs, a BO that
can't be copied without blocking, including one in CPU invisible VRAM,
or that doesn't fit in the 8 MiB copied at hang time, is retried from
the coredump worker and marked as captured late. The worker only copies
a mapping that is still flagged and starts at the same address, so it
can't dump a mapping that replaced the flagged one. The worker also
selects the BOs if the root PD was contended, or if the VM has more
mappings than the list holds, since finding the flagged ones means
walking all of them.
32 MiB as one hex dword per line, as the IBs are printed, would be
almost 90 MiB of text, so print each BO as a single line of ascii85
instead, as i915, msm and xe do for buffer contents in their
coredumps. That takes at most five characters per dword, and one for
each zero dword. Formatting can still take a while, so stop early once
the printer is full and reschedule now and then.
Bump the KMS minor version so userspace can tell whether the flag is
accepted.
Mesa MR: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/47015
Suggested-by: Gregoire Pean <gpean@netflix.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 213 ++++++++++++++++++++---
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h | 14 ++
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 +-
include/uapi/drm/amdgpu_drm.h | 6 +
5 files changed, 213 insertions(+), 25 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
index 8395e9d35f7e..c531bc894a63 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -22,6 +22,7 @@
*
*/
+#include <linux/ascii85.h>
#include <linux/devcoredump.h>
#include <linux/utsname.h>
#include <drm/drm_exec.h>
@@ -59,6 +60,14 @@ void amdgpu_coredump_fini(struct amdgpu_device *adev)
/* Only this many VM mappings are listed in the coredump. */
#define AMDGPU_COREDUMP_MAX_MAPPINGS 1024
+/*
+ * Limits on copying the mappings flagged with AMDGPU_VM_PAGE_DUMP: how many,
+ * how much of each, and how much in total.
+ */
+#define AMDGPU_COREDUMP_MAX_BOS 64
+#define AMDGPU_COREDUMP_BO_MAX_BYTES ((u64)SZ_4M)
+#define AMDGPU_COREDUMP_BOS_MAX_BYTES ((u64)SZ_32M)
+
/* Placement of a mapping without a BO or whose BO has no backing store */
#define AMDGPU_COREDUMP_MEM_TYPE_NONE -1
/* Placement of a mapping whose BO could not be locked to read it */
@@ -376,6 +385,12 @@ static int amdgpu_devcoredump_copy_blob(struct amdgpu_vm *vm,
if (!abo)
return -ENOENT;
+ /* The worker must not copy a mapping that replaced a flagged one. */
+ if (blob->flagged &&
+ (!(mapping->flags & AMDGPU_VM_PAGE_DUMP) ||
+ mapping->start * AMDGPU_GPU_PAGE_SIZE != blob->va))
+ return -ENOENT;
+
if (blob->va + blob->size > (mapping->last + 1) * AMDGPU_GPU_PAGE_SIZE)
return -ERANGE;
@@ -497,6 +512,82 @@ static int amdgpu_devcoredump_capture_mappings(struct amdgpu_vm *vm,
return 0;
}
+/*
+ * Choose which parts of the mappings flagged with AMDGPU_VM_PAGE_DUMP to copy:
+ * the start of each mapping, up to the per-mapping and total limits. The VM
+ * root PD must be reserved by the caller.
+ */
+static int amdgpu_devcoredump_select_bos(struct amdgpu_vm *vm,
+ struct amdgpu_coredump_info *coredump,
+ bool nowait)
+{
+ struct amdgpu_bo_va_mapping *mapping = NULL;
+ u64 budget = AMDGPU_COREDUMP_BOS_MAX_BYTES;
+ u32 count = 0, n = 0;
+
+ /*
+ * Finding the flagged mappings means walking all of them, so leave
+ * that to the worker if there are more than are listed.
+ */
+ if (nowait && coredump->more_mappings)
+ return -EAGAIN;
+
+ while ((mapping = amdgpu_vm_bo_next_mapping(vm, mapping)))
+ count += !!(mapping->flags & AMDGPU_VM_PAGE_DUMP);
+
+ coredump->total_bos = count;
+ if (!count)
+ return 0;
+
+ count = min(count, AMDGPU_COREDUMP_MAX_BOS);
+ coredump->bos = kvzalloc_objs(struct amdgpu_coredump_bo_info, count,
+ (nowait ? GFP_NOWAIT : GFP_KERNEL) |
+ __GFP_NOWARN);
+ if (!coredump->bos)
+ return -ENOMEM;
+
+ while (n < count && budget &&
+ (mapping = amdgpu_vm_bo_next_mapping(vm, mapping))) {
+ struct amdgpu_coredump_bo_info *bo;
+ struct amdgpu_coredump_blob *blob;
+ u64 mapping_size, size;
+
+ if (!(mapping->flags & AMDGPU_VM_PAGE_DUMP))
+ continue;
+
+ mapping_size = (mapping->last - mapping->start + 1) *
+ AMDGPU_GPU_PAGE_SIZE;
+ size = min3(mapping_size, AMDGPU_COREDUMP_BO_MAX_BYTES, budget);
+ budget -= size;
+
+ bo = &coredump->bos[n++];
+ bo->mapping_size = mapping_size;
+ blob = &bo->blob;
+ blob->va = mapping->start * AMDGPU_GPU_PAGE_SIZE;
+ blob->size = size;
+ blob->status = -EAGAIN;
+ blob->flagged = true;
+ }
+ coredump->num_bos = n;
+
+ return 0;
+}
+
+static u32 amdgpu_devcoredump_num_blobs(struct amdgpu_coredump_info *coredump)
+{
+ return coredump->num_ibs + coredump->num_bos;
+}
+
+/* The IBs of the hung job, followed by the flagged mappings. */
+static struct amdgpu_coredump_blob *
+amdgpu_devcoredump_get_blob(struct amdgpu_coredump_info *coredump, u32 i)
+{
+ if (i < coredump->num_ibs)
+ return &coredump->ibs[i].blob;
+
+ return &coredump->bos[i - coredump->num_ibs].blob;
+}
+
/* Copy @blob at hang time if it fits in what is left of @budget. */
static void amdgpu_devcoredump_copy_blob_nowait(struct amdgpu_vm *vm,
struct amdgpu_coredump_blob *blob,
@@ -533,9 +624,11 @@ amdgpu_devcoredump_capture_vm_nowait(struct amdgpu_device *adev,
blob->status = PTR_ERR(vm);
}
coredump->mappings_status = PTR_ERR(vm);
+ coredump->bos_status = PTR_ERR(vm);
return;
}
+ /* In order of importance, in case GFP_NOWAIT allocations fail. */
for (int i = 0; i < coredump->num_ibs; i++)
amdgpu_devcoredump_copy_blob_nowait(vm, &coredump->ibs[i].blob,
&budget);
@@ -543,6 +636,11 @@ amdgpu_devcoredump_capture_vm_nowait(struct amdgpu_device *adev,
coredump->mappings_status =
amdgpu_devcoredump_capture_mappings(vm, coredump, true);
+ coredump->bos_status = amdgpu_devcoredump_select_bos(vm, coredump, true);
+ for (u32 i = 0; i < coredump->num_bos; i++)
+ amdgpu_devcoredump_copy_blob_nowait(vm, &coredump->bos[i].blob,
+ &budget);
+
dma_resv_unlock(vm->root.bo->tbo.base.resv);
}
@@ -608,8 +706,9 @@ amdgpu_devcoredump_print_mappings(struct drm_printer *p,
}
/*
- * List the VM mappings if that failed at hang time. The VM root PD must be
- * reserved by the caller.
+ * List the VM mappings and select the flagged BOs if that failed at hang time.
+ * The VM root PD must be reserved by the caller. The selected BOs are then
+ * copied like any other blob that has to be retried.
*/
static void amdgpu_devcoredump_list_vm_late(struct amdgpu_vm *vm,
struct amdgpu_coredump_info *coredump)
@@ -619,6 +718,10 @@ static void amdgpu_devcoredump_list_vm_late(struct amdgpu_vm *vm,
amdgpu_devcoredump_capture_mappings(vm, coredump, false);
coredump->mappings_late = !coredump->mappings_status;
}
+
+ if (amdgpu_devcoredump_status_retry(coredump->bos_status))
+ coredump->bos_status =
+ amdgpu_devcoredump_select_bos(vm, coredump, false);
}
/*
@@ -630,6 +733,7 @@ static void amdgpu_devcoredump_list_vm_late(struct amdgpu_vm *vm,
static void
amdgpu_devcoredump_capture_vm_late(struct amdgpu_coredump_info *coredump)
{
+ u32 num_blobs = amdgpu_devcoredump_num_blobs(coredump);
struct amdgpu_bo_va_mapping *mapping;
struct amdgpu_coredump_blob *blob;
struct amdgpu_bo *abo;
@@ -638,20 +742,23 @@ amdgpu_devcoredump_capture_vm_late(struct amdgpu_coredump_info *coredump)
bool retry;
int r = 0;
- retry = amdgpu_devcoredump_status_retry(coredump->mappings_status);
- for (int i = 0; i < coredump->num_ibs; i++)
- retry |= amdgpu_devcoredump_blob_retry(&coredump->ibs[i].blob);
+ retry = amdgpu_devcoredump_status_retry(coredump->mappings_status) ||
+ amdgpu_devcoredump_status_retry(coredump->bos_status);
+ for (u32 i = 0; i < num_blobs; i++) {
+ blob = amdgpu_devcoredump_get_blob(coredump, i);
+ retry |= amdgpu_devcoredump_blob_retry(blob);
+ }
if (!retry)
return;
/*
- * Lock the VM root PD and every IB BO together in a single drm_exec
- * ticket. Reserving the IB BOs one by one while the root PD is held
+ * Lock the VM root PD and every BO together in a single drm_exec
+ * ticket. Reserving the BOs one by one while the root PD is held
* would be a recursive reservation_ww_class_mutex acquire without a
- * ww_acquire_ctx, which trips lockdep and self-deadlocks for IB BOs
+ * ww_acquire_ctx, which trips lockdep and self-deadlocks for BOs
* that share their dma_resv with the root PD (always-valid BOs).
*/
- drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES, 1 + coredump->num_ibs);
+ drm_exec_init(&exec, DRM_EXEC_IGNORE_DUPLICATES, 1 + num_blobs);
drm_exec_until_all_locked(&exec) {
/* Don't keep an -EDEADLK from a previous pass. */
r = 0;
@@ -663,9 +770,10 @@ amdgpu_devcoredump_capture_vm_late(struct amdgpu_coredump_info *coredump)
}
amdgpu_devcoredump_list_vm_late(vm, coredump);
+ num_blobs = amdgpu_devcoredump_num_blobs(coredump);
- for (int i = 0; i < coredump->num_ibs; i++) {
- blob = &coredump->ibs[i].blob;
+ for (u32 i = 0; i < num_blobs; i++) {
+ blob = amdgpu_devcoredump_get_blob(coredump, i);
if (!amdgpu_devcoredump_blob_retry(blob))
continue;
@@ -681,8 +789,8 @@ amdgpu_devcoredump_capture_vm_late(struct amdgpu_coredump_info *coredump)
}
}
- for (int i = 0; i < coredump->num_ibs; i++) {
- blob = &coredump->ibs[i].blob;
+ for (u32 i = 0; i < num_blobs; i++) {
+ blob = amdgpu_devcoredump_get_blob(coredump, i);
if (!amdgpu_devcoredump_blob_retry(blob))
continue;
@@ -696,18 +804,26 @@ amdgpu_devcoredump_capture_vm_late(struct amdgpu_coredump_info *coredump)
if (r) {
if (amdgpu_devcoredump_status_retry(coredump->mappings_status))
coredump->mappings_status = r;
- for (int i = 0; i < coredump->num_ibs; i++) {
- blob = &coredump->ibs[i].blob;
+ if (amdgpu_devcoredump_status_retry(coredump->bos_status))
+ coredump->bos_status = r;
+ for (u32 i = 0; i < num_blobs; i++) {
+ blob = amdgpu_devcoredump_get_blob(coredump, i);
if (amdgpu_devcoredump_blob_retry(blob))
blob->status = r;
}
}
}
-/* Print the contents of a blob, or why they are missing. */
+/*
+ * Print the contents of a blob, or why they are missing: as one hex dword
+ * per line, or if @ascii85 is set as a single line of ascii85, which takes
+ * at most five characters per dword instead of eleven.
+ */
static void amdgpu_devcoredump_print_blob(struct drm_printer *p,
- struct amdgpu_coredump_blob *blob)
+ struct amdgpu_coredump_blob *blob,
+ bool ascii85)
{
+ char buf[ASCII85_BUFSZ];
const u32 *dw = blob->data;
if (!blob->data) {
@@ -719,8 +835,23 @@ static void amdgpu_devcoredump_print_blob(struct drm_printer *p,
if (blob->late)
drm_printf(p, "contents captured after recovery started\n");
- for (u64 i = 0; i < blob->size / 4; i++)
- drm_printf(p, "0x%08x\n", dw[i]);
+ if (!ascii85) {
+ for (u64 i = 0; i < blob->size / 4; i++)
+ drm_printf(p, "0x%08x\n", dw[i]);
+ return;
+ }
+
+ drm_puts(p, "data: ");
+ for (u64 i = 0; i < blob->size / 4; i++) {
+ drm_puts(p, ascii85_encode(dw[i], buf));
+
+ if (!(i % SZ_64K)) {
+ if (drm_coredump_printer_is_full(p))
+ return;
+ cond_resched();
+ }
+ }
+ drm_puts(p, "\n");
}
static void
@@ -732,7 +863,36 @@ amdgpu_devcoredump_print_ibs(struct drm_printer *p,
drm_printf(p, "\nIB #%d 0x%llx %d dw\n", i, ib->gpu_addr,
ib->ib_size_dw);
- amdgpu_devcoredump_print_blob(p, &ib->blob);
+ amdgpu_devcoredump_print_blob(p, &ib->blob, false);
+ }
+}
+
+static void
+amdgpu_devcoredump_print_bos(struct drm_printer *p,
+ struct amdgpu_coredump_info *coredump)
+{
+ struct amdgpu_device *adev = coredump->adev;
+
+ if (coredump->bos_status) {
+ drm_printf(p, "\nDumped BOs unavailable: %pe\n",
+ ERR_PTR(coredump->bos_status));
+ return;
+ }
+
+ if (!coredump->total_bos)
+ return;
+
+ /* Both counts and sizes: the caps can leave out BOs or their ends. */
+ drm_printf(p, "\nDumped BOs: %u of %u\n", coredump->num_bos,
+ coredump->total_bos);
+
+ for (u32 i = 0; i < coredump->num_bos; i++) {
+ struct amdgpu_coredump_bo_info *bo = &coredump->bos[i];
+
+ drm_printf(p, "\nBO #%u 0x%016llx 0x%llx of 0x%llx bytes\n", i,
+ amdgpu_gmc_sign_extend(bo->blob.va), bo->blob.size,
+ bo->mapping_size);
+ amdgpu_devcoredump_print_blob(p, &bo->blob, true);
}
}
@@ -973,6 +1133,9 @@ amdgpu_devcoredump_format(char *buffer, size_t count, struct amdgpu_coredump_inf
if (coredump->num_ibs)
amdgpu_devcoredump_print_ibs(&p, coredump);
+ if (coredump->pasid)
+ amdgpu_devcoredump_print_bos(&p, coredump);
+
return count - iter.remain;
}
@@ -1002,9 +1165,12 @@ amdgpu_devcoredump_read(char *buffer, loff_t offset, size_t count,
/* Free the copied memory, which is only needed to format the dump. */
static void amdgpu_devcoredump_free_blobs(struct amdgpu_coredump_info *coredump)
{
- for (int i = 0; i < coredump->num_ibs; i++) {
- kvfree(coredump->ibs[i].blob.data);
- coredump->ibs[i].blob.data = NULL;
+ for (u32 i = 0; i < amdgpu_devcoredump_num_blobs(coredump); i++) {
+ struct amdgpu_coredump_blob *blob =
+ amdgpu_devcoredump_get_blob(coredump, i);
+
+ kvfree(blob->data);
+ blob->data = NULL;
}
}
@@ -1016,6 +1182,7 @@ static void amdgpu_devcoredump_free(void *data)
kvfree(coredump->formatted);
kvfree(coredump->mappings);
amdgpu_devcoredump_free_blobs(coredump);
+ kvfree(coredump->bos);
for (i = 0; i < coredump->num_rings; i++) {
kvfree(coredump->rings[i].ring_dw);
kvfree(coredump->rings[i].fences);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
index 844fc87f386e..00982cf80809 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
@@ -63,6 +63,8 @@ struct amdgpu_coredump_blob {
int status;
/* copied by the worker rather than when the hang was detected */
bool late;
+ /* the start of a mapping flagged with AMDGPU_VM_PAGE_DUMP */
+ bool flagged;
};
struct amdgpu_coredump_ib_info {
@@ -71,6 +73,12 @@ struct amdgpu_coredump_ib_info {
struct amdgpu_coredump_blob blob;
};
+struct amdgpu_coredump_bo_info {
+ /* size of the whole mapping, of which blob has the start */
+ u64 mapping_size;
+ struct amdgpu_coredump_blob blob;
+};
+
struct amdgpu_coredump_mapping {
u64 va;
u64 size;
@@ -116,6 +124,12 @@ struct amdgpu_coredump_info {
/* listed by the worker rather than when the hang was detected */
bool mappings_late;
+ /* contents of the mappings with AMDGPU_VM_PAGE_DUMP set */
+ struct amdgpu_coredump_bo_info *bos;
+ u32 num_bos;
+ u32 total_bos;
+ int bos_status;
+
pid_t submit_tgid;
pid_t submit_pid;
char submit_process_name[TASK_COMM_LEN];
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index d2db20c172c6..8c2f958116aa 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -129,9 +129,10 @@
* - 3.64.0 - Userq IP support query
* - 3.65.0 - Add userq syncobj timeline signaling support
* - 3.66.0 - Allow jpeg type 4 packets and VCE SEI command
+ * - 3.67.0 - Add AMDGPU_VM_PAGE_DUMP
*/
#define KMS_DRIVER_MAJOR 3
-#define KMS_DRIVER_MINOR 66
+#define KMS_DRIVER_MINOR 67
#define KMS_DRIVER_PATCHLEVEL 0
/*
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 65b88e6008e4..6e7591d6ef2a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -889,7 +889,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
const uint32_t valid_flags = AMDGPU_VM_DELAY_UPDATE |
AMDGPU_VM_PAGE_READABLE | AMDGPU_VM_PAGE_WRITEABLE |
AMDGPU_VM_PAGE_EXECUTABLE | AMDGPU_VM_MTYPE_MASK |
- AMDGPU_VM_PAGE_NOALLOC;
+ AMDGPU_VM_PAGE_NOALLOC | AMDGPU_VM_PAGE_DUMP;
const uint32_t prt_flags = AMDGPU_VM_DELAY_UPDATE |
AMDGPU_VM_PAGE_PRT;
diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h
index 894fca0a79cc..cec897772728 100644
--- a/include/uapi/drm/amdgpu_drm.h
+++ b/include/uapi/drm/amdgpu_drm.h
@@ -915,6 +915,12 @@ struct drm_amdgpu_gem_list_handles_entry {
#define AMDGPU_VM_MTYPE_RW (5 << 5)
/* don't allocate MALL */
#define AMDGPU_VM_PAGE_NOALLOC (1 << 9)
+/*
+ * Include the contents of the mapping in the device coredump taken when a job
+ * using this VM hangs, subject to size limits. Has no effect on the GPU
+ * mapping itself.
+ */
+#define AMDGPU_VM_PAGE_DUMP (1 << 10)
struct drm_amdgpu_gem_va {
/** GEM object handle */
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 14/14] drm/amdgpu: bump the devcoredump version
2026-12-02 22:36 [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump Matt Turner
` (12 preceding siblings ...)
2026-12-02 22:36 ` [PATCH 13/14] drm/amdgpu: add AMDGPU_VM_PAGE_DUMP to include BOs " Matt Turner
@ 2026-12-02 22:36 ` Matt Turner
13 siblings, 0 replies; 15+ messages in thread
From: Matt Turner @ 2026-12-02 22:36 UTC (permalink / raw)
To: Alex Deucher, Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Sunil Khatri,
Trigger Huang
Cc: amd-gfx, dri-devel, linux-kernel, Matt Turner
The devcoredump now has the thread that submitted the hung job, the
unsignaled fences of each ring, the number of dropped dumps, the VM
mappings and the flagged BOs, the last printed as ascii85 rather than
as the hex dwords used for the IBs, and says why the IP state or IB
contents are missing. Bump AMDGPU_COREDUMP_VERSION, which commit
de009982c6aa ("drm/amdgpu: Create version number for coredumps") says
is to be incremented when the format or content changes, so that a
parser can tell the formats apart.
---
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
index 00982cf80809..8f2d32745a84 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.h
@@ -29,7 +29,7 @@
#ifdef CONFIG_DEV_COREDUMP
-#define AMDGPU_COREDUMP_VERSION "1"
+#define AMDGPU_COREDUMP_VERSION "2"
struct amdgpu_coredump_fence {
u64 context;
--
2.56.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-12-02 22:36 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 22:36 [PATCH 00/14] drm/amdgpu: capture more of the hang state in the devcoredump Matt Turner
2026-12-02 22:36 ` [PATCH 01/14] drm/amdgpu: dump the IP state of each device in an XGMI hive Matt Turner
2026-12-02 22:36 ` [PATCH 02/14] drm/amdgpu: only give the hung job to its own device's coredump Matt Turner
2026-12-02 22:36 ` [PATCH 03/14] drm/amdgpu: don't overwrite the IP state while a coredump is formatted Matt Turner
2026-12-02 22:36 ` [PATCH 04/14] drm/amdgpu: take a coredump before resets done by a reset handler Matt Turner
2026-12-02 22:36 ` [PATCH 05/14] drm/amdgpu: copy the VM fault info when the hang is detected Matt Turner
2026-12-02 22:36 ` [PATCH 06/14] drm/amdgpu/gfx10-12: dump CP_STAT and the IB2 state of each gfx queue Matt Turner
2026-12-02 22:36 ` [PATCH 07/14] drm/amdgpu: copy the IB contents before formatting the devcoredump Matt Turner
2026-12-02 22:36 ` [PATCH 08/14] drm/amdgpu: copy the IB contents when the hang is detected Matt Turner
2026-12-02 22:36 ` [PATCH 09/14] drm/amdgpu: record the submitting thread of the hung job in the coredump Matt Turner
2026-12-02 22:36 ` [PATCH 10/14] drm/amdgpu: dump the unsignaled fences of each ring " Matt Turner
2026-12-02 22:36 ` [PATCH 11/14] drm/amdgpu: report dropped devcoredumps Matt Turner
2026-12-02 22:36 ` [PATCH 12/14] drm/amdgpu: list the VM mappings of the hung job in the coredump Matt Turner
2026-12-02 22:36 ` [PATCH 13/14] drm/amdgpu: add AMDGPU_VM_PAGE_DUMP to include BOs " Matt Turner
2026-12-02 22:36 ` [PATCH 14/14] drm/amdgpu: bump the devcoredump version Matt Turner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox