Skip to contentSkip to conversation

driver core: Decouple device links enforcing and probe deferral timeouts

PATCH In review Javier Martinez Canillas 5 participants 19 messages Nov 16, 2022 – Dec 12, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover driver core: Decouple device links enforcing and probe deferral timeouts

This series is a v2 of patch "driver core: Disable driver deferred probe timeout by default" [0] but using a slightly different approach after the feedback I got on v1.

The problem with v1 was that just disabling the probe deferral timeout by default would cause a regression for drivers that may want to probe even if their (optional) dependencies are not present yet.

But this was achieved by timing out the probe deferral mechanism, which calls fw_devlink_drivers_done() in its work queue function handler. There is not reason to tie the two though, it should be possible to relax the device links to allow drivers to probe even if their optional suppliers are not present, while still keep the probe deferral mechanism enabled so that drivers that have required dependencies are still able to defer their probe.

This series decouple the two operations by adding a fw_devlink.timeout= command line parameter. That way, the probe deferral timeout can be set to -1 by default, reverting to the previous behaviour while still allow drivers to probe with optional dependencies missing.

Patch #1 is just a cleanup that makes the driver_deferred_probe_timeout variable static since isn't used outside of its compilation unit.

Patch #2 disables the deferred probe mechanism after late_initcall if modules are disable. Since there is no point to schedule the timer in that case.

Patch #3 adds the new "fw_devlink.timeout=" cmdline param, that can be used to set a timeout for the device links enforcing. The semantics are quite similar to the existing "deferred_probe_timeout=" cmdline param.

Patch #4 then changes the default value for the probe deferral timeout, to just disable it by default and make the probe deferral mechanism to revert to the behaviour that had before. That is, to just try to probe the drivers indefinitely. But the device link enforcing timeout is set to 10 seconds, to keep the existing expectations for drivers that want to probe even if their optional dependencies are not present.

I have tested on my HP X2 Chromebook and the DRM driver that was failing to probe before now works without any cmdline parameters. I also tested with different combinations of device links and deferred probe timeouts.

[0]: https://lore.kernel.org/lkml/[email protected]/T/#t

Best regards,
Javier

Changes in v2:
- Mention in the commit messsage the specific machine and drivers that are affected by the issue (Greg).
- Double check the commit message for accuracy (John).
- Add a second workqueue to timeout the devlink enforcing and allow drivers to probe even without their optional dependencies available.

Javier Martinez Canillas (4):
driver core: Make driver_deferred_probe_timeout a static variable driver core: Set deferred probe timeout to 0 if modules are disabled driver core: Add fw_devlink.timeout param to stop waiting for devlinks driver core: Disable driver deferred probe timeout by default

 .../admin-guide/kernel-parameters.txt         |  7 +++
 drivers/base/dd.c                             | 48 +++++++++++++++----
 include/linux/device/driver.h                 |  1 -
 3 files changed, 47 insertions(+), 9 deletions(-)
Signature · 1 line
2.38.1
#1 lore raw

PATCH v2 1/4 driver core: Make driver_deferred_probe_timeout a static variable

It is not used outside of its compilation unit, so there's no need to export this variable.

---

(no changes since v1)

 drivers/base/dd.c             | 6 ++----
 include/linux/device/driver.h | 1 -
 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/base/dd.c +2 -4
index 3dda62503102..040b4060f903 100644
@@ -257,13 +257,11 @@ static int deferred_devs_show(struct seq_file *s, void *data)
 DEFINE_SHOW_ATTRIBUTE(deferred_devs);
 
 #ifdef CONFIG_MODULES
-int driver_deferred_probe_timeout = 10;
+static int driver_deferred_probe_timeout = 10;
 #else
-int driver_deferred_probe_timeout;
+static int driver_deferred_probe_timeout;
 #endif
 
-EXPORT_SYMBOL_GPL(driver_deferred_probe_timeout);
-
 static int __init deferred_probe_timeout_setup(char *str)
 {
 	int timeout;
include/linux/device/driver.h +0 -1
index 2114d65b862f..50d0a416a5e7 100644
@@ -240,7 +240,6 @@ driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev)
 }
 #endif
 
-extern int driver_deferred_probe_timeout;
 void driver_deferred_probe_add(struct device *dev);
 int driver_deferred_probe_check_state(struct device *dev);
 void driver_init(void);
Signature · 1 line
2.38.1
Reviewed-by on v2 1/4
#2 lore raw

Re: [PATCH v2 1/4] driver core: Make driver_deferred_probe_timeout a static variable

Quoted 4 lines · Javier Martinez Canillas

It is not used outside of its compilation unit, so there's no need to export this variable.

Quoted 43 lines

---

(no changes since v1)

 drivers/base/dd.c             | 6 ++----
 include/linux/device/driver.h | 1 -
 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/base/dd.c +2 -4
index 3dda62503102..040b4060f903 100644
@@ -257,13 +257,11 @@ static int deferred_devs_show(struct seq_file *s, void *data)
 DEFINE_SHOW_ATTRIBUTE(deferred_devs);
 
 #ifdef CONFIG_MODULES
-int driver_deferred_probe_timeout = 10;
+static int driver_deferred_probe_timeout = 10;
 #else
-int driver_deferred_probe_timeout;
+static int driver_deferred_probe_timeout;
 #endif
 
-EXPORT_SYMBOL_GPL(driver_deferred_probe_timeout);
-
 static int __init deferred_probe_timeout_setup(char *str)
 {
 	int timeout;
include/linux/device/driver.h +0 -1
index 2114d65b862f..50d0a416a5e7 100644
@@ -240,7 +240,6 @@ driver_find_device_by_acpi_dev(struct device_driver *drv, const void *adev)
 }
 #endif
 
-extern int driver_deferred_probe_timeout;
 void driver_deferred_probe_add(struct device *dev);
 int driver_deferred_probe_check_state(struct device *dev);
 void driver_init(void);
Signature · 1 line
2.38.1
Acked-by on v2 1/4
#3 lore raw

Re: [PATCH v2 1/4] driver core: Make driver_deferred_probe_timeout a static variable

In reply to Javier Martinez Canillas
Quoted 20 lines · Javier Martinez Canillas

It is not used outside of its compilation unit, so there's no need to export this variable.

---

(no changes since v1)

 drivers/base/dd.c             | 6 ++----
 include/linux/device/driver.h | 1 -
 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/base/dd.c +0 -0
index 3dda62503102..040b4060f903 100644
@@ -257,13 +257,11 @@ static int deferred_devs_show(struct seq_file *s, void *data)
 DEFINE_SHOW_ATTRIBUTE(deferred_devs);
 

drivers/base/dd.c static int deferred_devs_show(struct seq_file *s, void *data) · line 266

Quoted 10 lines
drivers/base/dd.c +2 -4
 #ifdef CONFIG_MODULES
-int driver_deferred_probe_timeout = 10;
+static int driver_deferred_probe_timeout = 10;
 #else
-int driver_deferred_probe_timeout;
+static int driver_deferred_probe_timeout;
 #endif
 
-EXPORT_SYMBOL_GPL(driver_deferred_probe_timeout);
-

Yeah, I added the EXPORT for the regulator code to use it in dca0b44957e5 but that got backed out when setting driver_deferred_probe_timeout to 30s was reverted, and this bit was forgotten.

Thanks for catching this!

#4 lore raw

Re: [PATCH v2 1/4] driver core: Make driver_deferred_probe_timeout a static variable

Hello Greg,

Quoted 38 lines · John Stultz
Quoted 20 lines · Javier Martinez Canillas

It is not used outside of its compilation unit, so there's no need to export this variable.

---

(no changes since v1)

 drivers/base/dd.c             | 6 ++----
 include/linux/device/driver.h | 1 -
 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/base/dd.c +0 -0
index 3dda62503102..040b4060f903 100644
@@ -257,13 +257,11 @@ static int deferred_devs_show(struct seq_file *s, void *data)
 DEFINE_SHOW_ATTRIBUTE(deferred_devs);
 

drivers/base/dd.c static int deferred_devs_show(struct seq_file *s, void *data) · line 266

Quoted 10 lines
drivers/base/dd.c +2 -4
 #ifdef CONFIG_MODULES
-int driver_deferred_probe_timeout = 10;
+static int driver_deferred_probe_timeout = 10;
 #else
-int driver_deferred_probe_timeout;
+static int driver_deferred_probe_timeout;
 #endif
 
-EXPORT_SYMBOL_GPL(driver_deferred_probe_timeout);
-

Yeah, I added the EXPORT for the regulator code to use it in dca0b44957e5 but that got backed out when setting driver_deferred_probe_timeout to 30s was reverted, and this bit was forgotten.

Quoted 4 lines

Thanks for catching this!

Could you please pick this patch? Is a fix independent of the other patches in the series and it has already been acked by John.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#5 lore raw

Re: [PATCH v2 1/4] driver core: Make driver_deferred_probe_timeout a static variable

Quoted 41 lines · Javier Martinez Canillas

Hello Greg,

Quoted 38 lines · John Stultz
Quoted 20 lines · Javier Martinez Canillas

It is not used outside of its compilation unit, so there's no need to export this variable.

---

(no changes since v1)

 drivers/base/dd.c             | 6 ++----
 include/linux/device/driver.h | 1 -
 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/base/dd.c +0 -0
index 3dda62503102..040b4060f903 100644
@@ -257,13 +257,11 @@ static int deferred_devs_show(struct seq_file *s, void *data)
 DEFINE_SHOW_ATTRIBUTE(deferred_devs);
 

drivers/base/dd.c static int deferred_devs_show(struct seq_file *s, void *data) · line 266

Quoted 10 lines
drivers/base/dd.c +2 -4
 #ifdef CONFIG_MODULES
-int driver_deferred_probe_timeout = 10;
+static int driver_deferred_probe_timeout = 10;
 #else
-int driver_deferred_probe_timeout;
+static int driver_deferred_probe_timeout;
 #endif
 
-EXPORT_SYMBOL_GPL(driver_deferred_probe_timeout);
-

Yeah, I added the EXPORT for the regulator code to use it in dca0b44957e5 but that got backed out when setting driver_deferred_probe_timeout to 30s was reverted, and this bit was forgotten.

Quoted 7 lines
Quoted 4 lines

Thanks for catching this!

Could you please pick this patch? Is a fix independent of the other patches in the series and it has already been acked by John.

It is the middle of the merge window and I can't take anything now until after 6.2-rc1 is out. I also really can't take individual patches out of a patch series easily, so please just resend it as a single patch when 6.2-rc1 is out.

thanks,

greg k-h

#6 lore raw

Re: [PATCH v2 1/4] driver core: Make driver_deferred_probe_timeout a static variable

Quoted 1 line · Greg Kroah-Hartman

On Mon, Dec 12, 2022 at 09:50:16AM +0100, Javier Martinez Canillas wrote:

[...]

Quoted 8 lines
Quoted 2 lines

Could you please pick this patch? Is a fix independent of the other patches in the series and it has already been acked by John.

It is the middle of the merge window and I can't take anything now until after 6.2-rc1 is out. I also really can't take individual patches out of a patch series easily, so please just resend it as a single patch when 6.2-rc1 is out.

Sure, I will. Thanks!

Quoted 4 lines

thanks,

greg k-h

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#7 lore raw

PATCH v2 2/4 driver core: Set deferred probe timeout to 0 if modules are disabled

In reply to Javier Martinez Canillas

There is no point to schedule the work queue to timeout the deferred probe if all the initcalls are done and modules are not enabled. The default for this case is already 0 but can be overridden by the deferred_probe_timeout parameter. Let's just disable to avoid queuing a work that is not needed.

---

(no changes since v1)

 drivers/base/dd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/base/dd.c +3 -1
index 040b4060f903..1e8f1afeac98 100644
@@ -350,8 +350,10 @@ static int deferred_probe_initcall(void)
 	flush_work(&deferred_probe_work);
 	initcalls_done = true;
 
-	if (!IS_ENABLED(CONFIG_MODULES))
+	if (!IS_ENABLED(CONFIG_MODULES)) {
+		driver_deferred_probe_timeout = 0;
 		fw_devlink_drivers_done();
+	}
 
 	/*
 	 * Trigger deferred probe again, this time we won't defer anything
Signature · 1 line
2.38.1
#8 lore raw

Re: [PATCH v2 2/4] driver core: Set deferred probe timeout to 0 if modules are disabled

Quoted 18 lines · Javier Martinez Canillas

There is no point to schedule the work queue to timeout the deferred probe if all the initcalls are done and modules are not enabled. The default for this case is already 0 but can be overridden by the deferred_probe_timeout parameter. Let's just disable to avoid queuing a work that is not needed.

---

(no changes since v1)

 drivers/base/dd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/base/dd.c +0 -0
index 040b4060f903..1e8f1afeac98 100644

drivers/base/dd.c static int deferred_probe_initcall(void) · line 357

Quoted 9 lines
drivers/base/dd.c +3 -1
@@ -350,8 +350,10 @@ static int deferred_probe_initcall(void)
 	flush_work(&deferred_probe_work);
 	initcalls_done = true;
 
-	if (!IS_ENABLED(CONFIG_MODULES))
+	if (!IS_ENABLED(CONFIG_MODULES)) {
+		driver_deferred_probe_timeout = 0;
 		fw_devlink_drivers_done();
+	}
 

Potentially a stupid suggestion, but would it make sense to take out the ability to actually set that param if !CONFIG_MODULES? Then driver_deferred_probe_timeout would be the default value already.

Quoted 5 lines
drivers/base/dd.c +0 -0
 	/*
 	 * Trigger deferred probe again, this time we won't defer anything
Signature · 1 line
2.38.1
#9 lore raw

Re: [PATCH v2 2/4] driver core: Set deferred probe timeout to 0 if modules are disabled

Hello Andrew,

Thanks for your feedback.

Quoted 22 lines · Andrew Halaney
Quoted 21 lines · Javier Martinez Canillas

There is no point to schedule the work queue to timeout the deferred probe if all the initcalls are done and modules are not enabled. The default for this case is already 0 but can be overridden by the deferred_probe_timeout parameter. Let's just disable to avoid queuing a work that is not needed.

---

(no changes since v1)

 drivers/base/dd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/base/dd.c +0 -0
index 040b4060f903..1e8f1afeac98 100644
@@ -350,8 +350,10 @@ static int deferred_probe_initcall(void)
 	flush_work(&deferred_probe_work);
 	initcalls_done = true;
 
Quoted 11 lines

drivers/base/dd.c static int deferred_probe_initcall(void) · line 357

Quoted 6 lines
drivers/base/dd.c +3 -1
-	if (!IS_ENABLED(CONFIG_MODULES))
+	if (!IS_ENABLED(CONFIG_MODULES)) {
+		driver_deferred_probe_timeout = 0;
 		fw_devlink_drivers_done();
+	}
 

Potentially a stupid suggestion, but would it make sense to take out the ability to actually set that param if !CONFIG_MODULES? Then driver_deferred_probe_timeout would be the default value already.

Yes, I think it makes sense. I will do that in the next iteration.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#10 lore raw

PATCH v2 3/4 driver core: Add fw_devlink.timeout param to stop waiting for devlinks

In reply to Javier Martinez Canillas

Currently, the probe deferral timeout does two things:

1) Call to fw_devlink_drivers_done() to relax the device dependencies and allow drivers to be probed if these dependencies are optional.

2) Disable the probe deferral mechanism so that drivers will fail to probe if the required dependencies are not present, instead of adding them to the deferred probe pending list.

But there is no need to couple these two, for example the probe deferral can be used even when the device links are disable (i.e: fw_devlink=off).

So let's add a separate fw_devlink.timeout command line parameter to allow relaxing the device links and prevent drivers to wait for these to probe.

---

(no changes since v1)

 .../admin-guide/kernel-parameters.txt         |  7 ++++
 drivers/base/dd.c                             | 38 ++++++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +7 -0
index a465d5242774..38138a44d5ed 100644
@@ -1581,6 +1581,13 @@
 			dependencies. This only applies for fw_devlink=on|rpm.
 			Format: <bool>
 
+	fw_devlink.timeout=
+			[KNL] Debugging option to set a timeout in seconds for
+			drivers to give up waiting on dependencies and to probe
+			these are optional. 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.
+
 	gamecon.map[2|3]=
 			[HW,JOY] Multisystem joystick and NES/SNES/PSX pad
 			support via parallel port (up to 5 devices per port)
drivers/base/dd.c +37 -1
index 1e8f1afeac98..ea448df94d24 100644
@@ -261,6 +261,7 @@ static int driver_deferred_probe_timeout = 10;
 #else
 static int driver_deferred_probe_timeout;
 #endif
+static int fw_devlink_timeout = -1;
 
 static int __init deferred_probe_timeout_setup(char *str)
 {
@@ -272,6 +273,16 @@ static int __init deferred_probe_timeout_setup(char *str)
 }
 __setup("deferred_probe_timeout=", deferred_probe_timeout_setup);
 
+static int __init fw_devlink_timeout_setup(char *str)
+{
+	int timeout;
+
+	if (!kstrtoint(str, 10, &timeout))
+		fw_devlink_timeout = timeout;
+	return 1;
+}
+__setup("fw_devlink.timeout=", fw_devlink_timeout_setup);
+
 /**
  * driver_deferred_probe_check_state() - Check deferred probe state
  * @dev: device to check
@@ -318,6 +329,15 @@ static void deferred_probe_timeout_work_func(struct work_struct *work)
 }
 static DECLARE_DELAYED_WORK(deferred_probe_timeout_work, deferred_probe_timeout_work_func);
 
+static void fw_devlink_timeout_work_func(struct work_struct *work)
+{
+	fw_devlink_drivers_done();
+
+	driver_deferred_probe_trigger();
+	flush_work(&deferred_probe_work);
+}
+static DECLARE_DELAYED_WORK(fw_devlink_timeout_work, fw_devlink_timeout_work_func);
+
 void deferred_probe_extend_timeout(void)
 {
 	/*
@@ -330,6 +350,13 @@ void deferred_probe_extend_timeout(void)
 		pr_debug("Extended deferred probe timeout by %d secs\n",
 					driver_deferred_probe_timeout);
 	}
+
+	if (cancel_delayed_work(&fw_devlink_timeout_work)) {
+		schedule_delayed_work(&fw_devlink_timeout_work,
+				      fw_devlink_timeout * HZ);
+		pr_debug("Extended fw_devlink timeout by %d secs\n",
+			 fw_devlink_timeout);
+	}
 }
 
 /**
@@ -352,9 +379,12 @@ static int deferred_probe_initcall(void)
 
 	if (!IS_ENABLED(CONFIG_MODULES)) {
 		driver_deferred_probe_timeout = 0;
-		fw_devlink_drivers_done();
+		fw_devlink_timeout = 0;
 	}
 
+	if (!fw_devlink_timeout)
+		fw_devlink_drivers_done();
+
 	/*
 	 * Trigger deferred probe again, this time we won't defer anything
 	 * that is optional
@@ -366,6 +396,12 @@ static int deferred_probe_initcall(void)
 		schedule_delayed_work(&deferred_probe_timeout_work,
 			driver_deferred_probe_timeout * HZ);
 	}
+
+	if (fw_devlink_timeout > 0) {
+		schedule_delayed_work(&fw_devlink_timeout_work,
+				      fw_devlink_timeout * HZ);
+	}
+
 	return 0;
 }
 late_initcall(deferred_probe_initcall);
Signature · 1 line
2.38.1
reviewer
#11 lore raw

Re: [PATCH v2 3/4] driver core: Add fw_devlink.timeout param to stop waiting for devlinks

Hi--

Documentation/admin-guide/kernel-parameters.txt line 1588

Quoted 13 lines · Javier Martinez Canillas
Documentation/admin-guide/kernel-parameters.txt +5 -0
index a465d5242774..38138a44d5ed 100644
@@ -1581,6 +1581,13 @@
 			dependencies. This only applies for fw_devlink=on|rpm.
 			Format: <bool>
 
+	fw_devlink.timeout=
+			[KNL] Debugging option to set a timeout in seconds for
+			drivers to give up waiting on dependencies and to probe
+			these are optional. A timeout of 0 will timeout at the
+			end of initcalls. If the time out hasn't expired, it'll

timeout

Quoted 1 line
Documentation/admin-guide/kernel-parameters.txt +1 -0
+			be restarted by each successful driver registration.
Signature · 1 line
~Randy
Acked-by on v2 3/4
#12 lore raw

Re: [PATCH v2 3/4] driver core: Add fw_devlink.timeout param to stop waiting for devlinks

In reply to Javier Martinez Canillas
Quoted 9 lines · Javier Martinez Canillas

Currently, the probe deferral timeout does two things:

1) Call to fw_devlink_drivers_done() to relax the device dependencies and allow drivers to be probed if these dependencies are optional.

2) Disable the probe deferral mechanism so that drivers will fail to probe if the required dependencies are not present, instead of adding them to the deferred probe pending list.

Quoted 7 lines

But there is no need to couple these two, for example the probe deferral can be used even when the device links are disable (i.e: fw_devlink=off).

So let's add a separate fw_devlink.timeout command line parameter to allow relaxing the device links and prevent drivers to wait for these to probe.

I like this idea and it looks good as far as I can tell.

Quoted 115 lines

---

(no changes since v1)

 .../admin-guide/kernel-parameters.txt         |  7 ++++
 drivers/base/dd.c                             | 38 ++++++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +7 -0
index a465d5242774..38138a44d5ed 100644
@@ -1581,6 +1581,13 @@
 			dependencies. This only applies for fw_devlink=on|rpm.
 			Format: <bool>
 
+	fw_devlink.timeout=
+			[KNL] Debugging option to set a timeout in seconds for
+			drivers to give up waiting on dependencies and to probe
+			these are optional. 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.
+
 	gamecon.map[2|3]=
 			[HW,JOY] Multisystem joystick and NES/SNES/PSX pad
 			support via parallel port (up to 5 devices per port)
drivers/base/dd.c +37 -1
index 1e8f1afeac98..ea448df94d24 100644
@@ -261,6 +261,7 @@ static int driver_deferred_probe_timeout = 10;
 #else
 static int driver_deferred_probe_timeout;
 #endif
+static int fw_devlink_timeout = -1;
 
 static int __init deferred_probe_timeout_setup(char *str)
 {
@@ -272,6 +273,16 @@ static int __init deferred_probe_timeout_setup(char *str)
 }
 __setup("deferred_probe_timeout=", deferred_probe_timeout_setup);
 
+static int __init fw_devlink_timeout_setup(char *str)
+{
+	int timeout;
+
+	if (!kstrtoint(str, 10, &timeout))
+		fw_devlink_timeout = timeout;
+	return 1;
+}
+__setup("fw_devlink.timeout=", fw_devlink_timeout_setup);
+
 /**
  * driver_deferred_probe_check_state() - Check deferred probe state
  * @dev: device to check
@@ -318,6 +329,15 @@ static void deferred_probe_timeout_work_func(struct work_struct *work)
 }
 static DECLARE_DELAYED_WORK(deferred_probe_timeout_work, deferred_probe_timeout_work_func);
 
+static void fw_devlink_timeout_work_func(struct work_struct *work)
+{
+	fw_devlink_drivers_done();
+
+	driver_deferred_probe_trigger();
+	flush_work(&deferred_probe_work);
+}
+static DECLARE_DELAYED_WORK(fw_devlink_timeout_work, fw_devlink_timeout_work_func);
+
 void deferred_probe_extend_timeout(void)
 {
 	/*
@@ -330,6 +350,13 @@ void deferred_probe_extend_timeout(void)
 		pr_debug("Extended deferred probe timeout by %d secs\n",
 					driver_deferred_probe_timeout);
 	}
+
+	if (cancel_delayed_work(&fw_devlink_timeout_work)) {
+		schedule_delayed_work(&fw_devlink_timeout_work,
+				      fw_devlink_timeout * HZ);
+		pr_debug("Extended fw_devlink timeout by %d secs\n",
+			 fw_devlink_timeout);
+	}
 }
 
 /**
@@ -352,9 +379,12 @@ static int deferred_probe_initcall(void)
 
 	if (!IS_ENABLED(CONFIG_MODULES)) {
 		driver_deferred_probe_timeout = 0;
-		fw_devlink_drivers_done();
+		fw_devlink_timeout = 0;
 	}
 
+	if (!fw_devlink_timeout)
+		fw_devlink_drivers_done();
+
 	/*
 	 * Trigger deferred probe again, this time we won't defer anything
 	 * that is optional
@@ -366,6 +396,12 @@ static int deferred_probe_initcall(void)
 		schedule_delayed_work(&deferred_probe_timeout_work,
 			driver_deferred_probe_timeout * HZ);
 	}
+
+	if (fw_devlink_timeout > 0) {
+		schedule_delayed_work(&fw_devlink_timeout_work,
+				      fw_devlink_timeout * HZ);
+	}
+
 	return 0;
 }
 late_initcall(deferred_probe_initcall);
Signature · 1 line
2.38.1
#13 lore raw

Re: [PATCH v2 3/4] driver core: Add fw_devlink.timeout param to stop waiting for devlinks

In reply to Javier Martinez Canillas
Quoted 29 lines · Javier Martinez Canillas

Currently, the probe deferral timeout does two things:

1) Call to fw_devlink_drivers_done() to relax the device dependencies and allow drivers to be probed if these dependencies are optional.

2) Disable the probe deferral mechanism so that drivers will fail to probe if the required dependencies are not present, instead of adding them to the deferred probe pending list.

But there is no need to couple these two, for example the probe deferral can be used even when the device links are disable (i.e: fw_devlink=off).

So let's add a separate fw_devlink.timeout command line parameter to allow relaxing the device links and prevent drivers to wait for these to probe.

---

(no changes since v1)

 .../admin-guide/kernel-parameters.txt         |  7 ++++
 drivers/base/dd.c                             | 38 ++++++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +0 -0
index a465d5242774..38138a44d5ed 100644

Documentation/admin-guide/kernel-parameters.txt line 1584

Quoted 4 lines
Documentation/admin-guide/kernel-parameters.txt +1 -0
@@ -1581,6 +1581,13 @@
 			dependencies. This only applies for fw_devlink=on|rpm.
 			Format: <bool>
 
+	fw_devlink.timeout=

Just thought about this, but I think this should be called fw_devlink_timeout. Generally the $MODULE.$PARAM syntax is reserved for things that can be specificed with module_param().

The advantage is if you accidentally type say fw_devlink_timeut=10 the kernel logs will indicate it has no clue what that means. Including the "." makes the kernel assume that maybe a future module name fw_devlink will be loaded, and at that time will see if that module has the parameter mentioned. A little thing but I think work changing in v3.

Thanks,
Andrew

#14 lore raw

Re: [PATCH v2 3/4] driver core: Add fw_devlink.timeout param to stop waiting for devlinks

Hello Andrew,

Quoted 39 lines · Andrew Halaney
Quoted 29 lines · Javier Martinez Canillas

Currently, the probe deferral timeout does two things:

1) Call to fw_devlink_drivers_done() to relax the device dependencies and allow drivers to be probed if these dependencies are optional.

2) Disable the probe deferral mechanism so that drivers will fail to probe if the required dependencies are not present, instead of adding them to the deferred probe pending list.

But there is no need to couple these two, for example the probe deferral can be used even when the device links are disable (i.e: fw_devlink=off).

So let's add a separate fw_devlink.timeout command line parameter to allow relaxing the device links and prevent drivers to wait for these to probe.

---

(no changes since v1)

 .../admin-guide/kernel-parameters.txt         |  7 ++++
 drivers/base/dd.c                             | 38 ++++++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletion(-)
Documentation/admin-guide/kernel-parameters.txt +0 -0
index a465d5242774..38138a44d5ed 100644

Documentation/admin-guide/kernel-parameters.txt line 1584

Quoted 4 lines
Documentation/admin-guide/kernel-parameters.txt +1 -0
@@ -1581,6 +1581,13 @@
 			dependencies. This only applies for fw_devlink=on|rpm.
 			Format: <bool>
 
+	fw_devlink.timeout=

Just thought about this, but I think this should be called fw_devlink_timeout. Generally the $MODULE.$PARAM syntax is reserved for things that can be specificed with module_param().

Quoted 6 lines

The advantage is if you accidentally type say fw_devlink_timeut=10 the kernel logs will indicate it has no clue what that means. Including the "." makes the kernel assume that maybe a future module name fw_devlink will be loaded, and at that time will see if that module has the parameter mentioned. A little thing but I think work changing in v3.

I was actually on the fence on this one but the reason why I did the .timeout was that the other fw_devlink param [0] is defined as fw_devlink.strict=<bool> so I wanted to keep this one consistent with that.

https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#15 lore raw

Re: [PATCH v2 3/4] driver core: Add fw_devlink.timeout param to stop waiting for devlinks

In reply to Javier Martinez Canillas
Quoted 10 lines · Javier Martinez Canillas

Currently, the probe deferral timeout does two things:

1) Call to fw_devlink_drivers_done() to relax the device dependencies and allow drivers to be probed if these dependencies are optional.

2) Disable the probe deferral mechanism so that drivers will fail to probe if the required dependencies are not present, instead of adding them to the deferred probe pending list.

Quoted 5 lines

But there is no need to couple these two, for example the probe deferral can be used even when the device links are disable (i.e: fw_devlink=off).

So let's add a separate fw_devlink.timeout command line parameter to allow relaxing the device links and prevent drivers to wait for these to probe.

I'm probably being dim, but it's not immediately clear from this description *why* this is useful. Maybe add some words on the tangible benefit of splitting this up?

I'd also push a little bit back on why we need to split this into a separate boot option. Since it's not obvious as to when a user would want to use fw_devlink.timeout vs probe_deferral_timeout. The extra complexity of remembering which timeout is for what might become a burden to users and developers.

Documentation/admin-guide/kernel-parameters.txt line 1590

Quoted 8 lines
Documentation/admin-guide/kernel-parameters.txt +7 -0
+       fw_devlink.timeout=
+                       [KNL] Debugging option to set a timeout in seconds for
+                       drivers to give up waiting on dependencies and to probe
+                       these are optional. 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 sounds pretty close to like the deferred_probe_timeout option. I'd suggest some words to make the distinction more clear.

thanks
-john

#16 lore raw

Re: [PATCH v2 3/4] driver core: Add fw_devlink.timeout param to stop waiting for devlinks

Hello John,

Quoted 15 lines · John Stultz
Quoted 13 lines · Javier Martinez Canillas

Currently, the probe deferral timeout does two things:

1) Call to fw_devlink_drivers_done() to relax the device dependencies and allow drivers to be probed if these dependencies are optional.

2) Disable the probe deferral mechanism so that drivers will fail to probe if the required dependencies are not present, instead of adding them to the deferred probe pending list.

But there is no need to couple these two, for example the probe deferral can be used even when the device links are disable (i.e: fw_devlink=off).

Quoted 7 lines
Quoted 2 lines

So let's add a separate fw_devlink.timeout command line parameter to allow relaxing the device links and prevent drivers to wait for these to probe.

I'm probably being dim, but it's not immediately clear from this description *why* this is useful. Maybe add some words on the tangible benefit of splitting this up?

Thanks for your feedback. You are right that I need to better explain the why / goal of this patch. But basically is that it would be good to allow timeout waiting for the optional links while still allow the non-optional links to keep make the drivers to keep deferring.

I can make a better job at explaining the why in the next iteration.

Quoted 15 lines

I'd also push a little bit back on why we need to split this into a separate boot option. Since it's not obvious as to when a user would want to use fw_devlink.timeout vs probe_deferral_timeout. The extra complexity of remembering which timeout is for what might become a burden to users and developers.

Documentation/admin-guide/kernel-parameters.txt line 1590

Quoted 8 lines
Documentation/admin-guide/kernel-parameters.txt +7 -0
+       fw_devlink.timeout=
+                       [KNL] Debugging option to set a timeout in seconds for
+                       drivers to give up waiting on dependencies and to probe
+                       these are optional. 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.
+
Quoted 3 lines

This sounds pretty close to like the deferred_probe_timeout option. I'd suggest some words to make the distinction more clear.

Yeah, I can think how to better explain this... but it's similar because there is some overlapping between the two really, but are not exactly the same even though we are tying the two and folding the disable of the two under the same timeout.

I'll be OK to drop this parameter btw, and just keep it as an internal var if it's fine to just always use the default 10 seconds or whatever timeout it is decided.

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
#17 lore raw

PATCH v2 4/4 driver core: Disable driver deferred probe timeout by default

In reply to Javier Martinez Canillas

The driver_deferred_probe_timeout value has a long history. It was first set to -1 when was introduced by commit 25b4e70dcce9 ("driver core: allow stopping deferred probe after init"), meaning that the driver core would defer the probe forever unless a subsystem would opt-in by checking if the initcalls where done using the driver_deferred_probe_check_state() helper, or if a timeout was explicitly set with a "deferred_probe_timeout" param.

Only the power domain, IOMMU and MDIO subsystems currently opt-in to check if the initcalls have completed with driver_deferred_probe_check_state().

Commit c8c43cee29f6 ("driver core: Fix driver_deferred_probe_check_state() logic") then changed the driver_deferred_probe_check_state() helper logic, to take into account whether modules have been enabled or not and also to return -EPROBE_DEFER if the probe deferred timeout work was still running.

Then in commit e2cec7d68537 ("driver core: Set deferred_probe_timeout to a longer default if CONFIG_MODULES is set"), the timeout was increased to 30 seconds if modules are enabled. Because seems that some of the subsystems that were opt-in to not return -EPROBE_DEFER after the initcall where done could still have dependencies whose drivers were built as a module.

This commit did a fundamental change to how probe deferral worked though, since now the default was not to attempt probing for drivers indefinitely but instead to timeout after 30 seconds, unless a different timeout is set using the "deferred_probe_timeout" command line parameter.

The behavior was changed even more with commit ce68929f07de ("driver core:
Revert default driver_deferred_probe_timeout value to 0"), since the value was set to 0 by default. Meaning that the probe deferral would be disabled after the initcalls where done. Unless a timeout was set in the cmdline.

Notice that the commit said that it was reverting the default value to 0, but this was never 0. The default was -1 at the beginning and then changed to 30 in a later commit.

This default value of 0 was reverted again by commit f516d01b9df2 ("Revert "driver core: Set default deferred_probe_timeout back to 0."") and set to 10 seconds instead. Which was still less than the 30 seconds that was set at some point, to allow systems with drivers built as modules and loaded later by user-land to probe drivers that were still in the deferred list.

The 10 seconds timeout isn't enough in some cases, for example the Fedora kernel builds as much drivers as possible as modules. And this leads to an Snapdragon SC7180 based HP X2 Chromebook to not have display, due the DRM driver failing to probe if CONFIG_ARM_SMMU=y and CONFIG_SC_GPUCC_7180=m.

So let's change the default again to -1 as it was at the beginning. That's how probe deferral always worked. The kernel should try to avoid guessing when it should be safe to give up on deferred drivers to be probed.

The reason why the default "deferred_probe_timeout" was changed from -1 to the other values was to allow drivers that have only optional dependencies to probe even if the suppliers are not available.

But now there is a "fw_devlink.timeout" parameter to timeout the links and allow drivers to probe even when the dependencies are not present. Let's set the default for that timeout to 10 seconds, to give the same behaviour as expected by these driver with optional device links.

---

Changes in v2:
- Mention in the commit messsage the specific machine and drivers that are affected by the issue (Greg).
- Double check the commit message for accuracy (John).
- Add a second workqueue to timeout the devlink enforcing and allow drivers to probe even without their optional dependencies available.

 drivers/base/dd.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/base/dd.c +2 -6
index ea448df94d24..5f18cd497850 100644
@@ -256,12 +256,8 @@ 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 fw_devlink_timeout = -1;
+static int driver_deferred_probe_timeout = -1;
+static int fw_devlink_timeout = 10;
 
 static int __init deferred_probe_timeout_setup(char *str)
 {
Signature · 1 line
2.38.1
Acked-by on v2 4/4
#18 lore raw

Re: [PATCH v2 4/4] driver core: Disable driver deferred probe timeout by default

Quoted 6 lines · Javier Martinez Canillas

The driver_deferred_probe_timeout value has a long history. It was first set to -1 when was introduced by commit 25b4e70dcce9 ("driver core: allow stopping deferred probe after init"), meaning that the driver core would defer the probe forever unless a subsystem would opt-in by checking if the initcalls where done using the driver_deferred_probe_check_state() helper, or if a timeout was explicitly set with a "deferred_probe_timeout" param.

This or statement here sounds like you either opt-in, or the timeout affects you (at least that's how I read it).

A subsystem has to opt-in to get either result by using driver_deferred_probe_check_state()!

Quoted 9 lines

Only the power domain, IOMMU and MDIO subsystems currently opt-in to check if the initcalls have completed with driver_deferred_probe_check_state().

Commit c8c43cee29f6 ("driver core: Fix driver_deferred_probe_check_state() logic") then changed the driver_deferred_probe_check_state() helper logic, to take into account whether modules have been enabled or not and also to return -EPROBE_DEFER if the probe deferred timeout work was still running.

Quoted 4 lines

Then in commit e2cec7d68537 ("driver core: Set deferred_probe_timeout to a longer default if CONFIG_MODULES is set"), the timeout was increased to 30 seconds if modules are enabled. Because seems that some of the subsystems that were opt-in to not return -EPROBE_DEFER after the initcall where done

s/where/were/

Quoted 35 lines

could still have dependencies whose drivers were built as a module.

This commit did a fundamental change to how probe deferral worked though, since now the default was not to attempt probing for drivers indefinitely but instead to timeout after 30 seconds, unless a different timeout is set using the "deferred_probe_timeout" command line parameter.

The behavior was changed even more with commit ce68929f07de ("driver core:
Revert default driver_deferred_probe_timeout value to 0"), since the value was set to 0 by default. Meaning that the probe deferral would be disabled after the initcalls where done. Unless a timeout was set in the cmdline.

Notice that the commit said that it was reverting the default value to 0, but this was never 0. The default was -1 at the beginning and then changed to 30 in a later commit.

This default value of 0 was reverted again by commit f516d01b9df2 ("Revert "driver core: Set default deferred_probe_timeout back to 0."") and set to 10 seconds instead. Which was still less than the 30 seconds that was set at some point, to allow systems with drivers built as modules and loaded later by user-land to probe drivers that were still in the deferred list.

The 10 seconds timeout isn't enough in some cases, for example the Fedora kernel builds as much drivers as possible as modules. And this leads to an Snapdragon SC7180 based HP X2 Chromebook to not have display, due the DRM driver failing to probe if CONFIG_ARM_SMMU=y and CONFIG_SC_GPUCC_7180=m.

So let's change the default again to -1 as it was at the beginning. That's how probe deferral always worked. The kernel should try to avoid guessing when it should be safe to give up on deferred drivers to be probed.

The reason why the default "deferred_probe_timeout" was changed from -1 to the other values was to allow drivers that have only optional dependencies to probe even if the suppliers are not available.

Quoted 6 lines

But now there is a "fw_devlink.timeout" parameter to timeout the links and allow drivers to probe even when the dependencies are not present. Let's set the default for that timeout to 10 seconds, to give the same behaviour as expected by these driver with optional device links.

This sounds like a reasonable solution to me:

Quoted 34 lines

---

Changes in v2:
- Mention in the commit messsage the specific machine and drivers that are affected by the issue (Greg).
- Double check the commit message for accuracy (John).
- Add a second workqueue to timeout the devlink enforcing and allow drivers to probe even without their optional dependencies available.

 drivers/base/dd.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/base/dd.c +2 -6
index ea448df94d24..5f18cd497850 100644
@@ -256,12 +256,8 @@ 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 fw_devlink_timeout = -1;
+static int driver_deferred_probe_timeout = -1;
+static int fw_devlink_timeout = 10;
 
 static int __init deferred_probe_timeout_setup(char *str)
 {
Signature · 1 line
2.38.1