* [PATCH v4 0/4] Allow SoundWire devices to communicate during remove
@ 2026-11-24 16:09 Charles Keepax
2026-11-24 16:09 ` [PATCH v4 1/4] ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ Charles Keepax
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Charles Keepax @ 2026-11-24 16:09 UTC (permalink / raw)
To: vkoul, broonie
Cc: yung-chuan.liao, pierre-louis.bossart, lgirdwood, peter.ujfalusi,
kai.vehmanen, linux-sound, linux-kernel, patches
Currently on Intel systems SoundWire drivers can't communicate with the
device during driver removal. This is primarily because the IRQs are
disabled before the driver remove callback is run. The result of this is
such transactions timeout causing a) a lot of errors in the log and b)
driver remove to take a very long time.
This issue affects cs42l43 and cs42l45, primarily due to both using
regmap IRQ.
soundwire_intel soundwire_intel.link.0: IO transfer timed out, cmd 3 device 6 addr 5d len 1
soundwire sdw-master-0-0: trf on Slave 6 failed:-110 write addr 5d count 0
sdca_class sdw:0:0:01fa:4245:01: Failed to sync masks in 5d
As regmap IRQ is torn down it will mask the interrupts that are
removed. However, there are many valid reasons a driver might want
communicate with the device during removal, others would include
disabling jack detection, putting the device into the lowest possible
power state to save power, etc.
This patch set attempts to address this problem trying to locate the
reason interrupts are disabled, fixing that and then leaving the IRQs
enabled for the remove callback.
Thanks,
Charles
Changes since v3:
- Add IRQ chip to the Intel HDA stuff and use that to call the link
IRQs.
Changes since v2:
- Added a comment in the code for the splitting of device_unregister()
- Fixed missing i++ in error path if devm_add_action_or_reset() fails
during loop over links.
Changes since v1:
- Add a new helper to destroy the children on the bus separately, this
allows the IRQs to be disabled for final cleanup.
- Split device_unregister into device_del and put_device.
Charles Keepax (4):
ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ
soundwire: bus: Don't unassign dev_num before unregistering device
soundwire: bus: Expose a helper to remove devices from the bus
soundwire: intel_auxdevice: Don't disable IRQs before removing
children
drivers/soundwire/bus.c | 55 ++++++++++++++++++++++-------
drivers/soundwire/intel_auxdevice.c | 17 ++++++++-
drivers/soundwire/intel_init.c | 16 +++------
include/linux/soundwire/sdw.h | 1 +
include/linux/soundwire/sdw_intel.h | 6 ++--
sound/soc/sof/intel/hda.c | 42 ++++++++++++++++++----
sound/soc/sof/intel/hda.h | 8 +++++
7 files changed, 112 insertions(+), 33 deletions(-)
--
2.47.3
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v4 1/4] ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ
2026-11-24 16:09 [PATCH v4 0/4] Allow SoundWire devices to communicate during remove Charles Keepax
@ 2026-11-24 16:09 ` Charles Keepax
2026-11-24 16:36 ` sashiko-bot
2026-11-24 16:49 ` Pierre-Louis Bossart
2026-11-24 16:09 ` [PATCH v4 2/4] soundwire: bus: Don't unassign dev_num before unregistering device Charles Keepax
` (2 subsequent siblings)
3 siblings, 2 replies; 12+ messages in thread
From: Charles Keepax @ 2026-11-24 16:09 UTC (permalink / raw)
To: vkoul, broonie
Cc: yung-chuan.liao, pierre-louis.bossart, lgirdwood, peter.ujfalusi,
kai.vehmanen, linux-sound, linux-kernel, patches
Add an IRQ chip into the HDA code that can be used to trigger the
SoundWire IRQ for each link. Currently, only the SoundWire IRQ
is moved over to this IRQ chip, although in time the other IRQ
functions could be too.
This will allow refactoring such that the individual links each
request and free their IRQs locally, rather than having to rely
on looping over a list of links which is tricky to maintain while
destroying the devices.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
New since v3.
drivers/soundwire/intel_auxdevice.c | 10 +++++++
drivers/soundwire/intel_init.c | 16 +++--------
include/linux/soundwire/sdw_intel.h | 6 +++--
sound/soc/sof/intel/hda.c | 42 ++++++++++++++++++++++++-----
sound/soc/sof/intel/hda.h | 8 ++++++
5 files changed, 62 insertions(+), 20 deletions(-)
diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c
index 8bdb2bf1c6446..d84fbe716febc 100644
--- a/drivers/soundwire/intel_auxdevice.c
+++ b/drivers/soundwire/intel_auxdevice.c
@@ -366,6 +366,14 @@ static int intel_link_probe(struct auxiliary_device *auxdev,
/* use generic bandwidth allocation algorithm */
sdw->cdns.bus.compute_params = sdw_compute_params;
+ ret = request_threaded_irq(sdw->link_res->irq, NULL, sdw_cdns_irq,
+ IRQF_SHARED | IRQF_ONESHOT, dev_name(dev),
+ cdns);
+ if (ret) {
+ dev_err(dev, "failed to request IRQ: %d\n", ret);
+ return ret;
+ }
+
ret = sdw_bus_master_add(bus, dev, dev->fwnode);
if (ret) {
dev_err(dev, "sdw_bus_master_add fail: %d\n", ret);
@@ -503,6 +511,8 @@ static void intel_link_remove(struct auxiliary_device *auxdev)
struct sdw_intel *sdw = cdns_to_intel(cdns);
struct sdw_bus *bus = &cdns->bus;
+ free_irq(sdw->link_res->irq, cdns);
+
/*
* Since pm_runtime is already disabled, we don't decrease
* the refcount when the clock_stop_quirk is
diff --git a/drivers/soundwire/intel_init.c b/drivers/soundwire/intel_init.c
index ad48d67fa9358..d08d79f259629 100644
--- a/drivers/soundwire/intel_init.c
+++ b/drivers/soundwire/intel_init.c
@@ -89,6 +89,8 @@ static struct sdw_intel_link_dev *intel_link_dev_register(struct sdw_intel_res *
link->hbus = res->hbus;
+ link->irq = ctx->irq;
+
/* now follow the two-step init/add sequence */
ret = auxiliary_device_init(auxdev);
if (ret < 0) {
@@ -140,18 +142,6 @@ static int sdw_intel_cleanup(struct sdw_intel_ctx *ctx)
return 0;
}
-irqreturn_t sdw_intel_thread(int irq, void *dev_id)
-{
- struct sdw_intel_ctx *ctx = dev_id;
- struct sdw_intel_link_res *link;
-
- list_for_each_entry(link, &ctx->link_list, list)
- sdw_cdns_irq(irq, link->cdns);
-
- return IRQ_HANDLED;
-}
-EXPORT_SYMBOL_NS(sdw_intel_thread, "SOUNDWIRE_INTEL_INIT");
-
static struct sdw_intel_ctx
*sdw_intel_probe_controller(struct sdw_intel_res *res)
{
@@ -215,6 +205,8 @@ static struct sdw_intel_ctx
INIT_LIST_HEAD(&ctx->link_list);
+ ctx->irq = res->irq;
+
for (i = 0; i < count; i++) {
if (!(link_mask & BIT(i)))
continue;
diff --git a/include/linux/soundwire/sdw_intel.h b/include/linux/soundwire/sdw_intel.h
index 9710f2dc04e29..a23b187df283b 100644
--- a/include/linux/soundwire/sdw_intel.h
+++ b/include/linux/soundwire/sdw_intel.h
@@ -5,6 +5,8 @@
#define __SDW_INTEL_H
#include <linux/acpi.h>
+#include <linux/irq.h>
+#include <linux/irqdomain.h>
#include <linux/irqreturn.h>
#include <linux/soundwire/sdw.h>
@@ -299,6 +301,7 @@ struct hdac_bus;
* @shim_base: sdw shim base.
* @alh_base: sdw alh base.
* @peripherals: array representing Peripherals exposed across all enabled links
+ * @irq: Interrupt line for the SoundWire
*/
struct sdw_intel_ctx {
int count;
@@ -312,6 +315,7 @@ struct sdw_intel_ctx {
u32 shim_base;
u32 alh_base;
struct sdw_peripherals *peripherals;
+ int irq;
};
/**
@@ -382,8 +386,6 @@ int sdw_intel_startup(struct sdw_intel_ctx *ctx);
void sdw_intel_exit(struct sdw_intel_ctx *ctx);
-irqreturn_t sdw_intel_thread(int irq, void *dev_id);
-
#define SDW_INTEL_QUIRK_MASK_BUS_DISABLE BIT(1)
struct sdw_intel;
diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
index 9fc95806697e1..06961e5e666ff 100644
--- a/sound/soc/sof/intel/hda.c
+++ b/sound/soc/sof/intel/hda.c
@@ -46,6 +46,22 @@
/* platform specific devices */
#include "shim.h"
+static int hda_irq_map(struct irq_domain *h, unsigned int virq, irq_hw_number_t hw)
+{
+ struct sof_intel_hda_dev *hdev = h->host_data;
+
+ irq_set_chip_data(virq, hdev);
+ irq_set_chip(virq, &hdev->irq_chip);
+ irq_set_nested_thread(virq, 1);
+ irq_set_noprobe(virq);
+
+ return 0;
+}
+
+static const struct irq_domain_ops hda_domain_ops = {
+ .map = hda_irq_map,
+};
+
#if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE)
/*
@@ -198,7 +214,7 @@ static int hda_sdw_probe(struct snd_sof_dev *sdev)
if (chip->hw_ip_version >= SOF_INTEL_ACE_3_0)
res.mic_privacy = true;
}
- res.irq = sdev->ipc_irq;
+ res.irq = irq_create_mapping(hdev->domain, HDA_IRQ_SDW);
res.handle = hdev->info.handle;
res.parent = sdev->dev;
@@ -260,6 +276,8 @@ static int hda_sdw_exit(struct snd_sof_dev *sdev)
sdw_intel_exit(hdev->sdw);
hdev->sdw = NULL;
+ irq_dispose_mapping(irq_find_mapping(hdev->domain, HDA_IRQ_SDW));
+
hda_sdw_int_enable(sdev, false);
return 0;
@@ -307,9 +325,9 @@ static bool hda_dsp_check_sdw_irq(struct snd_sof_dev *sdev)
return false;
}
-static irqreturn_t hda_dsp_sdw_thread(int irq, void *context)
+static void hda_dsp_sdw_thread(struct sof_intel_hda_dev *hdev)
{
- return sdw_intel_thread(irq, context);
+ handle_nested_irq(irq_find_mapping(hdev->domain, HDA_IRQ_SDW));
}
bool hda_sdw_check_wakeen_irq_common(struct snd_sof_dev *sdev)
@@ -399,9 +417,8 @@ static inline bool hda_dsp_check_sdw_irq(struct snd_sof_dev *sdev)
return false;
}
-static inline irqreturn_t hda_dsp_sdw_thread(int irq, void *context)
+static inline void hda_dsp_sdw_thread(struct sof_intel_hda_dev *hdev)
{
- return IRQ_HANDLED;
}
static inline bool hda_sdw_check_wakeen_irq(struct snd_sof_dev *sdev)
@@ -727,7 +744,7 @@ static irqreturn_t hda_dsp_interrupt_thread(int irq, void *context)
if (hda_dsp_check_sdw_irq(sdev)) {
trace_sof_intel_hda_irq(sdev, "sdw");
- hda_dsp_sdw_thread(irq, hdev->sdw);
+ hda_dsp_sdw_thread(hdev);
if (hda_dsp_sdw_check_mic_privacy_irq(sdev)) {
trace_sof_intel_hda_irq(sdev, "mic privacy");
@@ -883,6 +900,14 @@ int hda_dsp_probe(struct snd_sof_dev *sdev)
sdev->ipc_irq = pci->irq;
}
+ hdev->irq_chip.name = dev_name(sdev->dev);
+ hdev->domain = irq_domain_create_linear(NULL, HDA_IRQ_COUNT,
+ &hda_domain_ops, hdev);
+ if (!hdev->domain) {
+ dev_err(sdev->dev, "failed to create IRQ domain\n");
+ goto remove_irq_domain;
+ }
+
dev_dbg(sdev->dev, "using IPC IRQ %d\n", sdev->ipc_irq);
ret = request_threaded_irq(sdev->ipc_irq, hda_dsp_interrupt_handler,
hda_dsp_interrupt_thread,
@@ -941,6 +966,8 @@ int hda_dsp_probe(struct snd_sof_dev *sdev)
free_ipc_irq:
hda_dsp_ctrl_stop_chip(sdev);
free_irq(sdev->ipc_irq, sdev);
+remove_irq_domain:
+ irq_domain_remove(hdev->domain);
free_irq_vector:
if (sdev->msi_enabled)
pci_free_irq_vectors(pci);
@@ -1011,6 +1038,9 @@ void hda_dsp_remove(struct snd_sof_dev *sdev)
hda_dsp_ctrl_stop_chip(sdev);
free_irq(sdev->ipc_irq, sdev);
+
+ irq_domain_remove(hda->domain);
+
if (sdev->msi_enabled)
pci_free_irq_vectors(pci);
diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h
index 43fb11b247740..29b9feb0daef4 100644
--- a/sound/soc/sof/intel/hda.h
+++ b/sound/soc/sof/intel/hda.h
@@ -466,6 +466,10 @@ struct sof_intel_dsp_bdl {
__le32 ioc;
} __attribute((packed));
+/* HDA IRQs */
+#define HDA_IRQ_SDW 0
+#define HDA_IRQ_COUNT 1
+
#define SOF_HDA_PLAYBACK_STREAMS 16
#define SOF_HDA_CAPTURE_STREAMS 16
#define SOF_HDA_PLAYBACK 0
@@ -580,6 +584,10 @@ struct sof_intel_hda_dev {
* is received from the DSP for the previous message)
*/
struct snd_sof_ipc_msg *delayed_ipc_tx_msg;
+
+ /* Used to distribute IRQs */
+ struct irq_domain *domain;
+ struct irq_chip irq_chip;
};
static inline struct hdac_bus *sof_to_bus(struct snd_sof_dev *s)
--
2.47.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 2/4] soundwire: bus: Don't unassign dev_num before unregistering device
2026-11-24 16:09 [PATCH v4 0/4] Allow SoundWire devices to communicate during remove Charles Keepax
2026-11-24 16:09 ` [PATCH v4 1/4] ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ Charles Keepax
@ 2026-11-24 16:09 ` Charles Keepax
2026-11-24 16:10 ` [PATCH v4 3/4] soundwire: bus: Expose a helper to remove devices from the bus Charles Keepax
2026-11-24 16:10 ` [PATCH v4 4/4] soundwire: intel_auxdevice: Don't disable IRQs before removing children Charles Keepax
3 siblings, 0 replies; 12+ messages in thread
From: Charles Keepax @ 2026-11-24 16:09 UTC (permalink / raw)
To: vkoul, broonie
Cc: yung-chuan.liao, pierre-louis.bossart, lgirdwood, peter.ujfalusi,
kai.vehmanen, linux-sound, linux-kernel, patches
Don't mark dev_num as unassigned until after the driver remove has
been called. The driver may want to communicate with the device
as part of the driver remove operation, so the dev_num should
remain assigned until that has completed. This requires moving from
device_unregister() to manually calling device_del() and device_put()
to ensure that the slave struct isn't freed too early.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
No changes since v3.
drivers/soundwire/bus.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index 15c66effbf4f4..001407fa50ddc 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -175,8 +175,18 @@ static int sdw_delete_slave(struct device *dev, void *data)
sdw_slave_debugfs_exit(slave);
- mutex_lock(&bus->bus_lock);
+ /*
+ * Split device_unregister(), the framework level needs to access
+ * members of the slave structure after the slave driver has been
+ * removed, thus the device_put() needs to be delayed. The device
+ * number needs to be marked as unused and the slave needs to be
+ * removed from the slave list. These can't be done before the
+ * drivers remove callback as the remove callback should still
+ * be able to communicate with the device.
+ */
+ device_del(dev);
+ mutex_lock(&bus->bus_lock);
if (slave->dev_num) { /* clear dev_num if assigned */
clear_bit(slave->dev_num, bus->assigned);
if (bus->ops && bus->ops->put_device_num)
@@ -185,7 +195,8 @@ static int sdw_delete_slave(struct device *dev, void *data)
list_del_init(&slave->node);
mutex_unlock(&bus->bus_lock);
- device_unregister(dev);
+ put_device(dev);
+
return 0;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 3/4] soundwire: bus: Expose a helper to remove devices from the bus
2026-11-24 16:09 [PATCH v4 0/4] Allow SoundWire devices to communicate during remove Charles Keepax
2026-11-24 16:09 ` [PATCH v4 1/4] ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ Charles Keepax
2026-11-24 16:09 ` [PATCH v4 2/4] soundwire: bus: Don't unassign dev_num before unregistering device Charles Keepax
@ 2026-11-24 16:10 ` Charles Keepax
2026-11-24 16:29 ` sashiko-bot
2026-11-24 16:10 ` [PATCH v4 4/4] soundwire: intel_auxdevice: Don't disable IRQs before removing children Charles Keepax
3 siblings, 1 reply; 12+ messages in thread
From: Charles Keepax @ 2026-11-24 16:10 UTC (permalink / raw)
To: vkoul, broonie
Cc: yung-chuan.liao, pierre-louis.bossart, lgirdwood, peter.ujfalusi,
kai.vehmanen, linux-sound, linux-kernel, patches
Some SoundWire controllers may have features such as IRQs that are
needed to support peripheral operation, it is desirable to continue
to support these whilst peripheral drivers are removed. However,
the current sdw_bus_master_delete() monolithically removes the
peripherals and destroys the controller giving no chance for the
controller driver to perform clean up after the slaves are removed,
but before it is itself destroyed.
Split out a separate helper function that only removes the
peripherals, this will allow drivers that require this to sequence
things appropriately. The functionality of the current helper is
left as is, if the peripherals have already been removed the call
to do this is a no-op which allows drivers that don't need this
functionality to remain untouched.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
No changes since v3.
drivers/soundwire/bus.c | 44 +++++++++++++++++++++++++----------
include/linux/soundwire/sdw.h | 1 +
2 files changed, 33 insertions(+), 12 deletions(-)
diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index 001407fa50ddc..5baae0bedaf09 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -169,7 +169,6 @@ EXPORT_SYMBOL(sdw_bus_master_add);
static int sdw_delete_slave(struct device *dev, void *data)
{
struct sdw_slave *slave = dev_to_sdw_dev(dev);
- struct sdw_bus *bus = slave->bus;
pm_runtime_disable(dev);
@@ -186,18 +185,38 @@ static int sdw_delete_slave(struct device *dev, void *data)
*/
device_del(dev);
- mutex_lock(&bus->bus_lock);
- if (slave->dev_num) { /* clear dev_num if assigned */
- clear_bit(slave->dev_num, bus->assigned);
- if (bus->ops && bus->ops->put_device_num)
- bus->ops->put_device_num(bus, slave);
- }
- list_del_init(&slave->node);
- mutex_unlock(&bus->bus_lock);
+ return 0;
+}
- put_device(dev);
+/**
+ * sdw_bus_slaves_delete() - delete all peripherals on a bus
+ * @bus: bus with peripherals to be deleted
+ *
+ * Delete the child devices.
+ */
+void sdw_bus_slaves_delete(struct sdw_bus *bus)
+{
+ device_for_each_child(bus->dev, NULL, sdw_delete_slave);
+}
+EXPORT_SYMBOL(sdw_bus_slaves_delete);
- return 0;
+static void sdw_bus_slaves_put(struct sdw_bus *bus)
+{
+ struct sdw_slave *slave, *tmp;
+
+ list_for_each_entry_safe(slave, tmp, &bus->slaves, node) {
+ mutex_lock(&bus->bus_lock);
+ if (slave->dev_num) { /* clear dev_num if assigned */
+ clear_bit(slave->dev_num, bus->assigned);
+ if (bus->ops && bus->ops->put_device_num)
+ bus->ops->put_device_num(bus, slave);
+ }
+ list_del_init(&slave->node);
+ mutex_unlock(&bus->bus_lock);
+
+ /* See comment in sdw_delete_slave() */
+ put_device(&slave->dev);
+ }
}
/**
@@ -208,7 +227,8 @@ static int sdw_delete_slave(struct device *dev, void *data)
*/
void sdw_bus_master_delete(struct sdw_bus *bus)
{
- device_for_each_child(bus->dev, NULL, sdw_delete_slave);
+ sdw_bus_slaves_delete(bus);
+ sdw_bus_slaves_put(bus);
sdw_irq_delete(bus);
diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
index b8f5ad39e9b37..f83b7f622288a 100644
--- a/include/linux/soundwire/sdw.h
+++ b/include/linux/soundwire/sdw.h
@@ -899,6 +899,7 @@ struct sdw_master_ops {
int sdw_bus_master_add(struct sdw_bus *bus, struct device *parent,
struct fwnode_handle *fwnode);
+void sdw_bus_slaves_delete(struct sdw_bus *bus);
void sdw_bus_master_delete(struct sdw_bus *bus);
void sdw_show_ping_status(struct sdw_bus *bus, bool sync_delay);
--
2.47.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 4/4] soundwire: intel_auxdevice: Don't disable IRQs before removing children
2026-11-24 16:09 [PATCH v4 0/4] Allow SoundWire devices to communicate during remove Charles Keepax
` (2 preceding siblings ...)
2026-11-24 16:10 ` [PATCH v4 3/4] soundwire: bus: Expose a helper to remove devices from the bus Charles Keepax
@ 2026-11-24 16:10 ` Charles Keepax
2026-11-24 16:27 ` sashiko-bot
2026-11-24 18:27 ` Pierre-Louis Bossart
3 siblings, 2 replies; 12+ messages in thread
From: Charles Keepax @ 2026-11-24 16:10 UTC (permalink / raw)
To: vkoul, broonie
Cc: yung-chuan.liao, pierre-louis.bossart, lgirdwood, peter.ujfalusi,
kai.vehmanen, linux-sound, linux-kernel, patches
Currently the auxiliary device for the link disables IRQs before it
calls sdw_bus_master_delete(). This has the side effect that none
of the devices on the link can access their own registers whilst
their remove functions run, because the IRQs are required for bus
transactions to function.
Now that the link auxiliary drivers register their own IRQs and a
core helper is available to destroy the slaves before the master
is destroyed, it is save to update intel_link_remove() to leave
the IRQ enabled whilst the slaves are destroyed.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
Changes since v3:
- Dropped all the link lock and list stuff and just use the IRQ core.
- Removed Pierre's Reviewed-by as things have changed quite
substantively.
drivers/soundwire/intel_auxdevice.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c
index d84fbe716febc..450c3927f0910 100644
--- a/drivers/soundwire/intel_auxdevice.c
+++ b/drivers/soundwire/intel_auxdevice.c
@@ -511,8 +511,6 @@ static void intel_link_remove(struct auxiliary_device *auxdev)
struct sdw_intel *sdw = cdns_to_intel(cdns);
struct sdw_bus *bus = &cdns->bus;
- free_irq(sdw->link_res->irq, cdns);
-
/*
* Since pm_runtime is already disabled, we don't decrease
* the refcount when the clock_stop_quirk is
@@ -521,8 +519,15 @@ static void intel_link_remove(struct auxiliary_device *auxdev)
if (!bus->prop.hw_disabled) {
sdw_intel_debugfs_exit(sdw);
cancel_delayed_work_sync(&cdns->attach_dwork);
- sdw_cdns_enable_interrupt(cdns, false);
}
+
+ sdw_bus_slaves_delete(bus);
+
+ free_irq(sdw->link_res->irq, cdns);
+
+ if (!bus->prop.hw_disabled)
+ sdw_cdns_enable_interrupt(cdns, false);
+
sdw_bus_master_delete(bus);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v4 4/4] soundwire: intel_auxdevice: Don't disable IRQs before removing children
2026-11-24 16:10 ` [PATCH v4 4/4] soundwire: intel_auxdevice: Don't disable IRQs before removing children Charles Keepax
@ 2026-11-24 16:27 ` sashiko-bot
2026-11-24 18:27 ` Pierre-Louis Bossart
1 sibling, 0 replies; 12+ messages in thread
From: sashiko-bot @ 2026-11-24 16:27 UTC (permalink / raw)
To: Charles Keepax; +Cc: linux-sound
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] soundwire: free_irq() called before disabling IRQs in
intel_link_remove()
- [Medium] soundwire: cdns->work races with devres release in
sdw_bus_slaves_delete()
- [Medium] soundwire: missing free_irq() on error path in
intel_link_probe()
--
commit 7c3721ba123431be83148cab636e34ed615878ea
Author: Charles Keepax <ckeepax@opensource.cirrus.com>
soundwire: intel_auxdevice: Don't disable IRQs before removing children
This commit defers freeing the link IRQ and disabling Cadence interrupts
in intel_link_remove() until after sdw_bus_slaves_delete() has removed the
child slave devices.
> diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c
> index d84fbe716febc..450c3927f0910 100644
> --- a/drivers/soundwire/intel_auxdevice.c
> +++ b/drivers/soundwire/intel_auxdevice.c
> @@ -511,8 +511,6 @@ static void intel_link_remove(struct auxiliary_device *auxdev)
> struct sdw_intel *sdw = cdns_to_intel(cdns);
> struct sdw_bus *bus = &cdns->bus;
>
> - free_irq(sdw->link_res->irq, cdns);
> -
> /*
> * Since pm_runtime is already disabled, we don't decrease
> * the refcount when the clock_stop_quirk is
> @@ -521,8 +519,15 @@ static void intel_link_remove(struct auxiliary_device *auxdev)
> if (!bus->prop.hw_disabled) {
> sdw_intel_debugfs_exit(sdw);
> cancel_delayed_work_sync(&cdns->attach_dwork);
> - sdw_cdns_enable_interrupt(cdns, false);
> }
> +
> + sdw_bus_slaves_delete(bus);
[Severity: Medium]
Can cdns_update_slave_status_work() race with sdw_bus_slaves_delete() and
access resources already released by device_del()?
Because commit "soundwire: bus: Don't unassign dev_num before
unregistering device" leaves slave->dev_num set in bus->assigned and the
slave on bus->slaves until sdw_bus_master_delete() calls
sdw_bus_slaves_put(), a concurrent status update work item still looks up
the slave after device_del() has released its devres allocations:
CPU0 CPU1 (kworker)
intel_link_remove()
sdw_bus_slaves_delete(bus)
sdw_delete_slave()
device_del(&slave->dev)
...
devres_release_all()
sdw_irq_dispose_mapping()
irq_dispose_mapping(slave->irq)
/* frees prop->dp0_prop */
cdns_update_slave_status_work()
sdw_handle_slave_status()
sdw_handle_slave_alerts()
handle_nested_irq(slave->irq)
<-- NULL deref / use-after-free
In sdw_handle_slave_alerts(), handle_nested_irq(slave->irq) runs outside
slave->sdw_dev_lock without checking slave->probed after slave->irq has
been disposed. Similarly, if the slave transitions to SDW_SLAVE_ATTACHED,
sdw_initialize_slave() dereferences the devm-freed slave->prop.dp0_prop.
> +
> + free_irq(sdw->link_res->irq, cdns);
> +
> + if (!bus->prop.hw_disabled)
> + sdw_cdns_enable_interrupt(cdns, false);
[Severity: Medium]
Should sdw_cdns_enable_interrupt(cdns, false) be called before free_irq()?
sdw_cdns_enable_interrupt(cdns, false) sets cdns->interrupt_enabled to
false, calls cancel_work_sync(&cdns->work), and then clears
CDNS_MCP_INTMASK. When free_irq() runs first, any in-flight
cdns_update_slave_status_work() waiting in _cdns_xfer_msg() on
cdns->tx_complete has no sdw_cdns_irq() handler registered to service
CDNS_MCP_INT_RX_WL, so each bus transfer blocks for CDNS_TX_TIMEOUT
(500 ms). In addition, while CDNS_MCP_INTMASK remains enabled after
free_irq(), any asserted Cadence interrupt has no handler on
sdw->link_res->irq to clear CDNS_MCP_INTSTAT.
[Severity: Medium]
In intel_link_probe(), added by commit "ASoC: SOF: Intel: Add IRQ chip to
distribute the SoundWire IRQ", does a failure in sdw_bus_master_add() leak
sdw->link_res->irq and leave cdns registered as the IRQ dev_id after devres
frees sdw?
drivers/soundwire/intel_auxdevice.c:intel_link_probe() {
...
ret = request_threaded_irq(sdw->link_res->irq, NULL, sdw_cdns_irq,
IRQF_SHARED | IRQF_ONESHOT, dev_name(dev),
cdns);
if (ret) {
dev_err(dev, "failed to request IRQ: %d\n", ret);
return ret;
}
ret = sdw_bus_master_add(bus, dev, dev->fwnode);
if (ret) {
dev_err(dev, "sdw_bus_master_add fail: %d\n", ret);
return ret;
}
...
}
Because sdw is allocated with devm_kzalloc_obj(dev, *sdw) while
request_threaded_irq() is non-managed, returning without calling
free_irq(sdw->link_res->irq, cdns) leaves sdw_cdns_irq() active on the
shared interrupt line with a freed dev_id pointer.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124161001.702882-1-ckeepax@opensource.cirrus.com?part=4
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 3/4] soundwire: bus: Expose a helper to remove devices from the bus
2026-11-24 16:10 ` [PATCH v4 3/4] soundwire: bus: Expose a helper to remove devices from the bus Charles Keepax
@ 2026-11-24 16:29 ` sashiko-bot
0 siblings, 0 replies; 12+ messages in thread
From: sashiko-bot @ 2026-11-24 16:29 UTC (permalink / raw)
To: Charles Keepax; +Cc: linux-sound
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] soundwire: bus: UAF and disposed IRQ access after
sdw_bus_slaves_delete()
- [Medium] soundwire: bus: unlocked list traversal in
sdw_bus_slaves_put()
--
commit 5d1d7079438eb055e1748b6f548e146aa51c7a6c
Author: Charles Keepax <ckeepax@opensource.cirrus.com>
soundwire: bus: Expose a helper to remove devices from the bus
This commit splits peripheral device removal out of sdw_bus_master_delete()
into a new exported sdw_bus_slaves_delete() helper while deferring slave
list removal, device number release, and put_device() to a new
sdw_bus_slaves_put() helper.
> diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
> index eddff9a5fd35d..c97f6c27fa854 100644
> --- a/drivers/soundwire/bus.c
> +++ b/drivers/soundwire/bus.c
> @@ -169,7 +169,6 @@ EXPORT_SYMBOL(sdw_bus_master_add);
> static int sdw_delete_slave(struct device *dev, void *data)
> {
> struct sdw_slave *slave = dev_to_sdw_dev(dev);
> - struct sdw_bus *bus = slave->bus;
>
> pm_runtime_disable(dev);
>
> @@ -186,18 +185,38 @@ static int sdw_delete_slave(struct device *dev, void *data)
> */
> device_del(dev);
>
> - mutex_lock(&bus->bus_lock);
> - if (slave->dev_num) { /* clear dev_num if assigned */
> - clear_bit(slave->dev_num, bus->assigned);
> - if (bus->ops && bus->ops->put_device_num)
> - bus->ops->put_device_num(bus, slave);
> - }
> - list_del_init(&slave->node);
> - mutex_unlock(&bus->bus_lock);
> + return 0;
> +}
>
> - put_device(dev);
> +/**
> + * sdw_bus_slaves_delete() - delete all peripherals on a bus
> + * @bus: bus with peripherals to be deleted
> + *
> + * Delete the child devices.
> + */
> +void sdw_bus_slaves_delete(struct sdw_bus *bus)
> +{
> + device_for_each_child(bus->dev, NULL, sdw_delete_slave);
> +}
> +EXPORT_SYMBOL(sdw_bus_slaves_delete);
[Severity: High]
Can deferring the bus->assigned and bus->slaves cleanup until
sdw_bus_slaves_put() cause a NULL pointer dereference or use-after-free
when a status update arrives after sdw_delete_slave()?
device_del(dev) runs devres_release_all(&slave->dev), which invokes
sdw_irq_dispose_mapping() to free slave->irq's descriptor (leaving
slave->irq non-zero) and frees devm-allocated slave->prop.dp0_prop.
Because the slave remains in bus->slaves and bus->assigned until the
controller later calls sdw_bus_master_delete(), a concurrent status
update can still reach the deleted slave:
CPU0 CPU1 (status workqueue)
sdw_bus_slaves_delete(bus)
sdw_delete_slave(&slave->dev)
device_del(&slave->dev)
devres_release_all(&slave->dev)
irq_dispose_mapping(slave->irq)
sdw_handle_slave_status(bus, ...)
sdw_handle_slave_alerts(slave)
handle_nested_irq(slave->irq)
<-- NULL irq_desc dereference
Similarly, if a peripheral re-attaches during teardown,
sdw_initialize_slave() runs without checking slave->probed and
dereferences the freed slave->prop.dp0_prop.
> - return 0;
> +static void sdw_bus_slaves_put(struct sdw_bus *bus)
> +{
> + struct sdw_slave *slave, *tmp;
> +
> + list_for_each_entry_safe(slave, tmp, &bus->slaves, node) {
> + mutex_lock(&bus->bus_lock);
> + if (slave->dev_num) { /* clear dev_num if assigned */
> + clear_bit(slave->dev_num, bus->assigned);
> + if (bus->ops && bus->ops->put_device_num)
> + bus->ops->put_device_num(bus, slave);
> + }
> + list_del_init(&slave->node);
> + mutex_unlock(&bus->bus_lock);
> +
> + /* See comment in sdw_delete_slave() */
> + put_device(&slave->dev);
> + }
> }
[Severity: Medium]
Is it safe for list_for_each_entry_safe() to traverse bus->slaves
without holding bus->bus_lock across the iteration?
On controllers whose interrupt handler remains active during
sdw_bus_master_delete() (such as qcom_swrm_remove(), where the IRQ is
managed with devm), a concurrent enumeration interrupt can call
sdw_slave_add(), which modifies bus->slaves under bus->bus_lock via
list_add_tail() and list_del(). Reading the list pointers outside
bus->bus_lock can race with those updates and miss a newly added slave
or follow a removed node. Holding bus->bus_lock around a
while (!list_empty(&bus->slaves)) loop and dropping it only around
put_device(&slave->dev) would avoid the unlocked traversal.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124161001.702882-1-ckeepax@opensource.cirrus.com?part=3
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 1/4] ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ
2026-11-24 16:09 ` [PATCH v4 1/4] ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ Charles Keepax
@ 2026-11-24 16:36 ` sashiko-bot
2026-11-24 16:49 ` Pierre-Louis Bossart
1 sibling, 0 replies; 12+ messages in thread
From: sashiko-bot @ 2026-11-24 16:36 UTC (permalink / raw)
To: Charles Keepax; +Cc: linux-sound
Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [Medium] ASoC: SOF: Intel: swapped error labels and unset ret in
hda_dsp_probe()
- [Medium] soundwire: intel_auxdevice: missing free_irq() in
intel_link_probe()
- [Medium] ASoC: SOF: Intel: undisposed IRQ mapping on hda_sdw_probe()
failure
- [Medium] soundwire: intel_auxdevice: free_irq() called before
disabling link IRQs
- [Medium] ASoC: SOF: Intel: race between hda_sdw_exit() and
hda_dsp_sdw_thread()
- [Low] ASoC: SOF: Intel: missing IRQ_DOMAIN select for
SND_SOC_SOF_HDA_GENERIC
--
commit 5df72fed7029dd88ed89bc7f4dff6d1d49c10ae2
Author: Charles Keepax <ckeepax@opensource.cirrus.com>
ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ
This commit introduces an IRQ domain and chip in the Intel HDA SOF driver
to dispatch the SoundWire interrupt to per-link threaded IRQ handlers.
> diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c
> index 8bdb2bf1c6446..d84fbe716febc 100644
> --- a/drivers/soundwire/intel_auxdevice.c
> +++ b/drivers/soundwire/intel_auxdevice.c
> @@ -366,6 +366,14 @@ static int intel_link_probe(struct auxiliary_device *auxdev,
> /* use generic bandwidth allocation algorithm */
> sdw->cdns.bus.compute_params = sdw_compute_params;
>
> + ret = request_threaded_irq(sdw->link_res->irq, NULL, sdw_cdns_irq,
> + IRQF_SHARED | IRQF_ONESHOT, dev_name(dev),
> + cdns);
> + if (ret) {
> + dev_err(dev, "failed to request IRQ: %d\n", ret);
> + return ret;
> + }
> +
> ret = sdw_bus_master_add(bus, dev, dev->fwnode);
> if (ret) {
> dev_err(dev, "sdw_bus_master_add fail: %d\n", ret);
[Severity: Medium]
If sdw_bus_master_add() fails, does intel_link_probe() return without
calling free_irq(sdw->link_res->irq, cdns)? Because sdw is allocated with
devm_kzalloc_obj(), probe failure frees cdns while leaving the irqaction
registered on the shared virtual IRQ, causing a use-after-free when the
IRQ fires or is inspected.
> @@ -503,6 +511,8 @@ static void intel_link_remove(struct auxiliary_device *auxdev)
> struct sdw_intel *sdw = cdns_to_intel(cdns);
> struct sdw_bus *bus = &cdns->bus;
>
> + free_irq(sdw->link_res->irq, cdns);
> +
> /*
> * Since pm_runtime is already disabled, we don't decrease
> * the refcount when the clock_stop_quirk is
[Severity: Medium]
Should sdw_cdns_enable_interrupt(cdns, false) run before free_irq() here?
sdw_intel_exit() resumes the link and re-enables Cadence interrupts before
removing the auxiliary device, and sdw_cdns_enable_interrupt(cdns, false)
flushes cdns->work before masking CDNS_MCP_INTMASK. Freeing the IRQ
handler first means any SoundWire transfer in cdns->work (or attach_dwork
and slave teardown before commit "soundwire: intel_auxdevice: Don't
disable IRQs before removing children" later in the series) will never get
its CDNS_MCP_INT_RX_WL completion interrupt and will stall for
CDNS_TX_TIMEOUT, while hardware interrupts remain unmasked without a
handler.
> diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c
> index 9fc95806697e1..06961e5e666ff 100644
> --- a/sound/soc/sof/intel/hda.c
> +++ b/sound/soc/sof/intel/hda.c
> @@ -46,6 +46,22 @@
> /* platform specific devices */
> #include "shim.h"
>
> +static int hda_irq_map(struct irq_domain *h, unsigned int virq, irq_hw_number_t hw)
> +{
> + struct sof_intel_hda_dev *hdev = h->host_data;
> +
> + irq_set_chip_data(virq, hdev);
> + irq_set_chip(virq, &hdev->irq_chip);
> + irq_set_nested_thread(virq, 1);
> + irq_set_noprobe(virq);
> +
> + return 0;
> +}
> +
> +static const struct irq_domain_ops hda_domain_ops = {
> + .map = hda_irq_map,
> +};
[Severity: Low]
Does SND_SOC_SOF_HDA_GENERIC in sound/soc/sof/intel/Kconfig need to select
IRQ_DOMAIN? struct irq_domain_ops and irq_domain_create_linear() are only
declared when CONFIG_IRQ_DOMAIN is enabled, which breaks COMPILE_TEST
builds on architectures that do not unconditionally select IRQ_DOMAIN.
> @@ -198,7 +214,7 @@ static int hda_sdw_probe(struct snd_sof_dev *sdev)
> if (chip->hw_ip_version >= SOF_INTEL_ACE_3_0)
> res.mic_privacy = true;
> }
> - res.irq = sdev->ipc_irq;
> + res.irq = irq_create_mapping(hdev->domain, HDA_IRQ_SDW);
> res.handle = hdev->info.handle;
> res.parent = sdev->dev;
>
[Severity: Medium]
Does this leak the HDA_IRQ_SDW mapping if sdw_intel_probe(&res) fails in
hda_sdw_probe(), or if hda_sdw_startup() later fails in hda_dsp_probe()?
In both cases hda_dsp_probe() unwinds to irq_domain_remove(hdev->domain)
without disposing of the mapping (or calling hda_sdw_exit() on
hda_sdw_startup() failure), triggering the WARN_ON() in
irq_domain_remove() and leaving the leaked irq_desc pointing to freed
hdev->domain and hdev->irq_chip.
> @@ -260,6 +276,8 @@ static int hda_sdw_exit(struct snd_sof_dev *sdev)
> sdw_intel_exit(hdev->sdw);
> hdev->sdw = NULL;
>
> + irq_dispose_mapping(irq_find_mapping(hdev->domain, HDA_IRQ_SDW));
> +
> hda_sdw_int_enable(sdev, false);
>
> return 0;
> @@ -307,9 +325,9 @@ static bool hda_dsp_check_sdw_irq(struct snd_sof_dev *sdev)
> return false;
> }
>
> -static irqreturn_t hda_dsp_sdw_thread(int irq, void *context)
> +static void hda_dsp_sdw_thread(struct sof_intel_hda_dev *hdev)
> {
> - return sdw_intel_thread(irq, context);
> + handle_nested_irq(irq_find_mapping(hdev->domain, HDA_IRQ_SDW));
> }
[Severity: Medium]
Can hda_sdw_exit() dispose of the HDA_IRQ_SDW mapping while
hda_dsp_interrupt_thread() is still running?
In hda_dsp_remove(), hda_sdw_exit() runs before SOF_HDA_INT_GLOBAL_EN is
cleared and before free_irq(sdev->ipc_irq, sdev) stops
hda_dsp_interrupt_thread():
CPU0 CPU1
hda_dsp_remove() hda_dsp_interrupt_thread()
hda_sdw_exit() if (hda_dsp_check_sdw_irq(sdev))
sdw_intel_exit()
...
free_irq(virq, cdns)
irq_dispose_mapping(virq)
hda_dsp_sdw_thread(hdev)
virq = irq_find_mapping(...)
handle_nested_irq(virq)
<-- virq is 0 or freed desc
Once irq_dispose_mapping() unmaps HDA_IRQ_SDW and frees its irq_desc,
irq_find_mapping() returns 0 (which on x86 resolves to legacy timer IRQ 0
where action->thread_fn is NULL, causing a NULL pointer dereference in
handle_nested_irq()) or races with irq_free_desc().
[ ... ]
> @@ -883,6 +900,14 @@ int hda_dsp_probe(struct snd_sof_dev *sdev)
> sdev->ipc_irq = pci->irq;
> }
>
> + hdev->irq_chip.name = dev_name(sdev->dev);
> + hdev->domain = irq_domain_create_linear(NULL, HDA_IRQ_COUNT,
> + &hda_domain_ops, hdev);
> + if (!hdev->domain) {
> + dev_err(sdev->dev, "failed to create IRQ domain\n");
> + goto remove_irq_domain;
> + }
> +
> dev_dbg(sdev->dev, "using IPC IRQ %d\n", sdev->ipc_irq);
> ret = request_threaded_irq(sdev->ipc_irq, hda_dsp_interrupt_handler,
> hda_dsp_interrupt_thread,
> @@ -941,6 +966,8 @@ int hda_dsp_probe(struct snd_sof_dev *sdev)
> free_ipc_irq:
> hda_dsp_ctrl_stop_chip(sdev);
> free_irq(sdev->ipc_irq, sdev);
> +remove_irq_domain:
> + irq_domain_remove(hdev->domain);
> free_irq_vector:
> if (sdev->msi_enabled)
> pci_free_irq_vectors(pci);
[Severity: Medium]
Are the error labels for irq_domain_create_linear() and
request_threaded_irq() swapped here?
When irq_domain_create_linear() returns NULL, ret is still 0 from
hda_dsp_stream_init(), and jumping to remove_irq_domain passes NULL to
irq_domain_remove(), which immediately dereferences domain->exit.
Conversely, if request_threaded_irq() fails, it jumps to free_irq_vector
and skips remove_irq_domain, leaking hdev->domain.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124161001.702882-1-ckeepax@opensource.cirrus.com?part=1
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 1/4] ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ
2026-11-24 16:09 ` [PATCH v4 1/4] ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ Charles Keepax
2026-11-24 16:36 ` sashiko-bot
@ 2026-11-24 16:49 ` Pierre-Louis Bossart
2026-11-24 17:06 ` Charles Keepax
1 sibling, 1 reply; 12+ messages in thread
From: Pierre-Louis Bossart @ 2026-11-24 16:49 UTC (permalink / raw)
To: Charles Keepax, vkoul, broonie
Cc: yung-chuan.liao, lgirdwood, peter.ujfalusi, kai.vehmanen,
linux-sound, linux-kernel, patches
On 11/24/26 17:09, Charles Keepax wrote:
> Add an IRQ chip into the HDA code that can be used to trigger the
> SoundWire IRQ for each link. Currently, only the SoundWire IRQ
> is moved over to this IRQ chip, although in time the other IRQ
> functions could be too.
>
> This will allow refactoring such that the individual links each
> request and free their IRQs locally, rather than having to rely
> on looping over a list of links which is tricky to maintain while
> destroying the devices.
Well, there's no such thing as a per-link SoundWire IRQ...
The hardware is built in such a way that once a global interrupt is
received at the HDAudio controller level, the handler has to check if
this was an IPC, HDA, SoundWire interrupt - in that order. And in the
latter case there's no other way than iterating over each link.
Using an abstraction to make each interrupt source 'self-contained'
would be fine and probably make the code cleaner, but then why stop at
SoundWire? I'd err on the side of 'go big or go home'...
At any rate this would be a significant change on both SOF/HDA and
SoundWire sides that should be handled as a well-tested prerequisite to
the series to allow for communication with the device during remove - it
doesn't seem right as a patch casually added in a v4...
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 1/4] ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ
2026-11-24 16:49 ` Pierre-Louis Bossart
@ 2026-11-24 17:06 ` Charles Keepax
2026-11-24 18:33 ` Pierre-Louis Bossart
0 siblings, 1 reply; 12+ messages in thread
From: Charles Keepax @ 2026-11-24 17:06 UTC (permalink / raw)
To: Pierre-Louis Bossart
Cc: vkoul, broonie, yung-chuan.liao, lgirdwood, peter.ujfalusi,
kai.vehmanen, linux-sound, linux-kernel, patches
On Tue, Nov 24, 2026 at 05:49:21PM +0100, Pierre-Louis Bossart wrote:
> On 11/24/26 17:09, Charles Keepax wrote:
> > Add an IRQ chip into the HDA code that can be used to trigger the
> > SoundWire IRQ for each link. Currently, only the SoundWire IRQ
> > is moved over to this IRQ chip, although in time the other IRQ
> > functions could be too.
> >
> > This will allow refactoring such that the individual links each
> > request and free their IRQs locally, rather than having to rely
> > on looping over a list of links which is tricky to maintain while
> > destroying the devices.
>
> Well, there's no such thing as a per-link SoundWire IRQ...
>
> The hardware is built in such a way that once a global interrupt is
> received at the HDAudio controller level, the handler has to check if
> this was an IPC, HDA, SoundWire interrupt - in that order. And in the
> latter case there's no other way than iterating over each link.
Yeah, hence why we add the IRQ domain and claim a shared interrupt.
I will reword a bit for the next spin.
> Using an abstraction to make each interrupt source 'self-contained'
> would be fine and probably make the code cleaner, but then why stop at
> SoundWire? I'd err on the side of 'go big or go home'...
Yeah this definitely could be expanded to the other handlers, as
I note in one of the commit messages. But not really sure I want
to go that far as it no longer relates to the issues I am trying
to solve.
> At any rate this would be a significant change on both SOF/HDA and
> SoundWire sides that should be handled as a well-tested prerequisite to
> the series to allow for communication with the device during remove - it
> doesn't seem right as a patch casually added in a v4...
I can split this patch out to a separate series if you prefer?
Apologies, for the changes a few revisions in but I had generally
imagined doing this would be too much work, hence the more hacky
approach in the previous versions. But it turned out the rabbit
hole was much shallower than I thought.
Thanks,
Charles
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 4/4] soundwire: intel_auxdevice: Don't disable IRQs before removing children
2026-11-24 16:10 ` [PATCH v4 4/4] soundwire: intel_auxdevice: Don't disable IRQs before removing children Charles Keepax
2026-11-24 16:27 ` sashiko-bot
@ 2026-11-24 18:27 ` Pierre-Louis Bossart
1 sibling, 0 replies; 12+ messages in thread
From: Pierre-Louis Bossart @ 2026-11-24 18:27 UTC (permalink / raw)
To: Charles Keepax, vkoul, broonie
Cc: yung-chuan.liao, lgirdwood, peter.ujfalusi, kai.vehmanen,
linux-sound, linux-kernel, patches
> @@ -511,8 +511,6 @@ static void intel_link_remove(struct auxiliary_device *auxdev)
> struct sdw_intel *sdw = cdns_to_intel(cdns);
> struct sdw_bus *bus = &cdns->bus;
>
> - free_irq(sdw->link_res->irq, cdns);
> -
> /*
> * Since pm_runtime is already disabled, we don't decrease
> * the refcount when the clock_stop_quirk is
> @@ -521,8 +519,15 @@ static void intel_link_remove(struct auxiliary_device *auxdev)
> if (!bus->prop.hw_disabled) {
> sdw_intel_debugfs_exit(sdw);
> cancel_delayed_work_sync(&cdns->attach_dwork);
> - sdw_cdns_enable_interrupt(cdns, false);
> }
> +
> + sdw_bus_slaves_delete(bus);
> +
> + free_irq(sdw->link_res->irq, cdns);
> +
> + if (!bus->prop.hw_disabled)
> + sdw_cdns_enable_interrupt(cdns, false);
> +
also wondering if the two actions should be reversed. It'd seem more
intuitive to make sure the controller can't deal with interrupts before
taking the resources down.
edit: I just noticed the AI has the same comment.
> sdw_bus_master_delete(bus);
> }
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 1/4] ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ
2026-11-24 17:06 ` Charles Keepax
@ 2026-11-24 18:33 ` Pierre-Louis Bossart
0 siblings, 0 replies; 12+ messages in thread
From: Pierre-Louis Bossart @ 2026-11-24 18:33 UTC (permalink / raw)
To: Charles Keepax
Cc: vkoul, broonie, yung-chuan.liao, lgirdwood, peter.ujfalusi,
kai.vehmanen, linux-sound, linux-kernel, patches
On 11/24/26 18:06, Charles Keepax wrote:
> On Tue, Nov 24, 2026 at 05:49:21PM +0100, Pierre-Louis Bossart wrote:
>> On 11/24/26 17:09, Charles Keepax wrote:
>>> Add an IRQ chip into the HDA code that can be used to trigger the
>>> SoundWire IRQ for each link. Currently, only the SoundWire IRQ
>>> is moved over to this IRQ chip, although in time the other IRQ
>>> functions could be too.
>>>
>>> This will allow refactoring such that the individual links each
>>> request and free their IRQs locally, rather than having to rely
>>> on looping over a list of links which is tricky to maintain while
>>> destroying the devices.
>>
>> Well, there's no such thing as a per-link SoundWire IRQ...
>>
>> The hardware is built in such a way that once a global interrupt is
>> received at the HDAudio controller level, the handler has to check if
>> this was an IPC, HDA, SoundWire interrupt - in that order. And in the
>> latter case there's no other way than iterating over each link.
>
> Yeah, hence why we add the IRQ domain and claim a shared interrupt.
> I will reword a bit for the next spin.
>
>> Using an abstraction to make each interrupt source 'self-contained'
>> would be fine and probably make the code cleaner, but then why stop at
>> SoundWire? I'd err on the side of 'go big or go home'...
>
> Yeah this definitely could be expanded to the other handlers, as
> I note in one of the commit messages. But not really sure I want
> to go that far as it no longer relates to the issues I am trying
> to solve.
understand, this would probably need to be handled by Intel folks, since
it'd impact ALL platforms since GeminiLake - 2019.
>> At any rate this would be a significant change on both SOF/HDA and
>> SoundWire sides that should be handled as a well-tested prerequisite to
>> the series to allow for communication with the device during remove - it
>> doesn't seem right as a patch casually added in a v4...
>
> I can split this patch out to a separate series if you prefer?
I guess it's more the Intel people who'd need to speak up on such an
invasive change. My recommendation would be to pick this patch and make
sure it's well tested with CI and daily tests. Whether it's part of the
same series or not is not really important, it's the test part that matters.
> Apologies, for the changes a few revisions in but I had generally
> imagined doing this would be too much work, hence the more hacky
> approach in the previous versions. But it turned out the rabbit
> hole was much shallower than I thought.
One open that I have is whether the dispatch of the shared interrupt
will deal with the links in the same order as with the explicit loop. If
not, there could be interesting timing issues that show up.
The other remark is that the free_irq() introduced in patch1 in
intel_link_remove() is moved in patch4.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-11-24 18:33 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 16:09 [PATCH v4 0/4] Allow SoundWire devices to communicate during remove Charles Keepax
2026-11-24 16:09 ` [PATCH v4 1/4] ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ Charles Keepax
2026-11-24 16:36 ` sashiko-bot
2026-11-24 16:49 ` Pierre-Louis Bossart
2026-11-24 17:06 ` Charles Keepax
2026-11-24 18:33 ` Pierre-Louis Bossart
2026-11-24 16:09 ` [PATCH v4 2/4] soundwire: bus: Don't unassign dev_num before unregistering device Charles Keepax
2026-11-24 16:10 ` [PATCH v4 3/4] soundwire: bus: Expose a helper to remove devices from the bus Charles Keepax
2026-11-24 16:29 ` sashiko-bot
2026-11-24 16:10 ` [PATCH v4 4/4] soundwire: intel_auxdevice: Don't disable IRQs before removing children Charles Keepax
2026-11-24 16:27 ` sashiko-bot
2026-11-24 18:27 ` Pierre-Louis Bossart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox