Add Krait Cache Scaling support
Subsystems (2)
v2 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.
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 | 92 ++++++++ drivers/cpufreq/Kconfig.arm | 9 + drivers/cpufreq/Makefile | 1 + drivers/cpufreq/krait-cache.c | 214 ++++++++++++++++++ 4 files changed, 316 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 v2 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 | 213 ++++++++++++++++++++++++++++++++++ 3 files changed, 223 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 +213 -0
213 lines not on this page · raw message
Signature · 1 line
2.27.0
RFC PATCH v2 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 | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml
Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml new file +92 -0
@@ -0,0 +1,92 @@ +# 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. + $ref: /schemas/types.yaml#/definitions/uint32-array + 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 + $ref: /schemas/types.yaml#/definitions/uint32-array + 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. + $ref: /schemas/types.yaml#/definitions/uint32-array + 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
Re: [RFC PATCH v2 2/2] dt-bindings: cpufreq: Document Krait CPU Cache scaling
Quoted 28 lines · Ansuel Smith
Document dedicated Krait CPU Cache Scaling driver.
Signed-off-by Ansuel Smith <[email protected]>--- .../bindings/cpufreq/krait-cache-scale.yaml | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yamlDocumentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml new file +14
-0@@ -0,0 +1,92 @@ +# 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).
Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml line 24
Quoted 10 lines
Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml new file +10
-0+ + 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 +
How does this fit in the standard cache hierarchy nodes ? Extend the example to cover that.
Quoted 9 lines
Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml new file +9
-0+ clocks: + description: Phandle to the L2 CPU clock + + clock-names: + const: "l2" + + voltage-tolerance: + description: Same voltage tollerance of the Krait CPU +
Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml line 43
Quoted 10 lines
Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yaml new file +10
-0+ l2-rates: + description: | + Frequency the L2 cache will be scaled at. + Value is in Hz. + $ref: /schemas/types.yaml#/definitions/uint32-array + items: + - description: idle + - description: nominal + - description: high +
Why can't you re-use the standard OPP v2 bindings ?
--
Regards,
Sudeep
R: [RFC PATCH v2 2/2] dt-bindings: cpufreq: Document Krait CPU Cache scaling
Quoted 52 lines
-----Messaggio originale-----
Da: Sudeep Holla <[email protected]>
Inviato: lunedì 10 agosto 2020 10:02
A: Ansuel Smith <[email protected]>
Cc: Viresh Kumar <[email protected]>; Rafael J. Wysocki <[email protected]>; Rob Herring <[email protected]>; linux- [email protected]; [email protected]; linux- [email protected]
Oggetto: Re: [RFC PATCH v2 2/2] dt-bindings: cpufreq: Document Krait CPU Cache scalingQuoted 5 lines · Ansuel Smith
Document dedicated Krait CPU Cache Scaling driver.
Signed-off-by Ansuel Smith <[email protected]>--- .../bindings/cpufreq/krait-cache-scale.yaml | 92+++++++++++++++++++
Quoted 2 lines
1 file changed, 92 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/krait-
cache-scale.yamlReview
Quoted 2 lines
(quoted diff) +0
-0
scale.yamlb/Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yamlDocumentation/devicetree/bindings/cpufreq/krait-cache-
Quoted 4 lines
new file mode 100644
index 000000000000..f10b1f386a99Documentation/devicetree/bindings/cpufreq/krait-cache- new file +0
-0
scale.yamlQuoted 20 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- new file +19
-0@@ -0,0 +1,92 @@ +# 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.
Quoted 9 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- line 24
Quoted 5 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- new file +5
-0+ +properties: + compatible: + const: qcom,krait-cache +How does this fit in the standard cache hierarchy nodes ? Extend the example to cover that.
I think i didn't understand this question. You mean that I should put in the example how the standard l2 cache nodes are defined?
Quoted 13 lines
Quoted 13 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- new file +13
-0+ 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.
Quoted 9 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- line 43
Quoted 6 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- new file +6
-0+ $ref: /schemas/types.yaml#/definitions/uint32-array + items: + - description: idle + - description: nominal + - description: high +Why can't you re-use the standard OPP v2 bindings ?
Isn't overkill to use the OPP v2 bindings to represent the the microvolt related
to the le freq? Is the OPP v1 sufficient? Also I can't find a way to reflect this specific
case where the l2 rates are changed based on the cpu freq value? Any idea about that?
Quoted 3 lines
--
Regards,
Sudeep
Re: R: [RFC PATCH v2 2/2] dt-bindings: cpufreq: Document Krait CPU Cache scaling
Quoted 62 lines · On Mon, Aug 10, 2020 at 01:15:24PM +0200, [email protected] wrote:
Quoted 52 lines
-----Messaggio originale-----
Da: Sudeep Holla <[email protected]>
Inviato: lunedì 10 agosto 2020 10:02
A: Ansuel Smith <[email protected]>
Cc: Viresh Kumar <[email protected]>; Rafael J. Wysocki <[email protected]>; Rob Herring <[email protected]>; linux- [email protected]; [email protected]; linux- [email protected]
Oggetto: Re: [RFC PATCH v2 2/2] dt-bindings: cpufreq: Document Krait CPU Cache scalingQuoted 5 lines · Ansuel Smith
Document dedicated Krait CPU Cache Scaling driver.
Signed-off-by Ansuel Smith <[email protected]>--- .../bindings/cpufreq/krait-cache-scale.yaml | 92+++++++++++++++++++
Quoted 2 lines
1 file changed, 92 insertions(+) create mode 100644 Documentation/devicetree/bindings/cpufreq/krait-
cache-scale.yamlReview
Quoted 2 lines
(quoted diff) +0
-0
scale.yamlb/Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yamlDocumentation/devicetree/bindings/cpufreq/krait-cache-
Quoted 4 lines
new file mode 100644
index 000000000000..f10b1f386a99Documentation/devicetree/bindings/cpufreq/krait-cache- new file +0
-0
scale.yamlQuoted 20 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- new file +19
-0@@ -0,0 +1,92 @@ +# 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.Quoted 9 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- line 24
Quoted 5 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- new file +5
-0+ +properties: + compatible: + const: qcom,krait-cache +How does this fit in the standard cache hierarchy nodes ? Extend the example to cover that.
Quoted 3 lines
I think i didn't understand this question. You mean that I should put in the example how the standard l2 cache nodes are defined?
I was referring to something like below which I found now in arch/arm/boot/dts/qcom-msm8974.dtsi:
L2: l2-cache {
compatible = "cache";
cache-level = <2>;
qcom,saw = <&saw_l2>;
};Quoted 23 lines
Quoted 13 lines
Quoted 13 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- new file +13
-0+ 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.Quoted 9 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- line 43
Quoted 6 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- new file +6
-0+ $ref: /schemas/types.yaml#/definitions/uint32-array + items: + - description: idle + - description: nominal + - description: high +Why can't you re-use the standard OPP v2 bindings ?
Quoted 2 lines
Isn't overkill to use the OPP v2 bindings to represent the the microvolt related to the le freq? Is the OPP v1 sufficient?
Should be fine if it is allowed. v2 came out in the flow of my thought and was not intentional.
Quoted 3 lines
Also I can't find a way to reflect this specific case where the l2 rates are changed based on the cpu freq value? Any idea about that?
OK, I am always opposed to giving such independent controls in the kernel as one can play around say max cpu freq and lowest cache or vice-versa and create instabilities. IMO this should be completely hidden from OS. But I know these are old platforms, so I will shut my mouth ;)
--
Regards,
Sudeep
R: R: [RFC PATCH v2 2/2] dt-bindings: cpufreq: Document Krait CPU Cache scaling
Quoted 58 lines
-----Messaggio originale-----
Da: Sudeep Holla <[email protected]>
Inviato: lunedì 10 agosto 2020 14:45
A: [email protected]
Cc: 'Viresh Kumar' <[email protected]>; 'Rafael J. Wysocki' <[email protected]>; 'Rob Herring' <[email protected]>; linux- [email protected]; [email protected]; linux- [email protected]
Oggetto: Re: R: [RFC PATCH v2 2/2] dt-bindings: cpufreq: Document Krait CPU Cache scalingQuoted 11 lines · On Mon, Aug 10, 2020 at 01:15:24PM +0200, [email protected] wrote:
Quoted 11 lines
-----Messaggio originale-----
Da: Sudeep Holla <[email protected]>
Inviato: lunedì 10 agosto 2020 10:02
A: Ansuel Smith <[email protected]>
Cc: Viresh Kumar <[email protected]>; Rafael J. Wysocki <[email protected]>; Rob Herring <[email protected]>; linux- [email protected]; [email protected]; linux- [email protected]
Oggetto: Re: [RFC PATCH v2 2/2] dt-bindings: cpufreq: Document KraitCPU
Quoted 11 lines
Quoted 11 lines
Cache scaling
Quoted 5 lines · Ansuel Smith
Document dedicated Krait CPU Cache Scaling driver.
Signed-off-by Ansuel Smith <[email protected]>--- .../bindings/cpufreq/krait-cache-scale.yaml | 92+++++++++++++++++++
Quoted 2 lines
1 file changed, 92 insertions(+) create mode 100644
Documentation/devicetree/bindings/cpufreq/krait-Quoted 19 lines
Quoted 19 lines
cache-scale.yamlReview
Quoted 2 lines
(quoted diff) +0
-0
scale.yamlb/Documentation/devicetree/bindings/cpufreq/krait-cache-scale.yamlDocumentation/devicetree/bindings/cpufreq/krait-cache-
Quoted 4 lines
new file mode 100644
index 000000000000..f10b1f386a99Documentation/devicetree/bindings/cpufreq/krait-cache- new file +0
-0
scale.yamlQuoted 9 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- new file +8
-0@@ -0,0 +1,92 @@ +# 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 +
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- line 16
Quoted 8 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- new file +8
-0+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
Quoted 1 line
Quoted 1 line
Quoted 1 line
Documentation/devicetree/bindings/cpufreq/krait-cache- line 17
Quoted 1 line
Documentation/devicetree/bindings/cpufreq/krait-cache- new file +1
-0+ frequency will scale based on the configured threshold in the
dts.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- line 19
Quoted 2 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- new file +2
-0+ + The cache is hardcoded to 3 frequency bin, idle, nominal and
high.
Quoted 51 lines
Quoted 10 lines
Quoted 9 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- line 24
Quoted 5 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- new file +5
-0+ +properties: + compatible: + const: qcom,krait-cache +How does this fit in the standard cache hierarchy nodes ? Extend the example to cover that.
Quoted 3 lines
I think i didn't understand this question. You mean that I should put in the example how the standard l2 cache nodes are defined?
I was referring to something like below which I found now in
arch/arm/boot/dts/qcom-msm8974.dtsi:L2: l2-cache { compatible = "cache"; cache-level = <2>; qcom,saw = <&saw_l2>; };Quoted 23 lines
Quoted 13 lines
Quoted 13 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- new file +13
-0+ 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.Quoted 9 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- line 43
Quoted 6 lines
Documentation/devicetree/bindings/cpufreq/krait-cache- new file +6
-0+ $ref: /schemas/types.yaml#/definitions/uint32-array + items: + - description: idle + - description: nominal + - description: high +Why can't you re-use the standard OPP v2 bindings ?
Quoted 2 lines
Isn't overkill to use the OPP v2 bindings to represent the the microvolt related to the le freq? Is the OPP v1 sufficient?
Should be fine if it is allowed. v2 came out in the flow of my thought and was not intentional.
Quoted 9 lines
Quoted 3 lines
Also I can't find a way to reflect this specific case where the l2 rates are changed based on the cpu freq value? Any idea about that?
OK, I am always opposed to giving such independent controls in the kernel as one can play around say max cpu freq and lowest cache or vice-versa and create instabilities. IMO this should be completely hidden from OS. But I know these are old platforms, so I will shut my mouth ;)
If we really want to deny this practice, I can add a check in the probe function to fail if the l2 freq threshold is less than the cpu freq.
Quoted 3 lines
--
Regards,
Sudeep