Re: [PATCH v2 1/2] clk: ti: mux: resolve parent clocks by DT index, not by name

Geert Uytterhoeven <[email protected]>
Newsgroups org.kernel.vger.linux-omap,org.kernel.vger.linux-clk,org.kernel.vger.linux-kernel
Message-ID <CAMuHMdVfFZ0P9Na-yD9EzBaUqkyiwjo8byxA2MouBt1DM8xQtA@mail.gmail.com>
Hi Mathieu,

On Wed, 19 Aug 2026 at 07:39, Mathieu Dubois-Briand
<[email protected]> wrote:
> On Tue Aug 18, 2026 at 6:02 PM CEST, Geert Uytterhoeven wrote:
> > On Mon, 27 Jul 2026 at 09:44, Mathieu Dubois-Briand
> > <[email protected]> wrote:
> >> Resolve parent clocks by their index into the device tree "clocks"
> >> property rather than matching names as strings. Name-based matching is
> >> fragile because a clock's "clock-output-names" value in its provider
> >> node can differ from the name used to reference it in a consumer node,
> >> and because names must be globally unique across all clock providers.
> >>
> >> On AM335x, this caused broken clock trees where some clocks failed to
> >> enable because their parents could not be found.
> >>
> >> Replace of_clk_parent_fill() with a clk_parent_data array that sets
> >> .index to the array position.
> >>
> >> Fixes: ec7aa25fa483 ("ARM: dts: Use clock-output-names for am3")
> >> Signed-off-by: Mathieu Dubois-Briand <[email protected]>
> >
> > Thanks for your patch, which is now commit 667f420c09f1417c ("clk: ti:
> > mux: resolve parent clocks by DT index, not by name") in clk/clk-next.
> >
> > This breaks booting BeagleBone Black for me: I don't get any output
> > on the serial console, even with "earlycon keep_bootcon".  When the
> > watchdog kicks in (or on kernel panic?), the system reboots.
>
> Sorry for that!
>
> It's a bit unexpected, as the beaglebone black was one of my test
> platforms and I didn't see any issue.
>
> > Reverting this commit fixes the issue.
> > After reverting, I added debug code to print all parents, and compared
> > them to the DTB, but didn't see any discrepancies.
> >
> > Your similar change to drivers/clk/ti/composite.c does not cause any
> > issues for me.
> >
> > Do you have a clue?
> > Thanks!
>
> Can you describe what bootloader and device tree you are using for your
> tests? Any specific configuration?
>
> On my side, I have:
> - BeagleBone Black Wireless A5
> - am335x-boneblack-wireless.dtb
> - U-boot 2025.10-ti-g6825d60bea17. Maybe I should try with u-boot master
>   branch.

BeagleBone Black Rev C3 (by Seeed Studio)
am335x-boneblack.dtb
Stock U-Boot SPL 2019.04-00002-g31a8ae0206 (May 13 2020 - 09:26:17 -0500)

I am using my own config.

With omap2plus_defconfig and multi_v7_defconfig, it does boot.  However,
this commit does have an impact on /sys/kernel/debug/clk/clk_summary:

--- summary-7.2.0-rc2-00106-g0d4d262c1664       2026-08-19
10:56:51.622275674 +0200
+++ summary-7.2.0-rc2-00107-g667f420c09f1       2026-08-19
10:58:13.929823890 +0200
@@ -77,10 +77,14 @@
 clk_summary:

deviceless                      no_connection_id
 clk_summary:                clkdiv32k_ck         0       1        0
     32786       0          0     50000      Y
deviceless                      of_clk_get_from_provider
 clk_summary:

deviceless                      no_connection_id
-clk_summary:                   clk-24mhz-clkctrl:0000:0 0       4
   0        32786       0          0     50000      N
   deviceless                      clkdiv32k_ick
+clk_summary:                   clk-24mhz-clkctrl:0000:0 0       5
   0        32786       0          0     50000      N
   deviceless                      clkdiv32k_ick
 clk_summary:

deviceless                      of_clk_get_from_provider
 clk_summary:

deviceless                      of_clk_get_from_provider
 clk_summary:

deviceless                      no_connection_id
+clk_summary:                      wdt1_fck       0       1        0
     32786       0          0     50000      Y
deviceless                      wdt1_fck
+clk_summary:

deviceless                      no_connection_id
+clk_summary:                         l4-wkup-clkctrl:00d4:0 0       1
       0        32786       0          0     50000      N
             44e35000.target-module          fck
+clk_summary:

  deviceless                      no_connection_id
 clk_summary:                      l4-rtc-clkctrl:0000:0 0       1
   0        32786       0          0     50000      N
      44e3e074.target-module          fck
 clk_summary:

deviceless                      no_connection_id
 clk_summary:                      l4ls-clkctrl:0074:18 0       2
  0        32786       0          0     50000      N
     4804c000.gpio                   dbclk
@@ -297,17 +301,13 @@
 clk_summary:       l4-cefuse-clkctrl:0020:0      0       0        0
     24000000    0          0     50000      N         deviceless
                no_connection_id
 clk_summary: virt_19200000_ck                    0       0        0
     19200000    0          0     50000      Y   deviceless
          of_clk_get_from_provider
 clk_summary:
                                                 deviceless
          no_connection_id
-clk_summary: clk_rc32k_ck                        0       2        0
     32000       0          0     50000      Y   deviceless
          of_clk_get_from_provider
+clk_summary: clk_rc32k_ck                        0       1        0
     32000       0          0     50000      Y   deviceless
          of_clk_get_from_provider
 clk_summary:
                                                 deviceless
          no_connection_id
 clk_summary:    gpio0_dbclk_mux_ck               0       1        0
     32000       0          0     50000      Y      deviceless
             no_connection_id
 clk_summary:       l4-wkup-clkctrl:0008:18       0       2        0
     32000       0          0     50000      N         44e07000.gpio
                dbclk
 clk_summary:

44e07000.target-module          dbclk
 clk_summary:
                                                       deviceless
                of_clk_get_from_provider
 clk_summary:
                                                       deviceless
                no_connection_id
-clk_summary:    wdt1_fck                         0       1        0
     32000       0          0     50000      Y      deviceless
             wdt1_fck
-clk_summary:
                                                    deviceless
             no_connection_id
-clk_summary:       l4-wkup-clkctrl:00d4:0        0       1        0
     32000       0          0     50000      N
44e35000.target-module          fck
-clk_summary:
                                                       deviceless
                no_connection_id
 clk_summary: clk_32768_ck                        1       1        0
     32768       0          0     50000      Y   deviceless
          of_clk_get_from_provider
 clk_summary:
                                                 deviceless
          no_connection_id
 clk_summary:    sysclkout_pre_ck                 1       1        0
     32768       0          0     50000      Y      deviceless
             no_connection_id

I.e. wdt1_fck changed its parent from clk_rc32k_ck to
clk-24mhz-clkctrl:0000:0, which is probably not intended?

However, that is not the cause of the crash.  My .config has
CONFIG_INIT_STACK_ALL_PATTERN enabled, so any uninitialized local
variables contain garbage.

> @@ -136,7 +136,7 @@ static struct clk *_register_mux(struct device_node *node, const char *name,
>         init.name = name;
>         init.ops = &ti_clk_mux_ops;
>         init.flags = flags;
> -       init.parent_names = parent_names;
> +       init.parent_data = parent_data;
>         init.num_parents = num_parents;
>
>         /* struct clk_mux assignments

Init is not fully initialized, hence init.parent_names contains garbage
(before, .parent_data contained garbage).
As clk_core_populate_parent_map() prioritizes .parent_names over
.parent_data, the uninitialized .parent_data didn't cause any harm before.

I will send a patch to fix this.  This seems to be a recurring issue:
lots of clk_init_data structures are not fully initialized...

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.