<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/clk/clk.c, branch linux-4.4.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.4.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.4.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2021-04-16T10:00:21Z</updated>
<entry>
<title>clk: fix invalid usage of list cursor in unregister</title>
<updated>2021-04-16T10:00:21Z</updated>
<author>
<name>Lukasz Bartosik</name>
</author>
<published>2021-04-01T22:51:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=784758df9bae4979d19bde306908fc8990640dbe'/>
<id>urn:sha1:784758df9bae4979d19bde306908fc8990640dbe</id>
<content type='text'>
[ Upstream commit 7045465500e465b09f09d6e5bdc260a9f1aab97b ]

Fix invalid usage of a list_for_each_entry cursor in
clk_notifier_unregister(). When list is empty or if the list
is completely traversed (without breaking from the loop on one
of the entries) then the list cursor does not point to a valid
entry and therefore should not be used. The patch fixes a logical
bug that hasn't been seen in pratice however it is analogus
to the bug fixed in clk_notifier_register().

The issue was dicovered when running 5.12-rc1 kernel on x86_64
with KASAN enabled:
BUG: KASAN: global-out-of-bounds in clk_notifier_register+0xab/0x230
Read of size 8 at addr ffffffffa0d10588 by task swapper/0/1

CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.12.0-rc1 #1
Hardware name: Google Caroline/Caroline,
BIOS Google_Caroline.7820.430.0 07/20/2018
Call Trace:
 dump_stack+0xee/0x15c
 print_address_description+0x1e/0x2dc
 kasan_report+0x188/0x1ce
 ? clk_notifier_register+0xab/0x230
 ? clk_prepare_lock+0x15/0x7b
 ? clk_notifier_register+0xab/0x230
 clk_notifier_register+0xab/0x230
 dw8250_probe+0xc01/0x10d4
 ...
 Memory state around the buggy address:
  ffffffffa0d10480: 00 00 00 00 00 03 f9 f9 f9 f9 f9 f9 00 00 00 00
  ffffffffa0d10500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f9 f9
 &gt;ffffffffa0d10580: f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00
                          ^
  ffffffffa0d10600: 00 00 00 00 00 00 f9 f9 f9 f9 f9 f9 00 00 00 00
  ffffffffa0d10680: 00 00 00 00 00 00 00 00 f9 f9 f9 f9 00 00 00 00
  ==================================================================

Fixes: b2476490ef11 ("clk: introduce the common clock framework")
Reported-by: Lukasz Majczak &lt;lma@semihalf.com&gt;
Signed-off-by: Lukasz Bartosik &lt;lb@semihalf.com&gt;
Link: https://lore.kernel.org/r/20210401225149.18826-2-lb@semihalf.com
Signed-off-by: Stephen Boyd &lt;sboyd@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>clk: Don't show the incorrect clock phase</title>
<updated>2018-05-30T05:49:11Z</updated>
<author>
<name>Shawn Lin</name>
</author>
<published>2018-03-14T00:28:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9c43286998a2d5e26da0414e92958819790db4de'/>
<id>urn:sha1:9c43286998a2d5e26da0414e92958819790db4de</id>
<content type='text'>
[ Upstream commit 1f9c63e8de3d7b377c9d74e4a17524cfb60e6384 ]

It's found that the clock phase output from clk_summary is
wrong compared to the actual phase reading from the register.

cat /sys/kernel/debug/clk/clk_summary | grep sdio_sample
sdio_sample     0        1        0 50000000          0 -22

It exposes an issue that clk core, clk_core_get_phase, always
returns the cached core-&gt;phase which should be either updated
by calling clk_set_phase or directly from the first place the
clk was registered.

When registering the clk, the core-&gt;phase geting from -&gt;get_phase()
may return negative value indicating error. This is quite common
since the clk's phase may be highly related to its parent chain,
but it was temporarily orphan when registered, since its parent
chains hadn't be ready at that time, so the clk drivers decide to
return error in this case. However, if no clk_set_phase is called or
maybe the -&gt;set_phase() isn't even implemented, the core-&gt;phase would
never be updated. This is wrong, and we should try to update it when
all its parent chains are settled down, like the way of updating clock
rate for that. But it's not deserved to complicate the code now and
just update it anyway when calling clk_core_get_phase, which would be
much simple and enough.

Signed-off-by: Shawn Lin &lt;shawn.lin@rock-chips.com&gt;
Acked-by: Jerome Brunet &lt;jbrunet@baylibre.com&gt;
Signed-off-by: Stephen Boyd &lt;sboyd@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>clk: Add clk_hw_is_enabled() for use by clk providers</title>
<updated>2015-10-26T19:36:55Z</updated>
<author>
<name>Joachim Eastwood</name>
</author>
<published>2015-10-24T16:55:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=be68bf883170b3e4123fc4ff3745e38fb45a573e'/>
<id>urn:sha1:be68bf883170b3e4123fc4ff3745e38fb45a573e</id>
<content type='text'>
Add clk_hw_is_enabled() to the provider APIs so clk providers can
use a struct clk_hw instead of a struct clk to check if a clk is
enabled or not.

Signed-off-by: Joachim Eastwood &lt;manabian@gmail.com&gt;
Signed-off-by: Stephen Boyd &lt;sboyd@codeaurora.org&gt;
</content>
</entry>
<entry>
<title>clk: add missing of_node_put</title>
<updated>2015-10-21T23:16:32Z</updated>
<author>
<name>Julia Lawall</name>
</author>
<published>2015-10-21T20:41:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6bc9d9d62cbc885414c7d4bb1926c43950498479'/>
<id>urn:sha1:6bc9d9d62cbc885414c7d4bb1926c43950498479</id>
<content type='text'>
for_each_matching_node_and_match performs an of_node_get on each iteration,
so a break out of the loop requires an of_node_put.

A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):

// &lt;smpl&gt;
@@
expression e1,e2,e;
local idexpression np;
@@

 for_each_matching_node_and_match(np, e1, e2) {
   ... when != of_node_put(np)
       when != e = np
(
   return np;
|
+  of_node_put(np);
?  return ...;
)
   ...
 }
// &lt;/smpl&gt;

Besides the problem identified by the semantic patch, this patch adds an
of_node_get in front of saving np in a field of parent, to account for the
fact that this value will be put on going on to the next element in the
iteration, and then adds of_node_puts in the two loops where the parent
pointer can be freed.

Signed-off-by: Julia Lawall &lt;Julia.Lawall@lip6.fr&gt;
Signed-off-by: Stephen Boyd &lt;sboyd@codeaurora.org&gt;
</content>
</entry>
<entry>
<title>clk: Make clk input parameter of __clk_get_name() const</title>
<updated>2015-10-16T18:56:19Z</updated>
<author>
<name>Geert Uytterhoeven</name>
</author>
<published>2015-10-16T12:35:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b76281cb97761002277730432812b1687de96062'/>
<id>urn:sha1:b76281cb97761002277730432812b1687de96062</id>
<content type='text'>
When calling __clk_get_name() on a const clock:

    warning: passing argument 1 of '__clk_get_name' discards 'const' qualifier from pointer target type
    include/linux/clk-provider.h:613:13: note: expected 'struct clk *' but argument is of type 'const struct clk *'

__clk_get_name() does not modify the passed clock, hence make it const.

Signed-off-by: Geert Uytterhoeven &lt;geert+renesas@glider.be&gt;
Signed-off-by: Stephen Boyd &lt;sboyd@codeaurora.org&gt;
</content>
</entry>
<entry>
<title>clk: Use %u to format unsigned int in of_clk_src_onecell_get()</title>
<updated>2015-10-16T18:49:01Z</updated>
<author>
<name>Geert Uytterhoeven</name>
</author>
<published>2015-10-16T15:12:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7e96353c3faaedea91f67972d011db41ed21b367'/>
<id>urn:sha1:7e96353c3faaedea91f67972d011db41ed21b367</id>
<content type='text'>
Signed-off-by: Geert Uytterhoeven &lt;geert+renesas@glider.be&gt;
Signed-off-by: Stephen Boyd &lt;sboyd@codeaurora.org&gt;
</content>
</entry>
<entry>
<title>clk: Make of_clk_get_parent_name() robust with #clock-cells = 1</title>
<updated>2015-10-15T23:17:03Z</updated>
<author>
<name>Stephen Boyd</name>
</author>
<published>2015-10-14T21:03:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0a4807c2f9a4a1afc2163089176abdc7ee4a361a'/>
<id>urn:sha1:0a4807c2f9a4a1afc2163089176abdc7ee4a361a</id>
<content type='text'>
If a clock provider has #clock-cells = 1 and we call
of_clk_get_parent_name() on it we may end up returning the name
of the provider node if the provider doesn't have a
clock-output-names property. This doesn't make sense, especially
when you consider that calling of_clk_get_parent_name() on such a
node with different indices will return the same name each time.

Let's try getting the clock from the framework via of_clk_get()
instead, and only fallback to the node name if we have a provider
with #clock-cells = 0. This way, we can't hand out the same name
for different clocks when we don't actually know their names.

Cc: Thomas Petazzoni &lt;thomas.petazzoni@free-electrons.com&gt;
Signed-off-by: Stephen Boyd &lt;sboyd@codeaurora.org&gt;
</content>
</entry>
<entry>
<title>Merge branch 'clk-fixes' into clk-next</title>
<updated>2015-09-17T19:28:41Z</updated>
<author>
<name>Stephen Boyd</name>
</author>
<published>2015-09-17T19:28:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ab5c342992cac7d1ddaf8a75a4dcab0d13718022'/>
<id>urn:sha1:ab5c342992cac7d1ddaf8a75a4dcab0d13718022</id>
<content type='text'>
* clk-fixes:
  drivers: clk: st: Rename st_pll3200c32_407_c0_x into st_pll3200c32_cx_x
  clk: check for invalid parent index of orphans in __clk_init()
</content>
</entry>
<entry>
<title>clk: Remove unneeded semicolons</title>
<updated>2015-09-17T18:15:14Z</updated>
<author>
<name>Javier Martinez Canillas</name>
</author>
<published>2015-09-17T13:49:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=90c53547fcae9daf46265fd9e74adc4f936cd919'/>
<id>urn:sha1:90c53547fcae9daf46265fd9e74adc4f936cd919</id>
<content type='text'>
There are cleary typo errors so can be removed.

Signed-off-by: Javier Martinez Canillas &lt;javier@osg.samsung.com&gt;
Acked-by: Leo Yan &lt;leo.yan@linaro.org&gt;
Signed-off-by: Stephen Boyd &lt;sboyd@codeaurora.org&gt;
</content>
</entry>
<entry>
<title>clk: check for invalid parent index of orphans in __clk_init()</title>
<updated>2015-09-16T22:35:18Z</updated>
<author>
<name>Mans Rullgard</name>
</author>
<published>2015-02-15T12:33:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9054a31d603ea82c6ed4914170a8708812a16324'/>
<id>urn:sha1:9054a31d603ea82c6ed4914170a8708812a16324</id>
<content type='text'>
If a mux clock is initialised (by hardware or firmware) with an
invalid parent, its -&gt;get_parent() can return an out of range
index.  For example, the generic mux clock attempts to return
-EINVAL, which due to the u8 return type ends up a rather large
number.  Using this index with the parent_names[] array results
in an invalid pointer and (usually) a crash in the following
strcmp().

This patch adds a check for the parent index being in range,
ignoring clocks reporting invalid values.

Signed-off-by: Mans Rullgard &lt;mans@mansr.com&gt;
Tested-by: Rhyland Klein &lt;rklein@nvidia.com&gt;
Signed-off-by: Stephen Boyd &lt;sboyd@codeaurora.org&gt;
</content>
</entry>
</feed>
