drm/amdgpu/gfx11: fix me field handling in map_queue packet
Subsystems (2)
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu/gfx11: fix me field handling in map_queue packet
From: Jack Xiao <[email protected]>
Select the correct microengine (me) when using the map_queue packet. There are different me's for GFX, compute, and scheduling.
Signed-off-by Jack Xiao <[email protected]>
Reviewed-by Hawking Zhang <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +5 -2
@@ -145,16 +145,19 @@ static void gfx11_kiq_map_queues(struct amdgpu_ring *kiq_ring, {uint64_t mqd_addr =amdgpu_bo_gpu_offset (ring->mqd_obj);uint64_t wptr_addr = ring->wptr_gpu_addr; -uint32_t eng_sel =0 ; +uint32_t me =0 , eng_sel =0 ;switch (ring->funcs->type) {case AMDGPU_RING_TYPE_COMPUTE : + me =1 ; eng_sel =0 ;break ;case AMDGPU_RING_TYPE_GFX : + me =0 ; eng_sel =4 ;break ;case AMDGPU_RING_TYPE_MES : + me =2 ; eng_sel =5 ;break ;default :
@@ -168,7 +171,7 @@ static void gfx11_kiq_map_queues(struct amdgpu_ring *kiq_ring,PACKET3_MAP_QUEUES_VMID (0 ) |/* VMID */ PACKET3_MAP_QUEUES_QUEUE (ring->queue) |PACKET3_MAP_QUEUES_PIPE (ring->pipe) | -PACKET3_MAP_QUEUES_ME ((ring->me ==1 ?0 :1 )) | +PACKET3_MAP_QUEUES_ME ((me)) |PACKET3_MAP_QUEUES_QUEUE_TYPE (0 ) |/*queue_type: normal compute queue */ PACKET3_MAP_QUEUES_ALLOC_FORMAT (0 ) |/* alloc format: all_on_one_pipe */ PACKET3_MAP_QUEUES_ENGINE_SEL(eng_sel) |
Signature · 1 line
2.35.3
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu/gfx11: fix mes mqd settings
From: Jack Xiao <[email protected]>
Use the correct Memory Queue Descriptor (MQD) structure for GC 11.
Signed-off-by Jack Xiao <[email protected]>
Reviewed-by Hawking Zhang <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +10 -10
@@ -29,7 +29,7 @@#include "gc/gc_11_0_0_offset.h" #include "gc/gc_11_0_0_sh_mask.h" #include "gc/gc_11_0_0_default.h" -#include "v10_structs.h" +#include "v11_structs.h" #include "mes_v11_api_def.h" MODULE_FIRMWARE ("amdgpu/gc_11_0_0_mes.bin" );
@@ -637,7 +637,7 @@ static int mes_v11_0_allocate_eop_buf(struct amdgpu_device *adev,static int mes_v11_0_mqd_init (struct amdgpu_ring *ring) { -struct v10_compute_mqd *mqd = ring->mqd_ptr; +struct v11_compute_mqd *mqd = ring->mqd_ptr;uint64_t hqd_gpu_addr, wb_gpu_addr, eop_base_addr;uint32_t tmp;
@@ -724,22 +724,22 @@ static int mes_v11_0_mqd_init(struct amdgpu_ring *ring) mqd->cp_hqd_vmid =0 ;/* activate the queue */ mqd->cp_hqd_active =1 ; - mqd->cp_hqd_persistent_state = regCP_HQD_PERSISTENT_STATE_DEFAULT; + + tmp = regCP_HQD_PERSISTENT_STATE_DEFAULT; + tmp =REG_SET_FIELD (tmp,CP_HQD_PERSISTENT_STATE , +PRELOAD_SIZE ,0x55 ); + mqd->cp_hqd_persistent_state = tmp; + mqd->cp_hqd_ib_control = regCP_HQD_IB_CONTROL_DEFAULT; mqd->cp_hqd_iq_timer = regCP_HQD_IQ_TIMER_DEFAULT; mqd->cp_hqd_quantum = regCP_HQD_QUANTUM_DEFAULT; - tmp = regCP_HQD_GFX_CONTROL_DEFAULT; - tmp =REG_SET_FIELD (tmp,CP_HQD_GFX_CONTROL ,DB_UPDATED_MSG_EN ,1 ); -/* offset: 184 - this is used for CP_HQD_GFX_CONTROL */ - mqd->cp_hqd_suspend_cntl_stack_offset = tmp; -return 0 ; }static void mes_v11_0_queue_init_register (struct amdgpu_ring *ring) { -struct v10_compute_mqd *mqd = ring->mqd_ptr; +struct v11_compute_mqd *mqd = ring->mqd_ptr;struct amdgpu_device *adev = ring->adev;uint32_t data =0 ;
@@ -910,7 +910,7 @@ static int mes_v11_0_kiq_ring_init(struct amdgpu_device *adev)static int mes_v11_0_mqd_sw_init (struct amdgpu_device *adev,enum admgpu_mes_pipe pipe) { -int r, mqd_size =sizeof (struct v10_compute_mqd ); +int r, mqd_size =sizeof (struct v11_compute_mqd );struct amdgpu_ring *ring;if (pipe ==AMDGPU_MES_KIQ_PIPE )
Signature · 1 line
2.35.3
Alex Deucher
maintainerPATCH 1/1 drm/amdgpu/gmc11: avoid cpu accessing registers to flush VM
In reply to Alex DeucherFrom: Jack Xiao <[email protected]>
Due to gfxoff on, cpu accessing registers is not expected.
v2: remove bug-on, fix the vmhub check
Signed-off-by Jack Xiao <[email protected]>
Reviewed-by Hawking Zhang <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 49 +++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +48 -1
@@ -258,6 +258,12 @@ static void gmc_v11_0_flush_vm_hub(struct amdgpu_device *adev, uint32_t vmid,static void gmc_v11_0_flush_gpu_tlb (struct amdgpu_device *adev,uint32_t vmid,uint32_t vmhub,uint32_t flush_type) { +struct amdgpu_ring *ring = adev->mman.buffer_funcs_ring; +struct dma_fence *fence; +struct amdgpu_job *job; + +int r; +if ((vmhub ==AMDGPU_GFXHUB_0 ) && !adev->gfx.is_poweron)return ;
@@ -281,8 +287,49 @@ static void gmc_v11_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid, }mutex_lock (&adev->mman.gtt_window_lock); -gmc_v11_0_flush_vm_hub (adev, vmid, vmhub,0 ); + +if (vmhub !=AMDGPU_GFXHUB_0 ) { +gmc_v11_0_flush_vm_hub (adev, vmid, vmhub,0 ); +mutex_unlock (&adev->mman.gtt_window_lock); +return ; + } + +if (!adev->mman.buffer_funcs_enabled || + !adev->ib_pool_ready || +amdgpu_in_reset (adev) || + ring->sched.ready == false) { +gmc_v11_0_flush_vm_hub (adev, vmid,AMDGPU_GFXHUB_0 ,0 ); +mutex_unlock (&adev->mman.gtt_window_lock); +return ; + } + + r =amdgpu_job_alloc_with_ib (adev,16 *4 ,AMDGPU_IB_POOL_IMMEDIATE , + &job); +if (r) + goto error_alloc; + + job->vm_pd_addr =amdgpu_gmc_pd_addr (adev->gart.bo); + job->vm_needs_flush = true; + job->ibs->ptr[job->ibs->length_dw++] = ring->funcs->nop; +amdgpu_ring_pad_ib (ring, &job->ibs[0 ]); + r =amdgpu_job_submit (job, &adev->mman.entity, +AMDGPU_FENCE_OWNER_UNDEFINED , &fence); +if (r) + goto error_submit; + +mutex_unlock (&adev->mman.gtt_window_lock); + +dma_fence_wait (fence, false); +dma_fence_put (fence); + +return ; + +error_submit: +amdgpu_job_free (job); + +error_alloc:mutex_unlock (&adev->mman.gtt_window_lock); +DRM_ERROR ("Error flushing GPU TLB using the SDMA (%d)!\n" , r);return ; }
Signature · 1 line
2.35.3