Linux-i3c Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Billy Tsai" <billy_tsai@aspeedtech.com>
Cc: linux-i3c@lists.infradead.org, Frank.Li@kernel.org,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH] i3c: master: mark OF bus child nodes OF_POPULATED to avoid legacy I2C rescan
Date: Fri, 27 Nov 2026 06:31:56 +0000	[thread overview]
Message-ID: <sashiko-outbox-236743@kernel.org> (raw)
In-Reply-To: <20261127-i3c-master-of-populated-v1-1-29d2a6a5509c@aspeedtech.com>

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@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

-- 
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c

      reply	other threads:[~2026-11-27  6:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  6:20 [PATCH] i3c: master: mark OF bus child nodes OF_POPULATED to avoid legacy I2C rescan Billy Tsai
2026-11-27  6:31 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-236743@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=billy_tsai@aspeedtech.com \
    --cc=linux-i3c@lists.infradead.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox