Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Masney <bmasney@redhat.com>
To: Joakim  Zhang <joakim.zhang@cixtech.com>
Cc: "mturquette@baylibre.com" <mturquette@baylibre.com>,
	"sboyd@kernel.org" <sboyd@kernel.org>,
	"robh@kernel.org" <robh@kernel.org>,
	"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
	"conor+dt@kernel.org" <conor+dt@kernel.org>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	cix-kernel-upstream <cix-kernel-upstream@cixtech.com>,
	"linux-clk@vger.kernel.org" <linux-clk@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v11 2/4] clk: cix: add sky1 audss clock controller
Date: Fri, 24 Jul 2026 15:00:37 -0400	[thread overview]
Message-ID: <amO2VSHtSQE98CNz@redhat.com> (raw)
In-Reply-To: <SEYPR06MB6226EA6519C74A0FF0AB677482CF2@SEYPR06MB6226.apcprd06.prod.outlook.com>

Hi Joakim,

On Fri, Jul 24, 2026 at 06:14:29AM +0000, Joakim  Zhang wrote:
> > -----Original Message-----
> > From: Brian Masney <bmasney@redhat.com>
> > Sent: Friday, July 24, 2026 12:43 AM
> > To: Joakim Zhang <joakim.zhang@cixtech.com>
> > Cc: mturquette@baylibre.com; sboyd@kernel.org; robh@kernel.org;
> > krzk+dt@kernel.org; conor+dt@kernel.org; p.zabel@pengutronix.de; cix-kernel-
> > upstream <cix-kernel-upstream@cixtech.com>; linux-clk@vger.kernel.org;
> > devicetree@vger.kernel.org; linux-kernel@vger.kernel.org; linux-arm-
> > kernel@lists.infradead.org
> > Subject: Re: [PATCH v11 2/4] clk: cix: add sky1 audss clock controller
> > 
> > EXTERNAL EMAIL
> > 
> > Hi Joakim,
> > 
> > There's one question from Sashiko that I don't see where you answered that seems
> > to be legit.
> > 
> > On Thu, Jul 23, 2026 at 05:08:06PM +0800, joakim.zhang@cixtech.com wrote:
> > > From: Joakim Zhang <joakim.zhang@cixtech.com>
> > >
> > > Add a platform driver for the Cix Sky1 AUDSS CRU. The driver maps the
> > > CRU registers and registers mux, divider and gate clocks for DSP,
> > > SRAM, HDA, DMAC, I2S, mailbox, watchdog and timer blocks.
> > >
> > > Four SoC-level audio reference clocks are enabled as inputs to the
> > > internal clock tree. The driver releases the AUDSS NOC reset, enables
> > > runtime PM and instantiates the auxiliary reset device.
> > >
> > > Signed-off-by: Joakim Zhang <joakim.zhang@cixtech.com>
> > 
> > [snip]
> > 
> > > +static int __maybe_unused sky1_audss_clk_runtime_resume(struct device
> > > +*dev) {
> > > +     struct sky1_audss_clks_priv *priv = dev_get_drvdata(dev);
> > > +     const struct sky1_audss_clks_devtype_data *devtype_data = priv-
> > >devtype_data;
> > > +     unsigned long flags;
> > > +     int i, ret;
> > > +
> > > +     ret = sky1_audss_clks_enable(priv);
> > 
> > From Sashiko:
> > 
> >     [Severity: High]
> >     Could this result in a deadlock? When a consumer calls clk_prepare on an
> >     audss clock, CCF acquires the global prepare_lock mutex and may call
> >     pm_runtime_resume_and_get. This triggers sky1_audss_clk_runtime_resume,
> >     which calls sky1_audss_clks_enable. Since sky1_audss_clks_enable executes
> >     clk_prepare_enable, it will attempt to acquire the non-recursive prepare_lock
> >     again.
> 
> prepare_lock is re-entrant for the same task (see clk_prepare_lock(): if prepare_owner == current it just bumps prepare_refcnt). So calling clk_prepare_enable() on the parent SCMI clocks from runtime_resume(), while already in clk_prepare() for an AUDSS clock, does not deadlock. This matches how CCF recursively prepares parents under the same lock.
> 
> That safety assumes resume of the AUDSS CRU is driven from CCF while the same task already owns prepare_lock. If another device device-links to the AUDSS CRU (or otherwise runtime resumes it outside clk_prepare), a concurrent clk_prepare() can deadlock:
>   Thread A: holds prepare_lock, waits in pm_runtime for our resume
>   Thread B: in our runtime_resume, clk_prepare_enable() waits for prepare_lock
> 
> We do not have such a device-link usage today. Would you prefer we add a short comment near sky1_audss_clk_runtime_resume() / sky1_audss_clks_enable() documenting that consumers should use these clocks via CCF and should not PM-resume this device through a device link (or other non-CCF path) that can race with clk_prepare? Happy to add that in the next version if useful.
> 
> > I found drivers/clk/samsung/clk-exynos-audss.c that is similar to your driver and it
> > calls clk_prepare_enable() in probe.
> 
> Exynos AUDSS is only partially similar. It clk_prepare_enable()s EPLL in probe and keeps it enabled for the lifetime of the driver; its runtime PM callbacks only save/restore AUDSS registers and never disable that parent.
> 
> We cannot follow that pattern. Our parent clocks come from SCMI and also gate the audio subsystem power domain. If we clk_prepare_enable() them in probe and leave them enabled, their enable counts stay non-zero, so after system suspend (and on runtime idle) those SCMI clocks cannot be disabled and the audio SS power domain stays on.
> 
> That is why we enable the parent SCMI clocks in runtime_resume() and disable them in runtime_suspend(), instead of keeping a permanent prepare/enable from probe like Exynos.

That makes sense and thanks for the clarification.

Reviewed-by: Brian Masney <bmasney@redhat.com>



  reply	other threads:[~2026-07-24 19:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23  9:08 [PATCH v11 0/4] Add Cix Sky1 AUDSS clock and reset support joakim.zhang
2026-07-23  9:08 ` [PATCH v11 2/4] clk: cix: add sky1 audss clock controller joakim.zhang
2026-07-23 16:42   ` Brian Masney
2026-07-24  6:14     ` Joakim  Zhang
2026-07-24 19:00       ` Brian Masney [this message]
2026-07-23  9:08 ` [PATCH v11 3/4] reset: cix: add sky1 audss auxiliary reset driver joakim.zhang
2026-07-23  9:26   ` Philipp Zabel
2026-07-23  9:08 ` [PATCH v11 4/4] arm64: dts: cix: sky1: add audss cru joakim.zhang

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=amO2VSHtSQE98CNz@redhat.com \
    --to=bmasney@redhat.com \
    --cc=cix-kernel-upstream@cixtech.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=joakim.zhang@cixtech.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=sboyd@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