Linux clock framework development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vyacheslav Yurkov" <V.Yurkov.EXT@bruker.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org,
	linux-clk@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v6 2/2] clk: Add gpio-locked clock driver
Date: Sun, 27 Sep 2026 13:42:00 +0000	[thread overview]
Message-ID: <20260927134200.9DB2F1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260927-feature-clock-guard-v6-2-007983b13ec2@bruker.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] clk: gpio: locked-clock prepare callback violates API and inverts success
--

commit 6568d5231c6cc47d178121c89d700cd8a3a8cf08
Author: Vyacheslav Yurkov <V.Yurkov.EXT@bruker.com>

clk: Add gpio-locked clock driver

This commit introduces a gpio-locked clock driver where the clock's status
is determined by a GPIO signal. It is intended for FPGA-assisted clocking
designs where consumers can wait until the input clock is locked before
initializing dependent peripherals.

> diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c
> index 9099c57e27156..a264ba21baf26 100644
> --- a/drivers/clk/clk-gpio.c
> +++ b/drivers/clk/clk-gpio.c

[ ... ]

> @@ -138,6 +138,19 @@ static const struct clk_ops clk_gpio_mux_ops = {
>  	.determine_rate = __clk_mux_determine_rate,
>  };
>  
> +/* We can't prepare the clock, but the Common Clock Framework calls only
> + * prepare() not is_prepared(), therefore we fallback on the actuall GPIO value.
> + */
> +static int clk_gpio_locked_prepare(struct clk_hw *hw)
> +{
> +	return clk_sleeping_gpio_gate_is_prepared(hw);
> +}

[Severity: High]
Does this callback violate the Common Clock Framework prepare semantics?

The Common Clock Framework expects the prepare callback to return 0 on
success and a negative error code on failure. However,
clk_sleeping_gpio_gate_is_prepared() returns the instantaneous boolean GPIO
state.

If the clock is successfully locked, this returns 1, which the framework
interprets as an error, aborting the preparation. If it is unlocked, it
returns 0, which the framework interprets as a success.

Additionally, the commit message states consumers can wait until the clock is
locked, but this implementation returns the state immediately without blocking
or polling for the lock. Will this cause dependent peripherals to initialize
prematurely or fail to initialize at all?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260927-feature-clock-guard-v6-0-007983b13ec2@bruker.com?part=2

      reply	other threads:[~2026-09-27 13:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-27 13:34 [PATCH v6 0/2] A proposal to add a gpio-locked clock driver Vyacheslav Yurkov via B4 Relay
2026-09-27 13:34 ` [PATCH v6 1/2] dt-bindings: clock: gpio-gate-clock: Add a new compatible string Vyacheslav Yurkov via B4 Relay
2026-09-27 13:39   ` sashiko-bot
2026-09-27 13:34 ` [PATCH v6 2/2] clk: Add gpio-locked clock driver Vyacheslav Yurkov via B4 Relay
2026-09-27 13:42   ` sashiko-bot [this message]

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=20260927134200.9DB2F1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=V.Yurkov.EXT@bruker.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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