drm/amdgpu: fix mes packet params issue when flush hdp.
Subsystems (2)
PATCH v2 1/1 drm/amdgpu: fix mes packet params issue when flush hdp.
v2:
place "get_ref_and_mask" in amdgpu_gfx_funcs instead of amdgpu_ring, since this function only assigns the cp entry.
v1:
both gfx ring and mes ring use cp0 to flush hdp, cause conflict.
use function get_ref_and_mask to assign the cp entry. reassign mes to use cp8 instead.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 13 +++++- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 58 +++++++++++++++++-------- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 58 +++++++++++++++++-------- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 3 +- 8 files changed, 101 insertions(+), 42 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +2 -0
@@ -356,6 +356,8 @@ struct amdgpu_gfx_funcs { int num_xccs_per_xcp);int (*ih_node_to_logical_xcc)(struct amdgpu_device *adev,int ih_node);int (*get_xccs_per_xcp)(struct amdgpu_device *adev); +void (*get_ref_and_mask)(struct amdgpu_ring *ring, +uint32_t *ref_and_mask,uint32_t *reg_mem_engine); };struct sq_work {
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +11 -2
@@ -556,11 +556,20 @@ int amdgpu_mes_reg_write_reg_wait(struct amdgpu_device *adev,int amdgpu_mes_hdp_flush (struct amdgpu_device *adev) { -uint32_t hdp_flush_req_offset, hdp_flush_done_offset, ref_and_mask; +uint32_t hdp_flush_req_offset, hdp_flush_done_offset; +struct amdgpu_ring *mes_ring; +uint32_t ref_and_mask =0 , reg_mem_engine =0 ; +if (!adev->gfx.funcs->get_ref_and_mask) { +dev_err (adev->dev,"amdgpu_mes_hdp_flush not support\n" ); +return -EINVAL ; + } + + mes_ring = &adev->mes.ring[0 ]; hdp_flush_req_offset = adev->nbio.funcs->get_hdp_flush_req_offset (adev); hdp_flush_done_offset = adev->nbio.funcs->get_hdp_flush_done_offset (adev); - ref_and_mask = adev->nbio.hdp_flush_reg->ref_and_mask_cp0; + + adev->gfx.funcs->get_ref_and_mask (mes_ring, &ref_and_mask, ®_mem_engine);return amdgpu_mes_reg_write_reg_wait (adev, hdp_flush_req_offset, hdp_flush_done_offset, ref_and_mask, ref_and_mask,0 );
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2 -1
@@ -8616,7 +8616,8 @@ static void gfx_v10_0_ring_emit_hdp_flush(struct amdgpu_ring *ring)u32 ref_and_mask, reg_mem_engine;const struct nbio_hdp_flush_reg *nbio_hf_reg = adev->nbio.hdp_flush_reg; -if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) { +if ((ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) || + (ring->funcs->type ==AMDGPU_RING_TYPE_KIQ )) {switch (ring->me) {case 1 : ref_and_mask = nbio_hf_reg->ref_and_mask_cp2 << ring->pipe;
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +40 -18
77 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +40 -18
77 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +2 -1
@@ -2070,7 +2070,8 @@ static void gfx_v7_0_ring_emit_hdp_flush(struct amdgpu_ring *ring)u32 ref_and_mask;int usepfp = ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ?0 :1 ; -if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) { +if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE || + ring->funcs->type ==AMDGPU_RING_TYPE_KIQ ) {switch (ring->me) {case 1 : ref_and_mask =GPU_HDP_FLUSH_DONE__CP2_MASK << ring->pipe;
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -1
@@ -5382,7 +5382,8 @@ static void gfx_v9_0_ring_emit_hdp_flush(struct amdgpu_ring *ring)u32 ref_and_mask, reg_mem_engine;const struct nbio_hdp_flush_reg *nbio_hf_reg = adev->nbio.hdp_flush_reg; -if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) { +if ((ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) || + (ring->funcs->type ==AMDGPU_RING_TYPE_KIQ )) {switch (ring->me) {case 1 : ref_and_mask = nbio_hf_reg->ref_and_mask_cp2 << ring->pipe;
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +2 -1
@@ -2820,7 +2820,8 @@ static void gfx_v9_4_3_ring_emit_hdp_flush(struct amdgpu_ring *ring)u32 ref_and_mask, reg_mem_engine;const struct nbio_hdp_flush_reg *nbio_hf_reg = adev->nbio.hdp_flush_reg; -if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) { +if ((ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) || + (ring->funcs->type ==AMDGPU_RING_TYPE_KIQ )) {switch (ring->me) {case 1 : ref_and_mask = nbio_hf_reg->ref_and_mask_cp2 << ring->pipe;
Signature · 1 line
2.48.1
Quoted 234 lines · chong li
v2:
place "get_ref_and_mask" inamdgpu_gfx_funcsinstead ofamdgpu_ring, since this function only assigns the cp entry.v1:
both gfx ring and mes ring use cp0 to flush hdp, cause conflict.use function
get_ref_and_maskto assign the cp entry. reassign mes to use cp8 instead.Signed-off-by chong li <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 13 +++++- drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 58 +++++++++++++++++-------- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 58 +++++++++++++++++-------- drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 3 +- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 3 +- 8 files changed, 101 insertions(+), 42 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +2
-0@@ -356,6 +356,8 @@ struct amdgpu_gfx_funcs { int num_xccs_per_xcp);int (*ih_node_to_logical_xcc)(struct amdgpu_device *adev,int ih_node);int (*get_xccs_per_xcp)(struct amdgpu_device *adev); +void (*get_ref_and_mask)(struct amdgpu_ring *ring, +uint32_t *ref_and_mask,uint32_t *reg_mem_engine); };struct sq_work {drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +11
-2@@ -556,11 +556,20 @@ int amdgpu_mes_reg_write_reg_wait(struct amdgpu_device *adev,int amdgpu_mes_hdp_flush (struct amdgpu_device *adev) { -uint32_t hdp_flush_req_offset, hdp_flush_done_offset, ref_and_mask; +uint32_t hdp_flush_req_offset, hdp_flush_done_offset; +struct amdgpu_ring *mes_ring; +uint32_t ref_and_mask =0 , reg_mem_engine =0 ; +if (!adev->gfx.funcs->get_ref_and_mask) { +dev_err (adev->dev,"amdgpu_mes_hdp_flush not support\n" ); +return -EINVAL ; + } + + mes_ring = &adev->mes.ring[0 ]; hdp_flush_req_offset = adev->nbio.funcs->get_hdp_flush_req_offset (adev); hdp_flush_done_offset = adev->nbio.funcs->get_hdp_flush_done_offset (adev); - ref_and_mask = adev->nbio.hdp_flush_reg->ref_and_mask_cp0; + + adev->gfx.funcs->get_ref_and_mask (mes_ring, &ref_and_mask, ®_mem_engine);return amdgpu_mes_reg_write_reg_wait (adev, hdp_flush_req_offset, hdp_flush_done_offset, ref_and_mask, ref_and_mask,0 );drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2
-1@@ -8616,7 +8616,8 @@ static void gfx_v10_0_ring_emit_hdp_flush(struct amdgpu_ring *ring)u32 ref_and_mask, reg_mem_engine;const struct nbio_hdp_flush_reg *nbio_hf_reg = adev->nbio.hdp_flush_reg; -if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) { +if ((ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) || + (ring->funcs->type ==AMDGPU_RING_TYPE_KIQ )) {switch (ring->me) {case 1 : ref_and_mask = nbio_hf_reg->ref_and_mask_cp2 << ring->pipe;drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +40
-18@@ -1072,6 +1072,44 @@ static int gfx_v11_0_get_gfx_shadow_info(struct amdgpu_device *adev, } } +/** +* gfx_v11_0_get_ref_and_mask - get the reference and mask for HDP flush +* +* @ring: amdgpu_ring structure holding ring information +* @ref_and_mask: pointer to store the reference and mask +* @reg_mem_engine: pointer to store the register memory engine +* +* Calculates the reference and mask for HDP flush based on the ring type and me. +*/ +static void gfx_v11_0_get_ref_and_mask (struct amdgpu_ring *ring, +uint32_t *ref_and_mask,uint32_t *reg_mem_engine) +{ +struct amdgpu_device *adev = ring->adev; +const struct nbio_hdp_flush_reg *nbio_hf_reg = adev->nbio.hdp_flush_reg; + +if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE || + ring->funcs->type ==AMDGPU_RING_TYPE_MES || + ring->funcs->type ==AMDGPU_RING_TYPE_KIQ ) { +switch (ring->me) { +case 1 : + *ref_and_mask = nbio_hf_reg->ref_and_mask_cp2 << ring->pipe; +break ; +case 2 : + *ref_and_mask = nbio_hf_reg->ref_and_mask_cp6 << ring->pipe; +break ; +case 3 : + *ref_and_mask = nbio_hf_reg->ref_and_mask_cp8 << ring->pipe; +break ; +default : +return ; + } + *reg_mem_engine =0 ; + }else { + *ref_and_mask = nbio_hf_reg->ref_and_mask_cp0 << ring->pipe; + *reg_mem_engine =1 ;/* pfp */ + } +} +static const struct amdgpu_gfx_funcs gfx_v11_0_gfx_funcs = { .get_gpu_clock_counter = &gfx_v11_0_get_gpu_clock_counter, .select_se_sh = &gfx_v11_0_select_se_sh,@@ -1081,6 +1119,7 @@ static const struct amdgpu_gfx_funcs gfx_v11_0_gfx_funcs = { .select_me_pipe_q = &gfx_v11_0_select_me_pipe_q, .update_perfmon_mgcg = &gfx_v11_0_update_perf_clk, .get_gfx_shadow_info = &gfx_v11_0_get_gfx_shadow_info, + .get_ref_and_mask = &gfx_v11_0_get_ref_and_mask, };static int gfx_v11_0_gpu_early_init (struct amdgpu_device *adev)@@ -5833,25 +5872,8 @@ static void gfx_v11_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) {struct amdgpu_device *adev = ring->adev;u32 ref_and_mask, reg_mem_engine; -const struct nbio_hdp_flush_reg *nbio_hf_reg = adev->nbio.hdp_flush_reg; - -if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) { -switch (ring->me) { -case 1 : - ref_and_mask = nbio_hf_reg->ref_and_mask_cp2 << ring->pipe; -break ; -case 2 : - ref_and_mask = nbio_hf_reg->ref_and_mask_cp6 << ring->pipe; -break ; -default : -return ; - } - reg_mem_engine =0 ; - }else { - ref_and_mask = nbio_hf_reg->ref_and_mask_cp0 << ring->pipe; - reg_mem_engine =1 ;/* pfp */ - } + adev->gfx.funcs->get_ref_and_mask (ring, &ref_and_mask, ®_mem_engine); gfx_v11_0_wait_reg_mem(ring, reg_mem_engine, 0, 1, adev->nbio.funcs->get_hdp_flush_req_offset(adev), adev->nbio.funcs->get_hdp_flush_done_offset(adev),drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +39
-13@@ -929,6 +929,44 @@ static int gfx_v12_0_get_gfx_shadow_info(struct amdgpu_device *adev,return -EINVAL ; } +/** +* gfx_v12_0_get_ref_and_mask - get the reference and mask for HDP flush +* +* @ring: amdgpu_ring structure holding ring information +* @ref_and_mask: pointer to store the reference and mask +* @reg_mem_engine: pointer to store the register memory engine +* +* Calculates the reference and mask for HDP flush based on the ring type and me. +*/ +static void gfx_v12_0_get_ref_and_mask (struct amdgpu_ring *ring, +uint32_t *ref_and_mask,uint32_t *reg_mem_engine) +{ +struct amdgpu_device *adev = ring->adev; +const struct nbio_hdp_flush_reg *nbio_hf_reg = adev->nbio.hdp_flush_reg; + +if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE || + ring->funcs->type ==AMDGPU_RING_TYPE_MES || + ring->funcs->type ==AMDGPU_RING_TYPE_KIQ ) { +switch (ring->me) { +case 1 : + *ref_and_mask = nbio_hf_reg->ref_and_mask_cp2 << ring->pipe; +break ; +case 2 : + *ref_and_mask = nbio_hf_reg->ref_and_mask_cp6 << ring->pipe; +break ; +case 3 : + *ref_and_mask = nbio_hf_reg->ref_and_mask_cp8 << ring->pipe; +break ; +default : +return ; + } + *reg_mem_engine =0 ; + }else { + *ref_and_mask = nbio_hf_reg->ref_and_mask_cp0; + *reg_mem_engine =1 ;/* pfp */ + } +} +static const struct amdgpu_gfx_funcs gfx_v12_0_gfx_funcs = { .get_gpu_clock_counter = &gfx_v12_0_get_gpu_clock_counter, .select_se_sh = &gfx_v12_0_select_se_sh,@@ -938,6 +976,7 @@ static const struct amdgpu_gfx_funcs gfx_v12_0_gfx_funcs = { .select_me_pipe_q = &gfx_v12_0_select_me_pipe_q, .update_perfmon_mgcg = &gfx_v12_0_update_perf_clk, .get_gfx_shadow_info = &gfx_v12_0_get_gfx_shadow_info, + .get_ref_and_mask = &gfx_v12_0_get_ref_and_mask, };static int gfx_v12_0_gpu_early_init (struct amdgpu_device *adev)@@ -4389,25 +4428,8 @@ static void gfx_v12_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) {struct amdgpu_device *adev = ring->adev;u32 ref_and_mask, reg_mem_engine; -const struct nbio_hdp_flush_reg *nbio_hf_reg = adev->nbio.hdp_flush_reg; - -if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) { -switch (ring->me) { -case 1 : - ref_and_mask = nbio_hf_reg->ref_and_mask_cp2 << ring->pipe; -break ; -case 2 : - ref_and_mask = nbio_hf_reg->ref_and_mask_cp6 << ring->pipe; -break ; -default : -return ; - }
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c static void gfx_v12_0_ring_emit_hdp_flush(struct amdgpu_ring *ring) · line 4435
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1
-5- reg_mem_engine =0 ; - }else { - ref_and_mask = nbio_hf_reg->ref_and_mask_cp0; - reg_mem_engine =1 ;/* pfp */ - } + adev->gfx.funcs->get_ref_and_mask (ring, &ref_and_mask, ®_mem_engine); gfx_v12_0_wait_reg_mem(ring, reg_mem_engine, 0, 1, adev->nbio.funcs->get_hdp_flush_req_offset(adev), adev->nbio.funcs->get_hdp_flush_done_offset(adev),
Though it's about mes, could you also convert the below ones also to make it uniform?
Thanks,
Lijo
Quoted 42 lines
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +2
-1@@ -2070,7 +2070,8 @@ static void gfx_v7_0_ring_emit_hdp_flush(struct amdgpu_ring *ring)u32 ref_and_mask;int usepfp = ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ?0 :1 ; -if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) { +if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE || + ring->funcs->type ==AMDGPU_RING_TYPE_KIQ ) {switch (ring->me) {case 1 : ref_and_mask =GPU_HDP_FLUSH_DONE__CP2_MASK << ring->pipe;drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2
-1@@ -5382,7 +5382,8 @@ static void gfx_v9_0_ring_emit_hdp_flush(struct amdgpu_ring *ring)u32 ref_and_mask, reg_mem_engine;const struct nbio_hdp_flush_reg *nbio_hf_reg = adev->nbio.hdp_flush_reg; -if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) { +if ((ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) || + (ring->funcs->type ==AMDGPU_RING_TYPE_KIQ )) {switch (ring->me) {case 1 : ref_and_mask = nbio_hf_reg->ref_and_mask_cp2 << ring->pipe;drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +2
-1@@ -2820,7 +2820,8 @@ static void gfx_v9_4_3_ring_emit_hdp_flush(struct amdgpu_ring *ring)u32 ref_and_mask, reg_mem_engine;const struct nbio_hdp_flush_reg *nbio_hf_reg = adev->nbio.hdp_flush_reg; -if (ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) { +if ((ring->funcs->type ==AMDGPU_RING_TYPE_COMPUTE ) || + (ring->funcs->type ==AMDGPU_RING_TYPE_KIQ )) {switch (ring->me) {case 1 : ref_and_mask = nbio_hf_reg->ref_and_mask_cp2 << ring->pipe;