Re: [PATCH 3/4] ASoC: codecs: wsa884x: fix codec initialisation

From: Johan Hovold
Date: Fri Jan 02 2026 - 06:45:45 EST


On Fri, Jan 02, 2026 at 12:31:21PM +0100, Krzysztof Kozlowski wrote:
> On 02/01/2026 12:14, Johan Hovold wrote:
> > The soundwire update_status() callback may be called multiple times with
> > the same ATTACHED status but initialisation should only be done when
> > transitioning from UNATTACHED to ATTACHED.
> >
> > Fix the inverted hw_init flag which was set to false instead of true
> > after initialisation which defeats its purpose and may result in
> > repeated unnecessary initialisation.
>
> Either it results or it does not, not "may".

No, it depends on whether update_status() is called with the same status
more than once. So "may" is correct here.

> If the device moves to
> UNATTACHED state flag should be probably set to "true". This is the bug.

No, update_status() has:

if (wsa884x->hw_init || status != SDW_SLAVE_ATTACHED)
return 0;

...

wsa884x_init(wsa884x);

so if you set hw_init to true then init is never called when status is
changed to ATTACHED.

> >
> > Similarly, the initial state of the flag was also inverted so that the
> > codec would only be initialised and brought out of regmap cache only
> > mode if its status first transitions to UNATTACHED.
>
> Maybe that's confusing wording but existing code was intentional and IMO
> almost correct. The flag is saying - we need hw init - that's why it is
> set to true in the probe and to false AFTER the proper hw initialization
> which is done after ATTACHED state.

All other codec drivers have hw_init mean that init has been done and
the check in update_status() reflects that too so this driver is still
broken.

Johan