Skip to contentSkip to conversation

drm/amdgpu: Fix for GPU reset being blocked by KIQ I/O.

PATCH In review Heng Zhou 2 participants 2 messages Sep 25, 2025

Subsystems (2)
lore
Share & tools
lore

Heng Zhou

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix for GPU reset being blocked by KIQ I/O.

There is some probability that reset workqueue is blocked by KIQ I/O for 10+ seconds after gpu hangs. So we need to add a in_reset check during each KIQ register poll.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +6 -0
index 89fc1015d3a6..b6a88103adfd 100644
@@ -1102,6 +1102,9 @@ uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg, uint32_t xcc_
 
 	might_sleep();
 	while (r < 1 && cnt++ < MAX_KIQ_REG_TRY) {
+		if (amdgpu_in_reset(adev)) {
+			goto failed_kiq_read;
+		}
 		msleep(MAX_KIQ_REG_BAILOUT_INTERVAL);
 		r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
 	}
@@ -1172,6 +1175,9 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v, uint3
 	might_sleep();
 	while (r < 1 && cnt++ < MAX_KIQ_REG_TRY) {
 
+		if (amdgpu_in_reset(adev)) {
+			goto failed_kiq_write;
+		}
 		msleep(MAX_KIQ_REG_BAILOUT_INTERVAL);
 		r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
 	}
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 13 lines · Heng Zhou

There is some probability that reset workqueue is blocked by KIQ I/O for 10+ seconds after gpu hangs. So we need to add a in_reset check during each KIQ register poll.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +0 -0
index 89fc1015d3a6..b6a88103adfd 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg, uint32_t xcc_ · line 1107

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +3 -0
@@ -1102,6 +1102,9 @@ uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg, uint32_t xcc_
 
 	might_sleep();
 	while (r < 1 && cnt++ < MAX_KIQ_REG_TRY) {
+		if (amdgpu_in_reset(adev)) {
+			goto failed_kiq_read;
+		}

Drop the extra {}, apart from that sounds reasonable to me.

Regards,
Christian.

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +3 -0
 		msleep(MAX_KIQ_REG_BAILOUT_INTERVAL);
 		r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
 	}
@@ -1172,6 +1175,9 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v, uint3
 	might_sleep();
 	while (r < 1 && cnt++ < MAX_KIQ_REG_TRY) {
 
+		if (amdgpu_in_reset(adev)) {
+			goto failed_kiq_write;
+		}
 		msleep(MAX_KIQ_REG_BAILOUT_INTERVAL);
 		r = amdgpu_fence_wait_polling(ring, seq, MAX_KIQ_REG_WAIT);
 	}