From patchwork Tue Apr 7 07:06:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 185231 Delivered-To: patches@linaro.org Received: by 2002:a92:de47:0:0:0:0:0 with SMTP id e7csp4535324ilr; Tue, 7 Apr 2020 00:06:19 -0700 (PDT) X-Received: by 2002:a17:902:fe04:: with SMTP id g4mr1144963plj.234.1586243179486; Tue, 07 Apr 2020 00:06:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586243179; cv=none; d=google.com; s=arc-20160816; b=O93ZEbnmcEbdSqv28taH474E/cNy03g5v2SBifL/bJ6lVCxM87NGoZgmfFvfSgHnwy /0pCZGZLQh3cEyZmJVGqvG0Ln59AwbxOD6X8bSvlAFcZldAfcmg9pu9CthUW67M38wNz bDtIJNdEX9HHh41gX1C2Fb3jNA6zce0i82HcameKkZtoXss4jeSwy5rrilTdLBbyBTNR +G6JDJjE/RYzU5DrrWHM5RoXvgEr1/buH+z9JkG38s9wMrkiz/744IfS3B0nFo/XX6J2 qZNwySrkn4SrLAtImVhiK0zFGCJFsamTKYvzZHVlHK+opSCoyyiTB1qdykEiNVMui1Ar nS8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xAVY7T1+cZqyUQSpaOqLvP0ADsbvMfjMiLxlWlklJPo=; b=pxoAtGP3cWWDEl4iOAzNc2IjFB++4P44iaPfdRr5/61JQPE2gbOEABU5HneW0hS7uF L8fBeKzQs7aJjhIfNMWHWYMklHNxYLui8ecvdnOcfrMpcKAFQ98OT+nzEClCBBBfqehq MQuJ8yawEzTi6i4ouDer4JtpOhTt629qSdbnNirZbo5wFtADdCdvuflIacp01MgjfOLO 2feTZ3/OyQE6UZbG1I83D+zUROXQUJCK0xqhn9TujR/mpFcWUWliUpPXArdoA9c744+D mGtvfajutJSEKapyDzcQaHmBjas13HZHuwyYdVr7oeJ6+QDugGTDM9IU1L777K0h25EG exOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pddZluUM; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id mn12sor954202pjb.7.2020.04.07.00.06.19 for (Google Transport Security); Tue, 07 Apr 2020 00:06:19 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pddZluUM; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xAVY7T1+cZqyUQSpaOqLvP0ADsbvMfjMiLxlWlklJPo=; b=pddZluUMZtOco59Dv37yDhn0NwXH3iQvM0Oq48SS68zWVnjH55cfcAZhaBOJy4u1rv tJMnbj26p7YyNtuecgLVHXc4lGwC12izuYcBXigtG4ewMwsQ7MRtsr4sqmF4Y4gOouAN j4g3UTq3JaV7GmqCVZl40LSiDLx3/t/+SrkL54U/sCBsgj9+ujSwVa7tMfyn2C2dayPY bP6W5wxM7/3dzSe52070VxoT/fwX1/EyPrSk1vSBJY/UvQnu+VTl+/A9VfH84cSqb0+Z mYSHWrP+R6wGxZhLHeBsD1dn2Y1Z3ljyanl7uyiyXbR9t3mgjDl4eE0Y2wiEqOSU3GRe UdeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xAVY7T1+cZqyUQSpaOqLvP0ADsbvMfjMiLxlWlklJPo=; b=R8+XOT2mP6IRZPeuQtB7xEeS/md7JjFmUwZuCS3BuMkk/5rRrLNDhBSzssT2PuOOAl s8jnDHslsg6O5kGp0kGWU4Sks2NPYwBgkAqMaQ+JH03CG0yYoB0eBkuramneRmE1WVRO 54nO6tNg3l97buAUs0TRJ/1OqdIecnisoe2Mq+pAJjiCgnR1iSXvTVgSdSSbhFjPCPu1 QlMfr30bhmQpJOzN5KcJfC6Z4Nk2O3jrtmQsKw0pA+eG74nlYJFLq6F3Ojq0kpfwJINT st47YIP5Uk5ldnsuUMM4H6hyt7ju/H3KXIiA1Udv5xFF5j/TPS/NgDJo562i2+Wi8DJo CWlg== X-Gm-Message-State: AGi0PuYg4EiYEq4sI03c5B7ASsbWTTLjf9LHjoDdJdte0qaJ98IntOqk Ag/o0iP4SE8CwuwN6qq92A0vk479 X-Google-Smtp-Source: APiQypI9ny5imcqnQwUupSAXYN43rwnatWBWoNOx4g9R3mWkwWVHU851cSuUArsLGxHk8bcLnyA8Cw== X-Received: by 2002:a17:90a:30c3:: with SMTP id h61mr1110597pjb.18.1586243179017; Tue, 07 Apr 2020 00:06:19 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id na18sm826900pjb.31.2020.04.07.00.06.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 00:06:18 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Jakub Kicinski , Greg Kroah-Hartman , "Rafael J . Wysocki" , Rob Herring , Geert Uytterhoeven , Yoshihiro Shimoda , netdev , linux-pm@vger.kernel.org Subject: [RFC][PATCH] driver core: Ensure wait_for_device_probe() waits until the deferred_probe_timeout fires Date: Tue, 7 Apr 2020 07:06:09 +0000 Message-Id: <20200407070609.42865-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In commit c8c43cee29f6 ("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. NOTE: I'm not 100% sure this won't have other unwanted side effects (I don't have failing hardware myself to validate), so I'd apprecate testing and close review. If this approach doesn't work, I'll simply set the default driver_deferred_probe_timeout value back to zero, to avoid any behavioral change from before. Thanks to Geert for chasing down that ip_auto_config was why NFS was failing in this case! Cc: "David S. Miller" Cc: Alexey Kuznetsov Cc: Hideaki YOSHIFUJI Cc: Jakub Kicinski Cc: Greg Kroah-Hartman Cc: Rafael J. Wysocki Cc: Rob Herring Cc: Geert Uytterhoeven Cc: Yoshihiro Shimoda Cc: netdev Cc: linux-pm@vger.kernel.org Reported-by: Yoshihiro Shimoda Fixes: c8c43cee29f6 ("driver core: Fix driver_deferred_probe_check_state() logic") Signed-off-by: John Stultz --- drivers/base/dd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 06ec0e851fa1..8c13f0df3282 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -232,9 +232,10 @@ DEFINE_SHOW_ATTRIBUTE(deferred_devs); int driver_deferred_probe_timeout = 30; #else /* In the case of !modules, no probe timeout needed */ -int driver_deferred_probe_timeout = -1; +int driver_deferred_probe_timeout; #endif EXPORT_SYMBOL_GPL(driver_deferred_probe_timeout); +static DECLARE_WAIT_QUEUE_HEAD(probe_timeout_waitqueue); static int __init deferred_probe_timeout_setup(char *str) { @@ -266,7 +267,7 @@ int driver_deferred_probe_check_state(struct device *dev) return -ENODEV; } - if (!driver_deferred_probe_timeout) { + if (!driver_deferred_probe_timeout && initcalls_done) { dev_WARN(dev, "deferred probe timeout, ignoring dependency"); return -ETIMEDOUT; } @@ -284,6 +285,7 @@ static void deferred_probe_timeout_work_func(struct work_struct *work) list_for_each_entry_safe(private, p, &deferred_probe_pending_list, deferred_probe) dev_info(private->device, "deferred probe pending"); + wake_up(&probe_timeout_waitqueue); } static DECLARE_DELAYED_WORK(deferred_probe_timeout_work, deferred_probe_timeout_work_func); @@ -658,6 +660,9 @@ int driver_probe_done(void) */ void wait_for_device_probe(void) { + /* wait for probe timeout */ + wait_event(probe_timeout_waitqueue, !driver_deferred_probe_timeout); + /* wait for the deferred probe workqueue to finish */ flush_work(&deferred_probe_work);