Skip to content

Commit 35a6723

Browse files
johnstultz-workgregkh
authored andcommitted
driver core: Ensure wait_for_device_probe() waits until the deferred_probe_timeout fires
In commit c8c43ce ("driver core: Fix driver_deferred_probe_check_state() logic"), we set the default driver_deferred_probe_timeout value to 30 seconds to allow for drivers that are missing dependencies to have some time so that the dependency may be loaded from userland after initcalls_done is set. However, Yoshihiro Shimoda reported that on his device that expects to have unmet dependencies (due to "optional links" in its devicetree), was failing to mount the NFS root. In digging further, it seemed the problem was that while the device properly probes after waiting 30 seconds for any missing modules to load, the ip_auto_config() had already failed, resulting in NFS to fail. This was due to ip_auto_config() calling wait_for_device_probe() which doesn't wait for the driver_deferred_probe_timeout to fire. This patch tries to fix the issue by creating a waitqueue for the driver_deferred_probe_timeout, and calling wait_event() to make sure driver_deferred_probe_timeout is zero in wait_for_device_probe() to make sure all the probing is finished. The downside to this solution is that kernel functionality that uses wait_for_device_probe(), will block until the driver_deferred_probe_timeout fires, regardless of if there is any missing dependencies. However, the previous patch reverts the default timeout value to zero, so this side-effect will only affect users who specify a driver_deferred_probe_timeout= value as a boot argument, where the additional delay would be beneficial to allow modules to load later during boot. Thanks to Geert for chasing down that ip_auto_config was why NFS was failing in this case! Cc: "David S. Miller" <[email protected]> Cc: Alexey Kuznetsov <[email protected]> Cc: Hideaki YOSHIFUJI <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: Rafael J. Wysocki <[email protected]> Cc: Rob Herring <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Yoshihiro Shimoda <[email protected]> Cc: Robin Murphy <[email protected]> Cc: Andy Shevchenko <[email protected]> Cc: Sudeep Holla <[email protected]> Cc: Andy Shevchenko <[email protected]> Cc: Naresh Kamboju <[email protected]> Cc: Basil Eljuse <[email protected]> Cc: Ferry Toth <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Anders Roxell <[email protected]> Cc: [email protected] Reported-by: Yoshihiro Shimoda <[email protected]> Tested-by: Geert Uytterhoeven <[email protected]> Tested-by: Yoshihiro Shimoda <[email protected]> Fixes: c8c43ce ("driver core: Fix driver_deferred_probe_check_state() logic") Signed-off-by: John Stultz <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4ccc03e commit 35a6723

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/base/dd.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ DEFINE_SHOW_ATTRIBUTE(deferred_devs);
226226

227227
int driver_deferred_probe_timeout;
228228
EXPORT_SYMBOL_GPL(driver_deferred_probe_timeout);
229+
static DECLARE_WAIT_QUEUE_HEAD(probe_timeout_waitqueue);
229230

230231
static int __init deferred_probe_timeout_setup(char *str)
231232
{
@@ -275,6 +276,7 @@ static void deferred_probe_timeout_work_func(struct work_struct *work)
275276

276277
list_for_each_entry_safe(private, p, &deferred_probe_pending_list, deferred_probe)
277278
dev_info(private->device, "deferred probe pending");
279+
wake_up(&probe_timeout_waitqueue);
278280
}
279281
static DECLARE_DELAYED_WORK(deferred_probe_timeout_work, deferred_probe_timeout_work_func);
280282

@@ -649,6 +651,9 @@ int driver_probe_done(void)
649651
*/
650652
void wait_for_device_probe(void)
651653
{
654+
/* wait for probe timeout */
655+
wait_event(probe_timeout_waitqueue, !driver_deferred_probe_timeout);
656+
652657
/* wait for the deferred probe workqueue to finish */
653658
flush_work(&deferred_probe_work);
654659

0 commit comments

Comments
 (0)