Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
* [PATCH 00/21] soundwire: Fix Critical and High issues reported by Sashiko
@ 2026-10-30 10:46 Lee Jones
  2026-10-30 10:46 ` [PATCH 07/21] soundwire: qcom: Prevent pconfig buffer overflow in qcom_swrm_stream_alloc_ports() Lee Jones
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Lee Jones @ 2026-10-30 10:46 UTC (permalink / raw)
  To: lee
  Cc: linux-kernel, Uwe Kleine-König (The Capable Hub), Bard Liao,
	Bjorn Helgaas, Daniel Baluta, Danilo Krummrich,
	Greg Kroah-Hartman, Hardik T Shah, Jaroslav Kysela, Kai Vehmanen,
	Liam Girdwood, linux-arm-msm, linux-sound, Mark Brown,
	Mastan Katragadda, Peter Ujfalusi, Pierre-Louis Bossart,
	Rander Wang, Ranjani Sridharan, Sanyog Kale, Simon Trimmer,
	sound-open-firmware, Srinivas Kandagatla, Takashi Iwai,
	Takashi Sakamoto, Vijendar Mukunda, Vinod Koul

These issues were reported by Sashiko.

Cc: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@baylibre.com>
Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Daniel Baluta <daniel.baluta@nxp.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Hardik T Shah <hardik.t.shah@intel.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-sound@vger.kernel.org
Cc: Mark Brown <broonie@kernel.org>
Cc: Mastan Katragadda <Mastan.Katragadda@amd.com>
Cc: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
Cc: Rander Wang <rander.wang@intel.com>
Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Cc: Sanyog Kale <sanyog.r.kale@intel.com>
Cc: Simon Trimmer <simont@opensource.cirrus.com>
Cc: sound-open-firmware@alsa-project.org
Cc: Srinivas Kandagatla <srini@kernel.org>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Cc: Vinod Koul <vkoul@kernel.org>

Lee Jones (21):
  soundwire: bus: Hold bus_lock when looking up slave devices
  soundwire: sysfs: Use sysfs_emit_at() in array show callbacks
  soundwire: stream: Prevent m_rt_count underflow in
    sdw_stream_remove_master()
  soundwire: stream: Clean up allocated runtime resources on config
    failure
  ASoC: SOF: Intel: hda-sdw-bpt: Stop active DMA before closing BPT
    streams
  soundwire: intel_ace2x: Protect bus.bpt_stream with bus_lock
  soundwire: qcom: Prevent pconfig buffer overflow in
    qcom_swrm_stream_alloc_ports()
  soundwire: qcom: Disable runtime PM and avoid clock underflow in
    qcom_swrm_remove()
  soundwire: qcom: Check clk_prepare_enable() return value
  soundwire: qcom: Serialise ctrl->intr_mask updates
  soundwire: qcom: Prevent stale broadcast IRQ from completing
    subsequent command
  soundwire: amd: Check for NULL manager drvdata in sdw_amd_startup()
  soundwire: amd: Check ping command response for timeout
  soundwire: amd: Preserve lane control bits in amd_sdw_port_enable()
  soundwire: amd: Avoid static port offset leak in
    amd_sdw_compute_params()
  soundwire: amd: Initialise and cancel IRQ work around manager lifetime
  soundwire: amd: Resume manager before hardware teardown in
    amd_sdw_manager_remove()
  soundwire: amd: Synchronise parent IRQ and disable work on manager
    removal
  soundwire: amd: Cancel pending work before suspending manager
  soundwire: amd: Check clock resume timeout in amd_resume_runtime()
  soundwire: amd: Disable interrupts if enabling manager fails

 drivers/soundwire/amd_init.c        |  13 ++-
 drivers/soundwire/amd_manager.c     | 130 +++++++++++++++++++++++-----
 drivers/soundwire/bus.c             |   6 +-
 drivers/soundwire/intel_ace2x.c     |  36 ++++----
 drivers/soundwire/qcom.c            |  97 +++++++++++++++++----
 drivers/soundwire/stream.c          |  40 ++++++---
 drivers/soundwire/sysfs_slave.c     |   6 +-
 drivers/soundwire/sysfs_slave_dpn.c |   8 +-
 sound/soc/sof/intel/hda-sdw-bpt.c   |   6 ++
 9 files changed, 267 insertions(+), 75 deletions(-)

-- 
2.56.0.317.g454f8302e1-goog


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 07/21] soundwire: qcom: Prevent pconfig buffer overflow in qcom_swrm_stream_alloc_ports()
  2026-10-30 10:46 [PATCH 00/21] soundwire: Fix Critical and High issues reported by Sashiko Lee Jones
@ 2026-10-30 10:46 ` Lee Jones
  2026-10-30 10:46 ` [PATCH 08/21] soundwire: qcom: Disable runtime PM and avoid clock underflow in qcom_swrm_remove() Lee Jones
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2026-10-30 10:46 UTC (permalink / raw)
  To: lee, Srinivas Kandagatla, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, linux-arm-msm, linux-sound, linux-kernel
  Cc: stable

qcom_swrm_stream_alloc_ports() allocates the pconfig array with
ctrl->nports elements, but only checks that the assigned port number pn
is below maxport.  When multiple slave ports map to the same master port
via m_port_map or the stream requests more slave ports than
ctrl->nports, nports increments past ctrl->nports and writes out of
bounds of pconfig.

Verify that nports is less than maxport before writing to
pconfig[nports].

Fixes: 9e53a66a2f2f ("soundwire: qcom: deprecate qcom,din/out-ports")
Closes: https://sashiko.dev/#/bug/linux-543ea0c0-a6e5-4b03-a041-ea0a760802c1
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/soundwire/qcom.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index 6e0c5fb10efa..205011234030 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -1343,6 +1343,11 @@ static int qcom_swrm_stream_alloc_ports(struct qcom_swrm_ctrl *ctrl,
 		list_for_each_entry(s_rt, &m_rt->slave_rt_list, m_rt_node) {
 			slave = s_rt->slave;
 			list_for_each_entry(p_rt, &s_rt->port_list, port_node) {
+				if (nports >= maxport) {
+					dev_err(ctrl->dev, "All ports busy\n");
+					return -EBUSY;
+				}
+
 				m_port = slave->m_port_map[p_rt->num];
 				/* Port numbers start from 1 - 14*/
 				if (m_port)
-- 
2.56.0.317.g454f8302e1-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 08/21] soundwire: qcom: Disable runtime PM and avoid clock underflow in qcom_swrm_remove()
  2026-10-30 10:46 [PATCH 00/21] soundwire: Fix Critical and High issues reported by Sashiko Lee Jones
  2026-10-30 10:46 ` [PATCH 07/21] soundwire: qcom: Prevent pconfig buffer overflow in qcom_swrm_stream_alloc_ports() Lee Jones
@ 2026-10-30 10:46 ` Lee Jones
  2026-10-30 10:46 ` [PATCH 09/21] soundwire: qcom: Check clk_prepare_enable() return value Lee Jones
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2026-10-30 10:46 UTC (permalink / raw)
  To: lee, Srinivas Kandagatla, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, linux-arm-msm, linux-sound, linux-kernel
  Cc: stable

When the controller is runtime-suspended, swrm_runtime_suspend() has
already disabled ctrl->hclk.  If the device is unbound in that state,
qcom_swrm_remove() omits pm_runtime_disable() and unconditionally calls
clk_disable_unprepare(), triggering a clock enable count underflow and
leaving runtime PM enabled.

Resume the device before removing the bus master, disable runtime PM,
and only disable ctrl->hclk if the device is not runtime-suspended.

Fixes: 74e79da9fd46 ("soundwire: qcom: add runtime pm support")
Closes: https://sashiko.dev/#/bug/linux-e26e04cd-3dec-4a3d-94e6-f45403c4bb57
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/soundwire/qcom.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index 205011234030..246bc063b850 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -1791,8 +1791,13 @@ static void qcom_swrm_remove(struct platform_device *pdev)
 {
 	struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(&pdev->dev);
 
+	pm_runtime_get_sync(&pdev->dev);
 	sdw_bus_master_delete(&ctrl->bus);
-	clk_disable_unprepare(ctrl->hclk);
+	pm_runtime_disable(&pdev->dev);
+	pm_runtime_put_noidle(&pdev->dev);
+	if (!pm_runtime_status_suspended(&pdev->dev))
+		clk_disable_unprepare(ctrl->hclk);
+	pm_runtime_set_suspended(&pdev->dev);
 }
 
 static int __maybe_unused swrm_runtime_resume(struct device *dev)
-- 
2.56.0.317.g454f8302e1-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 09/21] soundwire: qcom: Check clk_prepare_enable() return value
  2026-10-30 10:46 [PATCH 00/21] soundwire: Fix Critical and High issues reported by Sashiko Lee Jones
  2026-10-30 10:46 ` [PATCH 07/21] soundwire: qcom: Prevent pconfig buffer overflow in qcom_swrm_stream_alloc_ports() Lee Jones
  2026-10-30 10:46 ` [PATCH 08/21] soundwire: qcom: Disable runtime PM and avoid clock underflow in qcom_swrm_remove() Lee Jones
@ 2026-10-30 10:46 ` Lee Jones
  2026-10-30 10:46 ` [PATCH 10/21] soundwire: qcom: Serialise ctrl->intr_mask updates Lee Jones
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2026-10-30 10:46 UTC (permalink / raw)
  To: lee, Srinivas Kandagatla, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, linux-sound, linux-arm-msm, linux-kernel
  Cc: stable

qcom_swrm_probe(), qcom_swrm_irq_handler(), and swrm_runtime_resume()
ignore the return value of clk_prepare_enable(ctrl->hclk) and proceed
to access controller registers even when enabling the interface clock
fails.  Also jump to err_clk when requesting the wake IRQ fails in
qcom_swrm_probe() so ctrl->hclk is disabled on error.

Check the return value of clk_prepare_enable() in all three callers and
abort register access on failure.

Fixes: 02efb49aa805 ("soundwire: qcom: add support for SoundWire controller")
Closes: https://sashiko.dev/#/bug/linux-f65cddc9-08ff-4531-9acf-76981d74d914
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/soundwire/qcom.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index 246bc063b850..555045b32a25 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -778,7 +778,9 @@ static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id)
 	u32 i;
 	int devnum;
 	int ret = IRQ_HANDLED;
-	clk_prepare_enable(ctrl->hclk);
+
+	if (clk_prepare_enable(ctrl->hclk))
+		return IRQ_NONE;
 
 	ctrl->reg_read(ctrl, ctrl->reg_layout[SWRM_REG_INTERRUPT_STATUS],
 		       &intr_sts);
@@ -1680,7 +1682,9 @@ static int qcom_swrm_probe(struct platform_device *pdev)
 		goto err_init;
 	}
 
-	clk_prepare_enable(ctrl->hclk);
+	ret = clk_prepare_enable(ctrl->hclk);
+	if (ret)
+		goto err_init;
 
 	ctrl->dev = dev;
 	dev_set_drvdata(&pdev->dev, ctrl);
@@ -1736,7 +1740,7 @@ static int qcom_swrm_probe(struct platform_device *pdev)
 						"swr_wake_irq", ctrl);
 		if (ret) {
 			dev_err(dev, "Failed to request soundwire wake irq\n");
-			goto err_init;
+			goto err_clk;
 		}
 	}
 
@@ -1805,13 +1809,15 @@ static int __maybe_unused swrm_runtime_resume(struct device *dev)
 	struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dev);
 	int ret;
 
+	ret = clk_prepare_enable(ctrl->hclk);
+	if (ret)
+		return ret;
+
 	if (ctrl->wake_irq > 0) {
 		if (!irqd_irq_disabled(irq_get_irq_data(ctrl->wake_irq)))
 			disable_irq_nosync(ctrl->wake_irq);
 	}
 
-	clk_prepare_enable(ctrl->hclk);
-
 	if (ctrl->clock_stop_not_supported) {
 		reinit_completion(&ctrl->enumeration);
 		ctrl->reg_write(ctrl, SWRM_COMP_SW_RESET, 0x01);
-- 
2.56.0.317.g454f8302e1-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 10/21] soundwire: qcom: Serialise ctrl->intr_mask updates
  2026-10-30 10:46 [PATCH 00/21] soundwire: Fix Critical and High issues reported by Sashiko Lee Jones
                   ` (2 preceding siblings ...)
  2026-10-30 10:46 ` [PATCH 09/21] soundwire: qcom: Check clk_prepare_enable() return value Lee Jones
@ 2026-10-30 10:46 ` Lee Jones
  2026-10-30 10:46 ` [PATCH 11/21] soundwire: qcom: Prevent stale broadcast IRQ from completing subsequent command Lee Jones
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2026-10-30 10:46 UTC (permalink / raw)
  To: lee, Srinivas Kandagatla, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, linux-arm-msm, linux-sound, linux-kernel
  Cc: stable

qcom_swrm_irq_handler(), swrm_runtime_suspend(), and
swrm_runtime_resume() concurrently read, modify, and write
ctrl->intr_mask and program the interrupt enable registers without
synchronisation.  Overlapping read-modify-write updates can clobber
interrupt mask bits and leave the hardware interrupt mask out of sync.

Add ctrl->intr_lock to serialise accesses to ctrl->intr_mask and its
associated interrupt mask register updates.

Fixes: 74e79da9fd46 ("soundwire: qcom: add runtime pm support")
Closes: https://sashiko.dev/#/bug/linux-ea523727-6467-42aa-850f-8f838e4b84a8
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/soundwire/qcom.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index 555045b32a25..cfa3466ff8e1 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -202,6 +202,8 @@ struct qcom_swrm_ctrl {
 	struct completion enumeration;
 	/* Port alloc/free lock */
 	struct mutex port_lock;
+	/* Interrupt mask and broadcast completion lock */
+	struct mutex intr_lock;
 	struct clk *hclk;
 	int irq;
 	u32 ee;
@@ -784,7 +786,9 @@ static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id)
 
 	ctrl->reg_read(ctrl, ctrl->reg_layout[SWRM_REG_INTERRUPT_STATUS],
 		       &intr_sts);
+	mutex_lock(&ctrl->intr_lock);
 	intr_sts_masked = intr_sts & ctrl->intr_mask;
+	mutex_unlock(&ctrl->intr_lock);
 
 	do {
 		for (i = 0; i < SWRM_INTERRUPT_MAX; i++) {
@@ -820,10 +824,12 @@ static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id)
 				dev_err_ratelimited(ctrl->dev,
 						"%s: SWR bus clsh detected\n",
 						__func__);
+				mutex_lock(&ctrl->intr_lock);
 				ctrl->intr_mask &= ~SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET;
 				ctrl->reg_write(ctrl,
 						ctrl->reg_layout[SWRM_REG_INTERRUPT_CPU_EN],
 						ctrl->intr_mask);
+				mutex_unlock(&ctrl->intr_lock);
 				break;
 			case SWRM_INTERRUPT_STATUS_RD_FIFO_OVERFLOW:
 				ctrl->reg_read(ctrl,
@@ -863,20 +869,24 @@ static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id)
 				dev_err_ratelimited(ctrl->dev,
 						"%s: SWR Port collision detected\n",
 						__func__);
+				mutex_lock(&ctrl->intr_lock);
 				ctrl->intr_mask &= ~SWRM_INTERRUPT_STATUS_DOUT_PORT_COLLISION;
 				ctrl->reg_write(ctrl,
 						ctrl->reg_layout[SWRM_REG_INTERRUPT_CPU_EN],
 						ctrl->intr_mask);
+				mutex_unlock(&ctrl->intr_lock);
 				break;
 			case SWRM_INTERRUPT_STATUS_READ_EN_RD_VALID_MISMATCH:
 				dev_err_ratelimited(ctrl->dev,
 					"%s: SWR read enable valid mismatch\n",
 					__func__);
+				mutex_lock(&ctrl->intr_lock);
 				ctrl->intr_mask &=
 					~SWRM_INTERRUPT_STATUS_READ_EN_RD_VALID_MISMATCH;
 				ctrl->reg_write(ctrl,
 						ctrl->reg_layout[SWRM_REG_INTERRUPT_CPU_EN],
 						ctrl->intr_mask);
+				mutex_unlock(&ctrl->intr_lock);
 				break;
 			case SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED:
 				complete(&ctrl->broadcast);
@@ -910,7 +920,9 @@ static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id)
 				intr_sts);
 		ctrl->reg_read(ctrl, ctrl->reg_layout[SWRM_REG_INTERRUPT_STATUS],
 			       &intr_sts);
+		mutex_lock(&ctrl->intr_lock);
 		intr_sts_masked = intr_sts & ctrl->intr_mask;
+		mutex_unlock(&ctrl->intr_lock);
 	} while (intr_sts_masked);
 
 	clk_disable_unprepare(ctrl->hclk);
@@ -952,11 +964,13 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl)
 	/* Enable Auto enumeration */
 	ctrl->reg_write(ctrl, SWRM_ENUMERATOR_CFG_ADDR, 1);
 
+	mutex_lock(&ctrl->intr_lock);
 	ctrl->intr_mask = SWRM_INTERRUPT_STATUS_RMSK;
 	/* Mask soundwire interrupts */
 	if (ctrl->version < SWRM_VERSION_2_0_0)
 		ctrl->reg_write(ctrl, ctrl->reg_layout[SWRM_REG_INTERRUPT_MASK_ADDR],
-				SWRM_INTERRUPT_STATUS_RMSK);
+				ctrl->intr_mask);
+	mutex_unlock(&ctrl->intr_lock);
 
 	/* Configure No pings */
 	ctrl->reg_read(ctrl, SWRM_MCP_CFG_ADDR, &val);
@@ -997,8 +1011,10 @@ static int qcom_swrm_init(struct qcom_swrm_ctrl *ctrl)
 			0xFFFFFFFF);
 
 	/* enable CPU IRQs for the selected EE window */
+	mutex_lock(&ctrl->intr_lock);
 	ctrl->reg_write(ctrl, ctrl->reg_layout[SWRM_REG_INTERRUPT_CPU_EN],
-			SWRM_INTERRUPT_STATUS_RMSK);
+			ctrl->intr_mask);
+	mutex_unlock(&ctrl->intr_lock);
 
 	/* Set IRQ to PULSE */
 	ctrl->reg_write(ctrl, SWRM_COMP_CFG_ADDR,
@@ -1689,6 +1705,7 @@ static int qcom_swrm_probe(struct platform_device *pdev)
 	ctrl->dev = dev;
 	dev_set_drvdata(&pdev->dev, ctrl);
 	mutex_init(&ctrl->port_lock);
+	mutex_init(&ctrl->intr_lock);
 	init_completion(&ctrl->broadcast);
 	init_completion(&ctrl->enumeration);
 
@@ -1854,6 +1871,7 @@ static int __maybe_unused swrm_runtime_resume(struct device *dev)
 		ctrl->reg_write(ctrl, ctrl->reg_layout[SWRM_REG_INTERRUPT_CLEAR],
 			SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET);
 
+		mutex_lock(&ctrl->intr_lock);
 		ctrl->intr_mask |= SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET;
 		if (ctrl->version < SWRM_VERSION_2_0_0)
 			ctrl->reg_write(ctrl,
@@ -1861,6 +1879,7 @@ static int __maybe_unused swrm_runtime_resume(struct device *dev)
 					ctrl->intr_mask);
 		ctrl->reg_write(ctrl, ctrl->reg_layout[SWRM_REG_INTERRUPT_CPU_EN],
 				ctrl->intr_mask);
+		mutex_unlock(&ctrl->intr_lock);
 
 		usleep_range(100, 105);
 		if (!swrm_wait_for_frame_gen_enabled(ctrl))
@@ -1882,6 +1901,7 @@ static int __maybe_unused swrm_runtime_suspend(struct device *dev)
 	swrm_wait_for_wr_fifo_done(ctrl);
 	if (!ctrl->clock_stop_not_supported) {
 		/* Mask bus clash interrupt */
+		mutex_lock(&ctrl->intr_lock);
 		ctrl->intr_mask &= ~SWRM_INTERRUPT_STATUS_MASTER_CLASH_DET;
 		if (ctrl->version < SWRM_VERSION_2_0_0)
 			ctrl->reg_write(ctrl,
@@ -1889,6 +1909,7 @@ static int __maybe_unused swrm_runtime_suspend(struct device *dev)
 					ctrl->intr_mask);
 		ctrl->reg_write(ctrl, ctrl->reg_layout[SWRM_REG_INTERRUPT_CPU_EN],
 				ctrl->intr_mask);
+		mutex_unlock(&ctrl->intr_lock);
 		/* Prepare slaves for clock stop */
 		ret = sdw_bus_prep_clk_stop(&ctrl->bus);
 		if (ret < 0 && ret != -ENODATA) {
-- 
2.56.0.317.g454f8302e1-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 11/21] soundwire: qcom: Prevent stale broadcast IRQ from completing subsequent command
  2026-10-30 10:46 [PATCH 00/21] soundwire: Fix Critical and High issues reported by Sashiko Lee Jones
                   ` (3 preceding siblings ...)
  2026-10-30 10:46 ` [PATCH 10/21] soundwire: qcom: Serialise ctrl->intr_mask updates Lee Jones
@ 2026-10-30 10:46 ` Lee Jones
  2026-11-02  1:07 ` (subset) [PATCH 00/21] soundwire: Fix Critical and High issues reported by Sashiko Mark Brown
  2026-11-02  7:00 ` Vinod Koul
  6 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2026-10-30 10:46 UTC (permalink / raw)
  To: lee, Srinivas Kandagatla, Vinod Koul, Bard Liao,
	Pierre-Louis Bossart, linux-sound, linux-arm-msm, linux-kernel
  Cc: stable

When wait_for_completion_timeout() expires for a broadcast command in
qcom_swrm_cmd_fifo_wr_cmd(), any late
SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED interrupt from the
timed-out command can fire concurrently with a subsequent broadcast
command after reinit_completion(&ctrl->broadcast), prematurely
completing the new command.

Clear any pending special command completion interrupt and reinitialise
ctrl->broadcast before issuing a broadcast command under
ctrl->intr_lock, clear the interrupt on timeout, and verify that the
interrupt status bit is still asserted under ctrl->intr_lock before
signalling ctrl->broadcast.

Fixes: ddea6cf7b619 ("soundwire: qcom: update register read/write routine")
Closes: https://sashiko.dev/#/bug/linux-fa1aa3a1-f9c7-4e8a-bdfc-49a559353546
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/soundwire/qcom.c | 44 +++++++++++++++++++++++++++++++++-------
 1 file changed, 37 insertions(+), 7 deletions(-)

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index cfa3466ff8e1..5432d3795cea 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -554,11 +554,18 @@ static int qcom_swrm_cmd_fifo_wr_cmd(struct qcom_swrm_ctrl *ctrl, u8 cmd_data,
 	if (swrm_wait_for_wr_fifo_avail(ctrl))
 		return SDW_CMD_FAIL_OTHER;
 
-	if (cmd_id == SWR_BROADCAST_CMD_ID)
+	if (cmd_id == SWR_BROADCAST_CMD_ID) {
+		mutex_lock(&ctrl->intr_lock);
+		ctrl->reg_write(ctrl,
+				ctrl->reg_layout[SWRM_REG_INTERRUPT_CLEAR],
+				SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED);
 		reinit_completion(&ctrl->broadcast);
-
-	/* Its assumed that write is okay as we do not get any status back */
-	ctrl->reg_write(ctrl, ctrl->reg_layout[SWRM_REG_CMD_FIFO_WR_CMD], val);
+		ctrl->reg_write(ctrl, ctrl->reg_layout[SWRM_REG_CMD_FIFO_WR_CMD], val);
+		mutex_unlock(&ctrl->intr_lock);
+	} else {
+		/* Its assumed that write is okay as we do not get any status back */
+		ctrl->reg_write(ctrl, ctrl->reg_layout[SWRM_REG_CMD_FIFO_WR_CMD], val);
+	}
 
 	if (ctrl->version <= SWRM_VERSION_1_3_0)
 		usleep_range(150, 155);
@@ -571,10 +578,16 @@ static int qcom_swrm_cmd_fifo_wr_cmd(struct qcom_swrm_ctrl *ctrl, u8 cmd_data,
 		 */
 		ret = wait_for_completion_timeout(&ctrl->broadcast,
 						  msecs_to_jiffies(TIMEOUT_MS));
-		if (!ret)
+		if (!ret) {
+			mutex_lock(&ctrl->intr_lock);
+			ctrl->reg_write(ctrl,
+					ctrl->reg_layout[SWRM_REG_INTERRUPT_CLEAR],
+					SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED);
+			mutex_unlock(&ctrl->intr_lock);
 			ret = SDW_CMD_IGNORED;
-		else
+		} else {
 			ret = SDW_CMD_OK;
+		}
 
 	} else {
 		ret = SDW_CMD_OK;
@@ -773,6 +786,22 @@ static irqreturn_t qcom_swrm_wake_irq_handler(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static void qcom_swrm_complete_broadcast(struct qcom_swrm_ctrl *ctrl)
+{
+	u32 status;
+
+	guard(mutex)(&ctrl->intr_lock);
+
+	ctrl->reg_read(ctrl, ctrl->reg_layout[SWRM_REG_INTERRUPT_STATUS],
+		       &status);
+	if (status & SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED) {
+		ctrl->reg_write(ctrl,
+				ctrl->reg_layout[SWRM_REG_INTERRUPT_CLEAR],
+				SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED);
+		complete(&ctrl->broadcast);
+	}
+}
+
 static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id)
 {
 	struct qcom_swrm_ctrl *ctrl = dev_id;
@@ -889,7 +918,8 @@ static irqreturn_t qcom_swrm_irq_handler(int irq, void *dev_id)
 				mutex_unlock(&ctrl->intr_lock);
 				break;
 			case SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED:
-				complete(&ctrl->broadcast);
+				qcom_swrm_complete_broadcast(ctrl);
+				intr_sts &= ~SWRM_INTERRUPT_STATUS_SPECIAL_CMD_ID_FINISHED;
 				break;
 			case SWRM_INTERRUPT_STATUS_BUS_RESET_FINISHED_V2:
 				break;
-- 
2.56.0.317.g454f8302e1-goog


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: (subset) [PATCH 00/21] soundwire: Fix Critical and High issues reported by Sashiko
  2026-10-30 10:46 [PATCH 00/21] soundwire: Fix Critical and High issues reported by Sashiko Lee Jones
                   ` (4 preceding siblings ...)
  2026-10-30 10:46 ` [PATCH 11/21] soundwire: qcom: Prevent stale broadcast IRQ from completing subsequent command Lee Jones
@ 2026-11-02  1:07 ` Mark Brown
  2026-11-02  7:00 ` Vinod Koul
  6 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2026-11-02  1:07 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-kernel, Uwe Kleine-König (The Capable Hub), Bard Liao,
	Bjorn Helgaas, Daniel Baluta, Danilo Krummrich,
	Greg Kroah-Hartman, Hardik T Shah, Jaroslav Kysela, Kai Vehmanen,
	Liam Girdwood, linux-arm-msm, linux-sound, Mastan Katragadda,
	Peter Ujfalusi, Pierre-Louis Bossart, Rander Wang,
	Ranjani Sridharan, Sanyog Kale, Simon Trimmer,
	sound-open-firmware, Srinivas Kandagatla, Takashi Iwai,
	Takashi Sakamoto, Vijendar Mukunda, Vinod Koul

On Fri, 30 Oct 2026 10:46:39 +0000, Lee Jones wrote:
> soundwire: Fix Critical and High issues reported by Sashiko
> 
> These issues were reported by Sashiko.
> 
> Cc: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@baylibre.com>
> Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Daniel Baluta <daniel.baluta@nxp.com>
> Cc: Danilo Krummrich <dakr@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Hardik T Shah <hardik.t.shah@intel.com>
> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Kai Vehmanen <kai.vehmanen@linux.intel.com>
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: linux-arm-msm@vger.kernel.org
> Cc: linux-sound@vger.kernel.org
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Mastan Katragadda <Mastan.Katragadda@amd.com>
> Cc: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
> Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
> Cc: Rander Wang <rander.wang@intel.com>
> Cc: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
> Cc: Sanyog Kale <sanyog.r.kale@intel.com>
> Cc: Simon Trimmer <simont@opensource.cirrus.com>
> Cc: sound-open-firmware@alsa-project.org
> Cc: Srinivas Kandagatla <srini@kernel.org>
> Cc: Takashi Iwai <tiwai@suse.com>
> Cc: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> Cc: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
> Cc: Vinod Koul <vkoul@kernel.org>
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4

Thanks!

[05/21] ASoC: SOF: Intel: hda-sdw-bpt: Stop active DMA before closing BPT streams
        https://git.kernel.org/broonie/sound/c/348bc756d912

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 00/21] soundwire: Fix Critical and High issues reported by Sashiko
  2026-10-30 10:46 [PATCH 00/21] soundwire: Fix Critical and High issues reported by Sashiko Lee Jones
                   ` (5 preceding siblings ...)
  2026-11-02  1:07 ` (subset) [PATCH 00/21] soundwire: Fix Critical and High issues reported by Sashiko Mark Brown
@ 2026-11-02  7:00 ` Vinod Koul
  2026-11-02  8:37   ` Lee Jones
  6 siblings, 1 reply; 10+ messages in thread
From: Vinod Koul @ 2026-11-02  7:00 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-kernel, Uwe Kleine-König (The Capable Hub), Bard Liao,
	Bjorn Helgaas, Daniel Baluta, Danilo Krummrich,
	Greg Kroah-Hartman, Hardik T Shah, Jaroslav Kysela, Kai Vehmanen,
	Liam Girdwood, linux-arm-msm, linux-sound, Mark Brown,
	Mastan Katragadda, Peter Ujfalusi, Pierre-Louis Bossart,
	Rander Wang, Ranjani Sridharan, Sanyog Kale, Simon Trimmer,
	sound-open-firmware, Srinivas Kandagatla, Takashi Iwai,
	Takashi Sakamoto, Vijendar Mukunda


Hi Lee,

On 30-10-26, 10:46, Lee Jones wrote:
> These issues were reported by Sashiko.

Thanks for looking up issues and fixing them. Some of them do sound good
to me. I would not want to cc stable and tag them to fixes though. These
are bugs, but I have no evidence they are impacting real world
scenarios. Mostly a good but theoretical exercise, so I would like to
avoid churn and move them for next cycle...

-- 
~Vinod

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 00/21] soundwire: Fix Critical and High issues reported by Sashiko
  2026-11-02  7:00 ` Vinod Koul
@ 2026-11-02  8:37   ` Lee Jones
  2026-11-02 11:28     ` Vinod Koul
  0 siblings, 1 reply; 10+ messages in thread
From: Lee Jones @ 2026-11-02  8:37 UTC (permalink / raw)
  To: Vinod Koul
  Cc: linux-kernel, Uwe Kleine-König (The Capable Hub), Bard Liao,
	Bjorn Helgaas, Daniel Baluta, Danilo Krummrich,
	Greg Kroah-Hartman, Hardik T Shah, Jaroslav Kysela, Kai Vehmanen,
	Liam Girdwood, linux-arm-msm, linux-sound, Mark Brown,
	Mastan Katragadda, Peter Ujfalusi, Pierre-Louis Bossart,
	Rander Wang, Ranjani Sridharan, Sanyog Kale, Simon Trimmer,
	sound-open-firmware, Srinivas Kandagatla, Takashi Iwai,
	Takashi Sakamoto, Vijendar Mukunda

On Mon, 02 Nov 2026, Vinod Koul wrote:
> On 30-10-26, 10:46, Lee Jones wrote:
> > These issues were reported by Sashiko.
> 
> Thanks for looking up issues and fixing them. Some of them do sound good
> to me. I would not want to cc stable and tag them to fixes though. These
> are bugs, but I have no evidence they are impacting real world
> scenarios. Mostly a good but theoretical exercise, so I would like to
> avoid churn and move them for next cycle...

That is expected.  I would like these to soak in -next.

I plan on preparing a v2 this week, taking into account all of the
review comments and collected trailers.

Would you like me to strip the Stable tags as well?

-- 
Lee Jones

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 00/21] soundwire: Fix Critical and High issues reported by Sashiko
  2026-11-02  8:37   ` Lee Jones
@ 2026-11-02 11:28     ` Vinod Koul
  0 siblings, 0 replies; 10+ messages in thread
From: Vinod Koul @ 2026-11-02 11:28 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-kernel, Uwe Kleine-König (The Capable Hub), Bard Liao,
	Bjorn Helgaas, Daniel Baluta, Danilo Krummrich,
	Greg Kroah-Hartman, Hardik T Shah, Jaroslav Kysela, Kai Vehmanen,
	Liam Girdwood, linux-arm-msm, linux-sound, Mark Brown,
	Mastan Katragadda, Peter Ujfalusi, Pierre-Louis Bossart,
	Rander Wang, Ranjani Sridharan, Sanyog Kale, Simon Trimmer,
	sound-open-firmware, Srinivas Kandagatla, Takashi Iwai,
	Takashi Sakamoto, Vijendar Mukunda

On 02-11-26, 08:37, Lee Jones wrote:
> On Mon, 02 Nov 2026, Vinod Koul wrote:
> > On 30-10-26, 10:46, Lee Jones wrote:
> > > These issues were reported by Sashiko.
> > 
> > Thanks for looking up issues and fixing them. Some of them do sound good
> > to me. I would not want to cc stable and tag them to fixes though. These
> > are bugs, but I have no evidence they are impacting real world
> > scenarios. Mostly a good but theoretical exercise, so I would like to
> > avoid churn and move them for next cycle...
> 
> That is expected.  I would like these to soak in -next.
> 
> I plan on preparing a v2 this week, taking into account all of the
> review comments and collected trailers.
> 
> Would you like me to strip the Stable tags as well?

Yes please, I do not consider this stable material..
Fixes doesn not help too... :-)

-- 
~Vinod

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-11-02 12:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 10:46 [PATCH 00/21] soundwire: Fix Critical and High issues reported by Sashiko Lee Jones
2026-10-30 10:46 ` [PATCH 07/21] soundwire: qcom: Prevent pconfig buffer overflow in qcom_swrm_stream_alloc_ports() Lee Jones
2026-10-30 10:46 ` [PATCH 08/21] soundwire: qcom: Disable runtime PM and avoid clock underflow in qcom_swrm_remove() Lee Jones
2026-10-30 10:46 ` [PATCH 09/21] soundwire: qcom: Check clk_prepare_enable() return value Lee Jones
2026-10-30 10:46 ` [PATCH 10/21] soundwire: qcom: Serialise ctrl->intr_mask updates Lee Jones
2026-10-30 10:46 ` [PATCH 11/21] soundwire: qcom: Prevent stale broadcast IRQ from completing subsequent command Lee Jones
2026-11-02  1:07 ` (subset) [PATCH 00/21] soundwire: Fix Critical and High issues reported by Sashiko Mark Brown
2026-11-02  7:00 ` Vinod Koul
2026-11-02  8:37   ` Lee Jones
2026-11-02 11:28     ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox