| Message ID | 20260115031114.220888-2-chiffathefoxx@gmail.com |
|---|---|
| State | Needs Review / ACK |
| Delegated to: | Tom Rini |
| Headers | show |
| Series | Improvements to the recent clock rework by marex. | expand |
On 1/15/26 4:11 AM, chiffathefox wrote: > When referencing clocks in DTS registered by another driver, > clk_resolve_parent_clk() is supposed to return the name > of the child device that provides the requested clock. > However, in reality, it returns the name of the parent DTB > node (e.g. clock-controller@1a240000). Such devices, for > instance the exynos7870-cmu-peri driver, do not store any > clock information in their dev->uclass_priv_ because they > expect you to call dev->ops->get_rate with the appropriate > clk->id. So when you try to resolve a clock that depends on > an externally referenced clock, the resolution fails on the > parent clock because it doesn't have a dev->uclass_priv_. > With this change clk_resolve_parent_clk() will take an > extra step to actually resolve the child device. > > Signed-off-by: chiffathefox <chiffathefoxx@gmail.com> > --- > > drivers/clk/clk-uclass.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c > index 0584429bed6..bea45fc396f 100644 > --- a/drivers/clk/clk-uclass.c > +++ b/drivers/clk/clk-uclass.c > @@ -430,6 +430,7 @@ clk_resolve_parent_clk(struct udevice *dev, const char *name) > { > struct udevice *parent; > struct clk clk; > + struct clk *c; > int ret; > > ret = uclass_get_device_by_name(UCLASS_CLK, name, &parent); > @@ -440,7 +441,11 @@ clk_resolve_parent_clk(struct udevice *dev, const char *name) > if (!clk.dev) > return name; > > - return clk.dev->name; > + ret = clk_get_by_id(clk.id, &c); > + if (ret) > + return name; > + > + return c->dev->name; > } > > int clk_release_all(struct clk *clk, unsigned int count) The issue description looks very similar to what this commit fixes: 0e9055b1488f ("clk: scmi: Fix priv initialization in scmi_clk_gate()") Is this related ? Can you share an example / test which triggers the problem ? (ideally, use sandbox or sandbox64, that would make it reproducible for others too) Thank you +CC Peng/Patrice.
On 2026-01-15 05:11 +02:00, chiffathefox wrote: > When referencing clocks in DTS registered by another driver, > clk_resolve_parent_clk() is supposed to return the name > of the child device that provides the requested clock. > However, in reality, it returns the name of the parent DTB > node (e.g. clock-controller@1a240000). Such devices, for > instance the exynos7870-cmu-peri driver, do not store any > clock information in their dev->uclass_priv_ because they > expect you to call dev->ops->get_rate with the appropriate > clk->id. So when you try to resolve a clock that depends on > an externally referenced clock, the resolution fails on the > parent clock because it doesn't have a dev->uclass_priv_. > With this change clk_resolve_parent_clk() will take an > extra step to actually resolve the child device. > > Signed-off-by: chiffathefox <chiffathefoxx@gmail.com> Tested-by: Kaustabh Chakraborty <kauschluss@disroot.org> # exynos-mobile/exynos7870
diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c index 0584429bed6..bea45fc396f 100644 --- a/drivers/clk/clk-uclass.c +++ b/drivers/clk/clk-uclass.c @@ -430,6 +430,7 @@ clk_resolve_parent_clk(struct udevice *dev, const char *name) { struct udevice *parent; struct clk clk; + struct clk *c; int ret; ret = uclass_get_device_by_name(UCLASS_CLK, name, &parent); @@ -440,7 +441,11 @@ clk_resolve_parent_clk(struct udevice *dev, const char *name) if (!clk.dev) return name; - return clk.dev->name; + ret = clk_get_by_id(clk.id, &c); + if (ret) + return name; + + return c->dev->name; } int clk_release_all(struct clk *clk, unsigned int count)
When referencing clocks in DTS registered by another driver, clk_resolve_parent_clk() is supposed to return the name of the child device that provides the requested clock. However, in reality, it returns the name of the parent DTB node (e.g. clock-controller@1a240000). Such devices, for instance the exynos7870-cmu-peri driver, do not store any clock information in their dev->uclass_priv_ because they expect you to call dev->ops->get_rate with the appropriate clk->id. So when you try to resolve a clock that depends on an externally referenced clock, the resolution fails on the parent clock because it doesn't have a dev->uclass_priv_. With this change clk_resolve_parent_clk() will take an extra step to actually resolve the child device. Signed-off-by: chiffathefox <chiffathefoxx@gmail.com> --- drivers/clk/clk-uclass.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)