* [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: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, 1 reply; 7+ 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] 7+ 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:10 ` [PATCH v4 4/4] soundwire: intel_auxdevice: Don't disable IRQs before removing children Charles Keepax
3 siblings, 0 replies; 7+ 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] 7+ 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
3 siblings, 0 replies; 7+ 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] 7+ messages in thread