From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Koenig, Christian" Subject: Re: [BUG] gpu: drm: amdgpu: Possible sleep-in-atomic-context bugs in amdgpu_uvd_ring_begin_use() Date: Sat, 15 Sep 2018 09:01:38 +0000 Message-ID: <3fe8b580-e94c-42bc-a4f8-54d8d44cbda2@email.android.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1892635747==" Return-path: In-Reply-To: Content-Language: de-DE List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: Jia-Ju Bai Cc: "airlied@linux.ie" , Linux Kernel Mailing List , "dri-devel@lists.freedesktop.org" , "amd-gfx@lists.freedesktop.org" , "Deucher, Alexander" List-Id: amd-gfx.lists.freedesktop.org --===============1892635747== Content-Language: de-DE Content-Type: multipart/alternative; boundary="_000_3fe8b580e94c42bca4f854d8d44cbda2emailandroidcom_" --_000_3fe8b580e94c42bca4f854d8d44cbda2emailandroidcom_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable 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 : 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 --_000_3fe8b580e94c42bca4f854d8d44cbda2emailandroidcom_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
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 <bai= jiaju1990@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_rre= g

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
--_000_3fe8b580e94c42bca4f854d8d44cbda2emailandroidcom_-- --===============1892635747== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============1892635747==--