diff options
author | Philipp Rossak <embed3d@gmail.com> | 2018-02-26 16:19:01 -0500 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@bootlin.com> | 2018-03-17 09:20:50 -0400 |
commit | 561f8281cf90051bc5f11017ac5ebb21eec45ad9 (patch) | |
tree | 939372d1a1b0d4ca44736d59ceb03ba8cc0283c8 /drivers/rtc/rtc-ac100.c | |
parent | 188306ac9536ec47674ffa9dd330f69927679aeb (diff) |
rtc: ac100: Fix ac100 determine rate bug
This patch fixes a bug, that prevents the Allwinner A83T and the A80
from a successful boot.
The bug is there since v4.16-rc1 and appeared after the clk branch was
merged.
You can find the shortend trace below:
Unable to handle kernel NULL pointer dereference at virtual address
00000000
pgd = (ptrval)
[00000000] *pgd=00000000
Internal error: Oops: 5 [#1] SMP ARM
Modules linked in:
CPU: 0 PID: 49 Comm: kworker/0:1 Not tainted 4.15.0-10190-gb89e32ccd1be #2
Hardware name: Allwinner sun8i Family
Workqueue: events deferred_probe_work_func
PC is at clk_hw_get_rate+0x0/0x34
LR is at ac100_clkout_determine_rate+0x48/0x19c
[ ... ]
(clk_hw_get_rate) from (ac100_clkout_determine_rate+0x48/0x19c)
(ac100_clkout_determine_rate) from (clk_core_set_rate_nolock+0x3c/0x1a0)
(clk_core_set_rate_nolock) from (clk_set_rate+0x30/0x88)
(clk_set_rate) from (of_clk_set_defaults+0x200/0x364)
(of_clk_set_defaults) from (platform_drv_probe+0x18/0xb0)
To fix that bug, we first check if the return of the
clk_hw_get_parent_by_index is non zero. If it is zero we skip that
clock parent.
The BUG report could be found here: https://lkml.org/lkml/2018/2/10/198
Fixes: 04940631b8d2 ("rtc: ac100: Add clk output support")
Signed-off-by: Philipp Rossak <embed3d@gmail.com>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'drivers/rtc/rtc-ac100.c')
-rw-r--r-- | drivers/rtc/rtc-ac100.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/rtc/rtc-ac100.c b/drivers/rtc/rtc-ac100.c index 080e3c04be43..3fe576fdd45e 100644 --- a/drivers/rtc/rtc-ac100.c +++ b/drivers/rtc/rtc-ac100.c | |||
@@ -183,7 +183,29 @@ static int ac100_clkout_determine_rate(struct clk_hw *hw, | |||
183 | 183 | ||
184 | for (i = 0; i < num_parents; i++) { | 184 | for (i = 0; i < num_parents; i++) { |
185 | struct clk_hw *parent = clk_hw_get_parent_by_index(hw, i); | 185 | struct clk_hw *parent = clk_hw_get_parent_by_index(hw, i); |
186 | unsigned long tmp, prate = clk_hw_get_rate(parent); | 186 | unsigned long tmp, prate; |
187 | |||
188 | /* | ||
189 | * The clock has two parents, one is a fixed clock which is | ||
190 | * internally registered by the ac100 driver. The other parent | ||
191 | * is a clock from the codec side of the chip, which we | ||
192 | * properly declare and reference in the devicetree and is | ||
193 | * not implemented in any driver right now. | ||
194 | * If the clock core looks for the parent of that second | ||
195 | * missing clock, it can't find one that is registered and | ||
196 | * returns NULL. | ||
197 | * So we end up in a situation where clk_hw_get_num_parents | ||
198 | * returns the amount of clocks we can be parented to, but | ||
199 | * clk_hw_get_parent_by_index will not return the orphan | ||
200 | * clocks. | ||
201 | * Thus we need to check if the parent exists before | ||
202 | * we get the parent rate, so we could use the RTC | ||
203 | * without waiting for the codec to be supported. | ||
204 | */ | ||
205 | if (!parent) | ||
206 | continue; | ||
207 | |||
208 | prate = clk_hw_get_rate(parent); | ||
187 | 209 | ||
188 | tmp = ac100_clkout_round_rate(hw, req->rate, prate); | 210 | tmp = ac100_clkout_round_rate(hw, req->rate, prate); |
189 | 211 | ||