ipq806x: 5.15: add experimental krait-cc patches
authorChristian Marangi <[email protected]>
Wed, 5 Oct 2022 18:41:35 +0000 (20:41 +0200)
committerChristian Marangi <[email protected]>
Mon, 10 Oct 2022 08:52:11 +0000 (10:52 +0200)
Add wip experimental krait-cc patches to speed up clock
scaling.

Signed-off-by: Christian Marangi <[email protected]>
target/linux/ipq806x/patches-5.15/122-03-clk-qcom-krait-cc-improve-safe-parent-logic.patch [new file with mode: 0644]
target/linux/ipq806x/patches-5.15/122-04-clk-qcom-krait-cc-disble-lpl-for-ipq806x.patch [new file with mode: 0644]

diff --git a/target/linux/ipq806x/patches-5.15/122-03-clk-qcom-krait-cc-improve-safe-parent-logic.patch b/target/linux/ipq806x/patches-5.15/122-03-clk-qcom-krait-cc-improve-safe-parent-logic.patch
new file mode 100644 (file)
index 0000000..c1dc5e2
--- /dev/null
@@ -0,0 +1,79 @@
+From 4e407fe2dc3b8e4fec4fcff3111f6a6621b90a7c Mon Sep 17 00:00:00 2001
+From: Christian Marangi <[email protected]>
+Date: Fri, 23 Sep 2022 19:19:17 +0200
+Subject: [PATCH 3/4] clk: qcom: krait-cc: improve safe parent logic
+
+We can skip switching to a safe parent if we are switching to the safe
+parent or the mux is already set to a safe parent.
+
+Use the clock notifier data to detect the old and new rate and decided
+based on the hardcoded safe rate that correspond to the safe parent
+rate.
+
+Signed-off-by: Christian Marangi <[email protected]>
+---
+ drivers/clk/qcom/clk-krait.h |  1 +
+ drivers/clk/qcom/krait-cc.c  | 10 ++++++++++
+ 2 files changed, 11 insertions(+)
+
+diff --git a/drivers/clk/qcom/clk-krait.h b/drivers/clk/qcom/clk-krait.h
+index 94c798f8e834..ef650e220b3a 100644
+--- a/drivers/clk/qcom/clk-krait.h
++++ b/drivers/clk/qcom/clk-krait.h
+@@ -16,6 +16,7 @@ struct krait_mux_clk {
+       u8              old_index;
+       bool            reparent;
+       bool            disable_sec_src_gating;
++      unsigned long   safe_rate;
+       struct clk_hw   hw;
+       struct notifier_block   clk_nb;
+diff --git a/drivers/clk/qcom/krait-cc.c b/drivers/clk/qcom/krait-cc.c
+index 949657186fdb..dd78d5eded47 100644
+--- a/drivers/clk/qcom/krait-cc.c
++++ b/drivers/clk/qcom/krait-cc.c
+@@ -39,10 +39,17 @@ static int krait_notifier_cb(struct notifier_block *nb,
+                            void *data)
+ {
+       int ret = 0;
++      struct clk_notifier_data *cnd = data;
+       struct krait_mux_clk *mux = container_of(nb, struct krait_mux_clk,
+                                                clk_nb);
+       /* Switch to safe parent */
+       if (event == PRE_RATE_CHANGE) {
++              if (likely(cnd->old_rate > mux->safe_rate) &&
++                  (cnd->new_rate == mux->safe_rate ||
++                   cnd->old_rate == mux->safe_rate)) {
++                      goto exit;
++              }
++
+               mux->old_index = krait_mux_clk_ops.get_parent(&mux->hw);
+               ret = krait_mux_clk_ops.set_parent(&mux->hw, mux->safe_sel);
+               mux->reparent = false;
+@@ -57,6 +64,7 @@ static int krait_notifier_cb(struct notifier_block *nb,
+                                                          mux->old_index);
+       }
++exit:
+       return notifier_from_errno(ret);
+ }
+@@ -150,6 +158,7 @@ krait_add_sec_mux(struct device *dev, int id, const char *s,
+       mux->parent_map = sec_mux_map;
+       mux->hw.init = &init;
+       mux->safe_sel = 0;
++      mux->safe_rate = QSB_RATE;
+       /* Checking for qcom,krait-cc-v1 or qcom,krait-cc-v2 is not
+        * enough to limit this to apq/ipq8064. Directly check machine
+@@ -228,6 +237,7 @@ krait_add_pri_mux(struct device *dev, struct clk *hfpll_div, struct clk *sec_mux
+       mux->parent_map = pri_mux_map;
+       mux->hw.init = &init;
+       mux->safe_sel = 2;
++      mux->safe_rate = AUX_RATE;
+       init.name = kasprintf(GFP_KERNEL, "krait%s_pri_mux", s);
+       if (!init.name)
+-- 
+2.37.2
+
diff --git a/target/linux/ipq806x/patches-5.15/122-04-clk-qcom-krait-cc-disble-lpl-for-ipq806x.patch b/target/linux/ipq806x/patches-5.15/122-04-clk-qcom-krait-cc-disble-lpl-for-ipq806x.patch
new file mode 100644 (file)
index 0000000..3a16cac
--- /dev/null
@@ -0,0 +1,50 @@
+From 5135074fdde015293ed31e4606ecc56b00ca6708 Mon Sep 17 00:00:00 2001
+From: Christian Marangi <[email protected]>
+Date: Fri, 23 Sep 2022 19:22:50 +0200
+Subject: [PATCH 4/4] clk: qcom: krait-cc: disble lpl for ipq806x
+
+Disable lpl for ipq806x since it seems it wasn't enabled in original
+firmware.
+
+Signed-off-by: Christian Marangi <[email protected]>
+---
+ drivers/clk/qcom/krait-cc.c | 9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/clk/qcom/krait-cc.c b/drivers/clk/qcom/krait-cc.c
+index dd78d5eded47..6accdc9a85db 100644
+--- a/drivers/clk/qcom/krait-cc.c
++++ b/drivers/clk/qcom/krait-cc.c
+@@ -101,7 +101,8 @@ krait_add_div(struct device *dev, int id, const char *s, unsigned int offset)
+       div->mask = 0x3;
+       div->divisor = 2;
+       div->shift = 6;
+-      div->lpl = id >= 0;
++      if (!of_machine_is_compatible("qcom,ipq8064"))
++              div->lpl = id >= 0;
+       div->offset = offset;
+       div->hw.init = &init;
+@@ -152,7 +153,8 @@ krait_add_sec_mux(struct device *dev, int id, const char *s,
+               return ERR_PTR(-ENOMEM);
+       mux->offset = offset;
+-      mux->lpl = id >= 0;
++      if (!of_machine_is_compatible("qcom,ipq8064"))
++              mux->lpl = id >= 0;
+       mux->mask = 0x3;
+       mux->shift = 2;
+       mux->parent_map = sec_mux_map;
+@@ -233,7 +235,8 @@ krait_add_pri_mux(struct device *dev, struct clk *hfpll_div, struct clk *sec_mux
+       mux->mask = 0x3;
+       mux->shift = 0;
+       mux->offset = offset;
+-      mux->lpl = id >= 0;
++      if (!of_machine_is_compatible("qcom,ipq8064"))
++              mux->lpl = id >= 0;
+       mux->parent_map = pri_mux_map;
+       mux->hw.init = &init;
+       mux->safe_sel = 2;
+-- 
+2.37.2
+