drm/amdkfd: Move a constant definition around
Subsystems (3)
PATCH 1/3 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/3 drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
Reserved 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 | 17 ++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h | 4 +++ drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 9 +++++++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 25 +++++++++++++------ .../gpu/drm/amd/include/kgd_kfd_interface.h | 19 +++++--------- 7 files changed, 56 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +13 -4
@@ -196,11 +196,20 @@ 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. + +/* Because of the setting in registers like +* SDMA0_DOORBELL_RANGE etc., BIF statically uses the +* lower 12 bits of doorbell address for routing, in +* order to route the CP queue doorbells to CP engine, +* the doorbells allocated to CP queues have to be +* outside the range set for SDMA, VCN, and IH blocks +* Prior to SOC15, all queues use queue ID to +* determine doorbells. */ - gpu_resources.reserved_doorbell_mask =0x1e0 ; - gpu_resources.reserved_doorbell_val =0x0e0 ; + gpu_resources.reserved_doorbells_start = + adev->doorbell_index.sdma_engine[0 ]; + gpu_resources.reserved_doorbells_end = + adev->doorbell_index.last_non_cp;kgd2kfd_device_init (adev->kfd.dev, &gpu_resources); }
drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +4 -0
@@ -71,6 +71,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;
@@ -143,6 +144,7 @@ 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 ;
@@ -222,6 +224,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
@@ -81,6 +81,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
@@ -85,6 +85,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 ; }
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +9 -0
@@ -103,6 +103,15 @@#define KFD_KERNEL_QUEUE_SIZE 2048 +/* 512 = 0x200 +* On SOC15, the doorbell index distance for SDMA RLC i and (i + 1) in the +* same SDMA engine, where i is a even number. +* For 8-bytes doorbells, it ensures that the mirror doorbell range (in terms +* of low 12 bit address for each HW engine) on the second doorbell page is +* the same as the range of the first doorbell page.*/ +#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 +18 -7
@@ -607,13 +607,24 @@ 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) { -set_bit (i, qpd->doorbell_bitmap); -pr_debug ("reserved doorbell 0x%03x\n" , i); - } +/* Mask out all reserved doorbells for SDMA, IH, and VCN on SOC15. +* Because of the setting in registers like SDMA0_DOORBELL_RANGE etc., +* BIF statically uses the lower 12 bits of doorbell address for +* routing. In order to route the CP queue doorbells to CP engine, +* the doorbells allocated to CP queues have to be outside the range +* set for SDMA, VCN, and IH blocks. +* Prior to SOC15, all queues use queue ID to +* determine doorbells. */ + i = dev->shared_resources.reserved_doorbells_start; +while (i <= dev->shared_resources.reserved_doorbells_end) { +set_bit (i, qpd->doorbell_bitmap); +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 ); + + i++; + }return 0 ; }
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +6 -13
@@ -137,20 +137,13 @@ 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 -* 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 onwards, the doorbell indexes reserved for SDMA, IH, +* and VCN +*/ +unsigned int reserved_doorbells_start; +unsigned int reserved_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
A message that is not in the archive (sent off-list or not yet received): [email protected]
RE: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
Can we delete userqueue_start/end? I think the original purpose for those two fields are to specify a doorbell range for user queues, but were never used. Now we clearly want user queue to use all the range, minus range of IH/MM/SDMA. So those two fields will not be used.
Thanks,
Oak
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Zhao, Yong
Sent: Thursday, January 31, 2019 5:27 PM
To: [email protected]
Cc: Zhao, Yong <[email protected]>
Subject: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
Reserved 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 | 17 ++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h | 4 +++ drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 9 +++++++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 25 +++++++++++++------ .../gpu/drm/amd/include/kgd_kfd_interface.h | 19 +++++--------- 7 files changed, 56 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +13 -4
@@ -196,11 +196,20 @@ 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. + +/* Because of the setting in registers like +* SDMA0_DOORBELL_RANGE etc., BIF statically uses the +* lower 12 bits of doorbell address for routing, in +* order to route the CP queue doorbells to CP engine, +* the doorbells allocated to CP queues have to be +* outside the range set for SDMA, VCN, and IH blocks +* Prior to SOC15, all queues use queue ID to +* determine doorbells. */ - gpu_resources.reserved_doorbell_mask =0x1e0 ; - gpu_resources.reserved_doorbell_val =0x0e0 ; + gpu_resources.reserved_doorbells_start = + adev->doorbell_index.sdma_engine[0 ]; + gpu_resources.reserved_doorbells_end = + adev->doorbell_index.last_non_cp;kgd2kfd_device_init (adev->kfd.dev, &gpu_resources); }
drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +4 -0
@@ -71,6 +71,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;
@@ -143,6 +144,7 @@ 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 ;
@@ -222,6 +224,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
@@ -81,6 +81,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; diff --git a/drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c b/drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c
index 53716c593b2b..b1052caaff5e 100644
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +4 -0
@@ -85,6 +85,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; } diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
index e5ebcca7f031..6b8459f852cc 100644
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +12 -0
@@ -103,6 +103,15 @@#define KFD_KERNEL_QUEUE_SIZE 2048 +/* 512 = 0x200 +* On SOC15, the doorbell index distance for SDMA RLC i and (i + 1) in +the +* same SDMA engine, where i is a even number. +* For 8-bytes doorbells, it ensures that the mirror doorbell range (in +terms +* of low 12 bit address for each HW engine) on the second doorbell +page is +* the same as the range of the first doorbell page.*/ #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 +18 -7
@@ -607,13 +607,24 @@ 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) { -set_bit (i, qpd->doorbell_bitmap); -pr_debug ("reserved doorbell 0x%03x\n" , i); - } +/* Mask out all reserved doorbells for SDMA, IH, and VCN on SOC15. +* Because of the setting in registers like SDMA0_DOORBELL_RANGE etc., +* BIF statically uses the lower 12 bits of doorbell address for +* routing. In order to route the CP queue doorbells to CP engine, +* the doorbells allocated to CP queues have to be outside the range +* set for SDMA, VCN, and IH blocks. +* Prior to SOC15, all queues use queue ID to +* determine doorbells. */ + i = dev->shared_resources.reserved_doorbells_start; +while (i <= dev->shared_resources.reserved_doorbells_end) { +set_bit (i, qpd->doorbell_bitmap); +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 ); + + i++; + }return 0 ; }
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +6 -13
@@ -137,20 +137,13 @@ 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 -* 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 onwards, the doorbell indexes reserved for SDMA, IH, +* and VCN +*/ +unsigned int reserved_doorbells_start; +unsigned int reserved_doorbells_end;/* Base address of doorbell aperture. */ phys_addr_t doorbell_physical_address;
--
2.17.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Kuehling, Felix
Reviewed-by Felix KuehlingRe: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
In reply to a message not in the archiveQuoted 5 lines · Yong
Reserved doorbells for SDMA IH and VCN were not properly masked out when allocating doorbells for CP user queues. This patch fixed that.
Change-Id I670adfc3fd7725d2ed0bd9665cb7f69f8b9023c2Signed-off-by Yong Zhao <[email protected]>
One mostly cosmetic comment inline. With that fixed, the series is
Quoted 131 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 17 ++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h | 4 +++ drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 9 +++++++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 25 +++++++++++++------ .../gpu/drm/amd/include/kgd_kfd_interface.h | 19 +++++--------- 7 files changed, 56 insertions(+), 24 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +13
-4@@ -196,11 +196,20 @@ 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. + +/* Because of the setting in registers like +* SDMA0_DOORBELL_RANGE etc., BIF statically uses the +* lower 12 bits of doorbell address for routing, in +* order to route the CP queue doorbells to CP engine, +* the doorbells allocated to CP queues have to be +* outside the range set for SDMA, VCN, and IH blocks +* Prior to SOC15, all queues use queue ID to +* determine doorbells. */ - gpu_resources.reserved_doorbell_mask =0x1e0 ; - gpu_resources.reserved_doorbell_val =0x0e0 ; + gpu_resources.reserved_doorbells_start = + adev->doorbell_index.sdma_engine[0 ]; + gpu_resources.reserved_doorbells_end = + adev->doorbell_index.last_non_cp;kgd2kfd_device_init (adev->kfd.dev, &gpu_resources); }drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +4
-0@@ -71,6 +71,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;@@ -143,6 +144,7 @@ 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 ;@@ -222,6 +224,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@@ -81,6 +81,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@@ -85,6 +85,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 ; }drivers/gpu/drm/amd/amdkfd/kfd_priv.h +9
-0@@ -103,6 +103,15 @@#define KFD_KERNEL_QUEUE_SIZE 2048 +/* 512 = 0x200 +* On SOC15, the doorbell index distance for SDMA RLC i and (i + 1) in the +* same SDMA engine, where i is a even number. +* For 8-bytes doorbells, it ensures that the mirror doorbell range (in terms +* of low 12 bit address for each HW engine) on the second doorbell page is +* the same as the range of the first doorbell page.*/ +#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 +0
-7@@ -607,13 +607,24 @@ 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) { -set_bit (i, qpd->doorbell_bitmap); -pr_debug ("reserved doorbell 0x%03x\n" , i); - }
drivers/gpu/drm/amd/amdkfd/kfd_process.c static int init_doorbell_bitmap(struct qcm_process_device *qpd, · line 619
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +10
-0+/* Mask out all reserved doorbells for SDMA, IH, and VCN on SOC15. +* Because of the setting in registers like SDMA0_DOORBELL_RANGE etc., +* BIF statically uses the lower 12 bits of doorbell address for +* routing. In order to route the CP queue doorbells to CP engine, +* the doorbells allocated to CP queues have to be outside the range +* set for SDMA, VCN, and IH blocks. +* Prior to SOC15, all queues use queue ID to +* determine doorbells. */ + i = dev->shared_resources.reserved_doorbells_start; +while (i <= dev->shared_resources.reserved_doorbells_end) {
This should be a for-loop to be more obvious:
for (i = dev->shared_resources.reserved_doorbells_start;
i <= dev->shared_resources.reserved_doorbells_end;
i++) {
...
}Quoted 32 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +8
-0+set_bit (i, qpd->doorbell_bitmap); +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 ); + + i++; + }return 0 ; }drivers/gpu/drm/amd/include/kgd_kfd_interface.h +0
-12@@ -137,20 +137,13 @@ 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 -* 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;
drivers/gpu/drm/amd/include/kgd_kfd_interface.h struct kgd2kfd_shared_resources { · line 149
Quoted 10 lines
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +6
-1-unsigned int reserved_doorbell_val; + +/* From SOC15 onwards, the doorbell indexes reserved for SDMA, IH, +* and VCN +*/ +unsigned int reserved_doorbells_start; +unsigned int reserved_doorbells_end;/* Base address of doorbell aperture. */ phys_addr_t doorbell_physical_address;
_______________________________________________
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): e01f29c1-74e8-4dd6-81fc-b25c0432798f-5C7GfCeVMHo@public.gmane.org
Zhao, Yong
Reviewed-by Felix KuehlingRe: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
Oak,
It is a good idea to remove the userqueue_start/end. However, when doing so, I came to the following code in gfx_v9_0_kiq_init_register() :
/* enable the doorbell if requested */
if (ring->use_doorbell) {
WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER,
(adev->doorbell_index.kiq * 2) << 2);
WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER,
(adev->doorbell_index.userqueue_end * 2) << 2);
}I remember that you reached the conclusion in one email thread that mmCP_MEC_DOORBELL_RANGE_UPPER/LOWER did not have effect at all on gfx9. Have we got any firm conclusions from HW engineer in the end? If those two registers are still valid, we should enforce the range for CP queues.
Regards,
Yong
________________________________
From: Kuehling, Felix
Sent: Friday, February 1, 2019 3:03 PM
To: Zhao, Yong; [email protected]
Subject: Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
Quoted 5 lines · Yong
Reserved doorbells for SDMA IH and VCN were not properly masked out when allocating doorbells for CP user queues. This patch fixed that.
Change-Id I670adfc3fd7725d2ed0bd9665cb7f69f8b9023c2Signed-off-by Yong Zhao <[email protected]>
One mostly cosmetic comment inline. With that fixed, the series is
Quoted 131 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 17 ++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h | 4 +++ drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 9 +++++++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 25 +++++++++++++------ .../gpu/drm/amd/include/kgd_kfd_interface.h | 19 +++++--------- 7 files changed, 56 insertions(+), 24 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +13
-4@@ -196,11 +196,20 @@ 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. + +/* Because of the setting in registers like +* SDMA0_DOORBELL_RANGE etc., BIF statically uses the +* lower 12 bits of doorbell address for routing, in +* order to route the CP queue doorbells to CP engine, +* the doorbells allocated to CP queues have to be +* outside the range set for SDMA, VCN, and IH blocks +* Prior to SOC15, all queues use queue ID to +* determine doorbells. */ - gpu_resources.reserved_doorbell_mask =0x1e0 ; - gpu_resources.reserved_doorbell_val =0x0e0 ; + gpu_resources.reserved_doorbells_start = + adev->doorbell_index.sdma_engine[0 ]; + gpu_resources.reserved_doorbells_end = + adev->doorbell_index.last_non_cp;kgd2kfd_device_init (adev->kfd.dev, &gpu_resources); }drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +4
-0@@ -71,6 +71,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;@@ -143,6 +144,7 @@ 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 ;@@ -222,6 +224,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@@ -81,6 +81,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@@ -85,6 +85,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 ; }drivers/gpu/drm/amd/amdkfd/kfd_priv.h +9
-0@@ -103,6 +103,15 @@#define KFD_KERNEL_QUEUE_SIZE 2048 +/* 512 = 0x200 +* On SOC15, the doorbell index distance for SDMA RLC i and (i + 1) in the +* same SDMA engine, where i is a even number. +* For 8-bytes doorbells, it ensures that the mirror doorbell range (in terms +* of low 12 bit address for each HW engine) on the second doorbell page is +* the same as the range of the first doorbell page.*/ +#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 +0
-7@@ -607,13 +607,24 @@ 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) { -set_bit (i, qpd->doorbell_bitmap); -pr_debug ("reserved doorbell 0x%03x\n" , i); - }
drivers/gpu/drm/amd/amdkfd/kfd_process.c static int init_doorbell_bitmap(struct qcm_process_device *qpd, · line 619
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +10
-0+/* Mask out all reserved doorbells for SDMA, IH, and VCN on SOC15. +* Because of the setting in registers like SDMA0_DOORBELL_RANGE etc., +* BIF statically uses the lower 12 bits of doorbell address for +* routing. In order to route the CP queue doorbells to CP engine, +* the doorbells allocated to CP queues have to be outside the range +* set for SDMA, VCN, and IH blocks. +* Prior to SOC15, all queues use queue ID to +* determine doorbells. */ + i = dev->shared_resources.reserved_doorbells_start; +while (i <= dev->shared_resources.reserved_doorbells_end) {
This should be a for-loop to be more obvious:
for (i = dev->shared_resources.reserved_doorbells_start;
i <= dev->shared_resources.reserved_doorbells_end;
i++) {
...
}Quoted 32 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +8
-0+set_bit (i, qpd->doorbell_bitmap); +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 ); + + i++; + }return 0 ; }drivers/gpu/drm/amd/include/kgd_kfd_interface.h +0
-12@@ -137,20 +137,13 @@ 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 -* 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;
drivers/gpu/drm/amd/include/kgd_kfd_interface.h struct kgd2kfd_shared_resources { · line 149
Quoted 10 lines
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +6
-1-unsigned int reserved_doorbell_val; + +/* From SOC15 onwards, the doorbell indexes reserved for SDMA, IH, +* and VCN +*/ +unsigned int reserved_doorbells_start; +unsigned int reserved_doorbells_end;/* Base address of doorbell aperture. */ phys_addr_t doorbell_physical_address;
_______________________________________________
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): BL0PR12MB250046784085018A70E34EC0F0920-b4cIHhjg/p89/[email protected]
Zeng, Oak
Reviewed-by Felix KuehlingRE: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
Hi Yong,
mmCP_MEC_DOORBELL_RANGE_LOWER/UPPER are used at CP to double check a doorbell ringing routed to CP. It is a must to program. We have to keep userqueue_start/end. Sorry for the confusion.
Regards,
Oak
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> On Behalf Of Zhao, Yong
Sent: Friday, February 1, 2019 7:04 PM
To: Kuehling, Felix <[email protected]>; [email protected]; Zeng, Oak <[email protected]>
Subject: Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
Oak,
It is a good idea to remove the userqueue_start/end. However, when doing so, I came to the following code in gfx_v9_0_kiq_init_register() :
/* enable the doorbell if requested */
if (ring->use_doorbell) {
WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER,
(adev->doorbell_index.kiq * 2) << 2);
WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER,
(adev->doorbell_index.userqueue_end * 2) << 2);
}I remember that you reached the conclusion in one email thread that mmCP_MEC_DOORBELL_RANGE_UPPER/LOWER did not have effect at all on gfx9. Have we got any firm conclusions from HW engineer in the end? If those two registers are still valid, we should enforce the range for CP queues.
Regards,
Yong
________________________________
From: Kuehling, Felix
Sent: Friday, February 1, 2019 3:03 PM
To: Zhao, Yong; [email protected]<mailto:amd-gfx-PD4FTy7X32lzq7FAFJ/[email protected]>
Subject: Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
Quoted 5 lines · Yong
Reserved doorbells for SDMA IH and VCN were not properly masked out when allocating doorbells for CP user queues. This patch fixed that.
Change-Id I670adfc3fd7725d2ed0bd9665cb7f69f8b9023c2Signed-off-by Yong Zhao <[email protected]<mailto:[email protected]>>
One mostly cosmetic comment inline. With that fixed, the series is
Quoted 131 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 17 ++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h | 4 +++ drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 9 +++++++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 25 +++++++++++++------ .../gpu/drm/amd/include/kgd_kfd_interface.h | 19 +++++--------- 7 files changed, 56 insertions(+), 24 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +13
-4@@ -196,11 +196,20 @@ 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. + +/* Because of the setting in registers like +* SDMA0_DOORBELL_RANGE etc., BIF statically uses the +* lower 12 bits of doorbell address for routing, in +* order to route the CP queue doorbells to CP engine, +* the doorbells allocated to CP queues have to be +* outside the range set for SDMA, VCN, and IH blocks +* Prior to SOC15, all queues use queue ID to +* determine doorbells. */ - gpu_resources.reserved_doorbell_mask =0x1e0 ; - gpu_resources.reserved_doorbell_val =0x0e0 ; + gpu_resources.reserved_doorbells_start = + adev->doorbell_index.sdma_engine[0 ]; + gpu_resources.reserved_doorbells_end = + adev->doorbell_index.last_non_cp;kgd2kfd_device_init (adev->kfd.dev, &gpu_resources); }drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +4
-0@@ -71,6 +71,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;@@ -143,6 +144,7 @@ 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 ;@@ -222,6 +224,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@@ -81,6 +81,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@@ -85,6 +85,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 ; }drivers/gpu/drm/amd/amdkfd/kfd_priv.h +9
-0@@ -103,6 +103,15 @@#define KFD_KERNEL_QUEUE_SIZE 2048 +/* 512 = 0x200 +* On SOC15, the doorbell index distance for SDMA RLC i and (i + 1) in the +* same SDMA engine, where i is a even number. +* For 8-bytes doorbells, it ensures that the mirror doorbell range (in terms +* of low 12 bit address for each HW engine) on the second doorbell page is +* the same as the range of the first doorbell page.*/ +#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 +0
-7@@ -607,13 +607,24 @@ 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) { -set_bit (i, qpd->doorbell_bitmap); -pr_debug ("reserved doorbell 0x%03x\n" , i); - }
drivers/gpu/drm/amd/amdkfd/kfd_process.c static int init_doorbell_bitmap(struct qcm_process_device *qpd, · line 619
Quoted 10 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +10
-0+/* Mask out all reserved doorbells for SDMA, IH, and VCN on SOC15. +* Because of the setting in registers like SDMA0_DOORBELL_RANGE etc., +* BIF statically uses the lower 12 bits of doorbell address for +* routing. In order to route the CP queue doorbells to CP engine, +* the doorbells allocated to CP queues have to be outside the range +* set for SDMA, VCN, and IH blocks. +* Prior to SOC15, all queues use queue ID to +* determine doorbells. */ + i = dev->shared_resources.reserved_doorbells_start; +while (i <= dev->shared_resources.reserved_doorbells_end) {
This should be a for-loop to be more obvious:
for (i = dev->shared_resources.reserved_doorbells_start;
i <= dev->shared_resources.reserved_doorbells_end;
i++) {
...
}Quoted 32 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +8
-0+set_bit (i, qpd->doorbell_bitmap); +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 ); + + i++; + }return 0 ; }drivers/gpu/drm/amd/include/kgd_kfd_interface.h +0
-12@@ -137,20 +137,13 @@ 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 -* 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;
drivers/gpu/drm/amd/include/kgd_kfd_interface.h struct kgd2kfd_shared_resources { · line 149
Quoted 10 lines
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +6
-1-unsigned int reserved_doorbell_val; + +/* From SOC15 onwards, the doorbell indexes reserved for SDMA, IH, +* and VCN +*/ +unsigned int reserved_doorbells_start; +unsigned int reserved_doorbells_end;/* Base address of doorbell aperture. */ phys_addr_t doorbell_physical_address;
_______________________________________________
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): DM5PR12MB25826F20FB8EF1E7E4B6348480930-2J9CzHegvk8nywYgqlzn1wdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
I don't see anything about userqueue start/end in Yong's patch. That said, I think you're mixing up two different things. MEC_DOORBELL_RANGE is not the same as userqueues? We have MEC kernel queues as well that would have to fall in the same range. And we have SDMA user queues that don't belong in the MEC doorbell range. Therefore I think the name USERQUEUE_START/END is misleading.
Regards,
Felix
Quoted 267 lines · Oak
Hi Yong,
mmCP_MEC_DOORBELL_RANGE_LOWER/UPPER are used at CP to double check a doorbell ringing routed to CP. It is a must to program. We have to keep userqueue_start/end. Sorry for the confusion.
Regards,
Oak
*From:* amd-gfx <[email protected]> *On Behalf Of *Zhao, Yong
*Sent:* Friday, February 1, 2019 7:04 PM
*To:* Kuehling, Felix <[email protected]>; [email protected]; Zeng, Oak <[email protected]> *Subject:* Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15Oak,
It is a good idea to remove the userqueue_start/end. However, when doing so, I came to the following code in
gfx_v9_0_kiq_init_register():/* enable the doorbell if requested */
if (
ring->use_doorbell) {WREG32_SOC15(GC, 0,
mmCP_MEC_DOORBELL_RANGE_LOWER,(
adev->doorbell_index.kiq* 2) << 2);WREG32_SOC15(GC, 0,
mmCP_MEC_DOORBELL_RANGE_UPPER,(
adev->doorbell_index.userqueue_end* 2) << 2);}
I remember that you reached the conclusion in one email thread that mmCP_MEC_DOORBELL_RANGE_UPPER/LOWER did not have effect at all on gfx9. Have we got any firm conclusions from HW engineer in the end? If those two registers are still valid, we should enforce the range for CP queues.
Regards,
Yong
------------------------------------------------------------------------
*From:*Kuehling, Felix
*Sent:* Friday, February 1, 2019 3:03 PM
*To:* Zhao, Yong; [email protected] <mailto:[email protected]>
*Subject:* Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15Quoted 5 lines · Yong
Reserved doorbells for SDMA IH and VCN were not properly masked out when allocating doorbells for CP user queues. This patch fixed that.
Change-Id I670adfc3fd7725d2ed0bd9665cb7f69f8b9023c2Signed-off-by Yong Zhao <[email protected] <mailto:[email protected]>>One mostly cosmetic comment inline. With that fixed, the series is
Reviewed-by Felix Kuehling <[email protected]<mailto:[email protected]>>
Review
Quoted 11 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 17 ++++++++++---drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h | 4 +++ drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 9 +++++++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 25 +++++++++++++------ .../gpu/drm/amd/include/kgd_kfd_interface.h | 19 +++++--------- 7 files changed, 56 insertions(+), 24 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.cdrivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c void amdgpu_amdkfd_device_init(struct
Quoted 4 lines
index
e957e42c539a..13710f34191a100644drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +0
-0@@ -196,11 +196,20 @@ void amdgpu_amdkfd_device_init(struct
amdgpu_device*adev)Quoted 22 lines
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. +
+ /* Because of the setting in registers like + *SDMA0_DOORBELL_RANGEetc., BIF statically uses the + * lower 12 bits of doorbell address for routing, in + * order to route the CP queue doorbells to CP engine, + * the doorbells allocated to CP queues have to be + * outside the range set for SDMA, VCN, and IH blocks + * Prior to SOC15, all queues use queue ID to + * determine doorbells.
*/
- gpu_resources.reserved_doorbell_mask =0x1e0; - gpu_resources.reserved_doorbell_val =0x0e0; + gpu_resources.reserved_doorbells_start =
+ adev->doorbell_index.sdma_engine[0];
+ gpu_resources.reserved_doorbells_end =
+adev->doorbell_index.last_non_cp;Review
Quoted 3 lines
kgd2kfd_device_init(adev->kfd.dev, &gpu_resources); }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.hQuoted 12 lines
index
1cfec06f81d4..4de431f7f380100644drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +1
-0@@ -71,6 +71,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;drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h typedef enum _AMDGPU_VEGA20_DOORBELL_ASSIGNMENT · line 147
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +1
-0@@ -143,6 +144,7 @@ typedef enum _AMDGPU_VEGA20_DOORBELL_ASSIGNMENT AMDGPU_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,drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h typedef enum _AMDGPU_DOORBELL64_ASSIGNMENT · line 227
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +0
-0AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT = 0x18F,AMDGPU_VEGA20_DOORBELL_INVALID =
0xFFFF}AMDGPU_VEGA20_DOORBELL_ASSIGNMENT;drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +1
-0@@ -222,6 +224,8 @@ typedef enum _AMDGPU_DOORBELL64_ASSIGNMENT AMDGPU_DOORBELL64_VCE_RING4_5 = 0xFE, AMDGPU_DOORBELL64_VCE_RING6_7 = 0xFF, + AMDGPU_DOORBELL64_LAST_NON_CP =
AMDGPU_DOORBELL64_VCE_RING6_7,Review
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +1
-0+ AMDGPU_DOORBELL64_MAX_ASSIGNMENT = 0xFF,AMDGPU_DOORBELL64_INVALID =
0xFFFF}AMDGPU_DOORBELL64_ASSIGNMENT;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/vega10_reg_init.cdrivers/gpu/drm/amd/amdgpu/vega10_reg_init.c void vega10_doorbell_index_init(struct
Quoted 4 lines
index
4b5d60ea3e78..fa0433199215100644drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c +0
-0@@ -81,6 +81,9 @@ void vega10_doorbell_index_init(struct
amdgpu_device*adev)Quoted 1 line
adev->doorbell_index.uvd_vce.vce_ring2_3=
AMDGPU_DOORBELL64_VCE_RING2_3;Quoted 1 line
adev->doorbell_index.uvd_vce.vce_ring4_5=
AMDGPU_DOORBELL64_VCE_RING4_5;Quoted 1 line
adev->doorbell_index.uvd_vce.vce_ring6_7=
AMDGPU_DOORBELL64_VCE_RING6_7;Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c +3
-0+ + 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;Review
Quoted 2 lines
adev->doorbell_index.sdma_doorbell_range= 4;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/vega20_reg_init.cdrivers/gpu/drm/amd/amdgpu/vega20_reg_init.c void vega20_doorbell_index_init(struct
Quoted 4 lines
index
53716c593b2b..b1052caaff5e100644drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +0
-0@@ -85,6 +85,9 @@ void vega20_doorbell_index_init(struct
amdgpu_device*adev)Quoted 1 line
adev->doorbell_index.uvd_vce.vce_ring2_3=
AMDGPU_VEGA20_DOORBELL64_VCE_RING2_3;Quoted 1 line
adev->doorbell_index.uvd_vce.vce_ring4_5=
AMDGPU_VEGA20_DOORBELL64_VCE_RING4_5;Quoted 1 line
adev->doorbell_index.uvd_vce.vce_ring6_7=
AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7;Quoted 2 lines
+
+adev->doorbell_index.last_non_cp=
AMDGPU_VEGA20_DOORBELL64_LAST_NON_CP;Quoted 2 lines
+
adev->doorbell_index.max_assignment=
AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT<< 1;Review
Quoted 3 lines
adev->doorbell_index.sdma_doorbell_range= 20; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_priv.hdrivers/gpu/drm/amd/amdkfd/kfd_priv.h line 107
Quoted 9 lines
index
e5ebcca7f031..6b8459f852cc100644drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2
-0@@ -103,6 +103,15 @@ #define KFD_KERNEL_QUEUE_SIZE 2048 +/* 512 = 0x200 +* On SOC15, the doorbell index distance for SDMA RLC i and (i + 1) in the
drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 109
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2
-0+* same SDMA engine, where i is a even number. +* For 8-bytes doorbells, it ensures that the mirror doorbell range (in terms
drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 110
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1
-0+* of low 12 bit address for each HW engine) on the second doorbell page is
drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 116
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +4
-0+* the same as the range of the first doorbell page.*/ +#define KFD_QUEUE_DOORBELL_MIRROR_OFFSET 512 + + /** Kernel module parameter to specify maximum number of supported queues per
Review
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0
-0* device(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_process.cdrivers/gpu/drm/amd/amdkfd/kfd_process.c static int init_doorbell_bitmap(struct
Quoted 4 lines
index
80b36e860a0a..c7b67c65d62d100644drivers/gpu/drm/amd/amdkfd/kfd_process.c +0
-0@@ -607,13 +607,24 @@ static int init_doorbell_bitmap(struct
qcm_process_device*qpd,drivers/gpu/drm/amd/amdkfd/kfd_process.c static int init_doorbell_bitmap(struct · line 611
Quoted 12 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +2
-7if (!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) { - set_bit(i, qpd->doorbell_bitmap); - pr_debug("reserved doorbell 0x%03x\n", i); - } + /* Mask out all reserved doorbells for SDMA, IH, and VCN on SOC15. +* Because of the setting in registers like
SDMA0_DOORBELL_RANGEetc.,drivers/gpu/drm/amd/amdkfd/kfd_process.c static int init_doorbell_bitmap(struct · line 614
Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +3
-0+ * BIF statically uses the lower 12 bits of doorbell address for + * routing. In order to route the CP queue doorbells to CP engine, + * the doorbells allocated to CP queues have to be outside therange
drivers/gpu/drm/amd/amdkfd/kfd_process.c static int init_doorbell_bitmap(struct · line 619
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +5
-0+* set for SDMA, VCN, and IH blocks. +* Prior to SOC15, all queues use queue ID to +* determine doorbells. */ + i = dev->shared_resources.reserved_doorbells_start; + while (i <= dev->shared_resources.reserved_doorbells_end) {This should be a for-loop to be more obvious:
for (i =
dev->shared_resources.reserved_doorbells_start; i <=dev->shared_resources.reserved_doorbells_end; i++) {
...
}Review
Quoted 12 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +8
-0+ set_bit(i, qpd->doorbell_bitmap); + 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); + + i++; + } return 0; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/include/kgd_kfd_interface.hQuoted 7 lines
index
83d960110d23..b1bf45419d93100644drivers/gpu/drm/amd/include/kgd_kfd_interface.h +0
-0@@ -137,20 +137,13 @@ struct kgd2kfd_shared_resources { /* Bit n == 1 means Queue n is available for KFD */ DECLARE_BITMAP(queue_bitmap, KGD_MAX_QUEUES);
Quoted 25 lines
drivers/gpu/drm/amd/include/kgd_kfd_interface.h struct kgd2kfd_shared_resources { · line 145
Quoted 6 lines
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +0
-6- /* 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_valQuoted 17 lines
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +6
-7-* -* 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 onwards, the doorbell indexes reserved for SDMA, IH, + * and VCN + */ + unsigned int reserved_doorbells_start; + unsigned int reserved_doorbells_end; /* Base address of doorbell aperture. */ phys_addr_t doorbell_physical_address;
_______________________________________________
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): 5aca7b73-2ef6-8a33-4a1c-3f876459de40-5C7GfCeVMHo@public.gmane.org
RE: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
Correct. MEC_DOORBELL_RANGE should cover both user and kernel CP (KIQ/HIQ/DIQ/amdgpu kernel MEC rings)queues. USERQUEUE_START/END should be renamed to USER_CP_QUEUE_START/END.
Thanks,
Oak
-----Original Message-----
From: Kuehling, Felix
Sent: Monday, February 4, 2019 11:35 AM
To: Zeng, Oak <[email protected]>; Zhao, Yong <[email protected]>; [email protected]
Subject: Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
I don't see anything about userqueue start/end in Yong's patch. That said, I think you're mixing up two different things. MEC_DOORBELL_RANGE is not the same as userqueues? We have MEC kernel queues as well that would have to fall in the same range. And we have SDMA user queues that don't belong in the MEC doorbell range. Therefore I think the name USERQUEUE_START/END is misleading.
Regards,
Felix
Quoted 299 lines · Oak
Hi Yong,
mmCP_MEC_DOORBELL_RANGE_LOWER/UPPER are used at CP to double check a doorbell ringing routed to CP. It is a must to program. We have to keep userqueue_start/end. Sorry for the confusion.
Regards,
Oak
*From:* amd-gfx <[email protected]> *On Behalf Of *Zhao, Yong
*Sent:* Friday, February 1, 2019 7:04 PM
*To:* Kuehling, Felix <[email protected]>; [email protected]; Zeng, Oak <[email protected]> *Subject:* Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15Oak,
It is a good idea to remove the userqueue_start/end. However, when doing so, I came to the following code in
gfx_v9_0_kiq_init_register():/* enable the doorbell if requested */
if (
ring->use_doorbell) {WREG32_SOC15(GC, 0,
mmCP_MEC_DOORBELL_RANGE_LOWER,(
adev->doorbell_index.kiq* 2) << 2);WREG32_SOC15(GC, 0,
mmCP_MEC_DOORBELL_RANGE_UPPER,(
adev->doorbell_index.userqueue_end* 2) << 2);}
I remember that you reached the conclusion in one email thread that mmCP_MEC_DOORBELL_RANGE_UPPER/LOWER did not have effect at all on gfx9. Have we got any firm conclusions from HW engineer in the end? If those two registers are still valid, we should enforce the range for CP queues.
Regards,
Yong
----------------------------------------------------------------------
--*From:*Kuehling, Felix
*Sent:* Friday, February 1, 2019 3:03 PM
*To:* Zhao, Yong; [email protected] <mailto:[email protected]>
*Subject:* Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15Quoted 6 lines · Yong
Reserved doorbells for SDMA IH and VCN were not properly masked out when allocating doorbells for CP user queues. This patch fixed that.
Change-Id I670adfc3fd7725d2ed0bd9665cb7f69f8b9023c2Signed-off-by Yong Zhao <[email protected]<mailto:[email protected]>>
One mostly cosmetic comment inline. With that fixed, the series is
Reviewed-by Felix Kuehling <[email protected]<mailto:[email protected]>>
Quoted 5 lines
---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 17 ++++++++++---drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h | 4 +++ drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c | 3 +++Review
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 9 +++++++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 25
+++++++++++++------
.../gpu/drm/amd/include/kgd_kfd_interface.h | 19 +++++---------7 files changed, 56 insertions(+), 24 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.cdrivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c void amdgpu_amdkfd_device_init(struct
Quoted 4 lines
index
e957e42c539a..13710f34191a100644drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +0
-0@@ -196,11 +196,20 @@ void amdgpu_amdkfd_device_init(struct
amdgpu_device*adev)Quoted 22 lines
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. +
+ /* Because of the setting in registers like + *SDMA0_DOORBELL_RANGEetc., BIF statically uses the + * lower 12 bits of doorbell address for routing, in + * order to route the CP queue doorbells to CP engine, + * the doorbells allocated to CP queues have to be + * outside the range set for SDMA, VCN, and IH blocks + * Prior to SOC15, all queues use queue ID to + * determine doorbells.
*/
- gpu_resources.reserved_doorbell_mask =0x1e0; - gpu_resources.reserved_doorbell_val =0x0e0; + gpu_resources.reserved_doorbells_start =
+ adev->doorbell_index.sdma_engine[0];
+ gpu_resources.reserved_doorbells_end =
+adev->doorbell_index.last_non_cp;Review
Quoted 3 lines
kgd2kfd_device_init(adev->kfd.dev, &gpu_resources); }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.hQuoted 10 lines
index
1cfec06f81d4..4de431f7f380100644drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +1
-0@@ -71,6 +71,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 */Quoted 6 lines
uint32_tsdma_doorbell_range; @@ -143,6 +144,7 @@ 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,drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h typedef enum _AMDGPU_DOORBELL64_ASSIGNMENT · line 227
Quoted 8 lines
AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT =
0x18F, AMDGPU_VEGA20_DOORBELL_INVALID =0xFFFF}AMDGPU_VEGA20_DOORBELL_ASSIGNMENT;drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +1
-0@@ -222,6 +224,8 @@ typedef enum _AMDGPU_DOORBELL64_ASSIGNMENT AMDGPU_DOORBELL64_VCE_RING4_5 = 0xFE, AMDGPU_DOORBELL64_VCE_RING6_7 = 0xFF, + AMDGPU_DOORBELL64_LAST_NON_CP =
AMDGPU_DOORBELL64_VCE_RING6_7,Review
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +1
-0+ AMDGPU_DOORBELL64_MAX_ASSIGNMENT = 0xFF,AMDGPU_DOORBELL64_INVALID =
0xFFFF}AMDGPU_DOORBELL64_ASSIGNMENT;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/vega10_reg_init.cdrivers/gpu/drm/amd/amdgpu/vega10_reg_init.c void vega10_doorbell_index_init(struct
Quoted 4 lines
index
4b5d60ea3e78..fa0433199215100644drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c +0
-0@@ -81,6 +81,9 @@ void vega10_doorbell_index_init(struct
amdgpu_device*adev)Quoted 1 line
adev->doorbell_index.uvd_vce.vce_ring2_3=
AMDGPU_DOORBELL64_VCE_RING2_3;Quoted 1 line
adev->doorbell_index.uvd_vce.vce_ring4_5=
AMDGPU_DOORBELL64_VCE_RING4_5;Quoted 1 line
adev->doorbell_index.uvd_vce.vce_ring6_7=
AMDGPU_DOORBELL64_VCE_RING6_7;Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c +4
-0+ + 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;Quoted 2 lines
adev->doorbell_index.sdma_doorbell_range= 4; diff --gita/drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c
b/drivers/gpu/drm/amd/amdgpu/vega20_reg_init.cdrivers/gpu/drm/amd/amdgpu/vega20_reg_init.c void vega20_doorbell_index_init(struct
Quoted 4 lines
index
53716c593b2b..b1052caaff5e100644drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +0
-0@@ -85,6 +85,9 @@ void vega20_doorbell_index_init(struct
amdgpu_device*adev)Quoted 1 line
adev->doorbell_index.uvd_vce.vce_ring2_3=
AMDGPU_VEGA20_DOORBELL64_VCE_RING2_3;Quoted 1 line
adev->doorbell_index.uvd_vce.vce_ring4_5=
AMDGPU_VEGA20_DOORBELL64_VCE_RING4_5;Quoted 1 line
adev->doorbell_index.uvd_vce.vce_ring6_7=
AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7;Quoted 2 lines
+
+adev->doorbell_index.last_non_cp=
AMDGPU_VEGA20_DOORBELL64_LAST_NON_CP;Quoted 2 lines
+
adev->doorbell_index.max_assignment=
AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT<< 1;Review
Quoted 3 lines
adev->doorbell_index.sdma_doorbell_range= 20; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_priv.hdrivers/gpu/drm/amd/amdkfd/kfd_priv.h line 107
Quoted 9 lines
index
e5ebcca7f031..6b8459f852cc100644drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2
-0@@ -103,6 +103,15 @@ #define KFD_KERNEL_QUEUE_SIZE 2048 +/* 512 = 0x200 +* On SOC15, the doorbell index distance for SDMA RLC i and (i + 1) in the
drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 109
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2
-0+* same SDMA engine, where i is a even number. +* For 8-bytes doorbells, it ensures that the mirror doorbell range (in terms
drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 110
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1
-0+* of low 12 bit address for each HW engine) on the second doorbell page is
drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 116
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +4
-0+* the same as the range of the first doorbell page.*/ #define +KFD_QUEUE_DOORBELL_MIRROR_OFFSET 512 + + /** Kernel module parameter to specify maximum number of supported queues per
Review
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0
-0* device(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_process.cdrivers/gpu/drm/amd/amdkfd/kfd_process.c static int init_doorbell_bitmap(struct
Quoted 4 lines
index
80b36e860a0a..c7b67c65d62d100644drivers/gpu/drm/amd/amdkfd/kfd_process.c +0
-0@@ -607,13 +607,24 @@ static int init_doorbell_bitmap(struct
qcm_process_device*qpd,Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +0
-3if (!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)Quoted 7 lines
==
-dev->shared_resources.reserved_doorbell_val) {
-set_bit(i, qpd->doorbell_bitmap);
-pr_debug("reserved doorbell 0x%03x\n", i); - }
+ /* Mask out all reserved doorbells for SDMA, IH, and VCN on SOC15. + * Because of the setting in registers like
SDMA0_DOORBELL_RANGEetc.,drivers/gpu/drm/amd/amdkfd/kfd_process.c
Quoted 5 lines
+ * BIF statically uses the lower 12 bits of doorbell address
drivers/gpu/drm/amd/amdkfd/kfd_process.c +4
-0+for + * routing. In order to route the CP queue doorbells to CP +engine, + * the doorbells allocated to CP queues have to be outside therange
Quoted 5 lines
+ * set for SDMA, VCN, and IH blocks.
+ * Prior to SOC15, all queues use queue ID to
+ * determine doorbells. */
+ i =dev->shared_resources.reserved_doorbells_start; + while (i <=dev->shared_resources.reserved_doorbells_end) {This should be a for-loop to be more obvious:
for (i =
dev->shared_resources.reserved_doorbells_start; i <=dev->shared_resources.reserved_doorbells_end; i++) {
...
}Quoted 9 lines
+
set_bit(i, qpd->doorbell_bitmap);
+ 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); +
+ i++;
+ }Review
Quoted 3 lines
return 0;
}(quoted diff) +0
-0
b/drivers/gpu/drm/amd/include/kgd_kfd_interface.hQuoted 12 lines
index
83d960110d23..b1bf45419d93100644drivers/gpu/drm/amd/include/kgd_kfd_interface.h +0
-5@@ -137,20 +137,13 @@ 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 -* 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 Quoted 2 lines
condition
- * is reserved: (D &reserved_doorbell_mask) ==
reserved_doorbell_valQuoted 17 lines
- *
- * KFD currently uses 1024 (=0x3ff) doorbells per process. If - * doorbells 0x0e0-0x0ff and 0x2e0-0x2ff are reserved, that means
- * mask would be set to0x1e0and val set to0x0e0. - */
unsigned int sdma_doorbell[2][8];
- unsigned intreserved_doorbell_mask;
- unsigned intreserved_doorbell_val;drivers/gpu/drm/amd/include/kgd_kfd_interface.h +7
-0+ + /* From SOC15 onwards, the doorbell indexes reserved for SDMA, +IH, + * and VCN + */ + unsigned int reserved_doorbells_start; + unsigned int reserved_doorbells_end;
Quoted 3 lines
Quoted 2 lines
/* Base address of doorbell aperture. */
phys_addr_tdoorbell_physical_address;
_______________________________________________
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): BL0PR12MB258041F4A571AE1356CA31B8806D0-b4cIHhjg/p/[email protected]
Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
The decision we need to make here is which value we should program mmCP_MEC_DOORBELL_RANGE_UPPER. It is not very consistent right now throughout our code. If we let CP to use all the doorbells left over by SDMA, IH and VCN, then we should probably use 1024 for mmCP_MEC_DOORBELL_RANGE_UPPER. If we continue to use adev->doorbell_index.userqueue_end * 2, as is currently in the code, we should limit the CP doorbells in the range of 0 to adev->doorbell_index.userqueue_end * 2 when allocating CP user queue doorbells.
It seems to me that either way would work.
Regards,
Yong
________________________________
From: Zeng, Oak
Sent: Monday, February 4, 2019 12:15 PM
To: Kuehling, Felix; Zhao, Yong; [email protected]
Subject: RE: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
Correct. MEC_DOORBELL_RANGE should cover both user and kernel CP (KIQ/HIQ/DIQ/amdgpu kernel MEC rings)queues. USERQUEUE_START/END should be renamed to USER_CP_QUEUE_START/END.
Thanks,
Oak
-----Original Message-----
From: Kuehling, Felix
Sent: Monday, February 4, 2019 11:35 AM
To: Zeng, Oak <[email protected]>; Zhao, Yong <[email protected]>; [email protected]
Subject: Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
I don't see anything about userqueue start/end in Yong's patch. That said, I think you're mixing up two different things. MEC_DOORBELL_RANGE is not the same as userqueues? We have MEC kernel queues as well that would have to fall in the same range. And we have SDMA user queues that don't belong in the MEC doorbell range. Therefore I think the name USERQUEUE_START/END is misleading.
Regards,
Felix
Quoted 299 lines · Oak
Hi Yong,
mmCP_MEC_DOORBELL_RANGE_LOWER/UPPER are used at CP to double check a doorbell ringing routed to CP. It is a must to program. We have to keep userqueue_start/end. Sorry for the confusion.
Regards,
Oak
*From:* amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> *On Behalf Of *Zhao, Yong
*Sent:* Friday, February 1, 2019 7:04 PM
*To:* Kuehling, Felix <[email protected]>; [email protected]; Zeng, Oak <[email protected]> *Subject:* Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user
queue doorbells mask on SOC15Oak,
It is a good idea to remove the userqueue_start/end. However, when doing so, I came to the following code in
gfx_v9_0_kiq_init_register():/* enable the doorbell if requested */ if (ring->use_doorbell) {WREG32_SOC15(GC, 0,
mmCP_MEC_DOORBELL_RANGE_LOWER,(adev->doorbell_index.kiq * 2) << 2);WREG32_SOC15(GC, 0,
mmCP_MEC_DOORBELL_RANGE_UPPER,(
adev->doorbell_index.userqueue_end* 2) << 2);}I remember that you reached the conclusion in one email thread that mmCP_MEC_DOORBELL_RANGE_UPPER/LOWER did not have effect at all on gfx9. Have we got any firm conclusions from HW engineer in the end? If those two registers are still valid, we should enforce the range for CP queues.
Regards,
Yong
----------------------------------------------------------------------
--*From:*Kuehling, Felix
*Sent:* Friday, February 1, 2019 3:03 PM
*To:* Zhao, Yong; [email protected] <mailto:[email protected]> *Subject:* Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15Quoted 6 lines · Yong
Reserved doorbells for SDMA IH and VCN were not properly masked out when allocating doorbells for CP user queues. This patch fixed that.
Change-Id I670adfc3fd7725d2ed0bd9665cb7f69f8b9023c2Signed-off-by Yong Zhao <[email protected]<mailto:[email protected]>>
One mostly cosmetic comment inline. With that fixed, the series is
Reviewed-by Felix Kuehling <[email protected]<mailto:[email protected]>>
Quoted 11 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 17 ++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h | 4 +++ drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 9 +++++++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 25 +++++++++++++------ .../gpu/drm/amd/include/kgd_kfd_interface.h | 19 +++++--------- 7 files changed, 56 insertions(+), 24 deletions(-)Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.cdrivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c void amdgpu_amdkfd_device_init(struct
Quoted 4 lines
index
e957e42c539a..13710f34191a100644drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +0
-0@@ -196,11 +196,20 @@ void amdgpu_amdkfd_device_init(struct
amdgpu_device*adev)Review
Quoted 25 lines
gpu_resources.sdma_doorbell[1][i+1] =
adev->doorbell_index.sdma_engine[1] + 0x200 + (i >> 1); }drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +13
-4-/* Doorbells 0x0e0-0ff and 0x2e0-2ff are reserved for -* SDMA, IH and VCN. So don't use them for the CP. + +/* Because of the setting in registers like +* SDMA0_DOORBELL_RANGE etc., BIF statically uses the +* lower 12 bits of doorbell address for routing, in +* order to route the CP queue doorbells to CP engine, +* the doorbells allocated to CP queues have to be +* outside the range set for SDMA, VCN, and IH blocks +* Prior to SOC15, all queues use queue ID to +* determine doorbells. */ - gpu_resources.reserved_doorbell_mask =0x1e0 ; - gpu_resources.reserved_doorbell_val =0x0e0 ; + gpu_resources.reserved_doorbells_start = + adev->doorbell_index.sdma_engine[0 ]; + gpu_resources.reserved_doorbells_end = + adev->doorbell_index.last_non_cp;kgd2kfd_device_init (adev->kfd.dev, &gpu_resources); }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.hQuoted 12 lines
index
1cfec06f81d4..4de431f7f380100644drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +1
-0@@ -71,6 +71,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; @@ -143,6 +144,7 @@ typedefenum
_AMDGPU_VEGA20_DOORBELL_ASSIGNMENTQuoted 4 lines
AMDGPU_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,drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h typedef enum _AMDGPU_DOORBELL64_ASSIGNMENT · line 227
Quoted 8 lines
AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT=0x18F,AMDGPU_VEGA20_DOORBELL_INVALID=0xFFFF
}AMDGPU_VEGA20_DOORBELL_ASSIGNMENT;drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +1
-0@@ -222,6 +224,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,Review
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +1
-0+AMDGPU_DOORBELL64_MAX_ASSIGNMENT =0xFF , AMDGPU_DOORBELL64_INVALID = 0xFFFF }AMDGPU_DOORBELL64_ASSIGNMENT ;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/vega10_reg_init.cdrivers/gpu/drm/amd/amdgpu/vega10_reg_init.c void vega10_doorbell_index_init(struct
Quoted 4 lines
index
4b5d60ea3e78..fa0433199215100644drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c +0
-0@@ -81,6 +81,9 @@ void vega10_doorbell_index_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c void vega10_doorbell_index_init(struct · line 81
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c +0
-0adev->doorbell_index.uvd_vce.vce_ring2_3 =
AMDGPU_DOORBELL64_VCE_RING2_3;drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c void vega10_doorbell_index_init(struct · line 82
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c +0
-0adev->doorbell_index.uvd_vce.vce_ring4_5 =
AMDGPU_DOORBELL64_VCE_RING4_5;drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c void vega10_doorbell_index_init(struct · line 83
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c +0
-0adev->doorbell_index.uvd_vce.vce_ring6_7 =
AMDGPU_DOORBELL64_VCE_RING6_7;drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c void vega10_doorbell_index_init(struct · line 89
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c +4
-0+ + 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;Quoted 2 lines
adev->doorbell_index.sdma_doorbell_range = 4; diff --git
a/drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c
b/drivers/gpu/drm/amd/amdgpu/vega20_reg_init.cdrivers/gpu/drm/amd/amdgpu/vega20_reg_init.c void vega20_doorbell_index_init(struct
Quoted 4 lines
index
53716c593b2b..b1052caaff5e100644drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +0
-0@@ -85,6 +85,9 @@ void vega20_doorbell_index_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c void vega20_doorbell_index_init(struct · line 85
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +0
-0adev->doorbell_index.uvd_vce.vce_ring2_3 =
AMDGPU_VEGA20_DOORBELL64_VCE_RING2_3;drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c void vega20_doorbell_index_init(struct · line 86
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +0
-0adev->doorbell_index.uvd_vce.vce_ring4_5 =
AMDGPU_VEGA20_DOORBELL64_VCE_RING4_5;drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c void vega20_doorbell_index_init(struct · line 87
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +0
-0adev->doorbell_index.uvd_vce.vce_ring6_7 =
AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7;drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c void vega20_doorbell_index_init(struct · line 89
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +2
-0+ + adev->doorbell_index.last_non_cp =
AMDGPU_VEGA20_DOORBELL64_LAST_NON_CP;drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c void vega20_doorbell_index_init(struct · line 91
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +1
-0+ adev->doorbell_index.max_assignment =
AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT<< 1;Review
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +0
-0adev->doorbell_index.sdma_doorbell_range =20 ; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_priv.hdrivers/gpu/drm/amd/amdkfd/kfd_priv.h line 107
Quoted 9 lines
index
e5ebcca7f031..6b8459f852cc100644drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2
-0@@ -103,6 +103,15 @@#define KFD_KERNEL_QUEUE_SIZE 2048 +/* 512 = 0x200 +* On SOC15, the doorbell index distance for SDMA RLC i and (i + 1) in the
drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 109
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2
-0+* same SDMA engine, where i is a even number. +* For 8-bytes doorbells, it ensures that the mirror doorbell range (in terms
drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 110
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1
-0+* of low 12 bit address for each HW engine) on the second doorbell page is
drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 116
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +4
-0+* the same as the range of the first doorbell page.*/ #define +KFD_QUEUE_DOORBELL_MIRROR_OFFSET 512 + +/* * Kernel module parameter to specify maximum number of supported queues per
Review
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0
-0* device (quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_process.cdrivers/gpu/drm/amd/amdkfd/kfd_process.c static int init_doorbell_bitmap(struct
Quoted 4 lines
index
80b36e860a0a..c7b67c65d62d100644drivers/gpu/drm/amd/amdkfd/kfd_process.c +0
-0@@ -607,13 +607,24 @@ static int init_doorbell_bitmap(struct
qcm_process_device*qpd,drivers/gpu/drm/amd/amdkfd/kfd_process.c
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +0
-3if (!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) {drivers/gpu/drm/amd/amdkfd/kfd_process.c +2
-3-set_bit (i, qpd->doorbell_bitmap); -pr_debug ("reserved doorbell 0x%03x\n" , i); - } +/* Mask out all reserved doorbells for SDMA, IH, and VCN on SOC15. +* Because of the setting in registers like
SDMA0_DOORBELL_RANGEetc.,drivers/gpu/drm/amd/amdkfd/kfd_process.c
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +5
-0+ * BIF statically uses the lower 12 bits of doorbell address +for + * routing. In order to route the CP queue doorbells to CP +engine, + * the doorbells allocated to CP queues have to be outside therange
drivers/gpu/drm/amd/amdkfd/kfd_process.c
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +5
-0+* set for SDMA, VCN, and IH blocks. +* Prior to SOC15, all queues use queue ID to +* determine doorbells. */ + i = dev->shared_resources.reserved_doorbells_start; +while (i <= dev->shared_resources.reserved_doorbells_end) {This should be a for-loop to be more obvious:
for (i = dev->shared_resources.reserved_doorbells_start; i <= dev->shared_resources.reserved_doorbells_end; i++) { ... }Review
Quoted 12 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +8
-0+set_bit (i, qpd->doorbell_bitmap); +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 ); + + i++; + }return 0 ; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/include/kgd_kfd_interface.hQuoted 12 lines
index
83d960110d23..b1bf45419d93100644drivers/gpu/drm/amd/include/kgd_kfd_interface.h +0
-5@@ -137,20 +137,13 @@ 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 -* 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 Quoted 2 lines
condition
- * is reserved: (D &reserved_doorbell_mask) ==
reserved_doorbell_valQuoted 17 lines
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +0
-3-* -* KFD currently uses 1024 (= 0x3ff) doorbells per process. If -* doorbells 0x0e0-0x0ff and 0x2e0-0x2ff are reserved, that means
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +7
-4-* 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 onwards, the doorbell indexes reserved for SDMA, +IH, +* and VCN +*/ +unsigned int reserved_doorbells_start; +unsigned int reserved_doorbells_end;
Quoted 3 lines
Quoted 2 lines
/* Base address of doorbell aperture. */ phys_addr_t doorbell_physical_address;
_______________________________________________
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): SN1PR12MB236591C1FC2D9D965C4DA304F06D0-z7L1TMIYDg7+b/[email protected]
RE: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
Quoted 1 line
then we should probably use 1024 for
mmCP_MEC_DOORBELL_RANGE_UPPER.
This is also what I thought.
Thanks,
Oak
From: Zhao, Yong
Sent: Monday, February 4, 2019 12:28 PM
To: Zeng, Oak <[email protected]>; Kuehling, Felix <[email protected]>; [email protected]
Subject: Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
The decision we need to make here is which value we should program mmCP_MEC_DOORBELL_RANGE_UPPER. It is not very consistent right now throughout our code. If we let CP to use all the doorbells left over by SDMA, IH and VCN, then we should probably use 1024 for mmCP_MEC_DOORBELL_RANGE_UPPER. If we continue to use adev->doorbell_index.userqueue_end * 2, as is currently in the code, we should limit the CP doorbells in the range of 0 to adev->doorbell_index.userqueue_end * 2 when allocating CP user queue doorbells.
It seems to me that either way would work.
Regards,
Yong
________________________________
From: Zeng, Oak
Sent: Monday, February 4, 2019 12:15 PM
To: Kuehling, Felix; Zhao, Yong; [email protected]<mailto:[email protected]>
Subject: RE: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
Correct. MEC_DOORBELL_RANGE should cover both user and kernel CP (KIQ/HIQ/DIQ/amdgpu kernel MEC rings)queues. USERQUEUE_START/END should be renamed to USER_CP_QUEUE_START/END.
Thanks,
Oak
-----Original Message-----
From: Kuehling, Felix
Sent: Monday, February 4, 2019 11:35 AM
To: Zeng, Oak <[email protected]<mailto:[email protected]>>; Zhao, Yong <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>
Subject: Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user queue doorbells mask on SOC15
I don't see anything about userqueue start/end in Yong's patch. That said, I think you're mixing up two different things. MEC_DOORBELL_RANGE is not the same as userqueues? We have MEC kernel queues as well that would have to fall in the same range. And we have SDMA user queues that don't belong in the MEC doorbell range. Therefore I think the name USERQUEUE_START/END is misleading.
Regards,
Felix
Quoted 51 lines · Oak
Hi Yong,
mmCP_MEC_DOORBELL_RANGE_LOWER/UPPER are used at CP to double check a doorbell ringing routed to CP. It is a must to program. We have to keep userqueue_start/end. Sorry for the confusion.
Regards,
Oak
*From:* amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org<mailto:amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>> *On Behalf Of
*Zhao, Yong
*Sent:* Friday, February 1, 2019 7:04 PM
*To:* Kuehling, Felix <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>; Zeng, Oak <[email protected]<mailto:[email protected]>> *Subject:* Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user
queue doorbells mask on SOC15Oak,
It is a good idea to remove the userqueue_start/end. However, when doing so, I came to the following code in
gfx_v9_0_kiq_init_register():/* enable the doorbell if requested */ if (ring->use_doorbell) {WREG32_SOC15(GC, 0,
mmCP_MEC_DOORBELL_RANGE_LOWER,(adev->doorbell_index.kiq * 2) << 2);WREG32_SOC15(GC, 0,
mmCP_MEC_DOORBELL_RANGE_UPPER,(
adev->doorbell_index.userqueue_end* 2) << 2);}I remember that you reached the conclusion in one email thread that mmCP_MEC_DOORBELL_RANGE_UPPER/LOWER did not have effect at all on gfx9. Have we got any firm conclusions from HW engineer in the end? If those two registers are still valid, we should enforce the range for CP queues.
Regards,
Yong
----------------------------------------------------------------------
--
Quoted 13 lines
*From:*Kuehling, Felix
*Sent:* Friday, February 1, 2019 3:03 PM
*To:* Zhao, Yong; [email protected]<mailto:[email protected]> <mailto:[email protected]>
*Subject:* Re: [PATCH 2/3] drm/amdkfd: Fix bugs regarding CP user
queue doorbells mask on SOC15Quoted 5 lines · Yong
Reserved doorbells for SDMA IH and VCN were not properly masked out when allocating doorbells for CP user queues. This patch fixed that.
Change-Id I670adfc3fd7725d2ed0bd9665cb7f69f8b9023c2Signed-off-by Yong Zhao <[email protected]
<mailto:[email protected]%20%0b>> > <mailto:[email protected]>>
Quoted 3 lines
One mostly cosmetic comment inline. With that fixed, the series is
Reviewed-by Felix Kuehling <[email protected]
<mailto:[email protected]%20%0b>> <mailto:[email protected]>>
Quoted 230 lines
Quoted 13 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 17 ++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h | 4 +++ drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c | 3 +++ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 9 +++++++ drivers/gpu/drm/amd/amdkfd/kfd_process.c | 25 +++++++++++++------ .../gpu/drm/amd/include/kgd_kfd_interface.h | 19 +++++--------- 7 files changed, 56 insertions(+), 24 deletions(-)Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.cdrivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c void amdgpu_amdkfd_device_init(struct
Quoted 4 lines
index
e957e42c539a..13710f34191a100644drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +0
-0@@ -196,11 +196,20 @@ void amdgpu_amdkfd_device_init(struct
amdgpu_device*adev)Review
Quoted 25 lines
gpu_resources.sdma_doorbell[1][i+1] =
adev->doorbell_index.sdma_engine[1] + 0x200 + (i >> 1); }drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +13
-4-/* Doorbells 0x0e0-0ff and 0x2e0-2ff are reserved for -* SDMA, IH and VCN. So don't use them for the CP. + +/* Because of the setting in registers like +* SDMA0_DOORBELL_RANGE etc., BIF statically uses the +* lower 12 bits of doorbell address for routing, in +* order to route the CP queue doorbells to CP engine, +* the doorbells allocated to CP queues have to be +* outside the range set for SDMA, VCN, and IH blocks +* Prior to SOC15, all queues use queue ID to +* determine doorbells. */ - gpu_resources.reserved_doorbell_mask =0x1e0 ; - gpu_resources.reserved_doorbell_val =0x0e0 ; + gpu_resources.reserved_doorbells_start = + adev->doorbell_index.sdma_engine[0 ]; + gpu_resources.reserved_doorbells_end = + adev->doorbell_index.last_non_cp;kgd2kfd_device_init (adev->kfd.dev, &gpu_resources); }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.hQuoted 12 lines
index
1cfec06f81d4..4de431f7f380100644drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +1
-0@@ -71,6 +71,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; @@ -143,6 +144,7 @@ typedefenum
_AMDGPU_VEGA20_DOORBELL_ASSIGNMENTQuoted 4 lines
AMDGPU_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,drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h typedef enum _AMDGPU_DOORBELL64_ASSIGNMENT · line 227
Quoted 8 lines
AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT=0x18F,AMDGPU_VEGA20_DOORBELL_INVALID=0xFFFF
}AMDGPU_VEGA20_DOORBELL_ASSIGNMENT;drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +1
-0@@ -222,6 +224,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,Review
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_doorbell.h +1
-0+AMDGPU_DOORBELL64_MAX_ASSIGNMENT =0xFF , AMDGPU_DOORBELL64_INVALID = 0xFFFF }AMDGPU_DOORBELL64_ASSIGNMENT ;(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/vega10_reg_init.cdrivers/gpu/drm/amd/amdgpu/vega10_reg_init.c void vega10_doorbell_index_init(struct
Quoted 4 lines
index
4b5d60ea3e78..fa0433199215100644drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c +0
-0@@ -81,6 +81,9 @@ void vega10_doorbell_index_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c void vega10_doorbell_index_init(struct · line 81
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c +0
-0adev->doorbell_index.uvd_vce.vce_ring2_3 =
AMDGPU_DOORBELL64_VCE_RING2_3;drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c void vega10_doorbell_index_init(struct · line 82
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c +0
-0adev->doorbell_index.uvd_vce.vce_ring4_5 =
AMDGPU_DOORBELL64_VCE_RING4_5;drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c void vega10_doorbell_index_init(struct · line 83
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c +0
-0adev->doorbell_index.uvd_vce.vce_ring6_7 =
AMDGPU_DOORBELL64_VCE_RING6_7;drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c void vega10_doorbell_index_init(struct · line 89
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/vega10_reg_init.c +4
-0+ + 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;Quoted 2 lines
adev->doorbell_index.sdma_doorbell_range = 4; diff --git
a/drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c
b/drivers/gpu/drm/amd/amdgpu/vega20_reg_init.cdrivers/gpu/drm/amd/amdgpu/vega20_reg_init.c void vega20_doorbell_index_init(struct
Quoted 4 lines
index
53716c593b2b..b1052caaff5e100644drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +0
-0@@ -85,6 +85,9 @@ void vega20_doorbell_index_init(struct
amdgpu_device*adev)drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c void vega20_doorbell_index_init(struct · line 85
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +0
-0adev->doorbell_index.uvd_vce.vce_ring2_3 =
AMDGPU_VEGA20_DOORBELL64_VCE_RING2_3;drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c void vega20_doorbell_index_init(struct · line 86
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +0
-0adev->doorbell_index.uvd_vce.vce_ring4_5 =
AMDGPU_VEGA20_DOORBELL64_VCE_RING4_5;drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c void vega20_doorbell_index_init(struct · line 87
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +0
-0adev->doorbell_index.uvd_vce.vce_ring6_7 =
AMDGPU_VEGA20_DOORBELL64_VCE_RING6_7;drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c void vega20_doorbell_index_init(struct · line 89
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +2
-0+ + adev->doorbell_index.last_non_cp =
AMDGPU_VEGA20_DOORBELL64_LAST_NON_CP;drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c void vega20_doorbell_index_init(struct · line 91
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +1
-0+ adev->doorbell_index.max_assignment =
AMDGPU_VEGA20_DOORBELL_MAX_ASSIGNMENT<< 1;Review
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/vega20_reg_init.c +0
-0adev->doorbell_index.sdma_doorbell_range =20 ; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_priv.hdrivers/gpu/drm/amd/amdkfd/kfd_priv.h line 107
Quoted 9 lines
index
e5ebcca7f031..6b8459f852cc100644drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2
-0@@ -103,6 +103,15 @@#define KFD_KERNEL_QUEUE_SIZE 2048 +/* 512 = 0x200 +* On SOC15, the doorbell index distance for SDMA RLC i and (i + 1) in the
drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 109
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2
-0+* same SDMA engine, where i is a even number. +* For 8-bytes doorbells, it ensures that the mirror doorbell range (in terms
drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 110
Quoted 1 line
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +1
-0+* of low 12 bit address for each HW engine) on the second doorbell page is
drivers/gpu/drm/amd/amdkfd/kfd_priv.h line 116
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +4
-0+* the same as the range of the first doorbell page.*/ #define +KFD_QUEUE_DOORBELL_MIRROR_OFFSET 512 + +/* * Kernel module parameter to specify maximum number of supported queues per
Review
Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +0
-0* device (quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdkfd/kfd_process.cdrivers/gpu/drm/amd/amdkfd/kfd_process.c static int init_doorbell_bitmap(struct
Quoted 4 lines
index
80b36e860a0a..c7b67c65d62d100644drivers/gpu/drm/amd/amdkfd/kfd_process.c +0
-0@@ -607,13 +607,24 @@ static int init_doorbell_bitmap(struct
qcm_process_device*qpd,drivers/gpu/drm/amd/amdkfd/kfd_process.c
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +0
-3if (!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) {drivers/gpu/drm/amd/amdkfd/kfd_process.c +2
-3-set_bit (i, qpd->doorbell_bitmap); -pr_debug ("reserved doorbell 0x%03x\n" , i); - } +/* Mask out all reserved doorbells for SDMA, IH, and VCN on SOC15. +* Because of the setting in registers like
SDMA0_DOORBELL_RANGEetc.,drivers/gpu/drm/amd/amdkfd/kfd_process.c
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +5
-0+ * BIF statically uses the lower 12 bits of doorbell address +for + * routing. In order to route the CP queue doorbells to CP +engine, + * the doorbells allocated to CP queues have to be outside therange
drivers/gpu/drm/amd/amdkfd/kfd_process.c
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +5
-0+* set for SDMA, VCN, and IH blocks. +* Prior to SOC15, all queues use queue ID to +* determine doorbells. */ + i = dev->shared_resources.reserved_doorbells_start; +while (i <= dev->shared_resources.reserved_doorbells_end) {This should be a for-loop to be more obvious:
for (i = dev->shared_resources.reserved_doorbells_start; i <= dev->shared_resources.reserved_doorbells_end; i++) { ... }Review
Quoted 12 lines
drivers/gpu/drm/amd/amdkfd/kfd_process.c +8
-0+set_bit (i, qpd->doorbell_bitmap); +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 ); + + i++; + }return 0 ; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/include/kgd_kfd_interface.hQuoted 12 lines
index
83d960110d23..b1bf45419d93100644drivers/gpu/drm/amd/include/kgd_kfd_interface.h +0
-5@@ -137,20 +137,13 @@ 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 -* 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 Quoted 2 lines
condition
- * is reserved: (D &reserved_doorbell_mask) ==
reserved_doorbell_valQuoted 17 lines
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +0
-3-* -* KFD currently uses 1024 (= 0x3ff) doorbells per process. If -* doorbells 0x0e0-0x0ff and 0x2e0-0x2ff are reserved, that means
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +7
-4-* 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 onwards, the doorbell indexes reserved for SDMA, +IH, +* and VCN +*/ +unsigned int reserved_doorbells_start; +unsigned int reserved_doorbells_end;
Quoted 3 lines
Quoted 2 lines
/* Base address of doorbell aperture. */ phys_addr_t doorbell_physical_address;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/3 drm/amdkfd: Optimize out sdma doorbell array in kgd2kfd_shared_resources
In reply to a message not in the archiveWe can directly calculate the sdma doorbell index 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, resulting in more portable code.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 55 ++++++------------- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 18 ++++-- .../gpu/drm/amd/include/kgd_kfd_interface.h | 2 +- 3 files changed, 31 insertions(+), 44 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +17 -38
@@ -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,45 +174,22 @@ 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. +if (adev->asic_type >=CHIP_VEGA10 ) { +/* Because of the setting in registers like +* SDMA0_DOORBELL_RANGE etc., BIF statically uses the +* lower 12 bits of doorbell address for routing, in +* order to route the CP queue doorbells to CP engine, +* the doorbells allocated to CP queues have to be +* outside the range set for SDMA, VCN, and IH blocks +* Prior to SOC15, all queues use queue ID to +* determine doorbells. */ - 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 ); + gpu_resources.reserved_doorbells_start = + adev->doorbell_index.sdma_engine[0 ]; + gpu_resources.reserved_doorbells_end = + adev->doorbell_index.last_non_cp; } -/* Because of the setting in registers like -* SDMA0_DOORBELL_RANGE etc., BIF statically uses the -* lower 12 bits of doorbell address for routing, in -* order to route the CP queue doorbells to CP engine, -* the doorbells allocated to CP queues have to be -* outside the range set for SDMA, VCN, and IH blocks -* Prior to SOC15, all queues use queue ID to -* determine doorbells. -*/ - gpu_resources.reserved_doorbells_start = - adev->doorbell_index.sdma_engine[0 ]; - gpu_resources.reserved_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 +13 -5
@@ -134,12 +134,20 @@ 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. +* 512 8-byte doorbell distance (i.e. one page away) ensures +* that SDMA RLC (2*i+1) doorbell lies exactly in the doorbell +* OFFSET and SIZE set in register BIF_SDMA0_DOORBELL_RANGE. */ - q->doorbell_id = dev->shared_resources.sdma_doorbell - [q->properties.sdma_engine_id] - [q->properties.sdma_queue_id]; +unsigned int *idx_offset = + dev->shared_resources.sdma_doorbell_idx; + q->doorbell_id = idx_offset[q->properties.sdma_engine_id] + + (q->properties.sdma_queue_id >>1 ) + + (q->properties.sdma_queue_id %2 ) + *KFD_QUEUE_DOORBELL_MIRROR_OFFSET ; }else {/* For CP queues on SOC15 reserve a free doorbell ID */ unsigned int found;
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +1 -1
@@ -137,7 +137,7 @@ struct kgd2kfd_shared_resources {/* Bit n == 1 means Queue n is available for KFD */ DECLARE_BITMAP (queue_bitmap,KGD_MAX_QUEUES ); -unsigned int sdma_doorbell[2 ][8 ]; +unsigned int *sdma_doorbell_idx;/* From SOC15 onwards, the doorbell indexes reserved for SDMA, IH, * and VCN
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]
Zeng, Oak
Reviewed-by Oak ZengRE: [PATCH 3/3] drm/amdkfd: Optimize out sdma doorbell array in kgd2kfd_shared_resources
Thanks,
Oak
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Zhao, Yong
Sent: Thursday, January 31, 2019 5:27 PM
To: [email protected]
Cc: Zhao, Yong <[email protected]>
Subject: [PATCH 3/3] drm/amdkfd: Optimize out sdma doorbell array in kgd2kfd_shared_resources
We can directly calculate the sdma doorbell index 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, resulting in more portable code.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 55 ++++++------------- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 18 ++++-- .../gpu/drm/amd/include/kgd_kfd_interface.h | 2 +- 3 files changed, 31 insertions(+), 44 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +4 -2
@@ -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,45 +174,22 @@ 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.
+ if (adev->asic_type >= CHIP_VEGA10) {
+ /* Because of the setting in registers like
+ * SDMA0_DOORBELL_RANGE etc., BIF statically uses the
+ * lower 12 bits of doorbell address for routing, in
+ * order to route the CP queue doorbells to CP engine,
+ * the doorbells allocated to CP queues have to be
+ * outside the range set for SDMA, VCN, and IH blocks
+ * Prior to SOC15, all queues use queue ID to
+ * determine doorbells.
*/
- 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);
+ gpu_resources.reserved_doorbells_start =
+ adev->doorbell_index.sdma_engine[0];
+ gpu_resources.reserved_doorbells_end =
+ adev->doorbell_index.last_non_cp;
}
- /* Because of the setting in registers like
- * SDMA0_DOORBELL_RANGE etc., BIF statically uses the
- * lower 12 bits of doorbell address for routing, in
- * order to route the CP queue doorbells to CP engine,
- * the doorbells allocated to CP queues have to be
- * outside the range set for SDMA, VCN, and IH blocks
- * Prior to SOC15, all queues use queue ID to
- * determine doorbells.
- */
- gpu_resources.reserved_doorbells_start =
- adev->doorbell_index.sdma_engine[0];
- gpu_resources.reserved_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 +13 -5
@@ -134,12 +134,20 @@ 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. +* 512 8-byte doorbell distance (i.e. one page away) ensures +* that SDMA RLC (2*i+1) doorbell lies exactly in the doorbell +* OFFSET and SIZE set in register BIF_SDMA0_DOORBELL_RANGE. */ - q->doorbell_id = dev->shared_resources.sdma_doorbell - [q->properties.sdma_engine_id] - [q->properties.sdma_queue_id]; +unsigned int *idx_offset = + dev->shared_resources.sdma_doorbell_idx; + q->doorbell_id = idx_offset[q->properties.sdma_engine_id] + + (q->properties.sdma_queue_id >>1 ) + + (q->properties.sdma_queue_id %2 ) + *KFD_QUEUE_DOORBELL_MIRROR_OFFSET ; }else {/* For CP queues on SOC15 reserve a free doorbell ID */ unsigned int found;
drivers/gpu/drm/amd/include/kgd_kfd_interface.h +1 -1
@@ -137,7 +137,7 @@ struct kgd2kfd_shared_resources {/* Bit n == 1 means Queue n is available for KFD */ DECLARE_BITMAP (queue_bitmap,KGD_MAX_QUEUES ); -unsigned int sdma_doorbell[2 ][8 ]; +unsigned int *sdma_doorbell_idx;/* From SOC15 onwards, the doorbell indexes reserved for SDMA, IH, * and VCN
--
2.17.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx