Skip to contentSkip to conversation

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

PATCH In review Feng Tang 2 participants 3 messages Jan 31, 2019

Subsystems (2)
lore
Share & tools
lore

Feng Tang

author
#0 lore raw

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

Asynchronous driver probing can help much on kernel 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 families of HWs, some of which could use async probing 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 async patch 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, while async probing may make those controllers get different index for each boot, which prevents those controller drivers to be async probed. For platforms not using these spi/i2c slave devices, they can use this cmdline option to benefit from the async probing.

---
Changelog:
v4:
Add description to kernel-parameters.txt and refine the prink message, as suggested by Randy Dunlap

v3:
move the cmdline_requested_async_probing() into "default:" part to enforce the PROBE_FORCE_SYNCHRONOUS check, as suggested by Alexander Duyck

v2:
* change Alexander Duyck's email to [email protected]
* fix the parameter for strlcpy()

 Documentation/admin-guide/kernel-parameters.txt |  4 ++++
 drivers/base/dd.c                               | 24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +4 -0
index b799bcf..a5b2112 100644
@@ -910,6 +910,10 @@
 			The filter can be disabled or changed to another
 			driver later using sysfs.
 
+	driver_async_probe=  [KNL]
+			List of driver names to be probed asynchronously.
+			Format: <driver_name1>,<driver_name2>...
+
 	drm.edid_firmware=[<connector>:]<file>[,[<connector>:]<file>]
 			Broken monitors, graphic adapters, KVMs and EDIDless
 			panels may send no or incorrect EDID data sets.
drivers/base/dd.c +24 -0
index 8ac10af..279204a 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,6 +678,23 @@ 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);
+}
+
+/* The option format is "driver_async_probe=drv_name1,drv_name2,..." */
+static int __init save_async_options(char *buf)
+{
+	if (strlen(buf) >= ASYNC_DRV_NAMES_MAX_LEN)
+		printk(KERN_WARNING
+			"Too long list of driver names for 'async_probe_drv_names'!\n");
+
+	strlcpy(async_probe_drv_names, buf, ASYNC_DRV_NAMES_MAX_LEN);
+	return 0;
+}
+__setup("driver_async_probe=", save_async_options);
+
 bool driver_allows_async_probing(struct device_driver *drv)
 {
 	switch (drv->probe_type) {
@@ -684,6 +705,9 @@ bool driver_allows_async_probing(struct device_driver *drv)
 		return false;
 
 	default:
+		if (cmdline_requested_async_probing(drv->name))
+			return true;
+
 		if (module_requested_async_probing(drv->owner))
 			return true;
 
Signature · 1 line
2.7.4
reviewer
#1 lore raw
Quoted 18 lines · Feng Tang

Asynchronous driver probing can help much on kernel 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 families of HWs, some of which could use async probing 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 async patch 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, while async probing may make those controllers get different index for each boot, which prevents those controller drivers to be async probed. For platforms not using these spi/i2c slave devices, they can use this cmdline option to benefit from the async probing.

Quoted 7 lines

---
Changelog:
v4:
Add description to kernel-parameters.txt and refine the

The doc update looks good, but I don't really see the refinement of the printk message. It still contains the incorrect cmdline option name.

Quoted 50 lines

prink message, as suggested by Randy Dunlap

v3:
move the cmdline_requested_async_probing() into "default:" part to enforce the PROBE_FORCE_SYNCHRONOUS check, as suggested by Alexander Duyck

v2:
* change Alexander Duyck's email to [email protected]
* fix the parameter for strlcpy()

 Documentation/admin-guide/kernel-parameters.txt |  4 ++++
 drivers/base/dd.c                               | 24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +4 -0
index b799bcf..a5b2112 100644
@@ -910,6 +910,10 @@
 			The filter can be disabled or changed to another
 			driver later using sysfs.
 
+	driver_async_probe=  [KNL]
+			List of driver names to be probed asynchronously.
+			Format: <driver_name1>,<driver_name2>...
+
 	drm.edid_firmware=[<connector>:]<file>[,[<connector>:]<file>]
 			Broken monitors, graphic adapters, KVMs and EDIDless
 			panels may send no or incorrect EDID data sets.
drivers/base/dd.c +5 -0
index 8ac10af..279204a 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,6 +678,23 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
 	return ret;
 }
 
+static inline bool cmdline_requested_async_probing(const char *drv_name)

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

Quoted 10 lines
drivers/base/dd.c +10 -0
+{
+	return parse_option_str(async_probe_drv_names, drv_name);
+}
+
+/* The option format is "driver_async_probe=drv_name1,drv_name2,..." */
+static int __init save_async_options(char *buf)
+{
+	if (strlen(buf) >= ASYNC_DRV_NAMES_MAX_LEN)
+		printk(KERN_WARNING
+			"Too long list of driver names for 'async_probe_drv_names'!\n");

should be 'driver_async_probe'

Quoted 11 lines
drivers/base/dd.c +6 -0
+
+	strlcpy(async_probe_drv_names, buf, ASYNC_DRV_NAMES_MAX_LEN);
+	return 0;
+}
+__setup("driver_async_probe=", save_async_options);
+
 bool driver_allows_async_probing(struct device_driver *drv)
 {
 	switch (drv->probe_type) {

drivers/base/dd.c bool driver_allows_async_probing(struct device_driver *drv) · line 713

Quoted 9 lines
drivers/base/dd.c +3 -0
@@ -684,6 +705,9 @@ bool driver_allows_async_probing(struct device_driver *drv)
 		return false;
 
 	default:
+		if (cmdline_requested_async_probing(drv->name))
+			return true;
+
 		if (module_requested_async_probing(drv->owner))
 			return true;
 

thanks.

Signature · 1 line
~Randy
author
#2 lore raw
In reply to Feng Tang

From 05e8ce911859e65d3b96348b0772f307daaeba77 Mon Sep 17 00:00:00 2001
From: Feng Tang <[email protected]>
Date: Fri, 25 Jan 2019 16:48:54 +0800
Subject: [PATCH v4] async: Add cmdline option to specify drivers to be async
probed

Asynchronous driver probing can help much on kernel 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 families of HWs, some of which could use async probing 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 async patch 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, while async probing may make those controllers get different index for each boot, which prevents those controller drivers to be async probed. For platforms not using these spi/i2c slave devices, they can use this cmdline option to benefit from the async probing.

---
Changelog:
v4:
Add description to kernel-parameters.txt and refine the prink message, as suggested by Randy Dunlap

v3:
move the cmdline_requested_async_probing() into "default:" part to enforce the PROBE_FORCE_SYNCHRONOUS check, as suggested by Alexander Duyck

v2:
* change Alexander Duyck's email to [email protected]
* fix the parameter for strlcpy()

 Documentation/admin-guide/kernel-parameters.txt |  4 ++++
 drivers/base/dd.c                               | 24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +4 -0
index b799bcf..a5b2112 100644
@@ -910,6 +910,10 @@
 			The filter can be disabled or changed to another
 			driver later using sysfs.
 
+	driver_async_probe=  [KNL]
+			List of driver names to be probed asynchronously.
+			Format: <driver_name1>,<driver_name2>...
+
 	drm.edid_firmware=[<connector>:]<file>[,[<connector>:]<file>]
 			Broken monitors, graphic adapters, KVMs and EDIDless
 			panels may send no or incorrect EDID data sets.
drivers/base/dd.c +24 -0
index 8ac10af..279204a 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,6 +678,23 @@ 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);
+}
+
+/* The option format is "driver_async_probe=drv_name1,drv_name2,..." */
+static int __init save_async_options(char *buf)
+{
+	if (strlen(buf) >= ASYNC_DRV_NAMES_MAX_LEN)
+		printk(KERN_WARNING
+			"Too long list of driver names for 'driver_async_probe'!\n");
+
+	strlcpy(async_probe_drv_names, buf, ASYNC_DRV_NAMES_MAX_LEN);
+	return 0;
+}
+__setup("driver_async_probe=", save_async_options);
+
 bool driver_allows_async_probing(struct device_driver *drv)
 {
 	switch (drv->probe_type) {
@@ -684,6 +705,9 @@ bool driver_allows_async_probing(struct device_driver *drv)
 		return false;
 
 	default:
+		if (cmdline_requested_async_probing(drv->name))
+			return true;
+
 		if (module_requested_async_probing(drv->owner))
 			return true;
 
Signature · 1 line
2.7.4