From patchwork Wed Apr 22 20:32:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 220725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 483BEC55185 for ; Wed, 22 Apr 2020 20:33:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 237A220882 for ; Wed, 22 Apr 2020 20:33:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jtXnZxTj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726615AbgDVUdW (ORCPT ); Wed, 22 Apr 2020 16:33:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726307AbgDVUdD (ORCPT ); Wed, 22 Apr 2020 16:33:03 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93A05C03C1AA for ; Wed, 22 Apr 2020 13:33:03 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id c21so579661plz.4 for ; Wed, 22 Apr 2020 13:33:03 -0700 (PDT) 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=tKbiuFbiZC2D1ImIHBQi0x36vK7Jcd27HL1H3KbbNwE=; b=jtXnZxTje+esnJi9OvNJ9lL0EfuD8nLu8pEU2HsoVZcg/CcP2zGyKA3ip87zMACuqC 8IlyHWtGZ3RDEGhMv1ojVcGzgcQ2UzGav1z8V9DVG46RPsrPFRbAQJKI1wqNKsZ/VnLa g3d28TJUfTOc2mB+OAcyAD67MLfZPLhPHuZLuE4I0tNKuDK5j5se4VPIjC56kkPNukxW nKMInSzxn/+VkR9MDaoQqWec8Mas1GxhOcVr5cZg3aNUZJBGcm5thaecm/GrELurVIjW 8OlM2Vqbe0pj6/rPfZGfZSokntDvKsAiIJnmF8cDaXKsHjGu82Twh55kz59Q60VlC2ct 0XDA== 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=tKbiuFbiZC2D1ImIHBQi0x36vK7Jcd27HL1H3KbbNwE=; b=fRkq2nmPcMHBwB5lI0LztY6r61Di2iOgV3n+AMulXdNGKvr/S1XWVr2F9Z8E/MrjZ2 uWjswHHyECHy2gwFeud6O6AFvuifBGmmkbg0Yuy5fzcQR3qOR9MfhmMUnzPSXALddmsl w+AnPucbqcDh316r5+FPmtJHmZ375L0UruNM4qbqcr2slPQl8kel2oj/QXBF7lBksaMx eLhd/bR0w8uPz/YmBQG6npLZwEAGYQL9BlPYvhq6dQnbY7IFhY00qjrAZpu3hma3+yxU wjDYRuQGfz/8ogL2PkE/u/OtV3kSfJvSFuGtTm5NW2vMd6/jsEAM+HRMyMDg8H4MQT7V m5DQ== X-Gm-Message-State: AGi0PuZb03Fzk3FDG5C/1au0j1+ga9TFYSOZpsCPdka3Omr97zaQ71Fe VI6Ey2vfg/2z7xnW/Hk4lEAAjA== X-Google-Smtp-Source: APiQypJU20peyuHuafIh34ajjRyIE0Frxlgkvku9w3XkjEew13yPlsFgnIJ3FqXvus+Ek2lmVgQrQg== X-Received: by 2002:a17:902:9347:: with SMTP id g7mr432520plp.77.1587587583090; Wed, 22 Apr 2020 13:33:03 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id b24sm360292pfd.175.2020.04.22.13.33.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2020 13:33:02 -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 , Robin Murphy , Andy Shevchenko , Sudeep Holla , Andy Shevchenko , Naresh Kamboju , Basil Eljuse , Ferry Toth , Arnd Bergmann , Anders Roxell , netdev , linux-pm@vger.kernel.org Subject: [PATCH v3 1/3] driver core: Revert default driver_deferred_probe_timeout value to 0 Date: Wed, 22 Apr 2020 20:32:43 +0000 Message-Id: <20200422203245.83244-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200422203245.83244-1-john.stultz@linaro.org> References: <20200422203245.83244-1-john.stultz@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch addresses a regression in 5.7-rc1+ In commit c8c43cee29f6 ("driver core: Fix driver_deferred_probe_check_state() logic"), we both cleaned up the logic and also 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. Fixing that issue is possible, but could also introduce 30 second delays in bootups for users who don't have any missing dependencies, which is not ideal. So I think the best solution to avoid any regressions is to revert back to a default timeout value of zero, and allow systems that need to utilize the timeout in order for userland to load any modules that supply misisng dependencies in the dts to specify the timeout length via the exiting documented boot argument. 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: Robin Murphy Cc: Andy Shevchenko Cc: Sudeep Holla Cc: Andy Shevchenko Cc: Naresh Kamboju Cc: Basil Eljuse Cc: Ferry Toth Cc: Arnd Bergmann Cc: Anders Roxell Cc: netdev Cc: linux-pm@vger.kernel.org Reported-by: Yoshihiro Shimoda Tested-by: Yoshihiro Shimoda Fixes: c8c43cee29f6 ("driver core: Fix driver_deferred_probe_check_state() logic") Signed-off-by: John Stultz --- drivers/base/dd.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 06ec0e851fa1..908ae4d7805e 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -224,16 +224,7 @@ static int deferred_devs_show(struct seq_file *s, void *data) } DEFINE_SHOW_ATTRIBUTE(deferred_devs); -#ifdef CONFIG_MODULES -/* - * In the case of modules, set the default probe timeout to - * 30 seconds to give userland some time to load needed modules - */ -int driver_deferred_probe_timeout = 30; -#else -/* In the case of !modules, no probe timeout needed */ -int driver_deferred_probe_timeout = -1; -#endif +int driver_deferred_probe_timeout; EXPORT_SYMBOL_GPL(driver_deferred_probe_timeout); static int __init deferred_probe_timeout_setup(char *str) @@ -266,7 +257,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; } From patchwork Wed Apr 22 20:32:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 220726 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F15ACC5518C for ; Wed, 22 Apr 2020 20:33:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BFEC920857 for ; Wed, 22 Apr 2020 20:33:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LEbaRv0d" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726512AbgDVUdI (ORCPT ); Wed, 22 Apr 2020 16:33:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726489AbgDVUdH (ORCPT ); Wed, 22 Apr 2020 16:33:07 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49BBEC03C1AB for ; Wed, 22 Apr 2020 13:33:06 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id g6so1673387pgs.9 for ; Wed, 22 Apr 2020 13:33:06 -0700 (PDT) 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=pMZgWl7gaqwxky4xlW6XJbmApvfvRuOxXJn93EkCWVo=; b=LEbaRv0dypc5e5Wc7a84Kw/SbMBDatTaHXbP6iCorD9zGzR1nVNn357pTZEPJbSGH8 DO6J+hGiFfATe4XvgoRwKD/iyt+vOghi0A+9lXjvJKQSSngW7mtkvUKJRtMFXag3XuGi kS1lvfmsj1CAadjzqIYzXXp3EGdkoP2Vb3RtgOpOrpr9uGeAie7EZkyNnSjLFFB/VIX+ cN/PSUP9+7xo5gVqezBN8MHq4yT+hnWXekDCIk3KvZ8RWPcHzzx5WEr2650WPRMUN3Sz od9S/oDQyg22NNcbzi4ErXcO0GuJt9RE4qxMlIr7y0GU4oeBhtj10hVFiTQCWHBjJ7SA 00qA== 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=pMZgWl7gaqwxky4xlW6XJbmApvfvRuOxXJn93EkCWVo=; b=LXWn6FJHWd3dJ2x6VGaxEXaSvJHOHsqRxGh/5GNsRLZZTnuPhGtXxxDT/w25F5oRlo 3pUrV+C3VtyswL1rhL7Y6noEB8iFR9K1lOYB7Z3LHf27Ef2QB0WjSQGC2hMdhmmDR+AY YsDJf2V/o+THmKqXKcMlqvabX1ArMZznSPPO6VYAdnyqoRq01kVMf2nduJlf/j2upV/4 oRCSNgYEWAVrw9/lz6fiLCtato5GwyndG97zhZqvCWv7IkLZus7ZFebAt/pwVpAW/g55 NEt3OcEGEwF4opXL12NNFijdhCgkhroP/Af7EbZGoSWAcghGIplA5rXlXP3VO6yzyIcm UZWw== X-Gm-Message-State: AGi0Puavgd7eNSb5U2Xn+07KOgKA0Uf2Zih09QLxDGQ3jOIh/hrFjjNp 3b5k3xlGtqt20UUbB4Gsgnnkiw== X-Google-Smtp-Source: APiQypIk7f8O7AVplXsto40VZokGnKKYUx0F+SKxFkELYuo0ol20r/CNbNqbITXVgN8Ro9fNiSWIaA== X-Received: by 2002:a63:ef4b:: with SMTP id c11mr760981pgk.400.1587587585769; Wed, 22 Apr 2020 13:33:05 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id b24sm360292pfd.175.2020.04.22.13.33.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2020 13:33:05 -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 , Robin Murphy , Andy Shevchenko , Sudeep Holla , Andy Shevchenko , Naresh Kamboju , Basil Eljuse , Ferry Toth , Arnd Bergmann , Anders Roxell , netdev , linux-pm@vger.kernel.org Subject: [PATCH v3 3/3] driver core: Ensure wait_for_device_probe() waits until the deferred_probe_timeout fires Date: Wed, 22 Apr 2020 20:32:45 +0000 Message-Id: <20200422203245.83244-4-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200422203245.83244-1-john.stultz@linaro.org> References: <20200422203245.83244-1-john.stultz@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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. 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" 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: Robin Murphy Cc: Andy Shevchenko Cc: Sudeep Holla Cc: Andy Shevchenko Cc: Naresh Kamboju Cc: Basil Eljuse Cc: Ferry Toth Cc: Arnd Bergmann Cc: Anders Roxell Cc: netdev Cc: linux-pm@vger.kernel.org Reported-by: Yoshihiro Shimoda Tested-by: Yoshihiro Shimoda Fixes: c8c43cee29f6 ("driver core: Fix driver_deferred_probe_check_state() logic") Signed-off-by: John Stultz --- drivers/base/dd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 9c88afa5c74a..94037be7f5d7 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -226,6 +226,7 @@ DEFINE_SHOW_ATTRIBUTE(deferred_devs); int driver_deferred_probe_timeout; EXPORT_SYMBOL_GPL(driver_deferred_probe_timeout); +static DECLARE_WAIT_QUEUE_HEAD(probe_timeout_waitqueue); static int __init deferred_probe_timeout_setup(char *str) { @@ -275,6 +276,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); @@ -649,6 +651,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);