linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Alexander Graf <agraf@suse.de>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Kevin Hilman <khilman@kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Joerg Roedel <joro@8bytes.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Mark Brown <broonie@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	boot-architecture@lists.linaro.org,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/8] driver core: add a deferred probe timeout
Date: Thu, 24 May 2018 12:50:18 -0500	[thread overview]
Message-ID: <20180524175024.19874-3-robh@kernel.org> (raw)
In-Reply-To: <20180524175024.19874-1-robh@kernel.org>

Deferring probe can wait forever on dependencies that may never appear
for a variety of reasons. This can be difficult to debug especially if
the console has dependencies or userspace fails to boot to a shell. Add
a timeout to retry probing without possibly optional dependencies and to
dump out the deferred probe pending list after retrying.

This mechanism is intended for debug purposes. It won't work for the
console which needs to be enabled before userspace starts. However, if
the console's dependencies are resolved, then the kernel log will be
printed (as opposed to no output).

Signed-off-by: Rob Herring <robh@kernel.org>
---
 .../admin-guide/kernel-parameters.txt         |  7 +++++
 drivers/base/dd.c                             | 28 ++++++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 11fc28ecdb6d..dd3f40b34a24 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -809,6 +809,13 @@
 			Defaults to the default architecture's huge page size
 			if not specified.
 
+	deferred_probe_timeout=
+			[KNL] Set a timeout in seconds for deferred probe to
+			give up waiting on dependencies to probe. Only specific
+			dependencies (subsystems or drivers) that have opted in
+			will be ignored. This option also dumps out devices
+			still on the deferred probe list after retrying.
+
 	dhash_entries=	[KNL]
 			Set number of hash buckets for dentry cache.
 
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index d6034718da6f..4133b240c7e4 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -226,9 +226,17 @@ void device_unblock_probing(void)
 	driver_deferred_probe_trigger();
 }
 
+static int deferred_probe_timeout = -1;
+static int __init deferred_probe_timeout_setup(char *str)
+{
+	deferred_probe_timeout = simple_strtol(str, NULL, 0);
+	return 1;
+}
+__setup("deferred_probe_timeout=", deferred_probe_timeout_setup);
+
 int driver_deferred_probe_check_init_done(struct device *dev, bool optional)
 {
-	if (optional && initcalls_done) {
+	if ((optional || !deferred_probe_timeout) && initcalls_done) {
 		dev_WARN(dev, "ignoring dependency for device, assuming no driver");
 		return -ENODEV;
 	}
@@ -236,6 +244,19 @@ int driver_deferred_probe_check_init_done(struct device *dev, bool optional)
 	return -EPROBE_DEFER;
 }
 
+static void deferred_probe_timeout_work_func(struct work_struct *work)
+{
+	struct device_private *private, *p;
+
+	deferred_probe_timeout = 0;
+	driver_deferred_probe_trigger();
+	flush_work(&deferred_probe_work);
+
+	list_for_each_entry_safe(private, p, &deferred_probe_pending_list, deferred_probe)
+		dev_info(private->device, "deferred probe pending");
+}
+static DECLARE_DELAYED_WORK(deferred_probe_timeout_work, deferred_probe_timeout_work_func);
+
 /**
  * deferred_probe_initcall() - Enable probing of deferred devices
  *
@@ -257,6 +278,11 @@ static int deferred_probe_initcall(void)
 	 */
 	driver_deferred_probe_trigger();
 	flush_work(&deferred_probe_work);
+
+	if (deferred_probe_timeout > 0) {
+		schedule_delayed_work(&deferred_probe_timeout_work,
+			deferred_probe_timeout * HZ);
+	}
 	return 0;
 }
 late_initcall(deferred_probe_initcall);
-- 
2.17.0

  parent reply	other threads:[~2018-05-24 17:50 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-24 17:50 [PATCH v2 0/8] Make deferring probe forever optional Rob Herring
2018-05-24 17:50 ` [PATCH v2 1/8] driver core: make deferring probe after init optional Rob Herring
2018-05-24 18:18   ` Mark Brown
2018-05-24 20:25     ` Rob Herring
2018-05-25 11:47     ` Robin Murphy
2018-05-29  5:12     ` Frank Rowand
2018-05-29 14:46       ` Rob Herring
2018-05-24 18:56   ` Greg Kroah-Hartman
2018-05-24 19:42     ` Rob Herring
2018-05-24 19:00   ` Greg Kroah-Hartman
2018-05-24 20:57     ` Rob Herring
2018-05-25 12:20       ` Robin Murphy
2018-05-25 17:35         ` Rob Herring
2018-05-24 22:28   ` Bjorn Andersson
2018-05-24 23:47     ` Rob Herring
2018-05-24 17:50 ` Rob Herring [this message]
2018-05-24 19:01   ` [PATCH v2 2/8] driver core: add a deferred probe timeout Greg Kroah-Hartman
2018-05-24 19:45     ` Rob Herring
2018-05-24 19:51       ` Greg Kroah-Hartman
2018-05-24 17:50 ` [PATCH v2 3/8] dt-bindings: pinctrl: add a 'pinctrl-use-default' property Rob Herring
2018-05-24 17:50 ` [PATCH v2 4/8] arm: dts: bcm283x: mark the UART pin muxing nodes with pinctrl-use-default Rob Herring
2018-05-24 17:50 ` [PATCH v2 5/8] pinctrl: optionally stop deferring probe at end of initcalls Rob Herring
2018-05-30  7:00   ` Linus Walleij
2018-05-24 17:50 ` [PATCH v2 6/8] iommu: Stop " Rob Herring
2018-05-24 17:50 ` [PATCH v2 7/8] iommu: Remove IOMMU_OF_DECLARE Rob Herring
2018-05-25 11:31   ` Will Deacon
2018-05-28  6:53   ` Marek Szyprowski
2018-05-24 17:50 ` [PATCH v2 8/8] PM / Domains: Stop deferring probe at the end of initcall Rob Herring
2018-05-29 11:48 ` [PATCH v2 0/8] Make deferring probe forever optional Joerg Roedel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180524175024.19874-3-robh@kernel.org \
    --to=robh@kernel.org \
    --cc=agraf@suse.de \
    --cc=bjorn.andersson@linaro.org \
    --cc=boot-architecture@lists.linaro.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=joro@8bytes.org \
    --cc=khilman@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=robin.murphy@arm.com \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).