The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: vkoul@kernel.org, broonie@kernel.org
Cc: yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev,
	lgirdwood@gmail.com, peter.ujfalusi@linux.intel.com,
	kai.vehmanen@linux.intel.com, linux-sound@vger.kernel.org,
	linux-kernel@vger.kernel.org, patches@opensource.cirrus.com
Subject: [PATCH v4 1/4] ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ
Date: Tue, 24 Nov 2026 16:09:58 +0000	[thread overview]
Message-ID: <20261124161001.702882-2-ckeepax@opensource.cirrus.com> (raw)
In-Reply-To: <20261124161001.702882-1-ckeepax@opensource.cirrus.com>

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


  reply	other threads:[~2026-11-24 16:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-11-24 16:49   ` [PATCH v4 1/4] ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ Pierre-Louis Bossart
2026-11-24 17:06     ` 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 ` [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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124161001.702882-2-ckeepax@opensource.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=broonie@kernel.org \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=vkoul@kernel.org \
    --cc=yung-chuan.liao@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox