Skip to content

Commit ccb7bb1

Browse files
charleskeepaxvinodkoul
authored andcommitted
soundwire: Move handle_nested_irq outside of sdw_dev_lock
The sdw_dev_lock protects the SoundWire driver callbacks against the probed flag, which is used to skip the callbacks if the driver gets removed. For more information see commit bd29c00 ("soundwire: revisit driver bind/unbind and callbacks"). However, this lock is a frequent source of mutex inversions. Many audio operations eventually hit the hardware resulting in a SoundWire callback, this means that typically the driver has the locking order ALSA/ASoC locks -> sdw_dev_lock. Conversely, the IRQ comes in directly from the SoundWire hardware, but then will often want to access ALSA/ASoC, such as updating something in DAPM or an ALSA control. This gives the other lock order sdw_dev_lock -> ALSA/ASoC locks. When the IRQ handling was initially added to SoundWire this was through a callback mechanism. As such it required being covered by the lock because the callbacks are part of the sdw_driver structure and are thus present regardless of if the driver is currently probed. Since then a newer mechanism using the IRQ framework has been added, which is currently covered by the same lock but this isn't actually required. Handlers for the IRQ framework are registered in probe and should by released during remove, thus the IRQ framework will have already unbound the IRQ before the slave driver is removed. Avoid the aforementioned mutex inversion by moving the handle_nested_irq call outside of the sdw_dev_lock. Signed-off-by: Charles Keepax <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 99d4a6e commit ccb7bb1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/soundwire/bus.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,15 +1753,15 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave)
17531753

17541754
/* Update the Slave driver */
17551755
if (slave_notify) {
1756+
if (slave->prop.use_domain_irq && slave->irq)
1757+
handle_nested_irq(slave->irq);
1758+
17561759
mutex_lock(&slave->sdw_dev_lock);
17571760

17581761
if (slave->probed) {
17591762
struct device *dev = &slave->dev;
17601763
struct sdw_driver *drv = drv_to_sdw_driver(dev->driver);
17611764

1762-
if (slave->prop.use_domain_irq && slave->irq)
1763-
handle_nested_irq(slave->irq);
1764-
17651765
if (drv->ops && drv->ops->interrupt_callback) {
17661766
slave_intr.sdca_cascade = sdca_cascade;
17671767
slave_intr.control_port = clear;

0 commit comments

Comments
 (0)