Skip to contentSkip to conversation

soundwire: suppress expected unattach warnings during codec reset

PATCH Applied Cole Leavitt 5 participants 13 messages Feb 17 – Mar 9

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover soundwire: suppress expected unattach warnings during codec reset

On systems with CS35L56 SoundWire codecs (e.g. Lenovo ThinkPad P16 Gen3), every boot produces misleading dev_warn() messages:

cs35l56 sdw:0:2:01fa:3556:01:0: Slave 2 state check1: UNATTACHED, status was 1 cs35l56 sdw:0:2:01fa:3556:01:1: Slave 1 state check1: UNATTACHED, status was 1

These fire when the CS35L56 driver triggers a system reset after firmware download, which physically detaches the codec from the bus. This is expected and handled gracefully -- the driver waits for re-enumeration and the codec recovers within milliseconds.

The warnings were added in commit d1b328557058 ("soundwire: bus: add dev_warn() messages to track UNATTACHED devices") to debug genuine attachment failures. They remain valuable for unexpected detachments, but firing on every boot for normal codec operation degrades their diagnostic value.

This series adds a simple boolean flag (unattach_pending) to struct sdw_slave that codec drivers can set before triggering an expected detach. When set, the bus layer emits dev_dbg() instead of dev_warn() and auto-clears the flag.

Note: There is also a separate set of UNATTACHED warnings during initial multi-device enumeration, caused by the known PING frame race documented in cadence_master.c. That is a different problem with different constraints and is not addressed here.

Cole Leavitt (2):
soundwire: bus: downgrade expected unattach warnings to dev_dbg
ASoC: cs35l56: set unattach_pending before SoundWire system reset

 drivers/soundwire/bus.c       | 9 +++++++--
 include/linux/soundwire/sdw.h | 1 +
 sound/soc/codecs/cs35l56.c    | 4 ++++
 3 files changed, 12 insertions(+), 2 deletions(-)
Signature · 1 line
2.52.0
#1 lore raw

PATCH 1/2 soundwire: bus: downgrade expected unattach warnings to dev_dbg

The sdw_handle_slave_status() function emits dev_warn() whenever a peripheral transitions to UNATTACHED from a previously ATTACHED state. While useful for debugging genuinely unexpected detachments, this warning also fires during normal operation when a codec driver intentionally triggers a system reset (e.g., after firmware download), causing unnecessary noise in the kernel log on every boot.

Add an 'unattach_pending' flag to struct sdw_slave that codec drivers can set before triggering an expected detach. When this flag is set, the bus layer emits a dev_dbg() instead of dev_warn() and clears the flag, preserving the warning for genuinely unexpected detachments.

---
 drivers/soundwire/bus.c       | 9 +++++++--
 include/linux/soundwire/sdw.h | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/soundwire/bus.c +7 -2
index fb68738dfb9b..a5a71ab1feed 100644
@@ -1899,8 +1899,13 @@ int sdw_handle_slave_status(struct sdw_bus *bus,
 
 		if (status[i] == SDW_SLAVE_UNATTACHED &&
 		    slave->status != SDW_SLAVE_UNATTACHED) {
-			dev_warn(&slave->dev, "Slave %d state check1: UNATTACHED, status was %d\n",
-				 i, slave->status);
+			if (slave->unattach_pending)
+				dev_dbg(&slave->dev, "Slave %d state check1: UNATTACHED (expected), status was %d\n",
+					i, slave->status);
+			else
+				dev_warn(&slave->dev, "Slave %d state check1: UNATTACHED, status was %d\n",
+					 i, slave->status);
+			slave->unattach_pending = false;
 			sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED);
 
 			/* Ensure driver knows that peripheral unattached */
include/linux/soundwire/sdw.h +1 -0
index f462717acf20..4318f2b144e1 100644
@@ -682,6 +682,7 @@ struct sdw_slave {
 	struct completion enumeration_complete;
 	struct completion initialization_complete;
 	u32 unattach_request;
+	bool unattach_pending;
 	bool first_interrupt_done;
 	bool is_mockup_device;
 	struct mutex sdw_dev_lock; /* protect callbacks/remove races */
Signature · 1 line
2.52.0
#2 lore raw

PATCH 2/2 ASoC: cs35l56: set unattach_pending before SoundWire system reset

In reply to Cole Leavitt

The CS35L56 driver triggers a system reset after firmware download and during initial probe when no hardware reset GPIO is available. This reset physically detaches the codec from the SoundWire bus while the driver waits for re-enumeration, which is expected and handled gracefully.

However, the bus layer emits a dev_warn() for this intentional transition to UNATTACHED because it cannot distinguish expected detachments from genuine failures. This produces misleading warnings on every boot for systems with CS35L56 codecs on SoundWire:

cs35l56 sdw:0:2:01fa:3556:01:0: Slave 2 state check1: UNATTACHED, status was 1 cs35l56 sdw:0:2:01fa:3556:01:1: Slave 1 state check1: UNATTACHED, status was 1

Set the unattach_pending flag on the SoundWire peripheral before triggering a system reset in both the firmware patch path and the initial probe soft reset path. This allows the bus layer to downgrade the warning to dev_dbg() for these expected transitions.

---
 sound/soc/codecs/cs35l56.c | 4 ++++
 1 file changed, 4 insertions(+)
sound/soc/codecs/cs35l56.c +4 -0
index 2ff8b172b76e..6566350a59c7 100644
@@ -807,6 +807,8 @@ static void cs35l56_patch(struct cs35l56_private *cs35l56, bool firmware_missing
 	reinit_completion(&cs35l56->init_completion);
 
 	cs35l56->soft_resetting = true;
+	if (cs35l56->sdw_peripheral)
+		cs35l56->sdw_peripheral->unattach_pending = true;
 	cs35l56_system_reset(&cs35l56->base, !!cs35l56->sdw_peripheral);
 
 	if (cs35l56->sdw_peripheral) {
@@ -1903,6 +1905,8 @@ int cs35l56_init(struct cs35l56_private *cs35l56)
 	if (!cs35l56->base.reset_gpio) {
 		dev_dbg(cs35l56->base.dev, "No reset gpio: using soft reset\n");
 		cs35l56->soft_resetting = true;
+		if (cs35l56->sdw_peripheral)
+			cs35l56->sdw_peripheral->unattach_pending = true;
 		cs35l56_system_reset(&cs35l56->base, !!cs35l56->sdw_peripheral);
 		if (cs35l56->sdw_peripheral) {
 			/* Keep alive while we wait for re-enumeration */
Signature · 1 line
2.52.0
#3 lore raw
In reply to Cole Leavitt
Quoted 6 lines · Cole Leavitt

On systems with CS35L56 SoundWire codecs (e.g. Lenovo ThinkPad P16 Gen3), every boot produces misleading dev_warn() messages:

   cs35l56 sdw:0:2:01fa:3556:01:0: Slave 2 state check1: UNATTACHED, status was 1
   cs35l56 sdw:0:2:01fa:3556:01:1: Slave 1 state check1: UNATTACHED, status was 1

Is this really a problem?
They are warns, not errors. Nothing in that message says that this is an error, or that it's unexpected. The message is accurate.

Quoted 30 lines

These fire when the CS35L56 driver triggers a system reset after firmware download, which physically detaches the codec from the bus. This is expected and handled gracefully -- the driver waits for re-enumeration and the codec recovers within milliseconds.

The warnings were added in commit d1b328557058 ("soundwire: bus: add dev_warn() messages to track UNATTACHED devices") to debug genuine attachment failures. They remain valuable for unexpected detachments, but firing on every boot for normal codec operation degrades their diagnostic value.

This series adds a simple boolean flag (unattach_pending) to struct sdw_slave that codec drivers can set before triggering an expected detach. When set, the bus layer emits dev_dbg() instead of dev_warn() and auto-clears the flag.

Note: There is also a separate set of UNATTACHED warnings during initial multi-device enumeration, caused by the known PING frame race documented in cadence_master.c. That is a different problem with different constraints and is not addressed here.

Cole Leavitt (2):
soundwire: bus: downgrade expected unattach warnings to dev_dbg
ASoC: cs35l56: set unattach_pending before SoundWire system reset

  drivers/soundwire/bus.c       | 9 +++++++--
  include/linux/soundwire/sdw.h | 1 +
  sound/soc/codecs/cs35l56.c    | 4 ++++
  3 files changed, 12 insertions(+), 2 deletions(-)
#4 lore raw
Quoted 11 lines · Richard Fitzgerald
Quoted 6 lines · Cole Leavitt

On systems with CS35L56 SoundWire codecs (e.g. Lenovo ThinkPad P16 Gen3), every boot produces misleading dev_warn() messages:

   cs35l56 sdw:0:2:01fa:3556:01:0: Slave 2 state check1: UNATTACHED, status was 1 cs35l56 sdw:0:2:01fa:3556:01:1: Slave 1 state check1: UNATTACHED, status was 1

Is this really a problem?
They are warns, not errors. Nothing in that message says that this is an error, or that it's unexpected. The message is accurate.

I would just demote the dev_warn() to dev_dbg().
If you look at the original commit, we were chasing weird cases where we have dyndng enabled anyways. Also IIRC the problem with 2 devices on the same link was fixed by Richard, wasn't it? That would make the dev_warn() even less useful.

#5 lore raw
Quoted 9 lines · Pierre-Louis Bossart
Quoted 8 lines · Richard Fitzgerald
Quoted 6 lines · Cole Leavitt

On systems with CS35L56 SoundWire codecs (e.g. Lenovo ThinkPad P16 Gen3), every boot produces misleading dev_warn() messages:

   cs35l56 sdw:0:2:01fa:3556:01:0: Slave 2 state check1: UNATTACHED, status was 1 cs35l56 sdw:0:2:01fa:3556:01:1: Slave 1 state check1: UNATTACHED, status was 1

Quoted 9 lines
Quoted 3 lines

Is this really a problem?
They are warns, not errors. Nothing in that message says that this is an error, or that it's unexpected. The message is accurate.

I would just demote the dev_warn() to dev_dbg().
If you look at the original commit, we were chasing weird cases where we have dyndng enabled anyways. Also IIRC the problem with 2 devices on the same link was fixed by Richard, wasn't it? That would make the dev_warn() even less useful.

Oh, does it date all the way back to that multiple device problem? If that's the one I'm thinking of, as I recall it was Simon Trimmer who fixed that.

#6 lore raw
In reply to Pierre-Louis Bossart
Quoted 9 lines · Pierre-Louis Bossart
Quoted 8 lines · Richard Fitzgerald
Quoted 6 lines · Cole Leavitt

On systems with CS35L56 SoundWire codecs (e.g. Lenovo ThinkPad P16 Gen3), every boot produces misleading dev_warn() messages:

   cs35l56 sdw:0:2:01fa:3556:01:0: Slave 2 state check1: UNATTACHED, status was 1 cs35l56 sdw:0:2:01fa:3556:01:1: Slave 1 state check1: UNATTACHED, status was 1

Quoted 8 lines
Quoted 3 lines

Is this really a problem?
They are warns, not errors. Nothing in that message says that this is an error, or that it's unexpected. The message is accurate.

I would just demote the dev_warn() to dev_dbg().
If you look at the original commit, we were chasing weird cases where we have dyndng enabled anyways. Also IIRC the problem with 2 devices on the same link was fixed by Richard, wasn't it? That would make the dev_warn() even less useful.

I would vote for either this or just leave it as is, doesn't seem worth the additional complexity to avoid it dynamically.

Thanks,
Charles

#7 lore raw

PATCH v2 1/1 soundwire: bus: demote UNATTACHED slave warnings to dev_dbg

In reply to Cole Leavitt

The dev_warn() messages in sdw_handle_slave_status() for UNATTACHED transitions were added in commit d1b328557058 ("soundwire: bus: add dev_warn() messages to track UNATTACHED devices") to debug attachment failures with dynamic debug enabled.

These warnings fire during normal operation -- for example when a codec driver triggers a system reset after firmware download, or during initial multi-device enumeration due to the PING frame race documented in cadence_master.c -- producing misleading noise on every boot.

The original debugging use case is fully served by dev_dbg(), which remains visible when dynamic debug is enabled. Demote both state check warnings to dev_dbg().

---
 drivers/soundwire/bus.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/soundwire/bus.c +4 -4
index fb68738dfb9b..45234cc07f35 100644
@@ -1899,8 +1899,8 @@ int sdw_handle_slave_status(struct sdw_bus *bus,
 
 		if (status[i] == SDW_SLAVE_UNATTACHED &&
 		    slave->status != SDW_SLAVE_UNATTACHED) {
-			dev_warn(&slave->dev, "Slave %d state check1: UNATTACHED, status was %d\n",
-				 i, slave->status);
+			dev_dbg(&slave->dev, "Slave %d state check1: UNATTACHED, status was %d\n",
+				i, slave->status);
 			sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED);
 
 			/* Ensure driver knows that peripheral unattached */
@@ -1951,8 +1951,8 @@ int sdw_handle_slave_status(struct sdw_bus *bus,
 			if (slave->status == SDW_SLAVE_UNATTACHED)
 				break;
 
-			dev_warn(&slave->dev, "Slave %d state check2: UNATTACHED, status was %d\n",
-				 i, slave->status);
+			dev_dbg(&slave->dev, "Slave %d state check2: UNATTACHED, status was %d\n",
+				i, slave->status);
 
 			sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED);
 			break;
Signature · 1 line
2.52.0
#8 lore raw

PATCH v3 1/1 soundwire: bus: demote UNATTACHED slave warnings to dev_dbg

In reply to Cole Leavitt

The dev_warn() messages in sdw_handle_slave_status() for UNATTACHED transitions were added in commit d1b328557058 ("soundwire: bus: add dev_warn() messages to track UNATTACHED devices") to debug attachment failures with dynamic debug enabled.

These warnings fire during normal operation -- for example when a codec driver triggers a system reset after firmware download, or during initial multi-device enumeration due to the PING frame race documented in cadence_master.c -- producing misleading noise on every boot.

The original debugging use case is fully served by dev_dbg(), which remains visible when dynamic debug is enabled. Demote both state check warnings to dev_dbg().

Fixes d1b328557058 ("soundwire: bus: add dev_warn() messages to track UNATTACHED devices")

---
Changes in v3:
- Add Fixes tag and version changelog

Changes in v2:
- Drop unattach_pending flag approach entirely per reviewer feedback (Pierre-Louis, Richard, Charles)
- Simply demote dev_warn() to dev_dbg() unconditionally
- Single patch instead of 2-patch series

 drivers/soundwire/bus.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/soundwire/bus.c +4 -4
index fb68738dfb9b..45234cc07f35 100644
@@ -1899,8 +1899,8 @@ int sdw_handle_slave_status(struct sdw_bus *bus,
 
 		if (status[i] == SDW_SLAVE_UNATTACHED &&
 		    slave->status != SDW_SLAVE_UNATTACHED) {
-			dev_warn(&slave->dev, "Slave %d state check1: UNATTACHED, status was %d\n",
-				 i, slave->status);
+			dev_dbg(&slave->dev, "Slave %d state check1: UNATTACHED, status was %d\n",
+				i, slave->status);
 			sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED);
 
 			/* Ensure driver knows that peripheral unattached */
@@ -1951,8 +1951,8 @@ int sdw_handle_slave_status(struct sdw_bus *bus,
 			if (slave->status == SDW_SLAVE_UNATTACHED)
 				break;
 
-			dev_warn(&slave->dev, "Slave %d state check2: UNATTACHED, status was %d\n",
-				 i, slave->status);
+			dev_dbg(&slave->dev, "Slave %d state check2: UNATTACHED, status was %d\n",
+				i, slave->status);
 
 			sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED);
 			break;
Signature · 1 line
2.52.0
#9 lore raw

Re: [PATCH v3] soundwire: bus: demote UNATTACHED slave warnings to dev_dbg

Quoted 9 lines · Cole Leavitt

The dev_warn() messages in sdw_handle_slave_status() for UNATTACHED transitions were added in commit d1b328557058 ("soundwire: bus: add dev_warn() messages to track UNATTACHED devices") to debug attachment failures with dynamic debug enabled.

These warnings fire during normal operation -- for example when a codec driver triggers a system reset after firmware download, or during initial multi-device enumeration due to the PING frame race documented in cadence_master.c -- producing misleading noise on every boot.

That second sentence doesn't seem right.
The problem documented in cadence_master.c was that devices may report as ATTACHED at the same time, but the detector only sees one device. As a result only one of the two devices would be assigned a non-zero device number.
But the second device does not lose sync and never becomes UNATTACHED.

Quoted 45 lines

The original debugging use case is fully served by dev_dbg(), which remains visible when dynamic debug is enabled. Demote both state check warnings to dev_dbg().

Fixes d1b328557058 ("soundwire: bus: add dev_warn() messages to track UNATTACHED devices")

---
Changes in v3:
- Add Fixes tag and version changelog

Changes in v2:
- Drop unattach_pending flag approach entirely per reviewer feedback (Pierre-Louis, Richard, Charles)
- Simply demote dev_warn() to dev_dbg() unconditionally
- Single patch instead of 2-patch series

 drivers/soundwire/bus.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/soundwire/bus.c +4 -4
index fb68738dfb9b..45234cc07f35 100644
@@ -1899,8 +1899,8 @@ int sdw_handle_slave_status(struct sdw_bus *bus,
 
 		if (status[i] == SDW_SLAVE_UNATTACHED &&
 		    slave->status != SDW_SLAVE_UNATTACHED) {
-			dev_warn(&slave->dev, "Slave %d state check1: UNATTACHED, status was %d\n",
-				 i, slave->status);
+			dev_dbg(&slave->dev, "Slave %d state check1: UNATTACHED, status was %d\n",
+				i, slave->status);
 			sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED);
 
 			/* Ensure driver knows that peripheral unattached */
@@ -1951,8 +1951,8 @@ int sdw_handle_slave_status(struct sdw_bus *bus,
 			if (slave->status == SDW_SLAVE_UNATTACHED)
 				break;
 
-			dev_warn(&slave->dev, "Slave %d state check2: UNATTACHED, status was %d\n",
-				 i, slave->status);
+			dev_dbg(&slave->dev, "Slave %d state check2: UNATTACHED, status was %d\n",
+				i, slave->status);
 
 			sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED);
 			break;
#10 lore raw

PATCH v4 1/1 soundwire: bus: demote UNATTACHED state warnings to dev_dbg()

In reply to Cole Leavitt

The dev_warn() messages in sdw_handle_slave_status() for UNATTACHED transitions were added in commit d1b328557058 ("soundwire: bus: add dev_warn() messages to track UNATTACHED devices") to debug attachment failures with dynamic debug enabled.

These warnings fire during normal operation -- for example when a codec driver triggers a hardware reset after firmware download, causing the device to momentarily go UNATTACHED before re-attaching -- producing misleading noise on every boot.

Demote the messages to dev_dbg() so they remain available via dynamic debug for diagnosing real attachment failures without alarming users during expected initialization sequences.

Fixes d1b328557058 ("soundwire: bus: add dev_warn() messages to track UNATTACHED devices")

---
Changes in v4:
- Remove incorrect PING frame race reference from commit message (Pierre-Louis Bossart)
- Clarify that the actual trigger is codec hardware reset after firmware download

Changes in v3:
- Add Fixes tag and version changelog

Changes in v2:
- Drop unattach_pending flag approach entirely per reviewer feedback (Pierre-Louis, Richard, Charles)
- Simply demote dev_warn() to dev_dbg() unconditionally
- Single patch instead of 2-patch series

 drivers/soundwire/bus.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/soundwire/bus.c +4 -4
index fb68738dfb9b..fe5316d93fef 100644
@@ -1899,8 +1899,8 @@ int sdw_handle_slave_status(struct sdw_bus *bus,
 
 		if (status[i] == SDW_SLAVE_UNATTACHED &&
 		    slave->status != SDW_SLAVE_UNATTACHED) {
-			dev_warn(&slave->dev, "Slave %d state check1: UNATTACHED, status was %d\n",
-				 i, slave->status);
+			dev_dbg(&slave->dev, "Slave %d state check1: UNATTACHED, status was %d\n",
+			i, slave->status);
 			sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED);
 
 			/* Ensure driver knows that peripheral unattached */
@@ -1951,8 +1951,8 @@ int sdw_handle_slave_status(struct sdw_bus *bus,
 			if (slave->status == SDW_SLAVE_UNATTACHED)
 				break;
 
-			dev_warn(&slave->dev, "Slave %d state check2: UNATTACHED, status was %d\n",
-				 i, slave->status);
+			dev_dbg(&slave->dev, "Slave %d state check2: UNATTACHED, status was %d\n",
+			i, slave->status);
 
 			sdw_modify_slave_status(slave, SDW_SLAVE_UNATTACHED);
 			break;
Signature · 1 line
2.52.0
maintainer Reviewed-by on v4 1/1
#11 lore raw

Re: [PATCH v4] soundwire: bus: demote UNATTACHED state warnings to dev_dbg()

Quoted 10 lines · Cole Leavitt

The dev_warn() messages in sdw_handle_slave_status() for UNATTACHED transitions were added in commit d1b328557058 ("soundwire: bus: add dev_warn() messages to track UNATTACHED devices") to debug attachment failures with dynamic debug enabled.

These warnings fire during normal operation -- for example when a codec driver triggers a hardware reset after firmware download, causing the device to momentarily go UNATTACHED before re-attaching -- producing misleading noise on every boot.

Quoted 7 lines

Demote the messages to dev_dbg() so they remain available via dynamic debug for diagnosing real attachment failures without alarming users during expected initialization sequences.

Fixes d1b328557058 ("soundwire: bus: add dev_warn() messages to track UNATTACHED devices")

---

maintainer Applied
#12 lore raw
In reply to Cole Leavitt
Quoted 6 lines · Cole Leavitt

On systems with CS35L56 SoundWire codecs (e.g. Lenovo ThinkPad P16 Gen3), every boot produces misleading dev_warn() messages:

cs35l56 sdw:0:2:01fa:3556:01:0: Slave 2 state check1: UNATTACHED, status was 1 cs35l56 sdw:0:2:01fa:3556:01:1: Slave 1 state check1: UNATTACHED, status was 1

Quoted 6 lines

These fire when the CS35L56 driver triggers a system reset after firmware download, which physically detaches the codec from the bus. This is expected and handled gracefully -- the driver waits for re-enumeration and the codec recovers within milliseconds.

[...]

Applied, thanks!

[1/1] soundwire: bus: demote UNATTACHED state warnings to dev_dbg()

      commit: 2c96956fe764f8224f9ec93b2a9160a578949a7a

Best regards,

Signature · 1 line
~Vinod