From: Stuart Hayes Date: Thu, 19 Sep 2024 04:31:43 +0000 (-0500) Subject: driver core: fix async device shutdown hang X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4f2c346e621624315e2a1405e98616a0c5ac146f;p=users%2Fjedix%2Flinux-maple.git driver core: fix async device shutdown hang Modify device_shutdown() so that supplier devices do not wait for consumer devices to be shut down first when the devlink is sync state only, since the consumer is not dependent on the supplier in this case. Without this change, a circular dependency could hang the system. Fixes: 8064952c6504 ("driver core: shut down devices asynchronously") Signed-off-by: Stuart Hayes Tested-by: Laurence Oberman Tested-by: Nathan Chancellor Link: https://lore.kernel.org/r/20240919043143.1194950-1-stuart.w.hayes@gmail.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/base/core.c b/drivers/base/core.c index b69b82da8837e..76513e360496b 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -4898,8 +4898,16 @@ void device_shutdown(void) idx = device_links_read_lock(); list_for_each_entry_rcu(link, &dev->links.suppliers, c_node, - device_links_read_lock_held()) + device_links_read_lock_held()) { + /* + * sync_state_only suppliers don't need to wait, + * aren't reordered on devices_kset, so making them + * wait could result in a hang + */ + if (device_link_flag_is_sync_state_only(link->flags)) + continue; link->supplier->p->shutdown_after = cookie; + } device_links_read_unlock(idx); put_device(dev);