Skip to contentSkip to conversation

drm/amdgpu: Small reset improvements

PATCH Applied André Almeida 3 participants 7 messages Feb 20, 2025 – Feb 21, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover drm/amdgpu: Small reset improvements

This series does some small improvements to GPU reset information collection.

v2: Keep the wedge event in amdgpu_device_gpu_recover() and add and
extra check to avoid triggering two events.

André Almeida (3):
drm/amdgpu: Log the creation of a coredump file drm/amdgpu: Log after a successful ring reset drm/amdgpu: Trigger a wedged event for every type of reset

 .../gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c  |  4 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c       | 21 ++++++++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)
Signature · 1 line
2.48.1
#1 lore raw

PATCH v2 1/3 drm/amdgpu: Log the creation of a coredump file

After a GPU reset happens, the driver creates a coredump file. However, the user might not be aware of it. Log the file creation the user can find more information about the device and add the file to bug reports. This is similar to what the xe driver does.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +4 -0
index 824f9da5b6ce..7b50741dc097 100644
@@ -364,5 +364,9 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
 
 	dev_coredumpm(dev->dev, THIS_MODULE, coredump, 0, GFP_NOWAIT,
 		      amdgpu_devcoredump_read, amdgpu_devcoredump_free);
+
+	drm_info(dev, "AMDGPU device coredump file has been created\n");
+	drm_info(dev, "Check your /sys/class/drm/card%d/device/devcoredump/data\n",
+		 dev->primary->index);
 }
 #endif
Signature · 1 line
2.48.1
Applied
#2 lore raw

Re: [PATCH v2 1/3] drm/amdgpu: Log the creation of a coredump file

Applied, thanks!

Alex

Quoted 29 lines · André Almeida

After a GPU reset happens, the driver creates a coredump file. However, the user might not be aware of it. Log the file creation the user can find more information about the device and add the file to bug reports. This is similar to what the xe driver does.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c +4 -1
index 824f9da5b6ce..7b50741dc097 100644
@@ -364,5 +364,9 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
 
        dev_coredumpm(dev->dev, THIS_MODULE, coredump, 0, GFP_NOWAIT,
                      amdgpu_devcoredump_read, amdgpu_devcoredump_free);
+
+       drm_info(dev, "AMDGPU device coredump file has been created\n");
+       drm_info(dev, "Check your /sys/class/drm/card%d/device/devcoredump/data\n",
+                dev->primary->index);
 }
 #endif
--

2.48.1

#3 lore raw

PATCH v2 2/3 drm/amdgpu: Log after a successful ring reset

In reply to André Almeida

When a ring reset happens, the kernel log shows only "amdgpu: Starting <ring name> ring reset", but when it finishes nothing appears in the log. Explicitly write in the log that the reset has finished correctly.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -0
index 100f04475943..698e5799e542 100644
@@ -149,6 +149,7 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)
 			amdgpu_fence_driver_force_completion(ring);
 			if (amdgpu_ring_sched_ready(ring))
 				drm_sched_start(&ring->sched, 0);
+			dev_err(adev->dev, "Ring %s reset succeeded\n", ring->sched.name);
 			goto exit;
 		}
 		dev_err(adev->dev, "Ring %s reset failure\n", ring->sched.name);
Signature · 1 line
2.48.1
Applied
#4 lore raw

Re: [PATCH v2 2/3] drm/amdgpu: Log after a successful ring reset

Applied. Thanks!

Quoted 26 lines · André Almeida

When a ring reset happens, the kernel log shows only "amdgpu: Starting <ring name> ring reset", but when it finishes nothing appears in the log. Explicitly write in the log that the reset has finished correctly.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
index 100f04475943..698e5799e542 100644
@@ -149,6 +149,7 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)
                        amdgpu_fence_driver_force_completion(ring);
                        if (amdgpu_ring_sched_ready(ring))
                                drm_sched_start(&ring->sched, 0);
+                       dev_err(adev->dev, "Ring %s reset succeeded\n", ring->sched.name);
                        goto exit;
                }
                dev_err(adev->dev, "Ring %s reset failure\n", ring->sched.name);
--

2.48.1

#5 lore raw

PATCH v2 3/3 drm/amdgpu: Trigger a wedged event for every type of reset

In reply to André Almeida

Instead of only triggering a wedged event for complete GPU resets, trigger for all types, like soft resets and ring resets. Regardless of the reset, it's useful for userspace to know that it happened because the kernel will reject further submissions from that app.

---
v2: Keep the wedge event in amdgpu_device_gpu_recover() and add and
extra check to avoid triggering two events.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +13 -7
index 698e5799e542..9948ea33d2c6 100644
@@ -91,8 +91,8 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)
 	struct amdgpu_job *job = to_amdgpu_job(s_job);
 	struct amdgpu_task_info *ti;
 	struct amdgpu_device *adev = ring->adev;
-	int idx;
-	int r;
+	bool gpu_recover = false;
+	int idx, ret = 0;
 
 	if (!drm_dev_enter(adev_to_drm(adev), &idx)) {
 		dev_info(adev->dev, "%s - device unplugged skipping recovery on scheduler:%s",
@@ -141,8 +141,8 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)
 		 * we'll fall back to full GPU reset.
 		 */
 		drm_sched_wqueue_stop(&ring->sched);
-		r = amdgpu_ring_reset(ring, job->vmid);
-		if (!r) {
+		ret = amdgpu_ring_reset(ring, job->vmid);
+		if (!ret) {
 			if (amdgpu_ring_sched_ready(ring))
 				drm_sched_stop(&ring->sched, s_job);
 			atomic_inc(&ring->adev->gpu_reset_counter);
@@ -170,9 +170,11 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)
 		 */
 		set_bit(AMDGPU_SKIP_COREDUMP, &reset_context.flags);
 
-		r = amdgpu_device_gpu_recover(ring->adev, job, &reset_context);
-		if (r)
-			dev_err(adev->dev, "GPU Recovery Failed: %d\n", r);
+		ret = amdgpu_device_gpu_recover(ring->adev, job, &reset_context);
+		if (ret)
+			dev_err(adev->dev, "GPU Recovery Failed: %d\n", ret);
+		else
+			gpu_recover = true;
 	} else {
 		drm_sched_suspend_timeout(&ring->sched);
 		if (amdgpu_sriov_vf(adev))
@@ -180,6 +182,10 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)
 	}
 
 exit:
+	/* Avoid sending two wedge events for the same reset */
+	if (!ret && !gpu_recover)
+		drm_dev_wedged_event(adev_to_drm(adev), DRM_WEDGE_RECOVERY_NONE);
+
 	drm_dev_exit(idx);
 	return DRM_GPU_SCHED_STAT_NOMINAL;
 }
Signature · 1 line
2.48.1
maintainer
#6 lore raw

Re: [PATCH v2 3/3] drm/amdgpu: Trigger a wedged event for every type of reset

Am 20.02.25 um 17:27 schrieb André Almeida:

Quoted 18 lines

Instead of only triggering a wedged event for complete GPU resets, trigger for all types, like soft resets and ring resets. Regardless of the reset, it's useful for userspace to know that it happened because the kernel will reject further submissions from that app.

---
v2: Keep the wedge event in amdgpu_device_gpu_recover() and add and
extra check to avoid triggering two events.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0 -0
index 698e5799e542..9948ea33d2c6 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) · line 95

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -2
@@ -91,8 +91,8 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)
 	struct amdgpu_job *job = to_amdgpu_job(s_job);
 	struct amdgpu_task_info *ti;
 	struct amdgpu_device *adev = ring->adev;
-	int idx;
-	int r;
+	bool gpu_recover = false;
+	int idx, ret = 0;

We usually stick to "r" as name for the return variable in amdgpu.

Quoted 30 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +7 -5
 	if (!drm_dev_enter(adev_to_drm(adev), &idx)) {
 		dev_info(adev->dev, "%s - device unplugged skipping recovery on scheduler:%s",
@@ -141,8 +141,8 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)
 		 * we'll fall back to full GPU reset.
 		 */
 		drm_sched_wqueue_stop(&ring->sched);
-		r = amdgpu_ring_reset(ring, job->vmid);
-		if (!r) {
+		ret = amdgpu_ring_reset(ring, job->vmid);
+		if (!ret) {
 			if (amdgpu_ring_sched_ready(ring))
 				drm_sched_stop(&ring->sched, s_job);
 			atomic_inc(&ring->adev->gpu_reset_counter);
@@ -170,9 +170,11 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)
 		 */
 		set_bit(AMDGPU_SKIP_COREDUMP, &reset_context.flags);
 
-		r = amdgpu_device_gpu_recover(ring->adev, job, &reset_context);
-		if (r)
-			dev_err(adev->dev, "GPU Recovery Failed: %d\n", r);
+		ret = amdgpu_device_gpu_recover(ring->adev, job, &reset_context);
+		if (ret)
+			dev_err(adev->dev, "GPU Recovery Failed: %d\n", ret);
+		else
+			gpu_recover = true;
 	} else {
 		drm_sched_suspend_timeout(&ring->sched);
 		if (amdgpu_sriov_vf(adev))

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) · line 186

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
@@ -180,6 +182,10 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)
 	}
 
 exit:
+	/* Avoid sending two wedge events for the same reset */
+	if (!ret && !gpu_recover)

Ugh, that's rather ugly I think.

Probably better to just add an extra drm_dev_wedged_event() after the amdgpu_ring_reset() call.

The soft recovery should probably never send a wedged event in the first place and we plan to remove it anyway when queue reset works reliable.

Regards,
Christian.

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +2 -0
+		drm_dev_wedged_event(adev_to_drm(adev), DRM_WEDGE_RECOVERY_NONE);
+
 	drm_dev_exit(idx);
 	return DRM_GPU_SCHED_STAT_NOMINAL;
 }