AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Donet Tom <donettom@linux.ibm.com>
To: Philip Yang <yangp@amd.com>,
	amd-gfx@lists.freedesktop.org,
	Felix Kuehling <Felix.Kuehling@amd.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	christian.koenig@amd.com
Cc: Kent.Russell@amd.com, Ritesh Harjani <ritesh.list@gmail.com>,
	Vaidyanathan Srinivasan <svaidy@linux.ibm.com>,
	Mukesh Kumar Chaurasiya <mkchauras@linux.ibm.com>
Subject: Re: [RFC PATCH v1 1/8] drm/amdkfd: Relax size checking during queue buffer get
Date: Tue, 16 Dec 2025 15:42:59 +0530	[thread overview]
Message-ID: <8b2805da-e0e1-42df-b200-05d6e14b4c30@linux.ibm.com> (raw)
In-Reply-To: <64013bb5-9510-4a29-873e-b23d59c494db@amd.com>


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 <donettom@linux.ibm.com>
>> ---
>>   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;
>>       }
>

  reply	other threads:[~2025-12-16 10:13 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-12  6:40 [RFC PATCH v1 0/8] amdgpu/amdkfd: Add support for non-4K page size systems Donet Tom
2025-12-12  6:40 ` [RFC PATCH v1 1/8] drm/amdkfd: Relax size checking during queue buffer get Donet Tom
2025-12-15 20:25   ` Philip Yang
2025-12-16 10:12     ` Donet Tom [this message]
2025-12-12  6:40 ` [RFC PATCH v1 2/8] amdkfd/kfd_svm: Fix SVM map/unmap address conversion for non-4k page sizes Donet Tom
2025-12-15 20:44   ` Philip Yang
2025-12-16 10:09     ` Donet Tom
2025-12-12  6:40 ` [RFC PATCH v1 3/8] amdkfd/kfd_migrate: Fix GART PTE for non-4K pagesize in svm_migrate_gart_map() Donet Tom
2025-12-15 21:03   ` Philip Yang
2025-12-12  6:40 ` [RFC PATCH v1 4/8] amdgpu/amdgpu_ttm: Fix AMDGPU_GTT_MAX_TRANSFER_SIZE for non-4K page size Donet Tom
2025-12-12  8:53   ` Christian König
2025-12-12 12:14     ` Donet Tom
2026-01-06 12:55     ` Donet Tom
2026-01-08 12:31       ` Christian König
2026-01-09 10:22         ` Pierre-Eric Pelloux-Prayer
2026-01-09 12:57         ` Donet Tom
2025-12-12  6:40 ` [RFC PATCH v1 5/8] amdkfd/kfd_chardev: Add error message for non-4k pagesize failures Donet Tom
2025-12-12  6:40 ` [RFC PATCH v1 6/8] drm/amdgpu: Handle GPU page faults correctly on non-4K page systems Donet Tom
2025-12-12  6:40 ` [RFC PATCH v1 7/8] amdgpu: Align ctl_stack_size and wg_data_size to GPU page size instead of CPU page size Donet Tom
2025-12-12  9:04   ` Christian König
2025-12-12 12:29     ` Donet Tom
2025-12-19 10:27     ` Donet Tom
2026-01-06 13:01       ` Donet Tom
2025-12-12  6:40 ` [RFC PATCH v1 8/8] amdgpu: Fix MQD and control stack alignment for non-4K CPU page size systems Donet Tom
2025-12-12  9:01 ` [RFC PATCH v1 0/8] amdgpu/amdkfd: Add support for non-4K " Christian König
2025-12-12 10:45   ` Ritesh Harjani
2025-12-12 13:01     ` Christian König
2025-12-12 17:24       ` Alex Deucher
2025-12-15  9:47         ` Christian König
2025-12-15 10:11           ` Donet Tom
2025-12-15 16:11             ` Christian König
2025-12-16 10:08               ` Donet Tom
2025-12-16 16:06                 ` Christian König
2025-12-17  9:04                   ` Donet Tom
2025-12-17  9:46               ` Donet Tom
2025-12-17 10:10                 ` Christian König
2025-12-15 14:09           ` Alex Deucher
2025-12-16 13:54             ` Donet Tom
2025-12-16 14:02               ` Alex Deucher
2025-12-17  9:03                 ` Donet Tom
2025-12-17 14:23                   ` Alex Deucher
2025-12-17 21:31                     ` Yat Sin, David
2026-01-02 18:53                       ` Donet Tom
2026-01-06 12:58                       ` Donet Tom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8b2805da-e0e1-42df-b200-05d6e14b4c30@linux.ibm.com \
    --to=donettom@linux.ibm.com \
    --cc=Felix.Kuehling@amd.com \
    --cc=Kent.Russell@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=mkchauras@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=svaidy@linux.ibm.com \
    --cc=yangp@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox