Skip to content

Commit 542c3bb

Browse files
PhilipYangAalexdeucher
authored andcommitted
drm/amdkfd: Fix user queue validation on Gfx7/8
To workaround queue full h/w issue on Gfx7/8, when application create AQL queue, the ring buffer bo allocate size is queue_size/2 and map queue_size ring buffer to GPU in 2 pieces using 2 attachments, each attachment map size is queue_size/2, with same ring_bo backing memory. For Gfx7/8, user queue buffer validation should use queue_size/2 to verify ring_bo allocation and mapping size. Fixes: 68e599d ("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> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit e7a4777) Cc: stable@vger.kernel.org
1 parent 35b6162 commit 542c3bb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/gpu/drm/amd/amdkfd/kfd_queue.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ void kfd_queue_buffer_put(struct amdgpu_bo **bo)
233233
int kfd_queue_acquire_buffers(struct kfd_process_device *pdd, struct queue_properties *properties)
234234
{
235235
struct kfd_topology_device *topo_dev;
236+
u64 expected_queue_size;
236237
struct amdgpu_vm *vm;
237238
u32 total_cwsr_size;
238239
int err;
@@ -241,6 +242,15 @@ int kfd_queue_acquire_buffers(struct kfd_process_device *pdd, struct queue_prope
241242
if (!topo_dev)
242243
return -EINVAL;
243244

245+
/* AQL queues on GFX7 and GFX8 appear twice their actual size */
246+
if (properties->type == KFD_QUEUE_TYPE_COMPUTE &&
247+
properties->format == KFD_QUEUE_FORMAT_AQL &&
248+
topo_dev->node_props.gfx_target_version >= 70000 &&
249+
topo_dev->node_props.gfx_target_version < 90000)
250+
expected_queue_size = properties->queue_size / 2;
251+
else
252+
expected_queue_size = properties->queue_size;
253+
244254
vm = drm_priv_to_vm(pdd->drm_priv);
245255
err = amdgpu_bo_reserve(vm->root.bo, false);
246256
if (err)
@@ -255,7 +265,7 @@ int kfd_queue_acquire_buffers(struct kfd_process_device *pdd, struct queue_prope
255265
goto out_err_unreserve;
256266

257267
err = kfd_queue_buffer_get(vm, (void *)properties->queue_address,
258-
&properties->ring_bo, properties->queue_size);
268+
&properties->ring_bo, expected_queue_size);
259269
if (err)
260270
goto out_err_unreserve;
261271

0 commit comments

Comments
 (0)