RE: [PATCH] soundwire: only handle alert events when the peripheral is attached
From: Liao, Bard
Date: Wed May 20 2026 - 22:26:33 EST
> -----Original Message-----
> From: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxx>
> Sent: Thursday, May 21, 2026 1:21 AM
> To: Bard Liao <yung-chuan.liao@xxxxxxxxxxxxxxx>; linux-
> sound@xxxxxxxxxxxxxxx; vkoul@xxxxxxxxxx
> Cc: vinod.koul@xxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx;
> peter.ujfalusi@xxxxxxxxxxxxxxx; Liao, Bard <bard.liao@xxxxxxxxx>
> Subject: Re: [PATCH] soundwire: only handle alert events when the peripheral
> is attached
>
> On 5/20/26 04:57, Bard Liao wrote:
> > 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.
>
> 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.
>
> > Signed-off-by: Bard Liao <yung-chuan.liao@xxxxxxxxxxxxxxx>
> > Reviewed-by: Péter Ujfalusi <peter.ujfalusi@xxxxxxxxxxxxxxx>
> > Reviewed-by: Ranjani Sridharan <ranjani.sridharan@xxxxxxxxxxxxxxx>
> > ---
> > drivers/soundwire/bus.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
> > index fe5316d93fef..0490777fa406 100644
> > --- a/drivers/soundwire/bus.c
> > +++ b/drivers/soundwire/bus.c
> > @@ -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,