Skip to contentSkip to conversation

driver core: Fix missing jiffies conversion in deferred_probe_extend_timeout()

PATCH Applied Danilo Krummrich 3 participants 7 messages May 25 – May 26 Driver core

lore
Share & tools
lore

Danilo Krummrich

author maintainer
#0 lore raw

PATCH 1/2 driver core: Fix missing jiffies conversion in deferred_probe_extend_timeout()

mod_delayed_work() takes jiffies, not seconds. Thus, restore the dropped conversion.

While at it, fix incorrect indentation.

Fixes 1137838865bf ("driver core: Use mod_delayed_work to prevent lost deferred probe work")
---
 drivers/base/dd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/dd.c +1 -1
index 172a02a438a2..bebb43acc132 100644
@@ -324,7 +324,7 @@ void deferred_probe_extend_timeout(void)
 	 * start a new one.
 	 */
 	if (mod_delayed_work(system_wq, &deferred_probe_timeout_work,
-						 driver_deferred_probe_timeout))
+			     secs_to_jiffies(driver_deferred_probe_timeout)))
 		pr_debug("Extended deferred probe timeout by %d secs\n",
 					driver_deferred_probe_timeout);
 }

base-commit: 56785dcb2ef6d3cff82ac33f2e34db94377416a3

Signature · 1 line
2.54.0
author maintainer
#1 lore raw

PATCH 2/2 driver core: Guard deferred probe timeout extension with delayed_work_pending()

mod_delayed_work() unconditionally queues the work even when it wasn't previously pending, which can fire the timeout prematurely or restart it after it already fired. Add a delayed_work_pending() guard to restore the originally intended semantics.

Premature firing calls fw_devlink_drivers_done() before all built-in drivers have registered, causing fw_devlink to prematurely relax device links for suppliers whose drivers haven't loaded yet.

Fixes 1137838865bf ("driver core: Use mod_delayed_work to prevent lost deferred probe work")
---
 drivers/base/dd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/dd.c +2 -1
index bebb43acc132..905269ecef9b 100644
@@ -323,7 +323,8 @@ void deferred_probe_extend_timeout(void)
 	 * If the work hasn't been queued yet or if the work expired, don't
 	 * start a new one.
 	 */
-	if (mod_delayed_work(system_wq, &deferred_probe_timeout_work,
+	if (delayed_work_pending(&deferred_probe_timeout_work) &&
+	    mod_delayed_work(system_wq, &deferred_probe_timeout_work,
 			     secs_to_jiffies(driver_deferred_probe_timeout)))
 		pr_debug("Extended deferred probe timeout by %d secs\n",
 					driver_deferred_probe_timeout);
Signature · 1 line
2.54.0
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] driver core: Guard deferred probe timeout extension with delayed_work_pending()

Quoted 33 lines · Danilo Krummrich

mod_delayed_work() unconditionally queues the work even when it wasn't previously pending, which can fire the timeout prematurely or restart it after it already fired. Add a delayed_work_pending() guard to restore the originally intended semantics.

Premature firing calls fw_devlink_drivers_done() before all built-in drivers have registered, causing fw_devlink to prematurely relax device links for suppliers whose drivers haven't loaded yet.

Fixes 1137838865bf ("driver core: Use mod_delayed_work to prevent lost deferred probe work")
---
 drivers/base/dd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/dd.c +2 -1
index bebb43acc132..905269ecef9b 100644
@@ -323,7 +323,8 @@ void deferred_probe_extend_timeout(void)
 	 * If the work hasn't been queued yet or if the work expired, don't
 	 * start a new one.
 	 */
-	if (mod_delayed_work(system_wq, &deferred_probe_timeout_work,
+	if (delayed_work_pending(&deferred_probe_timeout_work) &&
+	    mod_delayed_work(system_wq, &deferred_probe_timeout_work,
 			     secs_to_jiffies(driver_deferred_probe_timeout)))
 		pr_debug("Extended deferred probe timeout by %d secs\n",
 					driver_deferred_probe_timeout);
Signature · 1 line
2.54.0
Tested-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] driver core: Guard deferred probe timeout extension with delayed_work_pending()

In reply to Danilo Krummrich

Hi Danilo,

Quoted 11 lines · Danilo Krummrich

mod_delayed_work() unconditionally queues the work even when it wasn't previously pending, which can fire the timeout prematurely or restart it after it already fired. Add a delayed_work_pending() guard to restore the originally intended semantics.

Premature firing calls fw_devlink_drivers_done() before all built-in drivers have registered, causing fw_devlink to prematurely relax device links for suppliers whose drivers haven't loaded yet.

Fixes 1137838865bf ("driver core: Use mod_delayed_work to prevent lost deferred probe work")

Thanks, with both patches from this series applied, I am no longer seeing the WARNING Biju reported[1], and thousands of "sync_state() pending due to" and hundreds of "deferred probe pending" messages.

[1] https://lore.kernel.org/[email protected]

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

maintainer Reviewed-by on v1 1/2
#4 lore raw
In reply to Danilo Krummrich
Quoted 25 lines · Danilo Krummrich

mod_delayed_work() takes jiffies, not seconds. Thus, restore the dropped conversion.

While at it, fix incorrect indentation.

Fixes 1137838865bf ("driver core: Use mod_delayed_work to prevent lost deferred probe work")
---
 drivers/base/dd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/dd.c +1 -1
index 172a02a438a2..bebb43acc132 100644
@@ -324,7 +324,7 @@ void deferred_probe_extend_timeout(void)
 	 * start a new one.
 	 */
 	if (mod_delayed_work(system_wq, &deferred_probe_timeout_work,
-						 driver_deferred_probe_timeout))
+			     secs_to_jiffies(driver_deferred_probe_timeout)))
 		pr_debug("Extended deferred probe timeout by %d secs\n",
 					driver_deferred_probe_timeout);
 }
Quoted 5 lines

base-commit: 56785dcb2ef6d3cff82ac33f2e34db94377416a3

Signature · 1 line
2.54.0
Tested-by on v1 1/2
#5 lore raw
In reply to Danilo Krummrich

Hi Danilo,

Quoted 7 lines · Danilo Krummrich

mod_delayed_work() takes jiffies, not seconds. Thus, restore the dropped conversion.

While at it, fix incorrect indentation.

Fixes 1137838865bf ("driver core: Use mod_delayed_work to prevent lost deferred probe work")

Thanks, with both patches from this series applied, I am no longer seeing the WARNING Biju reported[1], and thousands of "sync_state() pending due to" and hundreds of "deferred probe pending" messages.

[1] https://lore.kernel.org/[email protected]

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer Applied
#6 lore raw
In reply to Danilo Krummrich
Quoted 1 line · Danilo Krummrich

[PATCH 1/2] driver core: Fix missing jiffies conversion in deferred_probe_extend_timeout()

Applied, thanks!

Branch: driver-core-next
Tree: git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git

[1/2] driver core: Fix missing jiffies conversion in deferred_probe_extend_timeout()

      commit: f9e6da99fe49
[2/2] driver core: Guard deferred probe timeout extension with delayed_work_pending()
      commit: 557495bc8790

The patches will appear in the next linux-next integration (typically within 24 hours on weekdays).

The patches are queued up for the upcoming merge window for the next major kernel release.