drm/amdgpu/mes12: use proper grbm_select function
Subsystems (2)
Alex Deucher
maintainerPATCH 1/9 drm/amdgpu/mes12: use proper grbm_select function
s/soc21_grbm_select/soc24_grbm_select/
No functional difference as the register offsets are the same.
--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 34 +++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +17 -17
@@ -26,7 +26,7 @@#include "amdgpu.h" #include "gfx_v12_0.h" #include "soc15_common.h" -#include "soc21.h" +#include "soc24.h" #include "gc/gc_12_0_0_offset.h" #include "gc/gc_12_0_0_sh_mask.h" #include "gc/gc_11_0_0_default.h"
@@ -442,7 +442,7 @@ static int mes_v12_0_reset_queue_mmio(struct amdgpu_mes *mes, uint32_t queue_typmutex_unlock (&adev->gfx.reset_sem_mutex);mutex_lock (&adev->srbm_mutex); -soc21_grbm_select (adev, me_id, pipe_id, queue_id,0 ); +soc24_grbm_select (adev, me_id, pipe_id, queue_id,0 );/* wait till dequeue take effects */ for (i =0 ; i < adev->usec_timeout; i++) {if (!(RREG32_SOC15 (GC ,0 , regCP_GFX_HQD_ACTIVE) &1 ))
@@ -454,13 +454,13 @@ static int mes_v12_0_reset_queue_mmio(struct amdgpu_mes *mes, uint32_t queue_typ r = -ETIMEDOUT ; } -soc21_grbm_select (adev,0 ,0 ,0 ,0 ); +soc24_grbm_select (adev,0 ,0 ,0 ,0 );mutex_unlock (&adev->srbm_mutex); }else if (queue_type ==AMDGPU_RING_TYPE_COMPUTE ) {dev_info (adev->dev,"reset compute queue (%d:%d:%d)\n" , me_id, pipe_id, queue_id);mutex_lock (&adev->srbm_mutex); -soc21_grbm_select (adev, me_id, pipe_id, queue_id,0 ); +soc24_grbm_select (adev, me_id, pipe_id, queue_id,0 );WREG32_SOC15 (GC ,0 , regCP_HQD_DEQUEUE_REQUEST,0x2 );WREG32_SOC15 (GC ,0 , regSPI_COMPUTE_QUEUE_RESET,0x1 );
@@ -474,7 +474,7 @@ static int mes_v12_0_reset_queue_mmio(struct amdgpu_mes *mes, uint32_t queue_typdev_err (adev->dev,"failed to wait on hqd deactivate\n" ); r = -ETIMEDOUT ; } -soc21_grbm_select (adev,0 ,0 ,0 ,0 ); +soc24_grbm_select (adev,0 ,0 ,0 ,0 );mutex_unlock (&adev->srbm_mutex); }else if (queue_type ==AMDGPU_RING_TYPE_SDMA ) { dev_info(adev->dev, "reset sdma queue (%d:%d:%d)\n",
@@ -1092,7 +1092,7 @@ static void mes_v12_0_enable(struct amdgpu_device *adev, bool enable)if (enable) {mutex_lock (&adev->srbm_mutex);for (pipe =0 ; pipe <AMDGPU_MAX_MES_PIPES ; pipe++) { -soc21_grbm_select (adev,3 , pipe,0 ,0 ); +soc24_grbm_select (adev,3 , pipe,0 ,0 );if (amdgpu_mes_log_enable) {u32 log_size =AMDGPU_MES_LOG_BUFFER_SIZE +AMDGPU_MES_MSCRATCH_SIZE ;/* In case uni mes is not enabled, only program for pipe 0 */
@@ -1131,7 +1131,7 @@ static void mes_v12_0_enable(struct amdgpu_device *adev, bool enable)WREG32_SOC15 (GC ,0 , regCP_MES_CNTL, data); } -soc21_grbm_select (adev,0 ,0 ,0 ,0 ); +soc24_grbm_select (adev,0 ,0 ,0 ,0 );mutex_unlock (&adev->srbm_mutex);if (amdgpu_emu_mode)
@@ -1163,7 +1163,7 @@ static void mes_v12_0_set_ucode_start_addr(struct amdgpu_device *adev)mutex_lock (&adev->srbm_mutex);for (pipe =0 ; pipe <AMDGPU_MAX_MES_PIPES ; pipe++) {/* me=3, queue=0 */ -soc21_grbm_select (adev,3 , pipe,0 ,0 ); +soc24_grbm_select (adev,3 , pipe,0 ,0 );/* set ucode start address */ ucode_addr = adev->mes.uc_start_addr[pipe] >>2 ;
@@ -1172,7 +1172,7 @@ static void mes_v12_0_set_ucode_start_addr(struct amdgpu_device *adev)WREG32_SOC15 (GC ,0 , regCP_MES_PRGRM_CNTR_START_HI,upper_32_bits (ucode_addr)); -soc21_grbm_select (adev,0 ,0 ,0 ,0 ); +soc24_grbm_select (adev,0 ,0 ,0 ,0 ); }mutex_unlock (&adev->srbm_mutex); }
@@ -1201,7 +1201,7 @@ static int mes_v12_0_load_microcode(struct amdgpu_device *adev,mutex_lock (&adev->srbm_mutex);/* me=3, pipe=0, queue=0 */ -soc21_grbm_select (adev,3 , pipe,0 ,0 ); +soc24_grbm_select (adev,3 , pipe,0 ,0 );WREG32_SOC15 (GC ,0 , regCP_MES_IC_BASE_CNTL,0 );
@@ -1236,7 +1236,7 @@ static int mes_v12_0_load_microcode(struct amdgpu_device *adev,WREG32_SOC15 (GC ,0 , regCP_MES_IC_OP_CNTL, data); } -soc21_grbm_select (adev,0 ,0 ,0 ,0 ); +soc24_grbm_select (adev,0 ,0 ,0 ,0 );mutex_unlock (&adev->srbm_mutex);return 0 ;
@@ -1383,7 +1383,7 @@ static void mes_v12_0_queue_init_register(struct amdgpu_ring *ring)uint32_t data =0 ;mutex_lock (&adev->srbm_mutex); -soc21_grbm_select (adev,3 , ring->pipe,0 ,0 ); +soc24_grbm_select (adev,3 , ring->pipe,0 ,0 );/* set CP_HQD_VMID.VMID = 0. */ data =RREG32_SOC15 (GC ,0 , regCP_HQD_VMID);
@@ -1434,7 +1434,7 @@ static void mes_v12_0_queue_init_register(struct amdgpu_ring *ring)/* set CP_HQD_ACTIVE.ACTIVE=1 */ WREG32_SOC15 (GC ,0 , regCP_HQD_ACTIVE, mqd->cp_hqd_active); -soc21_grbm_select (adev,0 ,0 ,0 ,0 ); +soc24_grbm_select (adev,0 ,0 ,0 ,0 );mutex_unlock (&adev->srbm_mutex); }
@@ -1500,14 +1500,14 @@ static int mes_v12_0_queue_init(struct amdgpu_device *adev, ((pipe == AMDGPU_MES_KIQ_PIPE) && !adev->mes.kiq_version)) {/* get MES scheduler/KIQ versions */ mutex_lock (&adev->srbm_mutex); -soc21_grbm_select (adev,3 , pipe,0 ,0 ); +soc24_grbm_select (adev,3 , pipe,0 ,0 );if (pipe ==AMDGPU_MES_SCHED_PIPE ) adev->mes.sched_version =RREG32_SOC15 (GC ,0 , regCP_MES_GP3_LO);else if (pipe ==AMDGPU_MES_KIQ_PIPE && adev->enable_mes_kiq) adev->mes.kiq_version =RREG32_SOC15 (GC ,0 , regCP_MES_GP3_LO); -soc21_grbm_select (adev,0 ,0 ,0 ,0 ); +soc24_grbm_select (adev,0 ,0 ,0 ,0 );mutex_unlock (&adev->srbm_mutex); }
@@ -1695,7 +1695,7 @@ static void mes_v12_0_kiq_dequeue_sched(struct amdgpu_device *adev)int i;mutex_lock (&adev->srbm_mutex); -soc21_grbm_select (adev,3 ,AMDGPU_MES_SCHED_PIPE ,0 ,0 ); +soc24_grbm_select (adev,3 ,AMDGPU_MES_SCHED_PIPE ,0 ,0 );/* disable the queue if it's active */ if (RREG32_SOC15 (GC ,0 , regCP_HQD_ACTIVE) &1 ) {
@@ -1719,7 +1719,7 @@ static void mes_v12_0_kiq_dequeue_sched(struct amdgpu_device *adev)WREG32_SOC15 (GC ,0 , regCP_HQD_PQ_WPTR_HI,0 );WREG32_SOC15 (GC ,0 , regCP_HQD_PQ_RPTR,0 ); -soc21_grbm_select (adev,0 ,0 ,0 ,0 ); +soc24_grbm_select (adev,0 ,0 ,0 ,0 );mutex_unlock (&adev->srbm_mutex); adev->mes.ring[0 ].sched.ready = false;
Signature · 1 line
2.54.0
Alex Deucher
maintainerPATCH 2/9 drm/amdgpu/gfx11: only need to remap KCQs when reset via MMIO
MES remaps kernels queues as part of it's reset sequence.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +13 -10
@@ -7009,11 +7009,12 @@ static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, struct amdgpu_fence *timedout_fence) {struct amdgpu_device *adev = ring->adev; +bool use_mmio = true;int r =0 ;amdgpu_ring_reset_helper_begin (ring, timedout_fence); - r =amdgpu_mes_reset_legacy_queue (ring->adev, ring, vmid, true,0 ); + r =amdgpu_mes_reset_legacy_queue (ring->adev, ring, vmid, use_mmio,0 );if (r) {dev_warn (adev->dev,"fail(%d) to reset kcq and try pipe reset\n" , r); r =gfx_v11_0_reset_compute_pipe (ring);
@@ -7021,15 +7022,17 @@ static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring,return r; } - r =gfx_v11_0_kcq_init_queue (ring, true); -if (r) { -dev_err (adev->dev,"fail to init kcq\n" ); -return r; - } - r =amdgpu_mes_map_legacy_queue (adev, ring,0 ); -if (r) { -dev_err (adev->dev,"failed to remap kcq\n" ); -return r; +if (use_mmio) { + r =gfx_v11_0_kcq_init_queue (ring, true); +if (r) { +dev_err (adev->dev,"fail to init kcq\n" ); +return r; + } + r =amdgpu_mes_map_legacy_queue (adev, ring,0 ); +if (r) { +dev_err (adev->dev,"failed to remap kcq\n" ); +return r; + } }return amdgpu_ring_reset_helper_end (ring, timedout_fence);
Signature · 1 line
2.54.0
Alex Deucher
maintainerPATCH 3/9 drm/amdgpu/gfx12: only need to remap KCQs when reset via MMIO
In reply to Alex DeucherMES remaps kernels queues as part of it's reset sequence.
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +13 -10
@@ -5397,11 +5397,12 @@ static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring, struct amdgpu_fence *timedout_fence) {struct amdgpu_device *adev = ring->adev; +bool use_mmio = true;int r;amdgpu_ring_reset_helper_begin (ring, timedout_fence); - r =amdgpu_mes_reset_legacy_queue (ring->adev, ring, vmid, true,0 ); + r =amdgpu_mes_reset_legacy_queue (ring->adev, ring, vmid, use_mmio,0 );if (r) {dev_warn (adev->dev,"fail(%d) to reset kcq and try pipe reset\n" , r); r =gfx_v12_0_reset_compute_pipe (ring);
@@ -5409,15 +5410,17 @@ static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring,return r; } - r =gfx_v12_0_kcq_init_queue (ring, true); -if (r) { -dev_err (adev->dev,"failed to init kcq\n" ); -return r; - } - r =amdgpu_mes_map_legacy_queue (adev, ring,0 ); -if (r) { -dev_err (adev->dev,"failed to remap kcq\n" ); -return r; +if (use_mmio) { + r =gfx_v12_0_kcq_init_queue (ring, true); +if (r) { +dev_err (adev->dev,"failed to init kcq\n" ); +return r; + } + r =amdgpu_mes_map_legacy_queue (adev, ring,0 ); +if (r) { +dev_err (adev->dev,"failed to remap kcq\n" ); +return r; + } }return amdgpu_ring_reset_helper_end (ring, timedout_fence);
Signature · 1 line
2.54.0
Alex Deucher
maintainerPATCH 4/9 drm/amdgpu/mes_v12_0: use mes schedule pipe for legacy queues on unified MES
In reply to Alex DeucherFrom: Jesse Zhang <[email protected]>
when suspend_all_gangs is issued to pipe0 MES during system suspend or runtime PM, pipe0 can only suspend and resume queues it has tracked. KCQs registered with a non-zero pipe slot may not be correctly handled, leaving them in an inconsistent state after resume.
v3: fix the schedule pipe issue
v4: use schedule pipe for KQ resets
--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 27 ++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +17 -10
@@ -528,10 +528,15 @@ static int mes_v12_0_map_legacy_queue(struct amdgpu_mes *mes,convert_to_mes_queue_type (input->queue_type); mes_add_queue_pkt.map_legacy_kq =1 ; -if (mes->adev->enable_uni_mes) - pipe =AMDGPU_MES_KIQ_PIPE ; -else +if (mes->adev->enable_uni_mes) { +/* Keep scheduler queue on KIQ pipe; map all other kernel queues on sched pipe. */ +if (input->queue_type ==AMDGPU_RING_TYPE_MES ) + pipe =AMDGPU_MES_KIQ_PIPE ; +else + pipe =AMDGPU_MES_SCHED_PIPE ; + }else { pipe =AMDGPU_MES_SCHED_PIPE ; + } return mes_v12_0_submit_pkt_and_poll_completion(mes, pipe, &mes_add_queue_pkt, sizeof(mes_add_queue_pkt),
@@ -567,10 +572,15 @@ static int mes_v12_0_unmap_legacy_queue(struct amdgpu_mes *mes,convert_to_mes_queue_type (input->queue_type); } -if (mes->adev->enable_uni_mes) - pipe =AMDGPU_MES_KIQ_PIPE ; -else +if (mes->adev->enable_uni_mes) { +/* Keep scheduler queue on KIQ pipe; unmap all other kernel queues on sched pipe. */ +if (input->queue_type ==AMDGPU_RING_TYPE_MES ) + pipe =AMDGPU_MES_KIQ_PIPE ; +else + pipe =AMDGPU_MES_SCHED_PIPE ; + }else { pipe =AMDGPU_MES_SCHED_PIPE ; + } return mes_v12_0_submit_pkt_and_poll_completion(mes, pipe, &mes_remove_queue_pkt, sizeof(mes_remove_queue_pkt),
@@ -913,10 +923,7 @@ static int mes_v12_0_reset_hw_queue(struct amdgpu_mes *mes, mes_reset_queue_pkt.doorbell_offset = input->doorbell_offset; } -if (input->is_kq) - pipe =AMDGPU_MES_KIQ_PIPE ; -else - pipe =AMDGPU_MES_SCHED_PIPE ; + pipe =AMDGPU_MES_SCHED_PIPE ; return mes_v12_0_submit_pkt_and_poll_completion(mes, pipe, &mes_reset_queue_pkt, sizeof(mes_reset_queue_pkt),
Signature · 1 line
2.54.0
Alex Deucher
maintainerPATCH 5/9 drm/amdgpu/mes_v12_1: use mes schedule pipe for legacy queues on unified MES
In reply to Alex DeucherFrom: Jesse Zhang <[email protected]>
when suspend_all_gangs is issued to pipe0 MES during system suspend or runtime PM, pipe0 can only suspend and resume queues it has tracked. KCQs registered with a non-zero pipe slot may not be correctly handled, leaving them in an inconsistent state after resume.
v3: fix the schedule pipe issue
--- drivers/gpu/drm/amd/amdgpu/mes_v12_1.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v12_1.c +16 -6
@@ -417,10 +417,15 @@ static int mes_v12_1_map_legacy_queue(struct amdgpu_mes *mes,convert_to_mes_queue_type (input->queue_type); mes_add_queue_pkt.map_legacy_kq =1 ; -if (mes->adev->enable_uni_mes) - pipe =AMDGPU_MES_KIQ_PIPE ; -else +if (mes->adev->enable_uni_mes) { +/* Keep scheduler queue on KIQ pipe; map all other kernel queues on sched pipe. */ +if (input->queue_type ==AMDGPU_RING_TYPE_MES ) + pipe =AMDGPU_MES_KIQ_PIPE ; +else + pipe =AMDGPU_MES_SCHED_PIPE ; + }else { pipe =AMDGPU_MES_SCHED_PIPE ; + } return mes_v12_1_submit_pkt_and_poll_completion(mes, input->xcc_id, pipe,
@@ -457,10 +462,15 @@ static int mes_v12_1_unmap_legacy_queue(struct amdgpu_mes *mes,convert_to_mes_queue_type (input->queue_type); } -if (mes->adev->enable_uni_mes) - pipe =AMDGPU_MES_KIQ_PIPE ; -else +if (mes->adev->enable_uni_mes) { +/* Keep scheduler queue on KIQ pipe; map all other kernel queues on sched pipe. */ +if (input->queue_type ==AMDGPU_RING_TYPE_MES ) + pipe =AMDGPU_MES_KIQ_PIPE ; +else + pipe =AMDGPU_MES_SCHED_PIPE ; + }else { pipe =AMDGPU_MES_SCHED_PIPE ; + } return mes_v12_1_submit_pkt_and_poll_completion(mes, input->xcc_id, pipe,
Signature · 1 line
2.54.0
Alex Deucher
maintainerPATCH 6/9 drm/amdgpu/gfx11: Refactor compute pipe reset and add HQD cleanup
In reply to Alex DeucherFrom: Jesse Zhang <[email protected]>
Refactor gfx_v11_0_reset_compute_pipe() to accept explicit me, pipe, and queue parameters instead of deriving them from the ring structure. This enables the function to be used in generic pipe reset flows.
Introduce gfx_v11_0_clear_hqds_on_mec_pipe() to properly clear CP_HQD_ACTIVE and CP_HQD_DEQUEUE_REQUEST for all queues on a given MEC pipe while the pipe reset is asserted, ensuring the HQDs are torn down correctly before deasserting reset.
Switch the KCQ reset path to use the common MEC pipe reset helper amdgpu_gfx_mec_pipe_reset_run(), which coordinates the reset sequence including KFD suspend/resume to avoid conflicts with user mode queues.
v2: just update the sequence (Alex)
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 166 +++++++++++++++---------- 1 file changed, 100 insertions(+), 66 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +100 -66
@@ -6874,11 +6874,39 @@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring,return amdgpu_ring_reset_helper_end (ring, timedout_fence); } -static int gfx_v11_0_reset_compute_pipe (struct amdgpu_ring *ring) +/* +* With MEC pipe reset asserted, clear CP_HQD_ACTIVE / CP_HQD_DEQUEUE_REQUEST for +* every queue on (me, pipe). HQDs must be torn down while pipe reset stays +* asserted; only then clear the pipe reset bit. +* Caller must hold adev->srbm_mutex. +*/ +static void gfx_v11_0_clear_hqds_on_mec_pipe (struct amdgpu_device *adev,u32 me, +u32 pipe) { +unsigned int q; +int j; -struct amdgpu_device *adev = ring->adev; -uint32_t reset_pipe =0 , clean_pipe =0 ; +for (q =0 ; q < adev->gfx.mec.num_queue_per_pipe; q++) { +soc21_grbm_select (adev, me, pipe, q,0 ); +/* Start from a clean HQD dequeue state before forcing HQD inactive. */ +WREG32_SOC15 (GC ,0 , regCP_HQD_ACTIVE,0 ); +if (RREG32_SOC15 (GC ,0 , regCP_HQD_ACTIVE) &1 ) { +WREG32_SOC15 (GC ,0 , regCP_HQD_DEQUEUE_REQUEST,1 ); +for (j =0 ; j < adev->usec_timeout; j++) { +if (!(RREG32_SOC15 (GC ,0 , regCP_HQD_ACTIVE) &1 )) +break ; +udelay (1 ); + } + } + +WREG32_SOC15 (GC ,0 , regCP_HQD_DEQUEUE_REQUEST,0 ); + } +} + +static int gfx_v11_0_reset_compute_pipe (struct amdgpu_device *adev, +u32 me,u32 pipe,u32 queue) +{ +uint32_t reset_val, clean_val;int r;if (!gfx_v11_pipe_reset_support (adev))
@@ -6886,109 +6914,115 @@ static int gfx_v11_0_reset_compute_pipe(struct amdgpu_ring *ring)gfx_v11_0_set_safe_mode (adev,0 );mutex_lock (&adev->srbm_mutex); -soc21_grbm_select (adev, ring->me, ring->pipe, ring->queue,0 ); - - reset_pipe =RREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL); - clean_pipe = reset_pipe; +soc21_grbm_select (adev, me, pipe, queue,0 );if (adev->gfx.rs64_enable) { + reset_val =RREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL); + clean_val = reset_val; -switch (ring->pipe) { +switch (pipe) {case 0 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_RS64_CNTL , -MEC_PIPE0_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_RS64_CNTL , -MEC_PIPE0_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_RS64_CNTL , +MEC_PIPE0_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_RS64_CNTL , +MEC_PIPE0_RESET ,0 );break ;case 1 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_RS64_CNTL , -MEC_PIPE1_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_RS64_CNTL , -MEC_PIPE1_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_RS64_CNTL , +MEC_PIPE1_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_RS64_CNTL , +MEC_PIPE1_RESET ,0 );break ;case 2 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_RS64_CNTL , -MEC_PIPE2_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_RS64_CNTL , -MEC_PIPE2_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_RS64_CNTL , +MEC_PIPE2_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_RS64_CNTL , +MEC_PIPE2_RESET ,0 );break ;case 3 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_RS64_CNTL , -MEC_PIPE3_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_RS64_CNTL , -MEC_PIPE3_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_RS64_CNTL , +MEC_PIPE3_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_RS64_CNTL , +MEC_PIPE3_RESET ,0 );break ;default :break ; } -WREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL, reset_pipe); -WREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL, clean_pipe); +WREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL, reset_val); +gfx_v11_0_clear_hqds_on_mec_pipe (adev, me, pipe); +soc21_grbm_select (adev, me, pipe, queue,0 ); +WREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL, clean_val); r = (RREG32_SOC15 (GC ,0 , regCP_MEC_RS64_INSTR_PNTR) <<2 ) -RS64_FW_UC_START_ADDR_LO ; }else { -if (ring->me ==1 ) { -switch (ring->pipe) { + reset_val =RREG32_SOC15 (GC ,0 , regCP_MEC_CNTL); + clean_val = reset_val; + +if (me ==1 ) { +switch (pipe) {case 0 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_CNTL , -MEC_ME1_PIPE0_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_CNTL , -MEC_ME1_PIPE0_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , +MEC_ME1_PIPE0_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , +MEC_ME1_PIPE0_RESET ,0 );break ;case 1 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_CNTL , -MEC_ME1_PIPE1_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_CNTL , -MEC_ME1_PIPE1_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , +MEC_ME1_PIPE1_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , +MEC_ME1_PIPE1_RESET ,0 );break ;case 2 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_CNTL , -MEC_ME1_PIPE2_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_CNTL , -MEC_ME1_PIPE2_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , +MEC_ME1_PIPE2_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , +MEC_ME1_PIPE2_RESET ,0 );break ;case 3 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_CNTL , -MEC_ME1_PIPE3_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_CNTL , -MEC_ME1_PIPE3_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , +MEC_ME1_PIPE3_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , +MEC_ME1_PIPE3_RESET ,0 );break ;default :break ; }/* mec1 fw pc: CP_MEC1_INSTR_PNTR */ }else { -switch (ring->pipe) { +switch (pipe) {case 0 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_CNTL , -MEC_ME2_PIPE0_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_CNTL , -MEC_ME2_PIPE0_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , +MEC_ME2_PIPE0_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , +MEC_ME2_PIPE0_RESET ,0 );break ;case 1 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_CNTL , -MEC_ME2_PIPE1_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_CNTL , -MEC_ME2_PIPE1_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , +MEC_ME2_PIPE1_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , +MEC_ME2_PIPE1_RESET ,0 );break ;case 2 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_CNTL , -MEC_ME2_PIPE2_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_CNTL , -MEC_ME2_PIPE2_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , +MEC_ME2_PIPE2_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , +MEC_ME2_PIPE2_RESET ,0 );break ;case 3 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_CNTL , -MEC_ME2_PIPE3_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_CNTL , -MEC_ME2_PIPE3_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , +MEC_ME2_PIPE3_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , +MEC_ME2_PIPE3_RESET ,0 );break ;default :break ; }/* mec2 fw pc: CP:CP_MEC2_INSTR_PNTR */ } -WREG32_SOC15 (GC ,0 , regCP_MEC_CNTL, reset_pipe); -WREG32_SOC15 (GC ,0 , regCP_MEC_CNTL, clean_pipe); +WREG32_SOC15 (GC ,0 , regCP_MEC_CNTL, reset_val); +gfx_v11_0_clear_hqds_on_mec_pipe (adev, me, pipe); +soc21_grbm_select (adev, me, pipe, queue,0 ); +WREG32_SOC15 (GC ,0 , regCP_MEC_CNTL, clean_val); r =RREG32 (SOC15_REG_OFFSET (GC ,0 , regCP_MEC1_INSTR_PNTR)); }
@@ -6996,8 +7030,8 @@ static int gfx_v11_0_reset_compute_pipe(struct amdgpu_ring *ring)mutex_unlock (&adev->srbm_mutex);gfx_v11_0_unset_safe_mode (adev,0 ); -dev_info (adev->dev,"The ring %s pipe resets to MEC FW start PC: %s\n" , ring->name, - r ==0 ?"successfully" :"failed" ); +dev_dbg (adev->dev,"MEC pipe me%u pipe%u queue%u resets to MEC FW start PC: %s\n" , + me, pipe, queue, r ==0 ?"successfully" :"failed" );/*FIXME:Sometimes driver can't cache the MEC firmware start PC correctly, so the pipe * reset status relies on the compute ring test result. */
@@ -7017,7 +7051,7 @@ static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring, r =amdgpu_mes_reset_legacy_queue (ring->adev, ring, vmid, use_mmio,0 );if (r) {dev_warn (adev->dev,"fail(%d) to reset kcq and try pipe reset\n" , r); - r =gfx_v11_0_reset_compute_pipe (ring); + r =gfx_v11_0_reset_compute_pipe (adev, ring->me, ring->pipe, ring->queue);if (r)return r; }
Signature · 1 line
2.54.0
Alex Deucher
maintainerPATCH 7/9 drm/amdgpu/gfx12: Refactor compute pipe reset and add HQD cleanup
In reply to Alex DeucherFrom: Jesse Zhang <[email protected]>
Refactor gfx_v12_0_reset_compute_pipe() to accept explicit me, pipe, and queue parameters instead of deriving them from the ring structure. This enables the function to be used in generic pipe reset flows.
Introduce gfx_v12_0_clear_hqds_on_mec_pipe() to properly clear CP_HQD_ACTIVE and CP_HQD_DEQUEUE_REQUEST for all queues on a given MEC pipe while the pipe reset is asserted, ensuring the HQDs are torn down correctly before deasserting reset.
Switch the KCQ reset path to use the common MEC pipe reset helper amdgpu_gfx_mec_pipe_reset_run(), which coordinates the reset sequence including KFD suspend/resume to avoid conflicts with user mode queues.
v2: just update the sequence (Alex)
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 123 ++++++++++++++++--------- 1 file changed, 77 insertions(+), 46 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +77 -46
@@ -5309,10 +5309,38 @@ static int gfx_v12_0_reset_kgq(struct amdgpu_ring *ring,return amdgpu_ring_reset_helper_end (ring, timedout_fence); } -static int gfx_v12_0_reset_compute_pipe (struct amdgpu_ring *ring) +/* +* With MEC pipe reset asserted, clear CP_HQD_ACTIVE / CP_HQD_DEQUEUE_REQUEST for +* every queue on (me, pipe). HQDs must be torn down while pipe reset stays +* asserted; only then clear the pipe reset bit. +* Caller must hold adev->srbm_mutex. +*/ +static void gfx_v12_0_clear_hqds_on_mec_pipe (struct amdgpu_device *adev,u32 me, +u32 pipe) { -struct amdgpu_device *adev = ring->adev; -uint32_t reset_pipe =0 , clean_pipe =0 ; +unsigned int q; +int j; + +for (q =0 ; q < adev->gfx.mec.num_queue_per_pipe; q++) { +soc24_grbm_select (adev, me, pipe, q,0 ); +/* Start from a clean HQD dequeue state before forcing HQD inactive. */ +WREG32_SOC15 (GC ,0 , regCP_HQD_ACTIVE,0 ); +if (RREG32_SOC15 (GC ,0 , regCP_HQD_ACTIVE) &1 ) { +WREG32_SOC15 (GC ,0 , regCP_HQD_DEQUEUE_REQUEST,1 ); +for (j =0 ; j < adev->usec_timeout; j++) { +if (!(RREG32_SOC15 (GC ,0 , regCP_HQD_ACTIVE) &1 )) +break ; +udelay (1 ); + } + } +WREG32_SOC15 (GC ,0 , regCP_HQD_DEQUEUE_REQUEST,0 ); + } +} + +static int gfx_v12_0_reset_compute_pipe (struct amdgpu_device *adev, +u32 me,u32 pipe,u32 queue) +{ +uint32_t reset_val, clean_val;int r =0 ;if (!gfx_v12_pipe_reset_support (adev))
@@ -5320,75 +5348,78 @@ static int gfx_v12_0_reset_compute_pipe(struct amdgpu_ring *ring)gfx_v12_0_set_safe_mode (adev,0 );mutex_lock (&adev->srbm_mutex); -soc24_grbm_select (adev, ring->me, ring->pipe, ring->queue,0 ); - - reset_pipe =RREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL); - clean_pipe = reset_pipe; - +soc24_grbm_select (adev, me, pipe, queue,0 );if (adev->gfx.rs64_enable) { -switch (ring->pipe) { + reset_val =RREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL); + clean_val = reset_val; + +switch (pipe) {case 0 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_RS64_CNTL , -MEC_PIPE0_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_RS64_CNTL , -MEC_PIPE0_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_RS64_CNTL , +MEC_PIPE0_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_RS64_CNTL , +MEC_PIPE0_RESET ,0 );break ;case 1 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_RS64_CNTL , -MEC_PIPE1_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_RS64_CNTL , -MEC_PIPE1_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_RS64_CNTL , +MEC_PIPE1_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_RS64_CNTL , +MEC_PIPE1_RESET ,0 );break ;case 2 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_RS64_CNTL , -MEC_PIPE2_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_RS64_CNTL , -MEC_PIPE2_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_RS64_CNTL , +MEC_PIPE2_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_RS64_CNTL , +MEC_PIPE2_RESET ,0 );break ;case 3 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_RS64_CNTL , -MEC_PIPE3_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_RS64_CNTL , -MEC_PIPE3_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_RS64_CNTL , +MEC_PIPE3_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_RS64_CNTL , +MEC_PIPE3_RESET ,0 );break ;default :break ; } -WREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL, reset_pipe); -WREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL, clean_pipe); +WREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL, reset_val); +gfx_v12_0_clear_hqds_on_mec_pipe (adev, me, pipe); +soc24_grbm_select (adev, me, pipe, queue,0 ); +WREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL, clean_val); r = (RREG32_SOC15 (GC ,0 , regCP_MEC_RS64_INSTR_PNTR) <<2 ) -RS64_FW_UC_START_ADDR_LO ; }else { -switch (ring->pipe) { + reset_val =RREG32_SOC15 (GC ,0 , regCP_MEC_CNTL); + clean_val = reset_val; + +switch (pipe) {case 0 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_CNTL , -MEC_ME1_PIPE0_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_CNTL , -MEC_ME1_PIPE0_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , +MEC_ME1_PIPE0_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , +MEC_ME1_PIPE0_RESET ,0 );break ;case 1 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_MEC_CNTL , -MEC_ME1_PIPE1_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_MEC_CNTL , -MEC_ME1_PIPE1_RESET ,0 ); + reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , +MEC_ME1_PIPE1_RESET ,1 ); + clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , +MEC_ME1_PIPE1_RESET ,0 );break ;default : -break ; +break ; } -WREG32_SOC15 (GC ,0 , regCP_MEC_CNTL, reset_pipe); -WREG32_SOC15 (GC ,0 , regCP_MEC_CNTL, clean_pipe); -/* Doesn't find the F32 MEC instruction pointer register, and suppose -* the driver won't run into the F32 mode. -*/ + +WREG32_SOC15 (GC ,0 , regCP_MEC_CNTL, reset_val); +gfx_v12_0_clear_hqds_on_mec_pipe (adev, me, pipe); +soc24_grbm_select (adev, me, pipe, queue,0 ); +WREG32_SOC15 (GC ,0 , regCP_MEC_CNTL, clean_val); }soc24_grbm_select (adev,0 ,0 ,0 ,0 );mutex_unlock (&adev->srbm_mutex);gfx_v12_0_unset_safe_mode (adev,0 ); -dev_info (adev->dev,"The ring %s pipe resets: %s\n" , ring->name, - r ==0 ?"successfully" :"failed" ); -/* Need the ring test to verify the pipe reset result.*/ +dev_dbg (adev->dev,"MEC pipe me%u pipe%u queue%u resets to MEC FW start PC: %s\n" , + me, pipe, queue, r ==0 ?"successfully" :"failed" );return 0 ; }
@@ -5405,7 +5436,7 @@ static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring, r =amdgpu_mes_reset_legacy_queue (ring->adev, ring, vmid, use_mmio,0 );if (r) {dev_warn (adev->dev,"fail(%d) to reset kcq and try pipe reset\n" , r); - r =gfx_v12_0_reset_compute_pipe (ring); + r =gfx_v12_0_reset_compute_pipe (adev, ring->me, ring->pipe, ring->queue);if (r)return r; }
Signature · 1 line
2.54.0
Alex Deucher
maintainerPATCH 8/9 drm/amdgpu/mes11: move pipe reset to mes use_mmio patch
In reply to Alex DeucherThis makes the code flows cleaner and it's only supported on the use_mmio path.
v2: fix typo
v3: fix typo
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 244 +----------------------- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 253 ++++++++++++++++++++++++- 2 files changed, 253 insertions(+), 244 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +4 -240
@@ -6775,69 +6775,6 @@ static void gfx_v11_0_emit_mem_sync(struct amdgpu_ring *ring)amdgpu_ring_write (ring, gcr_cntl);/* GCR_CNTL */ } -static bool gfx_v11_pipe_reset_support (struct amdgpu_device *adev) -{ -/* Disable the pipe reset until the CPFW fully support it.*/ -dev_warn_once (adev->dev,"The CPFW hasn't support pipe reset yet.\n" ); -return false; -} - - -static int gfx_v11_reset_gfx_pipe (struct amdgpu_ring *ring) -{ -struct amdgpu_device *adev = ring->adev; -uint32_t reset_pipe =0 , clean_pipe =0 ; -int r; - -if (!gfx_v11_pipe_reset_support (adev)) -return -EOPNOTSUPP ; - -gfx_v11_0_set_safe_mode (adev,0 ); -mutex_lock (&adev->srbm_mutex); -soc21_grbm_select (adev, ring->me, ring->pipe, ring->queue,0 ); - -switch (ring->pipe) { -case 0 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_ME_CNTL , -PFP_PIPE0_RESET ,1 ); - reset_pipe =REG_SET_FIELD (reset_pipe,CP_ME_CNTL , -ME_PIPE0_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_ME_CNTL , -PFP_PIPE0_RESET ,0 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_ME_CNTL , -ME_PIPE0_RESET ,0 ); -break ; -case 1 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_ME_CNTL , -PFP_PIPE1_RESET ,1 ); - reset_pipe =REG_SET_FIELD (reset_pipe,CP_ME_CNTL , -ME_PIPE1_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_ME_CNTL , -PFP_PIPE1_RESET ,0 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_ME_CNTL , -ME_PIPE1_RESET ,0 ); -break ; -default : -break ; - } - -WREG32_SOC15 (GC ,0 , regCP_ME_CNTL, reset_pipe); -WREG32_SOC15 (GC ,0 , regCP_ME_CNTL, clean_pipe); - - r = (RREG32 (SOC15_REG_OFFSET (GC ,0 , regCP_GFX_RS64_INSTR_PNTR1)) <<2 ) - -RS64_FW_UC_START_ADDR_LO ; -soc21_grbm_select (adev,0 ,0 ,0 ,0 ); -mutex_unlock (&adev->srbm_mutex); -gfx_v11_0_unset_safe_mode (adev,0 ); - -dev_info (adev->dev,"The ring %s pipe reset to the ME firmware start PC: %s\n" , ring->name, - r ==0 ?"successfully" :"failed" ); -/* FIXME: Sometimes driver can't cache the ME firmware start PC correctly, -* so the pipe reset status relies on the later gfx ring test result. -*/ -return 0 ; -} -static int gfx_v11_0_reset_kgq (struct amdgpu_ring *ring,unsigned int vmid,struct amdgpu_fence *timedout_fence)
@@ -6849,13 +6786,8 @@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring,amdgpu_ring_reset_helper_begin (ring, timedout_fence); r =amdgpu_mes_reset_legacy_queue (ring->adev, ring, vmid, use_mmio,0 ); -if (r) { - -dev_warn (adev->dev,"reset via MES failed and try pipe reset %d\n" , r); - r =gfx_v11_reset_gfx_pipe (ring); -if (r) -return r; - } +if (r) +return r;if (use_mmio) { r =gfx_v11_0_kgq_init_queue (ring, true);
@@ -6874,170 +6806,6 @@ static int gfx_v11_0_reset_kgq(struct amdgpu_ring *ring,return amdgpu_ring_reset_helper_end (ring, timedout_fence); } -/* -* With MEC pipe reset asserted, clear CP_HQD_ACTIVE / CP_HQD_DEQUEUE_REQUEST for -* every queue on (me, pipe). HQDs must be torn down while pipe reset stays -* asserted; only then clear the pipe reset bit. -* Caller must hold adev->srbm_mutex. -*/ -static void gfx_v11_0_clear_hqds_on_mec_pipe (struct amdgpu_device *adev,u32 me, -u32 pipe) -{ -unsigned int q; -int j; - -for (q =0 ; q < adev->gfx.mec.num_queue_per_pipe; q++) { -soc21_grbm_select (adev, me, pipe, q,0 ); -/* Start from a clean HQD dequeue state before forcing HQD inactive. */ -WREG32_SOC15 (GC ,0 , regCP_HQD_ACTIVE,0 ); -if (RREG32_SOC15 (GC ,0 , regCP_HQD_ACTIVE) &1 ) { -WREG32_SOC15 (GC ,0 , regCP_HQD_DEQUEUE_REQUEST,1 ); -for (j =0 ; j < adev->usec_timeout; j++) { -if (!(RREG32_SOC15 (GC ,0 , regCP_HQD_ACTIVE) &1 )) -break ; -udelay (1 ); - } - } - -WREG32_SOC15 (GC ,0 , regCP_HQD_DEQUEUE_REQUEST,0 ); - } -} - -static int gfx_v11_0_reset_compute_pipe (struct amdgpu_device *adev, -u32 me,u32 pipe,u32 queue) -{ -uint32_t reset_val, clean_val; -int r; - -if (!gfx_v11_pipe_reset_support (adev)) -return -EOPNOTSUPP ; - -gfx_v11_0_set_safe_mode (adev,0 ); -mutex_lock (&adev->srbm_mutex); -soc21_grbm_select (adev, me, pipe, queue,0 ); - -if (adev->gfx.rs64_enable) { - reset_val =RREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL); - clean_val = reset_val; - -switch (pipe) { -case 0 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_RS64_CNTL , -MEC_PIPE0_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_RS64_CNTL , -MEC_PIPE0_RESET ,0 ); -break ; -case 1 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_RS64_CNTL , -MEC_PIPE1_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_RS64_CNTL , -MEC_PIPE1_RESET ,0 ); -break ; -case 2 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_RS64_CNTL , -MEC_PIPE2_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_RS64_CNTL , -MEC_PIPE2_RESET ,0 ); -break ; -case 3 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_RS64_CNTL , -MEC_PIPE3_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_RS64_CNTL , -MEC_PIPE3_RESET ,0 ); -break ; -default : -break ; - } -WREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL, reset_val); -gfx_v11_0_clear_hqds_on_mec_pipe (adev, me, pipe); -soc21_grbm_select (adev, me, pipe, queue,0 ); -WREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL, clean_val); - r = (RREG32_SOC15 (GC ,0 , regCP_MEC_RS64_INSTR_PNTR) <<2 ) - -RS64_FW_UC_START_ADDR_LO ; - }else { - reset_val =RREG32_SOC15 (GC ,0 , regCP_MEC_CNTL); - clean_val = reset_val; - -if (me ==1 ) { -switch (pipe) { -case 0 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , -MEC_ME1_PIPE0_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , -MEC_ME1_PIPE0_RESET ,0 ); -break ; -case 1 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , -MEC_ME1_PIPE1_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , -MEC_ME1_PIPE1_RESET ,0 ); -break ; -case 2 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , -MEC_ME1_PIPE2_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , -MEC_ME1_PIPE2_RESET ,0 ); -break ; -case 3 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , -MEC_ME1_PIPE3_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , -MEC_ME1_PIPE3_RESET ,0 ); -break ; -default : -break ; - } -/* mec1 fw pc: CP_MEC1_INSTR_PNTR */ - }else { -switch (pipe) { -case 0 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , -MEC_ME2_PIPE0_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , -MEC_ME2_PIPE0_RESET ,0 ); -break ; -case 1 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , -MEC_ME2_PIPE1_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , -MEC_ME2_PIPE1_RESET ,0 ); -break ; -case 2 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , -MEC_ME2_PIPE2_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , -MEC_ME2_PIPE2_RESET ,0 ); -break ; -case 3 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , -MEC_ME2_PIPE3_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , -MEC_ME2_PIPE3_RESET ,0 ); -break ; -default : -break ; - } -/* mec2 fw pc: CP:CP_MEC2_INSTR_PNTR */ - } -WREG32_SOC15 (GC ,0 , regCP_MEC_CNTL, reset_val); -gfx_v11_0_clear_hqds_on_mec_pipe (adev, me, pipe); -soc21_grbm_select (adev, me, pipe, queue,0 ); -WREG32_SOC15 (GC ,0 , regCP_MEC_CNTL, clean_val); - r =RREG32 (SOC15_REG_OFFSET (GC ,0 , regCP_MEC1_INSTR_PNTR)); - } - -soc21_grbm_select (adev,0 ,0 ,0 ,0 ); -mutex_unlock (&adev->srbm_mutex); -gfx_v11_0_unset_safe_mode (adev,0 ); - -dev_dbg (adev->dev,"MEC pipe me%u pipe%u queue%u resets to MEC FW start PC: %s\n" , - me, pipe, queue, r ==0 ?"successfully" :"failed" ); -/*FIXME:Sometimes driver can't cache the MEC firmware start PC correctly, so the pipe -* reset status relies on the compute ring test result. -*/ -return 0 ; -} -static int gfx_v11_0_reset_kcq (struct amdgpu_ring *ring,unsigned int vmid,struct amdgpu_fence *timedout_fence)
@@ -7049,12 +6817,8 @@ static int gfx_v11_0_reset_kcq(struct amdgpu_ring *ring,amdgpu_ring_reset_helper_begin (ring, timedout_fence); r =amdgpu_mes_reset_legacy_queue (ring->adev, ring, vmid, use_mmio,0 ); -if (r) { -dev_warn (adev->dev,"fail(%d) to reset kcq and try pipe reset\n" , r); - r =gfx_v11_0_reset_compute_pipe (adev, ring->me, ring->pipe, ring->queue); -if (r) -return r; - } +if (r) +return r;if (use_mmio) { r =gfx_v11_0_kcq_init_queue (ring, true);
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +249 -4
265 lines not on this page · raw message
Signature · 1 line
2.54.0
Alex Deucher
maintainerPATCH 9/9 drm/amdgpu/mes12: move pipe reset to mes use_mmio patch
In reply to Alex DeucherThis makes the code flows cleaner and it's only supported on the use_mmio path.
v2: fix typo
v3: fix typo
--- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 193 +---------------------- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 205 ++++++++++++++++++++++++- 2 files changed, 205 insertions(+), 193 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +4 -189
@@ -5211,69 +5211,6 @@ static void gfx_v12_ip_dump(struct amdgpu_ip_block *ip_block)amdgpu_gfx_off_ctrl (adev, true); } -static bool gfx_v12_pipe_reset_support (struct amdgpu_device *adev) -{ -/* Disable the pipe reset until the CPFW fully support it.*/ -dev_warn_once (adev->dev,"The CPFW hasn't support pipe reset yet.\n" ); -return false; -} - -static int gfx_v12_reset_gfx_pipe (struct amdgpu_ring *ring) -{ -struct amdgpu_device *adev = ring->adev; -uint32_t reset_pipe =0 , clean_pipe =0 ; -int r; - -if (!gfx_v12_pipe_reset_support (adev)) -return -EOPNOTSUPP ; - -gfx_v12_0_set_safe_mode (adev,0 ); -mutex_lock (&adev->srbm_mutex); -soc24_grbm_select (adev, ring->me, ring->pipe, ring->queue,0 ); - -switch (ring->pipe) { -case 0 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_ME_CNTL , -PFP_PIPE0_RESET ,1 ); - reset_pipe =REG_SET_FIELD (reset_pipe,CP_ME_CNTL , -ME_PIPE0_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_ME_CNTL , -PFP_PIPE0_RESET ,0 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_ME_CNTL , -ME_PIPE0_RESET ,0 ); -break ; -case 1 : - reset_pipe =REG_SET_FIELD (reset_pipe,CP_ME_CNTL , -PFP_PIPE1_RESET ,1 ); - reset_pipe =REG_SET_FIELD (reset_pipe,CP_ME_CNTL , -ME_PIPE1_RESET ,1 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_ME_CNTL , -PFP_PIPE1_RESET ,0 ); - clean_pipe =REG_SET_FIELD (clean_pipe,CP_ME_CNTL , -ME_PIPE1_RESET ,0 ); -break ; -default : -break ; - } - -WREG32_SOC15 (GC ,0 , regCP_ME_CNTL, reset_pipe); -WREG32_SOC15 (GC ,0 , regCP_ME_CNTL, clean_pipe); - - r = (RREG32 (SOC15_REG_OFFSET (GC ,0 , regCP_GFX_RS64_INSTR_PNTR1)) <<2 ) - -RS64_FW_UC_START_ADDR_LO ; -soc24_grbm_select (adev,0 ,0 ,0 ,0 ); -mutex_unlock (&adev->srbm_mutex); -gfx_v12_0_unset_safe_mode (adev,0 ); - -dev_info (adev->dev,"The ring %s pipe reset: %s\n" , ring->name, - r ==0 ?"successfully" :"failed" ); -/* Sometimes the ME start pc counter can't cache correctly, so the -* PC check only as a reference and pipe reset result rely on the -* later ring test. -*/ -return 0 ; -} -static int gfx_v12_0_reset_kgq (struct amdgpu_ring *ring,unsigned int vmid,struct amdgpu_fence *timedout_fence)
@@ -5285,12 +5222,8 @@ static int gfx_v12_0_reset_kgq(struct amdgpu_ring *ring,amdgpu_ring_reset_helper_begin (ring, timedout_fence); r =amdgpu_mes_reset_legacy_queue (ring->adev, ring, vmid, use_mmio,0 ); -if (r) { -dev_warn (adev->dev,"reset via MES failed and try pipe reset %d\n" , r); - r =gfx_v12_reset_gfx_pipe (ring); -if (r) -return r; - } +if (r) +return r;if (use_mmio) { r =gfx_v12_0_kgq_init_queue (ring, true);
@@ -5309,120 +5242,6 @@ static int gfx_v12_0_reset_kgq(struct amdgpu_ring *ring,return amdgpu_ring_reset_helper_end (ring, timedout_fence); } -/* -* With MEC pipe reset asserted, clear CP_HQD_ACTIVE / CP_HQD_DEQUEUE_REQUEST for -* every queue on (me, pipe). HQDs must be torn down while pipe reset stays -* asserted; only then clear the pipe reset bit. -* Caller must hold adev->srbm_mutex. -*/ -static void gfx_v12_0_clear_hqds_on_mec_pipe (struct amdgpu_device *adev,u32 me, -u32 pipe) -{ -unsigned int q; -int j; - -for (q =0 ; q < adev->gfx.mec.num_queue_per_pipe; q++) { -soc24_grbm_select (adev, me, pipe, q,0 ); -/* Start from a clean HQD dequeue state before forcing HQD inactive. */ -WREG32_SOC15 (GC ,0 , regCP_HQD_ACTIVE,0 ); -if (RREG32_SOC15 (GC ,0 , regCP_HQD_ACTIVE) &1 ) { -WREG32_SOC15 (GC ,0 , regCP_HQD_DEQUEUE_REQUEST,1 ); -for (j =0 ; j < adev->usec_timeout; j++) { -if (!(RREG32_SOC15 (GC ,0 , regCP_HQD_ACTIVE) &1 )) -break ; -udelay (1 ); - } - } -WREG32_SOC15 (GC ,0 , regCP_HQD_DEQUEUE_REQUEST,0 ); - } -} - -static int gfx_v12_0_reset_compute_pipe (struct amdgpu_device *adev, -u32 me,u32 pipe,u32 queue) -{ -uint32_t reset_val, clean_val; -int r =0 ; - -if (!gfx_v12_pipe_reset_support (adev)) -return -EOPNOTSUPP ; - -gfx_v12_0_set_safe_mode (adev,0 ); -mutex_lock (&adev->srbm_mutex); -soc24_grbm_select (adev, me, pipe, queue,0 ); -if (adev->gfx.rs64_enable) { - reset_val =RREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL); - clean_val = reset_val; - -switch (pipe) { -case 0 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_RS64_CNTL , -MEC_PIPE0_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_RS64_CNTL , -MEC_PIPE0_RESET ,0 ); -break ; -case 1 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_RS64_CNTL , -MEC_PIPE1_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_RS64_CNTL , -MEC_PIPE1_RESET ,0 ); -break ; -case 2 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_RS64_CNTL , -MEC_PIPE2_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_RS64_CNTL , -MEC_PIPE2_RESET ,0 ); -break ; -case 3 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_RS64_CNTL , -MEC_PIPE3_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_RS64_CNTL , -MEC_PIPE3_RESET ,0 ); -break ; -default : -break ; - } -WREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL, reset_val); -gfx_v12_0_clear_hqds_on_mec_pipe (adev, me, pipe); -soc24_grbm_select (adev, me, pipe, queue,0 ); -WREG32_SOC15 (GC ,0 , regCP_MEC_RS64_CNTL, clean_val); - r = (RREG32_SOC15 (GC ,0 , regCP_MEC_RS64_INSTR_PNTR) <<2 ) - -RS64_FW_UC_START_ADDR_LO ; - }else { - reset_val =RREG32_SOC15 (GC ,0 , regCP_MEC_CNTL); - clean_val = reset_val; - -switch (pipe) { -case 0 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , -MEC_ME1_PIPE0_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , -MEC_ME1_PIPE0_RESET ,0 ); -break ; -case 1 : - reset_val =REG_SET_FIELD (reset_val,CP_MEC_CNTL , -MEC_ME1_PIPE1_RESET ,1 ); - clean_val =REG_SET_FIELD (clean_val,CP_MEC_CNTL , -MEC_ME1_PIPE1_RESET ,0 ); -break ; -default : -break ; - } - -WREG32_SOC15 (GC ,0 , regCP_MEC_CNTL, reset_val); -gfx_v12_0_clear_hqds_on_mec_pipe (adev, me, pipe); -soc24_grbm_select (adev, me, pipe, queue,0 ); -WREG32_SOC15 (GC ,0 , regCP_MEC_CNTL, clean_val); - } - -soc24_grbm_select (adev,0 ,0 ,0 ,0 ); -mutex_unlock (&adev->srbm_mutex); -gfx_v12_0_unset_safe_mode (adev,0 ); - -dev_dbg (adev->dev,"MEC pipe me%u pipe%u queue%u resets to MEC FW start PC: %s\n" , - me, pipe, queue, r ==0 ?"successfully" :"failed" ); -return 0 ; -} -static int gfx_v12_0_reset_kcq (struct amdgpu_ring *ring,unsigned int vmid,struct amdgpu_fence *timedout_fence)
@@ -5434,12 +5253,8 @@ static int gfx_v12_0_reset_kcq(struct amdgpu_ring *ring,amdgpu_ring_reset_helper_begin (ring, timedout_fence); r =amdgpu_mes_reset_legacy_queue (ring->adev, ring, vmid, use_mmio,0 ); -if (r) { -dev_warn (adev->dev,"fail(%d) to reset kcq and try pipe reset\n" , r); - r =gfx_v12_0_reset_compute_pipe (adev, ring->me, ring->pipe, ring->queue); -if (r) -return r; - } +if (r) +return r;if (use_mmio) { r =gfx_v12_0_kcq_init_queue (ring, true);
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +201 -4
223 lines not on this page · raw message
Signature · 1 line
2.54.0