Skip to content

Commit 411c0d5

Browse files
Saravana Kannangregkh
authored andcommitted
driver core: fw_devlink: Improve check for fwnode with no device/driver
fw_devlink shouldn't defer the probe of a device to wait on a supplier that'll never have a struct device or will never be probed by a driver. We currently check if a supplier falls into this category, but don't check its ancestors. We need to check the ancestors too because if the ancestor will never probe, then the supplier will never probe either. Signed-off-by: Saravana Kannan <saravanak@google.com> Tested-by: Colin Foster <colin.foster@in-advantage.com> Tested-by: Sudeep Holla <sudeep.holla@arm.com> Tested-by: Douglas Anderson <dianders@chromium.org> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> Tested-by: Luca Weiss <luca.weiss@fairphone.com> # qcom/sm7225-fairphone-fp4 Link: https://lore.kernel.org/r/20230207014207.1678715-3-saravanak@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3a2dbc5 commit 411c0d5

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

drivers/base/core.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,6 +1867,35 @@ static int fw_devlink_relax_cycle(struct device *con, void *sup)
18671867
return ret;
18681868
}
18691869

1870+
static bool fwnode_init_without_drv(struct fwnode_handle *fwnode)
1871+
{
1872+
struct device *dev;
1873+
bool ret;
1874+
1875+
if (!(fwnode->flags & FWNODE_FLAG_INITIALIZED))
1876+
return false;
1877+
1878+
dev = get_dev_from_fwnode(fwnode);
1879+
ret = !dev || dev->links.status == DL_DEV_NO_DRIVER;
1880+
put_device(dev);
1881+
1882+
return ret;
1883+
}
1884+
1885+
static bool fwnode_ancestor_init_without_drv(struct fwnode_handle *fwnode)
1886+
{
1887+
struct fwnode_handle *parent;
1888+
1889+
fwnode_for_each_parent_node(fwnode, parent) {
1890+
if (fwnode_init_without_drv(parent)) {
1891+
fwnode_handle_put(parent);
1892+
return true;
1893+
}
1894+
}
1895+
1896+
return false;
1897+
}
1898+
18701899
/**
18711900
* fw_devlink_create_devlink - Create a device link from a consumer to fwnode
18721901
* @con: consumer device for the device link
@@ -1948,9 +1977,16 @@ static int fw_devlink_create_devlink(struct device *con,
19481977
goto out;
19491978
}
19501979

1951-
/* Supplier that's already initialized without a struct device. */
1952-
if (sup_handle->flags & FWNODE_FLAG_INITIALIZED)
1980+
/*
1981+
* Supplier or supplier's ancestor already initialized without a struct
1982+
* device or being probed by a driver.
1983+
*/
1984+
if (fwnode_init_without_drv(sup_handle) ||
1985+
fwnode_ancestor_init_without_drv(sup_handle)) {
1986+
dev_dbg(con, "Not linking %pfwP - Might never probe\n",
1987+
sup_handle);
19531988
return -EINVAL;
1989+
}
19541990

19551991
/*
19561992
* DL_FLAG_SYNC_STATE_ONLY doesn't block probing and supports

0 commit comments

Comments
 (0)