Skip to contentSkip to conversation

Add CPUidle support for Tegra210

PATCH Superseded Joseph Lo 2 participants 13 messages Jan 31, 2019 – Feb 1, 2019

Subsystems (4)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Joseph Lo

author
#0 lore raw

v4 cover Add CPUidle support for Tegra210

This patch series adds CPUidle support for Tegra210, which supports power-down state (C7) for CPU cores. And due to arch timer cannot work across CPU core power-down and power on reset signal event. We introduce Tegra210 timer driver to work as clock event device. So it can be the wake-up source of CPU cores when they idled in the power-down state.

Fixed in V4:
* merge timer-tegra210.c into timer-tegra20.c
* add a new patch to select TEGRA_TIMER by default for Tegra210

Fixed in V3:
* use timer-of API for Tegra210 timer driver

Fixed in V2:
* list all the timer IRQs in the binding doc and dts file
* add error clean-up code in timer driver
* add entry-latency-us and exit-latency-us properties for idle-states DT node

Joseph Lo (7):
dt-bindings: timer: add Tegra210 timer
clocksource: tegra: add Tegra210 timer support soc/tegra: default select TEGRA_TIMER for Tegra210
arm64: dts: tegra210: fix timer node
arm64: dts: tegra210: add CPU idle states properties
arm64: dts: tegra210-p2180: Enable CPU idle support
arm64: dts: tegra210-smaug: Enable CPU idle support

 .../bindings/timer/nvidia,tegra210-timer.txt  |  36 ++
 .../arm64/boot/dts/nvidia/tegra210-p2180.dtsi |   6 +
 arch/arm64/boot/dts/nvidia/tegra210-smaug.dts |   7 +
 arch/arm64/boot/dts/nvidia/tegra210.dtsi      |  33 +-
 drivers/clocksource/Kconfig                   |   2 +-
 drivers/clocksource/timer-tegra20.c           | 369 +++++++++++++-----
 drivers/soc/tegra/Kconfig                     |   1 +
 include/linux/cpuhotplug.h                    |   1 +
 8 files changed, 352 insertions(+), 103 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/timer/nvidia,tegra210-timer.txt
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH v4 1/7 dt-bindings: timer: add Tegra210 timer

The Tegra210 timer provides fourteen 29-bit timer counters and one 32-bit timestamp counter. The TMRs run at either a fixed 1 MHz clock rate derived from the oscillator clock (TMR0-TMR9) or directly at the oscillator clock (TMR10-TMR13). Each TMR can be programmed to generate one-shot periodic, or watchdog interrupts.

---
V4:
* no change
v3:
* no change
v2:
* list all the interrupts that are supported by tegra210 timers block
* add RB tag from Rob.

---
 .../bindings/timer/nvidia,tegra210-timer.txt  | 36 +++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/nvidia,tegra210-timer.txt
Documentation/devicetree/bindings/timer/nvidia,tegra210-timer.txt new file +36 -0
new file mode 100644
index 000000000000..032cda96fe0d
@@ -0,0 +1,36 @@
+NVIDIA Tegra210 timer
+
+The Tegra210 timer provides fourteen 29-bit timer counters and one 32-bit
+timestamp counter. The TMRs run at either a fixed 1 MHz clock rate derived
+from the oscillator clock (TMR0-TMR9) or directly at the oscillator clock
+(TMR10-TMR13). Each TMR can be programmed to generate one-shot, periodic,
+or watchdog interrupts.
+
+Required properties:
+- compatible : "nvidia,tegra210-timer".
+- reg : Specifies base physical address and size of the registers.
+- interrupts : A list of 14 interrupts; one per each timer channels 0 through
+  13.
+- clocks : Must contain one entry, for the module clock.
+  See ../clocks/clock-bindings.txt for details.
+
+timer@60005000 {
+	compatible = "nvidia,tegra210-timer";
+	reg = <0x0 0x60005000 0x0 0x400>;
+	interrupts = <GIC_SPI 156 IRQ_TYPE_LEVEL_HIGH>,
+		     <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>,
+		     <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>,
+		     <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
+		     <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>,
+		     <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>,
+		     <GIC_SPI 152 IRQ_TYPE_LEVEL_HIGH>,
+		     <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>,
+		     <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>,
+		     <GIC_SPI 155 IRQ_TYPE_LEVEL_HIGH>,
+		     <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>,
+		     <GIC_SPI 177 IRQ_TYPE_LEVEL_HIGH>,
+		     <GIC_SPI 178 IRQ_TYPE_LEVEL_HIGH>,
+		     <GIC_SPI 179 IRQ_TYPE_LEVEL_HIGH>;
+	clocks = <&tegra_car TEGRA210_CLK_TIMER>;
+	clock-names = "timer";
+};
Signature · 1 line
2.20.1
author
#2 lore raw

PATCH v4 2/7 clocksource: tegra: add Tegra210 timer support

In reply to Joseph Lo

Add support for the Tegra210 timer that runs at oscillator clock (TMR10-TMR13). We need these timers to work as clock event device and to replace the ARMv8 architected timer due to it can't survive across the power cycle of the CPU core or CPUPORESET signal. So it can't be a wake-up source when CPU suspends in power down state.

Also convert the original driver to use timer-of API.

Cc Daniel Lezcano <[email protected]>
Cc Thomas Gleixner <[email protected]>

---
v4:
* merge timer-tegra210.c in previous version into timer-tegra20.c
v3:
* use timer-of API
v2:
* add error clean-up code

---
 drivers/clocksource/Kconfig         |   2 +-
 drivers/clocksource/timer-tegra20.c | 369 ++++++++++++++++++++--------
 include/linux/cpuhotplug.h          |   1 +
 3 files changed, 272 insertions(+), 100 deletions(-)
drivers/clocksource/Kconfig +1 -1
index a9e26f6a81a1..6af78534a285 100644
@@ -131,7 +131,7 @@ config SUN5I_HSTIMER
 config TEGRA_TIMER
 	bool "Tegra timer driver" if COMPILE_TEST
 	select CLKSRC_MMIO
-	depends on ARM
+	select TIMER_OF
 	help
 	  Enables support for the Tegra driver.
 
drivers/clocksource/timer-tegra20.c +270 -99

462 lines not on this page · raw message

include/linux/cpuhotplug.h +1 -0
index fd586d0301e7..e78281d07b70 100644
@@ -121,6 +121,7 @@ enum cpuhp_state {
 	CPUHP_AP_EXYNOS4_MCT_TIMER_STARTING,
 	CPUHP_AP_ARM_TWD_STARTING,
 	CPUHP_AP_QCOM_TIMER_STARTING,
+	CPUHP_AP_TEGRA_TIMER_STARTING,
 	CPUHP_AP_ARMADA_TIMER_STARTING,
 	CPUHP_AP_MARCO_TIMER_STARTING,
 	CPUHP_AP_MIPS_GIC_TIMER_STARTING,
Signature · 1 line
2.20.1
Acked-by on v4 2/7
#3 lore raw

Re: [PATCH V4 2/7] clocksource: tegra: add Tegra210 timer support

Quoted 19 lines · Joseph Lo

Add support for the Tegra210 timer that runs at oscillator clock (TMR10-TMR13). We need these timers to work as clock event device and to replace the ARMv8 architected timer due to it can't survive across the power cycle of the CPU core or CPUPORESET signal. So it can't be a wake-up source when CPU suspends in power down state.

Also convert the original driver to use timer-of API.

Cc Daniel Lezcano <[email protected]>
Cc Thomas Gleixner <[email protected]>

---
v4:
* merge timer-tegra210.c in previous version into timer-tegra20.c
v3:
* use timer-of API
v2:
* add error clean-up code

Quoted 5 lines
---
 drivers/clocksource/Kconfig         |   2 +-
 drivers/clocksource/timer-tegra20.c | 369 ++++++++++++++++++++--------
 include/linux/cpuhotplug.h          |   1 +
 3 files changed, 272 insertions(+), 100 deletions(-)

Looks good to me:

Thierry

author
#4 lore raw

PATCH v4 3/7 soc/tegra: default select TEGRA_TIMER for Tegra210

In reply to Joseph Lo

The tegra timer is necessary for Tegra210 to support CPU idle power-down state. So select it by default.

---
v4:
* new added in this version

---
 drivers/soc/tegra/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/soc/tegra/Kconfig +1 -0
index fe4481676da6..a0b03443d8c1 100644
@@ -76,6 +76,7 @@ config ARCH_TEGRA_210_SOC
 	select PINCTRL_TEGRA210
 	select SOC_TEGRA_FLOWCTRL
 	select SOC_TEGRA_PMC
+	select TEGRA_TIMER
 	help
 	  Enable support for the NVIDIA Tegra210 SoC. Also known as Tegra X1,
 	  the Tegra210 has four Cortex-A57 cores paired with four Cortex-A53
Signature · 1 line
2.20.1
Acked-by on v4 3/7
#5 lore raw

Re: [PATCH V4 3/7] soc/tegra: default select TEGRA_TIMER for Tegra210

Quoted 10 lines · Joseph Lo

The tegra timer is necessary for Tegra210 to support CPU idle power-down state. So select it by default.

---
v4:
* new added in this version

---
 drivers/soc/tegra/Kconfig | 1 +
 1 file changed, 1 insertion(+)

So this technically depends on patch 2/7, so it would make sense for Daniel or Thomas to pick this up along with 2/7, but you didn't Cc them, so they're not aware of this.

I think you need to either resend the series and Cc both Daniel and Thomas on all the patches in the series, or we have to make sure that this patch is not applied before patch 2/7, otherwise Kconfig will complain. If you decide to resend, this patch is:

Thierry

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#6 lore raw

Re: [PATCH V4 3/7] soc/tegra: default select TEGRA_TIMER for Tegra210

Quoted 12 lines · Thierry Reding
Quoted 10 lines · Joseph Lo

The tegra timer is necessary for Tegra210 to support CPU idle power-down state. So select it by default.

---
v4:
* new added in this version

---
  drivers/soc/tegra/Kconfig | 1 +
  1 file changed, 1 insertion(+)
Quoted 8 lines

So this technically depends on patch 2/7, so it would make sense for Daniel or Thomas to pick this up along with 2/7, but you didn't Cc them, so they're not aware of this.

I think you need to either resend the series and Cc both Daniel and Thomas on all the patches in the series, or we have to make sure that this patch is not applied before patch 2/7, otherwise Kconfig will complain. If you decide to resend, this patch is:

Okay, will resend this series.

Thanks for your review,
Joseph

Quoted 5 lines

Thierry

author
#7 lore raw

PATCH v4 4/7 arm64: dts: tegra210: fix timer node

In reply to Joseph Lo

Fix timer node to make it work with Tegra210 timer driver.

---
v4:
* no change
v3:
* no change
v2:
* list all the IRQs per each timer channels 0 through 13
* remove compatible string of "nvidia,tegra30-timer"

---
 arch/arm64/boot/dts/nvidia/tegra210.dtsi | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/nvidia/tegra210.dtsi +11 -3
index b5858b5ea052..2b387364afc3 100644
@@ -384,14 +384,22 @@
 	};
 
 	timer@60005000 {
-		compatible = "nvidia,tegra210-timer", "nvidia,tegra20-timer";
+		compatible = "nvidia,tegra210-timer";
 		reg = <0x0 0x60005000 0x0 0x400>;
-		interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>,
+		interrupts = <GIC_SPI 156 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>,
 			     <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>,
 			     <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
 			     <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>,
 			     <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>,
-			     <GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>;
+			     <GIC_SPI 152 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 155 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 177 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 178 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_SPI 179 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&tegra_car TEGRA210_CLK_TIMER>;
 		clock-names = "timer";
 	};
Signature · 1 line
2.20.1
author
#8 lore raw

PATCH v4 5/7 arm64: dts: tegra210: add CPU idle states properties

In reply to Joseph Lo

Add idle states properties for generic ARM CPU idle driver. This includes a C7 state which is the power down state of CPU cores.

---
v4:
* no change
v3:
* no change
v2:
* add entry-latency-us and exit-latency-us properties

Note:
This dt patch depends on the DT changes in below series.
http://patchwork.ozlabs.org/project/linux-tegra/list/?series=84380

---
 arch/arm64/boot/dts/nvidia/tegra210.dtsi | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/arm64/boot/dts/nvidia/tegra210.dtsi +19 -0
index 2b387364afc3..75534692604c 100644
@@ -1318,24 +1318,43 @@
 				 <&dfll>;
 			clock-names = "cpu_g", "pll_x", "pll_p", "dfll";
 			clock-latency = <300000>;
+			cpu-idle-states = <&C7>;
 		};
 
 		cpu@1 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a57";
 			reg = <1>;
+			cpu-idle-states = <&C7>;
 		};
 
 		cpu@2 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a57";
 			reg = <2>;
+			cpu-idle-states = <&C7>;
 		};
 
 		cpu@3 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a57";
 			reg = <3>;
+			cpu-idle-states = <&C7>;
+		};
+
+		idle-states {
+			entry-method = "psci";
+
+			C7: c7 {
+				compatible = "arm,idle-state";
+				arm,psci-suspend-param = <0x40000007>;
+				entry-latency-us = <250>;
+				exit-latency-us = <100>;
+				min-residency-us = <1000>;
+				wakeup-latency-us = <130>;
+				idle-state-name = "c7-cpu-powergated";
+				status = "disabled";
+			};
 		};
 	};
 
Signature · 1 line
2.20.1
author
#9 lore raw

PATCH v4 6/7 arm64: dts: tegra210-p2180: Enable CPU idle support

In reply to Joseph Lo

Enable CPU idle support for Jetson TX1 platform.

---
v4:
* no change
v3:
* no change
v2:
* no change

---
 arch/arm64/boot/dts/nvidia/tegra210-p2180.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/nvidia/tegra210-p2180.dtsi +6 -0
index 053458a5db55..d1a492c63e96 100644
@@ -305,6 +305,12 @@
 		cpu@3 {
 			enable-method = "psci";
 		};
+
+		idle-states {
+			c7 {
+				status = "okay";
+			};
+		};
 	};
 
 	psci {
Signature · 1 line
2.20.1
#10 lore raw

Re: [PATCH V4 6/7] arm64: dts: tegra210-p2180: Enable CPU idle support

Quoted 19 lines · Joseph Lo

Enable CPU idle support for Jetson TX1 platform.

---
v4:
* no change
v3:
* no change
v2:
* no change

---
 arch/arm64/boot/dts/nvidia/tegra210-p2180.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/nvidia/tegra210-p2180.dtsi +0 -0
index 053458a5db55..d1a492c63e96 100644

arch/arm64/boot/dts/nvidia/tegra210-p2180.dtsi line 311

Quoted 7 lines
arch/arm64/boot/dts/nvidia/tegra210-p2180.dtsi +4 -0
@@ -305,6 +305,12 @@
 		cpu@3 {
 			enable-method = "psci";
 		};
+
+		idle-states {
+			c7 {
+				status = "okay";

Doesn't seem like the code currently cares, but the bindings are specific, so this looks good to me.

Given that we need the timer in order to get out of this state, I'm assuming that I should hold back on these patches until the driver changes have been merged to make sure we don't regress. Is that correct?

Thierry

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#11 lore raw

Re: [PATCH V4 6/7] arm64: dts: tegra210-p2180: Enable CPU idle support

Quoted 31 lines · Thierry Reding
Quoted 19 lines · Joseph Lo

Enable CPU idle support for Jetson TX1 platform.

---
v4:
* no change
v3:
* no change
v2:
* no change

---
  arch/arm64/boot/dts/nvidia/tegra210-p2180.dtsi | 6 ++++++
  1 file changed, 6 insertions(+)
arch/arm64/boot/dts/nvidia/tegra210-p2180.dtsi +0 -0
index 053458a5db55..d1a492c63e96 100644

arch/arm64/boot/dts/nvidia/tegra210-p2180.dtsi line 311

Quoted 7 lines
arch/arm64/boot/dts/nvidia/tegra210-p2180.dtsi +4 -0
@@ -305,6 +305,12 @@
  		cpu@3 {
  			enable-method = "psci";
  		};
+
+		idle-states {
+			c7 {
+				status = "okay";

Doesn't seem like the code currently cares, but the bindings are specific, so this looks good to me.

Quoted 5 lines

Given that we need the timer in order to get out of this state, I'm assuming that I should hold back on these patches until the driver changes have been merged to make sure we don't regress. Is that correct?

Yes, correct. Need to make sure all the timer related stuff landed first.

Thanks,
Joseph

author
#12 lore raw

PATCH v4 7/7 arm64: dts: tegra210-smaug: Enable CPU idle support

In reply to Joseph Lo

Enable CPU idle support for Smaug platform.

---
v4:
* no change
v3:
* no change
v2:
* no change

---
 arch/arm64/boot/dts/nvidia/tegra210-smaug.dts | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/nvidia/tegra210-smaug.dts +7 -0
index 5a67890cfb7a..da0eb4530acf 100644
@@ -1751,6 +1751,13 @@
 		cpu@3 {
 			enable-method = "psci";
 		};
+
+		idle-states {
+			c7 {
+				arm,psci-suspend-param = <0x00010007>;
+				status = "okay";
+			};
+		};
 	};
 
 	gpio-keys {
Signature · 1 line
2.20.1