enable mes to map kgq/kcq
Subsystems (2)
cover enable mes to map kgq/kcq
Jack Xiao (5):
drm/amdgpu/mes: add mes mapping legacy queue support drm/amdgpu/mes11: update ADD_QUEUE interface drm/amdgpu/mes11: add mes mapping legacy queue support drm/amdgpu/mes11: adjust mes initialization sequence drm/amdgpu/gfx: enable mes to map legacy queue support
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 39 ++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 22 +++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 14 +++++++ drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 35 ++++++++++++++++- drivers/gpu/drm/amd/include/mes_v11_api_def.h | 17 ++++++-- 5 files changed, 118 insertions(+), 9 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/5 drm/amdgpu/mes: add mes mapping legacy queue support
Add mes mapping legacy queue framework support.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h | 14 ++++++++++++++ 2 files changed, 36 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +22 -0
@@ -786,6 +786,28 @@ int amdgpu_mes_remove_hw_queue(struct amdgpu_device *adev, int queue_id)return 0 ; } +int amdgpu_mes_map_legacy_queue (struct amdgpu_device *adev, +struct amdgpu_ring *ring) +{ +struct mes_map_legacy_queue_input queue_input; +int r; + +memset (&queue_input,0 ,sizeof (queue_input)); + + queue_input.queue_type = ring->funcs->type; + queue_input.doorbell_offset = ring->doorbell_index; + queue_input.pipe_id = ring->pipe; + queue_input.queue_id = ring->queue; + queue_input.mqd_addr =amdgpu_bo_gpu_offset (ring->mqd_obj); + queue_input.wptr_addr = ring->wptr_gpu_addr; + + r = adev->mes.funcs->map_legacy_queue (&adev->mes, &queue_input); +if (r) +DRM_ERROR ("failed to map legacy queue\n" ); + +return r; +} + int amdgpu_mes_unmap_legacy_queue(struct amdgpu_device *adev, struct amdgpu_ring *ring, enum amdgpu_unmap_queues_action action,
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.h +14 -0
@@ -248,6 +248,15 @@ struct mes_remove_queue_input {uint64_t gang_context_addr; }; +struct mes_map_legacy_queue_input { +uint32_t queue_type; +uint32_t doorbell_offset; +uint32_t pipe_id; +uint32_t queue_id; +uint64_t mqd_addr; +uint64_t wptr_addr; +}; +struct mes_unmap_legacy_queue_input {enum amdgpu_unmap_queues_action action;uint32_t queue_type;
@@ -324,6 +333,9 @@ struct amdgpu_mes_funcs {int (*remove_hw_queue)(struct amdgpu_mes *mes,struct mes_remove_queue_input *input); +int (*map_legacy_queue)(struct amdgpu_mes *mes, +struct mes_map_legacy_queue_input *input); +int (*unmap_legacy_queue)(struct amdgpu_mes *mes,struct mes_unmap_legacy_queue_input *input);
@@ -367,6 +379,8 @@ int amdgpu_mes_add_hw_queue(struct amdgpu_device *adev, int gang_id, int *queue_id);int amdgpu_mes_remove_hw_queue (struct amdgpu_device *adev,int queue_id); +int amdgpu_mes_map_legacy_queue (struct amdgpu_device *adev, +struct amdgpu_ring *ring); int amdgpu_mes_unmap_legacy_queue(struct amdgpu_device *adev, struct amdgpu_ring *ring, enum amdgpu_unmap_queues_action action,
Signature · 1 line
2.41.0
PATCH 2/5 drm/amdgpu/mes11: update ADD_QUEUE interface
In reply to Jack XiaoUpdate ADD_QUEUE interface for mes11 to support
mes mapping legacy queue.
--- drivers/gpu/drm/amd/include/mes_v11_api_def.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/include/mes_v11_api_def.h +14 -3
@@ -299,10 +299,21 @@ union MESAPI__ADD_QUEUE { uint32_t skip_process_ctx_clear : 1; uint32_t map_legacy_kq : 1; uint32_t exclusively_scheduled : 1; - uint32_t reserved : 17; + uint32_t is_long_running : 1; + uint32_t is_dwm_queue : 1; + uint32_t is_video_blit_queue : 1; + uint32_t reserved : 14; }; -struct MES_API_STATUS api_status; -uint64_t tma_addr; +struct MES_API_STATUS api_status; +uint64_t tma_addr; +uint32_t sch_id; +uint64_t timestamp; +uint32_t process_context_array_index; +uint32_t gang_context_array_index; +uint32_t pipe_id; +uint32_t queue_id; +uint32_t alignment_mode_setting; +uint64_t unmap_flag_addr; };uint32_t max_dwords_in_api[API_FRAME_SIZE_IN_DWORDS ];
Signature · 1 line
2.41.0
PATCH 3/5 drm/amdgpu/mes11: add mes mapping legacy queue support
In reply to Jack XiaoAdd mes11 map legacy queue packet submission.
--- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +26 -0
@@ -325,6 +325,31 @@ static int mes_v11_0_remove_hw_queue(struct amdgpu_mes *mes, offsetof(union MESAPI__REMOVE_QUEUE, api_status)); } +static int mes_v11_0_map_legacy_queue (struct amdgpu_mes *mes, +struct mes_map_legacy_queue_input *input) +{ +union MESAPI__ADD_QUEUE mes_add_queue_pkt; + +memset (&mes_add_queue_pkt,0 ,sizeof (mes_add_queue_pkt)); + + mes_add_queue_pkt.header.type =MES_API_TYPE_SCHEDULER ; + mes_add_queue_pkt.header.opcode =MES_SCH_API_ADD_QUEUE ; + mes_add_queue_pkt.header.dwsize =API_FRAME_SIZE_IN_DWORDS ; + + mes_add_queue_pkt.pipe_id = input->pipe_id; + mes_add_queue_pkt.queue_id = input->queue_id; + mes_add_queue_pkt.doorbell_offset = input->doorbell_offset; + mes_add_queue_pkt.mqd_addr = input->mqd_addr; + mes_add_queue_pkt.wptr_addr = input->wptr_addr; + mes_add_queue_pkt.queue_type = +convert_to_mes_queue_type (input->queue_type); + mes_add_queue_pkt.map_legacy_kq =1 ; + +return mes_v11_0_submit_pkt_and_poll_completion (mes, + &mes_add_queue_pkt,sizeof (mes_add_queue_pkt), + offsetof(union MESAPI__ADD_QUEUE , api_status)); +} +static int mes_v11_0_unmap_legacy_queue (struct amdgpu_mes *mes,struct mes_unmap_legacy_queue_input *input) {
@@ -538,6 +563,7 @@ static int mes_v11_0_set_hw_resources_1(struct amdgpu_mes *mes)static const struct amdgpu_mes_funcs mes_v11_0_funcs = { .add_hw_queue = mes_v11_0_add_hw_queue, .remove_hw_queue = mes_v11_0_remove_hw_queue, + .map_legacy_queue = mes_v11_0_map_legacy_queue, .unmap_legacy_queue = mes_v11_0_unmap_legacy_queue, .suspend_gang = mes_v11_0_suspend_gang, .resume_gang = mes_v11_0_resume_gang,
Signature · 1 line
2.41.0
PATCH 4/5 drm/amdgpu/mes11: adjust mes initialization sequence
In reply to Jack XiaoAdjust mes queue initialization before kgq/kcq initialization to enable mes mapping legacy queue.
--- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +8 -1
@@ -52,7 +52,7 @@ MODULE_FIRMWARE("amdgpu/gc_11_5_0_mes1.bin");MODULE_FIRMWARE ("amdgpu/gc_11_5_1_mes_2.bin" );MODULE_FIRMWARE ("amdgpu/gc_11_5_1_mes1.bin" ); - +static int mes_v11_0_hw_init (void *handle);static int mes_v11_0_hw_fini (void *handle);static int mes_v11_0_kiq_hw_init (struct amdgpu_device *adev);static int mes_v11_0_kiq_hw_fini (struct amdgpu_device *adev);
@@ -1292,6 +1292,10 @@ static int mes_v11_0_kiq_hw_init(struct amdgpu_device *adev)if (r) goto failure; + r =mes_v11_0_hw_init (adev); +if (r) + goto failure; +return r; failure:
@@ -1321,6 +1325,9 @@ 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) +return 0 ; +if (!adev->enable_mes_kiq) {if (adev->firmware.load_type ==AMDGPU_FW_LOAD_DIRECT ) { r = mes_v11_0_load_microcode(adev,
Signature · 1 line
2.41.0
PATCH 5/5 drm/amdgpu/gfx: enable mes to map legacy queue support
In reply to Jack XiaoEnable mes to map legacy queue support.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 39 +++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +34 -5
@@ -622,10 +622,28 @@ int amdgpu_gfx_enable_kcq(struct amdgpu_device *adev, int xcc_id) queue_mask |= (1ull <<amdgpu_queue_mask_bit_to_set_resource_bit (adev, i)); } -DRM_INFO ("kiq ring mec %d pipe %d q %d\n" , kiq_ring->me, kiq_ring->pipe, - kiq_ring->queue);amdgpu_device_flush_hdp (adev,NULL ); +if (adev->enable_mes) + queue_mask = ~0ULL ; + +if (adev->enable_mes) { +for (i =0 ; i < adev->gfx.num_compute_rings; i++) { + j = i + xcc_id * adev->gfx.num_compute_rings; + r =amdgpu_mes_map_legacy_queue (adev, + &adev->gfx.compute_ring[j]); +if (r) { +DRM_ERROR ("failed to map compute queue\n" ); +return r; + } + } + +return 0 ; + } + +DRM_INFO ("kiq ring mec %d pipe %d q %d\n" , kiq_ring->me, kiq_ring->pipe, + kiq_ring->queue); +spin_lock (&kiq->ring_lock); r = amdgpu_ring_alloc(kiq_ring, kiq->pmf->map_queues_size * adev->gfx.num_compute_rings +
@@ -636,9 +654,6 @@ int amdgpu_gfx_enable_kcq(struct amdgpu_device *adev, int xcc_id)return r; } -if (adev->enable_mes) - queue_mask = ~0ULL ; - kiq->pmf->kiq_set_resources (kiq_ring, queue_mask);for (i =0 ; i < adev->gfx.num_compute_rings; i++) { j = i + xcc_id * adev->gfx.num_compute_rings;
@@ -665,6 +680,20 @@ int amdgpu_gfx_enable_kgq(struct amdgpu_device *adev, int xcc_id)amdgpu_device_flush_hdp (adev,NULL ); +if (adev->enable_mes) { +for (i =0 ; i < adev->gfx.num_gfx_rings; i++) { + j = i + xcc_id * adev->gfx.num_gfx_rings; + r =amdgpu_mes_map_legacy_queue (adev, + &adev->gfx.gfx_ring[j]); +if (r) { +DRM_ERROR ("failed to map gfx queue\n" ); +return r; + } + } + +return 0 ; + } +spin_lock (&kiq->ring_lock);/* No need to map kcq on the slave */ if (amdgpu_gfx_is_master_xcc (adev, xcc_id)) {
Signature · 1 line
2.41.0
Re: [PATCH 5/5] drm/amdgpu/gfx: enable mes to map legacy queue support
Series looks good to me.
Quoted 78 lines · Jack Xiao
Enable mes to map legacy queue support.
Signed-off-by Jack Xiao <[email protected]>Reviewed-by Hawking Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 39 +++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +34
-6@@ -622,10 +622,28 @@ int amdgpu_gfx_enable_kcq(struct amdgpu_device *adev, int xcc_id) queue_mask |= (1ull <<amdgpu_queue_mask_bit_to_set_resource_bit (adev, i)); } -DRM_INFO ("kiq ring mec %d pipe %d q %d\n" , kiq_ring->me, kiq_ring->pipe, - kiq_ring->queue);amdgpu_device_flush_hdp (adev,NULL ); +if (adev->enable_mes) + queue_mask = ~0ULL ; + +if (adev->enable_mes) { +for (i =0 ; i < adev->gfx.num_compute_rings; i++) { + j = i + xcc_id * adev->gfx.num_compute_rings; + r =amdgpu_mes_map_legacy_queue (adev, + &adev->gfx.compute_ring[j]); +if (r) { +DRM_ERROR ("failed to map compute queue\n" ); +return r; + } + } + +return 0 ; + } + +DRM_INFO ("kiq ring mec %d pipe %d q %d\n" , kiq_ring->me, kiq_ring->pipe, + kiq_ring->queue); +spin_lock (&kiq->ring_lock); r = amdgpu_ring_alloc(kiq_ring, kiq->pmf->map_queues_size * adev->gfx.num_compute_rings +@@ -636,9 +654,6 @@ int amdgpu_gfx_enable_kcq(struct amdgpu_device *adev, int xcc_id)return r; } -if (adev->enable_mes) - queue_mask = ~0ULL ; - kiq->pmf->kiq_set_resources (kiq_ring, queue_mask);for (i =0 ; i < adev->gfx.num_compute_rings; i++) { j = i + xcc_id * adev->gfx.num_compute_rings;@@ -665,6 +680,20 @@ int amdgpu_gfx_enable_kgq(struct amdgpu_device *adev, int xcc_id)amdgpu_device_flush_hdp (adev,NULL ); +if (adev->enable_mes) { +for (i =0 ; i < adev->gfx.num_gfx_rings; i++) { + j = i + xcc_id * adev->gfx.num_gfx_rings; + r =amdgpu_mes_map_legacy_queue (adev, + &adev->gfx.gfx_ring[j]); +if (r) { +DRM_ERROR ("failed to map gfx queue\n" ); +return r; + } + } + +return 0 ; + } +spin_lock (&kiq->ring_lock);/* No need to map kcq on the slave */ if (amdgpu_gfx_is_master_xcc (adev, xcc_id)) { --2.41.0
Christian König
maintainerRe: [PATCH 5/5] drm/amdgpu/gfx: enable mes to map legacy queue support
Shashank can you take a look as well.
Thanks,
Christian.
Am 25.04.24 um 15:40 schrieb Alex Deucher:
Quoted 82 lines
Series looks good to me.
Reviewed-by Alex Deucher <[email protected]>Quoted 77 lines · Jack Xiao
Enable mes to map legacy queue support.
Signed-off-by Jack Xiao <[email protected]>Reviewed-by Hawking Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 39 +++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +34
-6@@ -622,10 +622,28 @@ int amdgpu_gfx_enable_kcq(struct amdgpu_device *adev, int xcc_id) queue_mask |= (1ull <<amdgpu_queue_mask_bit_to_set_resource_bit (adev, i)); } -DRM_INFO ("kiq ring mec %d pipe %d q %d\n" , kiq_ring->me, kiq_ring->pipe, - kiq_ring->queue);amdgpu_device_flush_hdp (adev,NULL ); +if (adev->enable_mes) + queue_mask = ~0ULL ; + +if (adev->enable_mes) { +for (i =0 ; i < adev->gfx.num_compute_rings; i++) { + j = i + xcc_id * adev->gfx.num_compute_rings; + r =amdgpu_mes_map_legacy_queue (adev, + &adev->gfx.compute_ring[j]); +if (r) { +DRM_ERROR ("failed to map compute queue\n" ); +return r; + } + } + +return 0 ; + } + +DRM_INFO ("kiq ring mec %d pipe %d q %d\n" , kiq_ring->me, kiq_ring->pipe, + kiq_ring->queue); +spin_lock (&kiq->ring_lock); r = amdgpu_ring_alloc(kiq_ring, kiq->pmf->map_queues_size * adev->gfx.num_compute_rings +@@ -636,9 +654,6 @@ int amdgpu_gfx_enable_kcq(struct amdgpu_device *adev, int xcc_id)return r; } -if (adev->enable_mes) - queue_mask = ~0ULL ; - kiq->pmf->kiq_set_resources (kiq_ring, queue_mask);for (i =0 ; i < adev->gfx.num_compute_rings; i++) { j = i + xcc_id * adev->gfx.num_compute_rings;@@ -665,6 +680,20 @@ int amdgpu_gfx_enable_kgq(struct amdgpu_device *adev, int xcc_id)amdgpu_device_flush_hdp (adev,NULL ); +if (adev->enable_mes) { +for (i =0 ; i < adev->gfx.num_gfx_rings; i++) { + j = i + xcc_id * adev->gfx.num_gfx_rings; + r =amdgpu_mes_map_legacy_queue (adev, + &adev->gfx.gfx_ring[j]); +if (r) { +DRM_ERROR ("failed to map gfx queue\n" ); +return r; + } + } + +return 0 ; + } +spin_lock (&kiq->ring_lock);/* No need to map kcq on the slave */ if (amdgpu_gfx_is_master_xcc (adev, xcc_id)) { --2.41.0