Switch to the DT cpufreq policy on the Integrator
Subsystems (3)
cover Switch to the DT cpufreq policy on the Integrator
This switches the ARM Integrator/AP and Integrator/CP to use the Device Tree cpufreq policy with its definition of operating points using the generic OPP library.
The Integrators does not need to control a regulator to switch frequency, only a clock. This clock and its device tree bindings have been defined in the device tree and merged upstream for v4.9.
This approach provides a little better granularity on the Integrator/AP where I defined a few operating points: before this change the Integrator would just switch between min speed (12 MHz) and max speed (71 MHz). Now it can switch between a few arbitrarily chosen OPPs as in the examples below:
The following tests were made on the Integrator/AP:
/sys/devices/system/cpu/cpufreq/policy0 echo ondemand > scaling_governor cpu cpu0: dev_pm_opp_set_rate: switching OPP: 71000000 Hz --> 24000000 Hz cpu cpu0: dev_pm_opp_set_rate: switching OPP: 24000000 Hz --> 12000000 Hz cpu cpu0: dev_pm_opp_set_rate: switching OPP: 12000000 Hz --> 24000000 Hz cpu cpu0: dev_pm_opp_set_rate: switching OPP: 24000000 Hz --> 12000000 Hz
The switch from 12 to 24 MHz is triggered by as little as using the command line with the ondemand governor. If we do this:
yes > /dev/null &
cpu cpu0: dev_pm_opp_set_rate: switching OPP: 12000000 Hz --> 36000000 Hz cpu cpu0: dev_pm_opp_set_rate: switching OPP: 36000000 Hz --> 71000000 Hz pkill yes
cpu cpu0: dev_pm_opp_set_rate: switching OPP: 71000000 Hz --> 12000000 Hz
So the algorithm is indeed using all the OPPs.
Also as a confirmation test to make sure performance is affected by the speed changes, we set the performance governor and:
echo 12000 > scaling_max_freq
cpu cpu0: dev_pm_opp_set_rate: switching OPP: 71000000 Hz --> 12000000 Hz time find /sys|sort|uniq > /dev/null
real 0m 45.51s user 0m 11.15s sys 0m 26.74s
echo 71000 > scaling_max_freq
cpu cpu0: dev_pm_opp_set_rate: switching OPP: 12000000 Hz --> 71000000 Hz time find /sys|sort|uniq
Quoted 1 line
/dev/null
real 0m 9.13s user 0m 2.35s sys 0m 5.50s
So it is working.
If people are happy with this approach and approve of the patches I'd like an ACK from the cpufreq people and then merge the whole set through ARM SoC.
Linus Walleij (5):
cpufreq: enable the DT cpufreq driver on the Integrators
ARM: dts: Add Integrator/AP cpus node and operating points
ARM: dts: Add Integrator/CP cpus node and operating points
ARM: defconfig: turn on the DT cpufreq for Integrator
cpufreq: retire the Integrator cpufreq driver
arch/arm/boot/dts/integratorap.dts | 35 +++++ arch/arm/boot/dts/integratorcp.dts | 26 ++++ arch/arm/configs/integrator_defconfig | 1 + drivers/cpufreq/Kconfig.arm | 8 -- drivers/cpufreq/Makefile | 1 - drivers/cpufreq/cpufreq-dt-platdev.c | 3 + drivers/cpufreq/integrator-cpufreq.c | 239 ---------------------------------- 7 files changed, 65 insertions(+), 248 deletions(-) delete mode 100644 drivers/cpufreq/integrator-cpufreq.c
Signature · 1 line
2.7.4
PATCH 1/5 cpufreq: enable the DT cpufreq driver on the Integrators
This enables the generic DT and OPP-based cpufreq driver on the ARM Integrator/AP and Integrator/CP.
--- drivers/cpufreq/cpufreq-dt-platdev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/cpufreq/cpufreq-dt-platdev.c +3 -0
@@ -26,6 +26,9 @@ static const struct of_device_id machines[] __initconst = { { .compatible = "allwinner,sun8i-a83t", }, { .compatible = "allwinner,sun8i-h3", }, + { .compatible = "arm,integrator-ap", }, + { .compatible = "arm,integrator-cp", }, + { .compatible = "hisilicon,hi6220", }, { .compatible = "fsl,imx27", },
Signature · 1 line
2.7.4
PATCH 2/5 ARM: dts: Add Integrator/AP cpus node and operating points
In reply to Linus WalleijThis adds the cpus node to the Integrator/AP device tree so that we have a proper placeholder to put in the DT-defined operating points for the generic DT/OPP cpufreq driver, along with the proper operating points.
The old Integrator cpufreq driver would resolve the max frequency to 71MHz, and the min frequency to 12 MHz, but the clock driver can actually handle any frequency inbetween so I picked a few select frequencies as OPPs. The cpufreq framework doesn't seem to deal with sliding frequency scales, only fixed points so 7 OPPs is better than 2 atleast.
We define a CPU node since this is required for cpufreq-dt, however we do not define any compatible string for the CPU since this architecture has pluggable CPU modules and we do not know which one will be used. If necessary, the CPU compatible can be filled in by the boot loader, but for just cpufreq-dt it is not required.
--- arch/arm/boot/dts/integratorap.dts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
arch/arm/boot/dts/integratorap.dts +35 -0
@@ -10,6 +10,41 @@ compatible = "arm,integrator-ap"; dma-ranges = <0x80000000 0x0 0x80000000>; + cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu at 0 { + device_type = "cpu"; + /* + * Since the board has pluggable CPU modules, we + * cannot define a proper compatible here. Let the + * boot loader fill in the apropriate compatible + * string if necessary. + */ + /* compatible = "arm,arm926ej-s"; */ + reg = <0>; + /* + * The documentation in ARM DUI 0138E page 3-12 states + * that the maximum frequency for this clock is 200 MHz + * but painful trial-and-error has proved to me that it + * is actually just hanging the system above 71 MHz. + * Sad but true. + */ + /* kHz uV */ + operating-points = <71000 0 + 66000 0 + 60000 0 + 48000 0 + 36000 0 + 24000 0 + 12000 0>; + clocks = <&cmosc>; + clock-names = "cpu"; + clock-latency = <1000000>; /* 1 ms */ + }; + }; + aliases { arm,timer-primary = &timer2; arm,timer-secondary = &timer1;
Signature · 1 line
2.7.4
PATCH 3/5 ARM: dts: Add Integrator/CP cpus node and operating points
In reply to Linus WalleijThis adds the cpus node to the Integrator/CP device tree so that we have a proper placeholder to put in the DT-defined operating points for the generic DT/OPP cpufreq driver, along with two working operating points.
I have only put in 48 and 50 MHz because going to e.g. 36 MHz hangs the system when CLCD graphics are active. Presumably the memory bus gets to slow to feed the display and the systems hangs for this reason. The ideal solution would be for the display controller to put constraints on the memory bus frequency, but that need to be a separate longer-term project.
We define a CPU node since this is required for cpufreq-dt, however we do not define any compatible string for the CPU since this architecture has pluggable CPU modules and we do not know which one will be used. If necessary, the CPU compatible can be filled in by the boot loader, but for just cpufreq-dt it is not required.
--- arch/arm/boot/dts/integratorcp.dts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
arch/arm/boot/dts/integratorcp.dts +26 -0
@@ -13,6 +13,32 @@ bootargs = "root=/dev/ram0 console=ttyAMA0,38400n8 earlyprintk"; }; + cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu at 0 { + device_type = "cpu"; + /* + * Since the board has pluggable CPU modules, we + * cannot define a proper compatible here. Let the + * boot loader fill in the apropriate compatible + * string if necessary. + */ + /* compatible = "arm,arm920t"; */ + reg = <0>; + /* + * TBD comment. + */ + /* kHz uV */ + operating-points = <50000 0 + 48000 0>; + clocks = <&cmcore>; + clock-names = "cpu"; + clock-latency = <1000000>; /* 1 ms */ + }; + }; + /* * The Integrator/CP overall clocking architecture can be found in * ARM DUI 0184B page 7-28 "Integrator/CP922T system clocks" which
Signature · 1 line
2.7.4
PATCH 4/5 ARM: defconfig: turn on the DT cpufreq for Integrator
In reply to Linus WalleijThe Integrators are now migrated to handle the CPUfreq scaling using the generic devicetree CPUfreq driver using the common clock framework and have the required device tree modifications, so turn off the old driver and turn on the new generic driver.
--- arch/arm/configs/integrator_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/configs/integrator_defconfig +1 -0
@@ -26,6 +26,7 @@ CONFIG_CPU_FREQ=y CONFIG_CPU_FREQ_GOV_POWERSAVE=y CONFIG_CPU_FREQ_GOV_USERSPACE=y CONFIG_CPU_FREQ_GOV_ONDEMAND=y +CONFIG_CPUFREQ_DT=y CONFIG_NET=y CONFIG_PACKET=y CONFIG_UNIX=y
Signature · 1 line
2.7.4
PATCH 5/5 cpufreq: retire the Integrator cpufreq driver
In reply to Linus WalleijAfter switching the core module clocks controlling the Integrator clock frequencies to the common clock framework, defining the operating points in the device tree, and activating the generic DT-based CPUfreq driver, we can retire the old Integrator cpufreq driver.
--- drivers/cpufreq/Kconfig.arm | 8 -- drivers/cpufreq/Makefile | 1 - drivers/cpufreq/integrator-cpufreq.c | 239 ----------------------------------- 3 files changed, 248 deletions(-) delete mode 100644 drivers/cpufreq/integrator-cpufreq.c
drivers/cpufreq/Kconfig.arm +0 -8
@@ -60,14 +60,6 @@ config ARM_IMX6Q_CPUFREQ If in doubt, say N. -config ARM_INTEGRATOR - tristate "CPUfreq driver for ARM Integrator CPUs" - depends on ARCH_INTEGRATOR - default y - help - This enables the CPUfreq driver for ARM Integrator CPUs. - If in doubt, say Y. - config ARM_KIRKWOOD_CPUFREQ def_bool MACH_KIRKWOOD help
drivers/cpufreq/Makefile +0 -1
@@ -56,7 +56,6 @@ obj-$(CONFIG_UX500_SOC_DB8500) += dbx500-cpufreq.o obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ) += exynos5440-cpufreq.o obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ) += highbank-cpufreq.o obj-$(CONFIG_ARM_IMX6Q_CPUFREQ) += imx6q-cpufreq.o -obj-$(CONFIG_ARM_INTEGRATOR) += integrator-cpufreq.o obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ) += kirkwood-cpufreq.o obj-$(CONFIG_ARM_MT8173_CPUFREQ) += mt8173-cpufreq.o obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ) += omap-cpufreq.o
drivers/cpufreq/integrator-cpufreq.c deleted +0 -239
239 lines not on this page · raw message
Signature · 1 line
2.7.4
cover Switch to the DT cpufreq policy on the Integrator
In reply to Linus WalleijQuoted 5 lines · CEST Linus Walleij
If people are happy with this approach and approve of the patches I'd like an ACK from the cpufreq people and then merge the whole set through ARM SoC.
I don't see any hard dependency here, so I'd suggest to merge the two cpufreq patches through the subsystem tree, and the ARM patches through arm-soc.
The patches look fine.
Removing the custom driver of course means that we break machines with old .dtb files, so we could consider leaving the driver in place, but probably there is no need for integrator.
Arnd
cover Switch to the DT cpufreq policy on the Integrator
Quoted 3 lines · Arnd Bergmann
I don't see any hard dependency here, so I'd suggest to merge the two cpufreq patches through the subsystem tree, and the ARM patches through arm-soc.
That's right, Viresh can you merge patches 1 and 5 to the cpufreq tree please?
I will funnel patches 2, 3 and 4 to ARM SoC.
Yours,
Linus Walleij
Rafael J. Wysocki
maintainercover Switch to the DT cpufreq policy on the Integrator
Quoted 8 lines · Linus Walleij
Quoted 3 lines · Arnd Bergmann
I don't see any hard dependency here, so I'd suggest to merge the two cpufreq patches through the subsystem tree, and the ARM patches through arm-soc.
That's right, Viresh can you merge patches 1 and 5 to the cpufreq tree please?
Well, that would be me.
Can you please resend the two as a separate series, with all tags collected so far if any?
Thanks,
Rafael
cover Switch to the DT cpufreq policy on the Integrator
Quoted 7 lines · Rafael J. Wysocki
Quoted 6 lines · Linus Walleij
Quoted 3 lines · Arnd Bergmann
I don't see any hard dependency here, so I'd suggest to merge the two cpufreq patches through the subsystem tree, and the ARM patches through arm-soc.
Quoted 7 lines
Quoted 2 lines
That's right, Viresh can you merge patches 1 and 5 to the cpufreq tree please?
Well, that would be me.
Can you please resend the two as a separate series, with all tags collected so far if any?
Sure no problem.
Yours,
Linus Walleij
cover Switch to the DT cpufreq policy on the Integrator
In reply to Linus WalleijQuoted 57 lines · Linus Walleij
This switches the ARM Integrator/AP and Integrator/CP to use the Device Tree cpufreq policy with its definition of operating points using the generic OPP library.
The Integrators does not need to control a regulator to switch frequency, only a clock. This clock and its device tree bindings have been defined in the device tree and merged upstream for v4.9.
This approach provides a little better granularity on the Integrator/AP where I defined a few operating points: before this change the Integrator would just switch between min speed (12 MHz) and max speed (71 MHz). Now it can switch between a few arbitrarily chosen OPPs as in the examples below:
The following tests were made on the Integrator/AP:
/sys/devices/system/cpu/cpufreq/policy0echo ondemand >scaling_governorcpu cpu0:dev_pm_opp_set_rate: switching OPP: 71000000 Hz --> 24000000 Hz cpu cpu0:dev_pm_opp_set_rate: switching OPP: 24000000 Hz --> 12000000 Hz cpu cpu0:dev_pm_opp_set_rate: switching OPP: 12000000 Hz --> 24000000 Hz cpu cpu0:dev_pm_opp_set_rate: switching OPP: 24000000 Hz --> 12000000 HzThe switch from 12 to 24 MHz is triggered by as little as using the command line with the ondemand governor. If we do this:
yes >
/dev/null&
cpu cpu0:dev_pm_opp_set_rate: switching OPP: 12000000 Hz --> 36000000 Hz cpu cpu0:dev_pm_opp_set_rate: switching OPP: 36000000 Hz --> 71000000 Hz pkill yes
cpu cpu0:dev_pm_opp_set_rate: switching OPP: 71000000 Hz --> 12000000 HzSo the algorithm is indeed using all the OPPs.
Also as a confirmation test to make sure performance is affected by the speed changes, we set the performance governor and:
echo 12000 >
scaling_max_freq
cpu cpu0:dev_pm_opp_set_rate: switching OPP: 71000000 Hz --> 12000000 Hz time find /sys|sort|uniq >/dev/nullreal 0m 45.51s user 0m 11.15s sys 0m 26.74secho 71000 >
scaling_max_freq
cpu cpu0:dev_pm_opp_set_rate: switching OPP: 12000000 Hz --> 71000000 Hz time find /sys|sort|uniqQuoted 1 line
/dev/nullreal 0m 9.13s user 0m 2.35s sys 0m 5.50sSo it is working.
If people are happy with this approach and approve of the patches I'd like an ACK from the cpufreq people and then merge the whole set through ARM SoC.
Quoted 6 lines
Linus Walleij (5):
cpufreq: enable the DT cpufreq driver on the Integrators
ARM: dts: Add Integrator/AP cpus node and operating points
ARM: dts: Add Integrator/CP cpus node and operating points
ARM: defconfig: turn on the DT cpufreq for Integrator
cpufreq: retire the Integrator cpufreq driver
The cpufreq changes look good to me, but Viresh is the expert for the DT stuff.
Thanks,
Rafael
Viresh Kumar
maintainercover Switch to the DT cpufreq policy on the Integrator
In reply to Linus WalleijQuoted 51 lines · Linus Walleij
This switches the ARM Integrator/AP and Integrator/CP to use the Device Tree cpufreq policy with its definition of operating points using the generic OPP library.
The Integrators does not need to control a regulator to switch frequency, only a clock. This clock and its device tree bindings have been defined in the device tree and merged upstream for v4.9.
This approach provides a little better granularity on the Integrator/AP where I defined a few operating points: before this change the Integrator would just switch between min speed (12 MHz) and max speed (71 MHz). Now it can switch between a few arbitrarily chosen OPPs as in the examples below:
The following tests were made on the Integrator/AP:
/sys/devices/system/cpu/cpufreq/policy0echo ondemand >scaling_governorcpu cpu0:dev_pm_opp_set_rate: switching OPP: 71000000 Hz --> 24000000 Hz cpu cpu0:dev_pm_opp_set_rate: switching OPP: 24000000 Hz --> 12000000 Hz cpu cpu0:dev_pm_opp_set_rate: switching OPP: 12000000 Hz --> 24000000 Hz cpu cpu0:dev_pm_opp_set_rate: switching OPP: 24000000 Hz --> 12000000 HzThe switch from 12 to 24 MHz is triggered by as little as using the command line with the ondemand governor. If we do this:
yes >
/dev/null&
cpu cpu0:dev_pm_opp_set_rate: switching OPP: 12000000 Hz --> 36000000 Hz cpu cpu0:dev_pm_opp_set_rate: switching OPP: 36000000 Hz --> 71000000 Hz pkill yes
cpu cpu0:dev_pm_opp_set_rate: switching OPP: 71000000 Hz --> 12000000 HzSo the algorithm is indeed using all the OPPs.
Also as a confirmation test to make sure performance is affected by the speed changes, we set the performance governor and:
echo 12000 >
scaling_max_freq
cpu cpu0:dev_pm_opp_set_rate: switching OPP: 71000000 Hz --> 12000000 Hz time find /sys|sort|uniq >/dev/nullreal 0m 45.51s user 0m 11.15s sys 0m 26.74secho 71000 >
scaling_max_freq
cpu cpu0:dev_pm_opp_set_rate: switching OPP: 12000000 Hz --> 71000000 Hz time find /sys|sort|uniqQuoted 1 line
/dev/nullreal 0m 9.13s user 0m 2.35s sys 0m 5.50s
Quoted 5 lines
So it is working.
If people are happy with this approach and approve of the patches I'd like an ACK from the cpufreq people and then merge the whole set through ARM SoC.
Signature · 1 line
viresh
Viresh Kumar
maintainercover Switch to the DT cpufreq policy on the Integrator
Quoted 52 lines · Viresh Kumar
Quoted 51 lines · Linus Walleij
This switches the ARM Integrator/AP and Integrator/CP to use the Device Tree cpufreq policy with its definition of operating points using the generic OPP library.
The Integrators does not need to control a regulator to switch frequency, only a clock. This clock and its device tree bindings have been defined in the device tree and merged upstream for v4.9.
This approach provides a little better granularity on the Integrator/AP where I defined a few operating points: before this change the Integrator would just switch between min speed (12 MHz) and max speed (71 MHz). Now it can switch between a few arbitrarily chosen OPPs as in the examples below:
The following tests were made on the Integrator/AP:
/sys/devices/system/cpu/cpufreq/policy0echo ondemand >scaling_governorcpu cpu0:dev_pm_opp_set_rate: switching OPP: 71000000 Hz --> 24000000 Hz cpu cpu0:dev_pm_opp_set_rate: switching OPP: 24000000 Hz --> 12000000 Hz cpu cpu0:dev_pm_opp_set_rate: switching OPP: 12000000 Hz --> 24000000 Hz cpu cpu0:dev_pm_opp_set_rate: switching OPP: 24000000 Hz --> 12000000 HzThe switch from 12 to 24 MHz is triggered by as little as using the command line with the ondemand governor. If we do this:
yes >
/dev/null&
cpu cpu0:dev_pm_opp_set_rate: switching OPP: 12000000 Hz --> 36000000 Hz cpu cpu0:dev_pm_opp_set_rate: switching OPP: 36000000 Hz --> 71000000 Hz pkill yes
cpu cpu0:dev_pm_opp_set_rate: switching OPP: 71000000 Hz --> 12000000 HzSo the algorithm is indeed using all the OPPs.
Also as a confirmation test to make sure performance is affected by the speed changes, we set the performance governor and:
echo 12000 >
scaling_max_freq
cpu cpu0:dev_pm_opp_set_rate: switching OPP: 71000000 Hz --> 12000000 Hz time find /sys|sort|uniq >/dev/nullreal 0m 45.51s user 0m 11.15s sys 0m 26.74secho 71000 >
scaling_max_freq
cpu cpu0:dev_pm_opp_set_rate: switching OPP: 12000000 Hz --> 71000000 Hz time find /sys|sort|uniqQuoted 1 line
/dev/nullreal 0m 9.13s user 0m 2.35s sys 0m 5.50s
Quoted 7 lines
Quoted 5 lines
So it is working.
If people are happy with this approach and approve of the patches I'd like an ACK from the cpufreq people and then merge the whole set through ARM SoC.
Acked-by Viresh Kumar <[email protected]>
Integrator is an UP, right? Otherwise you may want to use operating-points-v2 bindings instead.
Signature · 1 line
viresh