Skip to content

Commit 2451e74

Browse files
Saravana Kannangregkh
authored andcommitted
driver core: Avoid deferred probe due to fw_devlink_pause/resume()
With the earlier patch in this series, all devices that deferred probe due to fw_devlink_pause() will have their probes delayed till the deferred probe thread is kicked off during late_initcall. This will also affect all their consumers. This delayed probing in unnecessary. So this patch just keeps track of the devices that had their probe deferred due to fw_devlink_pause() and attempts to probe them once during fw_devlink_resume(). Fixes: 716a7a2 ("driver core: fw_devlink: Add support for batching fwnode parsing") Signed-off-by: Saravana Kannan <[email protected]> Tested-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ec7bd78 commit 2451e74

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

drivers/base/core.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ static DEFINE_MUTEX(wfs_lock);
5050
static LIST_HEAD(deferred_sync);
5151
static unsigned int defer_sync_state_count = 1;
5252
static unsigned int defer_fw_devlink_count;
53+
static LIST_HEAD(deferred_fw_devlink);
5354
static DEFINE_MUTEX(defer_fw_devlink_lock);
5455
static bool fw_devlink_is_permissive(void);
5556

@@ -1244,6 +1245,12 @@ static void fw_devlink_link_device(struct device *dev)
12441245
fw_ret = -EAGAIN;
12451246
} else {
12461247
fw_ret = -ENODEV;
1248+
/*
1249+
* defer_hook is not used to add device to deferred_sync list
1250+
* until device is bound. Since deferred fw devlink also blocks
1251+
* probing, same list hook can be used for deferred_fw_devlink.
1252+
*/
1253+
list_add_tail(&dev->links.defer_hook, &deferred_fw_devlink);
12471254
}
12481255

12491256
if (fw_ret == -ENODEV)
@@ -1312,6 +1319,9 @@ void fw_devlink_pause(void)
13121319
*/
13131320
void fw_devlink_resume(void)
13141321
{
1322+
struct device *dev, *tmp;
1323+
LIST_HEAD(probe_list);
1324+
13151325
mutex_lock(&defer_fw_devlink_lock);
13161326
if (!defer_fw_devlink_count) {
13171327
WARN(true, "Unmatched fw_devlink pause/resume!");
@@ -1323,8 +1333,19 @@ void fw_devlink_resume(void)
13231333
goto out;
13241334

13251335
device_link_add_missing_supplier_links();
1336+
list_splice_tail_init(&deferred_fw_devlink, &probe_list);
13261337
out:
13271338
mutex_unlock(&defer_fw_devlink_lock);
1339+
1340+
/*
1341+
* bus_probe_device() can cause new devices to get added and they'll
1342+
* try to grab defer_fw_devlink_lock. So, this needs to be done outside
1343+
* the defer_fw_devlink_lock.
1344+
*/
1345+
list_for_each_entry_safe(dev, tmp, &probe_list, links.defer_hook) {
1346+
list_del_init(&dev->links.defer_hook);
1347+
bus_probe_device(dev);
1348+
}
13281349
}
13291350
/* Device links support end. */
13301351

include/linux/device.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ enum dl_dev_state {
433433
* @suppliers: List of links to supplier devices.
434434
* @consumers: List of links to consumer devices.
435435
* @needs_suppliers: Hook to global list of devices waiting for suppliers.
436-
* @defer_hook: Hook to global list of devices that have deferred sync_state.
436+
* @defer_hook: Hook to global list of devices that have deferred sync_state or
437+
* deferred fw_devlink.
437438
* @need_for_probe: If needs_suppliers is on a list, this indicates if the
438439
* suppliers are needed for probe or not.
439440
* @status: Driver status information.

0 commit comments

Comments
 (0)