From: Marcus Folkesson <marcus.folkesson@gmail.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: Peter Rosin <peda@axentia.se>,
Michael Hennerich <michael.hennerich@analog.com>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Andi Shyti <andi.shyti@kernel.org>,
Andy Shevchenko <andriy.shevchenko@intel.com>,
Bartosz Golaszewski <brgl@kernel.org>,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v9 1/5] i2c: core: add callback to change bus frequency
Date: Sun, 31 May 2026 12:18:21 +0200 [thread overview]
Message-ID: <ahwK7XsUswya3F1L@gmail.com> (raw)
In-Reply-To: <ahX44_rzaRlTLSLU@shikoro>
Hi Wolfram!
On Tue, May 26, 2026 at 09:47:47PM +0200, Wolfram Sang wrote:
> Hi Marcus,
>
> finally I found some time... thank you for your patience!
No worries, I'm aware of your workload and appreciate you taking the
time to review the patches.
>
> Some comments here, but I have high level questions first to be
> discussed in patch 5. Maybe we should start there...
>
> > + int (*set_clk_freq)(struct i2c_adapter *adap, u32 clock_hz); /* Optional */
>
> Shouldn't this rather go into 'struct i2c_algorithm'?
Hrm, not sure.
When looking into `struct i2c_algorithm`, it has no information about
any other state.
Also, the `struct i2c_algorithm` is often shared between multiple
adapters, so if it had the information about the current clock
frequency, it will be shared as well, which is not what we want.
To me it feels more natural to have this callback in the adapter, but
I'm open to change it if there are good reasons to do so.
>
> > +static inline int
> > +__i2c_adapter_set_clk_freq(struct i2c_adapter *adapter, u32 clock_hz)
> > +{
> > + if (adapter->set_clk_freq)
> > + return adapter->set_clk_freq(adapter, clock_hz);
>
> So, Sashiko mentions[1] that setting 'adapter->clock_hz' below is not
> executed. This is fine in my book because the requested new rate might
> not be the actually used rate. However, I agree that it must be
> documented that the callback is required to set 'clock_hz'. Or maybe
> even better, the callback should return the newly set value and this
> function then updates the variable?
I will look into this, thanks!
>
> [1] https://sashiko.dev/#/patchset/20260324-i2c-mux-v9-0-5292b0608243%40gmail.com
>
> > +
> > + /*
> > + * If the adapter is a root adapter without .set_clk_freq() implemented, this feature is not
> > + * supported.
> > + */
> > + if (!i2c_parent_is_i2c_adapter(adapter))
> > + return -EOPNOTSUPP;
> > +
> > + /*
> > + * Update the clock_hz for non-root adapters, even if .set_clk_freq() is not implemented,
> > + * to allow the clock frequency to be propagated to root adapters that do support it.
> > + */
> > + adapter->clock_hz = clock_hz;
> > + return 0;
>
> So, Sashiko is IMO correct with asking what happens if setting the new
> freq in the root adapter fails? There is no path to restore the old
> values for the children then, or did I miss it?
I will look into this as well.
Spontaneously, I would say that if the root adapter fails to set the new
frequency, the deselect chain will restore the old frequency for all
children no matters what.
>
> Happy hacking,
>
> Wolfram
>
Best regards
Marcus Folkesson
next prev parent reply other threads:[~2026-05-31 10:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 13:54 [PATCH v9 0/5] I2C Mux per channel bus speed Marcus Folkesson
2026-03-24 13:54 ` [PATCH v9 1/5] i2c: core: add callback to change bus frequency Marcus Folkesson
2026-05-26 19:47 ` Wolfram Sang
2026-05-31 10:18 ` Marcus Folkesson [this message]
2026-03-24 13:54 ` [PATCH v9 2/5] i2c: mux: add support for per channel " Marcus Folkesson
2026-03-24 14:10 ` Andy Shevchenko
2026-03-26 11:39 ` Marcus Folkesson
2026-03-24 13:54 ` [PATCH v9 3/5] i2c: davinci: calculate bus freq from Hz instead of kHz Marcus Folkesson
2026-03-24 13:54 ` [PATCH v9 4/5] i2c: davinci: add support for setting bus frequency Marcus Folkesson
2026-03-24 13:54 ` [PATCH v9 5/5] docs: i2c: i2c-topology: add section about bus speed Marcus Folkesson
2026-05-26 19:48 ` Wolfram Sang
2026-05-30 6:54 ` Peter Rosin
2026-05-30 9:17 ` Wolfram Sang
2026-05-31 10:51 ` Marcus Folkesson
2026-05-31 10:42 ` Marcus Folkesson
2026-05-31 10:25 ` Marcus Folkesson
2026-03-26 12:17 ` [PATCH v9 0/5] I2C Mux per channel " Marcus Folkesson
2026-04-13 7:45 ` Marcus Folkesson
2026-05-08 13:14 ` Marcus Folkesson
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=ahwK7XsUswya3F1L@gmail.com \
--to=marcus.folkesson@gmail.com \
--cc=andi.shyti@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=brgl@bgdev.pl \
--cc=brgl@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.hennerich@analog.com \
--cc=peda@axentia.se \
--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