Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [High] drm/amdgpu: gang context array index leak in mes_userq_map() [1] --
commit d0ceeae2277f6c5db3f1b3901e53f85f8174b593 Author: Alex Deucher <[email protected]> drm/amdgpu/userq/mes: implement set gang submit This commit implements the .set_gang callback in userq_mes_funcs to support gang submission for MES usermode queues. > diff --git a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c > b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c > index 7abb9d95ef59a..68c10a8adcd20 100644 > --- a/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c > +++ b/drivers/gpu/drm/amd/amdgpu/mes_userqueue.c > @@ -649,6 +649,36 @@ static int mes_userq_restore(struct > amdgpu_usermode_queue *queue) > return r; > } > > +static int mes_set_gang(struct amdgpu_usermode_queue *primary_queue, > + struct amdgpu_usermode_queue *secondary_queue) > +{ > + struct amdgpu_userq_obj *primary_ctx = &primary_queue->fw_obj; > + struct amdgpu_userq_obj *secondary_ctx = &secondary_queue->fw_obj; > + struct amdgpu_userq_mgr *uq_mgr = primary_queue->userq_mgr; > + struct amdgpu_device *adev = uq_mgr->adev; > + struct mes_set_gang_submit_input input; > + struct amdgpu_mes *mes = &adev->mes; > + int r; > + > + memset(&input, 0x0, sizeof(struct mes_set_gang_submit_input)); > + > + input.primary_gang_context_addr = primary_ctx->gpu_addr; > + input.secondary_gang_context_addr = secondary_ctx->gpu_addr; > + if (mes->use_rs64mem) { > + input.primary_gang_context_array_idx = > + primary_queue->gang_ctx_array_index; > + input.secondary_gang_context_array_idx = > + secondary_queue->gang_ctx_array_index; > + } [Severity: High] This problem wasn't introduced by this patch, but does mes_userq_map() leak queue->gang_ctx_array_index [1] when add_hw_queue() fails? drivers/gpu/drm/amd/amdgpu/mes_userqueue.c:mes_userq_map() { ... if (mes->use_rs64mem) { ... r = amdgpu_mes_alloc_gang_ctx_index(mes, &queue->gang_ctx_array_index); if (r) { DRM_ERROR("Failed to allocate userq gang index err:%d\n", r); return r; } queue_input.process_context_array_index = uq_mgr->proc_ctx_array_index; queue_input.gang_context_array_index = queue->gang_ctx_array_index; } amdgpu_mes_lock(&adev->mes); r = adev->mes.funcs->add_hw_queue(&adev->mes, &queue_input); amdgpu_mes_unlock(&adev->mes); if (r) { DRM_ERROR("Failed to map queue in HW, err (%d)\n", r); return r; } ... } When add_hw_queue() fails during amdgpu_userq_create(), mes_userq_map() returns without calling amdgpu_mes_free_gang_ctx_index(), and the caller's error cleanup does not call mes_userq_unmap(). Repeated mapping failures can exhaust the gang context bitmap and prevent creating new MES user queues. [1] https://sashiko.dev/#/bug/linux-70b9dde6-e881-480d-9c56-534a231e5249 -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=7
