* [PATCH v2 0/2] Fix orphan clocks in clk-th1520-ap driver @ 2025-07-10 9:21 Yao Zi 2025-07-10 9:21 ` [PATCH v2 1/2] clk: thead: th1520-ap: Correctly refer the parent of osc_12m Yao Zi 2025-07-10 9:21 ` [PATCH v2 2/2] clk: thead: th1520-ap: Correctly refer the parent of c910-i0 Yao Zi 0 siblings, 2 replies; 7+ messages in thread From: Yao Zi @ 2025-07-10 9:21 UTC (permalink / raw) To: Drew Fustini, Guo Ren, Fu Wei, Michael Turquette, Stephen Boyd, Jisheng Zhang, Yangtao Li Cc: linux-riscv, linux-clk, linux-kernel, Yao Zi clk_orphan_dump shows two suspicious orphan clocks on TH1520 when booting the kernel with mainline U-Boot, $ cat /sys/kernel/debug/clk/clk_orphan_dump | jq 'keys' [ "c910", "osc_12m" ] where the correct parents should be c910-i0 for c910, and osc_24m for osc_12m. Note that the c910's case cannot be reproduced with vendor U-Boot, which always reparents c910 to its second parent, cpu-pll1. Another way to confirm the bug is to examine /sys/kernel/debug/clk/c910/clk_possible_parents, which obviously doesn't match c910's definition. This series corrects the parent description of these two clocks to eliminate the orphans. Changed from v1 - Split the two fixes into separate patches - Add a static qualifier for the new definition of osc_12m - Link to v1: https://lore.kernel.org/all/20250705052028.24611-1-ziyao@disroot.org/ Thanks for your time and review. Yao Zi (2): clk: thead: th1520-ap: Correctly refer the parent of osc_12m clk: thead: th1520-ap: Correctly refer the parent of c910-i0 drivers/clk/thead/clk-th1520-ap.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) -- 2.50.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] clk: thead: th1520-ap: Correctly refer the parent of osc_12m 2025-07-10 9:21 [PATCH v2 0/2] Fix orphan clocks in clk-th1520-ap driver Yao Zi @ 2025-07-10 9:21 ` Yao Zi 2025-07-10 21:00 ` Drew Fustini 2025-07-10 9:21 ` [PATCH v2 2/2] clk: thead: th1520-ap: Correctly refer the parent of c910-i0 Yao Zi 1 sibling, 1 reply; 7+ messages in thread From: Yao Zi @ 2025-07-10 9:21 UTC (permalink / raw) To: Drew Fustini, Guo Ren, Fu Wei, Michael Turquette, Stephen Boyd, Jisheng Zhang, Yangtao Li Cc: linux-riscv, linux-clk, linux-kernel, Yao Zi The "osc_12m" fixed factor clock refers the external oscillator by setting clk_parent_data.fw_name to osc_24m, which is obviously wrong since no clock-names property is allowed for compatible thead,th1520-clk-ap. Refer the oscillator as parent by index instead. Fixes: ae81b69fd2b1 ("clk: thead: Add support for T-Head TH1520 AP_SUBSYS clocks") Signed-off-by: Yao Zi <ziyao@disroot.org> --- drivers/clk/thead/clk-th1520-ap.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/clk/thead/clk-th1520-ap.c b/drivers/clk/thead/clk-th1520-ap.c index ebfb1d59401d..42feb4bb6329 100644 --- a/drivers/clk/thead/clk-th1520-ap.c +++ b/drivers/clk/thead/clk-th1520-ap.c @@ -582,7 +582,14 @@ static const struct clk_parent_data peri2sys_apb_pclk_pd[] = { { .hw = &peri2sys_apb_pclk.common.hw } }; -static CLK_FIXED_FACTOR_FW_NAME(osc12m_clk, "osc_12m", "osc_24m", 2, 1, 0); +static struct clk_fixed_factor osc12m_clk = { + .div = 2, + .mult = 1, + .hw.init = CLK_HW_INIT_PARENTS_DATA("osc_12m", + osc_24m_clk, + &clk_fixed_factor_ops, + 0), +}; static const char * const out_parents[] = { "osc_24m", "osc_12m" }; -- 2.50.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] clk: thead: th1520-ap: Correctly refer the parent of osc_12m 2025-07-10 9:21 ` [PATCH v2 1/2] clk: thead: th1520-ap: Correctly refer the parent of osc_12m Yao Zi @ 2025-07-10 21:00 ` Drew Fustini 2025-07-13 19:57 ` Drew Fustini 0 siblings, 1 reply; 7+ messages in thread From: Drew Fustini @ 2025-07-10 21:00 UTC (permalink / raw) To: Yao Zi Cc: Guo Ren, Fu Wei, Michael Turquette, Stephen Boyd, Jisheng Zhang, Yangtao Li, linux-riscv, linux-clk, linux-kernel On Thu, Jul 10, 2025 at 09:21:34AM +0000, Yao Zi wrote: > The "osc_12m" fixed factor clock refers the external oscillator by > setting clk_parent_data.fw_name to osc_24m, which is obviously wrong > since no clock-names property is allowed for compatible > thead,th1520-clk-ap. > > Refer the oscillator as parent by index instead. > > Fixes: ae81b69fd2b1 ("clk: thead: Add support for T-Head TH1520 AP_SUBSYS clocks") > Signed-off-by: Yao Zi <ziyao@disroot.org> > --- > drivers/clk/thead/clk-th1520-ap.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/clk/thead/clk-th1520-ap.c b/drivers/clk/thead/clk-th1520-ap.c > index ebfb1d59401d..42feb4bb6329 100644 > --- a/drivers/clk/thead/clk-th1520-ap.c > +++ b/drivers/clk/thead/clk-th1520-ap.c > @@ -582,7 +582,14 @@ static const struct clk_parent_data peri2sys_apb_pclk_pd[] = { > { .hw = &peri2sys_apb_pclk.common.hw } > }; > > -static CLK_FIXED_FACTOR_FW_NAME(osc12m_clk, "osc_12m", "osc_24m", 2, 1, 0); > +static struct clk_fixed_factor osc12m_clk = { > + .div = 2, > + .mult = 1, > + .hw.init = CLK_HW_INIT_PARENTS_DATA("osc_12m", > + osc_24m_clk, > + &clk_fixed_factor_ops, > + 0), > +}; > > static const char * const out_parents[] = { "osc_24m", "osc_12m" }; > > -- > 2.50.0 Reviewed-by: Drew Fustini <fustini@kernel.org> Thanks for fixing this. osc_12m now appears under osc_24m in clk_summary. Drew ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] clk: thead: th1520-ap: Correctly refer the parent of osc_12m 2025-07-10 21:00 ` Drew Fustini @ 2025-07-13 19:57 ` Drew Fustini 0 siblings, 0 replies; 7+ messages in thread From: Drew Fustini @ 2025-07-13 19:57 UTC (permalink / raw) To: Yao Zi Cc: Guo Ren, Fu Wei, Michael Turquette, Stephen Boyd, Jisheng Zhang, Yangtao Li, linux-riscv, linux-clk, linux-kernel On Thu, Jul 10, 2025 at 02:00:06PM -0700, Drew Fustini wrote: > On Thu, Jul 10, 2025 at 09:21:34AM +0000, Yao Zi wrote: > > The "osc_12m" fixed factor clock refers the external oscillator by > > setting clk_parent_data.fw_name to osc_24m, which is obviously wrong > > since no clock-names property is allowed for compatible > > thead,th1520-clk-ap. > > > > Refer the oscillator as parent by index instead. > > > > Fixes: ae81b69fd2b1 ("clk: thead: Add support for T-Head TH1520 AP_SUBSYS clocks") > > Signed-off-by: Yao Zi <ziyao@disroot.org> > > --- > > drivers/clk/thead/clk-th1520-ap.c | 9 ++++++++- > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/clk/thead/clk-th1520-ap.c b/drivers/clk/thead/clk-th1520-ap.c > > index ebfb1d59401d..42feb4bb6329 100644 > > --- a/drivers/clk/thead/clk-th1520-ap.c > > +++ b/drivers/clk/thead/clk-th1520-ap.c > > @@ -582,7 +582,14 @@ static const struct clk_parent_data peri2sys_apb_pclk_pd[] = { > > { .hw = &peri2sys_apb_pclk.common.hw } > > }; > > > > -static CLK_FIXED_FACTOR_FW_NAME(osc12m_clk, "osc_12m", "osc_24m", 2, 1, 0); > > +static struct clk_fixed_factor osc12m_clk = { > > + .div = 2, > > + .mult = 1, > > + .hw.init = CLK_HW_INIT_PARENTS_DATA("osc_12m", > > + osc_24m_clk, > > + &clk_fixed_factor_ops, > > + 0), > > +}; > > > > static const char * const out_parents[] = { "osc_24m", "osc_12m" }; > > > > -- > > 2.50.0 > > Reviewed-by: Drew Fustini <fustini@kernel.org> > > Thanks for fixing this. osc_12m now appears under osc_24m in > clk_summary. > > Drew Thank you for the patch. I've now applied it to thead-clk-for-next as commit d274c77ffa20 [1]. Drew [1] https://github.com/pdp7/linux/commit/d274c77ffa202b70ad01d579f33b73b4de123375 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] clk: thead: th1520-ap: Correctly refer the parent of c910-i0 2025-07-10 9:21 [PATCH v2 0/2] Fix orphan clocks in clk-th1520-ap driver Yao Zi 2025-07-10 9:21 ` [PATCH v2 1/2] clk: thead: th1520-ap: Correctly refer the parent of osc_12m Yao Zi @ 2025-07-10 9:21 ` Yao Zi 2025-07-11 8:52 ` Drew Fustini 1 sibling, 1 reply; 7+ messages in thread From: Yao Zi @ 2025-07-10 9:21 UTC (permalink / raw) To: Drew Fustini, Guo Ren, Fu Wei, Michael Turquette, Stephen Boyd, Jisheng Zhang, Yangtao Li Cc: linux-riscv, linux-clk, linux-kernel, Yao Zi The correct parent of c910, c910-i0, is registered with devm_clk_hw_register_mux_parent_data_table(), which creates a clk_hw structure from scratch. But it's assigned as c910's parent by referring &c910_i0_clk.common.hw, confusing the CCF since this clk_hw structure is never registered. Refer c910-i0 by its name instead to avoid turning c910 into an orphan clock. Fixes: ae81b69fd2b1 ("clk: thead: Add support for T-Head TH1520 AP_SUBSYS clocks") Signed-off-by: Yao Zi <ziyao@disroot.org> --- drivers/clk/thead/clk-th1520-ap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/thead/clk-th1520-ap.c b/drivers/clk/thead/clk-th1520-ap.c index 42feb4bb6329..41ed72b1a915 100644 --- a/drivers/clk/thead/clk-th1520-ap.c +++ b/drivers/clk/thead/clk-th1520-ap.c @@ -427,7 +427,7 @@ static struct ccu_mux c910_i0_clk = { }; static const struct clk_parent_data c910_parents[] = { - { .hw = &c910_i0_clk.common.hw }, + { .index = -1, .name = "c910-i0" }, { .hw = &cpu_pll1_clk.common.hw } }; -- 2.50.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] clk: thead: th1520-ap: Correctly refer the parent of c910-i0 2025-07-10 9:21 ` [PATCH v2 2/2] clk: thead: th1520-ap: Correctly refer the parent of c910-i0 Yao Zi @ 2025-07-11 8:52 ` Drew Fustini 2025-07-12 0:39 ` Yao Zi 0 siblings, 1 reply; 7+ messages in thread From: Drew Fustini @ 2025-07-11 8:52 UTC (permalink / raw) To: Yao Zi Cc: Guo Ren, Fu Wei, Michael Turquette, Stephen Boyd, Jisheng Zhang, Yangtao Li, linux-riscv, linux-clk, linux-kernel On Thu, Jul 10, 2025 at 09:21:35AM +0000, Yao Zi wrote: > The correct parent of c910, c910-i0, is registered with > devm_clk_hw_register_mux_parent_data_table(), which creates a clk_hw > structure from scratch. But it's assigned as c910's parent by > referring &c910_i0_clk.common.hw, confusing the CCF since this clk_hw > structure is never registered. > > Refer c910-i0 by its name instead to avoid turning c910 into an orphan > clock. > > Fixes: ae81b69fd2b1 ("clk: thead: Add support for T-Head TH1520 AP_SUBSYS clocks") > Signed-off-by: Yao Zi <ziyao@disroot.org> > --- > drivers/clk/thead/clk-th1520-ap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/clk/thead/clk-th1520-ap.c b/drivers/clk/thead/clk-th1520-ap.c > index 42feb4bb6329..41ed72b1a915 100644 > --- a/drivers/clk/thead/clk-th1520-ap.c > +++ b/drivers/clk/thead/clk-th1520-ap.c > @@ -427,7 +427,7 @@ static struct ccu_mux c910_i0_clk = { > }; > > static const struct clk_parent_data c910_parents[] = { > - { .hw = &c910_i0_clk.common.hw }, > + { .index = -1, .name = "c910-i0" }, Thanks for the patch. Unfortunately, I chatted with Stephen about this on irc and we need to avoid using strings in clk_parent_data. I'm trying to see how to correctly assign the pointer in the c910_parents[] after c910_io_clk has been registered. Thanks, Drew ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/2] clk: thead: th1520-ap: Correctly refer the parent of c910-i0 2025-07-11 8:52 ` Drew Fustini @ 2025-07-12 0:39 ` Yao Zi 0 siblings, 0 replies; 7+ messages in thread From: Yao Zi @ 2025-07-12 0:39 UTC (permalink / raw) To: Drew Fustini Cc: Guo Ren, Fu Wei, Michael Turquette, Stephen Boyd, Jisheng Zhang, Yangtao Li, linux-riscv, linux-clk, linux-kernel On Fri, Jul 11, 2025 at 01:52:15AM -0700, Drew Fustini wrote: > On Thu, Jul 10, 2025 at 09:21:35AM +0000, Yao Zi wrote: > > The correct parent of c910, c910-i0, is registered with > > devm_clk_hw_register_mux_parent_data_table(), which creates a clk_hw > > structure from scratch. But it's assigned as c910's parent by > > referring &c910_i0_clk.common.hw, confusing the CCF since this clk_hw > > structure is never registered. > > > > Refer c910-i0 by its name instead to avoid turning c910 into an orphan > > clock. > > > > Fixes: ae81b69fd2b1 ("clk: thead: Add support for T-Head TH1520 AP_SUBSYS clocks") > > Signed-off-by: Yao Zi <ziyao@disroot.org> > > --- > > drivers/clk/thead/clk-th1520-ap.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/clk/thead/clk-th1520-ap.c b/drivers/clk/thead/clk-th1520-ap.c > > index 42feb4bb6329..41ed72b1a915 100644 > > --- a/drivers/clk/thead/clk-th1520-ap.c > > +++ b/drivers/clk/thead/clk-th1520-ap.c > > @@ -427,7 +427,7 @@ static struct ccu_mux c910_i0_clk = { > > }; > > > > static const struct clk_parent_data c910_parents[] = { > > - { .hw = &c910_i0_clk.common.hw }, > > + { .index = -1, .name = "c910-i0" }, > > Thanks for the patch. Unfortunately, I chatted with Stephen about this > on irc and we need to avoid using strings in clk_parent_data. I'm trying > to see how to correctly assign the pointer in the c910_parents[] after > c910_io_clk has been registered. If we stop using *_register_mux() for all the muxes, the problem should go away: the key cause is that *_register_mux() always allocates a new clk_mux structure, which in turn contains a new clk_hw structure. We could avoid the ccu_mux structure, instead defining clk_muxes directly and register them with devm_clk_hw_register(), for example, static struct clk_mux c910_i0_clk = { .reg = 0x100, .mask = BIT(0), .shift = 1, .hw.init = CLK_HW_INIT_PARENT_DATA("c910-i0", c910_i0_parents, &clk_mux_ops, 0), }; c910_i0_clk.reg += base; ret = devm_clk_hw_register(dev, &c910_i0_clk.hw); (not tested, just for demostration) Now no new clk_hw structure is created and we could refer to muxes by its hw member when defining other clocks. > Thanks, > Drew Regards, Yao Zi ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-07-13 19:57 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-07-10 9:21 [PATCH v2 0/2] Fix orphan clocks in clk-th1520-ap driver Yao Zi 2025-07-10 9:21 ` [PATCH v2 1/2] clk: thead: th1520-ap: Correctly refer the parent of osc_12m Yao Zi 2025-07-10 21:00 ` Drew Fustini 2025-07-13 19:57 ` Drew Fustini 2025-07-10 9:21 ` [PATCH v2 2/2] clk: thead: th1520-ap: Correctly refer the parent of c910-i0 Yao Zi 2025-07-11 8:52 ` Drew Fustini 2025-07-12 0:39 ` Yao Zi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).