Re: [PATCH 3/5] driver core: async device shutdown infrastructure

Bjorn Helgaas
2026-03-11T23:05:25Z

On Wed, Mar 11, 2026 at 01:12:07PM -0400, David Jeffery wrote:
> Patterned after async suspend, allow devices to mark themselves as wanting
> to perform async shutdown. Devices using async shutdown wait only for their
> dependencies to shutdown before executing their shutdown routine.

I'm not an expert on dependencies. Is it obvious to everybody else
how these dependencies are expressed? What would I look at to verify
that, for example, PCI devices are dependencies of the PCI bridges
leading to them? I suppose it's the same dependencies used for
suspend?

From wait_for_shutdown_dependencies() below, it looks like we'll wait
for each child of dev and then wait for each consumer of dev before
shutting down dev itself.

> Sync shutdown devices are shut down one at a time and will only wait for an
> async shutdown device if the async device is a dependency.

> @@ -132,6 +133,7 @@ struct device_private {
> #ifdef CONFIG_RUST
> struct driver_type driver_type;
> #endif
> + struct completion complete;

I thought "complete" might be a little too generic, but I guess async
suspend uses "dev->power.completion" :)

> +static void wait_for_shutdown_dependencies(struct device *dev, bool async)
> +{
> + struct device_link *link;
> + int idx;
> +
> + device_for_each_child(dev, &async, wait_for_device_shutdown);
> +
> + idx = device_links_read_lock();
> +
> + dev_for_each_link_to_consumer(link, dev)
> + if (!device_link_flag_is_sync_state_only(link->flags))
> + wait_for_device_shutdown(link->consumer, &async);
> +
> + device_links_read_unlock(idx);
> +}

> @@ -4828,6 +4919,12 @@ void device_shutdown(void)
>
> cpufreq_suspend();
>
> + /*
> + * Start async device threads where possible to maximize potential
> + * paralellism and minimize false dependency on unrelated sync devices

s/paralellism/parallelism/