enable mes pipe0 and pipe1 for unified mes fw.
Subsystems (2)
cover enable mes pipe0 and pipe1 for unified mes fw.
Enable both pipe0 and pipe1 running unified mes firmware. They are almost identical pipe, but pipe1 behaves more like legacy kiq. As per fw design, pipe0 is required to be mapped by pipe1 to make some fw feature work.
Jack Xiao (8):
drm/amdgpu/mes12: update mes_v12_api_def.h drm/amdgpu/mes: add multiple mes ring instances support drm/amdgpu/mes12: load unified mes fw on pipe0 and pipe1 drm/amdgpu/mes12: add mes pipe switch support drm/amdgpu/mes12: adjust mes12 sw/hw init for multiple pipes drm/amdgpu/mes12: configure tow pipes hardware resources drm/amdgpu/mes12: sw/hw fini for unified mes drm/amdgpu/mes12: fix suspend issue
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 26 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 83 ++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 16 +- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 27 +- drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 41 ++- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 278 +++++++++--------- drivers/gpu/drm/amd/include/mes_v12_api_def.h | 7 +- 11 files changed, 262 insertions(+), 227 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/8 drm/amdgpu/mes12: update mes_v12_api_def.h
Update mes12 api definition.
--- drivers/gpu/drm/amd/include/mes_v12_api_def.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/include/mes_v12_api_def.h +6 -1
@@ -94,6 +94,7 @@ enum MES_QUEUE_TYPE {MES_QUEUE_TYPE_SDMA ,MES_QUEUE_TYPE_MAX , + MES_QUEUE_TYPE_SCHQ = MES_QUEUE_TYPE_MAX, }; struct MES_API_STATUS {
@@ -239,8 +240,12 @@ union MESAPI_SET_HW_RESOURCES { uint32_t send_write_data : 1; uint32_t os_tdr_timeout_override : 1; uint32_t use_rs64mem_for_proc_gang_ctx : 1; + uint32_t halt_on_misaligned_access : 1; + uint32_t use_add_queue_unmap_flag_addr : 1; + uint32_t enable_mes_sch_stb_log : 1; + uint32_t limit_single_process : 1; uint32_t unmapped_doorbell_handling: 2; - uint32_t reserved : 15; + uint32_t reserved : 11; };uint32_t uint32_all; };
Signature · 1 line
2.41.0
PATCH 2/8 drm/amdgpu/mes: add multiple mes ring instances support
In reply to Jack XiaoAdd multiple mes ring instances in mes structure to support multiple mes pipes.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 4 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 5 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 4 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 4 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 34 ++++++++++++------------ drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 34 ++++++++++++------------ 9 files changed, 47 insertions(+), 44 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +2 -2
@@ -995,7 +995,7 @@ uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg, uint32_t xcc_if (amdgpu_device_skip_hw_access (adev))return 0 ; -if (adev->mes.ring.sched.ready) +if (adev->mes.ring[0 ].sched.ready)return amdgpu_mes_rreg (adev, reg);BUG_ON (!ring->funcs->emit_rreg);
@@ -1065,7 +1065,7 @@ void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v, uint3if (amdgpu_device_skip_hw_access (adev))return ; -if (adev->mes.ring.sched.ready) { +if (adev->mes.ring[0 ].sched.ready) {amdgpu_mes_wreg (adev, reg, v);return ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +3 -2
@@ -589,7 +589,8 @@ int amdgpu_gmc_allocate_vm_inv_eng(struct amdgpu_device *adev) ring = adev->rings[i]; vmhub = ring->vm_hub; -if (ring == &adev->mes.ring || +if (ring == &adev->mes.ring[0 ] || + ring == &adev->mes.ring[1 ] || ring == &adev->umsch_mm.ring)continue ;
@@ -762,7 +763,7 @@ void amdgpu_gmc_fw_reg_write_reg_wait(struct amdgpu_device *adev,unsigned long flags;uint32_t seq; -if (adev->mes.ring.sched.ready) { +if (adev->mes.ring[0 ].sched.ready) {amdgpu_mes_reg_write_reg_wait (adev, reg0, reg1, ref, mask);return ;
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +3 -1
@@ -135,9 +135,11 @@ int amdgpu_mes_init(struct amdgpu_device *adev)idr_init (&adev->mes.queue_id_idr);ida_init (&adev->mes.doorbell_ida);spin_lock_init (&adev->mes.queue_id_lock); -spin_lock_init (&adev->mes.ring_lock);mutex_init (&adev->mes.mutex_hidden); +for (i =0 ; i <AMDGPU_MAX_MES_PIPES ; i++) +spin_lock_init (&adev->mes.ring_lock[i]); + adev->mes.total_max_queue =AMDGPU_FENCE_MES_QUEUE_ID_MASK ; adev->mes.vmid_mask_mmhub =0xffffff00 ; adev->mes.vmid_mask_gfxhub =0xffffff00 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +2 -2
@@ -83,8 +83,8 @@ struct amdgpu_mes {uint64_t default_process_quantum;uint64_t default_gang_quantum; -struct amdgpu_ring ring; -spinlock_t ring_lock; +struct amdgpu_ring ring[AMDGPU_MAX_MES_PIPES ]; +spinlock_t ring_lock[AMDGPU_MAX_MES_PIPES ];const struct firmware *fw[AMDGPU_MAX_MES_PIPES ];
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c +1 -1
@@ -858,7 +858,7 @@ void amdgpu_virt_post_reset(struct amdgpu_device *adev) adev->gfx.is_poweron = false; } - adev->mes.ring.sched.ready = false; + adev->mes.ring[0 ].sched.ready = false; }bool amdgpu_virt_fw_load_skip_check (struct amdgpu_device *adev,uint32_t ucode_id)
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +1 -1
@@ -230,7 +230,7 @@ static void gmc_v11_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,/* This is necessary for SRIOV as well as for GFXOFF to function * properly under bare metal */ -if ((adev->gfx.kiq[0 ].ring.sched.ready || adev->mes.ring.sched.ready) && +if ((adev->gfx.kiq[0 ].ring.sched.ready || adev->mes.ring[0 ].sched.ready) && (amdgpu_sriov_runtime (adev) || !amdgpu_sriov_vf (adev))) {amdgpu_gmc_fw_reg_write_reg_wait (adev, req, ack, inv_req,1 << vmid,GET_INST (GC ,0 ));
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +1 -1
@@ -299,7 +299,7 @@ static void gmc_v12_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,/* This is necessary for SRIOV as well as for GFXOFF to function * properly under bare metal */ -if ((adev->gfx.kiq[0 ].ring.sched.ready || adev->mes.ring.sched.ready) && +if ((adev->gfx.kiq[0 ].ring.sched.ready || adev->mes.ring[0 ].sched.ready) && (amdgpu_sriov_runtime (adev) || !amdgpu_sriov_vf (adev))) {struct amdgpu_vmhub *hub = &adev->vmhub[vmhub];const unsigned eng =17 ;
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +17 -17
@@ -162,7 +162,7 @@ static int mes_v11_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes,union MESAPI__QUERY_MES_STATUS mes_status_pkt;signed long timeout =3000000 ;/* 3000 ms */ struct amdgpu_device *adev = mes->adev; -struct amdgpu_ring *ring = &mes->ring; +struct amdgpu_ring *ring = &mes->ring[0 ];struct MES_API_STATUS *api_status;union MESAPI__MISC *x_pkt = pkt;const char *op_str, *misc_op_str;
@@ -191,7 +191,7 @@ static int mes_v11_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes, status_ptr = (u64 *)&adev->wb.wb[status_offset]; *status_ptr =0 ; -spin_lock_irqsave (&mes->ring_lock, flags); +spin_lock_irqsave (&mes->ring_lock[0 ], flags); r =amdgpu_ring_alloc (ring, (size +sizeof (mes_status_pkt)) /4 );if (r) goto error_unlock_free;
@@ -221,7 +221,7 @@ static int mes_v11_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes, sizeof(mes_status_pkt) / 4);amdgpu_ring_commit (ring); -spin_unlock_irqrestore (&mes->ring_lock, flags); +spin_unlock_irqrestore (&mes->ring_lock[0 ], flags); op_str =mes_v11_0_get_op_string (x_pkt); misc_op_str =mes_v11_0_get_misc_op_string (x_pkt);
@@ -263,7 +263,7 @@ static int mes_v11_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes,amdgpu_ring_undo (ring); error_unlock_free: -spin_unlock_irqrestore (&mes->ring_lock, flags); +spin_unlock_irqrestore (&mes->ring_lock[0 ], flags); error_wb_free:amdgpu_device_wb_free (adev, status_offset);
@@ -1025,7 +1025,7 @@ static int mes_v11_0_kiq_enable_queue(struct amdgpu_device *adev)return r; } - kiq->pmf->kiq_map_queues (kiq_ring, &adev->mes.ring); + kiq->pmf->kiq_map_queues (kiq_ring, &adev->mes.ring[0 ]);return amdgpu_ring_test_helper (kiq_ring); }
@@ -1039,7 +1039,7 @@ static int mes_v11_0_queue_init(struct amdgpu_device *adev,if (pipe ==AMDGPU_MES_KIQ_PIPE ) ring = &adev->gfx.kiq[0 ].ring;else if (pipe ==AMDGPU_MES_SCHED_PIPE ) - ring = &adev->mes.ring; + ring = &adev->mes.ring[0 ];else BUG ();
@@ -1081,7 +1081,7 @@ static int mes_v11_0_ring_init(struct amdgpu_device *adev) {struct amdgpu_ring *ring; - ring = &adev->mes.ring; + ring = &adev->mes.ring[0 ]; ring->funcs = &mes_v11_0_ring_funcs;
@@ -1134,7 +1134,7 @@ static int mes_v11_0_mqd_sw_init(struct amdgpu_device *adev,if (pipe ==AMDGPU_MES_KIQ_PIPE ) ring = &adev->gfx.kiq[0 ].ring;else if (pipe ==AMDGPU_MES_SCHED_PIPE ) - ring = &adev->mes.ring; + ring = &adev->mes.ring[0 ];else BUG ();
@@ -1224,12 +1224,12 @@ static int mes_v11_0_sw_fini(void *handle) &adev->gfx.kiq[0 ].ring.mqd_gpu_addr, &adev->gfx.kiq[0].ring.mqd_ptr); -amdgpu_bo_free_kernel (&adev->mes.ring.mqd_obj, - &adev->mes.ring.mqd_gpu_addr, - &adev->mes.ring.mqd_ptr); +amdgpu_bo_free_kernel (&adev->mes.ring[0 ].mqd_obj, + &adev->mes.ring[0 ].mqd_gpu_addr, + &adev->mes.ring[0 ].mqd_ptr);amdgpu_ring_fini (&adev->gfx.kiq[0 ].ring); -amdgpu_ring_fini (&adev->mes.ring); +amdgpu_ring_fini (&adev->mes.ring[0 ]);if (adev->firmware.load_type ==AMDGPU_FW_LOAD_DIRECT ) {mes_v11_0_free_ucode_buffers (adev,AMDGPU_MES_KIQ_PIPE );
@@ -1340,9 +1340,9 @@ static int mes_v11_0_kiq_hw_init(struct amdgpu_device *adev)static int mes_v11_0_kiq_hw_fini (struct amdgpu_device *adev) { -if (adev->mes.ring.sched.ready) { -mes_v11_0_kiq_dequeue (&adev->mes.ring); - adev->mes.ring.sched.ready = false; +if (adev->mes.ring[0 ].sched.ready) { +mes_v11_0_kiq_dequeue (&adev->mes.ring[0 ]); + adev->mes.ring[0 ].sched.ready = false; }if (amdgpu_sriov_vf (adev)) {
@@ -1360,7 +1360,7 @@ static int mes_v11_0_hw_init(void *handle)int r;struct amdgpu_device *adev = (struct amdgpu_device *)handle; -if (adev->mes.ring.sched.ready) +if (adev->mes.ring[0 ].sched.ready) goto out;if (!adev->enable_mes_kiq) {
@@ -1405,7 +1405,7 @@ static int mes_v11_0_hw_init(void *handle)* with MES enabled. */ adev->gfx.kiq[0 ].ring.sched.ready = false; - adev->mes.ring.sched.ready = true; + adev->mes.ring[0 ].sched.ready = true;return 0 ;
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +17 -17
@@ -148,7 +148,7 @@ static int mes_v12_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes,union MESAPI__QUERY_MES_STATUS mes_status_pkt;signed long timeout =3000000 ;/* 3000 ms */ struct amdgpu_device *adev = mes->adev; -struct amdgpu_ring *ring = &mes->ring; +struct amdgpu_ring *ring = &mes->ring[0 ];struct MES_API_STATUS *api_status;union MESAPI__MISC *x_pkt = pkt;const char *op_str, *misc_op_str;
@@ -177,7 +177,7 @@ static int mes_v12_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes, status_ptr = (u64 *)&adev->wb.wb[status_offset]; *status_ptr =0 ; -spin_lock_irqsave (&mes->ring_lock, flags); +spin_lock_irqsave (&mes->ring_lock[0 ], flags); r =amdgpu_ring_alloc (ring, (size +sizeof (mes_status_pkt)) /4 );if (r) goto error_unlock_free;
@@ -207,7 +207,7 @@ static int mes_v12_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes, sizeof(mes_status_pkt) / 4);amdgpu_ring_commit (ring); -spin_unlock_irqrestore (&mes->ring_lock, flags); +spin_unlock_irqrestore (&mes->ring_lock[0 ], flags); op_str =mes_v12_0_get_op_string (x_pkt); misc_op_str =mes_v12_0_get_misc_op_string (x_pkt);
@@ -249,7 +249,7 @@ static int mes_v12_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes,amdgpu_ring_undo (ring); error_unlock_free: -spin_unlock_irqrestore (&mes->ring_lock, flags); +spin_unlock_irqrestore (&mes->ring_lock[0 ], flags); error_wb_free:amdgpu_device_wb_free (adev, status_offset);
@@ -1093,7 +1093,7 @@ static int mes_v12_0_kiq_enable_queue(struct amdgpu_device *adev)return r; } - kiq->pmf->kiq_map_queues (kiq_ring, &adev->mes.ring); + kiq->pmf->kiq_map_queues (kiq_ring, &adev->mes.ring[0 ]); r =amdgpu_ring_test_ring (kiq_ring);if (r) {
@@ -1112,7 +1112,7 @@ static int mes_v12_0_queue_init(struct amdgpu_device *adev,if (pipe ==AMDGPU_MES_KIQ_PIPE ) ring = &adev->gfx.kiq[0 ].ring;else if (pipe ==AMDGPU_MES_SCHED_PIPE ) - ring = &adev->mes.ring; + ring = &adev->mes.ring[0 ];else BUG ();
@@ -1158,7 +1158,7 @@ static int mes_v12_0_ring_init(struct amdgpu_device *adev) {struct amdgpu_ring *ring; - ring = &adev->mes.ring; + ring = &adev->mes.ring[0 ]; ring->funcs = &mes_v12_0_ring_funcs;
@@ -1211,7 +1211,7 @@ static int mes_v12_0_mqd_sw_init(struct amdgpu_device *adev,if (pipe ==AMDGPU_MES_KIQ_PIPE ) ring = &adev->gfx.kiq[0 ].ring;else if (pipe ==AMDGPU_MES_SCHED_PIPE ) - ring = &adev->mes.ring; + ring = &adev->mes.ring[0 ];else BUG ();
@@ -1298,12 +1298,12 @@ static int mes_v12_0_sw_fini(void *handle) &adev->gfx.kiq[0 ].ring.mqd_gpu_addr, &adev->gfx.kiq[0].ring.mqd_ptr); -amdgpu_bo_free_kernel (&adev->mes.ring.mqd_obj, - &adev->mes.ring.mqd_gpu_addr, - &adev->mes.ring.mqd_ptr); +amdgpu_bo_free_kernel (&adev->mes.ring[0 ].mqd_obj, + &adev->mes.ring[0 ].mqd_gpu_addr, + &adev->mes.ring[0 ].mqd_ptr);amdgpu_ring_fini (&adev->gfx.kiq[0 ].ring); -amdgpu_ring_fini (&adev->mes.ring); +amdgpu_ring_fini (&adev->mes.ring[0 ]);if (adev->firmware.load_type ==AMDGPU_FW_LOAD_DIRECT ) {mes_v12_0_free_ucode_buffers (adev,AMDGPU_MES_KIQ_PIPE );
@@ -1347,7 +1347,7 @@ static void mes_v12_0_kiq_dequeue_sched(struct amdgpu_device *adev)soc21_grbm_select (adev,0 ,0 ,0 ,0 );mutex_unlock (&adev->srbm_mutex); - adev->mes.ring.sched.ready = false; + adev->mes.ring[0 ].sched.ready = false; }static void mes_v12_0_kiq_setting (struct amdgpu_ring *ring)
@@ -1411,9 +1411,9 @@ static int mes_v12_0_kiq_hw_init(struct amdgpu_device *adev)static int mes_v12_0_kiq_hw_fini (struct amdgpu_device *adev) { -if (adev->mes.ring.sched.ready) { +if (adev->mes.ring[0 ].sched.ready) {mes_v12_0_kiq_dequeue_sched (adev); - adev->mes.ring.sched.ready = false; + adev->mes.ring[0 ].sched.ready = false; }mes_v12_0_enable (adev, false);
@@ -1426,7 +1426,7 @@ static int mes_v12_0_hw_init(void *handle)int r;struct amdgpu_device *adev = (struct amdgpu_device *)handle; -if (adev->mes.ring.sched.ready) +if (adev->mes.ring[0 ].sched.ready) goto out;if (!adev->enable_mes_kiq || adev->enable_uni_mes) {
@@ -1478,7 +1478,7 @@ static int mes_v12_0_hw_init(void *handle)* with MES enabled. */ adev->gfx.kiq[0 ].ring.sched.ready = false; - adev->mes.ring.sched.ready = true; + adev->mes.ring[0 ].sched.ready = true;return 0 ;
Signature · 1 line
2.41.0
PATCH 3/8 drm/amdgpu/mes12: load unified mes fw on pipe0 and pipe1
In reply to Jack XiaoEnable unified mes firmware to load on pipe0 and pipe1.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 2 +- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 27 +++---------------------- 2 files changed, 4 insertions(+), 25 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1 -1
@@ -1500,7 +1500,7 @@ int amdgpu_mes_init_microcode(struct amdgpu_device *adev, int pipe)amdgpu_ucode_ip_version_decode (adev,GC_HWIP , ucode_prefix,sizeof (ucode_prefix)); -if (adev->enable_uni_mes && pipe ==AMDGPU_MES_SCHED_PIPE ) { +if (adev->enable_uni_mes) {snprintf (fw_name,sizeof (fw_name),"amdgpu/%s_uni_mes.bin" , ucode_prefix); } else if (amdgpu_ip_version(adev, GC_HWIP, 0) >= IP_VERSION(11, 0, 0) &&
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +3 -24
@@ -742,16 +742,11 @@ static void mes_v12_0_enable(struct amdgpu_device *adev, bool enable)if (enable) { data =RREG32_SOC15 (GC ,0 , regCP_MES_CNTL); data =REG_SET_FIELD (data,CP_MES_CNTL ,MES_PIPE0_RESET ,1 ); - data =REG_SET_FIELD (data,CP_MES_CNTL ,MES_PIPE1_RESET , - (!adev->enable_uni_mes && adev->enable_mes_kiq) ?1 :0 ); + data =REG_SET_FIELD (data,CP_MES_CNTL ,MES_PIPE1_RESET ,1 );WREG32_SOC15 (GC ,0 , regCP_MES_CNTL, data);mutex_lock (&adev->srbm_mutex);for (pipe =0 ; pipe <AMDGPU_MAX_MES_PIPES ; pipe++) { -if ((!adev->enable_mes_kiq || adev->enable_uni_mes) && - pipe ==AMDGPU_MES_KIQ_PIPE ) -continue ; -soc21_grbm_select (adev,3 , pipe,0 ,0 ); ucode_addr = adev->mes.uc_start_addr[pipe] >>2 ;
@@ -765,8 +760,7 @@ static void mes_v12_0_enable(struct amdgpu_device *adev, bool enable)/* unhalt MES and activate pipe0 */ data =REG_SET_FIELD (0 ,CP_MES_CNTL ,MES_PIPE0_ACTIVE ,1 ); - data =REG_SET_FIELD (data,CP_MES_CNTL ,MES_PIPE1_ACTIVE , - (!adev->enable_uni_mes && adev->enable_mes_kiq) ?1 :0 ); + data =REG_SET_FIELD (data,CP_MES_CNTL ,MES_PIPE1_ACTIVE ,1 );WREG32_SOC15 (GC ,0 , regCP_MES_CNTL, data);if (amdgpu_emu_mode)
@@ -782,8 +776,7 @@ static void mes_v12_0_enable(struct amdgpu_device *adev, bool enable) data =REG_SET_FIELD (data,CP_MES_CNTL ,MES_INVALIDATE_ICACHE ,1 ); data =REG_SET_FIELD (data,CP_MES_CNTL ,MES_PIPE0_RESET ,1 ); - data =REG_SET_FIELD (data,CP_MES_CNTL ,MES_PIPE1_RESET , - (!adev->enable_uni_mes && adev->enable_mes_kiq) ?1 :0 ); + data =REG_SET_FIELD (data,CP_MES_CNTL ,MES_PIPE1_RESET ,1 ); data =REG_SET_FIELD (data,CP_MES_CNTL ,MES_HALT ,1 );WREG32_SOC15 (GC ,0 , regCP_MES_CNTL, data); }
@@ -798,10 +791,6 @@ 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++) { -if ((!adev->enable_mes_kiq || adev->enable_uni_mes) && - pipe ==AMDGPU_MES_KIQ_PIPE ) -continue ; -/* me=3, queue=0 */ soc21_grbm_select (adev,3 , pipe,0 ,0 );
@@ -1521,17 +1510,7 @@ static int mes_v12_0_early_init(void *handle)struct amdgpu_device *adev = (struct amdgpu_device *)handle;int pipe, r; -if (adev->enable_uni_mes) { - r =amdgpu_mes_init_microcode (adev,AMDGPU_MES_SCHED_PIPE ); -if (!r) -return 0 ; - - adev->enable_uni_mes = false; - } -for (pipe =0 ; pipe <AMDGPU_MAX_MES_PIPES ; pipe++) { -if (!adev->enable_mes_kiq && pipe ==AMDGPU_MES_KIQ_PIPE ) -continue ; r =amdgpu_mes_init_microcode (adev, pipe);if (r)return r;
Signature · 1 line
2.41.0
PATCH 4/8 drm/amdgpu/mes12: add mes pipe switch support
In reply to Jack XiaoAdd mes pipe switch to let caller choose pipe
to submit packet.
--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 59 ++++++++++++++------------ 1 file changed, 33 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +33 -26
@@ -142,13 +142,14 @@ static const char *mes_v12_0_get_misc_op_string(union MESAPI__MISC *x_pkt) }static int mes_v12_0_submit_pkt_and_poll_completion (struct amdgpu_mes *mes, -void *pkt,int size, -int api_status_off) +int pipe,void *pkt,int size, +int api_status_off) {union MESAPI__QUERY_MES_STATUS mes_status_pkt;signed long timeout =3000000 ;/* 3000 ms */ struct amdgpu_device *adev = mes->adev; -struct amdgpu_ring *ring = &mes->ring[0 ]; +struct amdgpu_ring *ring = &mes->ring[pipe]; +spinlock_t *ring_lock = &mes->ring_lock[pipe];struct MES_API_STATUS *api_status;union MESAPI__MISC *x_pkt = pkt;const char *op_str, *misc_op_str;
@@ -177,7 +178,7 @@ static int mes_v12_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes, status_ptr = (u64 *)&adev->wb.wb[status_offset]; *status_ptr =0 ; -spin_lock_irqsave (&mes->ring_lock[0 ], flags); +spin_lock_irqsave (ring_lock, flags); r =amdgpu_ring_alloc (ring, (size +sizeof (mes_status_pkt)) /4 );if (r) goto error_unlock_free;
@@ -207,32 +208,33 @@ static int mes_v12_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes, sizeof(mes_status_pkt) / 4);amdgpu_ring_commit (ring); -spin_unlock_irqrestore (&mes->ring_lock[0 ], flags); +spin_unlock_irqrestore (ring_lock, flags); op_str =mes_v12_0_get_op_string (x_pkt); misc_op_str =mes_v12_0_get_misc_op_string (x_pkt);if (misc_op_str) -dev_dbg (adev->dev,"MES msg=%s (%s) was emitted\n" , op_str, - misc_op_str); +dev_dbg (adev->dev,"MES(%d) msg=%s (%s) was emitted\n" , + pipe, op_str, misc_op_str);else if (op_str) -dev_dbg (adev->dev,"MES msg=%s was emitted\n" , op_str); +dev_dbg (adev->dev,"MES(%d) msg=%s was emitted\n" , + pipe, op_str);else -dev_dbg (adev->dev,"MES msg=%d was emitted\n" , - x_pkt->header.opcode); +dev_dbg (adev->dev,"MES(%d) msg=%d was emitted\n" , + pipe, x_pkt->header.opcode); r =amdgpu_fence_wait_polling (ring, seq, timeout);if (r <1 || !*status_ptr) {if (misc_op_str) -dev_err (adev->dev,"MES failed to respond to msg=%s (%s)\n" , - op_str, misc_op_str); +dev_err (adev->dev,"MES(%d) failed to respond to msg=%s (%s)\n" , + pipe, op_str, misc_op_str);else if (op_str) -dev_err (adev->dev,"MES failed to respond to msg=%s\n" , - op_str); +dev_err (adev->dev,"MES(%d) failed to respond to msg=%s\n" , + pipe, op_str);else -dev_err (adev->dev,"MES failed to respond to msg=%d\n" , - x_pkt->header.opcode); +dev_err (adev->dev,"MES(%d) failed to respond to msg=%d\n" , + pipe, x_pkt->header.opcode);while (halt_if_hws_hang)schedule ();
@@ -249,7 +251,7 @@ static int mes_v12_0_submit_pkt_and_poll_completion(struct amdgpu_mes *mes,amdgpu_ring_undo (ring); error_unlock_free: -spin_unlock_irqrestore (&mes->ring_lock[0 ], flags); +spin_unlock_irqrestore (ring_lock, flags); error_wb_free:amdgpu_device_wb_free (adev, status_offset);
@@ -321,6 +323,7 @@ static int mes_v12_0_add_hw_queue(struct amdgpu_mes *mes, mes_add_queue_pkt.gds_size = input->queue_size;return mes_v12_0_submit_pkt_and_poll_completion (mes, +AMDGPU_MES_SCHED_PIPE , &mes_add_queue_pkt,sizeof (mes_add_queue_pkt), offsetof(union MESAPI__ADD_QUEUE , api_status)); }
@@ -340,6 +343,7 @@ static int mes_v12_0_remove_hw_queue(struct amdgpu_mes *mes, mes_remove_queue_pkt.gang_context_addr = input->gang_context_addr;return mes_v12_0_submit_pkt_and_poll_completion (mes, +AMDGPU_MES_SCHED_PIPE , &mes_remove_queue_pkt,sizeof (mes_remove_queue_pkt), offsetof(union MESAPI__REMOVE_QUEUE , api_status)); }
@@ -365,6 +369,7 @@ static int mes_v12_0_map_legacy_queue(struct amdgpu_mes *mes, mes_add_queue_pkt.map_legacy_kq =1 ;return mes_v12_0_submit_pkt_and_poll_completion (mes, +AMDGPU_MES_SCHED_PIPE , &mes_add_queue_pkt,sizeof (mes_add_queue_pkt), offsetof(union MESAPI__ADD_QUEUE , api_status)); }
@@ -398,6 +403,7 @@ static int mes_v12_0_unmap_legacy_queue(struct amdgpu_mes *mes, }return mes_v12_0_submit_pkt_and_poll_completion (mes, +AMDGPU_MES_SCHED_PIPE , &mes_remove_queue_pkt,sizeof (mes_remove_queue_pkt), offsetof(union MESAPI__REMOVE_QUEUE , api_status)); }
@@ -414,7 +420,7 @@ static int mes_v12_0_resume_gang(struct amdgpu_mes *mes,return 0 ; } -static int mes_v12_0_query_sched_status (struct amdgpu_mes *mes) +static int mes_v12_0_query_sched_status (struct amdgpu_mes *mes,int pipe) {union MESAPI__QUERY_MES_STATUS mes_status_pkt;
@@ -424,7 +430,7 @@ static int mes_v12_0_query_sched_status(struct amdgpu_mes *mes) mes_status_pkt.header.opcode =MES_SCH_API_QUERY_SCHEDULER_STATUS ; mes_status_pkt.header.dwsize =API_FRAME_SIZE_IN_DWORDS ; -return mes_v12_0_submit_pkt_and_poll_completion (mes, +return mes_v12_0_submit_pkt_and_poll_completion (mes, pipe, &mes_status_pkt,sizeof (mes_status_pkt), offsetof(union MESAPI__QUERY_MES_STATUS , api_status)); }
@@ -486,11 +492,12 @@ static int mes_v12_0_misc_op(struct amdgpu_mes *mes, }return mes_v12_0_submit_pkt_and_poll_completion (mes, +AMDGPU_MES_SCHED_PIPE , &misc_pkt,sizeof (misc_pkt), offsetof(union MESAPI__MISC , api_status)); } -static int mes_v12_0_set_hw_resources_1 (struct amdgpu_mes *mes) +static int mes_v12_0_set_hw_resources_1 (struct amdgpu_mes *mes,int pipe) {union MESAPI_SET_HW_RESOURCES_1 mes_set_hw_res_1_pkt;
@@ -501,12 +508,12 @@ static int mes_v12_0_set_hw_resources_1(struct amdgpu_mes *mes) mes_set_hw_res_1_pkt.header.dwsize =API_FRAME_SIZE_IN_DWORDS ; mes_set_hw_res_1_pkt.mes_kiq_unmap_timeout =100 ; -return mes_v12_0_submit_pkt_and_poll_completion (mes, +return mes_v12_0_submit_pkt_and_poll_completion (mes, pipe, &mes_set_hw_res_1_pkt,sizeof (mes_set_hw_res_1_pkt), offsetof(union MESAPI_SET_HW_RESOURCES_1 , api_status)); } -static int mes_v12_0_set_hw_resources (struct amdgpu_mes *mes) +static int mes_v12_0_set_hw_resources (struct amdgpu_mes *mes,int pipe) {int i;struct amdgpu_device *adev = mes->adev;
@@ -564,7 +571,7 @@ static int mes_v12_0_set_hw_resources(struct amdgpu_mes *mes) mes_set_hw_res_pkt.enable_mes_event_int_logging =0 ; mes_set_hw_res_pkt.event_intr_history_gpu_mc_ptr = mes->event_log_gpu_addr; -return mes_v12_0_submit_pkt_and_poll_completion (mes, +return mes_v12_0_submit_pkt_and_poll_completion (mes, pipe, &mes_set_hw_res_pkt,sizeof (mes_set_hw_res_pkt), offsetof(union MESAPI_SET_HW_RESOURCES , api_status)); }
@@ -1442,19 +1449,19 @@ static int mes_v12_0_hw_init(void *handle)if (r) goto failure; - r =mes_v12_0_set_hw_resources (&adev->mes); + r =mes_v12_0_set_hw_resources (&adev->mes,AMDGPU_MES_SCHED_PIPE );if (r) goto failure;if (adev->enable_uni_mes) -mes_v12_0_set_hw_resources_1 (&adev->mes); +mes_v12_0_set_hw_resources_1 (&adev->mes,AMDGPU_MES_SCHED_PIPE );mes_v12_0_init_aggregated_doorbell (&adev->mes);/* Enable the MES to handle doorbell ring on unmapped queue */ mes_v12_0_enable_unmapped_doorbell_handling (&adev->mes, true); - r =mes_v12_0_query_sched_status (&adev->mes); + r =mes_v12_0_query_sched_status (&adev->mes,AMDGPU_MES_SCHED_PIPE );if (r) {DRM_ERROR ("MES is busy\n" ); goto failure;
Signature · 1 line
2.41.0
PATCH 5/8 drm/amdgpu/mes12: adjust mes12 sw/hw init for multiple pipes
In reply to Jack XiaoAdjust mes12 sw/hw initiailization for both pipe0 and pipe1 enablement. The two pipes are almost identical pipe. Pipe0 behaves like schq and pipe1 like kiq, pipe0 was mapped by pipe1.
--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 106 +++++++++++++++---------- 1 file changed, 62 insertions(+), 44 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +62 -44
@@ -266,6 +266,8 @@ static int convert_to_mes_queue_type(int queue_type)return MES_QUEUE_TYPE_COMPUTE ; else if (queue_type == AMDGPU_RING_TYPE_SDMA) return MES_QUEUE_TYPE_SDMA; + else if (queue_type == AMDGPU_RING_TYPE_MES) + return MES_QUEUE_TYPE_SCHQ; elseBUG ();return -1 ;
@@ -352,6 +354,7 @@ static int mes_v12_0_map_legacy_queue(struct amdgpu_mes *mes, struct mes_map_legacy_queue_input *input) {union MESAPI__ADD_QUEUE mes_add_queue_pkt; +int pipe;memset (&mes_add_queue_pkt,0 ,sizeof (mes_add_queue_pkt));
@@ -368,8 +371,12 @@ 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 ; -return mes_v12_0_submit_pkt_and_poll_completion (mes, -AMDGPU_MES_SCHED_PIPE , +if (mes->adev->enable_uni_mes) + pipe =AMDGPU_MES_KIQ_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), offsetof(union MESAPI__ADD_QUEUE , api_status)); }
@@ -378,6 +385,7 @@ static int mes_v12_0_unmap_legacy_queue(struct amdgpu_mes *mes, struct mes_unmap_legacy_queue_input *input) {union MESAPI__REMOVE_QUEUE mes_remove_queue_pkt; +int pipe;memset (&mes_remove_queue_pkt,0 ,sizeof (mes_remove_queue_pkt));
@@ -402,8 +410,12 @@ static int mes_v12_0_unmap_legacy_queue(struct amdgpu_mes *mes,convert_to_mes_queue_type (input->queue_type); } -return mes_v12_0_submit_pkt_and_poll_completion (mes, -AMDGPU_MES_SCHED_PIPE , +if (mes->adev->enable_uni_mes) + pipe =AMDGPU_MES_KIQ_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), offsetof(union MESAPI__REMOVE_QUEUE , api_status)); }
@@ -439,6 +451,7 @@ static int mes_v12_0_misc_op(struct amdgpu_mes *mes, struct mes_misc_op_input *input) {union MESAPI__MISC misc_pkt; +int pipe;memset (&misc_pkt,0 ,sizeof (misc_pkt));
@@ -491,8 +504,12 @@ static int mes_v12_0_misc_op(struct amdgpu_mes *mes,return -EINVAL ; } -return mes_v12_0_submit_pkt_and_poll_completion (mes, -AMDGPU_MES_SCHED_PIPE , +if (mes->adev->enable_uni_mes) + pipe =AMDGPU_MES_KIQ_PIPE ; +else + pipe =AMDGPU_MES_SCHED_PIPE ; + +return mes_v12_0_submit_pkt_and_poll_completion (mes, pipe, &misc_pkt,sizeof (misc_pkt), offsetof(union MESAPI__MISC , api_status)); }
@@ -1105,14 +1122,12 @@ static int mes_v12_0_queue_init(struct amdgpu_device *adev,struct amdgpu_ring *ring;int r; -if (pipe ==AMDGPU_MES_KIQ_PIPE ) +if (!adev->enable_uni_mes && pipe ==AMDGPU_MES_KIQ_PIPE ) ring = &adev->gfx.kiq[0 ].ring; -else if (pipe ==AMDGPU_MES_SCHED_PIPE ) - ring = &adev->mes.ring[0 ];else -BUG (); + ring = &adev->mes.ring[pipe]; -if ((pipe ==AMDGPU_MES_SCHED_PIPE ) && +if ((adev->enable_uni_mes || pipe ==AMDGPU_MES_SCHED_PIPE ) && (amdgpu_in_reset (adev) || adev->in_suspend)) { *(ring->wptr_cpu_addr) =0 ; *(ring->rptr_cpu_addr) =0 ;
@@ -1124,13 +1139,12 @@ static int mes_v12_0_queue_init(struct amdgpu_device *adev,return r;if (pipe ==AMDGPU_MES_SCHED_PIPE ) { -if (adev->enable_uni_mes) { -mes_v12_0_queue_init_register (ring); - }else { +if (adev->enable_uni_mes) + r =amdgpu_mes_map_legacy_queue (adev, ring); +else r =mes_v12_0_kiq_enable_queue (adev); -if (r) -return r; - } +if (r) +return r; }else {mes_v12_0_queue_init_register (ring); }
@@ -1150,25 +1164,29 @@ static int mes_v12_0_queue_init(struct amdgpu_device *adev,return 0 ; } -static int mes_v12_0_ring_init (struct amdgpu_device *adev) +static int mes_v12_0_ring_init (struct amdgpu_device *adev,int pipe) {struct amdgpu_ring *ring; - ring = &adev->mes.ring[0 ]; + ring = &adev->mes.ring[pipe]; ring->funcs = &mes_v12_0_ring_funcs; ring->me =3 ; - ring->pipe =0 ; + ring->pipe = pipe; ring->queue =0 ; ring->ring_obj =NULL ; ring->use_doorbell = true; - ring->doorbell_index = adev->doorbell_index.mes_ring0 <<1 ; - ring->eop_gpu_addr = adev->mes.eop_gpu_addr[AMDGPU_MES_SCHED_PIPE ]; + ring->eop_gpu_addr = adev->mes.eop_gpu_addr[pipe]; ring->no_scheduler = true;sprintf (ring->name,"mes_%d.%d.%d" , ring->me, ring->pipe, ring->queue); +if (pipe ==AMDGPU_MES_SCHED_PIPE ) + ring->doorbell_index = adev->doorbell_index.mes_ring0 <<1 ; +else + ring->doorbell_index = adev->doorbell_index.mes_ring1 <<1 ; +return amdgpu_ring_init (adev, ring,1024 ,NULL ,0 ,AMDGPU_RING_PRIO_DEFAULT ,NULL ); }
@@ -1182,7 +1200,7 @@ static int mes_v12_0_kiq_ring_init(struct amdgpu_device *adev) ring = &adev->gfx.kiq[0 ].ring; ring->me =3 ; - ring->pipe = adev->enable_uni_mes ?0 :1 ; + ring->pipe =1 ; ring->queue =0 ; ring->adev =NULL ;
@@ -1204,12 +1222,10 @@ static int mes_v12_0_mqd_sw_init(struct amdgpu_device *adev,int r, mqd_size =sizeof (struct v12_compute_mqd );struct amdgpu_ring *ring; -if (pipe ==AMDGPU_MES_KIQ_PIPE ) +if (!adev->enable_uni_mes && pipe ==AMDGPU_MES_KIQ_PIPE ) ring = &adev->gfx.kiq[0 ].ring; -else if (pipe ==AMDGPU_MES_SCHED_PIPE ) - ring = &adev->mes.ring[0 ];else -BUG (); + ring = &adev->mes.ring[pipe];if (ring->mqd_obj)return 0 ;
@@ -1248,9 +1264,6 @@ static int mes_v12_0_sw_init(void *handle)return r;for (pipe =0 ; pipe <AMDGPU_MAX_MES_PIPES ; pipe++) { -if (!adev->enable_mes_kiq && pipe ==AMDGPU_MES_KIQ_PIPE ) -continue ; - r =mes_v12_0_allocate_eop_buf (adev, pipe);if (r)return r;
@@ -1258,18 +1271,15 @@ static int mes_v12_0_sw_init(void *handle) r =mes_v12_0_mqd_sw_init (adev, pipe);if (r)return r; - } -if (adev->enable_mes_kiq) { - r =mes_v12_0_kiq_ring_init (adev); +if (!adev->enable_uni_mes && pipe ==AMDGPU_MES_KIQ_PIPE ) + r =mes_v12_0_kiq_ring_init (adev); +else + r =mes_v12_0_ring_init (adev, pipe);if (r)return r; } - r =mes_v12_0_ring_init (adev); -if (r) -return r; -return 0 ; }
@@ -1364,10 +1374,10 @@ static int mes_v12_0_kiq_hw_init(struct amdgpu_device *adev) {int r =0 ; -mes_v12_0_kiq_setting (&adev->gfx.kiq[0 ].ring); -if (adev->enable_uni_mes) -return mes_v12_0_hw_init (adev); +mes_v12_0_kiq_setting (&adev->mes.ring[AMDGPU_MES_KIQ_PIPE ]); +else +mes_v12_0_kiq_setting (&adev->gfx.kiq[0 ].ring);if (adev->firmware.load_type ==AMDGPU_FW_LOAD_DIRECT ) {
@@ -1394,6 +1404,14 @@ static int mes_v12_0_kiq_hw_init(struct amdgpu_device *adev)if (r) goto failure; +if (adev->enable_uni_mes) { + r =mes_v12_0_set_hw_resources (&adev->mes,AMDGPU_MES_KIQ_PIPE ); +if (r) + goto failure; + +mes_v12_0_set_hw_resources_1 (&adev->mes,AMDGPU_MES_KIQ_PIPE ); + } + r =mes_v12_0_hw_init (adev);if (r) goto failure;
@@ -1425,7 +1443,7 @@ static int mes_v12_0_hw_init(void *handle)if (adev->mes.ring[0 ].sched.ready) goto out; -if (!adev->enable_mes_kiq || adev->enable_uni_mes) { +if (!adev->enable_mes_kiq) {if (adev->firmware.load_type ==AMDGPU_FW_LOAD_DIRECT ) { r =mes_v12_0_load_microcode (adev,AMDGPU_MES_SCHED_PIPE , true);
@@ -1445,6 +1463,9 @@ static int mes_v12_0_hw_init(void *handle)mes_v12_0_enable (adev, true); } +/* Enable the MES to handle doorbell ring on unmapped queue */ +mes_v12_0_enable_unmapped_doorbell_handling (&adev->mes, true); + r =mes_v12_0_queue_init (adev,AMDGPU_MES_SCHED_PIPE );if (r) goto failure;
@@ -1458,9 +1479,6 @@ static int mes_v12_0_hw_init(void *handle)mes_v12_0_init_aggregated_doorbell (&adev->mes); -/* Enable the MES to handle doorbell ring on unmapped queue */ -mes_v12_0_enable_unmapped_doorbell_handling (&adev->mes, true); - r =mes_v12_0_query_sched_status (&adev->mes,AMDGPU_MES_SCHED_PIPE );if (r) {DRM_ERROR ("MES is busy\n" );
Signature · 1 line
2.41.0
PATCH 6/8 drm/amdgpu/mes12: configure tow pipes hardware resources
In reply to Jack XiaoConfigure tow pipes with different hardware resources.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 77 +++++++++++++++---------- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 12 ++-- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 7 +-- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 49 ++++++++-------- 4 files changed, 81 insertions(+), 64 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +47 -30
@@ -165,36 +165,38 @@ int amdgpu_mes_init(struct amdgpu_device *adev) adev->mes.sdma_hqd_mask[i] =0xfc ; } - r =amdgpu_device_wb_get (adev, &adev->mes.sch_ctx_offs); -if (r) { -dev_err (adev->dev, -"(%d) ring trail_fence_offs wb alloc failed\n" , r); - goto error_ids; - } - adev->mes.sch_ctx_gpu_addr = - adev->wb.gpu_addr + (adev->mes.sch_ctx_offs *4 ); - adev->mes.sch_ctx_ptr = - (uint64_t *)&adev->wb.wb[adev->mes.sch_ctx_offs]; +for (i =0 ; i <AMDGPU_MAX_MES_PIPES ; i++) { + r =amdgpu_device_wb_get (adev, &adev->mes.sch_ctx_offs[i]); +if (r) { +dev_err (adev->dev, +"(%d) ring trail_fence_offs wb alloc failed\n" , + r); + goto error; + } + adev->mes.sch_ctx_gpu_addr[i] = + adev->wb.gpu_addr + (adev->mes.sch_ctx_offs[i] *4 ); + adev->mes.sch_ctx_ptr[i] = + (uint64_t *)&adev->wb.wb[adev->mes.sch_ctx_offs[i]]; - r =amdgpu_device_wb_get (adev, &adev->mes.query_status_fence_offs); -if (r) { -amdgpu_device_wb_free (adev, adev->mes.sch_ctx_offs); -dev_err (adev->dev, -"(%d) query_status_fence_offs wb alloc failed\n" , r); - goto error_ids; + r =amdgpu_device_wb_get (adev, + &adev->mes.query_status_fence_offs[i]); +if (r) { +dev_err (adev->dev, +"(%d) query_status_fence_offs wb alloc failed\n" , + r); + goto error; + } + adev->mes.query_status_fence_gpu_addr[i] = adev->wb.gpu_addr + + (adev->mes.query_status_fence_offs[i] *4 ); + adev->mes.query_status_fence_ptr[i] = + (uint64_t *)&adev->wb.wb[adev->mes.query_status_fence_offs[i]]; } - adev->mes.query_status_fence_gpu_addr = - adev->wb.gpu_addr + (adev->mes.query_status_fence_offs *4 ); - adev->mes.query_status_fence_ptr = - (uint64_t *)&adev->wb.wb[adev->mes.query_status_fence_offs]; r =amdgpu_device_wb_get (adev, &adev->mes.read_val_offs);if (r) { -amdgpu_device_wb_free (adev, adev->mes.sch_ctx_offs); -amdgpu_device_wb_free (adev, adev->mes.query_status_fence_offs);dev_err (adev->dev,"(%d) read_val_offs alloc failed\n" , r); - goto error_ids; + goto error; } adev->mes.read_val_gpu_addr = adev->wb.gpu_addr + (adev->mes.read_val_offs *4 );
@@ -214,10 +216,16 @@ int amdgpu_mes_init(struct amdgpu_device *adev) error_doorbell:amdgpu_mes_doorbell_free (adev); error: -amdgpu_device_wb_free (adev, adev->mes.sch_ctx_offs); -amdgpu_device_wb_free (adev, adev->mes.query_status_fence_offs); -amdgpu_device_wb_free (adev, adev->mes.read_val_offs); -error_ids: +for (i =0 ; i <AMDGPU_MAX_MES_PIPES ; i++) { +if (adev->mes.sch_ctx_ptr[i]) +amdgpu_device_wb_free (adev, adev->mes.sch_ctx_offs[i]); +if (adev->mes.query_status_fence_ptr[i]) +amdgpu_device_wb_free (adev, + adev->mes.query_status_fence_offs[i]); + } +if (adev->mes.read_val_ptr) +amdgpu_device_wb_free (adev, adev->mes.read_val_offs); +idr_destroy (&adev->mes.pasid_idr);idr_destroy (&adev->mes.gang_id_idr);idr_destroy (&adev->mes.queue_id_idr);
@@ -228,13 +236,22 @@ int amdgpu_mes_init(struct amdgpu_device *adev)void amdgpu_mes_fini (struct amdgpu_device *adev) { +int i; +amdgpu_bo_free_kernel (&adev->mes.event_log_gpu_obj, &adev->mes.event_log_gpu_addr, &adev->mes.event_log_cpu_addr); -amdgpu_device_wb_free (adev, adev->mes.sch_ctx_offs); -amdgpu_device_wb_free (adev, adev->mes.query_status_fence_offs); -amdgpu_device_wb_free (adev, adev->mes.read_val_offs); +for (i =0 ; i <AMDGPU_MAX_MES_PIPES ; i++) { +if (adev->mes.sch_ctx_ptr[i]) +amdgpu_device_wb_free (adev, adev->mes.sch_ctx_offs[i]); +if (adev->mes.query_status_fence_ptr[i]) +amdgpu_device_wb_free (adev, + adev->mes.query_status_fence_offs[i]); + } +if (adev->mes.read_val_ptr) +amdgpu_device_wb_free (adev, adev->mes.read_val_offs); +amdgpu_mes_doorbell_free (adev);idr_destroy (&adev->mes.pasid_idr);
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +6 -6
@@ -113,12 +113,12 @@ struct amdgpu_mes {uint32_t gfx_hqd_mask[AMDGPU_MES_MAX_GFX_PIPES ];uint32_t sdma_hqd_mask[AMDGPU_MES_MAX_SDMA_PIPES ];uint32_t aggregated_doorbells[AMDGPU_MES_PRIORITY_NUM_LEVELS ]; -uint32_t sch_ctx_offs; -uint64_t sch_ctx_gpu_addr; -uint64_t *sch_ctx_ptr; -uint32_t query_status_fence_offs; -uint64_t query_status_fence_gpu_addr; -uint64_t *query_status_fence_ptr; +uint32_t sch_ctx_offs[AMDGPU_MAX_MES_PIPES ]; +uint64_t sch_ctx_gpu_addr[AMDGPU_MAX_MES_PIPES ]; +uint64_t *sch_ctx_ptr[AMDGPU_MAX_MES_PIPES ]; +uint32_t query_status_fence_offs[AMDGPU_MAX_MES_PIPES ]; +uint64_t query_status_fence_gpu_addr[AMDGPU_MAX_MES_PIPES ]; +uint64_t *query_status_fence_ptr[AMDGPU_MAX_MES_PIPES ];uint32_t read_val_offs;uint64_t read_val_gpu_addr;uint32_t *read_val_ptr;
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +2 -5
@@ -522,9 +522,9 @@ static int mes_v11_0_set_hw_resources(struct amdgpu_mes *mes) mes_set_hw_res_pkt.vmid_mask_gfxhub = mes->vmid_mask_gfxhub; mes_set_hw_res_pkt.gds_size = adev->gds.gds_size; mes_set_hw_res_pkt.paging_vmid =0 ; - mes_set_hw_res_pkt.g_sch_ctx_gpu_mc_ptr = mes->sch_ctx_gpu_addr; + mes_set_hw_res_pkt.g_sch_ctx_gpu_mc_ptr = mes->sch_ctx_gpu_addr[0 ]; mes_set_hw_res_pkt.query_status_fence_gpu_mc_ptr = - mes->query_status_fence_gpu_addr; + mes->query_status_fence_gpu_addr[0 ];for (i =0 ; i <MAX_COMPUTE_PIPES ; i++) mes_set_hw_res_pkt.compute_hqd_mask[i] =
@@ -1208,9 +1208,6 @@ static int mes_v11_0_sw_fini(void *handle)struct amdgpu_device *adev = (struct amdgpu_device *)handle;int pipe; -amdgpu_device_wb_free (adev, adev->mes.sch_ctx_offs); -amdgpu_device_wb_free (adev, adev->mes.query_status_fence_offs); -for (pipe =0 ; pipe <AMDGPU_MAX_MES_PIPES ; pipe++) {kfree (adev->mes.mqd_backup[pipe]);
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +26 -23
62 lines not on this page · raw message
Signature · 1 line
2.41.0
PATCH 7/8 drm/amdgpu/mes12: sw/hw fini for unified mes
In reply to Jack XiaoFree memory for two pipes and unmap pipe0 via pipe1.
--- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 31 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +20 -11
@@ -1301,18 +1301,21 @@ static int mes_v12_0_sw_fini(void *handle) &adev->mes.eop_gpu_addr[pipe], NULL);amdgpu_ucode_release (&adev->mes.fw[pipe]); - } - -amdgpu_bo_free_kernel (&adev->gfx.kiq[0 ].ring.mqd_obj, - &adev->gfx.kiq[0 ].ring.mqd_gpu_addr, - &adev->gfx.kiq[0 ].ring.mqd_ptr); -amdgpu_bo_free_kernel (&adev->mes.ring[0 ].mqd_obj, - &adev->mes.ring[0 ].mqd_gpu_addr, - &adev->mes.ring[0 ].mqd_ptr); +if (adev->enable_uni_mes || pipe ==AMDGPU_MES_SCHED_PIPE ) { +amdgpu_bo_free_kernel (&adev->mes.ring[pipe].mqd_obj, + &adev->mes.ring[pipe].mqd_gpu_addr, + &adev->mes.ring[pipe].mqd_ptr); +amdgpu_ring_fini (&adev->mes.ring[pipe]); + } + } -amdgpu_ring_fini (&adev->gfx.kiq[0 ].ring); -amdgpu_ring_fini (&adev->mes.ring[0 ]); +if (!adev->enable_uni_mes) { +amdgpu_bo_free_kernel (&adev->gfx.kiq[0 ].ring.mqd_obj, + &adev->gfx.kiq[0 ].ring.mqd_gpu_addr, + &adev->gfx.kiq[0 ].ring.mqd_ptr); +amdgpu_ring_fini (&adev->gfx.kiq[0 ].ring); + }if (adev->firmware.load_type ==AMDGPU_FW_LOAD_DIRECT ) {mes_v12_0_free_ucode_buffers (adev,AMDGPU_MES_KIQ_PIPE );
@@ -1429,7 +1432,13 @@ static int mes_v12_0_kiq_hw_init(struct amdgpu_device *adev)static int mes_v12_0_kiq_hw_fini (struct amdgpu_device *adev) {if (adev->mes.ring[0 ].sched.ready) { -mes_v12_0_kiq_dequeue_sched (adev); +if (adev->enable_uni_mes) +amdgpu_mes_unmap_legacy_queue (adev, + &adev->mes.ring[AMDGPU_MES_SCHED_PIPE ], +RESET_QUEUES ,0 ,0 ); +else +mes_v12_0_kiq_dequeue_sched (adev); + adev->mes.ring[0 ].sched.ready = false; }
Signature · 1 line
2.41.0
PATCH 8/8 drm/amdgpu/mes12: fix suspend issue
In reply to Jack XiaoUse mes pipe to unmap kcq and kgq.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 22 ++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 27 +------------------------ 2 files changed, 23 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +22 -0
@@ -509,6 +509,16 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id)int i, r =0 ;int j; +if (adev->enable_mes) { +for (i =0 ; i < adev->gfx.num_compute_rings; i++) { + j = i + xcc_id * adev->gfx.num_compute_rings; +amdgpu_mes_unmap_legacy_queue (adev, + &adev->gfx.compute_ring[j], +RESET_QUEUES ,0 ,0 ); + } +return 0 ; + } +if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)return -EINVAL ;
@@ -551,6 +561,18 @@ int amdgpu_gfx_disable_kgq(struct amdgpu_device *adev, int xcc_id)int i, r =0 ;int j; +if (adev->enable_mes) { +if (amdgpu_gfx_is_master_xcc (adev, xcc_id)) { +for (i =0 ; i < adev->gfx.num_gfx_rings; i++) { + j = i + xcc_id * adev->gfx.num_gfx_rings; +amdgpu_mes_unmap_legacy_queue (adev, + &adev->gfx.gfx_ring[j], +PREEMPT_QUEUES ,0 ,0 ); + } + } +return 0 ; + } +if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)return -EINVAL ;
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1 -26
@@ -3519,33 +3519,9 @@ static int gfx_v12_0_hw_init(void *handle)return r; } -static int gfx_v12_0_kiq_disable_kgq (struct amdgpu_device *adev) -{ -struct amdgpu_kiq *kiq = &adev->gfx.kiq[0 ]; -struct amdgpu_ring *kiq_ring = &kiq->ring; -int i, r =0 ; - -if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues) -return -EINVAL ; - -if (amdgpu_ring_alloc (kiq_ring, kiq->pmf->unmap_queues_size * - adev->gfx.num_gfx_rings)) -return -ENOMEM ; - -for (i =0 ; i < adev->gfx.num_gfx_rings; i++) - kiq->pmf->kiq_unmap_queues (kiq_ring, &adev->gfx.gfx_ring[i], -PREEMPT_QUEUES ,0 ,0 ); - -if (adev->gfx.kiq[0 ].ring.sched.ready) - r =amdgpu_ring_test_helper (kiq_ring); - -return r; -} -static int gfx_v12_0_hw_fini (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; -int r;uint32_t tmp;amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );
@@ -3553,8 +3529,7 @@ static int gfx_v12_0_hw_fini(void *handle)if (!adev->no_hw_access) {if (amdgpu_async_gfx_ring) { - r =gfx_v12_0_kiq_disable_kgq (adev); -if (r) +if (amdgpu_gfx_disable_kgq (adev,0 ))DRM_ERROR ("KGQ disable failed\n" ); }
Signature · 1 line
2.41.0
Re: [PATCH 8/8] drm/amdgpu/mes12: fix suspend issue
Quoted 4 lines · Jack Xiao
Use mes pipe to unmap kcq and kgq.
Signed-off-by Jack Xiao <[email protected]>
Series is:
Quoted 96 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 22 ++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 27 +------------------------ 2 files changed, 23 insertions(+), 26 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +22
-0@@ -509,6 +509,16 @@ int amdgpu_gfx_disable_kcq(struct amdgpu_device *adev, int xcc_id)int i, r =0 ;int j; +if (adev->enable_mes) { +for (i =0 ; i < adev->gfx.num_compute_rings; i++) { + j = i + xcc_id * adev->gfx.num_compute_rings; +amdgpu_mes_unmap_legacy_queue (adev, + &adev->gfx.compute_ring[j], +RESET_QUEUES ,0 ,0 ); + } +return 0 ; + } +if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)return -EINVAL ;@@ -551,6 +561,18 @@ int amdgpu_gfx_disable_kgq(struct amdgpu_device *adev, int xcc_id)int i, r =0 ;int j; +if (adev->enable_mes) { +if (amdgpu_gfx_is_master_xcc (adev, xcc_id)) { +for (i =0 ; i < adev->gfx.num_gfx_rings; i++) { + j = i + xcc_id * adev->gfx.num_gfx_rings; +amdgpu_mes_unmap_legacy_queue (adev, + &adev->gfx.gfx_ring[j], +PREEMPT_QUEUES ,0 ,0 ); + } + } +return 0 ; + } +if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues)return -EINVAL ;drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1
-27@@ -3519,33 +3519,9 @@ static int gfx_v12_0_hw_init(void *handle)return r; } -static int gfx_v12_0_kiq_disable_kgq (struct amdgpu_device *adev) -{ -struct amdgpu_kiq *kiq = &adev->gfx.kiq[0 ]; -struct amdgpu_ring *kiq_ring = &kiq->ring; -int i, r =0 ; - -if (!kiq->pmf || !kiq->pmf->kiq_unmap_queues) -return -EINVAL ; - -if (amdgpu_ring_alloc (kiq_ring, kiq->pmf->unmap_queues_size * - adev->gfx.num_gfx_rings)) -return -ENOMEM ; - -for (i =0 ; i < adev->gfx.num_gfx_rings; i++) - kiq->pmf->kiq_unmap_queues (kiq_ring, &adev->gfx.gfx_ring[i], -PREEMPT_QUEUES ,0 ,0 ); - -if (adev->gfx.kiq[0 ].ring.sched.ready) - r =amdgpu_ring_test_helper (kiq_ring); - -return r; -} -static int gfx_v12_0_hw_fini (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; -int r;uint32_t tmp;amdgpu_irq_put (adev, &adev->gfx.priv_reg_irq,0 );@@ -3553,8 +3529,7 @@ static int gfx_v12_0_hw_fini(void *handle)if (!adev->no_hw_access) {if (amdgpu_async_gfx_ring) { - r =gfx_v12_0_kiq_disable_kgq (adev); -if (r) +if (amdgpu_gfx_disable_kgq (adev,0 ))DRM_ERROR ("KGQ disable failed\n" ); } --2.41.0
[AMD Official Use Only - AMD Internal Distribution Only]
Series is
Regards,
Hawking
-----Original Message-----
From: Xiao, Jack <[email protected]>
Sent: Wednesday, August 7, 2024 17:39
To: [email protected]; Zhang, Hawking <[email protected]>
Cc: Xiao, Jack <[email protected]>
Subject: [PATCH 0/8] enable mes pipe0 and pipe1 for unified mes fw.
Enable both pipe0 and pipe1 running unified mes firmware.
They are almost identical pipe, but pipe1 behaves more like legacy kiq. As per fw design, pipe0 is required to be mapped by pipe1 to make some fw feature work.
Jack Xiao (8):
drm/amdgpu/mes12: update mes_v12_api_def.h drm/amdgpu/mes: add multiple mes ring instances support drm/amdgpu/mes12: load unified mes fw on pipe0 and pipe1 drm/amdgpu/mes12: add mes pipe switch support drm/amdgpu/mes12: adjust mes12 sw/hw init for multiple pipes drm/amdgpu/mes12: configure tow pipes hardware resources drm/amdgpu/mes12: sw/hw fini for unified mes drm/amdgpu/mes12: fix suspend issue
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 26 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 83 ++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 16 +- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 27 +- drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 41 ++- drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 278 +++++++++--------- drivers/gpu/drm/amd/include/mes_v12_api_def.h | 7 +- 11 files changed, 262 insertions(+), 227 deletions(-)
--
2.41.0