linux/drivers/soundwire
Richard Fitzgerald 256a9978eb soundwire: bus: Prevent lockdep asserts when stream has multiple buses
Give the bus_lock and msg_lock of each bus a different unique key
so that it is possible to acquire the locks of multiple buses
without lockdep asserting a possible deadlock.

Using mutex_init() to initialize a mutex gives all those mutexes
the same lock class. Lockdep checking treats it as an error to
attempt to take a mutex while already holding a mutex of the same
class. This causes a lockdep assert when sdw_acquire_bus_lock()
attempts to lock multiple buses, and when do_bank_switch() takes
multiple msg_lock.

[  138.697350] WARNING: possible recursive locking detected
[  138.697366] 6.3.0-test #1 Tainted: G            E
[  138.697380] --------------------------------------------
[  138.697394] play/903 is trying to acquire lock:
[  138.697409] ffff99b8c41aa8c8 (&bus->bus_lock){+.+.}-{3:3}, at:
sdw_prepare_stream+0x52/0x2e0
[  138.697443]
               but task is already holding lock:
[  138.697468] ffff99b8c41af8c8 (&bus->bus_lock){+.+.}-{3:3}, at:
sdw_prepare_stream+0x52/0x2e0
[  138.697493]
               other info that might help us debug this:
[  138.697521]  Possible unsafe locking scenario:

[  138.697540]        CPU0
[  138.697550]        ----
[  138.697559]   lock(&bus->bus_lock);
[  138.697570]   lock(&bus->bus_lock);
[  138.697581]
                *** DEADLOCK ***

Giving each mutex a unique key allows multiple to be held
without triggering a lockdep assert. But note that it does not
allow them to be taken in one order then a different order.
If two mutexes are taken in the order A, B then they must
always be taken in that order otherwise they could deadlock.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20230615141208.679011-1-rf@opensource.cirrus.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2023-06-21 16:31:44 +05:30
..
amd_manager.c soundwire: amd: Improve error message in remove callback 2023-05-29 10:49:46 +05:30
amd_manager.h soundwire: amd: handle SoundWire wake enable interrupt 2023-04-12 15:30:36 +05:30
bus_type.c soundwire updates for 6.3 2023-02-24 17:29:52 -08:00
bus.c soundwire: bus: Prevent lockdep asserts when stream has multiple buses 2023-06-21 16:31:44 +05:30
bus.h soundwire: export sdw_compute_slave_ports() function 2023-04-12 15:30:35 +05:30
cadence_master.c soundwire: cadence: revisit parity injection 2023-05-29 10:49:47 +05:30
cadence_master.h soundwire: intel/cadence: update hardware reset sequence 2023-05-29 10:49:47 +05:30
debugfs.c soundwire: debugfs: Add missing SCP registers 2023-06-08 17:10:32 +05:30
dmi-quirks.c soundwire: dmi-quirks: add new mapping for HP Spectre x360 2023-05-27 16:07:47 +05:30
generic_bandwidth_allocation.c soundwire: bandwidth allocation: Remove pointless variable 2023-06-08 17:09:11 +05:30
intel_ace2x_debugfs.c soundwire: intel_ace2x: add debugfs support 2023-05-27 16:06:45 +05:30
intel_ace2x.c soundwire: intel_ace2x: add pre/post bank switch callbacks 2023-05-27 16:06:47 +05:30
intel_auxdevice.c soundwire: intel_ace2x: add new_peripheral_assigned callback 2023-05-27 16:06:46 +05:30
intel_auxdevice.h soundwire: intel: split auxdevice to different file 2022-11-23 20:11:49 +05:30
intel_bus_common.c soundwire: intel/cadence: update hardware reset sequence 2023-05-29 10:49:47 +05:30
intel_init.c soundwire: intel_init: use eml_lock parameter 2023-05-27 16:06:45 +05:30
intel.c soundwire: intel: read AC timing control register before updating it 2023-05-27 16:08:48 +05:30
intel.h soundwire: intel_ace2x: add debugfs support 2023-05-27 16:06:45 +05:30
Kconfig soundwire: intel_ace2x: fix SND_SOC_SOF_HDA_MLINK dependency 2023-06-21 16:19:44 +05:30
Makefile soundwire: intel_ace2x: add debugfs support 2023-05-27 16:06:45 +05:30
master.c soundwire: master: use pm_runtime_set_active() on add 2020-12-02 12:49:34 +05:30
mipi_disco.c soundwire: fix port_ready[] dynamic allocation in mipi_disco 2020-09-03 16:02:29 +05:30
qcom.c soundwire: qcom: fix storing port config out-of-bounds 2023-06-21 16:31:44 +05:30
slave.c Char / Misc driver changes for 6.0-rc1 2022-08-04 11:05:48 -07:00
stream.c soundwire: stream: Remove unnecessary gotos 2023-06-08 17:09:11 +05:30
sysfs_local.h soundwire: sysfs: add slave status and device number before probe 2020-09-28 11:17:43 +05:30
sysfs_slave_dpn.c soundwire: Fix DEBUG_LOCKS_WARN_ON for uninitialized attribute 2020-11-24 14:08:51 +05:30
sysfs_slave.c soundwire: sysfs: Constify static struct attribute_group 2021-01-19 20:21:20 +05:30