Skip to contentSkip to conversation

async: Add cmdline option to specify drivers to be async probed

RFC PATCH Superseded Feng Tang 2 participants 2 messages Jan 25, 2019 Driver core

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Feng Tang

author
#0 lore raw

RFC PATCH 1/1 async: Add cmdline option to specify drivers to be async probed

Asynchronous driver probing can help much on kerenl fastboot, and this option can provide a flexible way to optimize and quickly verify async driver probe.

Also it will help in below cases:
* Some driver actually covers several family of HWs, some of which could use async probling while others don't. So we can't simply turn on the PROBE_PREFER_ASYNCHRONOUS flag in driver, but use this cmdline option, like igb driver discussed at
https://www.spinics.net/lists/netdev/msg545986.html

* For SOC (System on Chip) with multiple spi or i2c controllers, most of the slave spi/i2c devices will be assigned with fixed controller number, which prevents these spi/i2c controller drivers to be async probed. For plaforms not using these spi/i2c slave devices, they can use this cmdline option to benefit from the async probing.

---
 drivers/base/dd.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/base/dd.c +22 -0
index 8ac10af..1f257561 100644
@@ -57,6 +57,10 @@ static atomic_t deferred_trigger_count = ATOMIC_INIT(0);
 static struct dentry *deferred_devices;
 static bool initcalls_done;
 
+/* Save the async probe drivers' name from kernel cmdline */
+#define ASYNC_DRV_NAMES_MAX_LEN	256
+static char async_probe_drv_names[ASYNC_DRV_NAMES_MAX_LEN];
+
 /*
  * In some cases, like suspend to RAM or hibernation, It might be reasonable
  * to prohibit probing of devices as it could be unsafe.
@@ -674,8 +678,26 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
 	return ret;
 }
 
+static inline bool cmdline_requested_async_probing(const char *drv_name)
+{
+	return parse_option_str(async_probe_drv_names, drv_name);
+}
+
+static int __init save_async_options(char *buf)
+{
+	if (strlen(buf) >= ASYNC_DRV_NAMES_MAX_LEN)
+		printk(KERN_WARNING "Too long list for async_probe_drv_names!");
+
+	strlcpy(async_probe_drv_names, buf, ASYNC_DRV_NAMES_MAX_LEN - 1);
+	return 0;
+}
+__setup("driver_async_probe=", save_async_options);
+
 bool driver_allows_async_probing(struct device_driver *drv)
 {
+	if (unlikely(cmdline_requested_async_probing(drv->name)))
+		return true;
+
 	switch (drv->probe_type) {
 	case PROBE_PREFER_ASYNCHRONOUS:
 		return true;
Signature · 1 line
2.7.4
#1 lore raw
Quoted 12 lines · Feng Tang

Asynchronous driver probing can help much on kerenl fastboot, and this option can provide a flexible way to optimize and quickly verify async driver probe.

Also it will help in below cases:
* Some driver actually covers several family of HWs, some of which could use async probling while others don't. So we can't simply turn on the PROBE_PREFER_ASYNCHRONOUS flag in driver, but use this cmdline option, like igb driver discussed at
https://www.spinics.net/lists/netdev/msg545986.html

Quoted 7 lines

* For SOC (System on Chip) with multiple spi or i2c controllers, most of the slave spi/i2c devices will be assigned with fixed controller number, which prevents these spi/i2c controller drivers to be async probed. For plaforms not using these spi/i2c slave devices, they can use this cmdline option to benefit from the async probing.

Actually instead of using my personal email I would prefer if you used "[email protected]".

Quoted 34 lines
---
 drivers/base/dd.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/base/dd.c +14 -0
index 8ac10af..1f257561 100644
@@ -57,6 +57,10 @@ static atomic_t deferred_trigger_count = ATOMIC_INIT(0);
 static struct dentry *deferred_devices;
 static bool initcalls_done;
 
+/* Save the async probe drivers' name from kernel cmdline */
+#define ASYNC_DRV_NAMES_MAX_LEN        256
+static char async_probe_drv_names[ASYNC_DRV_NAMES_MAX_LEN];
+
 /*
  * In some cases, like suspend to RAM or hibernation, It might be reasonable
  * to prohibit probing of devices as it could be unsafe.
@@ -674,8 +678,26 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
        return ret;
 }
 
+static inline bool cmdline_requested_async_probing(const char *drv_name)
+{
+       return parse_option_str(async_probe_drv_names, drv_name);
+}
+
+static int __init save_async_options(char *buf)
+{
+       if (strlen(buf) >= ASYNC_DRV_NAMES_MAX_LEN)
+               printk(KERN_WARNING "Too long list for async_probe_drv_names!");
+

drivers/base/dd.c int driver_probe_device(struct device_driver *drv, struct device *dev) · line 700

Quoted 10 lines
drivers/base/dd.c +8 -0
+       strlcpy(async_probe_drv_names, buf, ASYNC_DRV_NAMES_MAX_LEN - 1);
+       return 0;
+}
+__setup("driver_async_probe=", save_async_options);
+
 bool driver_allows_async_probing(struct device_driver *drv)
 {
+       if (unlikely(cmdline_requested_async_probing(drv->name)))
+               return true;
+

Instead of placing it here it might make more sense to place it down in the "default" case. This way we don't override a PROBE_FORCE_SYNCHRONOUS if that is the probe type value used by the driver.

Quoted 6 lines
drivers/base/dd.c +0 -1
        switch (drv->probe_type) {
        case PROBE_PREFER_ASYNCHRONOUS:
                return true;
--

2.7.4