Re: [PATCH] ASoC: soc-core: Create device_link to ensure correct suspend order

From: Richard Fitzgerald

Date: Fri Jun 05 2026 - 05:07:28 EST


On 01/06/2026 3:28 pm, Richard Fitzgerald wrote:
In snd_soc_bind_card() create a device_link from card to all components
to ensure correct order of system_suspend. The card is the consumer and
the components are the supplier, so that the card will system_suspend
before any of the components.

The PM core will normally system_suspend drivers in the opposite order
that they registered. This ensures children are suspended before their
parents, for example users of a bus driver should suspend before the bus
driver suspends.

For ASoC, snd_soc_suspend() shuts down any active audio, which requires
that the components are still able to communicate with their hardware.
Previously there was nothing to ensure this ordering, because there is
(usually) no relationship between a machine driver and component drivers.
If the machine driver registered before the codec drivers, the codec
drivers would be suspended before the machine driver snd_soc_suspend()
runs, so that ASoC is attempting to stop audio on a driver that has
already suspended.

Signed-off-by: Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx>
---
Mark,
I think it would be ok to put this into -next and let it get some wider
testing before it goes into 7.1 or older.

I was looking at the Sashiko review for this patch.
If Sashiko can be trusted, device_links seems to be thoroughly
booby-trapped.

Short summary seems to be: only safe way to use them is with the
STATELESS flag and do manual cleanup.