linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state()
@ 2020-02-25  5:08 John Stultz
  2020-02-25  5:08 ` [PATCH v5 1/6] driver core: Fix driver_deferred_probe_check_state() logic John Stultz
                   ` (7 more replies)
  0 siblings, 8 replies; 19+ messages in thread
From: John Stultz @ 2020-02-25  5:08 UTC (permalink / raw)
  To: lkml
  Cc: John Stultz, Rob Herring, Rafael J. Wysocki, Kevin Hilman,
	Ulf Hansson, Pavel Machek, Len Brown, Todd Kjos, Saravana Kannan,
	Bjorn Andersson, Liam Girdwood, Mark Brown, Thierry Reding,
	Linus Walleij, Greg Kroah-Hartman, linux-pm

This series goal is to improve and cleanup the
driver_deferred_probe_check_state() code in the driver core.

This series is useful for being able to support modules
dependencies which may be loaded by userland, far after
late_initcall is done. For instance, this series allows us to
successfully use various clk drivers as modules on the db845c
board. And without it, those drivers have to be statically built
in to work.

Since I first sent out this patch, Saravana suggested an
alternative approach which also works for our needs, and is a
bit simpler:
 https://lore.kernel.org/lkml/20200220055250.196456-1-saravanak@google.com/T/#u

However, while that patch provides the functionality we need,
I still suspect the driver_deferred_probe_check_state() code
could benefit from the cleanup in this patch, as the existing
logic is somewhat muddy.

New in v5:
* Reworked the driver_deferred_probe_check_state() logic as
  suggested by Saravana to tie the initcall_done checking with
  modules being enabled.
* Cleanup some comment wording as suggested by Rafael
* Try to slightly simplify the regulator logic as suggested by
  Bjorn

Thanks so much to Bjorn, Saravana and Rafael for their reviews
and suggestions! Additional review and feedback is always greatly
appreciated!

thanks
-john

Cc: Rob Herring <robh@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Kevin Hilman <khilman@kernel.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Len Brown <len.brown@intel.com>
Cc: Todd Kjos <tkjos@google.com>
Cc: Saravana Kannan <saravanak@google.com>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Thierry Reding <treding@nvidia.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-pm@vger.kernel.org

John Stultz (6):
  driver core: Fix driver_deferred_probe_check_state() logic
  driver core: Set deferred_probe_timeout to a longer default if
    CONFIG_MODULES is set
  pinctrl: Remove use of driver_deferred_probe_check_state_continue()
  driver core: Remove driver_deferred_probe_check_state_continue()
  driver core: Rename deferred_probe_timeout and make it global
  regulator: Use driver_deferred_probe_timeout for
    regulator_init_complete_work

 drivers/base/dd.c             | 82 +++++++++++++----------------------
 drivers/pinctrl/devicetree.c  |  9 ++--
 drivers/regulator/core.c      | 25 ++++++-----
 include/linux/device/driver.h |  2 +-
 4 files changed, 49 insertions(+), 69 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v5 1/6] driver core: Fix driver_deferred_probe_check_state() logic
  2020-02-25  5:08 [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state() John Stultz
@ 2020-02-25  5:08 ` John Stultz
  2020-02-25 16:24   ` Rafael J. Wysocki
  2020-02-25  5:08 ` [PATCH v5 2/6] driver core: Set deferred_probe_timeout to a longer default if CONFIG_MODULES is set John Stultz
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: John Stultz @ 2020-02-25  5:08 UTC (permalink / raw)
  To: lkml
  Cc: John Stultz, Rob Herring, Rafael J. Wysocki, Kevin Hilman,
	Ulf Hansson, Pavel Machek, Len Brown, Todd Kjos, Saravana Kannan,
	Bjorn Andersson, Liam Girdwood, Mark Brown, Thierry Reding,
	Linus Walleij, Greg Kroah-Hartman, linux-pm

driver_deferred_probe_check_state() has some uninituitive behavior.

* From boot to late_initcall, it returns -EPROBE_DEFER

* From late_initcall to the deferred_probe_timeout (if set)
  it returns -ENODEV

* If the deferred_probe_timeout it set, after it fires, it
  returns -ETIMEDOUT

This is a bit confusing, as its useful to have the function
return -EPROBE_DEFER while the timeout is still running. This
behavior has resulted in the somwhat duplicative
driver_deferred_probe_check_state_continue() function being
added.

Thus this patch tries to improve the logic, so that it behaves
as such:

* If late_initcall has passed, and modules are not enabled
  it returns -ENODEV

* If modules are enabled and deferred_probe_timeout is set,
  it returns -EPROBE_DEFER until the timeout, afterwhich it
  returns -ETIMEDOUT.

* In all other cases, it returns -EPROBE_DEFER

This will make the deferred_probe_timeout value much more
functional, and will allow us to consolidate the
driver_deferred_probe_check_state() and
driver_deferred_probe_check_state_continue() logic in a later
patch.

Cc: Rob Herring <robh@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Kevin Hilman <khilman@kernel.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Len Brown <len.brown@intel.com>
Cc: Todd Kjos <tkjos@google.com>
Cc: Saravana Kannan <saravanak@google.com>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Thierry Reding <treding@nvidia.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
v4:
* Simplified logic suggested by Andy Shevchenko
* Clarified commit message to focus on logic change
v5:
* Cleanup comment wording as suggested by Rafael
* Tweaked the logic to use Saravana's suggested conditionals
---
 drivers/base/dd.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index b25bcab2a26b..d75b34de6964 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -237,24 +237,26 @@ __setup("deferred_probe_timeout=", deferred_probe_timeout_setup);
 
 static int __driver_deferred_probe_check_state(struct device *dev)
 {
-	if (!initcalls_done)
-		return -EPROBE_DEFER;
+	if (!IS_ENABLED(CONFIG_MODULES) && initcalls_done)
+		return -ENODEV;
 
 	if (!deferred_probe_timeout) {
 		dev_WARN(dev, "deferred probe timeout, ignoring dependency");
 		return -ETIMEDOUT;
 	}
 
-	return 0;
+	return -EPROBE_DEFER;
 }
 
 /**
  * driver_deferred_probe_check_state() - Check deferred probe state
  * @dev: device to check
  *
- * Returns -ENODEV if init is done and all built-in drivers have had a chance
- * to probe (i.e. initcalls are done), -ETIMEDOUT if deferred probe debug
- * timeout has expired, or -EPROBE_DEFER if none of those conditions are met.
+ * Return:
+ * -ENODEV if initcalls have completed and modules are disabled.
+ * -ETIMEDOUT if the deferred probe timeout was set and has expired
+ *  and modules are enabled.
+ * -EPROBE_DEFER in other cases.
  *
  * Drivers or subsystems can opt-in to calling this function instead of directly
  * returning -EPROBE_DEFER.
@@ -264,7 +266,7 @@ int driver_deferred_probe_check_state(struct device *dev)
 	int ret;
 
 	ret = __driver_deferred_probe_check_state(dev);
-	if (ret < 0)
+	if (ret != -ENODEV)
 		return ret;
 
 	dev_warn(dev, "ignoring dependency for device, assuming no driver");
@@ -292,7 +294,7 @@ int driver_deferred_probe_check_state_continue(struct device *dev)
 	int ret;
 
 	ret = __driver_deferred_probe_check_state(dev);
-	if (ret < 0)
+	if (ret != -ENODEV)
 		return ret;
 
 	return -EPROBE_DEFER;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v5 2/6] driver core: Set deferred_probe_timeout to a longer default if CONFIG_MODULES is set
  2020-02-25  5:08 [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state() John Stultz
  2020-02-25  5:08 ` [PATCH v5 1/6] driver core: Fix driver_deferred_probe_check_state() logic John Stultz
@ 2020-02-25  5:08 ` John Stultz
  2020-02-25  5:08 ` [PATCH v5 3/6] pinctrl: Remove use of driver_deferred_probe_check_state_continue() John Stultz
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: John Stultz @ 2020-02-25  5:08 UTC (permalink / raw)
  To: lkml
  Cc: John Stultz, Rob Herring, Rafael J. Wysocki, Kevin Hilman,
	Ulf Hansson, Pavel Machek, Len Brown, Todd Kjos, Saravana Kannan,
	Bjorn Andersson, Liam Girdwood, Mark Brown, Thierry Reding,
	Linus Walleij, Greg Kroah-Hartman, linux-pm

When using modules, its common for the modules not to be loaded
until quite late by userland. With the current code,
driver_deferred_probe_check_state() will stop returning
EPROBE_DEFER after late_initcall, which can cause module
dependency resolution to fail after that.

So allow a longer window of 30 seconds (picked somewhat
arbitrarily, but influenced by the similar regulator core
timeout value) in the case where modules are enabled.

Cc: Rob Herring <robh@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Kevin Hilman <khilman@kernel.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Len Brown <len.brown@intel.com>
Cc: Todd Kjos <tkjos@google.com>
Cc: Saravana Kannan <saravanak@google.com>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Thierry Reding <treding@nvidia.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-pm@vger.kernel.org
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
v4:
* Split out into its own patch as suggested by Mark
* Made change conditional on CONFIG_MODULES
---
 drivers/base/dd.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index d75b34de6964..fe26f2574a6d 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -224,7 +224,16 @@ 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
+ */
+static int deferred_probe_timeout = 30;
+#else
+/* In the case of !modules, no probe timeout needed */
 static int deferred_probe_timeout = -1;
+#endif
 static int __init deferred_probe_timeout_setup(char *str)
 {
 	int timeout;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v5 3/6] pinctrl: Remove use of driver_deferred_probe_check_state_continue()
  2020-02-25  5:08 [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state() John Stultz
  2020-02-25  5:08 ` [PATCH v5 1/6] driver core: Fix driver_deferred_probe_check_state() logic John Stultz
  2020-02-25  5:08 ` [PATCH v5 2/6] driver core: Set deferred_probe_timeout to a longer default if CONFIG_MODULES is set John Stultz
@ 2020-02-25  5:08 ` John Stultz
  2020-02-26  2:11   ` Saravana Kannan
  2020-02-25  5:08 ` [PATCH v5 4/6] driver core: Remove driver_deferred_probe_check_state_continue() John Stultz
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 19+ messages in thread
From: John Stultz @ 2020-02-25  5:08 UTC (permalink / raw)
  To: lkml
  Cc: John Stultz, Rob Herring, Rafael J. Wysocki, Kevin Hilman,
	Ulf Hansson, Pavel Machek, Len Brown, Todd Kjos, Saravana Kannan,
	Bjorn Andersson, Liam Girdwood, Mark Brown, Thierry Reding,
	Linus Walleij, Greg Kroah-Hartman, linux-pm

With the earlier sanity fixes to
driver_deferred_probe_check_state() it should be usable for the
pinctrl logic here.

So tweak the logic to use driver_deferred_probe_check_state()
instead of driver_deferred_probe_check_state_continue()

Cc: Rob Herring <robh@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Kevin Hilman <khilman@kernel.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Len Brown <len.brown@intel.com>
Cc: Todd Kjos <tkjos@google.com>
Cc: Saravana Kannan <saravanak@google.com>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Thierry Reding <treding@nvidia.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-pm@vger.kernel.org
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 drivers/pinctrl/devicetree.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
index 9357f7c46cf3..1ed20ac2243f 100644
--- a/drivers/pinctrl/devicetree.c
+++ b/drivers/pinctrl/devicetree.c
@@ -127,11 +127,12 @@ static int dt_to_map_one_config(struct pinctrl *p,
 		np_pctldev = of_get_next_parent(np_pctldev);
 		if (!np_pctldev || of_node_is_root(np_pctldev)) {
 			of_node_put(np_pctldev);
+			ret = driver_deferred_probe_check_state(p->dev);
 			/* keep deferring if modules are enabled unless we've timed out */
-			if (IS_ENABLED(CONFIG_MODULES) && !allow_default)
-				return driver_deferred_probe_check_state_continue(p->dev);
-
-			return driver_deferred_probe_check_state(p->dev);
+			if (IS_ENABLED(CONFIG_MODULES) && !allow_default &&
+			    (ret == -ENODEV))
+				ret = -EPROBE_DEFER;
+			return ret;
 		}
 		/* If we're creating a hog we can use the passed pctldev */
 		if (hog_pctldev && (np_pctldev == p->dev->of_node)) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v5 4/6] driver core: Remove driver_deferred_probe_check_state_continue()
  2020-02-25  5:08 [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state() John Stultz
                   ` (2 preceding siblings ...)
  2020-02-25  5:08 ` [PATCH v5 3/6] pinctrl: Remove use of driver_deferred_probe_check_state_continue() John Stultz
@ 2020-02-25  5:08 ` John Stultz
  2020-02-25  5:08 ` [PATCH v5 5/6] driver core: Rename deferred_probe_timeout and make it global John Stultz
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: John Stultz @ 2020-02-25  5:08 UTC (permalink / raw)
  To: lkml
  Cc: John Stultz, Rob Herring, Rafael J. Wysocki, Kevin Hilman,
	Ulf Hansson, Pavel Machek, Len Brown, Todd Kjos, Saravana Kannan,
	Bjorn Andersson, Liam Girdwood, Mark Brown, Thierry Reding,
	Linus Walleij, Greg Kroah-Hartman, linux-pm

Now that driver_deferred_probe_check_state() works better, and
we've converted the only user of
driver_deferred_probe_check_state_continue() we can simply
remove it and simplify some of the logic.

Cc: Rob Herring <robh@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Kevin Hilman <khilman@kernel.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Len Brown <len.brown@intel.com>
Cc: Todd Kjos <tkjos@google.com>
Cc: Saravana Kannan <saravanak@google.com>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Thierry Reding <treding@nvidia.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-pm@vger.kernel.org
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
 drivers/base/dd.c             | 53 ++++++-----------------------------
 include/linux/device/driver.h |  1 -
 2 files changed, 8 insertions(+), 46 deletions(-)

diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index fe26f2574a6d..c09e4e7277d4 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -244,19 +244,6 @@ static int __init deferred_probe_timeout_setup(char *str)
 }
 __setup("deferred_probe_timeout=", deferred_probe_timeout_setup);
 
-static int __driver_deferred_probe_check_state(struct device *dev)
-{
-	if (!IS_ENABLED(CONFIG_MODULES) && initcalls_done)
-		return -ENODEV;
-
-	if (!deferred_probe_timeout) {
-		dev_WARN(dev, "deferred probe timeout, ignoring dependency");
-		return -ETIMEDOUT;
-	}
-
-	return -EPROBE_DEFER;
-}
-
 /**
  * driver_deferred_probe_check_state() - Check deferred probe state
  * @dev: device to check
@@ -272,39 +259,15 @@ static int __driver_deferred_probe_check_state(struct device *dev)
  */
 int driver_deferred_probe_check_state(struct device *dev)
 {
-	int ret;
-
-	ret = __driver_deferred_probe_check_state(dev);
-	if (ret != -ENODEV)
-		return ret;
-
-	dev_warn(dev, "ignoring dependency for device, assuming no driver");
-
-	return -ENODEV;
-}
-
-/**
- * driver_deferred_probe_check_state_continue() - check deferred probe state
- * @dev: device to check
- *
- * Returns -ETIMEDOUT if deferred probe debug timeout has expired, or
- * -EPROBE_DEFER otherwise.
- *
- * Drivers or subsystems can opt-in to calling this function instead of
- * directly returning -EPROBE_DEFER.
- *
- * This is similar to driver_deferred_probe_check_state(), but it allows the
- * subsystem to keep deferring probe after built-in drivers have had a chance
- * to probe. One scenario where that is useful is if built-in drivers rely on
- * resources that are provided by modular drivers.
- */
-int driver_deferred_probe_check_state_continue(struct device *dev)
-{
-	int ret;
+	if (!IS_ENABLED(CONFIG_MODULES) && initcalls_done) {
+		dev_warn(dev, "ignoring dependency for device, assuming no driver");
+		return -ENODEV;
+	}
 
-	ret = __driver_deferred_probe_check_state(dev);
-	if (ret != -ENODEV)
-		return ret;
+	if (!deferred_probe_timeout) {
+		dev_WARN(dev, "deferred probe timeout, ignoring dependency");
+		return -ETIMEDOUT;
+	}
 
 	return -EPROBE_DEFER;
 }
diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h
index 1188260f9a02..5242afabfaba 100644
--- a/include/linux/device/driver.h
+++ b/include/linux/device/driver.h
@@ -238,7 +238,6 @@ driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev)
 
 void driver_deferred_probe_add(struct device *dev);
 int driver_deferred_probe_check_state(struct device *dev);
-int driver_deferred_probe_check_state_continue(struct device *dev);
 void driver_init(void);
 
 /**
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v5 5/6] driver core: Rename deferred_probe_timeout and make it global
  2020-02-25  5:08 [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state() John Stultz
                   ` (3 preceding siblings ...)
  2020-02-25  5:08 ` [PATCH v5 4/6] driver core: Remove driver_deferred_probe_check_state_continue() John Stultz
@ 2020-02-25  5:08 ` John Stultz
  2020-02-25  5:08 ` [PATCH v5 6/6] regulator: Use driver_deferred_probe_timeout for regulator_init_complete_work John Stultz
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 19+ messages in thread
From: John Stultz @ 2020-02-25  5:08 UTC (permalink / raw)
  To: lkml
  Cc: John Stultz, Rob Herring, Rafael J. Wysocki, Kevin Hilman,
	Ulf Hansson, Pavel Machek, Len Brown, Todd Kjos, Saravana Kannan,
	Bjorn Andersson, Liam Girdwood, Mark Brown, Thierry Reding,
	Linus Walleij, Greg Kroah-Hartman, linux-pm

Since other subsystems (like regulator) have similar arbitrary
timeouts for how long they try to resolve driver dependencies,
rename deferred_probe_timeout to driver_deferred_probe_timeout
and set it as global, so it can be shared.

Cc: Rob Herring <robh@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Kevin Hilman <khilman@kernel.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Len Brown <len.brown@intel.com>
Cc: Todd Kjos <tkjos@google.com>
Cc: Saravana Kannan <saravanak@google.com>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Thierry Reding <treding@nvidia.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-pm@vger.kernel.org
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
v4:
* Split out into its own patch as suggested by Mark
* Renamed deferred_probe_timeout as suggested by Greg
---
 drivers/base/dd.c             | 16 +++++++++-------
 include/linux/device/driver.h |  1 +
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index c09e4e7277d4..76888a7459d8 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -229,17 +229,19 @@ DEFINE_SHOW_ATTRIBUTE(deferred_devs);
  * In the case of modules, set the default probe timeout to
  * 30 seconds to give userland some time to load needed modules
  */
-static int deferred_probe_timeout = 30;
+int driver_deferred_probe_timeout = 30;
 #else
 /* In the case of !modules, no probe timeout needed */
-static int deferred_probe_timeout = -1;
+int driver_deferred_probe_timeout = -1;
 #endif
+EXPORT_SYMBOL_GPL(driver_deferred_probe_timeout);
+
 static int __init deferred_probe_timeout_setup(char *str)
 {
 	int timeout;
 
 	if (!kstrtoint(str, 10, &timeout))
-		deferred_probe_timeout = timeout;
+		driver_deferred_probe_timeout = timeout;
 	return 1;
 }
 __setup("deferred_probe_timeout=", deferred_probe_timeout_setup);
@@ -264,7 +266,7 @@ int driver_deferred_probe_check_state(struct device *dev)
 		return -ENODEV;
 	}
 
-	if (!deferred_probe_timeout) {
+	if (!driver_deferred_probe_timeout) {
 		dev_WARN(dev, "deferred probe timeout, ignoring dependency");
 		return -ETIMEDOUT;
 	}
@@ -276,7 +278,7 @@ static void deferred_probe_timeout_work_func(struct work_struct *work)
 {
 	struct device_private *private, *p;
 
-	deferred_probe_timeout = 0;
+	driver_deferred_probe_timeout = 0;
 	driver_deferred_probe_trigger();
 	flush_work(&deferred_probe_work);
 
@@ -310,9 +312,9 @@ static int deferred_probe_initcall(void)
 	driver_deferred_probe_trigger();
 	flush_work(&deferred_probe_work);
 
-	if (deferred_probe_timeout > 0) {
+	if (driver_deferred_probe_timeout > 0) {
 		schedule_delayed_work(&deferred_probe_timeout_work,
-			deferred_probe_timeout * HZ);
+			driver_deferred_probe_timeout * HZ);
 	}
 	return 0;
 }
diff --git a/include/linux/device/driver.h b/include/linux/device/driver.h
index 5242afabfaba..ee7ba5b5417e 100644
--- a/include/linux/device/driver.h
+++ b/include/linux/device/driver.h
@@ -236,6 +236,7 @@ driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev)
 }
 #endif
 
+extern int driver_deferred_probe_timeout;
 void driver_deferred_probe_add(struct device *dev);
 int driver_deferred_probe_check_state(struct device *dev);
 void driver_init(void);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v5 6/6] regulator: Use driver_deferred_probe_timeout for regulator_init_complete_work
  2020-02-25  5:08 [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state() John Stultz
                   ` (4 preceding siblings ...)
  2020-02-25  5:08 ` [PATCH v5 5/6] driver core: Rename deferred_probe_timeout and make it global John Stultz
@ 2020-02-25  5:08 ` John Stultz
  2020-02-25 12:43   ` Mark Brown
  2020-03-04 17:12 ` [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state() Greg Kroah-Hartman
  2020-04-21 23:59 ` Eugeniu Rosca
  7 siblings, 1 reply; 19+ messages in thread
From: John Stultz @ 2020-02-25  5:08 UTC (permalink / raw)
  To: lkml
  Cc: John Stultz, Rob Herring, Rafael J. Wysocki, Kevin Hilman,
	Ulf Hansson, Pavel Machek, Len Brown, Todd Kjos, Saravana Kannan,
	Bjorn Andersson, Liam Girdwood, Mark Brown, Thierry Reding,
	Linus Walleij, Greg Kroah-Hartman, linux-pm

The regulator_init_complete_work logic defers the cleanup for an
arbitrary 30 seconds of time to allow modules loaded by userland
to start.

This arbitrary timeout is similar to the
driver_deferred_probe_timeout value, and its been suggested we
align these so users have a method to extend the timeouts as
needed.

So this patch changes the logic to use the
driver_deferred_probe_timeout value for the delay value if it
is set (using a delay of 0 if it is not).

Cc: Rob Herring <robh@kernel.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Kevin Hilman <khilman@kernel.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Len Brown <len.brown@intel.com>
Cc: Todd Kjos <tkjos@google.com>
Cc: Saravana Kannan <saravanak@google.com>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Thierry Reding <treding@nvidia.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-pm@vger.kernel.org
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
v4:
* Split out into its own patch, as suggested by Mark
v5:
* Try to simplify the logic a touch as suggested by Bjorn
---
 drivers/regulator/core.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index d015d99cb59d..51b6a2dea717 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -5757,6 +5757,10 @@ static DECLARE_DELAYED_WORK(regulator_init_complete_work,
 
 static int __init regulator_init_complete(void)
 {
+	int delay = driver_deferred_probe_timeout;
+
+	if (delay < 0)
+		delay = 0;
 	/*
 	 * Since DT doesn't provide an idiomatic mechanism for
 	 * enabling full constraints and since it's much more natural
@@ -5767,18 +5771,17 @@ static int __init regulator_init_complete(void)
 		has_full_constraints = true;
 
 	/*
-	 * We punt completion for an arbitrary amount of time since
-	 * systems like distros will load many drivers from userspace
-	 * so consumers might not always be ready yet, this is
-	 * particularly an issue with laptops where this might bounce
-	 * the display off then on.  Ideally we'd get a notification
-	 * from userspace when this happens but we don't so just wait
-	 * a bit and hope we waited long enough.  It'd be better if
-	 * we'd only do this on systems that need it, and a kernel
-	 * command line option might be useful.
+	 * If driver_deferred_probe_timeout is set, we punt
+	 * completion for that many seconds since systems like
+	 * distros will load many drivers from userspace so consumers
+	 * might not always be ready yet, this is particularly an
+	 * issue with laptops where this might bounce the display off
+	 * then on.  Ideally we'd get a notification from userspace
+	 * when this happens but we don't so just wait a bit and hope
+	 * we waited long enough.  It'd be better if we'd only do
+	 * this on systems that need it.
 	 */
-	schedule_delayed_work(&regulator_init_complete_work,
-			      msecs_to_jiffies(30000));
+	schedule_delayed_work(&regulator_init_complete_work, delay * HZ);
 
 	return 0;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH v5 6/6] regulator: Use driver_deferred_probe_timeout for regulator_init_complete_work
  2020-02-25  5:08 ` [PATCH v5 6/6] regulator: Use driver_deferred_probe_timeout for regulator_init_complete_work John Stultz
@ 2020-02-25 12:43   ` Mark Brown
  0 siblings, 0 replies; 19+ messages in thread
From: Mark Brown @ 2020-02-25 12:43 UTC (permalink / raw)
  To: John Stultz
  Cc: lkml, Rob Herring, Rafael J. Wysocki, Kevin Hilman, Ulf Hansson,
	Pavel Machek, Len Brown, Todd Kjos, Saravana Kannan,
	Bjorn Andersson, Liam Girdwood, Thierry Reding, Linus Walleij,
	Greg Kroah-Hartman, linux-pm

[-- Attachment #1: Type: text/plain, Size: 250 bytes --]

On Tue, Feb 25, 2020 at 05:08:28AM +0000, John Stultz wrote:
> The regulator_init_complete_work logic defers the cleanup for an
> arbitrary 30 seconds of time to allow modules loaded by userland
> to start.

Acked-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v5 1/6] driver core: Fix driver_deferred_probe_check_state() logic
  2020-02-25  5:08 ` [PATCH v5 1/6] driver core: Fix driver_deferred_probe_check_state() logic John Stultz
@ 2020-02-25 16:24   ` Rafael J. Wysocki
  0 siblings, 0 replies; 19+ messages in thread
From: Rafael J. Wysocki @ 2020-02-25 16:24 UTC (permalink / raw)
  To: John Stultz
  Cc: lkml, Rob Herring, Rafael J. Wysocki, Kevin Hilman, Ulf Hansson,
	Pavel Machek, Len Brown, Todd Kjos, Saravana Kannan,
	Bjorn Andersson, Liam Girdwood, Mark Brown, Thierry Reding,
	Linus Walleij, Greg Kroah-Hartman, Linux PM

On Tue, Feb 25, 2020 at 6:08 AM John Stultz <john.stultz@linaro.org> wrote:
>
> driver_deferred_probe_check_state() has some uninituitive behavior.
>
> * From boot to late_initcall, it returns -EPROBE_DEFER
>
> * From late_initcall to the deferred_probe_timeout (if set)
>   it returns -ENODEV
>
> * If the deferred_probe_timeout it set, after it fires, it
>   returns -ETIMEDOUT
>
> This is a bit confusing, as its useful to have the function
> return -EPROBE_DEFER while the timeout is still running. This
> behavior has resulted in the somwhat duplicative
> driver_deferred_probe_check_state_continue() function being
> added.
>
> Thus this patch tries to improve the logic, so that it behaves
> as such:
>
> * If late_initcall has passed, and modules are not enabled
>   it returns -ENODEV
>
> * If modules are enabled and deferred_probe_timeout is set,
>   it returns -EPROBE_DEFER until the timeout, afterwhich it
>   returns -ETIMEDOUT.
>
> * In all other cases, it returns -EPROBE_DEFER
>
> This will make the deferred_probe_timeout value much more
> functional, and will allow us to consolidate the
> driver_deferred_probe_check_state() and
> driver_deferred_probe_check_state_continue() logic in a later
> patch.
>
> Cc: Rob Herring <robh@kernel.org>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Kevin Hilman <khilman@kernel.org>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Len Brown <len.brown@intel.com>
> Cc: Todd Kjos <tkjos@google.com>
> Cc: Saravana Kannan <saravanak@google.com>
> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Thierry Reding <treding@nvidia.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-pm@vger.kernel.org
> Signed-off-by: John Stultz <john.stultz@linaro.org>

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
> v4:
> * Simplified logic suggested by Andy Shevchenko
> * Clarified commit message to focus on logic change
> v5:
> * Cleanup comment wording as suggested by Rafael
> * Tweaked the logic to use Saravana's suggested conditionals
> ---
>  drivers/base/dd.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index b25bcab2a26b..d75b34de6964 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -237,24 +237,26 @@ __setup("deferred_probe_timeout=", deferred_probe_timeout_setup);
>
>  static int __driver_deferred_probe_check_state(struct device *dev)
>  {
> -       if (!initcalls_done)
> -               return -EPROBE_DEFER;
> +       if (!IS_ENABLED(CONFIG_MODULES) && initcalls_done)
> +               return -ENODEV;
>
>         if (!deferred_probe_timeout) {
>                 dev_WARN(dev, "deferred probe timeout, ignoring dependency");
>                 return -ETIMEDOUT;
>         }
>
> -       return 0;
> +       return -EPROBE_DEFER;
>  }
>
>  /**
>   * driver_deferred_probe_check_state() - Check deferred probe state
>   * @dev: device to check
>   *
> - * Returns -ENODEV if init is done and all built-in drivers have had a chance
> - * to probe (i.e. initcalls are done), -ETIMEDOUT if deferred probe debug
> - * timeout has expired, or -EPROBE_DEFER if none of those conditions are met.
> + * Return:
> + * -ENODEV if initcalls have completed and modules are disabled.
> + * -ETIMEDOUT if the deferred probe timeout was set and has expired
> + *  and modules are enabled.
> + * -EPROBE_DEFER in other cases.
>   *
>   * Drivers or subsystems can opt-in to calling this function instead of directly
>   * returning -EPROBE_DEFER.
> @@ -264,7 +266,7 @@ int driver_deferred_probe_check_state(struct device *dev)
>         int ret;
>
>         ret = __driver_deferred_probe_check_state(dev);
> -       if (ret < 0)
> +       if (ret != -ENODEV)
>                 return ret;
>
>         dev_warn(dev, "ignoring dependency for device, assuming no driver");
> @@ -292,7 +294,7 @@ int driver_deferred_probe_check_state_continue(struct device *dev)
>         int ret;
>
>         ret = __driver_deferred_probe_check_state(dev);
> -       if (ret < 0)
> +       if (ret != -ENODEV)
>                 return ret;
>
>         return -EPROBE_DEFER;
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v5 3/6] pinctrl: Remove use of driver_deferred_probe_check_state_continue()
  2020-02-25  5:08 ` [PATCH v5 3/6] pinctrl: Remove use of driver_deferred_probe_check_state_continue() John Stultz
@ 2020-02-26  2:11   ` Saravana Kannan
  2020-02-26  2:13     ` John Stultz
  0 siblings, 1 reply; 19+ messages in thread
From: Saravana Kannan @ 2020-02-26  2:11 UTC (permalink / raw)
  To: John Stultz
  Cc: lkml, Rob Herring, Rafael J. Wysocki, Kevin Hilman, Ulf Hansson,
	Pavel Machek, Len Brown, Todd Kjos, Bjorn Andersson,
	Liam Girdwood, Mark Brown, Thierry Reding, Linus Walleij,
	Greg Kroah-Hartman, Linux PM

Sending again because of accidental HTML email.

On Mon, Feb 24, 2020 at 9:08 PM John Stultz <john.stultz@linaro.org> wrote:
>
> With the earlier sanity fixes to
> driver_deferred_probe_check_state() it should be usable for the
> pinctrl logic here.
>
> So tweak the logic to use driver_deferred_probe_check_state()
> instead of driver_deferred_probe_check_state_continue()
>
> Cc: Rob Herring <robh@kernel.org>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Kevin Hilman <khilman@kernel.org>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Len Brown <len.brown@intel.com>
> Cc: Todd Kjos <tkjos@google.com>
> Cc: Saravana Kannan <saravanak@google.com>
> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
> Cc: Liam Girdwood <lgirdwood@gmail.com>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Thierry Reding <treding@nvidia.com>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-pm@vger.kernel.org
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> ---
>  drivers/pinctrl/devicetree.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
> index 9357f7c46cf3..1ed20ac2243f 100644
> --- a/drivers/pinctrl/devicetree.c
> +++ b/drivers/pinctrl/devicetree.c
> @@ -127,11 +127,12 @@ static int dt_to_map_one_config(struct pinctrl *p,
>                 np_pctldev = of_get_next_parent(np_pctldev);
>                 if (!np_pctldev || of_node_is_root(np_pctldev)) {
>                         of_node_put(np_pctldev);
> +                       ret = driver_deferred_probe_check_state(p->dev);
>                         /* keep deferring if modules are enabled unless we've timed out */
> -                       if (IS_ENABLED(CONFIG_MODULES) && !allow_default)
> -                               return driver_deferred_probe_check_state_continue(p->dev);
> -
> -                       return driver_deferred_probe_check_state(p->dev);
> +                       if (IS_ENABLED(CONFIG_MODULES) && !allow_default &&

Is this IS_ENABLED(CONFIG_MODULES) still necessary? At the end of this
series, doesn't driver_deferred_probe_check_state() already return
-EPROBE_DEFER if modules are enabled and timeout hasn't happened?

-Saravana

> +                           (ret == -ENODEV))
> +                               ret = -EPROBE_DEFER;
> +                       return ret;
>                 }
>                 /* If we're creating a hog we can use the passed pctldev */
>                 if (hog_pctldev && (np_pctldev == p->dev->of_node)) {
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v5 3/6] pinctrl: Remove use of driver_deferred_probe_check_state_continue()
  2020-02-26  2:11   ` Saravana Kannan
@ 2020-02-26  2:13     ` John Stultz
  0 siblings, 0 replies; 19+ messages in thread
From: John Stultz @ 2020-02-26  2:13 UTC (permalink / raw)
  To: Saravana Kannan
  Cc: lkml, Rob Herring, Rafael J. Wysocki, Kevin Hilman, Ulf Hansson,
	Pavel Machek, Len Brown, Todd Kjos, Bjorn Andersson,
	Liam Girdwood, Mark Brown, Thierry Reding, Linus Walleij,
	Greg Kroah-Hartman, Linux PM

On Tue, Feb 25, 2020 at 6:11 PM Saravana Kannan <saravanak@google.com> wrote:
> On Mon, Feb 24, 2020 at 9:08 PM John Stultz <john.stultz@linaro.org> wrote:
> >
> > With the earlier sanity fixes to
> > driver_deferred_probe_check_state() it should be usable for the
> > pinctrl logic here.
> >
> > So tweak the logic to use driver_deferred_probe_check_state()
> > instead of driver_deferred_probe_check_state_continue()
> >
> > Cc: Rob Herring <robh@kernel.org>
> > Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> > Cc: Kevin Hilman <khilman@kernel.org>
> > Cc: Ulf Hansson <ulf.hansson@linaro.org>
> > Cc: Pavel Machek <pavel@ucw.cz>
> > Cc: Len Brown <len.brown@intel.com>
> > Cc: Todd Kjos <tkjos@google.com>
> > Cc: Saravana Kannan <saravanak@google.com>
> > Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
> > Cc: Liam Girdwood <lgirdwood@gmail.com>
> > Cc: Mark Brown <broonie@kernel.org>
> > Cc: Thierry Reding <treding@nvidia.com>
> > Cc: Linus Walleij <linus.walleij@linaro.org>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: linux-pm@vger.kernel.org
> > Acked-by: Linus Walleij <linus.walleij@linaro.org>
> > Signed-off-by: John Stultz <john.stultz@linaro.org>
> > ---
> >  drivers/pinctrl/devicetree.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
> > index 9357f7c46cf3..1ed20ac2243f 100644
> > --- a/drivers/pinctrl/devicetree.c
> > +++ b/drivers/pinctrl/devicetree.c
> > @@ -127,11 +127,12 @@ static int dt_to_map_one_config(struct pinctrl *p,
> >                 np_pctldev = of_get_next_parent(np_pctldev);
> >                 if (!np_pctldev || of_node_is_root(np_pctldev)) {
> >                         of_node_put(np_pctldev);
> > +                       ret = driver_deferred_probe_check_state(p->dev);
> >                         /* keep deferring if modules are enabled unless we've timed out */
> > -                       if (IS_ENABLED(CONFIG_MODULES) && !allow_default)
> > -                               return driver_deferred_probe_check_state_continue(p->dev);
> > -
> > -                       return driver_deferred_probe_check_state(p->dev);
> > +                       if (IS_ENABLED(CONFIG_MODULES) && !allow_default &&
>
> Is this IS_ENABLED(CONFIG_MODULES) still necessary? At the end of this
> series, doesn't driver_deferred_probe_check_state() already return
> -EPROBE_DEFER if modules are enabled and timeout hasn't happened?
>

Yea, good point. With the reworked logic in v5, the
IS_ENABLED(CONFIG_MODULES) check could go.

thanks
-john

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state()
  2020-02-25  5:08 [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state() John Stultz
                   ` (5 preceding siblings ...)
  2020-02-25  5:08 ` [PATCH v5 6/6] regulator: Use driver_deferred_probe_timeout for regulator_init_complete_work John Stultz
@ 2020-03-04 17:12 ` Greg Kroah-Hartman
  2020-04-21 23:59 ` Eugeniu Rosca
  7 siblings, 0 replies; 19+ messages in thread
From: Greg Kroah-Hartman @ 2020-03-04 17:12 UTC (permalink / raw)
  To: John Stultz
  Cc: lkml, Rob Herring, Rafael J. Wysocki, Kevin Hilman, Ulf Hansson,
	Pavel Machek, Len Brown, Todd Kjos, Saravana Kannan,
	Bjorn Andersson, Liam Girdwood, Mark Brown, Thierry Reding,
	Linus Walleij, linux-pm

On Tue, Feb 25, 2020 at 05:08:22AM +0000, John Stultz wrote:
> This series goal is to improve and cleanup the
> driver_deferred_probe_check_state() code in the driver core.
> 
> This series is useful for being able to support modules
> dependencies which may be loaded by userland, far after
> late_initcall is done. For instance, this series allows us to
> successfully use various clk drivers as modules on the db845c
> board. And without it, those drivers have to be statically built
> in to work.
> 
> Since I first sent out this patch, Saravana suggested an
> alternative approach which also works for our needs, and is a
> bit simpler:
>  https://lore.kernel.org/lkml/20200220055250.196456-1-saravanak@google.com/T/#u
> 
> However, while that patch provides the functionality we need,
> I still suspect the driver_deferred_probe_check_state() code
> could benefit from the cleanup in this patch, as the existing
> logic is somewhat muddy.

This looks much better, thanks for sticking with it, all now queued up.

greg k-h

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state()
  2020-02-25  5:08 [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state() John Stultz
                   ` (6 preceding siblings ...)
  2020-03-04 17:12 ` [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state() Greg Kroah-Hartman
@ 2020-04-21 23:59 ` Eugeniu Rosca
  2020-04-22  1:16   ` John Stultz
  7 siblings, 1 reply; 19+ messages in thread
From: Eugeniu Rosca @ 2020-04-21 23:59 UTC (permalink / raw)
  To: John Stultz
  Cc: lkml, Rob Herring, Rafael J. Wysocki, Kevin Hilman, Ulf Hansson,
	Pavel Machek, Len Brown, Todd Kjos, Saravana Kannan,
	Bjorn Andersson, Liam Girdwood, Mark Brown, Thierry Reding,
	Linus Walleij, Greg Kroah-Hartman, linux-pm, linux-renesas-soc,
	Eugeniu Rosca, Eugeniu Rosca

Hi John,
Cc: linux-renesas-soc

On Tue, Feb 25, 2020 at 05:08:22AM +0000, John Stultz wrote:
> This series goal is to improve and cleanup the
> driver_deferred_probe_check_state() code in the driver core.
> 
> This series is useful for being able to support modules
> dependencies which may be loaded by userland, far after
> late_initcall is done. For instance, this series allows us to
> successfully use various clk drivers as modules on the db845c
> board. And without it, those drivers have to be statically built
> in to work.
> 
> Since I first sent out this patch, Saravana suggested an
> alternative approach which also works for our needs, and is a
> bit simpler:
>  https://lore.kernel.org/lkml/20200220055250.196456-1-saravanak@google.com/T/#u
> 
> However, while that patch provides the functionality we need,
> I still suspect the driver_deferred_probe_check_state() code
> could benefit from the cleanup in this patch, as the existing
> logic is somewhat muddy.
> 
> New in v5:
> * Reworked the driver_deferred_probe_check_state() logic as
>   suggested by Saravana to tie the initcall_done checking with
>   modules being enabled.
> * Cleanup some comment wording as suggested by Rafael
> * Try to slightly simplify the regulator logic as suggested by
>   Bjorn
> 
> Thanks so much to Bjorn, Saravana and Rafael for their reviews
> and suggestions! Additional review and feedback is always greatly
> appreciated!

Building a recent [0] kernel using vanilla arm64 defconfig
and booting it on H3ULCB, I get buried into backtraces [1].

After reverting this series, up to and including its first commit,
booting goes back to normal [2].

Any chance to get a fix or at least some hints where to dig into?

[0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=18bf34080c4c3b
    ("Merge branch 'akpm' (patches from Andrew)")
[1] https://gist.github.com/erosca/ac779c348dd272c448e162c406c48f4a
[2] https://gist.github.com/erosca/5eea2bc5e82be651d405ba038d0ad036

-- 
Best regards,
Eugeniu Rosca

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state()
  2020-04-21 23:59 ` Eugeniu Rosca
@ 2020-04-22  1:16   ` John Stultz
  2020-04-22  6:46     ` Eugeniu Rosca
  2020-04-22  7:54     ` Mark Brown
  0 siblings, 2 replies; 19+ messages in thread
From: John Stultz @ 2020-04-22  1:16 UTC (permalink / raw)
  To: Eugeniu Rosca
  Cc: lkml, Rob Herring, Rafael J. Wysocki, Kevin Hilman, Ulf Hansson,
	Pavel Machek, Len Brown, Todd Kjos, Saravana Kannan,
	Bjorn Andersson, Liam Girdwood, Mark Brown, Thierry Reding,
	Linus Walleij, Greg Kroah-Hartman, Linux PM list,
	linux-renesas-soc, Eugeniu Rosca

On Tue, Apr 21, 2020 at 4:59 PM Eugeniu Rosca <erosca@de.adit-jv.com> wrote:
>
> Hi John,
> Cc: linux-renesas-soc
>
> On Tue, Feb 25, 2020 at 05:08:22AM +0000, John Stultz wrote:
> > This series goal is to improve and cleanup the
> > driver_deferred_probe_check_state() code in the driver core.
> >
> > This series is useful for being able to support modules
> > dependencies which may be loaded by userland, far after
> > late_initcall is done. For instance, this series allows us to
> > successfully use various clk drivers as modules on the db845c
> > board. And without it, those drivers have to be statically built
> > in to work.
> >
> > Since I first sent out this patch, Saravana suggested an
> > alternative approach which also works for our needs, and is a
> > bit simpler:
> >  https://lore.kernel.org/lkml/20200220055250.196456-1-saravanak@google.com/T/#u
> >
> > However, while that patch provides the functionality we need,
> > I still suspect the driver_deferred_probe_check_state() code
> > could benefit from the cleanup in this patch, as the existing
> > logic is somewhat muddy.
> >
> > New in v5:
> > * Reworked the driver_deferred_probe_check_state() logic as
> >   suggested by Saravana to tie the initcall_done checking with
> >   modules being enabled.
> > * Cleanup some comment wording as suggested by Rafael
> > * Try to slightly simplify the regulator logic as suggested by
> >   Bjorn
> >
> > Thanks so much to Bjorn, Saravana and Rafael for their reviews
> > and suggestions! Additional review and feedback is always greatly
> > appreciated!
>
> Building a recent [0] kernel using vanilla arm64 defconfig
> and booting it on H3ULCB, I get buried into backtraces [1].
>
> After reverting this series, up to and including its first commit,
> booting goes back to normal [2].
>
> Any chance to get a fix or at least some hints where to dig into?

Yea. There's two patch sets I have for this. The first quiets down the
warnings(we don't need stack dumps for these):
  https://lore.kernel.org/lkml/20200330202715.86609-1-john.stultz@linaro.org/

The second reverts the default timeout back to 0:
  https://lore.kernel.org/lkml/20200413204253.84991-1-john.stultz@linaro.org/


Let me know if those work for you, or if you're still having trouble
afterwards.  I need to resubmit the set as I'm guessing they've been
overlooked.

thanks
-john

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state()
  2020-04-22  1:16   ` John Stultz
@ 2020-04-22  6:46     ` Eugeniu Rosca
  2020-04-22  7:54     ` Mark Brown
  1 sibling, 0 replies; 19+ messages in thread
From: Eugeniu Rosca @ 2020-04-22  6:46 UTC (permalink / raw)
  To: John Stultz
  Cc: lkml, Rob Herring, Rafael J. Wysocki, Kevin Hilman, Ulf Hansson,
	Pavel Machek, Len Brown, Todd Kjos, Saravana Kannan,
	Bjorn Andersson, Liam Girdwood, Mark Brown, Thierry Reding,
	Linus Walleij, Greg Kroah-Hartman, Linux PM list,
	linux-renesas-soc, Eugeniu Rosca, Eugeniu Rosca

Hi John,

On Tue, Apr 21, 2020 at 06:16:31PM -0700, John Stultz wrote:
> On Tue, Apr 21, 2020 at 4:59 PM Eugeniu Rosca <erosca@de.adit-jv.com> wrote:
> >
> > Building a recent [0] kernel using vanilla arm64 defconfig
> > and booting it on H3ULCB, I get buried into backtraces [1].
> >
> > After reverting this series, up to and including its first commit,
> > booting goes back to normal [2].
> >
> > Any chance to get a fix or at least some hints where to dig into?
> 
> Yea. There's two patch sets I have for this. The first quiets down the
> warnings(we don't need stack dumps for these):
>   https://lore.kernel.org/lkml/20200330202715.86609-1-john.stultz@linaro.org/
> 
> The second reverts the default timeout back to 0:
>   https://lore.kernel.org/lkml/20200413204253.84991-1-john.stultz@linaro.org/
> 
> 
> Let me know if those work for you, or if you're still having trouble
> afterwards.  I need to resubmit the set as I'm guessing they've been
> overlooked.

The patches fix the issue on my end. Thanks!
One note is that they carry a slight mutual conflict, but that's up to
the maintainer to complain about.

Many thanks again!
Hope the patches will be picked up soon!

-- 
Best regards,
Eugeniu Rosca

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state()
  2020-04-22  1:16   ` John Stultz
  2020-04-22  6:46     ` Eugeniu Rosca
@ 2020-04-22  7:54     ` Mark Brown
  2020-04-22 20:45       ` John Stultz
  1 sibling, 1 reply; 19+ messages in thread
From: Mark Brown @ 2020-04-22  7:54 UTC (permalink / raw)
  To: John Stultz
  Cc: Eugeniu Rosca, lkml, Rob Herring, Rafael J. Wysocki,
	Kevin Hilman, Ulf Hansson, Pavel Machek, Len Brown, Todd Kjos,
	Saravana Kannan, Bjorn Andersson, Liam Girdwood, Thierry Reding,
	Linus Walleij, Greg Kroah-Hartman, Linux PM list,
	linux-renesas-soc, Eugeniu Rosca

[-- Attachment #1: Type: text/plain, Size: 278 bytes --]

On Tue, Apr 21, 2020 at 06:16:31PM -0700, John Stultz wrote:

> The second reverts the default timeout back to 0:
>   https://lore.kernel.org/lkml/20200413204253.84991-1-john.stultz@linaro.org/

If you're reverting the timeout we should revert the regulator change
too I think.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state()
  2020-04-22  7:54     ` Mark Brown
@ 2020-04-22 20:45       ` John Stultz
  2020-04-23  7:26         ` Geert Uytterhoeven
  2020-04-23 14:35         ` Mark Brown
  0 siblings, 2 replies; 19+ messages in thread
From: John Stultz @ 2020-04-22 20:45 UTC (permalink / raw)
  To: Mark Brown
  Cc: Eugeniu Rosca, lkml, Rob Herring, Rafael J. Wysocki,
	Kevin Hilman, Ulf Hansson, Pavel Machek, Len Brown, Todd Kjos,
	Saravana Kannan, Bjorn Andersson, Liam Girdwood, Thierry Reding,
	Linus Walleij, Greg Kroah-Hartman, Linux PM list,
	linux-renesas-soc, Eugeniu Rosca

On Wed, Apr 22, 2020 at 12:54 AM Mark Brown <broonie@kernel.org> wrote:
> On Tue, Apr 21, 2020 at 06:16:31PM -0700, John Stultz wrote:
>
> > The second reverts the default timeout back to 0:
> >   https://lore.kernel.org/lkml/20200413204253.84991-1-john.stultz@linaro.org/
>
> If you're reverting the timeout we should revert the regulator change
> too I think.

Maybe? The main issue for me was my change was clearly breaking users
with dts with missing dependencies where their setup was working
before. I sort of feel like having a dtb with missing dependencies is
less valid than wanting to load module dependencies from userland, but
they were working first, so we have to keep them happy :) And at least
now the latter can add the timeout boot argument to make it work.

For your case, I'm not sure if the timeout would run afoul on the nfs
root mounting case this one tripped over.

thanks
-john

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state()
  2020-04-22 20:45       ` John Stultz
@ 2020-04-23  7:26         ` Geert Uytterhoeven
  2020-04-23 14:35         ` Mark Brown
  1 sibling, 0 replies; 19+ messages in thread
From: Geert Uytterhoeven @ 2020-04-23  7:26 UTC (permalink / raw)
  To: John Stultz
  Cc: Mark Brown, Eugeniu Rosca, lkml, Rob Herring, Rafael J. Wysocki,
	Kevin Hilman, Ulf Hansson, Pavel Machek, Len Brown, Todd Kjos,
	Saravana Kannan, Bjorn Andersson, Liam Girdwood, Thierry Reding,
	Linus Walleij, Greg Kroah-Hartman, Linux PM list, Linux-Renesas,
	Eugeniu Rosca

Hi John,

On Wed, Apr 22, 2020 at 10:46 PM John Stultz <john.stultz@linaro.org> wrote:
> On Wed, Apr 22, 2020 at 12:54 AM Mark Brown <broonie@kernel.org> wrote:
> > On Tue, Apr 21, 2020 at 06:16:31PM -0700, John Stultz wrote:
> > > The second reverts the default timeout back to 0:
> > >   https://lore.kernel.org/lkml/20200413204253.84991-1-john.stultz@linaro.org/
> >
> > If you're reverting the timeout we should revert the regulator change
> > too I think.
>
> Maybe? The main issue for me was my change was clearly breaking users
> with dts with missing dependencies where their setup was working
> before. I sort of feel like having a dtb with missing dependencies is
> less valid than wanting to load module dependencies from userland, but
> they were working first, so we have to keep them happy :) And at least
> now the latter can add the timeout boot argument to make it work.

IOMMU support is optional.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state()
  2020-04-22 20:45       ` John Stultz
  2020-04-23  7:26         ` Geert Uytterhoeven
@ 2020-04-23 14:35         ` Mark Brown
  1 sibling, 0 replies; 19+ messages in thread
From: Mark Brown @ 2020-04-23 14:35 UTC (permalink / raw)
  To: John Stultz
  Cc: Eugeniu Rosca, lkml, Rob Herring, Rafael J. Wysocki,
	Kevin Hilman, Ulf Hansson, Pavel Machek, Len Brown, Todd Kjos,
	Saravana Kannan, Bjorn Andersson, Liam Girdwood, Thierry Reding,
	Linus Walleij, Greg Kroah-Hartman, Linux PM list,
	linux-renesas-soc, Eugeniu Rosca

[-- Attachment #1: Type: text/plain, Size: 986 bytes --]

On Wed, Apr 22, 2020 at 01:45:49PM -0700, John Stultz wrote:
> On Wed, Apr 22, 2020 at 12:54 AM Mark Brown <broonie@kernel.org> wrote:

> > If you're reverting the timeout we should revert the regulator change
> > too I think.

> Maybe? The main issue for me was my change was clearly breaking users
> with dts with missing dependencies where their setup was working
> before. I sort of feel like having a dtb with missing dependencies is
> less valid than wanting to load module dependencies from userland, but
> they were working first, so we have to keep them happy :) And at least
> now the latter can add the timeout boot argument to make it work.

> For your case, I'm not sure if the timeout would run afoul on the nfs
> root mounting case this one tripped over.

Given that it's basically entirely about glitching displays rather than
an unrecoverable break I suspect that anyone using NFS root is some
combination of unaffected or doesn't care if they see the timeout kick
in.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 484 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2020-04-23 14:35 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-25  5:08 [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state() John Stultz
2020-02-25  5:08 ` [PATCH v5 1/6] driver core: Fix driver_deferred_probe_check_state() logic John Stultz
2020-02-25 16:24   ` Rafael J. Wysocki
2020-02-25  5:08 ` [PATCH v5 2/6] driver core: Set deferred_probe_timeout to a longer default if CONFIG_MODULES is set John Stultz
2020-02-25  5:08 ` [PATCH v5 3/6] pinctrl: Remove use of driver_deferred_probe_check_state_continue() John Stultz
2020-02-26  2:11   ` Saravana Kannan
2020-02-26  2:13     ` John Stultz
2020-02-25  5:08 ` [PATCH v5 4/6] driver core: Remove driver_deferred_probe_check_state_continue() John Stultz
2020-02-25  5:08 ` [PATCH v5 5/6] driver core: Rename deferred_probe_timeout and make it global John Stultz
2020-02-25  5:08 ` [PATCH v5 6/6] regulator: Use driver_deferred_probe_timeout for regulator_init_complete_work John Stultz
2020-02-25 12:43   ` Mark Brown
2020-03-04 17:12 ` [PATCH v5 0/6] driver core: Improve and cleanup driver_deferred_probe_check_state() Greg Kroah-Hartman
2020-04-21 23:59 ` Eugeniu Rosca
2020-04-22  1:16   ` John Stultz
2020-04-22  6:46     ` Eugeniu Rosca
2020-04-22  7:54     ` Mark Brown
2020-04-22 20:45       ` John Stultz
2020-04-23  7:26         ` Geert Uytterhoeven
2020-04-23 14:35         ` Mark Brown

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).