[RFC PATCH v2 2/2] of: dynamic: Fix probing of overlay devices
Saravana Kannan
saravanak at google.com
Mon Apr 8 22:37:03 PDT 2024
Get fw_devlink to work well with overlay devices.
Signed-off-by: Saravana Kannan <saravanak at google.com>
---
drivers/base/core.c | 23 +++++++++++++++++++++++
drivers/of/dynamic.c | 1 +
include/linux/fwnode.h | 1 +
3 files changed, 25 insertions(+)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 5f4e03336e68..5ce33dbd7560 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -237,6 +237,29 @@ static void __fw_devlink_pickup_dangling_consumers(struct fwnode_handle *fwnode,
__fw_devlink_pickup_dangling_consumers(child, new_sup);
}
+
+void fw_devlink_fixup_new_fwnode(struct fwnode_handle *new_fwnode)
+{
+ struct fwnode_handle *parent;
+
+ if (new_fwnode->dev && new_fwnode->dev->bus)
+ return;
+
+ fwnode_for_each_parent_node(new_fwnode, parent)
+ if (parent->dev && parent->dev->bus)
+ break;
+
+ if (!parent)
+ return;
+
+ mutex_lock(&fwnode_link_lock);
+ __fw_devlink_pickup_dangling_consumers(new_fwnode, parent);
+ __fw_devlink_link_to_consumers(parent->dev);
+ mutex_unlock(&fwnode_link_lock);
+
+ fwnode_handle_put(parent);
+}
+
static DEFINE_MUTEX(device_links_lock);
DEFINE_STATIC_SRCU(device_links_srcu);
diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 19a1a38554f2..a2ad79ea9a06 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -581,6 +581,7 @@ static int __of_changeset_entry_notify(struct of_changeset_entry *ce,
memset(&rd, 0, sizeof(rd));
rd.dn = ce->np;
ret = of_reconfig_notify(ce->action, &rd);
+ fw_devlink_fixup_new_fwnode(of_fwnode_handle(ce->np));
break;
case OF_RECONFIG_ADD_PROPERTY:
case OF_RECONFIG_REMOVE_PROPERTY:
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 0d79070c5a70..230aeccef6f3 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -220,6 +220,7 @@ int fwnode_link_add(struct fwnode_handle *con, struct fwnode_handle *sup,
u8 flags);
void fwnode_links_purge(struct fwnode_handle *fwnode);
void fw_devlink_purge_absent_suppliers(struct fwnode_handle *fwnode);
+void fw_devlink_fixup_new_fwnode(struct fwnode_handle *new_fwnode);
bool fw_devlink_is_strict(void);
#endif
--
2.44.0.478.gd926399ef9-goog
More information about the linux-arm-kernel
mailing list