On 12/16/25 1:55 AM, Philip Yang wrote:
On 2025-12-12 01:40, Donet Tom wrote:
HW-supported EOP buffer sizes are 4K and 32K. On systems that do not
use 4K pages, the minimum buffer object (BO) allocation size is
PAGE_SIZE (for example, 64K). During queue buffer acquisition, the
driver
currently checks the allocated BO size against the supported EOP buffer
size. Since the allocated BO is larger than the expected size, this
check
fails, preventing queue creation.
Relax the strict size validation and allow PAGE_SIZE-sized BOs to be
used.
Only the required 4K region of the buffer will be used as the EOP buffer
and avoids queue creation failures on non-4K page systems.
Signed-off-by: Donet Tom <[email protected]>
---
drivers/gpu/drm/amd/amdkfd/kfd_queue.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
b/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
index f1e7583650c4..dc857450fa16 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
@@ -199,6 +199,7 @@ int kfd_queue_buffer_get(struct amdgpu_vm *vm,
void __user *addr, struct amdgpu_
struct amdgpu_bo_va_mapping *mapping;
u64 user_addr;
u64 size;
+ u64 bo_size;
user_addr = (u64)addr >> AMDGPU_GPU_PAGE_SHIFT;
size = expected_size >> AMDGPU_GPU_PAGE_SHIFT;
@@ -207,11 +208,12 @@ int kfd_queue_buffer_get(struct amdgpu_vm *vm,
void __user *addr, struct amdgpu_
if (!mapping)
goto out_err;
- if (user_addr != mapping->start ||
- (size != 0 && user_addr + size - 1 != mapping->last)) {
- pr_debug("expected size 0x%llx not equal to mapping addr
0x%llx size 0x%llx\n",
+ bo_size = mapping->last - mapping->start + 1;
+
+ if (user_addr != mapping->start || (size != 0 && bo_size < size)) {
+ pr_debug("expected size 0x%llx grater than mapping addr
0x%llx size 0x%llx\n",
expected_size, mapping->start << AMDGPU_GPU_PAGE_SHIFT,
- (mapping->last - mapping->start + 1) <<
AMDGPU_GPU_PAGE_SHIFT);
+ bo_size << AMDGPU_GPU_PAGE_SHIFT);
This change works, but also relax the size validation for ring buffer
size etc, this may have side effect,
for example FW and user space should have the same ring buffer size.
Other buffers already use PAGE_SIZE as expected size or size aligned
to PAGE_SIZE, maybe only relax the eop buffer
size check
@@ -275,7 +275,7 @@ int kfd_queue_acquire_buffers(struct
kfd_process_device *pdd, struct queue_prope
/* EOP buffer is not required for all ASICs */
if (properties->eop_ring_buffer_address) {
- if (properties->eop_ring_buffer_size !=
topo_dev->node_props.eop_buffer_size) {
+ if (properties->eop_ring_buffer_size <
topo_dev->node_props.eop_buffer_size) {
pr_debug("queue eop bo size 0x%x not equal to
node eop buf size 0x%x\n",
properties->eop_ring_buffer_size,
topo_dev->node_props.eop_buffer_size);
@@ -284,7 +284,7 @@ int kfd_queue_acquire_buffers(struct
kfd_process_device *pdd, struct queue_prope
}
err = kfd_queue_buffer_get(vm, (void
*)properties->eop_ring_buffer_address,
&properties->eop_buf_bo,
- properties->eop_ring_buffer_size);
+ ALIGN(properties->eop_ring_buffer_size, PAGE_SIZE));
if (err)
goto out_err_unreserve;
}
Thank you. I will make this change in next version.
Regards,
Philip
goto out_err;
}