* [PATCH] clk: tegra: Avoid calling an uninitialized function
@ 2023-06-30 13:07 Thierry Reding
2023-07-04 15:54 ` Stephen Boyd
0 siblings, 1 reply; 2+ messages in thread
From: Thierry Reding @ 2023-06-30 13:07 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd
Cc: Jon Hunter, Maxime Ripard, Dmitry Osipenko, linux-clk, linux-tegra
From: Thierry Reding <treding@nvidia.com>
Commit 493ffb046cf5 ("clk: tegra: super: Switch to determine_rate")
replaced clk_super_round_rate() by clk_super_determine_rate(), but
didn't update one callsite that was explicitly calling the old
tegra_clk_super_ops.round_rate() function, which was now NULL. This
resulted in a crash on Tegra30 systems during early boot.
Switch this callsite over to the clk_super_determine_rate() equivalent
to avoid the crash.
Fixes: 493ffb046cf5 ("clk: tegra: super: Switch to determine_rate")
Tested-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/clk/tegra/clk-tegra-super-cclk.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/clk/tegra/clk-tegra-super-cclk.c b/drivers/clk/tegra/clk-tegra-super-cclk.c
index 68d7bcd5fc8a..3b22a4d0dffc 100644
--- a/drivers/clk/tegra/clk-tegra-super-cclk.c
+++ b/drivers/clk/tegra/clk-tegra-super-cclk.c
@@ -86,9 +86,18 @@ static int cclk_super_determine_rate(struct clk_hw *hw,
if (rate <= pllp_rate) {
if (super->flags & TEGRA20_SUPER_CLK)
rate = pllp_rate;
- else
- rate = tegra_clk_super_ops.round_rate(hw, rate,
- &pllp_rate);
+ else {
+ struct clk_rate_request parent = {
+ .rate = req->rate,
+ .best_parent_rate = pllp_rate,
+ };
+
+ clk_hw_get_rate_range(hw, &parent.min_rate,
+ &parent.max_rate);
+ tegra_clk_super_ops.determine_rate(hw, &parent);
+ pllp_rate = parent.best_parent_rate;
+ rate = parent.rate;
+ }
req->best_parent_rate = pllp_rate;
req->best_parent_hw = pllp_hw;
--
2.41.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] clk: tegra: Avoid calling an uninitialized function
2023-06-30 13:07 [PATCH] clk: tegra: Avoid calling an uninitialized function Thierry Reding
@ 2023-07-04 15:54 ` Stephen Boyd
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2023-07-04 15:54 UTC (permalink / raw)
To: Michael Turquette, Thierry Reding
Cc: Jon Hunter, Maxime Ripard, Dmitry Osipenko, linux-clk, linux-tegra
Quoting Thierry Reding (2023-06-30 06:07:48)
> From: Thierry Reding <treding@nvidia.com>
>
> Commit 493ffb046cf5 ("clk: tegra: super: Switch to determine_rate")
> replaced clk_super_round_rate() by clk_super_determine_rate(), but
> didn't update one callsite that was explicitly calling the old
> tegra_clk_super_ops.round_rate() function, which was now NULL. This
> resulted in a crash on Tegra30 systems during early boot.
>
> Switch this callsite over to the clk_super_determine_rate() equivalent
> to avoid the crash.
>
> Fixes: 493ffb046cf5 ("clk: tegra: super: Switch to determine_rate")
> Tested-by: Dmitry Osipenko <digetx@gmail.com>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
Applied to clk-next
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-04 15:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-30 13:07 [PATCH] clk: tegra: Avoid calling an uninitialized function Thierry Reding
2023-07-04 15:54 ` Stephen Boyd
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).