drm/amdkfd: fix circular locking on get_wave_state
Subsystems (3)
PATCH 1/1 drm/amdkfd: fix circular locking on get_wave_state
get_wave_state acquires the mmap_lock on copy_to_user but so do mmu_notifiers. mmu_notifiers allows dqm locking so do get_wave_state outside the dqm_lock to prevent circular locking.
Signed-off-by Jonathan Kim <[email protected]>
Reviewed-by Felix Kuehling <[email protected]>
--- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +13 -14
@@ -1678,25 +1678,24 @@ static int get_wave_state(struct device_queue_manager *dqm,dqm_lock (dqm); -if (q->properties.type !=KFD_QUEUE_TYPE_COMPUTE || - q->properties.is_active || !q->device->cwsr_enabled) { - r = -EINVAL ; - goto dqm_unlock; - } - mqd_mgr = dqm->mqd_mgrs[KFD_MQD_TYPE_CP ]; -if (!mqd_mgr->get_wave_state) { - r = -EINVAL ; - goto dqm_unlock; +if (q->properties.type !=KFD_QUEUE_TYPE_COMPUTE || + q->properties.is_active || !q->device->cwsr_enabled || + !mqd_mgr->get_wave_state) { +dqm_unlock (dqm); +return -EINVAL ; } - r = mqd_mgr->get_wave_state (mqd_mgr, q->mqd, ctl_stack, - ctl_stack_used_size, save_area_used_size); - -dqm_unlock:dqm_unlock (dqm); -return r; + +/* +* get_wave_state is outside the dqm lock to prevent circular locking +* and the queue should be protected against destruction by the process +* lock. +*/ +return mqd_mgr->get_wave_state (mqd_mgr, q->mqd, ctl_stack, + ctl_stack_used_size, save_area_used_size); } static int process_termination_cpsch(struct device_queue_manager *dqm,
Signature · 6 lines
2.25.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx