Commit 367a0af4 authored by Arvind Yadav's avatar Arvind Yadav Committed by Alex Deucher

drm/amdkfd: get doorbell's absolute offset based on the db_size

Here, Adding db_size in byte to find the doorbell's
absolute offset for both 32-bit and 64-bit doorbell sizes.
So that doorbell offset will be aligned based on the doorbell
size.

v2:
- Addressed the review comment from Felix.
v3:
- Adding doorbell_size as parameter to get db absolute offset.
v4:
  Squash the two patches into one.

Cc: Christian Koenig <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarShashank Sharma <shashank.sharma@amd.com>
Signed-off-by: default avatarArvind Yadav <Arvind.Yadav@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 31220ee9
...@@ -361,7 +361,8 @@ void amdgpu_doorbell_fini(struct amdgpu_device *adev); ...@@ -361,7 +361,8 @@ void amdgpu_doorbell_fini(struct amdgpu_device *adev);
int amdgpu_doorbell_create_kernel_doorbells(struct amdgpu_device *adev); int amdgpu_doorbell_create_kernel_doorbells(struct amdgpu_device *adev);
uint32_t amdgpu_doorbell_index_on_bar(struct amdgpu_device *adev, uint32_t amdgpu_doorbell_index_on_bar(struct amdgpu_device *adev,
struct amdgpu_bo *db_bo, struct amdgpu_bo *db_bo,
uint32_t doorbell_index); uint32_t doorbell_index,
uint32_t db_size);
#define RDOORBELL32(index) amdgpu_mm_rdoorbell(adev, (index)) #define RDOORBELL32(index) amdgpu_mm_rdoorbell(adev, (index))
#define WDOORBELL32(index, v) amdgpu_mm_wdoorbell(adev, (index), (v)) #define WDOORBELL32(index, v) amdgpu_mm_wdoorbell(adev, (index), (v))
......
...@@ -114,19 +114,24 @@ void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, u32 index, u64 v) ...@@ -114,19 +114,24 @@ void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, u32 index, u64 v)
* @adev: amdgpu_device pointer * @adev: amdgpu_device pointer
* @db_bo: doorbell object's bo * @db_bo: doorbell object's bo
* @doorbell_index: doorbell relative index in this doorbell object * @doorbell_index: doorbell relative index in this doorbell object
* @db_size: doorbell size is in byte
* *
* returns doorbell's absolute index in BAR * returns doorbell's absolute index in BAR
*/ */
uint32_t amdgpu_doorbell_index_on_bar(struct amdgpu_device *adev, uint32_t amdgpu_doorbell_index_on_bar(struct amdgpu_device *adev,
struct amdgpu_bo *db_bo, struct amdgpu_bo *db_bo,
uint32_t doorbell_index) uint32_t doorbell_index,
uint32_t db_size)
{ {
int db_bo_offset; int db_bo_offset;
db_bo_offset = amdgpu_bo_gpu_offset_no_check(db_bo); db_bo_offset = amdgpu_bo_gpu_offset_no_check(db_bo);
/* doorbell index is 32 bit but doorbell's size is 64-bit, so *2 */ /* doorbell index is 32 bit but doorbell's size can be 32 bit
return db_bo_offset / sizeof(u32) + doorbell_index * 2; * or 64 bit, so *db_size(in byte)/4 for alignment.
*/
return db_bo_offset / sizeof(u32) + doorbell_index *
DIV_ROUND_UP(db_size, 4);
} }
/** /**
......
...@@ -410,7 +410,8 @@ static int allocate_doorbell(struct qcm_process_device *qpd, ...@@ -410,7 +410,8 @@ static int allocate_doorbell(struct qcm_process_device *qpd,
q->properties.doorbell_off = amdgpu_doorbell_index_on_bar(dev->adev, q->properties.doorbell_off = amdgpu_doorbell_index_on_bar(dev->adev,
qpd->proc_doorbells, qpd->proc_doorbells,
q->doorbell_id); q->doorbell_id,
dev->kfd->device_info.doorbell_size);
return 0; return 0;
} }
......
...@@ -161,7 +161,10 @@ void __iomem *kfd_get_kernel_doorbell(struct kfd_dev *kfd, ...@@ -161,7 +161,10 @@ void __iomem *kfd_get_kernel_doorbell(struct kfd_dev *kfd,
if (inx >= KFD_MAX_NUM_OF_QUEUES_PER_PROCESS) if (inx >= KFD_MAX_NUM_OF_QUEUES_PER_PROCESS)
return NULL; return NULL;
*doorbell_off = amdgpu_doorbell_index_on_bar(kfd->adev, kfd->doorbells, inx); *doorbell_off = amdgpu_doorbell_index_on_bar(kfd->adev,
kfd->doorbells,
inx,
kfd->device_info.doorbell_size);
inx *= 2; inx *= 2;
pr_debug("Get kernel queue doorbell\n" pr_debug("Get kernel queue doorbell\n"
...@@ -240,7 +243,10 @@ phys_addr_t kfd_get_process_doorbells(struct kfd_process_device *pdd) ...@@ -240,7 +243,10 @@ phys_addr_t kfd_get_process_doorbells(struct kfd_process_device *pdd)
return 0; return 0;
} }
first_db_index = amdgpu_doorbell_index_on_bar(adev, pdd->qpd.proc_doorbells, 0); first_db_index = amdgpu_doorbell_index_on_bar(adev,
pdd->qpd.proc_doorbells,
0,
pdd->dev->kfd->device_info.doorbell_size);
return adev->doorbell.base + first_db_index * sizeof(uint32_t); return adev->doorbell.base + first_db_index * sizeof(uint32_t);
} }
......
...@@ -377,7 +377,8 @@ int pqm_create_queue(struct process_queue_manager *pqm, ...@@ -377,7 +377,8 @@ int pqm_create_queue(struct process_queue_manager *pqm,
*/ */
uint32_t first_db_index = amdgpu_doorbell_index_on_bar(pdd->dev->adev, uint32_t first_db_index = amdgpu_doorbell_index_on_bar(pdd->dev->adev,
pdd->qpd.proc_doorbells, pdd->qpd.proc_doorbells,
0); 0,
pdd->dev->kfd->device_info.doorbell_size);
*p_doorbell_offset_in_process = (q->properties.doorbell_off *p_doorbell_offset_in_process = (q->properties.doorbell_off
- first_db_index) * sizeof(uint32_t); - first_db_index) * sizeof(uint32_t);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment