Skip to contentSkip to conversation

devfreq: qcom: Add L2 Krait Cache devfreq scaling driver

PATCH Superseded Ansuel Smith 2 participants 5 messages Sep 27, 2020 – Sep 28, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 devfreq: qcom: Add L2 Krait Cache devfreq scaling driver

Qcom L2 Krait CPUs use the generic cpufreq-dt driver and doesn't actually scale the Cache frequency when the CPU frequency is changed. This devfreq 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/devfreq/Kconfig               |  10 +
 drivers/devfreq/Makefile              |   1 +
 drivers/devfreq/krait-cache-devfreq.c | 298 ++++++++++++++++++++++++++
 3 files changed, 309 insertions(+)
 create mode 100644 drivers/devfreq/krait-cache-devfreq.c
drivers/devfreq/Kconfig +10 -0
index 37dc40d1fcfb..99051aaf9c5e 100644
@@ -143,6 +143,16 @@ config ARM_RK3399_DMC_DEVFREQ
 	  It sets the frequency for the memory controller and reads the usage counts
 	  from hardware.
 
+config ARM_KRAIT_CACHE_DEVFREQ
+	tristate "Scaling support for Krait CPU Cache Devfreq"
+	depends on ARCH_QCOM || COMPILE_TEST
+	help
+	  This adds the DEVFREQ driver for the Krait CPU L2 Cache shared by all cores.
+
+	  The driver register with the cpufreq notifier and find the right frequency
+	  based on the max frequency across all core and the range set in the device
+	  dts. If provided this scale also the regulator attached to the l2 cache.
+
 source "drivers/devfreq/event/Kconfig"
 
 endif # PM_DEVFREQ
drivers/devfreq/Makefile +1 -0
index 3ca1ad0ecb97..bb87925a6a2d 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_ARM_IMX8M_DDRC_DEVFREQ)	+= imx8m-ddrc.o
 obj-$(CONFIG_ARM_RK3399_DMC_DEVFREQ)	+= rk3399_dmc.o
 obj-$(CONFIG_ARM_TEGRA_DEVFREQ)		+= tegra30-devfreq.o
 obj-$(CONFIG_ARM_TEGRA20_DEVFREQ)	+= tegra20-devfreq.o
+obj-$(CONFIG_ARM_KRAIT_CACHE_DEVFREQ)	+= krait-cache-devfreq.o
 
 # DEVFREQ Event Drivers
 obj-$(CONFIG_PM_DEVFREQ_EVENT)		+= event/
drivers/devfreq/krait-cache-devfreq.c new file +298 -0

298 lines not on this page · raw message

Signature · 1 line
2.27.0
#1 lore raw

PATCH 2/2 dt-bindings: devfreq: Document L2 Krait CPU Cache devfreq driver

Document dedicated L2 Krait CPU Cache devfreq scaling driver.

---
 .../bindings/devfreq/krait-cache-devfreq.yaml | 77 +++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml
Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml new file +77 -0
new file mode 100644
index 000000000000..099ed978e022
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/cpufreq/krait-cache-devfreq.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: DEVFREQ driver for Krait L2 Cpu Cache Frequency Scaling
+
+maintainers:
+  - Ansuel Smith <[email protected]>
+
+description: |
+  This Scale the Krait CPU L2 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 tolerance 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
+
+examples:
+  - |
+    qcom-krait-cache {
+      compatible = "qcom,krait-cache";
+      clocks = <&kraitcc 4>;
+      clock-names = "l2";
+      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
maintainer
#2 lore raw

Re: [PATCH 2/2] dt-bindings: devfreq: Document L2 Krait CPU Cache devfreq driver

Quoted 8 lines · Ansuel Smith

Document dedicated L2 Krait CPU Cache devfreq scaling driver.

---
 .../bindings/devfreq/krait-cache-devfreq.yaml | 77 +++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml

My bot found errors running 'make dt_binding_check' on your patch:

./Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml: $id: relative path/filename doesn't match actual path or filename
expected: http://devicetree.org/schemas/devfreq/krait-cache-devfreq.yaml#
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.example.dt.yaml: qcom-krait-cache: clocks:0:1: missing phandle tag in 4
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.example.dt.yaml: qcom-krait-cache: clocks:0: [4294967295, 4] is too long
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.example.dt.yaml: qcom-krait-cache: 'voltage-tolerance' is a required property
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml

See https://patchwork.ozlabs.org/patch/1372099

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.

maintainer
#3 lore raw

Re: [PATCH 2/2] dt-bindings: devfreq: Document L2 Krait CPU Cache devfreq driver

In reply to Ansuel Smith
Quoted 14 lines · Ansuel Smith

Document dedicated L2 Krait CPU Cache devfreq scaling driver.

---
 .../bindings/devfreq/krait-cache-devfreq.yaml | 77 +++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml
Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml new file +0 -0
new file mode 100644
index 000000000000..099ed978e022

Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml line 7

Quoted 7 lines
Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml new file +7 -0
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/cpufreq/krait-cache-devfreq.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: DEVFREQ driver for Krait L2 Cpu Cache Frequency Scaling

Bindings are for h/w devices, not collections of properties for some driver. Define a binding for L2 cache and add on to it what you need.

Quoted 10 lines
Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml new file +10 -0
+
+maintainers:
+  - Ansuel Smith <[email protected]>
+
+description: |
+  This Scale the Krait CPU L2 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.

Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml line 27

Quoted 10 lines
Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml new file +10 -0
+
+  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"

'clocks' already has a type defined. You just need how many and what each entry is.

Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml line 34

Quoted 7 lines
Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml new file +7 -0
+    description: Phandle to the L2 CPU clock
+
+  clock-names:
+    const: "l2"
+
+  voltage-tolerance:
+    description: Same voltage tolerance of the Krait CPU

Needs a vendor prefix and unit suffix.

Quoted 27 lines
Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml new file +27 -0
+
+  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
+

Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml line 71

Quoted 10 lines
Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml new file +10 -0
+examples:
+  - |
+    qcom-krait-cache {
+      compatible = "qcom,krait-cache";
+      clocks = <&kraitcc 4>;
+      clock-names = "l2";
+      l2-cpufreq = <384000 600000 1200000>;
+      l2-supply = <&smb208_s1a>;
+
+      operating-points = <

Not documented and generally deprecated.

Quoted 9 lines
Documentation/devicetree/bindings/devfreq/krait-cache-devfreq.yaml new file +6 -0
+        /* kHz    uV */
+        384000  1100000
+        1000000  1100000
+        1200000  1150000
+      >;
+    };
Signature · 1 line
2.27.0
#4 lore raw

RE: [PATCH 2/2] dt-bindings: devfreq: Document L2 Krait CPU Cache devfreq driver

Quoted 32 lines

-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Monday, September 28, 2020 8:09 PM
To: Ansuel Smith <[email protected]>
Cc: MyungJoo Ham <[email protected]>; Kyungmin Park <[email protected]>; Chanwoo Choi <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/2] dt-bindings: devfreq: Document L2 Krait CPU Cache devfreq driver

Quoted 5 lines · Ansuel Smith

Document dedicated L2 Krait CPU Cache devfreq scaling driver.

---
 .../bindings/devfreq/krait-cache-devfreq.yaml | 77

+++++++++++++++++++

Quoted 2 lines
 1 file changed, 77 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/devfreq/krait-

cache-devfreq.yaml

Review

Quoted 2 lines
(quoted diff) +0 -0

devfreq.yaml b/Documentation/devicetree/bindings/devfreq/krait-cache- devfreq.yaml

Documentation/devicetree/bindings/devfreq/krait-cache-

Quoted 4 lines

new file mode 100644
index 000000000000..099ed978e022

Documentation/devicetree/bindings/devfreq/krait-cache- new file +0 -0

devfreq.yaml

Quoted 12 lines

Documentation/devicetree/bindings/devfreq/krait-cache- line 7

Quoted 8 lines
Documentation/devicetree/bindings/devfreq/krait-cache- new file +7 -0
@@ -0,0 +1,77 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/cpufreq/krait-cache-devfreq.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: DEVFREQ driver for Krait L2 Cpu Cache Frequency Scaling

Bindings are for h/w devices, not collections of properties for some driver. Define a binding for L2 cache and add on to it what you need.

Should I still document it in the devfreq directory or somewhere else?

Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/devfreq/krait-cache- new file +4 -0
+
+maintainers:
+  - Ansuel Smith <[email protected]>
+
Quoted 8 lines

Documentation/devicetree/bindings/devfreq/krait-cache- line 19

Quoted 8 lines
Documentation/devicetree/bindings/devfreq/krait-cache- new file +8 -0
+description: |
+  This Scale the Krait CPU L2 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

Quoted 53 lines

Documentation/devicetree/bindings/devfreq/krait-cache- line 27

Quoted 8 lines
Documentation/devicetree/bindings/devfreq/krait-cache- new file +8 -0
+  high.
+
+properties:
+  compatible:
+    const: qcom,krait-cache
+
+  clocks:
+    $ref: "/schemas/types.yaml#/definitions/phandle"

'clocks' already has a type defined. You just need how many and what each entry is.

Documentation/devicetree/bindings/devfreq/krait-cache- line 34

Quoted 7 lines
Documentation/devicetree/bindings/devfreq/krait-cache- new file +7 -0
+    description: Phandle to the L2 CPU clock
+
+  clock-names:
+    const: "l2"
+
+  voltage-tolerance:
+    description: Same voltage tolerance of the Krait CPU

Needs a vendor prefix and unit suffix.

Quoted 31 lines
Documentation/devicetree/bindings/devfreq/krait-cache- new file +31 -0
+
+  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
+
+examples:
+  - |
+    qcom-krait-cache {
+      compatible = "qcom,krait-cache";
Quoted 9 lines

Documentation/devicetree/bindings/devfreq/krait-cache- line 71

Quoted 6 lines
Documentation/devicetree/bindings/devfreq/krait-cache- new file +6 -0
+      clocks = <&kraitcc 4>;
+      clock-names = "l2";
+      l2-cpufreq = <384000 600000 1200000>;
+      l2-supply = <&smb208_s1a>;
+
+      operating-points = <

Not documented and generally deprecated.

Ok will change to v2.

Quoted 9 lines
Quoted 9 lines
Documentation/devicetree/bindings/devfreq/krait-cache- new file +6 -1
+        /* kHz    uV */
+        384000  1100000
+        1000000  1100000
+        1200000  1150000
+      >;
+    };
--

2.27.0