From: Joshua Covington <joshuacov@gmail.com>
To: masneyb@kernel.org
Cc: sboyd@kernel.org, bmasney+clk@redhat.com,
jbrunet+clk@baylibre.com, andrea.porta@suse.com,
linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] clk: rp1: allow the clock provider to be probed again
Date: Mon, 23 Nov 2026 23:38:27 +0000 [thread overview]
Message-ID: <20261123233827.61587-1-joshuacov@gmail.com> (raw)
In-Reply-To: <179545567027.246915.947299820828330388.b4-review@b4>
Hi Brian,
On Mon, Nov 23, 2026 at 12:41:10PM -0500, Brian Masney wrote:
> There's presumably other drivers that will have the same issue as well.
> Rather than having drivers all try to fix this themselves, let's see if
> we can fix this in the core for everyone. Can you try this completely
> untested patch? If that works, then you can take it over. It will need a
> kunit test.
Thanks a lot, it works. I tested it on my Raspberry Pi CM5 (currently
6.18.64 with the Raspberry Pi downstream patches) with your patch
instead of the clk-rp1 change. Unbinding and binding the RP1 PCI device
again, which oopsed in __clk_register() before, now brings all RP1
peripherals back without any warning.
I also wrote three KUnit tests for the following:
- registering, unregistering and registering the same clk_hw again;
- hw->init being restored when registration fails (-EEXIST on a
duplicate name);
- a parent referenced through clk_parent_data.hw being an orphan after
it has been unregistered, and reparented once it is registered again.
They pass on the CM5 and on QEMU x86_64 with KASAN. Without your patch,
the first two oops on the NULL init data, and the third reports a
slab-use-after-free in __clk_register().
I noticed two things while reading it:
- clk_unregister() now writes to the clk_hw. So far it only touched it
through ops->terminate, so a driver that frees its clk_hw before
unregistering it may now write to freed memory.
- hw->init is also restored when the clk_init_data was on the stack of
the registering function, so after unregistering it can point to a
dead stack frame. That only matters for a driver that registers the
clk_hw again without setting hw->init first, as the updated comment
in clk-provider.h says.
On the CM5, clk-rp1 also keeps a cached rate per clock that survives a
rebind, so I added a small clk-rp1 patch that resets it on probe.
I'll rebase on clk-next and send a series with your change, the tests
and the clk-rp1 patch. How would you like to be credited for the core
change? If you add your Signed-off-by, I'll keep you as the author;
otherwise I'll use Suggested-by.
Thanks,
Joshua
next prev parent reply other threads:[~2026-11-23 23:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 18:16 Joshua Covington
2026-11-23 17:41 ` Brian Masney
2026-11-23 23:38 ` Joshua Covington [this message]
2026-11-24 0:44 ` Brian Masney
2026-11-24 0:48 ` Brian Masney
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=20261123233827.61587-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=masneyb@kernel.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®