The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Matt Turner <mattst88@gmail.com>
To: "Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Sunil Khatri" <sunil.khatri@amd.com>,
	"Trigger Huang" <Trigger.Huang@amd.com>
Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	 linux-kernel@vger.kernel.org, Matt Turner <mattst88@gmail.com>
Subject: [PATCH 05/14] drm/amdgpu: copy the VM fault info when the hang is detected
Date: Wed, 02 Dec 2026 17:36:11 -0500	[thread overview]
Message-ID: <20261202-amdgpu-devcoredump-v1-5-3dfa0e033b97@gmail.com> (raw)
In-Reply-To: <20261202-amdgpu-devcoredump-v1-0-3dfa0e033b97@gmail.com>

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


  parent reply	other threads:[~2026-12-02 22:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Matt Turner [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202-amdgpu-devcoredump-v1-5-3dfa0e033b97@gmail.com \
    --to=mattst88@gmail.com \
    --cc=Trigger.Huang@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=sunil.khatri@amd.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox