From: Joshua Covington <joshuacov@gmail.com>
To: Stephen Boyd <sboyd@kernel.org>
Cc: Brian Masney <bmasney+clk@redhat.com>,
Jerome Brunet <jbrunet+clk@baylibre.com>,
Andrea della Porta <andrea.porta@suse.com>,
linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Joshua Covington <joshuacov@gmail.com>
Subject: [PATCH v2] clk: rp1: allow the clock provider to be probed again
Date: Sat, 21 Nov 2026 18:16:50 +0000 [thread overview]
Message-ID: <20261121181650.143474-1-joshuacov@gmail.com> (raw)
The clock descriptors are static. The clock core clears hw.init when a
clock is registered. When RP1 is unbound and bound again, the second
probe registers the clocks without init data and oopses:
pc : __clk_register+0x5c/0x9dc
Call trace:
__clk_register+0x5c/0x9dc (P)
devm_clk_hw_register+0x5c/0xe0
rp1_register_pll+0x24/0x40
rp1_clk_probe+0xc0/0x168
The clock core also leaves hw.core pointing to the freed clk_core on
unregister. Some clocks refer to a parent that is registered after
them, e.g. clk_mipi0_dpi to clksrc_mipi0_dsi_byteclk. On the second
probe, their parent lookup can use the stale clk_core.
Restore hw.init and clear the stale state of all descriptors before
registering them.
Fixes: 6486341721a2 ("clk: rp1: Add support for clocks provided by RP1")
Signed-off-by: Joshua Covington <joshuacov@gmail.com>
---
v2:
- Also clear hw.core, div.hw.core and cached_rate of all descriptors
before registering them (Sashiko review)
v1: https://lore.kernel.org/all/20261121163915.86681-1-joshuacov@gmail.com/
drivers/clk/clk-rp1.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/clk/clk-rp1.c b/drivers/clk/clk-rp1.c
index 1dd276dd2b..c261306dcd 100644
--- a/drivers/clk/clk-rp1.c
+++ b/drivers/clk/clk-rp1.c
@@ -363,6 +363,7 @@ struct rp1_clk_desc {
struct rp1_clk_desc *desc);
const void *data;
struct clk_hw hw;
+ const struct clk_init_data *init;
struct rp1_clockman *clockman;
unsigned long cached_rate;
struct clk_divider div;
@@ -2416,6 +2417,18 @@ static int rp1_clk_probe(struct platform_device *pdev)
clockman->onecell.num = asize;
hws = clockman->onecell.hws;
+ for (i = 0; i < asize; i++) {
+ desc = clk_desc_array[i];
+ if (!desc)
+ continue;
+ if (!desc->init)
+ desc->init = desc->hw.init;
+ desc->hw.init = desc->init;
+ desc->hw.core = NULL;
+ desc->div.hw.core = NULL;
+ desc->cached_rate = 0;
+ }
+
for (i = 0; i < asize; i++) {
desc = clk_desc_array[i];
if (desc && desc->clk_register && desc->data)
--
2.56.0
reply other threads:[~2026-11-21 18:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261121181650.143474-1-joshuacov@gmail.com \
--to=joshuacov@gmail.com \
--cc=andrea.porta@suse.com \
--cc=bmasney+clk@redhat.com \
--cc=jbrunet+clk@baylibre.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.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
all inboxes | Powered by JetHome®