Commit 63f6e012 authored by Jonathan Kim's avatar Jonathan Kim Committed by Alex Deucher

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.

v2: squash in unused variable removal.
Signed-off-by: default avatarJonathan Kim <jonathan.kim@amd.com>
Reviewed-by: default avatarFelix Kuehling <felix.kuehling@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 03fc4cf4
...@@ -1674,29 +1674,27 @@ static int get_wave_state(struct device_queue_manager *dqm, ...@@ -1674,29 +1674,27 @@ static int get_wave_state(struct device_queue_manager *dqm,
u32 *save_area_used_size) u32 *save_area_used_size)
{ {
struct mqd_manager *mqd_mgr; struct mqd_manager *mqd_mgr;
int r;
dqm_lock(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]; mqd_mgr = dqm->mqd_mgrs[KFD_MQD_TYPE_CP];
if (!mqd_mgr->get_wave_state) { if (q->properties.type != KFD_QUEUE_TYPE_COMPUTE ||
r = -EINVAL; q->properties.is_active || !q->device->cwsr_enabled ||
goto dqm_unlock; !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); 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, static int process_termination_cpsch(struct device_queue_manager *dqm,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment