UPSTREAM: 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: 716a7a259690 ("driver core: fw_devlink: Add support for batching fwnode parsing")
Signed-off-by: Saravana Kannan <saravanak@google.com>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200701194259.3337652-4-saravanak@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 2451e746478a6a6e981cfa66b62b791ca93b90c8)
Signed-off-by: Saravana Kannan <saravanak@google.com>
Bug: 157691602
Change-Id: I76205ec0851fa251da5df485b1503b65b3296c7c
Git-repo: https://android.googlesource.com/kernel/common
Git-commit: c88a69f0e9a39d48d2ed72c2473a3502aded7d25
Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
This commit is contained in:
Saravana Kannan
2020-07-01 12:42:59 -07:00
committed by Srinivasarao P
parent 508be47d4f
commit 3b9cf91c29
2 changed files with 23 additions and 1 deletions

View File

@@ -49,6 +49,7 @@ static DEFINE_MUTEX(wfs_lock);
static LIST_HEAD(deferred_sync); static LIST_HEAD(deferred_sync);
static unsigned int defer_sync_state_count = 1; static unsigned int defer_sync_state_count = 1;
static unsigned int defer_fw_devlink_count; static unsigned int defer_fw_devlink_count;
static LIST_HEAD(deferred_fw_devlink);
static DEFINE_MUTEX(defer_fw_devlink_lock); static DEFINE_MUTEX(defer_fw_devlink_lock);
#ifdef CONFIG_SRCU #ifdef CONFIG_SRCU
@@ -1193,6 +1194,12 @@ static void fw_devlink_link_device(struct device *dev)
fw_ret = fwnode_call_int_op(dev->fwnode, add_links, dev); fw_ret = fwnode_call_int_op(dev->fwnode, add_links, dev);
} else { } else {
fw_ret = -ENODEV; fw_ret = -ENODEV;
/*
* defer_hook is not used to add device to deferred_sync list
* until device is bound. Since deferred fw devlink also blocks
* probing, same list hook can be used for deferred_fw_devlink.
*/
list_add_tail(&dev->links.defer_hook, &deferred_fw_devlink);
} }
if (fw_ret == -ENODEV) if (fw_ret == -ENODEV)
@@ -1261,6 +1268,9 @@ void fw_devlink_pause(void)
*/ */
void fw_devlink_resume(void) void fw_devlink_resume(void)
{ {
struct device *dev, *tmp;
LIST_HEAD(probe_list);
mutex_lock(&defer_fw_devlink_lock); mutex_lock(&defer_fw_devlink_lock);
if (!defer_fw_devlink_count) { if (!defer_fw_devlink_count) {
WARN(true, "Unmatched fw_devlink pause/resume!"); WARN(true, "Unmatched fw_devlink pause/resume!");
@@ -1272,8 +1282,19 @@ void fw_devlink_resume(void)
goto out; goto out;
device_link_add_missing_supplier_links(); device_link_add_missing_supplier_links();
list_splice_tail_init(&deferred_fw_devlink, &probe_list);
out: out:
mutex_unlock(&defer_fw_devlink_lock); mutex_unlock(&defer_fw_devlink_lock);
/*
* bus_probe_device() can cause new devices to get added and they'll
* try to grab defer_fw_devlink_lock. So, this needs to be done outside
* the defer_fw_devlink_lock.
*/
list_for_each_entry_safe(dev, tmp, &probe_list, links.defer_hook) {
list_del_init(&dev->links.defer_hook);
bus_probe_device(dev);
}
} }
/* Device links support end. */ /* Device links support end. */

View File

@@ -922,7 +922,8 @@ enum dl_dev_state {
* @suppliers: List of links to supplier devices. * @suppliers: List of links to supplier devices.
* @consumers: List of links to consumer devices. * @consumers: List of links to consumer devices.
* @needs_suppliers: Hook to global list of devices waiting for suppliers. * @needs_suppliers: Hook to global list of devices waiting for suppliers.
* @defer_hook: Hook to global list of devices that have deferred sync_state. * @defer_hook: Hook to global list of devices that have deferred sync_state or
* deferred fw_devlink.
* @need_for_probe: If needs_suppliers is on a list, this indicates if the * @need_for_probe: If needs_suppliers is on a list, this indicates if the
* suppliers are needed for probe or not. * suppliers are needed for probe or not.
* @status: Driver status information. * @status: Driver status information.