drivers: psci: PSCI checker module
PATCH 1/2 drivers: psci: PSCI checker module
From: Kevin Brodsky <[email protected]>
On arm and arm64, PSCI is one of the possible firmware interfaces used for power management. This includes both turning CPUs on and off, and suspending them (entering idle states).
This patch adds a PSCI checker module that enables basic testing of PSCI operations during startup. There are two main tests: CPU hotplugging and suspending.
In the hotplug tests, the hotplug API is used to turn off and on again all CPUs in the system, and then all CPUs in each cluster, checking the consistency of the return codes.
In the suspend tests, a high-priority thread is created on each core and uses low-level cpuidle functionalities to enter suspend, in all the possible states and multiple times. This should allow a maximum number of CPUs to enter the same sleep state at the same or slightly different time.
In essence, the suspend tests use a principle similar to that of the intel_powerclamp driver (drivers/thermal/intel_powerclamp.c), but the threads are only kept for the duration of the test (they are already gone when userspace is started) and it does not require to stop/start the tick.
While in theory power management PSCI functions (CPU_{ON,OFF,SUSPEND}) could be directly called, this proved too difficult as it would imply the duplication of all the logic used by the kernel to allow for a clean shutdown/bringup/suspend of the CPU (the deepest sleep states implying potentially the shutdown of the CPU).
Note that this file cannot be compiled as a loadable module, since it uses a number of non-exported identifiers (essentially for PSCI-specific checks and direct use of cpuidle) and relies on the absence of userspace to avoid races when calling hotplug and cpuidle functions.
For now at least, CONFIG_PSCI_CHECKER is mutually exclusive with CONFIG_TORTURE_TEST, because torture tests may also use hotplug and cause false positives in the hotplug tests.
--- drivers/firmware/Kconfig | 11 + drivers/firmware/Makefile | 1 + drivers/firmware/psci_checker.c | 490 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 502 insertions(+) create mode 100644 drivers/firmware/psci_checker.c
drivers/firmware/Kconfig +11 -0
@@ -8,6 +8,17 @@ menu "Firmware Drivers" config ARM_PSCI_FW bool +config ARM_PSCI_CHECKER + bool "ARM PSCI checker" + depends on ARM_PSCI_FW && HOTPLUG_CPU && !TORTURE_TEST + help + Run the PSCI checker during startup. This checks that hotplug and + suspend operations work correctly when using PSCI. + + The torture tests may interfere with the PSCI checker by turning CPUs + on and off through hotplug, so for now torture tests and PSCI checker + are mutually exclusive. + config ARM_SCPI_PROTOCOL tristate "ARM System Control and Power Interface (SCPI) Message Protocol" depends on MAILBOX
drivers/firmware/Makefile +1 -0
@@ -2,6 +2,7 @@ # Makefile for the linux kernel. # obj-$(CONFIG_ARM_PSCI_FW) += psci.o +obj-$(CONFIG_ARM_PSCI_CHECKER) += psci_checker.o obj-$(CONFIG_ARM_SCPI_PROTOCOL) += arm_scpi.o obj-$(CONFIG_ARM_SCPI_POWER_DOMAIN) += scpi_pm_domain.o obj-$(CONFIG_DMI) += dmi_scan.o
drivers/firmware/psci_checker.c new file +490 -0
490 lines not on this page · raw message
Signature · 1 line
2.10.0
PATCH 2/2 drivers: psci: Allow PSCI node to be disabled
From: Thierry Reding <[email protected]>
Allow disabling PSCI support (mostly for testing purposes) by setting the status property to "disabled". This makes the node behave in much the same way as proper device nodes.
--- drivers/firmware/psci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/psci.c +1 -1
@@ -630,7 +630,7 @@ int __init psci_dt_init(void) np =of_find_matching_node_and_match (NULL , psci_of_match, &matched_np); -if (!np) +if (!np || !of_device_is_available (np))return -ENODEV ; init_fn = (psci_initcall_t )matched_np->data;
Signature · 1 line
2.10.0
Arnd Bergmann
AppliedPATCH 1/2 drivers: psci: PSCI checker module
In reply to Lorenzo PieralisiQuoted 42 lines · CET Lorenzo Pieralisi
From: Kevin Brodsky <[email protected]>
On arm and arm64, PSCI is one of the possible firmware interfaces used for power management. This includes both turning CPUs on and off, and suspending them (entering idle states).
This patch adds a PSCI checker module that enables basic testing of PSCI operations during startup. There are two main tests: CPU hotplugging and suspending.
In the hotplug tests, the hotplug API is used to turn off and on again all CPUs in the system, and then all CPUs in each cluster, checking the consistency of the return codes.
In the suspend tests, a high-priority thread is created on each core and uses low-level cpuidle functionalities to enter suspend, in all the possible states and multiple times. This should allow a maximum number of CPUs to enter the same sleep state at the same or slightly different time.
In essence, the suspend tests use a principle similar to that of the
intel_powerclampdriver (drivers/thermal/intel_powerclamp.c), but the threads are only kept for the duration of the test (they are already gone when userspace is started) and it does not require to stop/start the tick.While in theory power management PSCI functions (CPU_{ON,OFF,SUSPEND}) could be directly called, this proved too difficult as it would imply the duplication of all the logic used by the kernel to allow for a clean shutdown/bringup/suspend of the CPU (the deepest sleep states implying potentially the shutdown of the CPU).
Note that this file cannot be compiled as a loadable module, since it uses a number of non-exported identifiers (essentially for PSCI-specific checks and direct use of cpuidle) and relies on the absence of userspace to avoid races when calling hotplug and cpuidle functions.
For now at least,
CONFIG_PSCI_CHECKERis mutually exclusive withCONFIG_TORTURE_TEST, because torture tests may also use hotplug and cause false positives in the hotplug tests.
Quoted 13 lines
Cc Thomas Gleixner <[email protected]>Cc Kevin Hilman <[email protected]>Cc "Rafael J. Wysocki" <[email protected]>Cc Peter Zijlstra <[email protected]>Cc "Paul E. McKenney" <[email protected]>Cc James Morse <[email protected]>Cc Sudeep Holla <[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc Mark Rutland <[email protected]>Signed-off-by Kevin Brodsky <[email protected]>[lpieralisi: added cpuidle locking, reworded commit log/kconfig entry]Signed-off-by Lorenzo Pieralisi <[email protected]>
Applied both patches to the next/drivers tree in arm-soc now, sorry for the delay,
Arnd