lock debugging warning, probably bcm2835-isp related

Open
#4,160 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
c, linux, raspberry-pi

Research direction

Reproduce on an RPi4 using the bcm2711_defconfig debug options and load bcm2835_isp. Start with kernel/locking/mutex.c:938 and the trace through _vb2_fop_release in videobuf2_v4l2, then compare dmesg with bcm2835_isp loaded or blacklisted. Done means identifying and correcting the lock warning without introducing warnings under the listed lock-debug configuration.

Written by the indexing model from the issue text.

Description

Describe the bug
Building rpi-5.10.y with various lock debugging options enabled gives a kernel warning shortly after bcm2835 isp is loaded. The warning doesn't show up when bcm2835_isp is blacklisted.

[   13.933370] ------------[ cut here ]------------
[   13.937109] WARNING: CPU: 3 PID: 271 at kernel/locking/mutex.c:938 __mutex_lock+0x88c/0xac8
[   13.941159] DEBUG_LOCKS_WARN_ON(lock->magic != lock)
[   13.941177] Modules linked in: hid_logitech_dj(+) brcmfmac brcmutil sha256_generic cfg80211 bcm2835_codec(C) bcm2835_v4l2(C) rfkill v4l2_mem2mem videobuf2_vmalloc bcm2835_isp(C) bcm2835_mmal_vchiq(C) videobuf2_dma_contig videobuf2_memops videobuf2_v4l2 videobuf2_common raspberrypi_hwmon videodev vc_sm_cma(C) mc rpivid_mem nvmem_rmem uio_pdrv_genirq uio ip_tables x_tables ipv6
[   13.953252] CPU: 3 PID: 271 Comm: v4l_id Tainted: G         C        5.10.16-v7l+ #1
[   13.957181] Hardware name: BCM2711
[   13.961306] Backtrace: 
[   13.965480] [<c0caa6e0>] (dump_backtrace) from [<c0caaa8c>] (show_stack+0x20/0x24)
[   13.969475]  r7:ffffffff r6:00000000 r5:60000013 r4:c14f2a40
[   13.973513] [<c0caaa6c>] (show_stack) from [<c0cafc10>] (dump_stack+0xcc/0xf8)
[   13.977875] [<c0cafb44>] (dump_stack) from [<c0222370>] (__warn+0xfc/0x128)
[   13.982119]  r10:c1b7a670 r9:00000009 r8:c0cba0b0 r7:000003aa r6:00000009 r5:c0cba0b0
[   13.986356]  r4:c103146c r3:c1409094
[   13.990757] [<c0222274>] (__warn) from [<c0cab278>] (warn_slowpath_fmt+0xa4/0xd8)
[   13.994841]  r7:000003aa r6:c103146c r5:c1409048 r4:c102b64c
[   13.998921] [<c0cab1d8>] (warn_slowpath_fmt) from [<c0cba0b0>] (__mutex_lock+0x88c/0xac8)
[   14.003149]  r9:c4d105c4 r8:c2bc3900 r7:00000000 r6:c4614440 r5:00000000 r4:c4614914
[   14.007481] [<c0cb9824>] (__mutex_lock) from [<c0cba318>] (mutex_lock_nested+0x2c/0x34)
[   14.011839]  r10:c1409048 r9:c4d105c4 r8:c2bc3900 r7:c3409c10 r6:c4614440 r5:c4cff7c0
[   14.016106]  r4:c4614914
[   14.020331] [<c0cba2ec>] (mutex_lock_nested) from [<bf102b88>] (_vb2_fop_release+0x38/0x98 [videobuf2_v4l2])
[   14.024856] [<bf102b50>] (_vb2_fop_release [videobuf2_v4l2]) from [<bf102c1c>] (vb2_fop_release+0x34/0x38 [videobuf2_v4l2])
[   14.029443]  r7:c3409c10 r6:000a001d r5:c4cff7c0 r4:c4cff7c0
[   14.033803] [<bf102be8>] (vb2_fop_release [videobuf2_v4l2]) from [<bf1176e4>] (v4l2_release+0xdc/0xe8 [videodev])
[   14.038373]  r5:c4cff7c0 r4:c4614440
[   14.042922] [<bf117608>] (v4l2_release [videodev]) from [<c049d810>] (__fput+0xa4/0x270)
[   14.047345]  r5:c4519dd8 r4:c4cff7c0
[   14.051827] [<c049d76c>] (__fput) from [<c049d9f4>] (____fput+0x18/0x1c)
[   14.056313]  r9:c4d105c4 r8:c102df88 r7:c156be6c r6:c4d10000 r5:c4d10574 r4:00000000
[   14.060861] [<c049d9dc>] (____fput) from [<c024b10c>] (task_work_run+0xa8/0xe8)
[   14.065307] [<c024b064>] (task_work_run) from [<c020c390>] (do_work_pending+0x618/0x620)
[   14.069911]  r9:c4ce9fb0 r8:5ac3c35a r7:fffffe30 r6:00000084 r5:c0200204 r4:ffffe000
[   14.074300] [<c020bd78>] (do_work_pending) from [<c0200074>] (slow_work_pending+0xc/0x20)
[   14.078611] Exception stack(0xc4ce9fb0 to 0xc4ce9ff8)
[   14.082840] 9fa0:                                     00000000 00000000 0000006c 00000000
[   14.087169] 9fc0: 00000000 b6ff1170 00000000 00000006 00000000 00000000 004d1f50 00000000
[   14.091503] 9fe0: 004d1fc4 bef68c28 004c1638 b6f256bc 60000010 00000003
[   14.096096]  r10:00000006 r9:c4ce8000 r8:c0200204 r7:00000006 r6:00000000 r5:b6ff1170
[   14.100508]  r4:00000000
[   14.104866] irq event stamp: 4267
[   14.109156] hardirqs last  enabled at (4267): [<c0cbedc4>] _raw_spin_unlock_irq+0x30/0x50
[   14.109174] hardirqs last disabled at (4266): [<c0cbeae0>] _raw_spin_lock_irq+0x7c/0x80
[   14.109200] softirqs last  enabled at (3752): [<c02016f4>] __do_softirq+0x34c/0x60c
[   14.121955] softirqs last disabled at (3741): [<c022a478>] irq_exit+0x16c/0x1d4
[   14.121973] ---[ end trace c788e04c364b4c07 ]---

To reproduce
Build RPi4 kernel with lock debugging enabled

make bcm2711_defconfig
scripts/config \
	-e CONFIG_PROVE_LOCKING \
	-e CONFIG_DEBUG_RT_MUTEXES \
	-e CONFIG_DEBUG_SPINLOCK \
	-e CONFIG_DEBUG_MUTEXES \
	-e CONFIG_DEBUG_RWSEMS \
	-e CONFIG_DEBUG_LOCK_ALLOC \
	-e CONFIG_DEBUG_ATOMIC_SLEEP

Expected behaviour
No lock related warnings are shown.

System
RPi4 4GB, fully updated RPiOS lite with latest rpi-update kernel/firmware (Feb 16), kernel built from rpi-5.10.y branch with above options.

Logs
dmesg with warning: http://ix.io/2Qco
dmesg with bcm2835_isp blacklisted: http://ix.io/2Qcr

Additional context
I initially noticed the warning when enabling kernel debug options in LibreELEC

Dominant language
C
Stars
13.2k
Forks
5.5k
Avg merge
2d 21h
Merged PRs (30d)
21

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from raspberrypi/linux

All issues in raspberrypi/linux

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.