gpu: drm: amdgpu: Possible sleep-in-atomic-context bugs in amdgpu_uvd_ring_begin_use()
The driver may sleep with holding a spinlock.
The function call paths (from bottom to top) in Linux-4.17 are:
[FUNC] mutex_lock_nested drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c, 1477:
mutex_lock_nested in amdgpu_dpm_enable_uvddrivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_usedrivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_allocdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wregdrivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wregdrivers/gpu/drm/amd/amdgpu/vi.c, 207:
amdgpu_mm_wreg in vi_gc_cac_rregdrivers/gpu/drm/amd/amdgpu/vi.c, 206:
_raw_spin_lock_irqsave in vi_gc_cac_rreg
[FUNC] mutex_lock_nested drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c, 1477:
mutex_lock_nested in amdgpu_dpm_enable_uvddrivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_usedrivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_allocdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wregdrivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wregdrivers/gpu/drm/amd/amdgpu/soc15.c, 106:
amdgpu_mm_wreg in soc15_pcie_rregdrivers/gpu/drm/amd/amdgpu/soc15.c, 105:
_raw_spin_lock_irqsave in soc15_pcie_rreg
[FUNC] mutex_lock_nested drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c, 1477:
mutex_lock_nested in amdgpu_dpm_enable_uvddrivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_usedrivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_allocdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wregdrivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wregdrivers/gpu/drm/amd/amdgpu/cik.c, 139:
amdgpu_mm_wreg in cik_uvd_ctx_wregdrivers/gpu/drm/amd/amdgpu/cik.c, 138:
_raw_spin_lock_irqsave in cik_uvd_ctx_wreg
[FUNC] mutex_lock_nested drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c, 1477:
mutex_lock_nested in amdgpu_dpm_enable_uvddrivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_usedrivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_allocdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wregdrivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wregdrivers/gpu/drm/amd/amdgpu/dce_v6_0.c, 126:
amdgpu_mm_wreg in dce_v6_0_audio_endpt_rregdrivers/gpu/drm/amd/amdgpu/dce_v6_0.c, 125:
_raw_spin_lock_irqsave in dce_v6_0_audio_endpt_rreg
Note that [FUNC_PTR] means a function pointer call is used.
These bugs are found by my static analysis tool DSAC.
Best wishes,
Jia-Ju Bai
Sorry to say that but your analysis tool is buggy.
The proposed call paths will never trigger.
Regards,
Christian.
Am 15.09.2018 10:59 schrieb Jia-Ju Bai <[email protected]>:
The driver may sleep with holding a spinlock.
The function call paths (from bottom to top) in Linux-4.17 are:
[FUNC] mutex_lock_nested drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c, 1477:
mutex_lock_nested in amdgpu_dpm_enable_uvddrivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_usedrivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_allocdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wregdrivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wregdrivers/gpu/drm/amd/amdgpu/vi.c, 207:
amdgpu_mm_wreg in vi_gc_cac_rregdrivers/gpu/drm/amd/amdgpu/vi.c, 206:
_raw_spin_lock_irqsave in vi_gc_cac_rreg
[FUNC] mutex_lock_nested drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c, 1477:
mutex_lock_nested in amdgpu_dpm_enable_uvddrivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_usedrivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_allocdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wregdrivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wregdrivers/gpu/drm/amd/amdgpu/soc15.c, 106:
amdgpu_mm_wreg in soc15_pcie_rregdrivers/gpu/drm/amd/amdgpu/soc15.c, 105:
_raw_spin_lock_irqsave in soc15_pcie_rreg
[FUNC] mutex_lock_nested drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c, 1477:
mutex_lock_nested in amdgpu_dpm_enable_uvddrivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_usedrivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_allocdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wregdrivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wregdrivers/gpu/drm/amd/amdgpu/cik.c, 139:
amdgpu_mm_wreg in cik_uvd_ctx_wregdrivers/gpu/drm/amd/amdgpu/cik.c, 138:
_raw_spin_lock_irqsave in cik_uvd_ctx_wreg
[FUNC] mutex_lock_nested drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c, 1477:
mutex_lock_nested in amdgpu_dpm_enable_uvddrivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_usedrivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_allocdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wregdrivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wregdrivers/gpu/drm/amd/amdgpu/dce_v6_0.c, 126:
amdgpu_mm_wreg in dce_v6_0_audio_endpt_rregdrivers/gpu/drm/amd/amdgpu/dce_v6_0.c, 125:
_raw_spin_lock_irqsave in dce_v6_0_audio_endpt_rreg
Note that [FUNC_PTR] means a function pointer call is used.
These bugs are found by my static analysis tool DSAC.
Best wishes,
Jia-Ju Bai
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thanks for your reply.
Quoted 3 lines · Christian
Sorry to say that but your analysis tool is buggy.
The proposed call paths will never trigger.
Could you please explain which piece of the call path is incorrect? I am not very sure of my function pointer analysis.
Does amdgpu_ring_alloc() never calls amdgpu_uvd_ring_begin_use()?
Thanks in advance.
Best wishes,
Jia-Ju Bai
Quoted 72 lines
Regards,
Christian.Am 15.09.2018 10:59 schrieb Jia-Ju Bai <[email protected]>:
The driver may sleep with holding a spinlock.
The function call paths (from bottom to top) in Linux-4.17 are:[FUNC]
mutex_lock_nesteddrivers/gpu/drm/amd/amdgpu/amdgpu_pm.c, 1477:
mutex_lock_nestedinamdgpu_dpm_enable_uvddrivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvdinamdgpu_uvd_ring_begin_usedrivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use inamdgpu_ring_allocdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_allocinamdgpu_virt_kiq_wregdrivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreginamdgpu_mm_wregdrivers/gpu/drm/amd/amdgpu/vi.c, 207:
amdgpu_mm_wreginvi_gc_cac_rregdrivers/gpu/drm/amd/amdgpu/vi.c, 206:
_raw_spin_lock_irqsaveinvi_gc_cac_rreg[FUNC]
mutex_lock_nesteddrivers/gpu/drm/amd/amdgpu/amdgpu_pm.c, 1477:
mutex_lock_nestedinamdgpu_dpm_enable_uvddrivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvdinamdgpu_uvd_ring_begin_usedrivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use inamdgpu_ring_allocdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_allocinamdgpu_virt_kiq_wregdrivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreginamdgpu_mm_wregdrivers/gpu/drm/amd/amdgpu/soc15.c, 106:
amdgpu_mm_wreginsoc15_pcie_rregdrivers/gpu/drm/amd/amdgpu/soc15.c, 105:
_raw_spin_lock_irqsaveinsoc15_pcie_rreg[FUNC]
mutex_lock_nesteddrivers/gpu/drm/amd/amdgpu/amdgpu_pm.c, 1477:
mutex_lock_nestedinamdgpu_dpm_enable_uvddrivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvdinamdgpu_uvd_ring_begin_usedrivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use inamdgpu_ring_allocdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_allocinamdgpu_virt_kiq_wregdrivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreginamdgpu_mm_wregdrivers/gpu/drm/amd/amdgpu/cik.c, 139:
amdgpu_mm_wregincik_uvd_ctx_wregdrivers/gpu/drm/amd/amdgpu/cik.c, 138:
_raw_spin_lock_irqsaveincik_uvd_ctx_wreg[FUNC]
mutex_lock_nesteddrivers/gpu/drm/amd/amdgpu/amdgpu_pm.c, 1477:
mutex_lock_nestedinamdgpu_dpm_enable_uvddrivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvdinamdgpu_uvd_ring_begin_usedrivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use inamdgpu_ring_allocdrivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_allocinamdgpu_virt_kiq_wregdrivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreginamdgpu_mm_wregdrivers/gpu/drm/amd/amdgpu/dce_v6_0.c, 126:
amdgpu_mm_wregindce_v6_0_audio_endpt_rregdrivers/gpu/drm/amd/amdgpu/dce_v6_0.c, 125:
_raw_spin_lock_irqsaveindce_v6_0_audio_endpt_rreg
Quoted 7 lines
Note that [
FUNC_PTR] means a function pointer call is used.These bugs are found by my static analysis tool DSAC.
Best wishes,
Jia-Ju Bai
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel