devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafał Miłecki" <zajec5@gmail.com>
To: linux-clk@vger.kernel.org, Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	BCM Kernel Feedback <bcm-kernel-feedback-list@broadcom.com>
Cc: Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	Florian Fainelli <f.fainelli@gmail.com>
Subject: Re: clk & clock-controller@ DT nodes: __clk_core_init: clk clock-controller already initialized
Date: Tue, 23 Nov 2021 13:09:46 +0100	[thread overview]
Message-ID: <51926a0e-4d01-7361-8f18-62d56eaaa398@gmail.com> (raw)
In-Reply-To: <67ebc933-3c93-99b1-9dfc-7166cfa1f7a8@gmail.com>

On 23.11.2021 11:20, Rafał Miłecki wrote:
> On 23.11.2021 11:09, Rafał Miłecki wrote:
>> [    0.000000] __clk_core_init: clk clock-controller already initialized
>> [    0.000000] ------------[ cut here ]------------
>> [    0.000000] WARNING: CPU: 0 PID: 0 at drivers/clk/bcm/clk-iproc-pll.c:802 iproc_pll_clk_setup+0x4c8/0x4f4
>> [    0.000000] Modules linked in:
>> [    0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.10.80 #0
>> [    0.000000] Hardware name: BCM5301X
>> [    0.000000] [<c0108410>] (unwind_backtrace) from [<c0104bc4>] (show_stack+0x10/0x14)
>> [    0.000000] [<c0104bc4>] (show_stack) from [<c03dca28>] (dump_stack+0x94/0xa8)
>> [    0.000000] [<c03dca28>] (dump_stack) from [<c0118440>] (__warn+0xb8/0x114)
>> [    0.000000] [<c0118440>] (__warn) from [<c0118504>] (warn_slowpath_fmt+0x68/0x78)
>> [    0.000000] [<c0118504>] (warn_slowpath_fmt) from [<c043281c>] (iproc_pll_clk_setup+0x4c8/0x4f4)
>> [    0.000000] [<c043281c>] (iproc_pll_clk_setup) from [<c0818c04>] (nsp_genpll_clk_init+0x30/0x38)
>> [    0.000000] [<c0818c04>] (nsp_genpll_clk_init) from [<c0818634>] (of_clk_init+0x118/0x1f8)
>> [    0.000000] [<c0818634>] (of_clk_init) from [<c08039b0>] (time_init+0x24/0x30)
>> [    0.000000] [<c08039b0>] (time_init) from [<c0800d14>] (start_kernel+0x398/0x50c)
>> [    0.000000] [<c0800d14>] (start_kernel) from [<00000000>] (0x0)
>> [    0.000000] ---[ end trace fe236bfe9559ee50 ]---
>>
>> It seems that Linux's clock name is derived from DT node. With multiple
>> clock-controller@ nodes there is a name conflict as seen above.
>>
>>  From DT perspective I don't think there is anything wrong in having
>> multiple nodes using the same name prefix.
>>
>> Could clk subsystem be somehow improved to be more /creative/ at picking
>> clock names? ;) Would someone be kind to take a look at this, please?
> 
> Ah, I've just realized it's not clk subsystem but actually a clk driver
> that picks up a name based on DT node name.
> 
> iproc_pll_clk_setup() does:
> init.name = node->name;
> 
> I should have double check that before sending my e-mail.
> 
> I can't see any helper picking a clock unique name based on DT node.
> Any advise how to proceed with that?

I've tried a simple patch switching from "name" to "full_name".

That results in registering "clock-controller@100" and
"clock-controller@160" clocks (I can see them in /sys/kernel/debug/clk/)

They seem to work fine:
# cat /sys/kernel/debug/clk/clock-controller@140/clk_rate
2000000000
# cat /sys/kernel/debug/clk/clock-controller@100/clk_rate
3200000000

It seems however that output clocks are broken:
# cat /sys/kernel/debug/clk/usbclk/clk_rate
0

For some reason iproc_clk_recalc_rate() gets called with "parent_rate"
argument 0 whenever clocks aren't named "lcpll0" and "genpll". I'm not
sure why it happens. I don't see any code referencing clocks by
hardcoded names "lcpll0" and "genpll".


--- a/drivers/clk/bcm/clk-iproc-pll.c
+++ b/drivers/clk/bcm/clk-iproc-pll.c
@@ -783,7 +783,7 @@ void iproc_pll_clk_setup(struct device_n
  	iclk = &iclk_array[0];
  	iclk->pll = pll;

-	init.name = node->name;
+	init.name = node->full_name;
  	init.ops = &iproc_pll_ops;
  	init.flags = 0;
  	parent_name = of_clk_get_parent_name(node, 0);


      reply	other threads:[~2021-11-23 12:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-23 10:09 clk & clock-controller@ DT nodes: __clk_core_init: clk clock-controller already initialized Rafał Miłecki
2021-11-23 10:20 ` Rafał Miłecki
2021-11-23 12:09   ` Rafał Miłecki [this message]

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=51926a0e-4d01-7361-8f18-62d56eaaa398@gmail.com \
    --to=zajec5@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=rjui@broadcom.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=sbranden@broadcom.com \
    /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;
as well as URLs for NNTP newsgroup(s).