Commit 339903fa authored by Yong Zhao's avatar Yong Zhao Committed by Alex Deucher

drm/amdkfd: Use better name to indicate the offset is in dwords

The doorbell offset could mean the byte offset or the dword offset,
and the 0 offset place is also different, sometimes the start of PCI
doorbell bar or the start of process doorbell pages. Use better name
to avoid confusion.
Signed-off-by: default avatarYong Zhao <Yong.Zhao@amd.com>
Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 026674cf
...@@ -170,7 +170,7 @@ static int allocate_doorbell(struct qcm_process_device *qpd, struct queue *q) ...@@ -170,7 +170,7 @@ static int allocate_doorbell(struct qcm_process_device *qpd, struct queue *q)
} }
q->properties.doorbell_off = q->properties.doorbell_off =
kfd_doorbell_id_to_offset(dev, q->process, kfd_get_doorbell_dw_offset_in_bar(dev, q->process,
q->doorbell_id); q->doorbell_id);
return 0; return 0;
......
...@@ -91,7 +91,7 @@ int kfd_doorbell_init(struct kfd_dev *kfd) ...@@ -91,7 +91,7 @@ int kfd_doorbell_init(struct kfd_dev *kfd)
kfd->doorbell_base = kfd->shared_resources.doorbell_physical_address + kfd->doorbell_base = kfd->shared_resources.doorbell_physical_address +
doorbell_start_offset; doorbell_start_offset;
kfd->doorbell_id_offset = doorbell_start_offset / sizeof(u32); kfd->doorbell_base_dw_offset = doorbell_start_offset / sizeof(u32);
kfd->doorbell_kernel_ptr = ioremap(kfd->doorbell_base, kfd->doorbell_kernel_ptr = ioremap(kfd->doorbell_base,
kfd_doorbell_process_slice(kfd)); kfd_doorbell_process_slice(kfd));
...@@ -103,8 +103,8 @@ int kfd_doorbell_init(struct kfd_dev *kfd) ...@@ -103,8 +103,8 @@ int kfd_doorbell_init(struct kfd_dev *kfd)
pr_debug("doorbell base == 0x%08lX\n", pr_debug("doorbell base == 0x%08lX\n",
(uintptr_t)kfd->doorbell_base); (uintptr_t)kfd->doorbell_base);
pr_debug("doorbell_id_offset == 0x%08lX\n", pr_debug("doorbell_base_dw_offset == 0x%08lX\n",
kfd->doorbell_id_offset); kfd->doorbell_base_dw_offset);
pr_debug("doorbell_process_limit == 0x%08lX\n", pr_debug("doorbell_process_limit == 0x%08lX\n",
doorbell_process_limit); doorbell_process_limit);
...@@ -185,7 +185,7 @@ void __iomem *kfd_get_kernel_doorbell(struct kfd_dev *kfd, ...@@ -185,7 +185,7 @@ void __iomem *kfd_get_kernel_doorbell(struct kfd_dev *kfd,
* Calculating the kernel doorbell offset using the first * Calculating the kernel doorbell offset using the first
* doorbell page. * doorbell page.
*/ */
*doorbell_off = kfd->doorbell_id_offset + inx; *doorbell_off = kfd->doorbell_base_dw_offset + inx;
pr_debug("Get kernel queue doorbell\n" pr_debug("Get kernel queue doorbell\n"
" doorbell offset == 0x%08X\n" " doorbell offset == 0x%08X\n"
...@@ -225,17 +225,17 @@ void write_kernel_doorbell64(void __iomem *db, u64 value) ...@@ -225,17 +225,17 @@ void write_kernel_doorbell64(void __iomem *db, u64 value)
} }
} }
unsigned int kfd_doorbell_id_to_offset(struct kfd_dev *kfd, unsigned int kfd_get_doorbell_dw_offset_in_bar(struct kfd_dev *kfd,
struct kfd_process *process, struct kfd_process *process,
unsigned int doorbell_id) unsigned int doorbell_id)
{ {
/* /*
* doorbell_id_offset accounts for doorbells taken by KGD. * doorbell_base_dw_offset accounts for doorbells taken by KGD.
* index * kfd_doorbell_process_slice/sizeof(u32) adjusts to * index * kfd_doorbell_process_slice/sizeof(u32) adjusts to
* the process's doorbells. The offset returned is in dword * the process's doorbells. The offset returned is in dword
* units regardless of the ASIC-dependent doorbell size. * units regardless of the ASIC-dependent doorbell size.
*/ */
return kfd->doorbell_id_offset + return kfd->doorbell_base_dw_offset +
process->doorbell_index process->doorbell_index
* kfd_doorbell_process_slice(kfd) / sizeof(u32) + * kfd_doorbell_process_slice(kfd) / sizeof(u32) +
doorbell_id * kfd->device_info->doorbell_size / sizeof(u32); doorbell_id * kfd->device_info->doorbell_size / sizeof(u32);
......
...@@ -235,9 +235,10 @@ struct kfd_dev { ...@@ -235,9 +235,10 @@ struct kfd_dev {
* KFD. It is aligned for mapping * KFD. It is aligned for mapping
* into user mode * into user mode
*/ */
size_t doorbell_id_offset; /* Doorbell offset (from KFD doorbell size_t doorbell_base_dw_offset; /* Offset from the start of the PCI
* to HW doorbell, GFX reserved some * doorbell BAR to the first KFD
* at the start) * doorbell in dwords. GFX reserves
* the segment before this offset.
*/ */
u32 __iomem *doorbell_kernel_ptr; /* This is a pointer for a doorbells u32 __iomem *doorbell_kernel_ptr; /* This is a pointer for a doorbells
* page used by kernel queue * page used by kernel queue
...@@ -815,7 +816,7 @@ void kfd_release_kernel_doorbell(struct kfd_dev *kfd, u32 __iomem *db_addr); ...@@ -815,7 +816,7 @@ void kfd_release_kernel_doorbell(struct kfd_dev *kfd, u32 __iomem *db_addr);
u32 read_kernel_doorbell(u32 __iomem *db); u32 read_kernel_doorbell(u32 __iomem *db);
void write_kernel_doorbell(void __iomem *db, u32 value); void write_kernel_doorbell(void __iomem *db, u32 value);
void write_kernel_doorbell64(void __iomem *db, u64 value); void write_kernel_doorbell64(void __iomem *db, u64 value);
unsigned int kfd_doorbell_id_to_offset(struct kfd_dev *kfd, unsigned int kfd_get_doorbell_dw_offset_in_bar(struct kfd_dev *kfd,
struct kfd_process *process, struct kfd_process *process,
unsigned int doorbell_id); unsigned int doorbell_id);
phys_addr_t kfd_get_process_doorbells(struct kfd_dev *dev, phys_addr_t kfd_get_process_doorbells(struct kfd_dev *dev,
......
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