From: sashiko-bot@kernel.org
To: "A. Sverdlin" <alexander.sverdlin@siemens.com>
Cc: linux-rtc@vger.kernel.org,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH] rtc: pcf85063: disable the clkout output by default
Date: Mon, 24 Aug 2026 08:19:21 +0000 [thread overview]
Message-ID: <20260824081921.CDF2D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260824080801.709764-1-alexander.sverdlin@siemens.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [Critical] Unconditionally gating the CLKOUT clock during probe overrides the hardware power-on state and breaks Device Tree ABI backward compatibility.
- [Low] The patch introduces a compilation failure because the variable `ret` is undeclared, and returning it directly causes a type mismatch.
Pre-existing issues:
- [High] The driver's clock implementation violates the Common Clock Framework (CCF) contract by implicitly enabling the clock during set_rate and discarding the configured rate after unprepare.
- [High] The clock provider registered via `of_clk_add_provider` is never removed, causing a memory leak and a dangling pointer on driver unbind, despite the commit message claiming otherwise.
--
--- Patch [1]: [PATCH] rtc: pcf85063: disable the clkout output by default ---
commit f0b8f2118b75da5ed86252e825d0385a7e1fe816
Author: Alexander Sverdlin <alexander.sverdlin@siemens.com>
rtc: pcf85063: disable the clkout output by default
This patch gates the PCF85063 CLKOUT pin by default before registering the
OF provider to save power, unless a consumer explicitly claims it.
> Therefore gate CLKOUT in the driver before registering the OF provider,
> mirroring the pcf8563 and hym8563 siblings which already force an off state
> at registration. Doing it before devm_of_clk_add_hw_provider() leaves the
> real consumers in the device tree free to re-enable the output afterwards,
> while an otherwise unused CLKOUT now stays off.
[Severity: High]
This is a pre-existing issue, but the commit message mentions using
devm_of_clk_add_hw_provider(), which contradicts the actual code. The code
still uses of_clk_add_provider() without a corresponding removal, which
leads to a dangling pointer and memory leak if the driver is unbound:
drivers/rtc/rtc-pcf85063.c:pcf85063_clkout_register_clk() {
...
if (!IS_ERR(clk))
of_clk_add_provider(node, of_clk_src_simple_get, clk);
...
}
Since devm_clk_register() automatically frees the clock allocation on
unbind, but of_clk_del_provider() is never called, the global
of_clk_providers list will contain a pointer to freed memory. Should the
driver be updated to actually use devm_of_clk_add_hw_provider() to ensure
proper cleanup?
> diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
> index 8cb9ffc73f6d9..9ccfc893be8d3 100644
> --- a/drivers/rtc/rtc-pcf85063.c
> +++ b/drivers/rtc/rtc-pcf85063.c
> @@ -523,6 +523,12 @@ static struct clk *pcf85063_clkout_register_clk(struct pcf85063 *pcf85063)
> /* optional override of the clockname */
> of_property_read_string(node, "clock-output-names", &init.name);
>
> + /* power-on default is the 32768 Hz output on; gate it until claimed */
> + ret = regmap_update_bits(pcf85063->regmap, PCF85063_REG_CTRL2,
> + PCF85063_REG_CLKO_F_MASK, PCF85063_REG_CLKO_F_OFF);
[Severity: Critical]
Does unconditionally gating the CLKOUT clock during probe break Device Tree
ABI backward compatibility? Legacy hardware platforms might rely on the
default active 32.768 kHz clock output without explicitly defining a clock
consumer in their device tree. Will those systems lose their clock signal
when booting a kernel with this patch?
> + if (ret)
> + return ret;
[Severity: Low]
Does this code compile with CONFIG_COMMON_CLK enabled? It looks like the
variable ret is undeclared in pcf85063_clkout_register_clk(). Also, since
the function returns a struct clk pointer, wouldn't returning an integer
error code directly cause a type mismatch?
[Severity: High]
This isn't a bug introduced by this patch, but does the current clock
implementation violate the Common Clock Framework contract?
Looking at pcf85063_clkout_set_rate(), setting a rate implicitly enables
the clock by modifying the hardware register directly:
drivers/rtc/rtc-pcf85063.c:pcf85063_clkout_set_rate() {
...
return regmap_update_bits(pcf85063->regmap,
PCF85063_REG_CTRL2,
PCF85063_REG_CLKO_F_MASK, i);
}
Furthermore, if a consumer disables the clock and later re-enables it,
pcf85063_clkout_control() unconditionally resets the rate to 32768 Hz,
discarding any previously configured custom rates:
drivers/rtc/rtc-pcf85063.c:pcf85063_clkout_control() {
...
if (enable) {
if (buf == PCF85063_REG_CLKO_F_OFF)
buf = PCF85063_REG_CLKO_F_32768HZ;
...
}
Will this cause custom clock rates set by consumers or device tree to be
silently lost across enable/disable cycles?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260824080801.709764-1-alexander.sverdlin@siemens.com?part=1
next prev parent reply other threads:[~2026-08-24 8:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 8:07 [PATCH] rtc: pcf85063: disable the clkout output by default A. Sverdlin
2026-08-24 8:19 ` sashiko-bot [this message]
2026-08-24 10:30 ` Sverdlin, Alexander
2026-08-24 8:24 ` Alexandre Belloni
2026-08-24 9:58 ` Sverdlin, Alexander
2026-08-25 21:07 ` Alexandre Belloni
2026-08-26 6:13 ` Sverdlin, Alexander
2026-08-26 6:45 ` Alexandre Belloni
2026-08-25 21:48 ` kernel test robot
2026-08-25 22:10 ` kernel test robot
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=20260824081921.CDF2D1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexander.sverdlin@siemens.com \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-rtc@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.