[PATCH] i3c: master: mark OF bus child nodes OF_POPULATED to avoid legacy I2C rescan
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Thu Nov 26 22:31:56 PST 2026
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] i3c: master: duplicate I2C target registration in
i3c_master_add_acpi_dev() [1]
--
commit 90a128e17ec3265217e6df1035f55519b17c0fc3
Author: Billy Tsai <billy_tsai at aspeedtech.com>
i3c: master: mark OF bus child nodes OF_POPULATED to avoid legacy I2C rescan
This commit marks devicetree child nodes of an I3C bus as OF_POPULATED in
fwnode_populate_i3c_bus() so that registering a virtual legacy I2C adapter
sharing the bus of_node does not re-parse or duplicate them via
of_i2c_register_devices().
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index 01e05bad8661e..f025c9e9a0466 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;
> + }
> }
[Severity: High]
This problem wasn't introduced by this patch, but can
i3c_master_add_acpi_dev() register duplicate I2C boardinfo across multiple
I3C controllers [1]?
drivers/i3c/master.c:i3c_master_add_acpi_dev() {
...
if (!acpi_has_method(adev->handle, "_ADR")) {
ret = i3c_master_add_i2c_boardinfo(master, fwnode, reg);
if (ret == -ENODEV)
return 0;
return ret;
}
...
}
When an I3C controller is part of an MFD sharing a parent PCI device's
ACPI node, every controller instance iterates over the shared ACPI child
nodes in fwnode_populate_i3c_bus(). Unlike I3C targets, ACPI child nodes
for I2C devices have no _ADR method, so they bypass controller filtering
and are added to master->boardinfo.i2c on every controller instance,
causing multiple logical I3C buses to instantiate and probe the same
physical I2C target.
[1] https://sashiko.dev/#/bug/linux-d64b161b-09ef-4f5f-9be2-2f469152abee
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127-i3c-master-of-populated-v1-1-29d2a6a5509c@aspeedtech.com?part=1
More information about the linux-i3c
mailing list