Patch "driver core: Fix driver_deferred_probe_check_state() logic" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    driver core: Fix driver_deferred_probe_check_state() logic

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     driver-core-fix-driver_deferred_probe_check_state-lo.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e507b1ffd90ffc541fe254be4b63d4f3ff420a7c
Author: John Stultz <john.stultz@xxxxxxxxxx>
Date:   Tue Feb 25 05:08:23 2020 +0000

    driver core: Fix driver_deferred_probe_check_state() logic
    
    [ Upstream commit c8c43cee29f6ca2575c953ae600263690db28f41 ]
    
    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: linux-pm@xxxxxxxxxxxxxxx
    Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Cc: Linus Walleij <linus.walleij@xxxxxxxxxx>
    Cc: Thierry Reding <treding@xxxxxxxxxx>
    Cc: Mark Brown <broonie@xxxxxxxxxx>
    Cc: Liam Girdwood <lgirdwood@xxxxxxxxx>
    Cc: Bjorn Andersson <bjorn.andersson@xxxxxxxxxx>
    Cc: Saravana Kannan <saravanak@xxxxxxxxxx>
    Cc: Todd Kjos <tkjos@xxxxxxxxxx>
    Cc: Len Brown <len.brown@xxxxxxxxx>
    Cc: Pavel Machek <pavel@xxxxxx>
    Cc: Ulf Hansson <ulf.hansson@xxxxxxxxxx>
    Cc: Kevin Hilman <khilman@xxxxxxxxxx>
    Cc: "Rafael J. Wysocki" <rjw@xxxxxxxxxxxxx>
    Cc: Rob Herring <robh@xxxxxxxxxx>
    Signed-off-by: John Stultz <john.stultz@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20200225050828.56458-2-john.stultz@xxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 10063d8a1b7d..2a28e07d2e0b 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;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux