Linux clock framework development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Linkai Gong" <gonglinkai@kylinos.cn>
Cc: linux-clk@vger.kernel.org
Subject: Re: [PATCH] clk: zynq: return -ETIMEDOUT if the PLL never locks
Date: Tue, 01 Sep 2026 13:01:40 +0000	[thread overview]
Message-ID: <20260901130140.878881F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901125323.1556551-1-gonglinkai@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing hardware state rollback on PLL lock timeout.
--

commit 91f1719daf95abfb29082ef831a0b53acd17a349
Author: Linkai Gong <gonglinkai@kylinos.cn>

clk: zynq: return -ETIMEDOUT if the PLL never locks

zynq_pll_enable() waits for lock under a spinlock with no timeout. Poll
with a 1ms bound and return the error.

> diff --git a/drivers/clk/zynq/pll.c b/drivers/clk/zynq/pll.c
> index fe90b50e1545d..4e3a1cb40be74 100644
> --- a/drivers/clk/zynq/pll.c
> +++ b/drivers/clk/zynq/pll.c
[ ... ]
> @@ -131,12 +133,12 @@ static int zynq_pll_enable(struct clk_hw *hw)
>  	reg = readl(clk->pll_ctrl);
>  	reg &= ~(PLLCTRL_RESET_MASK | PLLCTRL_PWRDWN_MASK);
>  	writel(reg, clk->pll_ctrl);
> -	while (!(readl(clk->pll_status) & (1 << clk->lockbit)))
> -		;
> +	ret = readl_poll_timeout_atomic(clk->pll_status, reg,
> +					reg & (1 << clk->lockbit), 10, 1000);
>  
>  	spin_unlock_irqrestore(clk->lock, flags);
>  
> -	return 0;
> +	return ret;

[Severity: High]
Does this leave the hardware state desynchronized if the PLL fails to lock?

If readl_poll_timeout_atomic() returns -ETIMEDOUT, the function returns the
error directly without restoring the PLLCTRL_RESET_MASK and
PLLCTRL_PWRDWN_MASK bits in the control register.

Because zynq_pll_is_enabled() checks those same bits to determine if the
PLL is enabled:

drivers/clk/zynq/pll.c:zynq_pll_is_enabled() {
    ...
	reg = readl(clk->pll_ctrl);
    ...
	return !(reg & (PLLCTRL_RESET_MASK | PLLCTRL_PWRDWN_MASK));
}

A subsequent call to zynq_pll_enable() will falsely succeed since
zynq_pll_is_enabled() will return true, hiding the lock failure. Should we
re-assert the reset and power-down bits in the error path before returning?

>  }
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260901125323.1556551-1-gonglinkai@kylinos.cn?part=1

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

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 12:53 [PATCH] clk: zynq: return -ETIMEDOUT if the PLL never locks Linkai Gong
2026-09-01 13:01 ` sashiko-bot [this message]
2026-09-07 12:58 ` Michal Simek
2026-09-08  8:44   ` Linkai Gong
2026-09-08  8:47 ` [PATCH v2] " Linkai Gong

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=20260901130140.878881F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=gonglinkai@kylinos.cn \
    --cc=linux-clk@vger.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