Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdkfd: Fix sdma queue allocate race condition

SDMA queue allocation requires the dqm lock as it modify
the global dqm members. Enclose it in the dqm_lock.

Signed-off-by: Oak Zeng <Oak.Zeng@amd.com>
Reviewed-by: Philip Yang <philip.yang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Oak Zeng and committed by
Alex Deucher
38bb4226 6a6ef5ee

+6 -1
+6 -1
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
··· 1144 1144 1145 1145 if (q->properties.type == KFD_QUEUE_TYPE_SDMA || 1146 1146 q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) { 1147 + dqm_lock(dqm); 1147 1148 retval = allocate_sdma_queue(dqm, q); 1149 + dqm_unlock(dqm); 1148 1150 if (retval) 1149 1151 goto out; 1150 1152 } ··· 1205 1203 deallocate_doorbell(qpd, q); 1206 1204 out_deallocate_sdma_queue: 1207 1205 if (q->properties.type == KFD_QUEUE_TYPE_SDMA || 1208 - q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) 1206 + q->properties.type == KFD_QUEUE_TYPE_SDMA_XGMI) { 1207 + dqm_lock(dqm); 1209 1208 deallocate_sdma_queue(dqm, q); 1209 + dqm_unlock(dqm); 1210 + } 1210 1211 out: 1211 1212 return retval; 1212 1213 }