Skip to contentSkip to conversation

Add cpuidle support for Tegra194

PATCH In review Sowjanya Komatineni 5 participants 19 messages Mar 4, 2021 – Mar 16, 2021 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Add cpuidle support for Tegra194

This series adds cpuidle support for Tegra194 carmel CPUs.

MCE firmware is responsible for deciding on CPU idle power state based on state information and MCE firmware background work.

Tegra MCE ARI driver is the interface driver to communicate with MCE firmware from the kernel.

CPU idle driver passes idle state information to MCE through Tegra MCE driver and requests idle state transition to MCE happens through PSCI CPU suspend.

This series includes below patches
- Add CPUIDLE section to MAINTAINERS
- Add Tegra MCE ARI driver to communicate with MCE firmware from kernel
- Add dt-bindings for Tegra194 cpu idle states
- Add cpuidle driver to support Tegra194 CPUs idle state management
- Update Tegra194 device tree with cpuidle support to Tegra194 CPUs.

Sowjanya Komatineni (5):
MAINTAINERS: Add Tegra CPUIDLE driver section
firmware: tegra: Add Tegra194 MCE ARI driver
dt-bindings: arm: Add cpu-idle-states to Tegra194 CPU nodes
cpuidle: Add Tegra194 cpuidle driver
arm64: dts: tegra194: Add CPU idle states

 .../bindings/arm/nvidia,tegra194-ccplex.yaml       |  53 ++++
 MAINTAINERS                                        |  12 +
 arch/arm64/boot/dts/nvidia/tegra194.dtsi           |  28 ++
 drivers/cpuidle/Kconfig.arm                        |  10 +
 drivers/cpuidle/Makefile                           |   1 +
 drivers/cpuidle/cpuidle-tegra194.c                 | 319 +++++++++++++++++++++
 drivers/firmware/tegra/Kconfig                     |  11 +
 drivers/firmware/tegra/Makefile                    |   4 +
 drivers/firmware/tegra/mce-tegra194.c              | 155 ++++++++++
 drivers/firmware/tegra/mce.c                       |  88 ++++++
 include/soc/tegra/mce.h                            |  32 +++
 include/soc/tegra/t194_nvg.h                       |  56 ++++
 12 files changed, 769 insertions(+)
 create mode 100644 drivers/cpuidle/cpuidle-tegra194.c
 create mode 100644 drivers/firmware/tegra/mce-tegra194.c
 create mode 100644 drivers/firmware/tegra/mce.c
 create mode 100644 include/soc/tegra/mce.h
 create mode 100644 include/soc/tegra/t194_nvg.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/5 MAINTAINERS: Add Tegra CPUIDLE driver section

Add Tegra CPUIDLE driver section with maintainers and mailing list entries.

---
 MAINTAINERS | 12 ++++++++++++
 1 file changed, 12 insertions(+)
MAINTAINERS +12 -0
index cac8429..277fcfd 100644
@@ -4679,6 +4679,18 @@ S:	Supported
 F:	drivers/cpuidle/cpuidle-psci.h
 F:	drivers/cpuidle/cpuidle-psci-domain.c
 
+CPUIDLE DRIVER - TEGRA194
+M:	Thierry Reding <[email protected]>
+M:	Jonathan Hunter <[email protected]>
+M:	Krishna Sitaraman <[email protected]>
+M:	Sanjay Chandrashekara <[email protected]>
+M:	Sowjanya Komatineni <[email protected]>
+L:	[email protected]
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/arm/nvidia,tegra194-ccplex.yaml
+F:	drivers/cpuidle/cpuidle-tegra194.c
+
 CRAMFS FILESYSTEM
 M:	Nicolas Pitre <[email protected]>
 S:	Maintained
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH v1 1/5] MAINTAINERS: Add Tegra CPUIDLE driver section

Quoted 13 lines · Sowjanya Komatineni

Add Tegra CPUIDLE driver section with maintainers and mailing list entries.

---
 MAINTAINERS | 12 ++++++++++++
 1 file changed, 12 insertions(+)
MAINTAINERS +0 -0
index cac8429..277fcfd 100644

MAINTAINERS S: Supported · line 4687

Quoted 9 lines
MAINTAINERS +6 -0
@@ -4679,6 +4679,18 @@ S:	Supported
 F:	drivers/cpuidle/cpuidle-psci.h
 F:	drivers/cpuidle/cpuidle-psci-domain.c
 
+CPUIDLE DRIVER - TEGRA194
+M:	Thierry Reding <[email protected]>
+M:	Jonathan Hunter <[email protected]>
+M:	Krishna Sitaraman <[email protected]>
+M:	Sanjay Chandrashekara <[email protected]>
+M:	Sowjanya Komatineni <[email protected]>

It does not make sense to have so many maintainers for a single file.

Quoted 10 lines
MAINTAINERS +6 -0
+L:	[email protected]
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/arm/nvidia,tegra194-ccplex.yaml
+F:	drivers/cpuidle/cpuidle-tegra194.c
+
 CRAMFS FILESYSTEM
 M:	Nicolas Pitre <[email protected]>
 S:	Maintained
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#3 lore raw

PATCH 2/5 firmware: tegra: Add Tegra194 MCE ARI driver

In reply to Sowjanya Komatineni

Tegra MCE Abstract Request Interface (ARI) driver manages all NVG requests to MCE firmware running in the background.

This patch adds Tegra194 MCE interface driver for communicating with MCE firmware on CPU state configurations and state transition requests from the CPU idle driver.

---
 drivers/firmware/tegra/Kconfig        |  11 +++
 drivers/firmware/tegra/Makefile       |   4 +
 drivers/firmware/tegra/mce-tegra194.c | 155 ++++++++++++++++++++++++++++++++++
 drivers/firmware/tegra/mce.c          |  88 +++++++++++++++++++
 include/soc/tegra/mce.h               |  32 +++++++
 include/soc/tegra/t194_nvg.h          |  56 ++++++++++++
 6 files changed, 346 insertions(+)
 create mode 100644 drivers/firmware/tegra/mce-tegra194.c
 create mode 100644 drivers/firmware/tegra/mce.c
 create mode 100644 include/soc/tegra/mce.h
 create mode 100644 include/soc/tegra/t194_nvg.h
drivers/firmware/tegra/Kconfig +11 -0
index 1c8ba1f..a14ef1c 100644
@@ -23,4 +23,15 @@ config TEGRA_BPMP
 	  This driver manages the IPC interface between host CPU and the
 	  firmware running on BPMP.
 
+config TEGRA_MCE
+	bool "Tegra MCE driver"
+	depends on ARCH_TEGRA_194_SOC
+	help
+	  MCE (Micro Codec Engine) firmware is in charge of CPUs power state
+	  transitions.
+
+	  Tegra MCE driver is an interface driver to communicate with MCE
+	  firmware for all the CPU power state change requests from CPU idle
+	  driver.
+
 endmenu
drivers/firmware/tegra/Makefile +4 -0
index 49c87e0..2c0417e 100644
@@ -6,3 +6,7 @@ tegra-bpmp-$(CONFIG_ARCH_TEGRA_194_SOC)	+= bpmp-tegra186.o
 tegra-bpmp-$(CONFIG_DEBUG_FS)	+= bpmp-debugfs.o
 obj-$(CONFIG_TEGRA_BPMP)	+= tegra-bpmp.o
 obj-$(CONFIG_TEGRA_IVC)		+= ivc.o
+
+tegra-mce-y			= mce.o
+tegra-mce-$(CONFIG_ARCH_TEGRA_194_SOC)	+= mce-tegra194.o
+obj-$(CONFIG_TEGRA_MCE)		+= tegra-mce.o
drivers/firmware/tegra/mce-tegra194.c new file +155 -0

155 lines not on this page · raw message

drivers/firmware/tegra/mce.c new file +88 -0

88 lines not on this page · raw message

include/soc/tegra/mce.h new file +32 -0
new file mode 100644
index 0000000..d4be89f
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2021 NVIDIA Corporation
+ */
+
+#ifndef __SOC_TEGRA_MCE_H__
+#define __SOC_TEGRA_MCE_H__
+
+/*
+ * For correct version validation, below two defines need to be
+ * updated whenever there is a new ARI implementation.
+ */
+#define CUR_ARI_VER_MAJOR	1
+#define CUR_ARI_VER_MINOR	2
+
+int tegra_mce_update_cstate_info(u32 cluster, u32 ccplex, u32 system,
+				 u8 force, u32 wake_mask, bool valid);
+int tegra_mce_update_crossover_time(u32 type, u32 time);
+int tegra_mce_read_cstate_stats(u32 state, u64 *stats);
+int tegra_mce_read_versions(u32 *major, u32 *minor);
+
+struct tegra_mce_ops {
+	int (*update_cstate_info)(u32 cluster, u32 ccplex, u32 system,
+				  u8 force, u32 wake_mask, bool valid);
+	int (*update_crossover_time)(u32 type, u32 time);
+	int (*read_cstate_stats)(u32 state, u64 *stats);
+	int (*read_versions)(u32 *major, u32 *minor);
+};
+
+void tegra_mce_set_ops(struct tegra_mce_ops *mce_ops);
+
+#endif /* __SOC_TEGRA_MCE_H__ */
include/soc/tegra/t194_nvg.h new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
2.7.4
#4 lore raw

PATCH 3/5 dt-bindings: arm: Add cpu-idle-states to Tegra194 CPU nodes

In reply to Sowjanya Komatineni

This patch adds cpu-idle-states and corresponding state nodes to Tegra194 CPU in dt-binding document

---
 .../bindings/arm/nvidia,tegra194-ccplex.yaml       | 53 ++++++++++++++++++++++
 1 file changed, 53 insertions(+)
Documentation/devicetree/bindings/arm/nvidia,tegra194-ccplex.yaml +53 -0
index c9675c4..e1a5005 100644
@@ -30,6 +30,36 @@ properties:
       Specifies the bpmp node that needs to be queried to get
       operating point data for all CPUs.
 
+  cluster-deepest-power-state:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: CPU cluster deepest power state ID.
+
+patternProperties:
+  "^[a-z0-9]+$":
+    type: object
+    description: |
+      CPU core idle state nodes.
+      Refer to Documentation/devicetree/bindings/arm/idle-states.yaml
+
+    properties:
+      compatible:
+        enum:
+          - nvidia,tegra194-cpuidle-core
+
+  cpu_crossover_thresholds:
+    type: object
+    description: CPU idle states crossover threshold time in uSec.
+
+    patternProperties:
+      "^[a-z0-9]+$":
+        type: object
+
+        properties:
+          crossover_c1_c6:
+            $ref: /schemas/types.yaml#/definitions/uint32
+          crossover_cc1_cc6:
+            $ref: /schemas/types.yaml#/definitions/uint32
+
 additionalProperties: true
 
 examples:
@@ -39,12 +69,14 @@ examples:
       nvidia,bpmp = <&bpmp>;
       #address-cells = <1>;
       #size-cells = <0>;
+      cluster-deepest-power-state = <0x6>;
 
       cpu0_0: cpu@0 {
         compatible = "nvidia,tegra194-carmel";
         device_type = "cpu";
         reg = <0x0>;
         enable-method = "psci";
+        cpu-idle-states = <&C6>;
       };
 
       cpu0_1: cpu@1 {
@@ -52,6 +84,7 @@ examples:
         device_type = "cpu";
         reg = <0x001>;
         enable-method = "psci";
+        cpu-idle-states = <&C6>;
       };
 
       cpu1_0: cpu@100 {
@@ -59,6 +92,7 @@ examples:
         device_type = "cpu";
         reg = <0x100>;
         enable-method = "psci";
+        cpu-idle-states = <&C6>;
       };
 
       cpu1_1: cpu@101 {
@@ -66,6 +100,25 @@ examples:
         device_type = "cpu";
         reg = <0x101>;
         enable-method = "psci";
+        cpu-idle-states = <&C6>;
+      };
+
+      cpu_core_power_states {
+       C6: c6 {
+         compatible = "nvidia,tegra194-cpuidle-core";
+         idle-state-name = "CPU powergated, state retained";
+         wakeup-latency-us = <2000>;
+         min-residency-us = <30000>;
+         arm,psci-suspend-param = <0x6>;
+         status = "okay";
+       };
+     };
+
+     cpu_crossover_thresholds {
+      thresholds {
+        crossover_c1_c6         = <30000>;
+        crossover_cc1_cc6       = <80000>;
       };
+     };
     };
 ...
Signature · 1 line
2.7.4
maintainer
#5 lore raw

Re: [PATCH v1 3/5] dt-bindings: arm: Add cpu-idle-states to Tegra194 CPU nodes

Quoted 8 lines · Sowjanya Komatineni

This patch adds cpu-idle-states and corresponding state nodes to Tegra194 CPU in dt-binding document

---
 .../bindings/arm/nvidia,tegra194-ccplex.yaml       | 53 ++++++++++++++++++++++
 1 file changed, 53 insertions(+)

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

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/arm/nvidia,tegra194-ccplex.example.dt.yaml: cpus: compatible: ['nvidia,tegra194-ccplex'] is not of type 'object'
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/arm/nvidia,tegra194-ccplex.yaml

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

This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

#6 lore raw

Re: [PATCH v1 3/5] dt-bindings: arm: Add cpu-idle-states to Tegra194 CPU nodes

In reply to Sowjanya Komatineni
Quoted 3 lines · Sowjanya Komatineni

This patch adds cpu-idle-states and corresponding state nodes to Tegra194 CPU in dt-binding document

I see that this platform has PSCI support. Can you care to explain why you need additional DT bindings and driver for PSCI based CPU suspend. Until the reasons are convincing, consider NACK from my side for this driver and DT bindings. You should be really using those bindings and the driver may be with minor changes there.

Signature · 2 lines
Regards,
Sudeep
#7 lore raw

Re: [PATCH v1 3/5] dt-bindings: arm: Add cpu-idle-states to Tegra194 CPU nodes

Quoted 10 lines · Sudeep Holla
Quoted 3 lines · Sowjanya Komatineni

This patch adds cpu-idle-states and corresponding state nodes to Tegra194 CPU in dt-binding document

I see that this platform has PSCI support. Can you care to explain why you need additional DT bindings and driver for PSCI based CPU suspend. Until the reasons are convincing, consider NACK from my side for this driver and DT bindings. You should be really using those bindings and the driver may be with minor changes there.

MCE firmware is in charge of state transition for Tegra194 carmel CPUs.

For run-time state transitions, need to provide state request along with its residency time to MCE firmware which is running in the background.

State min residency is updated into power_state value along with state id that is passed to psci_cpu_suspend_enter

Also states cross-over idle times need to be provided to MCE firmware.

MCE firmware decides on state transition based on these inputs along with its background work load.

So, Tegra specific CPU idle driver is required mainly to provide cross-over thresholds from DT and run time idle state information to MCE firmware through Tegra MCE communication APIs.

Allowing cross-over threshold through DT allows users to vary idle time thresholds for state transitions based on different use-cases.

#8 lore raw

Re: [PATCH v1 3/5] dt-bindings: arm: Add cpu-idle-states to Tegra194 CPU nodes

Quoted 18 lines · Sowjanya Komatineni
Quoted 10 lines · Sudeep Holla
Quoted 3 lines · Sowjanya Komatineni

This patch adds cpu-idle-states and corresponding state nodes to Tegra194 CPU in dt-binding document

I see that this platform has PSCI support. Can you care to explain why you need additional DT bindings and driver for PSCI based CPU suspend. Until the reasons are convincing, consider NACK from my side for this driver and DT bindings. You should be really using those bindings and the driver may be with minor changes there.

MCE firmware is in charge of state transition for Tegra194 carmel CPUs.

For run-time state transitions, need to provide state request along with its residency time to MCE firmware which is running in the background.

State min residency is updated into power_state value along with state id that is passed to psci_cpu_suspend_enter

Quoted 8 lines

Also states cross-over idle times need to be provided to MCE firmware.

MCE firmware decides on state transition based on these inputs along with its background work load.

So, Tegra specific CPU idle driver is required mainly to provide cross-over thresholds from DT and run time idle state information to MCE firmware through Tegra MCE communication APIs.

Allowing cross-over threshold through DT allows users to vary idle time thresholds for state transitions based on different use-cases.

Hi Sudeep,

Can you please let me know if you have any more concerns for having this Tegra specific cpuidle driver?

Thanks

Sowjanya

#9 lore raw

Re: [PATCH v1 3/5] dt-bindings: arm: Add cpu-idle-states to Tegra194 CPU nodes

In reply to Sowjanya Komatineni
Quoted 6 lines · Sowjanya Komatineni
Quoted 4 lines · Sudeep Holla
Quoted 3 lines · Sowjanya Komatineni

This patch adds cpu-idle-states and corresponding state nodes to Tegra194 CPU in dt-binding document

Quoted 8 lines
Quoted 6 lines

I see that this platform has PSCI support. Can you care to explain why you need additional DT bindings and driver for PSCI based CPU suspend. Until the reasons are convincing, consider NACK from my side for this driver and DT bindings. You should be really using those bindings and the driver may be with minor changes there.

MCE firmware is in charge of state transition for Tegra194 carmel CPUs.

Sure, but I assume only TF-A talks to MCE and not any OSPM/Linux kernel.

Quoted 3 lines

For run-time state transitions, need to provide state request along with its residency time to MCE firmware which is running in the background.

Sounds similar to x86 mwait, perhaps we need to extend PSCI if we need to make this firmware PSCI compliant or just say it is not and implement completely independent implementation. I am not saying that is acceptable ATM but I prefer not to mix some implementation to make it look like PSCI compliant.

Quoted 3 lines

State min residency is updated into power_state value along with state id that is passed to psci_cpu_suspend_enter

Sounds like a hack/workaround. I would prefer to standardise that. IIUC the power_state is more static and derived from DT. I don't like to overload that TBH. Need to check with authors of that binding.

Quoted 2 lines

Also states cross-over idle times need to be provided to MCE firmware.

New requirements if this has to be PSCI compliant.

Quoted 7 lines

MCE firmware decides on state transition based on these inputs along with its background work load.

So, Tegra specific CPU idle driver is required mainly to provide cross-over thresholds from DT and run time idle state information to MCE firmware through Tegra MCE communication APIs.

I am worried if different vendors will come up with different custom solution for this. We need to either standardise this is Linux/DT or in PSCI.

Quoted 3 lines

Allowing cross-over threshold through DT allows users to vary idle time thresholds for state transitions based on different use-cases.

Sounds like policy and not platform specific to be in DT, but I will leave that to DT maintainers.

--
Regards,
Sudeep

#10 lore raw

Re: [PATCH v1 3/5] dt-bindings: arm: Add cpu-idle-states to Tegra194 CPU nodes

Quoted 12 lines · Sudeep Holla
Quoted 11 lines · Sowjanya Komatineni
Quoted 10 lines · Sudeep Holla
Quoted 3 lines · Sowjanya Komatineni

This patch adds cpu-idle-states and corresponding state nodes to Tegra194 CPU in dt-binding document

I see that this platform has PSCI support. Can you care to explain why you need additional DT bindings and driver for PSCI based CPU suspend. Until the reasons are convincing, consider NACK from my side for this driver and DT bindings. You should be really using those bindings and the driver may be with minor changes there.

Quoted 3 lines
Quoted 2 lines

MCE firmware is in charge of state transition for Tegra194 carmel CPUs.

Sure, but I assume only TF-A talks to MCE and not any OSPM/Linux kernel.

No. Tegra194 CPU idle driver works with MCE firmware running in background so cpuidle kernel driver also talks to MCE firmware directly on state information.

Quoted 10 lines
Quoted 4 lines

For run-time state transitions, need to provide state request along with its residency time to MCE firmware which is running in the background.

Sounds similar to x86 mwait, perhaps we need to extend PSCI if we need to make this firmware PSCI compliant or just say it is not and implement completely independent implementation. I am not saying that is acceptable ATM but I prefer not to mix some implementation to make it look like PSCI compliant.

Quoted 6 lines
Quoted 3 lines

State min residency is updated into power_state value along with state id that is passed to psci_cpu_suspend_enter

Sounds like a hack/workaround. I would prefer to standardise that. IIUC the power_state is more static and derived from DT. I don't like to overload that TBH. Need to check with authors of that binding.

Passing state idle time to ATF along with state to enter is Tegra specific as ATF firmware updates idle time to Tegra MCE firmware which will be used for deciding on state transition along with other information and background load.

Not sure if this need to be standardized but will try to find alternate way to update idle time without misusing power-state value.

Will discuss on this internally and get back.

Quoted 4 lines
Quoted 3 lines

Also states cross-over idle times need to be provided to MCE firmware.

New requirements if this has to be PSCI compliant.

Updating cross-over idle times from DT to MCE firmware directly from cpuidle kernel driver with corresponding MCE ARI commands is again Tegra specific.

Quoted 12 lines
Quoted 8 lines

MCE firmware decides on state transition based on these inputs along with its background work load.

So, Tegra specific CPU idle driver is required mainly to provide cross-over thresholds from DT and run time idle state information to MCE firmware through Tegra MCE communication APIs.

I am worried if different vendors will come up with different custom solution for this. We need to either standardise this is Linux/DT or in PSCI.

Quoted 5 lines
Quoted 3 lines

Allowing cross-over threshold through DT allows users to vary idle time thresholds for state transitions based on different use-cases.

Sounds like policy and not platform specific to be in DT, but I will leave that to DT maintainers.

cross-over idle times are based on supported CPU core and cluster states and updating these from DT to Tegra MCE firmware running in the background is Tegra specific.

Quoted 4 lines

--
Regards,
Sudeep

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#13 lore raw

Re: [PATCH v1 3/5] dt-bindings: arm: Add cpu-idle-states to Tegra194 CPU nodes

Re-sending as it went out as HTML instead of plain text.

Quoted 116 lines · Sowjanya Komatineni

Hi Sudeep,

I see you are one of the maintainer of PSCI driver. Please add any other right persons if you think should also agree/comment.

Can you please comment on below 2 items based on your feedback?

1. Can you please suggest on proper way of generalizing to pass state residency time run-time along with state during state enter?

Not sure if any other drivers need this but for Tegra as MCE firmware is in-charge of states enter and decisions, passing run-time state residency from kernel to ATF is required and agree on not using power_state value for this which is against PSCI spec.

2. Regarding state thresholds, although state thresholds are policy related in Tegra cpu idle perspective these thresholds are platform specific based on use case and mainly for MCE firmware usage to decide on state transitions for core and core clusters as well.

As these are Tegra platform specific, Please comment if any other concerns in having this configured by Tegra CPU Idle kernel driver.

Based on my understanding only above issue-1 is PSCI compliant related. Please confirm.

Thanks

Sowjanya

Quoted 93 lines · Sowjanya Komatineni

Hi Sudeep,

To make our driver PSCI compliant below are few updates to be done

1. Standardize passing residency time run-time thru PSCI to ATF.

    From PSCI specification I only see PSCI_STAT_RESIDENCY and PSCI_STAT_COUNT optional functions for PSCI1.0/PSCI1.1

   Can you please help add right people to explore on possible ways to add PSCI function for passing corresponding state residency time to ATF?

2. Tegra CPU Idle support definitely need to pass deepest cluster state and threshold to MCE firmware from DT and looks like we can move this implementation to ATF

     With both of the above implementation changes Tegra194 driver will be PSCI compliant.

Thanks

Sowjanya

Quoted 72 lines · Sowjanya Komatineni
Quoted 12 lines · Sudeep Holla
Quoted 11 lines · Sowjanya Komatineni
Quoted 10 lines · Sudeep Holla
Quoted 3 lines · Sowjanya Komatineni

This patch adds cpu-idle-states and corresponding state nodes to Tegra194 CPU in dt-binding document

I see that this platform has PSCI support. Can you care to explain why you need additional DT bindings and driver for PSCI based CPU suspend. Until the reasons are convincing, consider NACK from my side for this driver and DT bindings. You should be really using those bindings and the driver may be with minor changes there.

Quoted 3 lines
Quoted 2 lines

MCE firmware is in charge of state transition for Tegra194 carmel CPUs.

Sure, but I assume only TF-A talks to MCE and not any OSPM/Linux kernel.

No. Tegra194 CPU idle driver works with MCE firmware running in background so cpuidle kernel driver also talks to MCE firmware directly on state information.

Quoted 10 lines
Quoted 4 lines

For run-time state transitions, need to provide state request along with its residency time to MCE firmware which is running in the background.

Sounds similar to x86 mwait, perhaps we need to extend PSCI if we need to make this firmware PSCI compliant or just say it is not and implement completely independent implementation. I am not saying that is acceptable ATM but I prefer not to mix some implementation to make it look like PSCI compliant.

Quoted 6 lines
Quoted 3 lines

State min residency is updated into power_state value along with state id that is passed to psci_cpu_suspend_enter

Sounds like a hack/workaround. I would prefer to standardise that. IIUC the power_state is more static and derived from DT. I don't like to overload that TBH. Need to check with authors of that binding.

Passing state idle time to ATF along with state to enter is Tegra specific as ATF firmware updates idle time to Tegra MCE firmware which will be used for deciding on state transition along with other information and background load.

Not sure if this need to be standardized but will try to find alternate way to update idle time without misusing power-state value.

Will discuss on this internally and get back.

Quoted 4 lines
Quoted 3 lines

Also states cross-over idle times need to be provided to MCE firmware.

New requirements if this has to be PSCI compliant.

Updating cross-over idle times from DT to MCE firmware directly from cpuidle kernel driver with corresponding MCE ARI commands is again Tegra specific.

Quoted 12 lines
Quoted 8 lines

MCE firmware decides on state transition based on these inputs along with its background work load.

So, Tegra specific CPU idle driver is required mainly to provide cross-over thresholds from DT and run time idle state information to MCE firmware through Tegra MCE communication APIs.

I am worried if different vendors will come up with different custom solution for this. We need to either standardise this is Linux/DT or in PSCI.

Quoted 5 lines
Quoted 3 lines

Allowing cross-over threshold through DT allows users to vary idle time thresholds for state transitions based on different use-cases.

Sounds like policy and not platform specific to be in DT, but I will leave that to DT maintainers.

cross-over idle times are based on supported CPU core and cluster states and updating these from DT to Tegra MCE firmware running in the background is Tegra specific.

Quoted 4 lines
Signature · 3 lines
-- 
Regards,
Sudeep
#14 lore raw

Re: [PATCH v1 3/5] dt-bindings: arm: Add cpu-idle-states to Tegra194 CPU nodes

In reply to a message not in the archive
Quoted 7 lines · Sowjanya Komatineni

Hi Sudeep,

I see you are one of the maintainer of PSCI driver. Please add any other right persons if you think should also agree/comment.

Can you please comment on below 2 items based on your feedback?

Quoted 8 lines

1. Can you please suggest on proper way of generalizing to pass state residency time run-time along with state during state enter?

Not sure if any other drivers need this but for Tegra as MCE firmware is in-charge of states enter and decisions, passing run-time state residency from kernel to ATF is required and agree on not using power_state value for this which is against PSCI spec.

Yes, I prefer you need to get this added in the PSCI specification. I have passed this thread to the author of the specification.

Quoted 5 lines

2. Regarding state thresholds, although state thresholds are policy related in Tegra cpu idle perspective these thresholds are platform specific based on use case and mainly for MCE firmware usage to decide on state transitions for core and core clusters as well.

From previous emails, I gather these can be moved to firmware and need not be there in DT ?

Quoted 3 lines

As these are Tegra platform specific, Please comment if any other concerns in having this configured by Tegra CPU Idle kernel driver.

I prefer not to have Tegra specific idle driver if we can get the necessary changes in PSCI spec. We must then have just one PSCI idle driver in the kernel.

Quoted 3 lines

Based on my understanding only above issue-1 is PSCI compliant related. Please confirm.

Correct.

--
Regards,
Sudeep

#15 lore raw

Re: [PATCH v1 3/5] dt-bindings: arm: Add cpu-idle-states to Tegra194 CPU nodes

Quoted 11 lines · Sudeep Holla
Quoted 10 lines · Sowjanya Komatineni

Hi Sudeep,

I see you are one of the maintainer of PSCI driver. Please add any other right persons if you think should also agree/comment.

Can you please comment on below 2 items based on your feedback?

1. Can you please suggest on proper way of generalizing to pass state residency time run-time along with state during state enter?

Quoted 7 lines
Quoted 5 lines

Not sure if any other drivers need this but for Tegra as MCE firmware is in-charge of states enter and decisions, passing run-time state residency from kernel to ATF is required and agree on not using power_state value for this which is against PSCI spec.

Yes, I prefer you need to get this added in the PSCI specification. I have passed this thread to the author of the specification.

Thanks Sudeep.

Quoted 8 lines
Quoted 6 lines

2. Regarding state thresholds, although state thresholds are policy related in Tegra cpu idle perspective these thresholds are platform specific based on use case and mainly for MCE firmware usage to decide on state transitions for core and core clusters as well.

From previous emails, I gather these can be moved to firmware and need not be
there in DT ?

Yes we can move state thresholds programming from kernel driver to ATF but we still need to use DT properties for this to allow users to tweak for their use-cases.

With DT access in ATF this can be done. But checking internally on having DTB access in ATF as currently we don't support that.

Quoted 7 lines
Quoted 4 lines

As these are Tegra platform specific, Please comment if any other concerns in having this configured by Tegra CPU Idle kernel driver.

I prefer not to have Tegra specific idle driver if we can get the necessary changes in PSCI spec. We must then have just one PSCI idle driver in the kernel.

Agree by adding state residency run-time propagation along with power state to PSCI specification and moving state thresholds update to MCE from kernel driver to AT looks like we can use same PSCI cpu idle driver although we will be using state thresholds additional DT properties under cpu nodes which will be used by ATF firmware once we decide on no concerns to allow DTB access in ATF.

Quoted 8 lines
Quoted 3 lines

Based on my understanding only above issue-1 is PSCI compliant related. Please confirm.

Correct.

--
Regards,
Sudeep

#16 lore raw

Re: [PATCH v1 3/5] dt-bindings: arm: Add cpu-idle-states to Tegra194 CPU nodes

In reply to a message not in the archive
Quoted 6 lines · Sowjanya Komatineni

Hi Sudeep,

To make our driver PSCI compliant below are few updates to be done

1. Standardize passing residency time run-time thru PSCI to ATF.

Yes that was my initial understanding, but your previous response was confusing. I should have read this first.

Quoted 3 lines

    From PSCI specification I only see PSCI_STAT_RESIDENCY and PSCI_STAT_COUNT optional functions for PSCI1.0/PSCI1.1

Indeed, we don't have any support to pass run-time residency hints in PSCI today.

Quoted 3 lines

   Can you please help add right people to explore on possible ways to add PSCI function for passing corresponding state residency time to ATF?

Before we jump to implementation in TF-A we need to get agreement to get this added to the specification to support in OSPM/Linux. TF-A is just one implementation of PSCI and may not be only one.

Formally you can raise any specification related queries to
https://developer.arm.com/support or [email protected]. I will ask the author of PSCI specification internally to take a look at this thread and chime in if they can.

Quoted 4 lines

2. Tegra CPU Idle support definitely need to pass deepest cluster state and threshold to MCE firmware from DT and looks like we can move this implementation to ATF

Yes, I just asked the same question as response to your earlier email. Thanks for confirming that it can be moved out of OSPM/Linux and DT

Quoted 3 lines

     With both of the above implementation changes Tegra194 driver will be PSCI compliant.

We still need to get agreement on the specification front 😉.

--
Regards,
Sudeep

#17 lore raw

Re: [PATCH v1 3/5] dt-bindings: arm: Add cpu-idle-states to Tegra194 CPU nodes

In reply to Sowjanya Komatineni

+Lorenzo

Hi Sowjanya,

Sorry for the delayed response. I am still in vacation 😉

Quoted 14 lines · Sowjanya Komatineni
Quoted 12 lines · Sudeep Holla
Quoted 11 lines · Sowjanya Komatineni
Quoted 10 lines · Sudeep Holla
Quoted 3 lines · Sowjanya Komatineni

This patch adds cpu-idle-states and corresponding state nodes to Tegra194 CPU in dt-binding document

I see that this platform has PSCI support. Can you care to explain why you need additional DT bindings and driver for PSCI based CPU suspend. Until the reasons are convincing, consider NACK from my side for this driver and DT bindings. You should be really using those bindings and the driver may be with minor changes there.

Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

MCE firmware is in charge of state transition for Tegra194 carmel CPUs.

Sure, but I assume only TF-A talks to MCE and not any OSPM/Linux kernel.

No. Tegra194 CPU idle driver works with MCE firmware running in background so cpuidle kernel driver also talks to MCE firmware directly on state information.

If that is the case I wouldn't term this as PSCI compliant firmware and wouldn't attempt to use PSCI CPU idle driver. Now if we would what to allow non-PSCI idle driver for Arm64 is entirely different question that deserves a separate discussion IMO.

Quoted 13 lines
Quoted 13 lines
Quoted 4 lines

For run-time state transitions, need to provide state request along with its residency time to MCE firmware which is running in the background.

Sounds similar to x86 mwait, perhaps we need to extend PSCI if we need to make this firmware PSCI compliant or just say it is not and implement completely independent implementation. I am not saying that is acceptable ATM but I prefer not to mix some implementation to make it look like PSCI compliant.

Quoted 3 lines

State min residency is updated into power_state value along with state id that is passed to psci_cpu_suspend_enter

Quoted 9 lines
Quoted 3 lines

Sounds like a hack/workaround. I would prefer to standardise that. IIUC the power_state is more static and derived from DT. I don't like to overload that TBH. Need to check with authors of that binding.

Passing state idle time to ATF along with state to enter is Tegra specific as ATF firmware updates idle time to Tegra MCE firmware which will be used for deciding on state transition along with other information and background load.

So far we don't have any platform specific PSCI in OSPM and I prefer to keep it that way.

Quoted 3 lines

Not sure if this need to be standardized but will try to find alternate way to update idle time without misusing power-state value.

Sure, we can always review and see if any alternatives are acceptable, but I am bit nervous to tie this as PSCI if it is not strictly spec compliant.

Quoted 2 lines

Will discuss on this internally and get back.

Thanks.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

Also states cross-over idle times need to be provided to MCE firmware.

New requirements if this has to be PSCI compliant.

Updating cross-over idle times from DT to MCE firmware directly from cpuidle kernel driver with corresponding MCE ARI commands is again Tegra specific.

So all there are platform specific but static information you need from DT ? If so, what can't it be made part of TF-A and OSPM can avoid interfering with that info completely. My understanding was that OSPM provides runtime hints like x86 mwait. If that's not the case, I am failing to understand the need for OSPM to pass such static information from DT to the firmware. Why can't that be just part of the firmware to begin with ?

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

MCE firmware decides on state transition based on these inputs along with its background work load.

What do you mean by this *"background work load"* ?

--
Regards,
Sudeep

#18 lore raw

PATCH 4/5 cpuidle: Add Tegra194 cpuidle driver

In reply to Sowjanya Komatineni

This patch adds cpuidle driver for Tegra194.

Tegra194 Carmel CPU supports two core idle state C1 (clock gated) and C6 (power gated with state restoration) and one cluster idle state CC6 (power gated).

MCE firmware makes decision on core/cluster power state transition based on its background tasks and states information provided by CPU idle driver.

CPU idle driver provides deepest cluster power state, core power state transition request, estimated time of next wake-up and states crossover thresholds to MCE firmware through Tegra mce driver.

---
 drivers/cpuidle/Kconfig.arm        |  10 ++
 drivers/cpuidle/Makefile           |   1 +
 drivers/cpuidle/cpuidle-tegra194.c | 319 +++++++++++++++++++++++++++++++++++++
 3 files changed, 330 insertions(+)
 create mode 100644 drivers/cpuidle/cpuidle-tegra194.c
drivers/cpuidle/Kconfig.arm +10 -0
index 0844fad..e9adad1 100644
@@ -105,6 +105,16 @@ config ARM_TEGRA_CPUIDLE
 	help
 	  Select this to enable cpuidle for NVIDIA Tegra20/30/114/124 SoCs.
 
+config ARM_TEGRA194_CPUIDLE
+	tristate "CPU Idle Driver for NVIDIA Tegra194 SoC"
+	depends on ARCH_TEGRA_194_SOC
+	select ARM_CPU_SUSPEND
+	select DT_IDLE_STATES
+	select TEGRA_MCE
+	default y
+	help
+	  Select this to enable cpuidle for NVIDIA Tegra194 SoC.
+
 config ARM_QCOM_SPM_CPUIDLE
 	bool "CPU Idle Driver for Qualcomm Subsystem Power Manager (SPM)"
 	depends on (ARCH_QCOM || COMPILE_TEST) && !ARM64
drivers/cpuidle/Makefile +1 -0
index 26bbc5e..4d89578 100644
@@ -24,6 +24,7 @@ obj-$(CONFIG_ARM_CPUIDLE)		+= cpuidle-arm.o
 obj-$(CONFIG_ARM_PSCI_CPUIDLE)		+= cpuidle-psci.o
 obj-$(CONFIG_ARM_PSCI_CPUIDLE_DOMAIN)	+= cpuidle-psci-domain.o
 obj-$(CONFIG_ARM_TEGRA_CPUIDLE)		+= cpuidle-tegra.o
+obj-$(CONFIG_ARM_TEGRA194_CPUIDLE)      += cpuidle-tegra194.o
 obj-$(CONFIG_ARM_QCOM_SPM_CPUIDLE)	+= cpuidle-qcom-spm.o
 
 ###############################################################################
drivers/cpuidle/cpuidle-tegra194.c new file +319 -0

319 lines not on this page · raw message

Signature · 1 line
2.7.4
#19 lore raw

Re: [PATCH v1 4/5] cpuidle: Add Tegra194 cpuidle driver

04.03.2021 09:08, Sowjanya Komatineni пишет:
...

drivers/cpuidle/cpuidle-tegra194.c line 235

Quoted 7 lines
drivers/cpuidle/cpuidle-tegra194.c new file +7 -0
+static int __init tegra194_cpuidle_probe(struct platform_device *pdev)
+{
+	struct cpumask *cpumask;
+	int cpu, ret;
+
+	if (!check_mce_version()) {
+		pr_err("cpuidle: incompatible MCE version, cannot register driver\n");

Should be dev_err() everywhere.

drivers/cpuidle/cpuidle-tegra194.c line 243

Quoted 8 lines
drivers/cpuidle/cpuidle-tegra194.c new file +8 -0
+		return -ENODEV;
+	}
+
+	tsc_per_usec = arch_timer_get_cntfrq() / 1000000;
+
+	cpumask = devm_kzalloc(&pdev->dev, cpumask_size(), GFP_KERNEL);
+	for_each_online_cpu(cpu)
+		cpumask_set_cpu(cpu, cpumask);

cpumask_copy(..)?

drivers/cpuidle/cpuidle-tegra194.c line 244

Quoted 1 line
drivers/cpuidle/cpuidle-tegra194.c new file +1 -0
+	t194_cpu_idle_driver.cpumask = cpumask;

Depending on 'online' mask instead of the 'present' mask looks odd. Is this really intended to be so?

...

drivers/cpuidle/cpuidle-tegra194.c line 299

Quoted 6 lines
drivers/cpuidle/cpuidle-tegra194.c new file +6 -0
+static int tegra194_cpuidle_remove(struct platform_device *pdev)
+{
+	unregister_pm_notifier(&suspend_notifier);
+	cpuhp_remove_state(hp_state);
+	cpuidle_unregister(&t194_cpu_idle_driver);
+	kfree(t194_cpu_idle_driver.cpumask);

kfree() of a managed resource.

#20 lore raw

PATCH 5/5 arm64: dts: tegra194: Add CPU idle states

In reply to Sowjanya Komatineni

This patch adds CPU core and cluster idle states to Tegra194 device tree

---
 arch/arm64/boot/dts/nvidia/tegra194.dtsi | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
arch/arm64/boot/dts/nvidia/tegra194.dtsi +28 -0
index 9449156..f9c2731 100644
@@ -2155,12 +2155,14 @@
 		nvidia,bpmp = <&bpmp>;
 		#address-cells = <1>;
 		#size-cells = <0>;
+		cluster-deepest-power-state = <0x6>;
 
 		cpu0_0: cpu@0 {
 			compatible = "nvidia,tegra194-carmel";
 			device_type = "cpu";
 			reg = <0x000>;
 			enable-method = "psci";
+			cpu-idle-states = <&C6>;
 			i-cache-size = <131072>;
 			i-cache-line-size = <64>;
 			i-cache-sets = <512>;
@@ -2175,6 +2177,7 @@
 			device_type = "cpu";
 			reg = <0x001>;
 			enable-method = "psci";
+			cpu-idle-states = <&C6>;
 			i-cache-size = <131072>;
 			i-cache-line-size = <64>;
 			i-cache-sets = <512>;
@@ -2189,6 +2192,7 @@
 			device_type = "cpu";
 			reg = <0x100>;
 			enable-method = "psci";
+			cpu-idle-states = <&C6>;
 			i-cache-size = <131072>;
 			i-cache-line-size = <64>;
 			i-cache-sets = <512>;
@@ -2203,6 +2207,7 @@
 			device_type = "cpu";
 			reg = <0x101>;
 			enable-method = "psci";
+			cpu-idle-states = <&C6>;
 			i-cache-size = <131072>;
 			i-cache-line-size = <64>;
 			i-cache-sets = <512>;
@@ -2217,6 +2222,7 @@
 			device_type = "cpu";
 			reg = <0x200>;
 			enable-method = "psci";
+			cpu-idle-states = <&C6>;
 			i-cache-size = <131072>;
 			i-cache-line-size = <64>;
 			i-cache-sets = <512>;
@@ -2231,6 +2237,7 @@
 			device_type = "cpu";
 			reg = <0x201>;
 			enable-method = "psci";
+			cpu-idle-states = <&C6>;
 			i-cache-size = <131072>;
 			i-cache-line-size = <64>;
 			i-cache-sets = <512>;
@@ -2245,6 +2252,7 @@
 			device_type = "cpu";
 			reg = <0x300>;
 			enable-method = "psci";
+			cpu-idle-states = <&C6>;
 			i-cache-size = <131072>;
 			i-cache-line-size = <64>;
 			i-cache-sets = <512>;
@@ -2259,6 +2267,7 @@
 			device_type = "cpu";
 			reg = <0x301>;
 			enable-method = "psci";
+			cpu-idle-states = <&C6>;
 			i-cache-size = <131072>;
 			i-cache-line-size = <64>;
 			i-cache-sets = <512>;
@@ -2343,12 +2352,31 @@
 			cache-line-size = <64>;
 			cache-sets = <4096>;
 		};
+
+		cpu_core_power_states {
+			C6: c6 {
+				compatible = "nvidia,tegra194-cpuidle-core";
+				idle-state-name = "CPU powergated, state retained";
+				wakeup-latency-us = <2000>;
+				min-residency-us = <30000>;
+				arm,psci-suspend-param = <0x6>;
+				status = "okay";
+			};
+		};
+
+		cpu_crossover_thresholds {
+			thresholds {
+				crossover_c1_c6 = <30000>;
+				crossover_cc1_cc6 = <80000>;
+			};
+		};
 	};
 
 	psci {
 		compatible = "arm,psci-1.0";
 		status = "okay";
 		method = "smc";
+		cpu_suspend = <0xC4000001>;
 	};
 
 	sound {
Signature · 1 line
2.7.4