Skip to content

Commit 5501765

Browse files
Saravana Kannangregkh
authored andcommitted
driver core: fw_devlink: Add support for FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD
If a parent device is also a supplier to a child device, fw_devlink=on by design delays the probe() of the child device until the probe() of the parent finishes successfully. However, some drivers of such parent devices (where parent is also a supplier) expect the child device to finish probing successfully as soon as they are added using device_add() and before the probe() of the parent device has completed successfully. One example of such a case is discussed in the link mentioned below. Add a flag to make fw_devlink=on not enforce these supplier-consumer relationships, so these drivers can continue working. Link: https://lore.kernel.org/netdev/CAGETcx_uj0V4DChME-gy5HGKTYnxLBX=TH2rag29f_p=UcG+Tg@mail.gmail.com/ Fixes: ea718c6 ("Revert "Revert "driver core: Set fw_devlink=on by default""") Signed-off-by: Saravana Kannan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2de9d8e commit 5501765

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

drivers/base/core.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,25 @@ static int fw_devlink_create_devlink(struct device *con,
17221722
struct device *sup_dev;
17231723
int ret = 0;
17241724

1725+
/*
1726+
* In some cases, a device P might also be a supplier to its child node
1727+
* C. However, this would defer the probe of C until the probe of P
1728+
* completes successfully. This is perfectly fine in the device driver
1729+
* model. device_add() doesn't guarantee probe completion of the device
1730+
* by the time it returns.
1731+
*
1732+
* However, there are a few drivers that assume C will finish probing
1733+
* as soon as it's added and before P finishes probing. So, we provide
1734+
* a flag to let fw_devlink know not to delay the probe of C until the
1735+
* probe of P completes successfully.
1736+
*
1737+
* When such a flag is set, we can't create device links where P is the
1738+
* supplier of C as that would delay the probe of C.
1739+
*/
1740+
if (sup_handle->flags & FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD &&
1741+
fwnode_is_ancestor_of(sup_handle, con->fwnode))
1742+
return -EINVAL;
1743+
17251744
sup_dev = get_dev_from_fwnode(sup_handle);
17261745
if (sup_dev) {
17271746
/*

include/linux/fwnode.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ struct device;
2222
* LINKS_ADDED: The fwnode has already be parsed to add fwnode links.
2323
* NOT_DEVICE: The fwnode will never be populated as a struct device.
2424
* INITIALIZED: The hardware corresponding to fwnode has been initialized.
25+
* NEEDS_CHILD_BOUND_ON_ADD: For this fwnode/device to probe successfully, its
26+
* driver needs its child devices to be bound with
27+
* their respective drivers as soon as they are
28+
* added.
2529
*/
26-
#define FWNODE_FLAG_LINKS_ADDED BIT(0)
27-
#define FWNODE_FLAG_NOT_DEVICE BIT(1)
28-
#define FWNODE_FLAG_INITIALIZED BIT(2)
30+
#define FWNODE_FLAG_LINKS_ADDED BIT(0)
31+
#define FWNODE_FLAG_NOT_DEVICE BIT(1)
32+
#define FWNODE_FLAG_INITIALIZED BIT(2)
33+
#define FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD BIT(3)
2934

3035
struct fwnode_handle {
3136
struct fwnode_handle *secondary;

0 commit comments

Comments
 (0)