[PATCH v2 resend] driver core: Make deferred_probe_timeout default a Kconfig option

Hans de Goede posted 1 patch 2 weeks, 4 days ago
Documentation/admin-guide/kernel-parameters.txt | 2 +-
drivers/base/Kconfig                            | 9 +++++++++
drivers/base/dd.c                               | 6 +-----
3 files changed, 11 insertions(+), 6 deletions(-)
[PATCH v2 resend] driver core: Make deferred_probe_timeout default a Kconfig option
Posted by Hans de Goede 2 weeks, 4 days ago
Code using driver_deferred_probe_check_state() differs from most
EPROBE_DEFER handling in the kernel. Where other EPROBE_DEFER handling
(e.g. clks, gpios and regulators) waits indefinitely for suppliers to
show up, code using driver_deferred_probe_check_state() will fail
after the deferred_probe_timeout.

This is a problem for generic distro kernels which want to support many
boards using a single kernel build. These kernels want as much drivers to
be modular as possible. The initrd also should be as small as possible,
so the initrd will *not* have drivers not needing to get the rootfs.

Combine this with waiting for a full-disk encryption password in
the initrd and it is pretty much guaranteed that the default 10s timeout
will be hit, causing probe() failures when drivers on the rootfs happen
to get modprobe-d before other rootfs modules providing their suppliers.

Make the default timeout configurable from Kconfig to allow distro kernel
configs where many of the supplier drivers are modules to set the default
through Kconfig.

While at it document that a value of -1 can be used to disable the timeout
(wait indefinitely).

Acked-by: Saravana Kannan <saravanak@kernel.org>
Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
---
Changes in v2:
- Remove unnecessary addition of "if (driver_deferred_probe_timeout < 0)"
  check
- Add Acked-by from Saravana
---
Resending as this one seems to have fallen through the cracks.
---
 Documentation/admin-guide/kernel-parameters.txt | 2 +-
 drivers/base/Kconfig                            | 9 +++++++++
 drivers/base/dd.c                               | 6 +-----
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index aa0031108bc1..d26957741713 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1250,7 +1250,7 @@ Kernel parameters
 			out hasn't expired, it'll be restarted by each
 			successful driver registration. This option will also
 			dump out devices still on the deferred probe list after
-			retrying.
+			retrying. Set to -1 to wait indefinitely.
 
 	delayacct	[KNL] Enable per-task delay accounting
 
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 1786d87b29e2..f7d385cbd3ba 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -73,6 +73,15 @@ config DEVTMPFS_SAFE
 	  with the PROT_EXEC flag. This can break, for example, non-KMS
 	  video drivers.
 
+config DRIVER_DEFERRED_PROBE_TIMEOUT
+	int "Default value for deferred_probe_timeout"
+	default 0 if !MODULES
+	default 10 if MODULES
+	help
+	  Set the default value for the deferred_probe_timeout kernel parameter.
+	  See Documentation/admin-guide/kernel-parameters.txt for a description
+	  of the deferred_probe_timeout kernel parameter.
+
 config STANDALONE
 	bool "Select only drivers that don't need compile-time external firmware"
 	default y
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index bea8da5f8a3a..2f358e29e0e8 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -257,11 +257,7 @@ static int deferred_devs_show(struct seq_file *s, void *data)
 }
 DEFINE_SHOW_ATTRIBUTE(deferred_devs);
 
-#ifdef CONFIG_MODULES
-static int driver_deferred_probe_timeout = 10;
-#else
-static int driver_deferred_probe_timeout;
-#endif
+static int driver_deferred_probe_timeout = CONFIG_DRIVER_DEFERRED_PROBE_TIMEOUT;
 
 static int __init deferred_probe_timeout_setup(char *str)
 {
-- 
2.53.0
Re: [PATCH v2 resend] driver core: Make deferred_probe_timeout default a Kconfig option
Posted by Danilo Krummrich 2 days, 3 hours ago
On Sat Mar 14, 2026 at 9:49 AM CET, Hans de Goede wrote:
> Code using driver_deferred_probe_check_state() differs from most
> EPROBE_DEFER handling in the kernel. Where other EPROBE_DEFER handling
> (e.g. clks, gpios and regulators) waits indefinitely for suppliers to
> show up, code using driver_deferred_probe_check_state() will fail
> after the deferred_probe_timeout.
>
> This is a problem for generic distro kernels which want to support many
> boards using a single kernel build. These kernels want as much drivers to
> be modular as possible. The initrd also should be as small as possible,
> so the initrd will *not* have drivers not needing to get the rootfs.
>
> Combine this with waiting for a full-disk encryption password in
> the initrd and it is pretty much guaranteed that the default 10s timeout
> will be hit, causing probe() failures when drivers on the rootfs happen
> to get modprobe-d before other rootfs modules providing their suppliers.
>
> Make the default timeout configurable from Kconfig to allow distro kernel
> configs where many of the supplier drivers are modules to set the default
> through Kconfig.
>
> While at it document that a value of -1 can be used to disable the timeout
> (wait indefinitely).
>
> Acked-by: Saravana Kannan <saravanak@kernel.org>
> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>

Applied to driver-core-testing, thanks!

    [ Drop deferred_probe_timeout documentation change in
      kernel-parameters.txt. - Danilo ]

Sorry for the delay -- I dropped the documentation change as I think it deserves
a separate patch and I think that just adding "Set to -1 to wait indefinitely."
at the end doesn't read very well.

(Also, I think every negative value will result in waiting indefinitely.)

I also upgraded Saravana's ACK (which already was conditional on this change
before) to an RB, as offered in [1].

	deferred_probe_timeout=
		[KNL] Debugging option to set a timeout in seconds for
		deferred probe to give up waiting on dependencies to
		probe. Only specific dependencies (subsystems or
		drivers) that have opted in will be ignored. A timeout
		of 0 will timeout at the end of initcalls. If the time
		out hasn't expired, it'll be restarted by each
		successful driver registration. This option will also
		dump out devices still on the deferred probe list after
		retrying. Set to -1 to wait indefinitely.

Maybe something like this?

	deferred_probe_timeout=
		[KNL] Debugging option to set a timeout in seconds for
		deferred probe to give up waiting on dependencies to
		probe. Only specific dependencies (subsystems or
		drivers) that have opted in will be ignored. A timeout
		of 0 will timeout at the end of initcalls; a negative value
		is treated as an infinite timeout value. If the timeout
		hasn't expired, it'll be restarted by each successful
		driver registration. This option will also dump out devices
		still on the deferred probe list after retrying.

[1] https://lore.kernel.org/all/CACRMN=eacrCNQodiYZJ-XH8rA6ZTEKNGrGi3JTrjFFGfMgSh5g@mail.gmail.com/
Re: [PATCH v2 resend] driver core: Make deferred_probe_timeout default a Kconfig option
Posted by Hans de Goede 2 days, 7 hours ago
Hi All,

On 14-Mar-26 09:49, Hans de Goede wrote:
> Code using driver_deferred_probe_check_state() differs from most
> EPROBE_DEFER handling in the kernel. Where other EPROBE_DEFER handling
> (e.g. clks, gpios and regulators) waits indefinitely for suppliers to
> show up, code using driver_deferred_probe_check_state() will fail
> after the deferred_probe_timeout.
> 
> This is a problem for generic distro kernels which want to support many
> boards using a single kernel build. These kernels want as much drivers to
> be modular as possible. The initrd also should be as small as possible,
> so the initrd will *not* have drivers not needing to get the rootfs.
> 
> Combine this with waiting for a full-disk encryption password in
> the initrd and it is pretty much guaranteed that the default 10s timeout
> will be hit, causing probe() failures when drivers on the rootfs happen
> to get modprobe-d before other rootfs modules providing their suppliers.
> 
> Make the default timeout configurable from Kconfig to allow distro kernel
> configs where many of the supplier drivers are modules to set the default
> through Kconfig.
> 
> While at it document that a value of -1 can be used to disable the timeout
> (wait indefinitely).
> 
> Acked-by: Saravana Kannan <saravanak@kernel.org>
> Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>

gentle ping ?

AFAICT there is no reason to not merge this ?

Regards,

Hans



> ---
> Changes in v2:
> - Remove unnecessary addition of "if (driver_deferred_probe_timeout < 0)"
>   check
> - Add Acked-by from Saravana
> ---
> Resending as this one seems to have fallen through the cracks.
> ---
>  Documentation/admin-guide/kernel-parameters.txt | 2 +-
>  drivers/base/Kconfig                            | 9 +++++++++
>  drivers/base/dd.c                               | 6 +-----
>  3 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index aa0031108bc1..d26957741713 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -1250,7 +1250,7 @@ Kernel parameters
>  			out hasn't expired, it'll be restarted by each
>  			successful driver registration. This option will also
>  			dump out devices still on the deferred probe list after
> -			retrying.
> +			retrying. Set to -1 to wait indefinitely.
>  
>  	delayacct	[KNL] Enable per-task delay accounting
>  
> diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
> index 1786d87b29e2..f7d385cbd3ba 100644
> --- a/drivers/base/Kconfig
> +++ b/drivers/base/Kconfig
> @@ -73,6 +73,15 @@ config DEVTMPFS_SAFE
>  	  with the PROT_EXEC flag. This can break, for example, non-KMS
>  	  video drivers.
>  
> +config DRIVER_DEFERRED_PROBE_TIMEOUT
> +	int "Default value for deferred_probe_timeout"
> +	default 0 if !MODULES
> +	default 10 if MODULES
> +	help
> +	  Set the default value for the deferred_probe_timeout kernel parameter.
> +	  See Documentation/admin-guide/kernel-parameters.txt for a description
> +	  of the deferred_probe_timeout kernel parameter.
> +
>  config STANDALONE
>  	bool "Select only drivers that don't need compile-time external firmware"
>  	default y
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index bea8da5f8a3a..2f358e29e0e8 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -257,11 +257,7 @@ static int deferred_devs_show(struct seq_file *s, void *data)
>  }
>  DEFINE_SHOW_ATTRIBUTE(deferred_devs);
>  
> -#ifdef CONFIG_MODULES
> -static int driver_deferred_probe_timeout = 10;
> -#else
> -static int driver_deferred_probe_timeout;
> -#endif
> +static int driver_deferred_probe_timeout = CONFIG_DRIVER_DEFERRED_PROBE_TIMEOUT;
>  
>  static int __init deferred_probe_timeout_setup(char *str)
>  {