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);
                goto out_err;
        }
 
-- 
2.52.0

Reply via email to