ARM: OMAP2+: iommu: fix sleeping lock usage in atomic context bug
The function omap_iommu_dra7_emu_swsup_config() implements the
workaround for DRA7 DSP MStandby errata i879, and uses a mutex for
providing mutual exclusion between the two DSP subsystems on DRA7
disabling the HW_AUTO mode on the EMU clock domain. This function
is called in an atomic context though (spinlocks are acquired in
omap_iommu_attach_dev()), and reports the following BUG:
remoteproc3: powering up 41000000.dsp
remoteproc3: Booting fw image dra7-dsp2-fw.xe66, size 6631556
BUG: sleeping function called from invalid context at kernel/locking/mutex.c:616
in_atomic(): 1, irqs_disabled(): 0, pid: 923, name: kworker/1:2
6 locks held by kworker/1:2/923:
#0: ("events"){.+.+.+}, at: [<c0062088>] process_one_work+0x124/0x8d4
#1: ((&fw_work->work)){+.+.+.}, at: [<c0062088>] process_one_work+0x124/0x8d4
#2: (&dev->mutex){......}, at: [<c04d6644>] device_attach+0x18/0x8c
#3: (&rproc->lock){+.+.+.}, at: [<c05e5ad8>] rproc_boot+0x24/0x564
#4: (&(&omap_domain->lock)->rlock){+.+...}, at: [<c0491d54>] omap_iommu_attach_dev+0x38/0x434
#5: (&(&obj->iommu_lock)->rlock){+.+...}, at: [<c0491e8c>] omap_iommu_attach_dev+0x170/0x434
Preemption disabled at:[< (null)>] (null)
CPU: 1 PID: 923 Comm: kworker/1:2 Not tainted 4.1.13-01787-gaa3bf4ce5e05 #4
Hardware name: Generic DRA74X (Flattened Device Tree)
Workqueue: events request_firmware_work_func
[<c0018e78>] (unwind_backtrace) from [<c00141e0>] (show_stack+0x10/0x14)
[<c00141e0>] (show_stack) from [<c0737c80>] (dump_stack+0x80/0xc8)
[<c0737c80>] (dump_stack) from [<c073bc88>] (mutex_lock_nested+0x24/0x48c)
[<c073bc88>] (mutex_lock_nested) from [<c003ebf8>] (omap_iommu_dra7_emu_swsup_config+0x38/0x11c)
[<c003ebf8>] (omap_iommu_dra7_emu_swsup_config) from [<c003ed5c>] (omap_iommu_set_pwrdm_constraint+0x80/0xc0)
[<c003ed5c>] (omap_iommu_set_pwrdm_constraint) from [<c0491ec0>] (omap_iommu_attach_dev+0x1a4/0x434)
[<c0491ec0>] (omap_iommu_attach_dev) from [<c048da08>] (iommu_attach_device+0x1c/0x28c)
[<c048da08>] (iommu_attach_device) from [<c05e5d5c>] (rproc_boot+0x2a8/0x564)
[<c05e5d5c>] (rproc_boot) from [<c05e733c>] (rproc_virtio_find_vqs+0x1bc/0x220)
[<c05e733c>] (rproc_virtio_find_vqs) from [<bf0013dc>] (rpmsg_probe+0xa4/0x400 [virtio_rpmsg_bus])
[<bf0013dc>] (rpmsg_probe [virtio_rpmsg_bus]) from [<c044fbf4>] (virtio_dev_probe+0x1e8/0x2d0)
[<c044fbf4>] (virtio_dev_probe) from [<c04d68f8>] (driver_probe_device+0x1f0/0x42c)
[<c04d68f8>] (driver_probe_device) from [<c04d4bd4>] (bus_for_each_drv+0x64/0x98)
[<c04d4bd4>] (bus_for_each_drv) from [<c04d66a0>] (device_attach+0x74/0x8c)
[<c04d66a0>] (device_attach) from [<c04d5be0>] (bus_probe_device+0x88/0xb0)
[<c04d5be0>] (bus_probe_device) from [<c04d3db4>] (device_add+0x3e0/0x5a8)
[<c04d3db4>] (device_add) from [<c044f824>] (register_virtio_device+0xa8/0xf8)
[<c044f824>] (register_virtio_device) from [<c05e75b0>] (rproc_add_virtio_dev+0x3c/0x98)
[<c05e75b0>] (rproc_add_virtio_dev) from [<c05e4630>] (rproc_handle_vdev+0x294/0x384)
[<c05e4630>] (rproc_handle_vdev) from [<c05e47b0>] (rproc_handle_resources+0x90/0x1b8)
[<c05e47b0>] (rproc_handle_resources) from [<c05e49c0>] (rproc_fw_config_virtio+0xe8/0xf4)
[<c05e49c0>] (rproc_fw_config_virtio) from [<c04ed56c>] (request_firmware_work_func+0x30/0x50)
[<c04ed56c>] (request_firmware_work_func) from [<c0062168>] (process_one_work+0x204/0x8d4)
[<c0062168>] (process_one_work) from [<c006286c>] (worker_thread+0x34/0x4d8)
[<c006286c>] (worker_thread) from [<c00687dc>] (kthread+0xe0/0x100)
[<c00687dc>] (kthread) from [<c0010378>] (ret_from_fork+0x14/0x3c)
Fix this invalid sleeping function invocation in atomic context BUG
by converting the mutex into a spinlock.
Reported-by:
Carlos Hernandez <ceh@ti.com>
Fixes: ffd06e9c ("ARM: OMAP2+: Add workaround for DRA7 DSP MStandby errata i879")
Signed-off-by:
Suman Anna <s-anna@ti.com>
Loading
Please sign in to comment