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 04/14] drm/amdgpu: take a coredump before resets done by a reset handler
Date: Wed, 02 Dec 2026 17:36:10 -0500	[thread overview]
Message-ID: <20261202-amdgpu-devcoredump-v1-4-3dfa0e033b97@gmail.com> (raw)
In-Reply-To: <20261202-amdgpu-devcoredump-v1-0-3dfa0e033b97@gmail.com>

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


  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 ` Matt Turner [this message]
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

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-4-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