* [PATCH] drm/amdkfd: Fix user queue validation on Gfx7/8
@ 2025-01-30 0:04 Philip Yang
2025-02-12 23:00 ` Philip Yang
2025-02-13 1:06 ` Alex Deucher
0 siblings, 2 replies; 3+ messages in thread
From: Philip Yang @ 2025-01-30 0:04 UTC (permalink / raw)
To: amd-gfx; +Cc: Felix.Kuehling, alexander.deucher, trnka, Philip Yang
To workaround queue full h/w issue on Gfx7/8, when application create
AQL queues, the ring buffer bo allocate size is queue_size/2 and
mapped to GPU twice using 2 attachments with same ring_bo backing
memory.
For this case, user queue buffer validation should use queue_size/2 to
verify ring_bo allocation and mapping size.
Fixes: 68e599db7a54 ("drm/amdkfd: Validate user queue buffers")
Suggested-by: Tomáš Trnka <trnka@scm.com>
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_queue.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
index ecccd7adbab4..62c635e9d1aa 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
@@ -233,6 +233,7 @@ void kfd_queue_buffer_put(struct amdgpu_bo **bo)
int kfd_queue_acquire_buffers(struct kfd_process_device *pdd, struct queue_properties *properties)
{
struct kfd_topology_device *topo_dev;
+ u64 expected_queue_size;
struct amdgpu_vm *vm;
u32 total_cwsr_size;
int err;
@@ -241,6 +242,15 @@ int kfd_queue_acquire_buffers(struct kfd_process_device *pdd, struct queue_prope
if (!topo_dev)
return -EINVAL;
+ /* AQL queues on GFX7 and GFX8 appear twice their actual size */
+ if (properties->type == KFD_QUEUE_TYPE_COMPUTE &&
+ properties->format == KFD_QUEUE_FORMAT_AQL &&
+ topo_dev->node_props.gfx_target_version >= 70000 &&
+ topo_dev->node_props.gfx_target_version < 90000)
+ expected_queue_size = properties->queue_size / 2;
+ else
+ expected_queue_size = properties->queue_size;
+
vm = drm_priv_to_vm(pdd->drm_priv);
err = amdgpu_bo_reserve(vm->root.bo, false);
if (err)
@@ -255,7 +265,7 @@ int kfd_queue_acquire_buffers(struct kfd_process_device *pdd, struct queue_prope
goto out_err_unreserve;
err = kfd_queue_buffer_get(vm, (void *)properties->queue_address,
- &properties->ring_bo, properties->queue_size);
+ &properties->ring_bo, expected_queue_size);
if (err)
goto out_err_unreserve;
--
2.47.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/amdkfd: Fix user queue validation on Gfx7/8
2025-01-30 0:04 [PATCH] drm/amdkfd: Fix user queue validation on Gfx7/8 Philip Yang
@ 2025-02-12 23:00 ` Philip Yang
2025-02-13 1:06 ` Alex Deucher
1 sibling, 0 replies; 3+ messages in thread
From: Philip Yang @ 2025-02-12 23:00 UTC (permalink / raw)
To: Philip Yang, amd-gfx; +Cc: Felix.Kuehling, alexander.deucher, trnka
[-- Attachment #1: Type: text/html, Size: 2706 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/amdkfd: Fix user queue validation on Gfx7/8
2025-01-30 0:04 [PATCH] drm/amdkfd: Fix user queue validation on Gfx7/8 Philip Yang
2025-02-12 23:00 ` Philip Yang
@ 2025-02-13 1:06 ` Alex Deucher
1 sibling, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2025-02-13 1:06 UTC (permalink / raw)
To: Philip Yang; +Cc: amd-gfx, Felix.Kuehling, alexander.deucher, trnka
On Wed, Jan 29, 2025 at 7:12 PM Philip Yang <Philip.Yang@amd.com> wrote:
>
> To workaround queue full h/w issue on Gfx7/8, when application create
> AQL queues, the ring buffer bo allocate size is queue_size/2 and
> mapped to GPU twice using 2 attachments with same ring_bo backing
> memory.
>
> For this case, user queue buffer validation should use queue_size/2 to
> verify ring_bo allocation and mapping size.
>
> Fixes: 68e599db7a54 ("drm/amdkfd: Validate user queue buffers")
> Suggested-by: Tomáš Trnka <trnka@scm.com>
> Signed-off-by: Philip Yang <Philip.Yang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_queue.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_queue.c b/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
> index ecccd7adbab4..62c635e9d1aa 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_queue.c
> @@ -233,6 +233,7 @@ void kfd_queue_buffer_put(struct amdgpu_bo **bo)
> int kfd_queue_acquire_buffers(struct kfd_process_device *pdd, struct queue_properties *properties)
> {
> struct kfd_topology_device *topo_dev;
> + u64 expected_queue_size;
> struct amdgpu_vm *vm;
> u32 total_cwsr_size;
> int err;
> @@ -241,6 +242,15 @@ int kfd_queue_acquire_buffers(struct kfd_process_device *pdd, struct queue_prope
> if (!topo_dev)
> return -EINVAL;
>
> + /* AQL queues on GFX7 and GFX8 appear twice their actual size */
> + if (properties->type == KFD_QUEUE_TYPE_COMPUTE &&
> + properties->format == KFD_QUEUE_FORMAT_AQL &&
> + topo_dev->node_props.gfx_target_version >= 70000 &&
> + topo_dev->node_props.gfx_target_version < 90000)
> + expected_queue_size = properties->queue_size / 2;
> + else
> + expected_queue_size = properties->queue_size;
> +
> vm = drm_priv_to_vm(pdd->drm_priv);
> err = amdgpu_bo_reserve(vm->root.bo, false);
> if (err)
> @@ -255,7 +265,7 @@ int kfd_queue_acquire_buffers(struct kfd_process_device *pdd, struct queue_prope
> goto out_err_unreserve;
>
> err = kfd_queue_buffer_get(vm, (void *)properties->queue_address,
> - &properties->ring_bo, properties->queue_size);
> + &properties->ring_bo, expected_queue_size);
> if (err)
> goto out_err_unreserve;
>
> --
> 2.47.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-13 1:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-30 0:04 [PATCH] drm/amdkfd: Fix user queue validation on Gfx7/8 Philip Yang
2025-02-12 23:00 ` Philip Yang
2025-02-13 1:06 ` Alex Deucher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox