devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Herve Codina <herve.codina@bootlin.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	linux-i2c@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Luca Ceresoli <luca.ceresoli@bootlin.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [RFC PATCH 1/3] i2c: core: Follow i2c-parent when retrieving an adapter from node
Date: Thu, 3 Apr 2025 12:50:50 +0200	[thread overview]
Message-ID: <20250403125050.22db0349@bootlin.com> (raw)
In-Reply-To: <Z-5O3-FSsHbn27lW@shikoro>

Hi Wolfram,

On Thu, 3 Apr 2025 11:03:27 +0200
Wolfram Sang <wsa+renesas@sang-engineering.com> wrote:

> > Extend i2c_find_adapter_by_fwnode() to perform the walking from the
> > given fwnode through i2c-parent references up to the adapter.  
> 
> Even with the review of the schema going on, here are some comments
> already.

Yes. Of course, depending on this review, things could be changed in the
implementation but every things already discussed here make the topic
moving forward. Thanks for that!

...

> > +
> > +	/* Walk extension busses (through i2c-parent) up to the adapter node */
> > +	while (fwnode_property_present(adap_fwnode, "i2c-parent")) {
> > +		/*
> > +		 * A specific case exists for the i2c demux pinctrl. The i2c bus
> > +		 * node related this component (the i2c demux pinctrl node
> > +		 * itself) has an i2c-parent property set. This property is used
> > +		 * by the i2c demux pinctrl component for the demuxing purpose
> > +		 * and is not related to the extension bus feature.
> > +		 *
> > +		 * In this current i2c-parent walking, the i2c demux pinctrl
> > +		 * node has to be considered as an adapter node and so, if
> > +		 * the adap_fwnode node is an i2c demux pinctrl node, simply
> > +		 * stop the i2c-parent walking.
> > +		 */
> > +		if (fwnode_property_match_string(adap_fwnode, "compatible",
> > +						 "i2c-demux-pinctrl") >= 0)
> > +			break;  
> 
> I understand the unlikeliness of another demux driver showing up, yet
> relying on compatible-values here is too easy to get stale. What about
> checking if the i2c-parent property has more than one entry? That should
> be only true for demuxers.

Indeed, this is better.
I will stop the walking based on this number of entries in the i2c-parent
property.

> 
> > +
> > +		/*
> > +		 * i2c-parent property available in a i2c bus node means that
> > +		 * this node is an extension bus node. In that case,
> > +		 * continue i2c-parent walking up to the adapter node.
> > +		 */
> > +		err = fwnode_property_get_reference_args(adap_fwnode, "i2c-parent",
> > +							 NULL, 0, 0, &args);
> > +		if (err)
> > +			break;
> > +
> > +		pr_debug("Find adapter for %pfw, use parent: %pfw\n", fwnode,
> > +			 args.fwnode);  
> 
> Is this useful when creating the overlays? I tend to ask you to remove
> it one RFC phase is over. If it is useful, it should be at least
> dev_dbg?

Using dev_dbg could lead to issues. Indeed, dev is not given as an argument
of i2c_find_adapter_by_fwnode() and there is no reason to add it (except
for this debug message).

Without a dev given as argument we have to retrieve it from the given
fw_node argument. This given fw_node may have its dev field not already set.
Indeed, the dev instanciation could be done later when the bus this fw_node
is connected to will probe().

For instance
  https://elixir.bootlin.com/linux/v6.14-rc6/source/drivers/gpu/drm/panel/panel-simple.c#L606
The panel driver can call of_find_i2c_adapter_by_node() which in turn call
i2c_find_adapter_by_fwnode() without having the I2C controller related to the
adapter already present. the panel driver will return a legit EPROBE_DEFER.

So back to our debug message in i2c_find_adapter_by_fwnode(), either I keep
pr_debug() or I fully remove the message but I don't thing I should change
the i2c_find_adapter_by_fwnode() prototype and update all the callers just
for this debug message.

The debug message can be interesting when things went wrong and we want
to investigate potential issue with i2c-parent chain from the last device
up to the adapter.

I don't have a strong opinion about the need of this message and I can
simply remove it.

What is your preference ?

Best regards,
Hervé

  reply	other threads:[~2025-04-03 10:50 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 17:39 [RFC PATCH 0/3] i2c: Introduce i2c bus extensions Herve Codina
2025-02-05 17:39 ` [RFC PATCH 1/3] i2c: core: Follow i2c-parent when retrieving an adapter from node Herve Codina
2025-04-03  9:03   ` Wolfram Sang
2025-04-03 10:50     ` Herve Codina [this message]
2025-04-03 11:20       ` Wolfram Sang
2025-04-03 12:21         ` Herve Codina
2025-02-05 17:39 ` [RFC PATCH 2/3] i2c: i2c-core-of: Move children registration in a dedicated function Herve Codina
2025-04-03  9:07   ` Wolfram Sang
2025-04-03 10:51     ` Herve Codina
2025-02-05 17:39 ` [RFC PATCH 3/3] i2c: i2c-core-of: Handle i2c bus extensions Herve Codina
2025-02-12  5:54   ` Krzysztof Kozlowski
2025-02-12  9:45     ` Herve Codina
2025-04-03  9:09   ` Wolfram Sang
2025-02-19 13:38 ` [RFC PATCH 0/3] i2c: Introduce " Herve Codina
2025-03-20 12:49 ` Wolfram Sang
2025-03-20 16:31   ` Luca Ceresoli
2025-03-20 21:37     ` Wolfram Sang
2025-04-03  9:15 ` Wolfram Sang
2025-06-12  7:52 ` Ayush Singh
2025-06-13  7:30   ` Herve Codina
2025-07-03 11:26     ` Ayush Singh
2025-07-03 15:19       ` Herve Codina

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=20250403125050.22db0349@bootlin.com \
    --to=herve.codina@bootlin.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=robh@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=wsa+renesas@sang-engineering.com \
    /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;
as well as URLs for NNTP newsgroup(s).