drm/amdkfd: Fix unaligned doorbell absolute offset for gfx8
Subsystems (3)
cover drm/amdkfd: Fix unaligned doorbell absolute offset for gfx8
On older chips, the absolute doorbell offset within the doorbell page is based on the queue ID. KFD is using queue ID and doorbell size to get an absolute doorbell offset in userspace.
This patch is to adjust the absolute doorbell offset against the doorbell id considering the doorbell size of 32/64 bit.
Arvind Yadav (1):
drm/amdkfd: Fix unaligned doorbell absolute offset for gfx8
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
Signature · 1 line
2.34.1
PATCH 1/1 drm/amdkfd: Fix unaligned doorbell absolute offset for gfx8
This patch is to adjust the absolute doorbell offset against the doorbell id considering the doorbell size of 32/64 bit.
--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +10 -1
@@ -407,7 +407,16 @@ static int allocate_doorbell(struct qcm_process_device *qpd, q->properties.doorbell_off =amdgpu_doorbell_index_on_bar (dev->adev, qpd->proc_doorbells, - q->doorbell_id); +0 ); + +/* Adjust the absolute doorbell offset against the doorbell id considering +* the doorbell size of 32/64 bit. +*/ +if (!KFD_IS_SOC15 (dev)) + q->properties.doorbell_off += q->doorbell_id; +else + q->properties.doorbell_off += q->doorbell_id *2 ; +return 0 ; }
Signature · 1 line
2.34.1
Adding [email protected] for review.
Thanks
~Arvind
Quoted 34 lines · Arvind Yadav
This patch is to adjust the absolute doorbell offset against the doorbell id considering the doorbell size of 32/64 bit.
Cc Christian Koenig <[email protected]>Cc Alex Deucher <[email protected]>Signed-off-by Shashank Sharma <[email protected]>Signed-off-by Arvind Yadav <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +10
-1@@ -407,7 +407,16 @@ static int allocate_doorbell(struct qcm_process_device *qpd, q->properties.doorbell_off =amdgpu_doorbell_index_on_bar (dev->adev, qpd->proc_doorbells, - q->doorbell_id); +0 ); + +/* Adjust the absolute doorbell offset against the doorbell id considering +* the doorbell size of 32/64 bit. +*/ +if (!KFD_IS_SOC15 (dev)) + q->properties.doorbell_off += q->doorbell_id; +else + q->properties.doorbell_off += q->doorbell_id *2 ; +return 0 ; }
Felix Kuehling
maintainer[+Mukul]
Quoted 17 lines · Arvind Yadav
This patch is to adjust the absolute doorbell offset against the doorbell id considering the doorbell size of 32/64 bit.
Cc Christian Koenig<[email protected]>Cc Alex Deucher<[email protected]>Signed-off-by Shashank Sharma<[email protected]>Signed-off-by Arvind Yadav<[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int allocate_doorbell(struct qcm_process_device *qpd, · line 410
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-1@@ -407,7 +407,16 @@ static int allocate_doorbell(struct qcm_process_device *qpd, q->properties.doorbell_off =amdgpu_doorbell_index_on_bar (dev->adev, qpd->proc_doorbells, - q->doorbell_id); +0 );
Looks like we're now always calling amdgpu_doorbell_index_on_bar with the third parameter = 0. So we could remove that parameter. It doesn't do us any good and only causes bugs if we use any non-0 value.
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int allocate_doorbell(struct qcm_process_device *qpd, · line 418
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +8
-0+ +/* Adjust the absolute doorbell offset against the doorbell id considering +* the doorbell size of 32/64 bit. +*/ +if (!KFD_IS_SOC15 (dev)) + q->properties.doorbell_off += q->doorbell_id; +else + q->properties.doorbell_off += q->doorbell_id *2 ;
This could be simplified and generalized as
q->properties.doorbell_off += q->doorbell_id * dev->kfd->device_info.doorbell_size / 4;
Regards,
Felix
Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-0+return 0 ; }
Quoted 22 lines · Felix Kuehling
[+Mukul]
Quoted 18 lines · Arvind Yadav
This patch is to adjust the absolute doorbell offset against the doorbell id considering the doorbell size of 32/64 bit.
Cc Christian Koenig<[email protected]>Cc Alex Deucher<[email protected]>Signed-off-by Shashank Sharma<[email protected]>Signed-off-by Arvind Yadav<[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0@@ -407,7 +407,16 @@ static int allocate_doorbell(struct qcm_process_device *qpd,
Quoted 7 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int allocate_doorbell(struct qcm_process_device *qpd, · line 410
Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-1q->properties.doorbell_off =amdgpu_doorbell_index_on_bar (dev->adev, qpd->proc_doorbells, - q->doorbell_id); +0 );Looks like we're now always calling
amdgpu_doorbell_index_on_barwith the third parameter = 0. So we could remove that parameter. It doesn't do us any good and only causes bugs if we use any non-0 value.
Hey Felix,
Actually this was happening because in usermode KFD library the doorbell-size is for non-SOC15() hardware is hard coded to 4 bytes.
We added this fix just so that the library code doesn't need to be changed, but can still get aligned to kernel code.
GFX Usermode queue code uses this doorbell-index parameter, and it gives us the right offset.
Regards
Shashank
Quoted 12 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int allocate_doorbell(struct qcm_process_device *qpd, · line 418
Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +8
-0+ +/* Adjust the absolute doorbell offset against the doorbell id considering +* the doorbell size of 32/64 bit. +*/ +if (!KFD_IS_SOC15 (dev)) + q->properties.doorbell_off += q->doorbell_id; +else + q->properties.doorbell_off += q->doorbell_id *2 ;This could be simplified and generalized as
Quoted 1 line
q->properties.doorbell_off += q->doorbell_id * dev->kfd->device_info.doorbell_size / 4;
Agree, we can do this simplification.
- Shashank
Quoted 8 lines
Regards,
FelixQuoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-0+return 0 ; }
Adding [email protected] for review.
Thanks
~Arvind
Quoted 15 lines · Arvind Yadav
On older chips, the absolute doorbell offset within the doorbell page is based on the queue ID. KFD is using queue ID and doorbell size to get an absolute doorbell offset in userspace.
This patch is to adjust the absolute doorbell offset against the doorbell id considering the doorbell size of 32/64 bit.
Arvind Yadav (1):
drm/amdkfd: Fix unaligned doorbell absolute offset for gfx8drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)