* [BUG] gpu: drm: amdgpu: Possible sleep-in-atomic-context bugs in amdgpu_uvd_ring_begin_use()
@ 2018-09-15 8:59 Jia-Ju Bai
2018-09-15 9:01 ` Koenig, Christian
0 siblings, 1 reply; 7+ messages in thread
From: Jia-Ju Bai @ 2018-09-15 8:59 UTC (permalink / raw)
To: alexander.deucher, christian.koenig, David1.Zhou, airlied
Cc: amd-gfx, dri-devel, Linux Kernel Mailing List
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_uvd
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
drivers/gpu/drm/amd/amdgpu/vi.c, 207:
amdgpu_mm_wreg in vi_gc_cac_rreg
drivers/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_uvd
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
drivers/gpu/drm/amd/amdgpu/soc15.c, 106:
amdgpu_mm_wreg in soc15_pcie_rreg
drivers/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_uvd
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
drivers/gpu/drm/amd/amdgpu/cik.c, 139:
amdgpu_mm_wreg in cik_uvd_ctx_wreg
drivers/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_uvd
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c, 126:
amdgpu_mm_wreg in dce_v6_0_audio_endpt_rreg
drivers/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
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [BUG] gpu: drm: amdgpu: Possible sleep-in-atomic-context bugs in amdgpu_uvd_ring_begin_use()
2018-09-15 8:59 [BUG] gpu: drm: amdgpu: Possible sleep-in-atomic-context bugs in amdgpu_uvd_ring_begin_use() Jia-Ju Bai
@ 2018-09-15 9:01 ` Koenig, Christian
2018-09-15 9:05 ` Jia-Ju Bai
0 siblings, 1 reply; 7+ messages in thread
From: Koenig, Christian @ 2018-09-15 9:01 UTC (permalink / raw)
To: Jia-Ju Bai
Cc: airlied@linux.ie, Linux Kernel Mailing List,
dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
Deucher, Alexander
[-- Attachment #1.1: Type: text/plain, Size: 3277 bytes --]
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 <baijiaju1990@gmail.com>:
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_uvd
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
drivers/gpu/drm/amd/amdgpu/vi.c, 207:
amdgpu_mm_wreg in vi_gc_cac_rreg
drivers/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_uvd
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
drivers/gpu/drm/amd/amdgpu/soc15.c, 106:
amdgpu_mm_wreg in soc15_pcie_rreg
drivers/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_uvd
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
drivers/gpu/drm/amd/amdgpu/cik.c, 139:
amdgpu_mm_wreg in cik_uvd_ctx_wreg
drivers/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_uvd
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c, 126:
amdgpu_mm_wreg in dce_v6_0_audio_endpt_rreg
drivers/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
[-- Attachment #1.2: Type: text/html, Size: 4813 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [BUG] gpu: drm: amdgpu: Possible sleep-in-atomic-context bugs in amdgpu_uvd_ring_begin_use()
2018-09-15 9:01 ` Koenig, Christian
@ 2018-09-15 9:05 ` Jia-Ju Bai
0 siblings, 0 replies; 7+ messages in thread
From: Jia-Ju Bai @ 2018-09-15 9:05 UTC (permalink / raw)
To: Koenig, Christian
Cc: airlied@linux.ie, Linux Kernel Mailing List,
dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
Deucher, Alexander
[-- Attachment #1.1: Type: text/plain, Size: 3652 bytes --]
Thanks for your reply.
On 2018/9/15 17:01, Koenig, Christian wrote:
> 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
>
> Regards,
> Christian.
>
> Am 15.09.2018 10:59 schrieb Jia-Ju Bai <baijiaju1990@gmail.com>:
> 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_uvd
> drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
> amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
> [FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
> drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
> amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
> amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
> drivers/gpu/drm/amd/amdgpu/vi.c, 207:
> amdgpu_mm_wreg in vi_gc_cac_rreg
> drivers/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_uvd
> drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
> amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
> [FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
> drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
> amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
> amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
> drivers/gpu/drm/amd/amdgpu/soc15.c, 106:
> amdgpu_mm_wreg in soc15_pcie_rreg
> drivers/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_uvd
> drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
> amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
> [FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
> drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
> amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
> amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
> drivers/gpu/drm/amd/amdgpu/cik.c, 139:
> amdgpu_mm_wreg in cik_uvd_ctx_wreg
> drivers/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_uvd
> drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
> amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
> [FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
> drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
> amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
> amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
> drivers/gpu/drm/amd/amdgpu/dce_v6_0.c, 126:
> amdgpu_mm_wreg in dce_v6_0_audio_endpt_rreg
> drivers/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
[-- Attachment #1.2: Type: text/html, Size: 6300 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [BUG] gpu: drm: amdgpu: Possible sleep-in-atomic-context bugs in amdgpu_uvd_ring_begin_use()
@ 2018-09-15 9:10 Koenig, Christian
2018-09-15 9:18 ` Jia-Ju Bai
0 siblings, 1 reply; 7+ messages in thread
From: Koenig, Christian @ 2018-09-15 9:10 UTC (permalink / raw)
To: Jia-Ju Bai
Cc: Zhou, David(ChunMing), airlied-cv59FeDIM0c@public.gmane.org,
Linux Kernel Mailing List,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
Deucher, Alexander
[-- Attachment #1.1: Type: text/plain, Size: 3906 bytes --]
amdgpu_ring_alloc() does call amdgpu_uvd_begin_use(), but never in the call chain you proposed.
Thinking about it I actually don't see a way a statically analysis could ever figure that out.
Christian.
Am 15.09.2018 11:05 schrieb Jia-Ju Bai <baijiaju1990@gmail.com>:
Thanks for your reply.
On 2018/9/15 17:01, Koenig, Christian wrote:
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
Regards,
Christian.
Am 15.09.2018 10:59 schrieb Jia-Ju Bai <baijiaju1990@gmail.com><mailto:baijiaju1990@gmail.com>:
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_uvd
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
drivers/gpu/drm/amd/amdgpu/vi.c, 207:
amdgpu_mm_wreg in vi_gc_cac_rreg
drivers/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_uvd
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
drivers/gpu/drm/amd/amdgpu/soc15.c, 106:
amdgpu_mm_wreg in soc15_pcie_rreg
drivers/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_uvd
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
drivers/gpu/drm/amd/amdgpu/cik.c, 139:
amdgpu_mm_wreg in cik_uvd_ctx_wreg
drivers/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_uvd
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
[FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c, 126:
amdgpu_mm_wreg in dce_v6_0_audio_endpt_rreg
drivers/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
[-- Attachment #1.2: Type: text/html, Size: 5765 bytes --]
[-- Attachment #2: Type: text/plain, Size: 154 bytes --]
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [BUG] gpu: drm: amdgpu: Possible sleep-in-atomic-context bugs in amdgpu_uvd_ring_begin_use()
2018-09-15 9:10 Koenig, Christian
@ 2018-09-15 9:18 ` Jia-Ju Bai
[not found] ` <9dd9f4ed-f338-8970-b29e-200ef0eafb62-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Jia-Ju Bai @ 2018-09-15 9:18 UTC (permalink / raw)
To: Koenig, Christian
Cc: airlied@linux.ie, Linux Kernel Mailing List,
dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
Deucher, Alexander
[-- Attachment #1.1: Type: text/plain, Size: 4999 bytes --]
Sorry, I am still not clear why the call chain I proposed is incorrect...
I find a conditional in amdgpu_mm_wreg():
if (!(acc_flags & AMDGPU_REGS_NO_KIQ) && amdgpu_sriov_runtime(adev))
return amdgpu_virt_kiq_wreg(adev, reg, v);
Is amdgpu_virt_kiq_wreg() never called from WREG32() or RREG32()?
Best wishes,
Jia-Ju Bai
On 2018/9/15 17:10, Koenig, Christian wrote:
> amdgpu_ring_alloc() does call amdgpu_uvd_begin_use(), but never in the
> call chain you proposed.
>
> Thinking about it I actually don't see a way a statically analysis
> could ever figure that out.
>
> Christian.
>
> Am 15.09.2018 11:05 schrieb Jia-Ju Bai <baijiaju1990@gmail.com>:
>
> Thanks for your reply.
>
> On 2018/9/15 17:01, Koenig, Christian wrote:
>
> 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
>
>
> Regards,
> Christian.
>
> Am 15.09.2018 10:59 schrieb Jia-Ju Bai
> <baijiaju1990@gmail.com> <mailto:baijiaju1990@gmail.com>:
> 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_uvd
> drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
> amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
> [FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
> drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
> amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
> amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
> drivers/gpu/drm/amd/amdgpu/vi.c, 207:
> amdgpu_mm_wreg in vi_gc_cac_rreg
> drivers/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_uvd
> drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
> amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
> [FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
> drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
> amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
> amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
> drivers/gpu/drm/amd/amdgpu/soc15.c, 106:
> amdgpu_mm_wreg in soc15_pcie_rreg
> drivers/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_uvd
> drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
> amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
> [FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
> drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
> amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
> amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
> drivers/gpu/drm/amd/amdgpu/cik.c, 139:
> amdgpu_mm_wreg in cik_uvd_ctx_wreg
> drivers/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_uvd
> drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c, 1154:
> amdgpu_dpm_enable_uvd in amdgpu_uvd_ring_begin_use
> drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c, 80:
> [FUNC_PTR]amdgpu_uvd_ring_begin_use in amdgpu_ring_alloc
> drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c, 199:
> amdgpu_ring_alloc in amdgpu_virt_kiq_wreg
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c, 207:
> amdgpu_virt_kiq_wreg in amdgpu_mm_wreg
> drivers/gpu/drm/amd/amdgpu/dce_v6_0.c, 126:
> amdgpu_mm_wreg in dce_v6_0_audio_endpt_rreg
> drivers/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
>
>
>
[-- Attachment #1.2: Type: text/html, Size: 9882 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-09-15 9:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-15 8:59 [BUG] gpu: drm: amdgpu: Possible sleep-in-atomic-context bugs in amdgpu_uvd_ring_begin_use() Jia-Ju Bai
2018-09-15 9:01 ` Koenig, Christian
2018-09-15 9:05 ` Jia-Ju Bai
-- strict thread matches above, loose matches on Subject: below --
2018-09-15 9:10 Koenig, Christian
2018-09-15 9:18 ` Jia-Ju Bai
[not found] ` <9dd9f4ed-f338-8970-b29e-200ef0eafb62-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-09-15 9:23 ` Koenig, Christian
2018-09-15 9:33 ` Jia-Ju Bai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.