From bc0ca20ca90e4d58090392c96b6d8d6405444268 Mon Sep 17 00:00:00 2001 From: Ansuel Smith Date: Sun, 15 Dec 2019 02:25:04 +0100 Subject: [PATCH] ipq806x: fix bug in L2 cache scaling It has been notice a buf in L2 cache scaling where the scaling is not done proprely if the frequency is set to the initial state before the new frequency. From: https://patchwork.kernel.org/patch/10565443/ * The clocks are set to aux clock rate first to make sure the * secondary mux is not sourcing off of QSB. The rate is then set to * two different rates to force a HFPLL reinit under all * circumstances. In the initial stage of boot to force a new frequency to apply, is needed to first set the frequency back to the lowest one (aux_rate) and then to the target one. This force and make sure the controller actually switch the frequency to the right one. Apply the same mechanism to L2 frequency scaling. Before scaling to the target frequency, first set the frequency to the aux_rate to force the transition, then scale it to the target frequency. Doing the wrong way can produce unexpected results and could lock the scaling mechanism until a full reboot is done (Causing a full reset by the krait-cc driver) From: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=77612720a2362230af726baa4149c40ec7a7fb05 When the Hfplls are reprogrammed during the rate change, the primary muxes which are sourced from the same hfpll for higher frequencies, needs to be switched to the 'safe secondary mux' as the parent for that small window. This is done by registering a clk notifier for the muxes and switching to the safe parent in the PRE_RATE_CHANGE notifier and back to the original parent in the POST_RATE_CHANGE notifier. This should apply also to L2 scaling... as we can't relly use the notifier, we manually do this on L2 scaling. Tested-By: Marc Benoit [19.07: R7800] Tested-by: Stefan Lippers-Hollmann [nbg6817/ipq8065] Signed-off-by: Ansuel Smith (cherry picked from commit 5ab9c0b388e9cf2537ef23d6e9baaf5730a14a1c) --- .../0055-cpufreq-dt-Add-L2-frequency-scaling-support.patch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/linux/ipq806x/patches-4.14/0055-cpufreq-dt-Add-L2-frequency-scaling-support.patch b/target/linux/ipq806x/patches-4.14/0055-cpufreq-dt-Add-L2-frequency-scaling-support.patch index 1c26650b78..f3e79b2178 100644 --- a/target/linux/ipq806x/patches-4.14/0055-cpufreq-dt-Add-L2-frequency-scaling-support.patch +++ b/target/linux/ipq806x/patches-4.14/0055-cpufreq-dt-Add-L2-frequency-scaling-support.patch @@ -11,7 +11,7 @@ Signed-off-by: Georgi Djakov --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c -@@ -49,11 +49,41 @@ static int set_target(struct cpufreq_pol +@@ -49,11 +49,42 @@ static int set_target(struct cpufreq_pol struct private_data *priv = policy->driver_data; int ret; unsigned long target_freq = policy->freq_table[index].frequency * 1000; @@ -43,6 +43,7 @@ Signed-off-by: Georgi Djakov + l2_freq = clk_get_rate(l2_clk); + + if (l2_freq != new_l2_freq) { ++ ret = clk_set_rate(l2_clk, policy->l2_rate[0]); + /* scale l2 with the core */ + ret = clk_set_rate(l2_clk, new_l2_freq); + } -- 2.25.1