[PATCH] i3c: master: mark OF bus child nodes OF_POPULATED to avoid legacy I2C rescan
From: Billy Tsai
Date: Fri Nov 27 2026 - 01:20:48 EST
Commit f26ecaa0f0ab ("i3c: master: dw-i3c: Fix missing of_node for
virtual I2C adapter") made the DesignWare I3C master's virtual legacy
I2C adapter reuse the I3C bus platform device's of_node, so consumers
can resolve the adapter by phandle. i2c_register_adapter() reacts to
any adapter with a non-NULL of_node by unconditionally calling
of_i2c_register_devices(), which walks every child of that node and
requires a "compatible" property to build a modalias.
The I3C core already owns and fully parses every child of the bus node
via fwnode_populate_i3c_bus()/i3c_master_add_of_dev(), for both native
I3C devices (no "compatible" needed per the i3c.yaml binding) and
legacy-I2C-under-I3C devices (registered explicitly through
master->boardinfo.i2c in i3c_master_i2c_adapter_init()). Since neither
path marks the node OF_POPULATED, the generic of_i2c_register_devices()
walk that now runs afterwards treats every child as unclaimed:
- native I3C-only nodes have no "compatible", so of_i2c_get_board_info()
fails the modalias lookup and logs "of_i2c: modalias failure" /
"Failed to create I2C device" noise for a device that is already
correctly registered on the I3C bus.
- legacy-I2C nodes do have "compatible", so of_i2c_register_devices()
silently creates a duplicate i2c_client for the same address that
i3c_master_i2c_adapter_init() also registers from boardinfo.i2c.
Mark each OF bus child OF_POPULATED once i3c_master_add_of_dev() has
accounted for it. ACPI-described children are left untouched, since
OF_POPULATED and of_i2c_register_devices() only apply to the
devicetree case. fwnode_populate_i3c_bus() always runs before the I2C
adapter is registered, so of_i2c_register_devices() sees the flag
already set and skips these nodes entirely, without disturbing the
of_node propagation from f26ecaa0f0ab.
Fixes: f26ecaa0f0ab ("i3c: master: dw-i3c: Fix missing of_node for virtual I2C adapter")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Billy Tsai <billy_tsai@xxxxxxxxxxxxxx>
---
drivers/i3c/master.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index 01e05bad8661..f025c9e9a046 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -3353,15 +3353,25 @@ static int fwnode_populate_i3c_bus(struct i3c_master_controller *master)
return 0;
fwnode_for_each_available_child_node_scoped(fwnode, child) {
- if (is_of_node(child))
+ if (is_of_node(child)) {
ret = i3c_master_add_of_dev(master, child);
- else if (is_acpi_device_node(child))
- ret = i3c_master_add_acpi_dev(master, child);
- else
- continue;
+ if (ret)
+ return ret;
- if (ret)
- return ret;
+ /*
+ * Claim the node so that i2c_register_adapter(),
+ * called later for the legacy I2C adapter sharing
+ * this same of_node, does not also run
+ * of_i2c_register_devices() on it: every child here
+ * is already fully accounted for, whether it ends up
+ * I3C or legacy-I2C boardinfo.
+ */
+ of_node_set_flag(to_of_node(child), OF_POPULATED);
+ } else if (is_acpi_device_node(child)) {
+ ret = i3c_master_add_acpi_dev(master, child);
+ if (ret)
+ return ret;
+ }
}
/*
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261127-i3c-master-of-populated-2ef07c2bb743
Best regards,
--
Billy Tsai <billy_tsai@xxxxxxxxxxxxxx>