drm/amdgpu/sdma6: don't do MMIO in MQD init
Subsystems (3)
Alex Deucher
maintainerPATCH 1/6 drm/amdgpu/sdma6: don't do MMIO in MQD init
There's no need to read the register, just use the default value.
--- drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +1 -2
@@ -860,8 +860,7 @@ static int sdma_v6_0_mqd_init(struct amdgpu_device *adev, void *mqd, m->sdmax_rlcx_rb_rptr_addr_lo =lower_32_bits (wb_gpu_addr); m->sdmax_rlcx_rb_rptr_addr_hi =upper_32_bits (wb_gpu_addr); - m->sdmax_rlcx_ib_cntl =RREG32_SOC15_IP (GC ,sdma_v6_0_get_reg_offset (adev,0 , - regSDMA0_QUEUE0_IB_CNTL)); + m->sdmax_rlcx_ib_cntl = regSDMA0_QUEUE0_IB_CNTL_DEFAULT; m->sdmax_rlcx_doorbell_offset = prop->doorbell_index <<SDMA0_QUEUE0_DOORBELL_OFFSET__OFFSET__SHIFT ;
Signature · 1 line
2.55.0
Alex Deucher
maintainerPATCH 2/6 drm/amdgpu/sdma7: don't do MMIO in MQD init
There's no need to read the register, just use the default value.
--- drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v7_0.c +1 -2
@@ -886,8 +886,7 @@ static int sdma_v7_0_mqd_init(struct amdgpu_device *adev, void *mqd, m->sdmax_rlcx_rb_rptr_addr_lo =lower_32_bits (wb_gpu_addr); m->sdmax_rlcx_rb_rptr_addr_hi =upper_32_bits (wb_gpu_addr); - m->sdmax_rlcx_ib_cntl =RREG32_SOC15_IP (GC ,sdma_v7_0_get_reg_offset (adev,0 , - regSDMA0_QUEUE0_IB_CNTL)); + m->sdmax_rlcx_ib_cntl =0x00000100 ;//regSDMA0_QUEUE0_IB_CNTL_DEFAULT m->sdmax_rlcx_doorbell_offset = prop->doorbell_index <<SDMA0_QUEUE0_DOORBELL_OFFSET__OFFSET__SHIFT ;
Signature · 1 line
2.55.0
Alex Deucher
maintainerPATCH 3/6 drm/amdgpu/sdma7.1: don't do MMIO in MQD init
In reply to Alex DeucherThere's no need to read the register, just use the default value.
--- drivers/gpu/drm/amd/amdgpu/sdma_v7_1.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v7_1.c +1 -2
@@ -879,8 +879,7 @@ static int sdma_v7_1_mqd_init(struct amdgpu_device *adev, void *mqd, m->sdmax_rlcx_rb_rptr_addr_lo =lower_32_bits (wb_gpu_addr); m->sdmax_rlcx_rb_rptr_addr_hi =upper_32_bits (wb_gpu_addr); - m->sdmax_rlcx_ib_cntl =RREG32_SOC15_IP (GC ,sdma_v7_1_get_reg_offset (adev,0 , - regSDMA0_SDMA_QUEUE0_IB_CNTL)); + m->sdmax_rlcx_ib_cntl =0x00000100 ;//regSDMA0_QUEUE0_IB_CNTL_DEFAULT m->sdmax_rlcx_doorbell_offset = prop->doorbell_index <<SDMA0_SDMA_QUEUE0_DOORBELL_OFFSET__OFFSET__SHIFT ;
Signature · 1 line
2.55.0
Alex Deucher
maintainerPATCH 4/6 drm/amdgpu: disallow gfxoff around gfx/compute/sdma KQ reset
In reply to Alex DeucherIf the engine is hung, we shouldn't need this since it won't be powered down, but we could potentially have a case where a queue can be preempted, but due to logic errors in the commands, the fence never signals. The engine could potentially go into the off state. Protect against that.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +8 -0
@@ -137,7 +137,15 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) s_job->sched->name);/* Stop the scheduler to prevent anybody else from touching the ring buffer. */ drm_sched_wqueue_stop (&ring->sched); +if (ring->funcs->type ==AMDGPU_RING_TYPE_GFX || + ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE || + ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) +amdgpu_gfx_off_ctrl (adev, false); r =amdgpu_ring_reset (ring, job->vmid, job->hw_fence); +if (ring->funcs->type ==AMDGPU_RING_TYPE_GFX || + ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE || + ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) +amdgpu_gfx_off_ctrl (adev, true);if (!r) {/* Start the scheduler again */ drm_sched_wqueue_start (&ring->sched);
Signature · 1 line
2.55.0
Re: [PATCH 4/6] drm/amdgpu: disallow gfxoff around gfx/compute/sdma KQ reset
Quoted 5 lines · Alex Deucher
If the engine is hung, we shouldn't need this since it won't be powered down, but we could potentially have a case where a queue can be preempted, but due to logic errors in the commands, the fence never signals. The engine could potentially go into the off state. Protect against that.
On a second thought, is this a real case? If engine already goes to off state, wouldn't everything be reset by default once it comes back?
Thanks,
Lijo
Quoted 26 lines
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +8
-0@@ -137,7 +137,15 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) s_job->sched->name);/* Stop the scheduler to prevent anybody else from touching the ring buffer. */ drm_sched_wqueue_stop (&ring->sched); +if (ring->funcs->type ==AMDGPU_RING_TYPE_GFX || + ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE || + ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) +amdgpu_gfx_off_ctrl (adev, false); r =amdgpu_ring_reset (ring, job->vmid, job->hw_fence); +if (ring->funcs->type ==AMDGPU_RING_TYPE_GFX || + ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE || + ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) +amdgpu_gfx_off_ctrl (adev, true);if (!r) {/* Start the scheduler again */ drm_sched_wqueue_start (&ring->sched);
Deucher, Alexander
maintainerRE: [PATCH 4/6] drm/amdgpu: disallow gfxoff around gfx/compute/sdma KQ reset
AMD General
Quoted 11 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, July 7, 2026 11:34 AM
To: Deucher, Alexander <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 4/6] drm/amdgpu: disallow gfxoff around gfx/compute/sdma KQ resetOn 07-Jul-26 8:04 PM, Alex Deucher wrote:
Quoted 8 lines
Quoted 5 lines
If the engine is hung, we shouldn't need this since it won't be powered down, but we could potentially have a case where a queue can be preempted, but due to logic errors in the commands, the fence never signals. The engine could potentially go into the off state. Protect against that.
On a second thought, is this a real case? If engine already goes to off state, wouldn't everything be reset by default once it comes back?
I'm not sure if gfxoff will actually enter or not, but consider the case of an IB which is waiting for some memory location. It's just waiting so the queue can be preempted, but when it's resumed, it just goes back to waiting so it needs to be reset even though it's not hung per se because it's fence will never signal. For compute queues at least, we peempt all the queues in the reset handler and then reset the bad queues. In theory there could be a window there where gfxoff entry could happen and then we may access a GC register via MMIO when we reset one of the bad queues.
Alex
Quoted 33 lines
Thanks,
Lijodrivers/gpu/drm/amd/amdgpu/amdgpu_job.c static enum drm_gpu_sched_stat
Quoted 12 lines
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0
-0@@ -137,7 +137,15 @@ static enum drm_gpu_sched_stat
amdgpu_job_timedout(struct drm_sched_job *s_job)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c static enum drm_gpu_sched_stat · line 138
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0
-0s_job->sched->name);/* Stop the scheduler to prevent anybody else from touching the ring buffer. */
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +8
-0drm_sched_wqueue_stop (&ring->sched); +if (ring->funcs->type ==AMDGPU_RING_TYPE_GFX || + ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE || + ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) +amdgpu_gfx_off_ctrl (adev, false); r =amdgpu_ring_reset (ring, job->vmid, job->hw_fence); +if (ring->funcs->type ==AMDGPU_RING_TYPE_GFX || + ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE || + ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) +amdgpu_gfx_off_ctrl (adev, true);if (!r) {/* Start the scheduler again */ drm_sched_wqueue_start (&ring->sched);
Re: [PATCH 4/6] drm/amdgpu: disallow gfxoff around gfx/compute/sdma KQ reset
Quoted 19 lines · Alexander
AMD General
Quoted 17 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, July 7, 2026 11:34 AM
To: Deucher, Alexander <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 4/6] drm/amdgpu: disallow gfxoff around gfx/compute/sdma KQ resetQuoted 5 lines · Alex Deucher
If the engine is hung, we shouldn't need this since it won't be powered down, but we could potentially have a case where a queue can be preempted, but due to logic errors in the commands, the fence never signals. The engine could potentially go into the off state. Protect against that.
Quoted 5 lines
Quoted 2 lines
On a second thought, is this a real case? If engine already goes to off state, wouldn't everything be reset by default once it comes back?
I'm not sure if gfxoff will actually enter or not, but consider the case of an IB which is waiting for some memory location. It's just waiting so the queue can be preempted, but when it's resumed, it just goes back to waiting so it needs to be reset even though it's not hung per se because it's fence will never signal. For compute queues at least, we peempt all the queues in the reset handler and then reset the bad queues. In theory there could be a window there where gfxoff entry could happen and then we may access a GC register via MMIO when we reset one of the bad queues.
I'm assuming IB execution will be considered as some part of GFX being active. A wakeup from gfxoff requires external intervention, so it's unlikely that it enters gfxoff during the wait. As far as I know, only doorbells could trigger external wakeup.
Thanks,
Lijo
Quoted 36 lines
Alex
Quoted 33 lines
Thanks,
Lijodrivers/gpu/drm/amd/amdgpu/amdgpu_job.c static enum drm_gpu_sched_stat
Quoted 12 lines
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0
-0@@ -137,7 +137,15 @@ static enum drm_gpu_sched_stat
amdgpu_job_timedout(struct drm_sched_job *s_job)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c static enum drm_gpu_sched_stat · line 138
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0
-0s_job->sched->name);/* Stop the scheduler to prevent anybody else from touching the ring buffer. */
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +8
-0drm_sched_wqueue_stop (&ring->sched); +if (ring->funcs->type ==AMDGPU_RING_TYPE_GFX || + ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE || + ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) +amdgpu_gfx_off_ctrl (adev, false); r =amdgpu_ring_reset (ring, job->vmid, job->hw_fence); +if (ring->funcs->type ==AMDGPU_RING_TYPE_GFX || + ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE || + ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) +amdgpu_gfx_off_ctrl (adev, true);if (!r) {/* Start the scheduler again */ drm_sched_wqueue_start (&ring->sched);
Re: [PATCH 4/6] drm/amdgpu: disallow gfxoff around gfx/compute/sdma KQ reset
Quoted 26 lines · Lijo
Quoted 22 lines · Alexander
AMD General
Quoted 19 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, July 7, 2026 11:34 AM
To: Deucher, Alexander <[email protected]>; amd- [email protected]
Subject: Re: [PATCH 4/6] drm/amdgpu: disallow gfxoff around gfx/compute/sdma KQ resetQuoted 5 lines · Alex Deucher
If the engine is hung, we shouldn't need this since it won't be powered down, but we could potentially have a case where a queue can be preempted, but due to logic errors in the commands, the fence never signals. The engine could potentially go into the off state. Protect against that.
On a second thought, is this a real case? If engine already goes to off state, wouldn't everything be reset by default once it comes back?
Quoted 7 lines
Quoted 2 lines
I'm not sure if gfxoff will actually enter or not, but consider the case of an IB which is waiting for some memory location. It's just waiting so the queue can be preempted, but when it's resumed, it just goes back to waiting so it needs to be reset even though it's not hung per se because it's fence will never signal. For compute queues at least, we peempt all the queues in the reset handler and then reset the bad queues. In theory there could be a window there where gfxoff entry could happen and then we may access a GC register via MMIO when we reset one of the bad queues.
I'm assuming IB execution will be considered as some part of GFX being active. A wakeup from gfxoff requires external intervention, so it's unlikely that it enters gfxoff during the wait. As far as I know, only doorbells could trigger external wakeup.
Couldn't gfxoff entry happen after MES preempts queues? if we ring the MES doorbell subsequently it should cause gfxoff entry, but in some cases, we do the reset via MMIO.
Alex
Quoted 40 lines
Thanks,
LijoQuoted 36 lines
Alex
Quoted 33 lines
Thanks,
Lijodrivers/gpu/drm/amd/amdgpu/amdgpu_job.c static enum drm_gpu_sched_stat
Quoted 12 lines
Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0
-0@@ -137,7 +137,15 @@ static enum drm_gpu_sched_stat
amdgpu_job_timedout(struct drm_sched_job *s_job)drivers/gpu/drm/amd/amdgpu/amdgpu_job.c static enum drm_gpu_sched_stat · line 138
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +0
-0s_job->sched->name);/* Stop the scheduler to prevent anybody else from touching the ring buffer. */
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +8
-0drm_sched_wqueue_stop (&ring->sched); +if (ring->funcs->type ==AMDGPU_RING_TYPE_GFX || + ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE || + ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) +amdgpu_gfx_off_ctrl (adev, false); r =amdgpu_ring_reset (ring, job->vmid, job->hw_fence); +if (ring->funcs->type ==AMDGPU_RING_TYPE_GFX || + ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE || + ring->funcs->type ==AMDGPU_RING_TYPE_SDMA ) +amdgpu_gfx_off_ctrl (adev, true);if (!r) {/* Start the scheduler again */ drm_sched_wqueue_start (&ring->sched);
Alex Deucher
maintainerPATCH 5/6 drm/amdgpu: disallow gfxoff around gfx/compute/sdma UQ reset
In reply to Alex DeucherIf the engine is hung, we shouldn't need this since it won't be powered down, but we could potentially have a case where a queue can be preempted, but due to logic errors in the commands, the fence never signals. The engine could potentially go into the off state. Protect against that.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +8 -0
@@ -141,11 +141,19 @@ static void amdgpu_userq_hang_detect_work(struct work_struct *work) AMDGPU_RESET_TYPE_PER_QUEUE)) {int r; +if (queue->queue_type ==AMDGPU_HW_IP_GFX || + queue->queue_type ==AMDGPU_HW_IP_COMPUTE || + queue->queue_type ==AMDGPU_HW_IP_DMA ) +amdgpu_gfx_off_ctrl (adev, false);if (queue->queue_type ==AMDGPU_HW_IP_COMPUTE ) r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL , queue,NULL ,NULL );else r = userq_funcs->reset (queue); +if (queue->queue_type ==AMDGPU_HW_IP_GFX || + queue->queue_type ==AMDGPU_HW_IP_COMPUTE || + queue->queue_type ==AMDGPU_HW_IP_DMA ) +amdgpu_gfx_off_ctrl (adev, true);if (r) gpu_reset = true; } else {
Signature · 1 line
2.55.0
Alex Deucher
maintainerPATCH 6/6 drm/amdkfd: disallow gfxoff around compute/sdma queue reset
In reply to Alex DeucherIf the engine is hung, we shouldn't need this since it won't be powered down, but we could potentially have a case where a queue can be preempted, but due to logic errors in the commands, the fence never signals. The engine could potentially go into the off state. Protect against that.
--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +6 -1
@@ -473,7 +473,9 @@ static int reset_queues_mes(struct device_queue_manager *dqm, struct queue *q) queue_input.remove_queue_after_reset = false; queue_input.xcc_id =ffs (dqm->dev->xcc_mask) -1 ;/* pass the known bad queue info to the reset function */ +amdgpu_gfx_off_ctrl (adev, false); r =amdgpu_gfx_reset_mes_compute (adev,NULL ,NULL ,NULL , &num_hung, &queue_input); +amdgpu_gfx_off_ctrl (adev, true);if (r) goto fail;
@@ -2454,7 +2456,10 @@ static int reset_hung_queues_sdma(struct device_queue_manager *dqm)continue ;/* Reset engine and check. */ -if (amdgpu_sdma_reset_engine (dqm->dev->adev, i, false) || +amdgpu_gfx_off_ctrl (dqm->dev->adev, false); + r =amdgpu_sdma_reset_engine (dqm->dev->adev, i, false); +amdgpu_gfx_off_ctrl (dqm->dev->adev, true); +if (r || dqm->dev->kfd2kgd->hqd_sdma_get_doorbell (dqm->dev->adev, i, j) || !set_sdma_queue_as_reset (dqm, doorbell_off)) { r = -ENOTRECOVERABLE ;
Signature · 1 line
2.55.0