soundwire: only handle alert events when the peripheral is attached
Bard Liao
maintainerPATCH 1/1 soundwire: only handle alert events when the peripheral is attached
It doesn't make sense to handle an alert event when the peripheral is not attached. The slave->status could be SDW_SLAVE_ATTACHED or SDW_SLAVE_ALERT when it is attached on the bus.
--- drivers/soundwire/bus.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/soundwire/bus.c +4 -0
@@ -1958,6 +1958,10 @@ int sdw_handle_slave_status(struct sdw_bus *bus,break ;case SDW_SLAVE_ALERT : +if (slave->status !=SDW_SLAVE_ATTACHED && + slave->status !=SDW_SLAVE_ALERT ) +continue ; + ret =sdw_handle_slave_alerts (slave);if (ret <0 ) dev_err(&slave->dev,
Signature · 1 line
2.43.0
Pierre-Louis Bossart
reviewerQuoted 3 lines · Bard Liao
It doesn't make sense to handle an alert event when the peripheral is not attached. The
slave->statuscould beSDW_SLAVE_ATTACHEDorSDW_SLAVE_ALERTwhen it is attached on the bus.
How would you get an ALERT if the peripheral is not attached in the first place? The status is only reported in a PING frame after enumeration.
Not following what this new test is needed for...
Quoted 22 lines
Signed-off-by Bard Liao <[email protected]>Reviewed-by Péter Ujfalusi <[email protected]>Reviewed-by Ranjani Sridharan <[email protected]>--- drivers/soundwire/bus.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/soundwire/bus.c +4
-0@@ -1958,6 +1958,10 @@ int sdw_handle_slave_status(struct sdw_bus *bus,break ;case SDW_SLAVE_ALERT : +if (slave->status !=SDW_SLAVE_ATTACHED && + slave->status !=SDW_SLAVE_ALERT ) +continue ; + ret =sdw_handle_slave_alerts (slave);if (ret <0 ) dev_err(&slave->dev,
Quoted 13 lines
-----Original Message-----
From: Pierre-Louis Bossart <[email protected]>
Sent: Thursday, May 21, 2026 1:21 AM
To: Bard Liao <[email protected]>; linux- [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; Liao, Bard <[email protected]>
Subject: Re: [PATCH] soundwire: only handle alert events when the peripheral is attachedOn 5/20/26 04:57, Bard Liao wrote:
Quoted 8 lines
Quoted 3 lines
It doesn't make sense to handle an alert event when the peripheral is not attached. The
slave->statuscould beSDW_SLAVE_ATTACHEDorSDW_SLAVE_ALERTwhen it is attached on the bus.How would you get an ALERT if the peripheral is not attached in the first place? The status is only reported in a PING frame after enumeration.
Not following what this new test is needed for...
It could be a race condition. We meet the issue rarely when running suspend/resume test. sdw_handle_slave_alerts() is called when the peripheral is still unattached. Hope this patch can filter this corner case.
Quoted 24 lines
drivers/soundwire/bus.c int sdw_handle_slave_status(struct sdw_bus
Quoted 13 lines
Signed-off-by Bard Liao <[email protected]>Reviewed-by Péter Ujfalusi <[email protected]>Reviewed-by Ranjani Sridharan <[email protected]>--- drivers/soundwire/bus.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/soundwire/bus.c +0
-0@@ -1958,6 +1958,10 @@ int sdw_handle_slave_status(struct sdw_bus*bus,
Quoted 10 lines
drivers/soundwire/bus.c +4
-0break ;case SDW_SLAVE_ALERT : +if (slave->status !=SDW_SLAVE_ATTACHED && + slave->status !=SDW_SLAVE_ALERT ) +continue ; + ret =sdw_handle_slave_alerts (slave);if (ret <0 ) dev_err(&slave->dev,
Quoted 20 lines · Bard
Quoted 20 lines
-----Original Message-----
From: Pierre-Louis Bossart <[email protected]>
Sent: Thursday, May 21, 2026 1:21 AM
To: Bard Liao <[email protected]>; linux- [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; Liao, Bard <[email protected]>
Subject: Re: [PATCH] soundwire: only handle alert events when the peripheral is attachedQuoted 3 lines · Bard Liao
It doesn't make sense to handle an alert event when the peripheral is not attached. The
slave->statuscould beSDW_SLAVE_ATTACHEDorSDW_SLAVE_ALERTwhen it is attached on the bus.How would you get an ALERT if the peripheral is not attached in the first place? The status is only reported in a PING frame after enumeration.
Quoted 6 lines
Quoted 1 line
Not following what this new test is needed for...
It could be a race condition. We meet the issue rarely when running suspend/resume test.
sdw_handle_slave_alerts()is called when the peripheral is still unattached. Hope this patch can filter this corner case.
Humm, it doesn't seem like this patch fixes the issue completely.
Either the status read from the Cadence registers is wrong, possibly due to a power-up sequence that doesn't reset registers properly. Or there's a race indeed where the enumeration happens but somehow the status isn't saved before the alert comes in.
At any rate this patch is probably not enough but it's not wrong either so
Quoted 24 lines
Quoted 23 lines
drivers/soundwire/bus.c int sdw_handle_slave_status(struct sdw_bus
Quoted 12 lines
Signed-off-by Bard Liao <[email protected]>Reviewed-by Péter Ujfalusi <[email protected]>Reviewed-by Ranjani Sridharan <[email protected]>--- drivers/soundwire/bus.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/soundwire/bus.c +0
-0@@ -1958,6 +1958,10 @@ int sdw_handle_slave_status(struct sdw_bus*bus,
Quoted 10 lines
drivers/soundwire/bus.c +4
-0break ;case SDW_SLAVE_ALERT : +if (slave->status !=SDW_SLAVE_ATTACHED && + slave->status !=SDW_SLAVE_ALERT ) +continue ; + ret =sdw_handle_slave_alerts (slave);if (ret <0 ) dev_err(&slave->dev,
Quoted 5 lines · Bard Liao
It doesn't make sense to handle an alert event when the peripheral is not attached. The
slave->statuscould beSDW_SLAVE_ATTACHEDorSDW_SLAVE_ALERTwhen it is attached on the bus.
Applied, thanks!
[1/1] soundwire: only handle alert events when the peripheral is attached
commit: 38cd651ebce7065a81c7e950d9e2ea1572304605
Best regards,
Signature · 1 line
~Vinod