lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240819-education-prong-3da4b83d42ed@thorsis.com>
Date: Mon, 19 Aug 2024 16:33:19 +0200
From: Alexander Dahl <ada@...rsis.com>
To: linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org,
	Claudiu Beznea <claudiu.beznea@...on.dev>,
	linux-arm-kernel@...ts.infradead.org
Cc: Boris Brezillon <bbrezillon@...nel.org>,
	Alexandre Belloni <alexandre.belloni@...tlin.com>,
	Nicolas Ferre <nicolas.ferre@...rochip.com>
Subject: Re: get, prepare, enable a clock not in DT?

Hello everyone,

Am Fri, Aug 16, 2024 at 04:34:48PM +0200 schrieb Alexander Dahl:
> Hello everyone,
> 
> while further investigating timeout issues with the at91 otpc
> controller on sam9x60 [1] I came to the conclusion the main RC
> oscillator on that SoC must be enabled for that driver to work.
> (Verified that by poking single bits in registers through devmem
> already.)
> 
> Fortunately the necessary clk is already registered from the SoC code
> in drivers/clk/at91/sam9x60.c [2] and I can see the clock in sysfs clk
> summary:
> 
>     root@...troKit:~ head -n4 /sys/kernel/debug/clk/clk_summary 
>                                      enable  prepare  protect                                duty  hardware                            connection
>        clock                          count    count    count        rate   accuracy phase  cycle    enable   consumer                         id
>     ---------------------------------------------------------------------------------------------------------------------------------------------
>      main_rc_osc                         0       0        0        12000000    50000000   0     50000      Y   deviceless                      no_connection_id         
> 
> That clock has no parent and is not found anywhere in devicetree, nor
> is it handled by the two clock-producers on that platform, so
> from within mchp_otpc_probe() I just tried this:
> 
>     otpc->clk = devm_clk_get_enabled(&pdev->dev, "main_rc_osc");
> 
> However that returns with -ENOENT, so I assume I can not reference the
> clock just by name?  Same result with this:
> 
>     otpc->clk = devm_clk_get_enabled(NULL, "main_rc_osc");
> 
> How do I get a pointer to that clk then to enable it?  Docs [3] where
> not as useful as I hoped for, neither was clk.h header docs. :-/

Tried this today:

    otpc->clk = __clk_lookup("main_rc_osc");

However calling that from platform driver code smells suspicious and I
get a linker error when building anyways.

Found no other possibility to get a grip on that clock from driver
code.  Do we need to hook that main_rc_osc into dt somehow so it can be
enabled from driver code?

Adding Boris, Alexandre, and Nicolas to Cc, because they were involved
in the at91 clk drivers in the past.  O:-)

Greets
Alex

> From what I understood from header docs reading 'device for clock
> "consumer"' I must pass the device from which I call that clk_get() as
> first parameter, so this would be the otpc device then, right?  What's
> that second parameter clock consumer id then?  Are these terms
> explained somewhere?
> 
> Greets
> Alex
> 
> [1] <20240813-payable-ecology-8a9e739704bb@...rsis.com>
> [2] https://elixir.bootlin.com/linux/v6.10.4/source/drivers/clk/at91/sam9x60.c#L217
> [3] https://kernel.org/doc/html/latest/driver-api/clk.html
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ