Linux I2C development
 help / color / mirror / Atom feed
From: Andi Shyti <andi.shyti@kernel.org>
To: "H. Nikolaus Schaller" <hns@goldelico.com>
Cc: Paul Cercueil <paul@crapouillou.net>,
	linux-mips@vger.kernel.org,  linux-i2c@vger.kernel.org,
	linux-kernel@vger.kernel.org, letux-kernel@openphoenux.org,
	 stable@vger.kernel.org
Subject: Re: [PATCH] i2c: jz4780: Cache clock rate at probe to prevent CCF prepare_lock deadlock
Date: Thu, 16 Jul 2026 13:41:17 +0200	[thread overview]
Message-ID: <aljCGkhZEQHzZVSW@zenone.zhora.eu> (raw)
In-Reply-To: <9421BB47-EFC8-4D82-989F-82A84FE46749@goldelico.com>

On Thu, Jul 16, 2026 at 10:33:56AM +0200, H. Nikolaus Schaller wrote:
> > Am 16.07.2026 um 09:43 schrieb Andi Shyti <andi.shyti@kernel.org>:
> > On Thu, Jul 16, 2026 at 07:44:20AM +0200, H. Nikolaus Schaller wrote:
> >>> Am 16.07.2026 um 00:07 schrieb Andi Shyti <andi.shyti@kernel.org>:
> >>> On Fri, Jul 10, 2026 at 08:58:35AM +0200, H. Nikolaus Schaller wrote:
> >>>> Fix a severe AB/BA deadlock between the Common Clock Framework (CCF)
> >>>> and the I2C adapter lock, which triggers when an I2C-controlled clock
> >>>> generator (like the Si5351) is registered or modified under the CCF.
> >>>> 
> >>>> During a clock frequency change, the CCF acquires its global 'prepare_lock'
> >>>> mutex and calls i2c_transfer() to update the chip registers, stalling
> >>>> for the adapter's I2C bus lock.
> >>> 
> >>> I don't think caching the clock rate once at probe is safe.
> >> 
> >> Ok, valid point to discuss.
> >> 
> >> 
> >>> If the controller clock rate changes afterwards,
> >>> jz4780_i2c_set_speed() will keep using the stale cached value and
> >>> calculate incorrect bus timings.
> >> 
> >> But: is clock rate ever changed during operation? Usually it is defined
> >> by the device tree constant.
> > 
> > That's what you are saying in your commit message.
> 
> The Si5351 clock generator driver is connected through this i2c bus. And that
> is referred to by "when an I2C-controlled clock generator (like the Si5351) is 
> registered or modified under the CCF".
> 
> Only then, this bug faces surface. Because that driver changes it's clock through
> sending i2c commands which also ask for the lock.

If you make a claim in the commit message, I expect the code to
support it.

You say that the clock rate can change, but then you store it
only once at probe time. That immediately suggests that later
rate changes will be ignored by the transfer path.

> But again: how would you solve this?

It's not my role to give you a solution. I'm just commenting on
what I see.

Besides that, is that an issue you have encountered yourself? Is
it a frequent issue?

Thanks,
Andi

  reply	other threads:[~2026-07-16 11:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10  6:58 [PATCH] i2c: jz4780: Cache clock rate at probe to prevent CCF prepare_lock deadlock H. Nikolaus Schaller
2026-07-15 22:07 ` Andi Shyti
2026-07-16  5:44   ` H. Nikolaus Schaller
2026-07-16  7:43     ` Andi Shyti
2026-07-16  8:33       ` H. Nikolaus Schaller
2026-07-16 11:41         ` Andi Shyti [this message]
2026-07-16 12:18           ` [Letux-kernel] " H. Nikolaus Schaller
2026-07-16 15:08             ` Andi Shyti
2026-07-16 15:46               ` H. Nikolaus Schaller

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=aljCGkhZEQHzZVSW@zenone.zhora.eu \
    --to=andi.shyti@kernel.org \
    --cc=hns@goldelico.com \
    --cc=letux-kernel@openphoenux.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=paul@crapouillou.net \
    --cc=stable@vger.kernel.org \
    /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