Add Krait Cache Scaling support
Subsystems (2)
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.
Ansuel Smith (2):
cpufreq: qcom: Add Krait Cache Scaling support
dt-bindings: cpufreq: Document Krait CPU Cache scaling
.../bindings/cpufreq/krait-cache-scale.yaml | 89 ++++++++ drivers/cpufreq/Kconfig.arm | 9 + drivers/cpufreq/Makefile | 1 + drivers/cpufreq/krait-cache.c | 216 ++++++++++++++++++ 4 files changed, 315 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 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 | 218 ++++++++++++++++++++++++++++++++++ 3 files changed, 228 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 +218 -0
218 lines not on this page · raw message
Signature · 1 line
2.27.0
RFC PATCH 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 | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml
Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml new file +89 -0
@@ -0,0 +1,89 @@ +# 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 is hardcoded to 3 frequency bin, idle, nominal and high. + +properties: + compatible: + const: qcom,krait-cache + + clocks: + description: Phandle to the L2 CPU clock + + clock-names: + const: "l2" + + voltage-tolerance: + description: Same voltage tollerance of the Krait CPU + + l2-rates: + description: | + Frequency the L2 cache will be scaled at. + Value is in Hz. + items: + - description: idle + - description: nominal + - description: high + + 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 + items: + - description: idle + - description: nominal + - description: high + + l2-volt: + 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 microvolt. + items: + - description: idle + - description: nominal + - description: high + + l2-supply: + description: Phandle to the L2 regulator supply. + +required: + - compatible + - clocks + - clock-names + - voltage-tolerance + - l2-rates + - l2-cpufreq + - l2-supply + - l2-volt + +examples: + - | + qcom-krait-cache { + compatible = "qcom,krait-cache"; + clocks = <&kraitcc 4>; + clock-names = "l2"; + voltage-tolerance = <5>; + l2-rates = <384000000 1000000000 1200000000>; + l2-cpufreq = <384000 600000 1200000>; + l2-volt = <1100000 1100000 1150000>; + l2-supply = <&smb208_s1a>; + };
Signature · 1 line
2.27.0
Rob Herring
maintainerRe: [RFC PATCH 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 | 89 +++++++++++++++++++ 1 file changed, 89 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: l2-cpufreq: [[384000, 600000, 1200000]] is too short /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/cpufreq/krait-cache-scale.example.dt.yaml: qcom-krait-cache: l2-rates: [[384000000, 1000000000, 1200000000]] is too short /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/cpufreq/krait-cache-scale.example.dt.yaml: qcom-krait-cache: l2-volt: [[1100000, 1100000, 1150000]] is too short
See https://patchwork.ozlabs.org/patch/1341295
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.