Fix deferred_probe_timeout and fw_devlink=on
Subsystems (2)
cover Fix deferred_probe_timeout and fw_devlink=on
This series fixes existing bugs in deferred_probe_timeout and fixes some interaction with fw_devlink=on.
Saravana Kannan (2):
driver core: Fix locking bug in deferred_probe_timeout_work_func() driver core: Improve fw_devlink & deferred_probe_timeout interaction
drivers/base/base.h | 1 + drivers/base/core.c | 64 ++++++++++++++++++++++++++++++++++++++++----- drivers/base/dd.c | 13 ++++++--- 3 files changed, 68 insertions(+), 10 deletions(-)
Signature · 1 line
2.31.0.208.g409f899ff0-goog
PATCH 1/2 driver core: Fix locking bug in deferred_probe_timeout_work_func()
list_for_each_entry_safe() is only useful if we are deleting nodes in a linked list within the loop. It doesn't protect against other threads adding/deleting nodes to the list in parallel. We need to grab deferred_probe_mutex when traversing the deferred_probe_pending_list.
--- drivers/base/dd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/base/dd.c +5 -3
@@ -291,14 +291,16 @@ int driver_deferred_probe_check_state(struct device *dev)static void deferred_probe_timeout_work_func (struct work_struct *work) { -struct device_private *private, *p; +struct device_private *p; driver_deferred_probe_timeout =0 ;driver_deferred_probe_trigger ();flush_work (&deferred_probe_work); -list_for_each_entry_safe (private, p, &deferred_probe_pending_list, deferred_probe) -dev_info (private->device,"deferred probe pending\n" ); +mutex_lock (&deferred_probe_mutex); +list_for_each_entry (p, &deferred_probe_pending_list, deferred_probe) +dev_info (p->device,"deferred probe pending\n" ); +mutex_unlock (&deferred_probe_mutex);wake_up_all (&probe_timeout_waitqueue); } static DECLARE_DELAYED_WORK(deferred_probe_timeout_work, deferred_probe_timeout_work_func);
Signature · 1 line
2.31.0.208.g409f899ff0-goog
PATCH 2/2 driver core: Improve fw_devlink & deferred_probe_timeout interaction
In reply to Saravana Kannandeferred_probe_timeout kernel commandline parameter allows probing of consumer devices if the supplier devices don't have any drivers.
fw_devlink=on will indefintely block probe() calls on a device if all its suppliers haven't probed successfully. This completely skips calls to driver_deferred_probe_check_state() since that's only called when a .probe() function calls framework APIs. So fw_devlink=on breaks deferred_probe_timeout.
deferred_probe_timeout in its current state also ignores a lot of information that's now available to the kernel. It assumes all suppliers that haven't probed when the timer expires (or when initcalls are done on a static kernel) will never probe and fails any calls to acquire resources from these unprobed suppliers.
However, this assumption by deferred_probe_timeout isn't true under many conditions. For example:
- If the consumer happens to be before the supplier in the deferred probe list.
- If the supplier itself is waiting on its supplier to probe.
This patch fixes both these issues by relaxing device links between devices only if the supplier doesn't have any driver that could match with (NOT bound to) the supplier device. This way, we only fail attempts to acquire resources from suppliers that truly don't have any driver vs suppliers that just happen to not have probed yet.
--- drivers/base/base.h | 1 + drivers/base/core.c | 64 ++++++++++++++++++++++++++++++++++++++++----- drivers/base/dd.c | 5 ++++ 3 files changed, 63 insertions(+), 7 deletions(-)
drivers/base/base.h +1 -0
@@ -191,6 +191,7 @@ extern void device_links_driver_cleanup(struct device *dev);extern void device_links_no_driver (struct device *dev);extern bool device_links_busy (struct device *dev);extern void device_links_unbind_consumers (struct device *dev); +extern void fw_devlink_drivers_done (void );/* device pm support */ void device_pm_move_to_tail (struct device *dev);
drivers/base/core.c +57 -7
88 lines not on this page · raw message
drivers/base/dd.c +5 -0
@@ -293,6 +293,8 @@ static void deferred_probe_timeout_work_func(struct work_struct *work) {struct device_private *p; +fw_devlink_drivers_done (); + driver_deferred_probe_timeout =0 ;driver_deferred_probe_trigger ();flush_work (&deferred_probe_work);
@@ -323,6 +325,9 @@ static int deferred_probe_initcall(void)flush_work (&deferred_probe_work); initcalls_done = true; +if (!IS_ENABLED (CONFIG_MODULES )) +fw_devlink_drivers_done (); +/* * Trigger deferred probe again, this time we won't defer anything * that is optional
Signature · 1 line
2.31.0.208.g409f899ff0-goog