Add Krait Cache Scaling support
Subsystems (2)
v3 cover Add Krait Cache Scaling support
This adds Krait Cache scaling support using the cpufreq notifier.
I have some doubt about where this should be actually placed (clk or cpufreq)? Also the original idea was to create a dedicated cpufreq driver (like it's done in the codeaurora qcom repo) by copying the cpufreq-dt driver and adding the cache scaling logic but i still don't know what is better. Have a very similar driver or add a dedicated driver only for the cache using the cpufreq notifier and do the scale on every freq transition.
Thanks to everyone who will review or answer these questions.
v3:
* Use opp infrastructure
* Update documentation
v2:
* Fix Documentation error reported by bot
* Rework code to fail probe on missing required params
* Optimize notifier callback to reduce CPU cycle
Ansuel Smith (2):
cpufreq: qcom: Add Krait Cache Scaling support
dt-bindings: cpufreq: Document Krait CPU Cache scaling
.../bindings/cpufreq/krait-cache-scale.yaml | 79 ++++++ drivers/cpufreq/Kconfig.arm | 9 + drivers/cpufreq/Makefile | 1 + drivers/cpufreq/krait-cache.c | 232 ++++++++++++++++++ 4 files changed, 321 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml create mode 100644 drivers/cpufreq/krait-cache.c
Signature · 1 line
2.27.0
RFC PATCH v3 1/2 cpufreq: qcom: Add Krait Cache Scaling support
Qcom Krait CPUs use the generic cpufreq-dt driver and doesn't actually scale the Cache frequency when the CPU frequency is changed. This companion driver register with the cpu notifier and scale the Cache based on the max Freq across all core as the CPU cache is shared across all of them. If provided this also scale the voltage of the regulator attached to the CPU cache. The scaling logic is based on the CPU freq and the 3 scaling interval are set by the device dts.
--- drivers/cpufreq/Kconfig.arm | 9 ++ drivers/cpufreq/Makefile | 1 + drivers/cpufreq/krait-cache.c | 232 ++++++++++++++++++++++++++++++++++ 3 files changed, 242 insertions(+) create mode 100644 drivers/cpufreq/krait-cache.c
drivers/cpufreq/Kconfig.arm +9 -0
@@ -126,6 +126,15 @@ config ARM_OMAP2PLUS_CPUFREQ depends on ARCH_OMAP2PLUS default ARCH_OMAP2PLUS +config ARM_QCOM_KRAIT_CACHE_SCALE + tristate "Scaling support for Krait CPU Cache" + depends on ARCH_QCOM || COMPILE_TEST + help + This adds the Scaling support for the Krait CPU Cache shared by + all cores. + + If in doubt, say N. + config ARM_QCOM_CPUFREQ_NVMEM tristate "Qualcomm nvmem based CPUFreq" depends on ARCH_QCOM
drivers/cpufreq/Makefile +1 -0
@@ -61,6 +61,7 @@ obj-$(CONFIG_MACH_MVEBU_V7) += mvebu-cpufreq.o obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ) += omap-cpufreq.o obj-$(CONFIG_ARM_PXA2xx_CPUFREQ) += pxa2xx-cpufreq.o obj-$(CONFIG_PXA3xx) += pxa3xx-cpufreq.o +obj-$(CONFIG_ARM_QCOM_KRAIT_CACHE_SCALE) += krait-cache.o obj-$(CONFIG_ARM_QCOM_CPUFREQ_HW) += qcom-cpufreq-hw.o obj-$(CONFIG_ARM_QCOM_CPUFREQ_NVMEM) += qcom-cpufreq-nvmem.o obj-$(CONFIG_ARM_RASPBERRYPI_CPUFREQ) += raspberrypi-cpufreq.o
drivers/cpufreq/krait-cache.c new file +232 -0
232 lines not on this page · raw message
Signature · 1 line
2.27.0
RFC PATCH v3 2/2 dt-bindings: cpufreq: Document Krait CPU Cache scaling
In reply to Ansuel SmithDocument dedicated Krait CPU Cache Scaling driver.
--- .../bindings/cpufreq/krait-cache-scale.yaml | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml
Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml new file +79 -0
@@ -0,0 +1,79 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/cpufreq/krait-cache-scale.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Krait Cpu Cache Frequency Scaling dedicated driver + +maintainers: + - Ansuel Smith <[email protected]> + +description: | + This Scale the Krait CPU Cache Frequency and optionally voltage + when the Cpu Frequency is changed (using the cpufreq notifier). + + Cache is scaled with the max frequency across all core and the cache + frequency will scale based on the configured threshold in the dts. + + The cache thresholds can be set to 3+ frequency bin, idle, nominal and + high. + +properties: + compatible: + const: qcom,krait-cache + + clocks: + $ref: "/schemas/types.yaml#/definitions/phandle" + description: Phandle to the L2 CPU clock + + clock-names: + const: "l2" + + voltage-tolerance: + description: Same voltage tollerance of the Krait CPU + + l2-cpufreq: + description: | + Threshold used by the driver to scale the L2 cache. + If the max CPU Frequency is more than the set frequency, + the driver will transition to the next frequency bin. + Value is in kHz + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 3 + items: + - description: idle + - description: nominal + - description: high + + l2-supply: + $ref: "/schemas/types.yaml#/definitions/phandle" + description: Phandle to the L2 regulator supply. + + opp-table: true + +required: + - compatible + - clocks + - clock-names + - voltage-tolerance + - l2-cpufreq + - l2-supply + +examples: + - | + qcom-krait-cache { + compatible = "qcom,krait-cache"; + clocks = <&kraitcc 4>; + clock-names = "l2"; + voltage-tolerance = <5>; + l2-cpufreq = <384000 600000 1200000>; + l2-supply = <&smb208_s1a>; + + operating-points = < + /* kHz uV */ + 384000 1100000 + 1000000 1100000 + 1200000 1150000 + >; + };
Signature · 1 line
2.27.0
Rob Herring
maintainerRe: [RFC PATCH v3 2/2] dt-bindings: cpufreq: Document Krait CPU Cache scaling
Quoted 8 lines · Ansuel Smith
Document dedicated Krait CPU Cache Scaling driver.
Signed-off-by Ansuel Smith <[email protected]>--- .../bindings/cpufreq/krait-cache-scale.yaml | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml
My bot found errors running 'make dt_binding_check' on your patch:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/cpufreq/krait-cache-scale.example.dt.yaml: qcom-krait-cache: clocks:0:1: missing phandle tag in 4
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/cpufreq/krait-cache-scale.example.dt.yaml: qcom-krait-cache: clocks:0: [4294967295, 4] is too long
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml
See https://patchwork.ozlabs.org/patch/1349260
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure dt-schema is up to date:
pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade
Please check and re-submit.
Viresh Kumar
maintainer+Vincent/Saravana/Sibi
Quoted 8 lines · Ansuel Smith
This adds Krait Cache scaling support using the cpufreq notifier.
I have some doubt about where this should be actually placed (clk or cpufreq)? Also the original idea was to create a dedicated cpufreq driver (like it's done in the codeaurora qcom repo) by copying the cpufreq-dt driver and adding the cache scaling logic but i still don't know what is better. Have a very similar driver or add a dedicated driver only for the cache using the cpufreq notifier and do the scale on every freq transition.
Thanks to everyone who will review or answer these questions.
Saravana was doing something with devfreq to solve such issues if I wasn't mistaken.
Sibi ?
Signature · 1 line
viresh
Quoted 12 lines · Viresh Kumar
+Vincent/Saravana/Sibi
Quoted 8 lines · Ansuel Smith
This adds Krait Cache scaling support using the cpufreq notifier.
I have some doubt about where this should be actually placed (clk or cpufreq)? Also the original idea was to create a dedicated cpufreq driver (like it's done in the codeaurora qcom repo) by copying the cpufreq-dt driver and adding the cache scaling logic but i still don't know what is better. Have a very similar driver or add a dedicated driver only for the cache using the cpufreq notifier and do the scale on every freq transition.
Thanks to everyone who will review or answer these questions.
Quoted 4 lines
Saravana was doing something with devfreq to solve such issues if I wasn't mistaken.
Sibi ?
IIRC the final plan was to create a devfreq device and devfreq-cpufreq based governor to scale them, this way one can switch to a different governor if required. (I don't see if ^^ applies well for l2 though). In the interim until such a solution is acked on the list we just scale the resources directly from the cpufreq driver. On SDM845/SC7180 SoCs, L3 is modeled as a interconnect provider and is directly scaled from the cpufreq-hw driver.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
R: [RFC PATCH v3 0/2] Add Krait Cache Scaling support
Quoted 32 lines
-----Messaggio originale-----
Da: [email protected] <[email protected]> Per conto di Sibi Sankar
Inviato: lunedì 31 agosto 2020 07:46
A: Viresh Kumar <[email protected]>
Cc: Ansuel Smith <[email protected]>; [email protected]; [email protected]; Sudeep Holla <[email protected]>; Rafael J. Wysocki <[email protected]>; Rob Herring <[email protected]>; linux- [email protected]; [email protected]; linux- [email protected]
Oggetto: Re: [RFC PATCH v3 0/2] Add Krait Cache Scaling supportQuoted 17 lines · Viresh Kumar
+Vincent/Saravana/Sibi
Quoted 13 lines · Ansuel Smith
This adds Krait Cache scaling support using the cpufreq notifier. I have some doubt about where this should be actually placed (clk or cpufreq)?
Also the original idea was to create a dedicated cpufreq driver (like it's done in
the codeaurora qcom repo) by copying the cpufreq-dt driver and adding the cache
scaling logic but i still don't know what is better. Have a very similar driver or
add a dedicated driver only for the cache using the cpufreq notifier and do the
scale on every freq transition.
Thanks to everyone who will review or answer these questions.
Quoted 8 lines
Quoted 4 lines
Saravana was doing something with devfreq to solve such issues if I wasn't mistaken.
Sibi ?
IIRC the final plan was to create a devfreq device and devfreq-cpufreq based governor to scale them, this way one can switch to a different governor if required.
So in this case I should convert this patch to a devfreq driver- Isn't overkill to use a governor for such a task?
(3 range based on the cpufreq?)
Quoted 3 lines
(I don't see if ^^ applies well for l2 though). In the interim until such a solution is acked on the list we just scale the resources directly from the cpufreq
In this case for this SoC we can't really scale the L2 freq with the cpu since we observed a bug and we need to switch back to the idle freq sometimes. Also this SoC use the generic cpufreq-dt driver and doesn't have a dedicated driver. So we must use a notifier.
Quoted 7 lines
driver. On SDM845/SC7180 SoCs, L3 is modeled as a interconnect provider and is directly scaled from the cpufreq-hw driver.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
Viresh Kumar
maintainerRe: R: [RFC PATCH v3 0/2] Add Krait Cache Scaling support
Quoted 22 lines · On 31-08-20, 09:41, [email protected] wrote:
Quoted 21 lines · Sibi
Quoted 20 lines · Viresh Kumar
+Vincent/Saravana/Sibi
Quoted 5 lines · Ansuel Smith
This adds Krait Cache scaling support using the cpufreq notifier. I have some doubt about where this should be actually placed (clk or cpufreq)?
Also the original idea was to create a dedicated cpufreq driver (like it's done inQuoted 8 lines
the codeaurora qcom repo) by copying the cpufreq-dt driver and adding the cache
scaling logic but i still don't know what is better. Have a very similar driver or
add a dedicated driver only for the cache using the cpufreq notifier and do the
scale on every freq transition.
Thanks to everyone who will review or answer these questions.Saravana was doing something with devfreq to solve such issues if I wasn't mistaken.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Sibi ?
IIRC the final plan was to create a devfreq device and devfreq-cpufreq based governor to scale them, this way one can switch to a different governor if required.
So in this case I should convert this patch to a devfreq driver-
I think this should happen nevertheless. You are doing DVFS for a device which isn't a CPU and devfreq looks to be the right place of doing so.
Quoted 2 lines
Isn't overkill to use a governor for such a task?
(3 range based on the cpufreq?)
I am not sure about the governor part here, maybe it won't be required ?
Signature · 1 line
viresh
Re: R: [RFC PATCH v3 0/2] Add Krait Cache Scaling support
Quoted 35 lines · Viresh Kumar
Quoted 22 lines · On 31-08-20, 09:41, [email protected] wrote:
Quoted 21 lines · Sibi
Quoted 20 lines · Viresh Kumar
+Vincent/Saravana/Sibi
Quoted 5 lines · Ansuel Smith
This adds Krait Cache scaling support using the cpufreq notifier. I have some doubt about where this should be actually placed (clk or cpufreq)?
Also the original idea was to create a dedicated cpufreq driver (like it's done inQuoted 8 lines
the codeaurora qcom repo) by copying the cpufreq-dt driver and adding the cache
scaling logic but i still don't know what is better. Have a very similar driver or
add a dedicated driver only for the cache using the cpufreq notifier and do the
scale on every freq transition.
Thanks to everyone who will review or answer these questions.Saravana was doing something with devfreq to solve such issues if I wasn't mistaken.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Sibi ?
IIRC the final plan was to create a devfreq device and devfreq-cpufreq based governor to scale them, this way one can switch to a different governor if required.
So in this case I should convert this patch to a devfreq driver-
I think this should happen nevertheless. You are doing DVFS for a device which isn't a CPU and devfreq looks to be the right place of doing so.
Quoted 5 lines
Quoted 2 lines
Isn't overkill to use a governor for such a task?
(3 range based on the cpufreq?)I am not sure about the governor part here, maybe it won't be required ?
Yeah I don't see it being needed in ^^
case as well. I just mentioned them as
an advantage in case you wanted to switch
to a different governor in the future.
https://lore.kernel.org/lkml/[email protected]/
A devfreq governor tracking cpufreq was
generally accepted but using a cpufreq
notifier to achieve that was discouraged.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
R: R: [RFC PATCH v3 0/2] Add Krait Cache Scaling support
Quoted 16 lines
-----Messaggio originale-----
Da: [email protected] <[email protected]> Per conto di Sibi Sankar
Inviato: giovedì 3 settembre 2020 09:13
A: Viresh Kumar <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; 'Sudeep Holla' <[email protected]>; 'Rafael J. Wysocki' <[email protected]>; 'Rob Herring' <[email protected]>; linux- [email protected]; [email protected]; linux- [email protected]
Oggetto: Re: R: [RFC PATCH v3 0/2] Add Krait Cache Scaling supportQuoted 1 line · Viresh Kumar
On 31-08-20, 09:41, [email protected] wrote:
Quoted 10 lines
Quoted 7 lines
Quoted 7 lines · Sibi
Quoted 6 lines · Viresh Kumar
Quoted 5 lines
+Vincent/Saravana/Sibi
Quoted 2 lines · Ansuel Smith
This adds Krait Cache scaling support using the cpufreq notifier. I have some doubt about where this should be actually placed (clk
or
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
cpufreq)?
Also the original idea was to create a dedicated cpufreq driver
(like
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
it's done in
the codeaurora qcom repo) by copying the cpufreq-dt driver andadding
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
the cache
scaling logic but i still don't know what is better. Have a very similar driver or
add a dedicated driver only for the cache using the cpufreq
notifier
Quoted 30 lines
Quoted 19 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
and do the
scale on every freq transition.
Thanks to everyone who will review or answer these questions.Saravana was doing something with devfreq to solve such issues if I wasn't mistaken.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Sibi ?
IIRC the final plan was to create a devfreq device and devfreq-cpufreq based governor to scale them, this way one can switch to a different governor if required.
So in this case I should convert this patch to a devfreq driver-
I think this should happen nevertheless. You are doing DVFS for a device which isn't a CPU and devfreq looks to be the right place of doing so.
Quoted 5 lines
Quoted 2 lines
Isn't overkill to use a governor for such a task?
(3 range based on the cpufreq?)I am not sure about the governor part here, maybe it won't be required ?
Yeah I don't see it being needed in ^^
case as well. I just mentioned them as
an advantage in case you wanted to switch
to a different governor in the future.
Quoted 7 lines
https://lore.kernel.org/lkml/d0bc8877-6d41-f54e-1c4c-
[email protected]/A devfreq governor tracking cpufreq was
generally accepted but using a cpufreq
notifier to achieve that was discouraged.
I read the patch discussion and it looks like at the very end they lost interest in pushing it. That would very fit what I need here so I'm asking how should I proceed? Keep the cpufreq notifier? Introduce a dedicated governor? Ask them to resume the pushing or try to include the changes to the passive governor by myself?
Quoted 3 lines
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.