linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: NXP Linux Team <linux-imx@nxp.com>,
	"A. Sverdlin" <alexander.sverdlin@siemens.com>,
	Dong Aisheng <aisheng.dong@nxp.com>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] i2c: lpi2c: cache peripheral clock rate
Date: Mon, 24 Apr 2023 09:03:34 +0200	[thread overview]
Message-ID: <4797405.GXAFRqVoOG@steina-w> (raw)
In-Reply-To: <20230421-kinfolk-glancing-e185fd9c47b4-mkl@pengutronix.de>

Hi Marc,

Am Freitag, 21. April 2023, 15:59:52 CEST schrieb Marc Kleine-Budde:
> * PGP Signed by an unknown key
> 
> On 21.04.2023 15:48:59, Alexander Stein wrote:
> [...]
> 
> > Now lpi2c_runtime_resume will call into clk_prepare() which also calls
> > clk_prepare_lock() (identical to clk_get_rate).
> 
> IIRC this is a general problem^w limitation of the clock framework,
> clock providers cannot use clocks themselves in certain callback, e.g.
> set_rate.

Well, that's essentially impossible when this clock provider is attached via 
i2c. i2c transfers potentially need to change or prepare clocks.

One problem is that during clock registration (__clk_core_init) in the call to 
clk_ops.recalc_rate an i2c transfer is issued (via regmap). This is the 
inverse lock order to a regular transfer runtime resuming the i2c master and 
preparing the clocks.

While looking at this, is_prepared is also affected by this. It's reading a 
register, thus issuing a i2c transfer. But this function can also be called 
from within clk_unprepare_unused_subtree, which holds clk_prepare_lock as 
well.

This might be avoided by using regcache, but I'm not really sure this catches 
every case.

Best regards,
Alexander
-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-04-24  7:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10 13:08 [PATCH v3] i2c: lpi2c: cache peripheral clock rate A. Sverdlin
2023-04-21 13:48 ` Alexander Stein
2023-04-21 13:59   ` Marc Kleine-Budde
2023-04-24  7:03     ` Alexander Stein [this message]
2023-04-30  7:05       ` Wolfram Sang
2023-05-02  6:50         ` Alexander Stein
2023-05-02  7:03           ` Marc Kleine-Budde
2023-04-21 14:10   ` Sverdlin, Alexander
2023-05-15  9:11   ` Alexander Stein
2023-05-15 12:04     ` Sverdlin, Alexander
2023-05-15 12:32       ` Alexander Stein
2023-05-15 12:37         ` Sverdlin, Alexander
2023-05-15 13:11   ` Sverdlin, Alexander
2023-04-24  8:08 ` Alexander Stein

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=4797405.GXAFRqVoOG@steina-w \
    --to=alexander.stein@ew.tq-group.com \
    --cc=aisheng.dong@nxp.com \
    --cc=alexander.sverdlin@siemens.com \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@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;
as well as URLs for NNTP newsgroup(s).