diff options
author | Saravana Kannan <saravanak@google.com> | 2021-03-02 13:11:31 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-03-23 14:58:11 +0100 |
commit | b6f617df4fa936c1ab1831c2b23563f6c1add6c4 (patch) | |
tree | e64a51de6431df1a4f3233e692ccaed05dc3b25f /drivers/base/core.c | |
parent | f2db85b64f0af1410ccb8ebcc9d7fa38e99feee9 (diff) | |
download | linux-b6f617df4fa936c1ab1831c2b23563f6c1add6c4.tar.gz linux-b6f617df4fa936c1ab1831c2b23563f6c1add6c4.tar.bz2 linux-b6f617df4fa936c1ab1831c2b23563f6c1add6c4.zip |
driver core: Update device link status properly for device_bind_driver()
Device link status was not getting updated correctly when
device_bind_driver() is called on a device. This causes a warning[1].
Fix this by updating device links that can be updated and dropping
device links that can't be updated to a sensible state.
[1] - https://lore.kernel.org/lkml/56f7d032-ba5a-a8c7-23de-2969d98c527e@nvidia.com/
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Saravana Kannan <saravanak@google.com>
Link: https://lore.kernel.org/r/20210302211133.2244281-3-saravanak@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r-- | drivers/base/core.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index f29839382f81..45c75cc96fdc 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1154,6 +1154,41 @@ static ssize_t waiting_for_supplier_show(struct device *dev, static DEVICE_ATTR_RO(waiting_for_supplier); /** + * device_links_force_bind - Prepares device to be force bound + * @dev: Consumer device. + * + * device_bind_driver() force binds a device to a driver without calling any + * driver probe functions. So the consumer really isn't going to wait for any + * supplier before it's bound to the driver. We still want the device link + * states to be sensible when this happens. + * + * In preparation for device_bind_driver(), this function goes through each + * supplier device links and checks if the supplier is bound. If it is, then + * the device link status is set to CONSUMER_PROBE. Otherwise, the device link + * is dropped. Links without the DL_FLAG_MANAGED flag set are ignored. + */ +void device_links_force_bind(struct device *dev) +{ + struct device_link *link, *ln; + + device_links_write_lock(); + + list_for_each_entry_safe(link, ln, &dev->links.suppliers, c_node) { + if (!(link->flags & DL_FLAG_MANAGED)) + continue; + + if (link->status != DL_STATE_AVAILABLE) { + device_link_drop_managed(link); + continue; + } + WRITE_ONCE(link->status, DL_STATE_CONSUMER_PROBE); + } + dev->links.status = DL_DEV_PROBING; + + device_links_write_unlock(); +} + +/** * device_links_driver_bound - Update device links after probing its driver. * @dev: Device to update the links for. * |