From patchwork Wed Apr 8 07:26:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 185270 Delivered-To: patches@linaro.org Received: by 2002:a92:de47:0:0:0:0:0 with SMTP id e7csp267344ilr; Wed, 8 Apr 2020 00:26:55 -0700 (PDT) X-Received: by 2002:a62:2a8d:: with SMTP id q135mr6742557pfq.220.1586330815358; Wed, 08 Apr 2020 00:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586330815; cv=none; d=google.com; s=arc-20160816; b=CIuTSuRANYHwcR8SvhmGxsSSukNZxTA5fzYI+iXvq5TsRDPQO4Yoeni/L7xFN1Jd3d t6iRJGX/byPum8xOZSfH8iCqEKanIz2asBynGFZkezrB/MUpkO1kTQ3jrwiuVFThi4t4 uynpDb3zWOW1lrNTL6uw5Byxv57TjKC9Ag7sJvnD1m8whBqqTI97T8EHzwb+8RSzvctL 859QmI9i02jFQui7XVHkiDSURMPQa+emn3DcyNpgAAGycBlenMRpO2OjHCKbrnuhJonU KxhITN7p0/+X7sMH7k8cH8RYzPFqimLePHJB7DC6l65LYj0/zNDcV0x9ZEn01IjaMGVV eEXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=RR92PJz/vfU5+w5Mw1m+JK7ovH9yXMWn2/XVn86hUF4=; b=aMmL35FznW9LLiGR86ZcYnmWySe256HlpOfl39YcJSwryIW8Kh7N+8uZIZcfiH3Pk8 E/QxLN8EynLg2Fm1JCKQWO1p2NIT5X7hNykBdfG7N5Cr6Q6wMH6OztzGXimmXNiamVUv kgtOdgX8dX9nst0Q5ZiYlS/H/uASaaoToR0FwXj4q42iGavhY6jFvzf95UlTmzxtzJW6 dHasOf1dP8TEehkS3BM5KnGVKBHTXIhUxm8NNz+Gp1ryx0tSlIqvp786Q9zQ/owpelnI fAjkURspNUM6OHOAqw7JJGv/MmgdjZo2eP/QIgxkO8rOuJ3EuixciAXg7SXxGaOBOIDe rN0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="o9b/IpfO"; 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 a23sor6945193pff.51.2020.04.08.00.26.55 for (Google Transport Security); Wed, 08 Apr 2020 00:26:55 -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="o9b/IpfO"; 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; bh=RR92PJz/vfU5+w5Mw1m+JK7ovH9yXMWn2/XVn86hUF4=; b=o9b/IpfOWX3nEWUPGPu6RG3SPuwiAKT/BMhB1+9/Kqv0fSB7vvdjWW1G+KaVsOfOgM r63wgBLsagQyRFpa3sML0m01aNH73sDIWQr5AZk2BUBOnjfhPmwj15A4J9269Y4eQL3A Aiy5PKV4bPb7xjbvqrNthovakqZ4XwH4m8acy7b+ipuIaF+yCnQ823+p4WB5HuSQTczU hS9RoyvPcKYjCNRfA4LDhhuNw0jrxtbeA9tcxUYpeFKJ6nQ645+j5wa2jjWRL3LhsdxQ sFmH767KJfS6IpcxfZ1FUM8vvbmAYo605CSd+aaSpnObNA4IR4EsC+FdYbwxWONGAjKA 9/Ng== 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; bh=RR92PJz/vfU5+w5Mw1m+JK7ovH9yXMWn2/XVn86hUF4=; b=kogFDTanyqr67klx7aWBbZ7b5OjLAOS0i6wZsCq7SCyiavhbR4PLgDAaHSKJIivkgj fSUA/q859c9oGbexpqP5+XglEuIs2O5vdXBzr2cViWSyCxLyJnmopa7rqundVdJqYPu6 HaGcV1xp86qdY3uZc9mbwMsDeZlXYhGIVyfkptNedPaWtl+BvvBG7N9XQ9NGXZMHV34c xu13dEjgjrMNp1Qx8jWpLH/cBrwqT/x2KEZ3csRgaNThY6HaSjfO2jeQQTwwxzw4l5Re YpsU6AKCdgZevz3seOXQHjRYPJK7uF2cPvBdHTtXFvmKe1n1jJwIKNRpuoK5mCKLBjO+ d5mQ== X-Gm-Message-State: AGi0PuYo0+smAsBR9n8sZLrUIX4jr6z3uFhTTx0jM5cLlmwmteBLpGp/ qk/PFHL/eXkZL41hshGJv5S+egsV8tt2yA== X-Google-Smtp-Source: APiQypI1PwvJKIu1MMqj4sk2SnhJoHI5jNaR8zvH0OAV2wrNTN00E9sg3z8mY1eZAALQB+ttBEMrWw== X-Received: by 2002:aa7:880c:: with SMTP id c12mr5940143pfo.77.1586330814919; Wed, 08 Apr 2020 00:26:54 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id e187sm15356066pfe.143.2020.04.08.00.26.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 00:26:54 -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 v2 1/2] driver core: Revert default driver_deferred_probe_timeout value to 0 Date: Wed, 8 Apr 2020 07:26:49 +0000 Message-Id: <20200408072650.1731-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 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: 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 | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) -- 2.17.1 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 8 07:26:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 185271 Delivered-To: patches@linaro.org Received: by 2002:a92:de47:0:0:0:0:0 with SMTP id e7csp267386ilr; Wed, 8 Apr 2020 00:26:59 -0700 (PDT) X-Received: by 2002:a17:902:c193:: with SMTP id d19mr6063678pld.327.1586330818671; Wed, 08 Apr 2020 00:26:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586330818; cv=none; d=google.com; s=arc-20160816; b=mwDdDolK26MJcDNMi83qYWjBW4TO27uVZAi4YuWhoQ3YvjGXBOE6BTE5dshO7Y52Mj D0eEgz6qYAGJPBu4OOVa6brCeReg9mCNtqOk8wd7Ba6MozM7t1cBeqWtMSfOqkISSntA TVTD6ogX6ObZnG67+/XlvAnZBfLvYaKYTxXstFofA3IhWwmN3/QBO2nnE8UMY0Z/3HZf V+1efrWiZkTKaylYELdilhjwc08NrrKz3w18cubbFdDO4ifPTV2gp8PQPVpCnE3N2Ksi 9HcW4l2+LnncF2+rZtypqlkXub28bSitBz2FDUJRZZUy5Oxk1jzD/os5ihvIXS0kr0/D dUzA== 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=MmpEQ8SQC6Xl5tR7Jjj5y8uD8BC/8L8xLziXkQ0TWVI=; b=GAPjp7W6+iAz/dUTG6Lup4h1snnPSEU16yglDRbALJGjr7QQqCVflhdkSVg/pItwhA AWvEpV6PO9yZZOwGYC4uk5SPe3o6kjlvsoAaRsPRKkNTMwC1hLEohmeZE3HxeN9pYQZB owNSxfxK+gUx3K9TzsCF7y63hNjZ5WDs/fAgcTRTL/Ijz3PnmeZT/Nm2M6+MP11NShU1 mC0ZX90QOj2y21BAq+V1/B9cZmnoYJG1hL2/aJ3LNkv2q0dwauXhbqj2bcZ5bHjiX0Z4 KN4CtyClpCbpjECR18LF5HI0FcmTke/iun4TMXPdm46tII/60aGx6EgCV4w0I66ndVsZ dVhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z+eW7VdI; 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 59sor6816280plf.23.2020.04.08.00.26.58 for (Google Transport Security); Wed, 08 Apr 2020 00:26:58 -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=Z+eW7VdI; 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=MmpEQ8SQC6Xl5tR7Jjj5y8uD8BC/8L8xLziXkQ0TWVI=; b=Z+eW7VdIANVP+y7K6bQ7lohbpmARsE8zZhuKT6N6QZUHELquqVNPm9CQ7F1SLG7RYS QIdpR3lDKGieyLPJ0t7fBN9hqU017Ekfn1idJP58ax8+d6CR4DdzOSkuV9dAs/B0PhgF DSZFB10RTROOOWvuV4752//VE1+P9z1sNXB83AHPCBQT51jB8SkiisAOqvfedZ58/p8d YwGW5wlHsBud4pZ0OLcZ6LYZESBsqCRrVY2oC/ziYwL9X1n2QCZYKLe71lpMS6FC8adA +uhz6cm1LtsjPcCIGOdBcTHcmEqpXVzn7LY68DsRxuCjOCLb2zkaEKfO3HL6LxETGtG7 Hsug== 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=MmpEQ8SQC6Xl5tR7Jjj5y8uD8BC/8L8xLziXkQ0TWVI=; b=UUaeSxwfegQgXG43TGz1Tsiau5gMJE28yRcbPDXFB8esRqRhwC0+SpEPqFNN1urMHI R8lA0+DbH2A2yhTRhw/NZr5YBqNL/v16eU5i28ulgGEZSiRmpXil3KFEEjvnGEkIsqnc rZ5Vs4keofDvrysDbeOh+U11K8gj3Lx4NRe4kRFdXVfDazISPEEK5fxeZLOVCIYT6JiP JWTs4lKOhrBL2Mifh7WSmmLnoBG8M+pngSpWdUQyE4HAGbsRHk6eLKaJjA6cPhJg8Miy fa8G8zMCIdI4dJJnKt9r73ywHba8fm/DWvACF4oW3Mz3GegH7vDxkPonqsiMxCOGtuo0 YekA== X-Gm-Message-State: AGi0PuZHyL2zZCpqdIGG/8/0Nxj9AkQpfROTSwWG/0Kl53HnlqU8voOb +rHsk4cd77Jsmh/rC5Pz3LatQJ6T X-Google-Smtp-Source: APiQypJY5jt1Z+kCEh8DOZw5UuW9RxeqX3HfnqdnLIu6JVDPye1OyCCRnTHl4q5Efv/HapSv97ToSg== X-Received: by 2002:a17:902:d303:: with SMTP id b3mr5933935plc.63.1586330818286; Wed, 08 Apr 2020 00:26:58 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id e187sm15356066pfe.143.2020.04.08.00.26.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2020 00:26:57 -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 v2 2/2] driver core: Ensure wait_for_device_probe() waits until the deferred_probe_timeout fires Date: Wed, 8 Apr 2020 07:26:50 +0000 Message-Id: <20200408072650.1731-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200408072650.1731-1-john.stultz@linaro.org> References: <20200408072650.1731-1-john.stultz@linaro.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: 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 --- * v2: Split patch, and apply it as a follow-on to setting the driver_deferred_probe_timeout defalt back to zero --- drivers/base/dd.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.17.1 diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 908ae4d7805e..5e6c00176969 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);