From patchwork Mon Apr 13 20:42:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 185378 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp650542ilf; Mon, 13 Apr 2020 13:43:05 -0700 (PDT) X-Received: by 2002:a17:90a:fa08:: with SMTP id cm8mr23701934pjb.144.1586810585090; Mon, 13 Apr 2020 13:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586810585; cv=none; d=google.com; s=arc-20160816; b=mlJ8kvu1oHOARTCJDbyJfRlCJsdSOnLgf5yIpwMSEcGBBebKz57Mi3mwncJohHgF4s 8UnXhx53Tyy5Eb00K3y2UT6bJxGD1Jut2M5MaKOXDtR2LgpJGVidr+jqre5v06WQiGs/ x1ipJXe+O7wA10HOpDa06V45IeM8pqZlFN8mkASf7P2sr1Gzjk6v+k730y0vV/ygDki5 +t9eeQJM/m0axnzuIZR5F+3JxYbP1R9f476Y7BDDLGdNMek4s603WKqSHb0fcSf2oI9e MIY1T5r1c7RhZF2RbSv1MUm0TQClV5leUVV/uZtJXGsbMm32bmPVV53Ob5AdkjaN/NX7 FYRA== 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=qou+3DHiFyCOtLsGQReefr67dF1uugnjJ0cGHULWluA=; b=n9U0KMElhXT+Ue4MeFOhFcImTcUwG3Fw6aI/q3js9atUTYHYtsRIafwk+IhQb7FdYK oNI7JG/mO5Qw3ojd8+VmQ+vFvznwUFD/a+7BT2toYwun1Vpyj22onty4n0214H9k508P ssLh//pJEC3zk1+cJL2mepGC8jl1x5KxQ0+U85YFpaMQ29ydaal0M7jVxh+ISGgHW4iE F9V8RBa1+cpRAwCpzkQbO4mltWC/nVqYfTwdnJZ6zYVkK1Lt3rl1W2HfOmZt5HBi9+/k IJzzDmNuI63KRslVy1jJIL+y3bWIn1HKvHMvZAJAugw1uGSjQk1MTu3XLy6+qzNU+Udk Ae1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=coykwgBI; 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 x126sor15571313pfb.68.2020.04.13.13.43.04 for (Google Transport Security); Mon, 13 Apr 2020 13:43:05 -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=coykwgBI; 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=qou+3DHiFyCOtLsGQReefr67dF1uugnjJ0cGHULWluA=; b=coykwgBIjHG5yqhbB92pLtYlavZqUPgMd8wp5wB4N0ep3Pf5b4P28noLdtnsX6vzhh DNUJhUpz04+jf0QCaP7dfox9eLLytpEK81PCZueXMA+BucEzHpYf0u3Cv57GZ4spGJbY galRVU88OpWrtJovA8bUMMqkROLS1K5zKlCn6vYohvCPK4l1nGyCUzDqgrLL3Y6DjoTs U51qY0k4hzI8u9eow/McGhyhcWEwrRuGWaA993blXxW1b5Lk0dLMcCYF/JrX3R3lMLCt cXpDakv1GwPUri1c4OcZlJdyrCXgJQDFlSriV1eJcSQW+7yFRU2sz5sVj6wR6oQH2Wix MQnw== 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=qou+3DHiFyCOtLsGQReefr67dF1uugnjJ0cGHULWluA=; b=P7iVygYzngF2XkhMs/+LgV2fxxPKxCRTRVRi30vGiVJYOld87FHu+gE7s07dZTloZ9 zapMHp8w1t8nPkSbXLx6peKsFCxJWx5Jvp1kt9tqLLdJ5GDKJRjVvuPeAa0FOSJDoRYc 1/MyB0szHTOL1I4LIXA2OmsEAHUD+ImciTqypn1fpvNB+DqX9vsI8Ni5OpC1lQjtRmWu HcmO+622WOzGs+CeX/oT25Rrx5G8IErHDjDO0yrji3ZDIAQPCSdhkcj/dHNET1v4oAcV NnWk1F4G/M6Gj/8LdpStdft9CWwhvFxbcrd1tKtp4jfXBtOqgC+IRhj2VBw0SxPkNYMP YehA== X-Gm-Message-State: AGi0PuYrNGgBQVGPaqI+QKJAkgMOMi+zcAhlOdqkrmUVodQ0Ukh6at0B 4LLb8iUSUR0JhLP1nH6pLlSutDYw X-Google-Smtp-Source: APiQypJbtAPo9CTtu89LDakkWDTpSdCWzy+mxaFrJgxd2ZgwfWY8+YwpvcEqMFAUQXrj8uIZ2KTUVA== X-Received: by 2002:a62:ee10:: with SMTP id e16mr19444743pfi.247.1586810584668; Mon, 13 Apr 2020 13:43:04 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id o21sm4763340pjr.37.2020.04.13.13.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 13:43:04 -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: [PATCH v2 1/2] driver core: Revert default driver_deferred_probe_timeout value to 0 Date: Mon, 13 Apr 2020 20:42:52 +0000 Message-Id: <20200413204253.84991-2-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200413204253.84991-1-john.stultz@linaro.org> References: <20200413204253.84991-1-john.stultz@linaro.org> 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 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(-) -- 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 Mon Apr 13 20:42:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 185379 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp650578ilf; Mon, 13 Apr 2020 13:43:08 -0700 (PDT) X-Received: by 2002:a17:90b:1b01:: with SMTP id nu1mr23454818pjb.129.1586810588663; Mon, 13 Apr 2020 13:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586810588; cv=none; d=google.com; s=arc-20160816; b=LSZ9ryXWYCruqwvXQ5bELDwk+jDDNxKUs2ENUkarBc6IiPPgdYEG3lE/wEXg4b5GAM N8FHnAE5s7Aedy54J6H/D3x7UFsf7EAZzPKO5PjDDAhTFS9o8+wey1ISFNZGU/5ewrq4 rC5rCJbQ746WaELeVhEgnowIEi6ou91Q1/G4AtUuwwjUnxj0rflo0XDvJ+riueMYKIM+ Z2Q0IJlLUeJ/dd475WUwyGXkiChlEfOht6b30zdQgmKL8f2qyPHBcC5uUHUxv9d83Z7l 0GbNjzXicEUIlaDmmEo9ZFHV3o+D1KWZrLB/acco/wUtfl0M11NCdzSDL90MsfrB6/Pk A9DA== 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=11QzCAwCYyDGgMhxuZK0S/ZjR3ZzKMO2xp+a6ZMWbek=; b=k4TLaz9mtfNxk7ck+rU3teuQaxkQXH/t2svc2Aaiex4pSEL8EECGsHXIneimwFUeRt rlnyXJF6wduf5JKWSt6Ak66LgQQHdEDqc0Pn5rjiyaOakKwdqUugnk+ZhlpjTaecSmOd ePDuEbIseySfQEjCXD/fj1Bi5UOtNrfIDn1cmgnNaZRWH1JkYgCXClF74itN9zmTQQgp LdCMlJRsXEBbSfw3J+1fzIekgpPc5Jxv3xZ0K8OFrpvxI77oj6FC9Scw3EvHSbzK28j4 EDTq6WjdDZOUxoLXZZtKgnH7hPYEwhyq9oJArAVeN7e1X8YfVDSYGZeGwjffsRxJlTe6 AfYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PlBN1HcZ; 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 m7sor7886579pgv.10.2020.04.13.13.43.08 for (Google Transport Security); Mon, 13 Apr 2020 13:43:08 -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=PlBN1HcZ; 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=11QzCAwCYyDGgMhxuZK0S/ZjR3ZzKMO2xp+a6ZMWbek=; b=PlBN1HcZrUiEv7MWRLQtjV6nvtJtZOdDbhfub7UlnxOnaMN0qg60iCi0wF7DA/tVTC HtcC8HeQqDu689LReB17jS89TYZlg89r8+9f4T99uPoZzZXVz3B95nyDn/8k18B9ZTWt BYiXbuyDh4oqV0PFMCr7w5aDunf3vU1yks2OCQJ9Xaxrp4hcHvf59hmzxam45XHRG7IM jEQLZQqWhgY1X81S9f0V1Cv3ifXnpoo0go5Wyi1Z+4tzM7hoQaODI0B9S9YQGJJHZMGY OaB6WGIE9Kk630+Slp8+aLxH8as8f2GI3sAd/kmBbDxuxvzIiOdx4o7GkqafWbNmVShr uCdA== 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=11QzCAwCYyDGgMhxuZK0S/ZjR3ZzKMO2xp+a6ZMWbek=; b=CCpCz7QP7VZO+M96A9e6GZAvNTW2IMzyD5ZtIgLPVY26C/AvDJt61tDFr1GZoP2nzE S7SZx7vGZk+rmpweRwN8SGyBCX4pOFjcc3NDZpWAAMoF79GylfvqWBCUDFXfUOPSp6nA Bth1NCYC5jpmVlypwIEY1wSkC8fpqZ8T11M6b88ci9Ng841Qy88+w2oaDJ9vKBQEiZsR G8HwWKobsoQdmOvtjnc20revyCdxidsVLA7uPlTJ0kfhreEchgXFX6OboSRFeFWeklly J5oywA87etcelNzF5HRoqsdYpHFmAfMIQb9ZiHsFvHl6DDCIFV+UFc0Lx1yq0ggjtxX/ F2WQ== X-Gm-Message-State: AGi0PuaAu3oAOKv6XC+olAivD+eLzyr/AWAR52OQ28Fihnx8TiEI3uPE x5MaBpKHV/n0eWsWQPUKUaIYvSyK X-Google-Smtp-Source: APiQypK0S60cHhJRzSVlendhej5naoveWnkgtP8KxMUUzly5JLU1zVS4i/ahVEhoNTqEwJlJbWWulA== X-Received: by 2002:a63:545:: with SMTP id 66mr10926795pgf.66.1586810588308; Mon, 13 Apr 2020 13:43:08 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id o21sm4763340pjr.37.2020.04.13.13.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 13:43:07 -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: [PATCH v2 2/2] driver core: Ensure wait_for_device_probe() waits until the deferred_probe_timeout fires Date: Mon, 13 Apr 2020 20:42:53 +0000 Message-Id: <20200413204253.84991-3-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200413204253.84991-1-john.stultz@linaro.org> References: <20200413204253.84991-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 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(+) -- 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);