All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] async: Add cmdline option to specify drivers to be async probed
@ 2019-01-30  7:23 Feng Tang
  2019-01-30 16:27 ` Randy Dunlap
  0 siblings, 1 reply; 4+ messages in thread
From: Feng Tang @ 2019-01-30  7:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Arjan van de Ven,
	Alexander Duyck, linux-kernel
  Cc: 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.

Suggested-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
---
Changelog:
  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 alexander.h.duyck@linux.intel.com
    * fix the parameter for strlcpy()

 drivers/base/dd.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 8ac10af..e99d781 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -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,22 @@ 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 format is like driver_async_probe=drv_name1,drv_name2,drv_name3 */
+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!\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 +704,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;
 
-- 
2.7.4


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

* Re: [PATCH v3] async: Add cmdline option to specify drivers to be async probed
  2019-01-30  7:23 [PATCH v3] async: Add cmdline option to specify drivers to be async probed Feng Tang
@ 2019-01-30 16:27 ` Randy Dunlap
  0 siblings, 0 replies; 4+ messages in thread
From: Randy Dunlap @ 2019-01-30 16:27 UTC (permalink / raw)
  To: Feng Tang, Greg Kroah-Hartman, Rafael J . Wysocki,
	Arjan van de Ven, Alexander Duyck, linux-kernel

On 1/29/19 11:23 PM, Feng Tang wrote:
> 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.
> 
> Suggested-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
> Signed-off-by: Feng Tang <feng.tang@intel.com>
> ---
> Changelog:
>   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 alexander.h.duyck@linux.intel.com
>     * fix the parameter for strlcpy()
> 
>  drivers/base/dd.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 8ac10af..e99d781 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -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,22 @@ 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 format is like driver_async_probe=drv_name1,drv_name2,drv_name3 */

Please document this boot option in Documentation/admin-guide/kernel-parameters.txt.

> +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!\n");

use the correct cmdline option name here.  E.g.:
		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 +704,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;
>  
> 


-- 
~Randy

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

* Re: [PATCH v3] async: Add cmdline option to specify drivers to be async probed
  2019-01-30  6:38 Feng Tang
@ 2019-01-30  7:16 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2019-01-30  7:16 UTC (permalink / raw)
  To: Feng Tang
  Cc: Rafael J . Wysocki, Arjan van de Ven, Alexander Duyck, linux-kernel

On Wed, Jan 30, 2019 at 02:38:07PM +0800, Feng Tang wrote:
> 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.
> 
> Suggested-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
> Signed-off-by: Feng Tang <feng.tang@intel.com>
> ---
>  drivers/base/dd.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)

This is v3 and yet no change information below the --- line saying what
is different from previous versions at all?

Not good, please fix.

greg k-h

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

* [PATCH v3] async: Add cmdline option to specify drivers to be async probed
@ 2019-01-30  6:38 Feng Tang
  2019-01-30  7:16 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Feng Tang @ 2019-01-30  6:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki, Arjan van de Ven,
	Alexander Duyck, linux-kernel
  Cc: 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.

Suggested-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
---
 drivers/base/dd.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 8ac10af..e99d781 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -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,22 @@ 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 format is like driver_async_probe=drv_name1,drv_name2,drv_name3 */
+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);
+	return 0;
+}
+__setup("driver_async_probe=", save_async_options);
+
 bool driver_allows_async_probing(struct device_driver *drv)
 {
 	switch (drv->probe_type) {
@@ -684,6 +704,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;
 
-- 
2.7.4


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

end of thread, other threads:[~2019-01-30 16:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-30  7:23 [PATCH v3] async: Add cmdline option to specify drivers to be async probed Feng Tang
2019-01-30 16:27 ` Randy Dunlap
  -- strict thread matches above, loose matches on Subject: below --
2019-01-30  6:38 Feng Tang
2019-01-30  7:16 ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.