drm/amdkfd: Move a constant definition around
Subsystems (3)
PATCH 1/4 drm/amdkfd: Move a constant definition around
The similar definitions should be consecutive.
--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +6 -5
@@ -97,17 +97,18 @@#define KFD_CWSR_TBA_TMA_SIZE (PAGE_SIZE * 2)#define KFD_CWSR_TMA_OFFSET PAGE_SIZE +#define KFD_MAX_NUM_OF_QUEUES_PER_DEVICE \ + (KFD_MAX_NUM_OF_PROCESSES * \ + KFD_MAX_NUM_OF_QUEUES_PER_PROCESS) + +#define KFD_KERNEL_QUEUE_SIZE 2048 +/* * Kernel module parameter to specify maximum number of supported queues per * device */ extern int max_num_of_queues_per_device; -#define KFD_MAX_NUM_OF_QUEUES_PER_DEVICE \ - (KFD_MAX_NUM_OF_PROCESSES * \ - KFD_MAX_NUM_OF_QUEUES_PER_PROCESS) - -#define KFD_KERNEL_QUEUE_SIZE 2048/* Kernel module parameter to specify the scheduling policy */ extern int sched_policy;
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/4 drm/amdgpu: Add last_non_cp in amdgpu_doorbell_index
--- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c | 3 +++ 3 files changed, 12 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +6 -0
@@ -69,6 +69,7 @@ struct amdgpu_doorbell_index {uint32_t vce_ring6_7; } uvd_vce; }; +uint32_t last_non_cp;uint32_t max_assignment;/* Per engine SDMA doorbell size in dword */ uint32_t sdma_doorbell_range;
@@ -139,6 +140,9 @@ typedef enum _AMDGPU_VEGA20_DOORBELL_ASSIGNMENTAMDGPU_VEGA20_DOORBELL64_VCE_RING2_3 =0x18D ,AMDGPU_VEGA20_DOORBELL64_VCE_RING4_5 =0x18E ,AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7 =0x18F , + +AMDGPU_VEGA20_DOORBELL64_LAST_NON_CP =AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7 , +AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT =0x18F , AMDGPU_VEGA20_DOORBELL_INVALID = 0xFFFF }AMDGPU_VEGA20_DOORBELL_ASSIGNMENT ;
@@ -214,6 +218,8 @@ typedef enum _AMDGPU_DOORBELL64_ASSIGNMENTAMDGPU_DOORBELL64_VCE_RING4_5 =0xFE ,AMDGPU_DOORBELL64_VCE_RING6_7 =0xFF , +AMDGPU_DOORBELL64_LAST_NON_CP =AMDGPU_DOORBELL64_VCE_RING6_7 , +AMDGPU_DOORBELL64_MAX_ASSIGNMENT =0xFF , AMDGPU_DOORBELL64_INVALID = 0xFFFF }AMDGPU_DOORBELL64_ASSIGNMENT ;
drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c +3 -0
@@ -79,6 +79,9 @@ void vega10_doorbell_index_init(struct amdgpu_device *adev) adev->doorbell_index.uvd_vce.vce_ring2_3 =AMDGPU_DOORBELL64_VCE_RING2_3 ; adev->doorbell_index.uvd_vce.vce_ring4_5 =AMDGPU_DOORBELL64_VCE_RING4_5 ; adev->doorbell_index.uvd_vce.vce_ring6_7 =AMDGPU_DOORBELL64_VCE_RING6_7 ; + + adev->doorbell_index.last_non_cp =AMDGPU_DOORBELL64_LAST_NON_CP ; +/* In unit of dword doorbell */ adev->doorbell_index.max_assignment =AMDGPU_DOORBELL64_MAX_ASSIGNMENT <<1 ; adev->doorbell_index.sdma_doorbell_range =4 ;
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +3 -0
@@ -83,6 +83,9 @@ void vega20_doorbell_index_init(struct amdgpu_device *adev) adev->doorbell_index.uvd_vce.vce_ring2_3 =AMDGPU_VEGA20_DOORBELL64_VCE_RING2_3 ; adev->doorbell_index.uvd_vce.vce_ring4_5 =AMDGPU_VEGA20_DOORBELL64_VCE_RING4_5 ; adev->doorbell_index.uvd_vce.vce_ring6_7 =AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7 ; + + adev->doorbell_index.last_non_cp =AMDGPU_VEGA20_DOORBELL64_LAST_NON_CP ; + adev->doorbell_index.max_assignment =AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT <<1 ; adev->doorbell_index.sdma_doorbell_range =20 ; }
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 2/4] drm/amdgpu: Add last_non_cp in amdgpu_doorbell_index
Please add a patch description.
It may make sense to define a first_non_cp doorbell index too. In patch 3 you have this, which is a bit inconsistent:
+ gpu_resources.non_cp_doorbells_start =
+ adev->doorbell_index.sdma_engine[0];
+ gpu_resources.non_cp_doorbells_end =
+ adev->doorbell_index.last_non_cp;
You avoid hard-coding an assumption that the last non-CP doorbell is the same as VCE ring 6/7. But you still hard code an assumption that the first non-CP doorbell is SDMA0.
Regards,
Felix
Quoted 58 lines · Yong
Change-Id Icc9167771ad9539d8e31b40058e3b22be825a585Signed-off-by Yong Zhao <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c | 3 +++ 3 files changed, 12 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +6
-0@@ -69,6 +69,7 @@ struct amdgpu_doorbell_index {uint32_t vce_ring6_7; } uvd_vce; }; +uint32_t last_non_cp;uint32_t max_assignment;/* Per engine SDMA doorbell size in dword */ uint32_t sdma_doorbell_range;@@ -139,6 +140,9 @@ typedef enum _AMDGPU_VEGA20_DOORBELL_ASSIGNMENTAMDGPU_VEGA20_DOORBELL64_VCE_RING2_3 =0x18D ,AMDGPU_VEGA20_DOORBELL64_VCE_RING4_5 =0x18E ,AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7 =0x18F , + +AMDGPU_VEGA20_DOORBELL64_LAST_NON_CP =AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7 , +AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT =0x18F , AMDGPU_VEGA20_DOORBELL_INVALID = 0xFFFF }AMDGPU_VEGA20_DOORBELL_ASSIGNMENT ;@@ -214,6 +218,8 @@ typedef enum _AMDGPU_DOORBELL64_ASSIGNMENTAMDGPU_DOORBELL64_VCE_RING4_5 =0xFE ,AMDGPU_DOORBELL64_VCE_RING6_7 =0xFF , +AMDGPU_DOORBELL64_LAST_NON_CP =AMDGPU_DOORBELL64_VCE_RING6_7 , +AMDGPU_DOORBELL64_MAX_ASSIGNMENT =0xFF , AMDGPU_DOORBELL64_INVALID = 0xFFFF }AMDGPU_DOORBELL64_ASSIGNMENT ;drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c +3
-0@@ -79,6 +79,9 @@ void vega10_doorbell_index_init(struct amdgpu_device *adev) adev->doorbell_index.uvd_vce.vce_ring2_3 =AMDGPU_DOORBELL64_VCE_RING2_3 ; adev->doorbell_index.uvd_vce.vce_ring4_5 =AMDGPU_DOORBELL64_VCE_RING4_5 ; adev->doorbell_index.uvd_vce.vce_ring6_7 =AMDGPU_DOORBELL64_VCE_RING6_7 ; + + adev->doorbell_index.last_non_cp =AMDGPU_DOORBELL64_LAST_NON_CP ; +/* In unit of dword doorbell */ adev->doorbell_index.max_assignment =AMDGPU_DOORBELL64_MAX_ASSIGNMENT <<1 ; adev->doorbell_index.sdma_doorbell_range =4 ;drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +0
-0
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c void vega20_doorbell_index_init(struct amdgpu_device *adev) · line 91
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +3
-0@@ -83,6 +83,9 @@ void vega20_doorbell_index_init(struct amdgpu_device *adev) adev->doorbell_index.uvd_vce.vce_ring2_3 =AMDGPU_VEGA20_DOORBELL64_VCE_RING2_3 ; adev->doorbell_index.uvd_vce.vce_ring4_5 =AMDGPU_VEGA20_DOORBELL64_VCE_RING4_5 ; adev->doorbell_index.uvd_vce.vce_ring6_7 =AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7 ; + + adev->doorbell_index.last_non_cp =AMDGPU_VEGA20_DOORBELL64_LAST_NON_CP ; + adev->doorbell_index.max_assignment =AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT <<1 ; adev->doorbell_index.sdma_doorbell_range =20 ; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/4 drm/amdkfd: Fix bugs regarding CP queue doorbell mask on SOC15
In reply to a message not in the archiveReserved doorbells for SDMA IH and VCN were not properly masked out when allocating doorbells for CP user queues. This patch fixed that.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 16 ++++++++++++---- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 11 +++++++++++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 14 +++++++++----- drivers/gpu/drm/amd/include/kgd_kfd_interface.h | 15 ++++++--------- 4 files changed, 38 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +12 -4
@@ -196,11 +196,19 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) gpu_resources.sdma_doorbell[1 ][i+1 ] = adev->doorbell_index.sdma_engine[1 ] +0x200 + (i >>1 ); } -/* Doorbells 0x0e0-0ff and 0x2e0-2ff are reserved for -* SDMA, IH and VCN. So don't use them for the CP. + +/* Since SOC15, BIF starts to statically use the +* lower 12 bits of doorbell addresses for routing +* based on settings in registers like +* SDMA0_DOORBELL_RANGE etc.. +* In order to route a doorbell to CP engine, the lower +* 12 bits of its address has to be outside the range +* set for SDMA, VCN, and IH blocks. */ - gpu_resources.reserved_doorbell_mask =0x1e0 ; - gpu_resources.reserved_doorbell_val =0x0e0 ; + gpu_resources.non_cp_doorbells_start = + adev->doorbell_index.sdma_engine[0 ]; + gpu_resources.non_cp_doorbells_end = + adev->doorbell_index.last_non_cp;kgd2kfd_device_init (adev->kfd.dev, &gpu_resources); }
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +11 -0
@@ -103,6 +103,17 @@#define KFD_KERNEL_QUEUE_SIZE 2048 +/* +* 512 = 0x200 +* The doorbell index distance between SDMA RLC (2*i) and (2*i+1) in the +* same SDMA engine on SOC15, which has 8-byte doorbells for SDMA. +* 512 8-byte doorbell distance (i.e. one page away) ensures that SDMA RLC +* (2*i+1) doorbells (in terms of the lower 12 bit address) lie exactly in +* the OFFSET and SIZE set in registers like BIF_SDMA0_DOORBELL_RANGE. +*/ +#define KFD_QUEUE_DOORBELL_MIRROR_OFFSET 512 + +/* * Kernel module parameter to specify maximum number of supported queues per * device
drivers/gpu/drm/amd/amdkfd/kfd_process.c +9 -5
@@ -607,13 +607,17 @@ static int init_doorbell_bitmap(struct qcm_process_device *qpd,if (!qpd->doorbell_bitmap)return -ENOMEM ; -/* Mask out any reserved doorbells */ -for (i =0 ; i <KFD_MAX_NUM_OF_QUEUES_PER_PROCESS ; i++) -if ((dev->shared_resources.reserved_doorbell_mask & i) == - dev->shared_resources.reserved_doorbell_val) { +/* Mask out doorbells reserved for SDMA, IH, and VCN on SOC15. */ +for (i =0 ; i <KFD_MAX_NUM_OF_QUEUES_PER_PROCESS /2 ; i++) { +if (i >= dev->shared_resources.non_cp_doorbells_start + && i <= dev->shared_resources.non_cp_doorbells_end) {set_bit (i, qpd->doorbell_bitmap); -pr_debug ("reserved doorbell 0x%03x\n" , i); +set_bit (i +KFD_QUEUE_DOORBELL_MIRROR_OFFSET , + qpd->doorbell_bitmap); +pr_debug ("reserved doorbell 0x%03x and 0x%03x\n" , i, + i +KFD_QUEUE_DOORBELL_MIRROR_OFFSET ); } + }return 0 ; }
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +6 -9
@@ -140,17 +140,14 @@ struct kgd2kfd_shared_resources {/* Doorbell assignments (SOC15 and later chips only). Only * specific doorbells are routed to each SDMA engine. Others * are routed to IH and VCN. They are not usable by the CP. -* -* Any doorbell number D that satisfies the following condition -* is reserved: (D & reserved_doorbell_mask) == reserved_doorbell_val -* -* KFD currently uses 1024 (= 0x3ff) doorbells per process. If -* doorbells 0x0e0-0x0ff and 0x2e0-0x2ff are reserved, that means -* mask would be set to 0x1e0 and val set to 0x0e0. */ unsigned int sdma_doorbell[2 ][8 ]; -unsigned int reserved_doorbell_mask; -unsigned int reserved_doorbell_val; + +/* From SOC15 onward, the doorbell index range not usable for CP +* queues. +*/ +uint32_t non_cp_doorbells_start; +uint32_t non_cp_doorbells_end;/* Base address of doorbell aperture. */ phys_addr_t doorbell_physical_address;
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/4 drm/amdkfd: Optimize out sdma doorbell array in kgd2kfd_shared_resources
In reply to a message not in the archiveWe can directly calculate sdma doorbell indexes in the process doorbell pages through the doorbell_index structure in amdgpu_device, so no need to cache them in kgd2kfd_shared_resources any more. This alleviates the adaptation needs when new SDMA configurations are introduced.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 41 +++++-------------- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 16 +++++--- .../gpu/drm/amd/include/kgd_kfd_interface.h | 4 +- 3 files changed, 23 insertions(+), 38 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +10 -31
@@ -131,7 +131,7 @@ static void amdgpu_doorbell_get_kfd_info(struct amdgpu_device *adev,void amdgpu_amdkfd_device_init (struct amdgpu_device *adev) { -int i, n; +int i;int last_valid_bit;if (adev->kfd.dev) {
@@ -142,7 +142,9 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) .gpuvm_size = min(adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT, AMDGPU_GMC_HOLE_START), - .drm_render_minor = adev->ddev->render->index + .drm_render_minor = adev->ddev->render->index, + .sdma_doorbell_idx = adev->doorbell_index.sdma_engine, + };/* this is going to have a few of the MSBs set that we need to
@@ -172,31 +174,6 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) &gpu_resources.doorbell_aperture_size, &gpu_resources.doorbell_start_offset); -if (adev->asic_type <CHIP_VEGA10 ) { -kgd2kfd_device_init (adev->kfd.dev, &gpu_resources); -return ; - } - - n = (adev->asic_type <CHIP_VEGA20 ) ?2 :8 ; - -for (i =0 ; i < n; i +=2 ) { -/* On SOC15 the BIF is involved in routing -* doorbells using the low 12 bits of the -* address. Communicate the assignments to -* KFD. KFD uses two doorbell pages per -* process in case of 64-bit doorbells so we -* can use each doorbell assignment twice. -*/ - gpu_resources.sdma_doorbell[0 ][i] = - adev->doorbell_index.sdma_engine[0 ] + (i >>1 ); - gpu_resources.sdma_doorbell[0 ][i+1 ] = - adev->doorbell_index.sdma_engine[0 ] +0x200 + (i >>1 ); - gpu_resources.sdma_doorbell[1 ][i] = - adev->doorbell_index.sdma_engine[1 ] + (i >>1 ); - gpu_resources.sdma_doorbell[1 ][i+1 ] = - adev->doorbell_index.sdma_engine[1 ] +0x200 + (i >>1 ); - } -/* Since SOC15, BIF starts to statically use the * lower 12 bits of doorbell addresses for routing * based on settings in registers like
@@ -205,10 +182,12 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)* 12 bits of its address has to be outside the range * set for SDMA, VCN, and IH blocks. */ - gpu_resources.non_cp_doorbells_start = - adev->doorbell_index.sdma_engine[0 ]; - gpu_resources.non_cp_doorbells_end = - adev->doorbell_index.last_non_cp; +if (adev->asic_type >=CHIP_VEGA10 ) { + gpu_resources.non_cp_doorbells_start = + adev->doorbell_index.sdma_engine[0 ]; + gpu_resources.non_cp_doorbells_end = + adev->doorbell_index.last_non_cp; + }kgd2kfd_device_init (adev->kfd.dev, &gpu_resources); }
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +11 -5
@@ -134,12 +134,18 @@ static int allocate_doorbell(struct qcm_process_device *qpd, struct queue *q)*/ q->doorbell_id = q->properties.queue_id; }else if (q->properties.type ==KFD_QUEUE_TYPE_SDMA ) { -/* For SDMA queues on SOC15, use static doorbell -* assignments based on the engine and queue. +/* For SDMA queues on SOC15 with 8-byte doorbell, use static +* doorbell assignments based on the engine and queue id. +* The doobell index distance between RLC (2*i) and (2*i+1) +* for a SDMA engine is 512. */ - q->doorbell_id = dev->shared_resources.sdma_doorbell - [q->properties.sdma_engine_id] - [q->properties.sdma_queue_id]; +uint32_t *idx_offset = + dev->shared_resources.sdma_doorbell_idx; + + q->doorbell_id = idx_offset[q->properties.sdma_engine_id] + + (q->properties.sdma_queue_id &1 ) + *KFD_QUEUE_DOORBELL_MIRROR_OFFSET + + (q->properties.sdma_queue_id >>1 ); }else {/* For CP queues on SOC15 reserve a free doorbell ID */ unsigned int found;
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +2 -2
@@ -137,11 +137,11 @@ struct kgd2kfd_shared_resources {/* Bit n == 1 means Queue n is available for KFD */ DECLARE_BITMAP (queue_bitmap,KGD_MAX_QUEUES ); -/* Doorbell assignments (SOC15 and later chips only). Only +/* SDMA doorbell assignments (SOC15 and later chips only). Only * specific doorbells are routed to each SDMA engine. Others * are routed to IH and VCN. They are not usable by the CP. */ -unsigned int sdma_doorbell[2 ][8 ]; +uint32_t *sdma_doorbell_idx;/* From SOC15 onward, the doorbell index range not usable for CP * queues.
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx