driver-core: enable drivers to opt-out of async probe
authorLuis R. Rodriguez <mcgrof@suse.com>
Mon, 30 Mar 2015 23:20:06 +0000 (16:20 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 May 2015 07:25:25 +0000 (00:25 -0700)
There are drivers that can not be probed asynchronously. One such group
is platform drivers registered with platform_driver_probe(), which
expects driver's probe routine be discarded after the driver has been
registered and initial binding attempt executed. Also
platform_driver_probe() an error when no devices were bound to the
driver, allowing failing to load such driver module altogether.

Other drivers do not work well with asynchronous probing because of
driver bug or not optimal driver organization.

To allow using such drivers even when user requests asynchronous probing
as default boot strategy, let's allow them to opt out.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/dd.c
include/linux/device.h

index 7a2fa5dcead7c924ce2fd5af2b08fc3d97944efa..39292535c74e1a9efa33d043a8d5a62c92ca157d 100644 (file)
@@ -419,13 +419,19 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
 
 bool driver_allows_async_probing(struct device_driver *drv)
 {
-       if (drv->probe_type == PROBE_PREFER_ASYNCHRONOUS)
+       switch (drv->probe_type) {
+       case PROBE_PREFER_ASYNCHRONOUS:
                return true;
 
-       if (drv->owner && drv->owner->async_probe_requested)
-               return true;
+       case PROBE_FORCE_SYNCHRONOUS:
+               return false;
+
+       default:
+               if (drv->owner && drv->owner->async_probe_requested)
+                       return true;
 
-       return false;
+               return false;
+       }
 }
 
 struct device_attach_data {
index 77b7cd9e54671cb00b150d4d93cd85fd3a687484..00ac57c26615103b0983040981cac8012c9e2f99 100644 (file)
@@ -201,15 +201,15 @@ extern struct klist *bus_get_device_klist(struct bus_type *bus);
  *     respective probe routines. This tells the core what to
  *     expect and prefer.
  *
- * @PROBE_DEFAULT_STRATEGY: Drivers expect their probe routines
- *     to run synchronously with driver and device registration
- *     (with the exception of -EPROBE_DEFER handling - re-probing
- *     always ends up being done asynchronously) unless user
- *     explicitly requested asynchronous probing via module
- *     parameter.
+ * @PROBE_DEFAULT_STRATEGY: Used by drivers that work equally well
+ *     whether probed synchronously or asynchronously.
  * @PROBE_PREFER_ASYNCHRONOUS: Drivers for "slow" devices which
  *     probing order is not essential for booting the system may
  *     opt into executing their probes asynchronously.
+ * @PROBE_FORCE_SYNCHRONOUS: Use this to annotate drivers that need
+ *     their probe routines to run synchronously with driver and
+ *     device registration (with the exception of -EPROBE_DEFER
+ *     handling - re-probing always ends up being done asynchronously).
  *
  * Note that the end goal is to switch the kernel to use asynchronous
  * probing by default, so annotating drivers with
@@ -220,6 +220,7 @@ extern struct klist *bus_get_device_klist(struct bus_type *bus);
 enum probe_type {
        PROBE_DEFAULT_STRATEGY,
        PROBE_PREFER_ASYNCHRONOUS,
+       PROBE_FORCE_SYNCHRONOUS,
 };
 
 /**