* [PATCH] drm/vc4: dsi: Register the PHY clock provider with devm
@ 2026-11-17 23:41 Henry Zhang
0 siblings, 0 replies; only message in thread
From: Henry Zhang @ 2026-11-17 23:41 UTC (permalink / raw)
To: mripard, dave.stevenson, mcanal
Cc: kernel-list, maarten.lankhorst, tzimmermann, airlied, simona,
dri-devel, linux-kernel, henryzhang62
vc4_dsi_init_phy_clocks() is called from the component bind. It
allocates the clock data with devm_kzalloc() and registers the clocks
with devm_clk_hw_register(), so both are released with the devres group
that the component framework opens for the bind, when the bind fails
later or the component is unbound. The OF clock provider that points at
that data is added with of_clk_add_hw_provider() and never removed:
after an unbind it stays registered with the freed data, and each new
bind adds another provider for the same node. A later lookup of one of
these clocks, such as <&dsi1 0>, would call of_clk_hw_onecell_get() on
freed memory.
Use devm_of_clk_add_hw_provider(), so that the provider is removed with
the same devres group, before the clocks and their data.
The analysis, this change and this description were prepared with the
help of an AI coding assistant (Claude Code).
Fixes: 4078f5757144 ("drm/vc4: Add DSI driver")
Signed-off-by: Henry Zhang <henryzhang62@gmail.com>
---
Found by the Sashiko review of
<20261117205902.1293962-1-henryzhang62@gmail.com>; independent of that
patch.
Testing:
- On this base (drm-misc-next 467ac0b56aeb): arm64, DRM_VC4=m, W=1, no
new warnings.
- On a Raspberry Pi 4 with a downstream 6.18.34 kernel and an
out-of-tree modular DSI panel driver, with kprobes on the provider
functions, reloading the panel driver (which unbinds and binds vc4):
- without the change, each bind adds a provider for the DSI node and
nothing removes it;
- with the change, each unbind removes it (from devres_release_group()
in component_unbind()), each bind adds one, and the DSI PHY clocks
are back after each bind;
- a bind that fails after the provider is added (with the old DRM
device held open, on a kernel that also has a backport of "drm/vc4:
dsi: Allocate the encoder per DRM device", where the bind fails in
drm_bridge_attach()) removes it again (devres_release_group() in
component_bind_all()), and binding again after the old DRM device is
closed works.
No warnings. In these tests no clock lookup went to the DSI node, so a
lookup on a stale provider was not reproduced.
drivers/gpu/drm/vc4/vc4_dsi.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c
index ec008f766..ed99cec9f 100644
--- a/drivers/gpu/drm/vc4/vc4_dsi.c
+++ b/drivers/gpu/drm/vc4/vc4_dsi.c
@@ -1592,9 +1592,8 @@ vc4_dsi_init_phy_clocks(struct vc4_dsi *dsi)
dsi->clk_onecell->hws[i] = &fix->hw;
}
- return of_clk_add_hw_provider(dev->of_node,
- of_clk_hw_onecell_get,
- dsi->clk_onecell);
+ return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
+ dsi->clk_onecell);
}
static void vc4_dsi_dma_mem_release(void *ptr)
base-commit: 467ac0b56aebc804360f276feffbc9032c265a6e
--
2.47.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-17 23:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 23:41 [PATCH] drm/vc4: dsi: Register the PHY clock provider with devm Henry Zhang
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®