From: Yuho Choi <oss.patchbox@gmail.com>
To: Lukasz Majewski <lukma@nabladev.com>
Cc: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
Neil Armstrong <neil.armstrong@linaro.org>,
u-boot@lists.u-boot-project.org,
Yuho Choi <oss.patchbox@gmail.com>
Subject: [PATCH] clk: Do not disable clocks when clk_get_bulk() fails
Date: Tue, 27 Oct 2026 10:38:42 -0400 [thread overview]
Message-ID: <20261027143845.1246876-1-oss.patchbox@gmail.com> (raw)
clk_get_bulk() looks up the clocks of a device one by one. If the
lookup of one clock fails, it calls clk_release_all() on the clocks
already looked up before returning the error. clk_release_all() calls
clk_disable() on each of them, although clk_get_bulk() never enabled
them.
With CLK_CCF, clocks registered by id are reference counted. The extra
clk_disable() is ignored while nobody has the clock enabled, but if
another device has enabled it, it drops that device's reference and,
if that was the last one, turns the clock off. Without CLK_CCF, and
for CCF clocks that are not registered by id, clk_disable() calls the
provider's disable op directly. A device whose clocks property names a
clock that cannot be looked up, e.g. because its provider is not
enabled, can therefore turn off clocks listed before it that firmware
or another device relies on.
There is no release operation for a clock that has only been looked
up: clk_free() had become a no-op and was removed in
commit c9309f40a683 ("treewide: Remove clk_free"). Therefore,
clk_release_all() does not undo the lookup, it only disables the clocks.
Return the error directly, and reset bulk->count so that the bulk is
left empty and a later clk_disable_bulk() or clk_release_bulk() on it
does nothing.
Fixes: a855be87da49 ("clk: Add get/enable/disable/release for a bulk of clocks")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
drivers/clk/clk-uclass.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 3fc772c8b4f..3d0b1c4dfff 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -159,7 +159,7 @@ int clk_get_by_index_nodev(ofnode node, int index, struct clk *clk)
int clk_get_bulk(struct udevice *dev, struct clk_bulk *bulk)
{
- int i, ret, err, count;
+ int i, ret, count;
bulk->count = 0;
@@ -173,21 +173,15 @@ int clk_get_bulk(struct udevice *dev, struct clk_bulk *bulk)
for (i = 0; i < count; i++) {
ret = clk_get_by_index(dev, i, &bulk->clks[i]);
- if (ret < 0)
- goto bulk_get_err;
+ if (ret < 0) {
+ bulk->count = 0;
+ return ret;
+ }
++bulk->count;
}
return 0;
-
-bulk_get_err:
- err = clk_release_all(bulk->clks, bulk->count);
- if (err)
- debug("%s: could not release all clocks for %s\n",
- __func__, dev_read_name(dev));
-
- return ret;
}
static struct clk *clk_set_default_get_by_id(struct clk *clk)
--
2.43.0
next reply other threads:[~2026-10-27 16:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 14:38 Yuho Choi [this message]
2026-10-28 7:35 ` [PATCH] clk: Do not disable clocks when clk_get_bulk() fails Simon Glass
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=20261027143845.1246876-1-oss.patchbox@gmail.com \
--to=oss.patchbox@gmail.com \
--cc=lukma@nabladev.com \
--cc=neil.armstrong@linaro.org \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.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 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.