SlideShare a Scribd company logo
1 of 30
Download to read offline
Introduction
CPUidle: One Driver to Rule Them All
D.Lezcano, L.Pieralisi
LCA 2013
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
Motivation
CPUidle Common Driver: Goal
The number of SoCs is increasing, so is their complexity
Vendors started to implement fine grained power gating
capabilities (per core)
CPUidle framework is gaining momentum
Unfortunately, each vendor is focused on their own solution
without taking care of:
Maintainability
Code reuse
Future improvements
Consistency across the cpuidle drivers
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
Motivation
CPUidle: Current issues
copy/paste is commonplace to implement a driver from
scratch
Result is a lot of duplicate code (which may duplicate bugs)
eg. ux500 vs imx6 cpuidle driver (mostly the same)
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
CPU idle status
CPUidle: UP platforms
WFI = Wait for interrupt (Clock gating)
OMAP3 7 idle states
very complex driver
using an extra array with data
AT91 2 idle states
WFI
WFI + DDR self refresh
Kirkwood 2 idle states
WFI
WFI + DDR self refresh
SH mobile 1 state
WFI defines a custom function but actually it reimplements cpu do idle()
For UP systems, apart from OMAP3, all other drivers are very similar
A default idle driver
state1 => WFI
state2 => DDR self refresh ops
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
CPU idle status
CPU idle: SMP platforms (1/2)
WFI = Wait for interrupt (Clock gating)
Calxeda 2 idle states
WFI
power gating (PSCI based)
Tegra2 1 idle state
WFI
Tegra3 2 idle states
WFI
Power gating
IMX5 1 state
WFI custom but described as ”CPU state retained/ Powered off”
IMX6 2 states
Last man standing copy’n’pasted from u8500
WFI
Clock Off
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
CPU idle status
CPUidle: SMP platforms (2/2)
WFI = Wait for interrupt (Clock gating)
Exynos 2 states (CPU hotplug)
WFI
CPU power down
u8500 2 states
WFI
CPU state retained
OMAP4 3 states
WFI custom
CPU off/MPU on
CPU off/MPU off
using coupled C-states
using an extra array
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
CPU idle status
CPUidle status: maintainership
drivers are under the SoC vendor maintainer umbrella
not a single entry point
reviews carried out by different people
different origin from the merge tree
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
CPU idle status
CPUidle status: internal
The cpuidle drivers tend to manage the peripherals power
Checks if the specific power domain could be powered down
Override the governor’s decision
Adds more complexity
Introduces more dependencies
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
CPU idle status
CPUidle Common Driver: guidelines
pm runtime / generic power domain
cpuidle attach to genpd
device tree representation
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
CPU idle status
CPUidle Common Driver: pm runtime / genpd
use pm runtime for the peripherals
use the generic power domain for the peripherals
if something is missing in pm runtime or genpd : improve
them, do not hack the driver
1 static struct rmobile pm domain sh7372 pm domains[] = {
2 ...
3 {
4 .genpd.name = ”A4S”,
5 ...
6 };
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
CPU idle status
CPUidle Common Driver: cpuidle attach
Attach the generic power domain to a cpuidle state
1 int pm genpd attach cpuidle(struct generic pm domain ∗genpd, int state);
2 int pm genpd name attach cpuidle(const char ∗name, int state);
Listing 1: example shmobile
1 pm genpd name attach cpuidle(”A4S”, 4);
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
CPU idle status
CPUidle Common Driver: cpuidle attach
Domain poweron/poweroff will disable the cpuidle state
1 int pm genpd poweron(struct generic pm domain ∗genpd)
2 {
3 ...
4 genpd−>cpu data−>idle state−>disabled = true;
5 ...
6 }
7
8 int pm genpd poweroff(struct generic pm domain ∗genpd)
9 {
10 ...
11 genpd−>cpu data−>idle state−>disabled = false;
12 ...
13 }
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
CPU idle status
CPUidle Common Driver: cpuidle attach
The cpuidle governor won’t choose the disabled state
1 int menu select(struct cpuidle driver ∗drv, struct cpuidle device ∗dev)
2 {
3 ...
4 for (i = CPUIDLE DRIVER STATE START; i < drv−>state count; i++) {
5 struct cpuidle state ∗s = &drv−>states[i];
6 struct cpuidle state usage ∗su = &dev−>states usage[i];
7
8 if (s−>disabled || su−>disable)
9 continue;
10
11 ...
12 }
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
CPU idle status
CPUidle Common Driver: dts
An array of callbacks for all the arch specific idle functions
A cpuidle driver structure initialized with the dts information
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
CPU idle status
CPUidle Common Driver: dts
1 cpuidle {
2 idlestates {
3 idlestate0: idlestate@0 {
4 enter = ”simple”;
5 exit latency = <1>;
6 target residency = <1>;
7 power usage = <0xffffffff>;
8 flags = <0x1>;
9 state name = ”WFI”;
10 desc = ”ARM WFI”;
11 };
12 };
13 };
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
CPU idle status
Conclusion
CPUidle drivers need consolidation
Use pm runtime for the peripherals
Use the generic power domain with cpuidle
Common code must be factorized
DT to the rescue for idle states data
Outlook
DT states bindings
Starting by creating a single driver for existing drivers
Integrate ARM PSCI proposal
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
CPU idle status
THANKS !!!
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
ARM Common PM Code
ARM Common PM Code Components
CPU PM notifiers
Local timers save/restore
CPU suspend/resume
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
ARM Common PM Code
CPU PM notifiers (1/3)
Introduced by C.Cross to overcome code duplication in idle
and suspend code path
CPU events and CLUSTER events
GIC, VFP, PMU
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
ARM Common PM Code
CPU PM notifiers (2/3)
static int cpu_pm_notify(enum cpu_pm_event event, int nr_to_call, int *nr_calls)
{
int ret;
ret = __raw_notifier_call_chain(&cpu_pm_notifier_chain, event, NULL,
nr_to_call, nr_calls);
return notifier_to_errno(ret);
}
int cpu_pm_enter(void)
{
[...]
ret = cpu_pm_notify(CPU_PM_ENTER, -1, &nr_calls);
if (ret)
cpu_pm_notify(CPU_PM_ENTER_FAILED, nr_calls - 1, NULL);
[...]
return ret;
}
//CPU shutdown
cpu_pm_{enter,exit}();
//Cluster shutdown
cpu_cluster_pm_{enter,exit}();
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
ARM Common PM Code
CPU PM notifiers (3/3)
static int gic_notifier(struct notifier_block *self, unsigned long cmd, void *v)
{
int i;
[...]
switch (cmd) {
case CPU_PM_ENTER:
gic_cpu_save(i);
break;
case CPU_PM_ENTER_FAILED:
case CPU_PM_EXIT:
gic_cpu_restore(i);
break;
case CPU_CLUSTER_PM_ENTER:
gic_dist_save(i);
break;
case CPU_CLUSTER_PM_ENTER_FAILED:
case CPU_CLUSTER_PM_EXIT:
gic_dist_restore(i);
break;
}
return NOTIFY_OK;
}
static struct notifier_block gic_notifier_block = {
.notifier_call = gic_notifier,
};
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
ARM Common PM Code
Local timers save/restore
void enter_idle(...)
{
[...]
clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu);
[...]
cpu_do_idle();
[...]
clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu);
[...]
}
void enter_idle(...)
{
struct tick_device *tdev = tick_get_device(cpu);
[...]
cpu_do_idle();
[...]
/* Restore the per-cpu timer event */
clockevents_program_event(tdev->evtdev, tdev->evtdev->next_event, 1);
}
Enter broadcast mode if a global timer is available
Rely on always-on firmware timer and restore timer through clock
events programming API
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
ARM Common PM Code
CPU suspend (1/3)
Introduced by R.King to consolidate existing (and duplicated)
code across diffent ARM platforms
save/restore core registers, clean L1 and some bits of L2
L2 RAM retention handling poses further challenges
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
ARM Common PM Code
CPU suspend (2/3)
1:1 mapping page tables cloned from init_mm
C API, generic for all ARM architectures
int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
{
struct mm_struct *mm = current->active_mm;
int ret;
if (!suspend_pgd)
return -EINVAL;
[...]
ret = __cpu_suspend(arg, fn);
if (ret == 0) {
cpu_switch_mm(mm->pgd, mm);
local_flush_tlb_all();
}
return ret;
}
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
ARM Common PM Code
CPU suspend (3/3)
registers saved on the stack
void __cpu_suspend_save(u32 *ptr, u32 ptrsz, u32 sp, u32 *save_ptr)
{
u32 *ctx = ptr;
*save_ptr = virt_to_phys(ptr);
/* This must correspond to the LDM in cpu_resume() assembly */
*ptr++ = virt_to_phys(suspend_pgd);
*ptr++ = sp;
*ptr++ = virt_to_phys(cpu_do_resume);
cpu_do_suspend(ptr);
}
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
ARM Common PM Code
CPU suspend (3/3)
registers saved on the stack
L1 complete cleaning
void __cpu_suspend_save(u32 *ptr, u32 ptrsz, u32 sp, u32 *save_ptr)
{
u32 *ctx = ptr;
*save_ptr = virt_to_phys(ptr);
/* This must correspond to the LDM in cpu_resume() assembly */
*ptr++ = virt_to_phys(suspend_pgd);
*ptr++ = sp;
*ptr++ = virt_to_phys(cpu_do_resume);
cpu_do_suspend(ptr);
flush_cache_louis();
}
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
ARM Common PM Code
CPU suspend (3/3)
registers saved on the stack
L1 complete cleaning
L2 partial cleaning
void __cpu_suspend_save(u32 *ptr, u32 ptrsz, u32 sp, u32 *save_ptr)
{
u32 *ctx = ptr;
*save_ptr = virt_to_phys(ptr);
/* This must correspond to the LDM in cpu_resume() assembly */
*ptr++ = virt_to_phys(suspend_pgd);
*ptr++ = sp;
*ptr++ = virt_to_phys(cpu_do_resume);
cpu_do_suspend(ptr);
flush_cache_louis();
__cpuc_flush_dcache_area(ctx, ptrsz);
__cpuc_flush_dcache_area(save_ptr, sizeof(*save_ptr));
outer_clean_range(*save_ptr, *save_ptr + ptrsz);
outer_clean_range(virt_to_phys(save_ptr),
virt_to_phys(save_ptr) + sizeof(*save_ptr));
}
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
ARM Common PM Code
Security Management
Most of the operations should be carried out in secure world
non-secure cache-line clean/invalidate can be deferred
Policy decisions made in Linux
ARM PSCI implementation in the making
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
ARM Common PM Code
Putting Everything Together (1/2)
CPU idle skeleton state enter function
struct pm_pms {
unsigned int cluster_state;
unsigned int cpu_state;
};
void enter_idle(unsigned int cluster_state, unsigned int cpu_state)
{
int cpu = smp_processor_id();
struct pm_pms pms;
struct cpumask tmp;
[...]
cpu_set(cpu, cpuidle_mask);
cpumask_and(&tmp, &cpuidle_mask, topology_core_cpumask(cpu));
pms.cluster_state = cluster_state;
pms.cpu_state = cpu_state;
if (!cpu_weight(&tmp) == cpu_weight(topology_core_cpumask(cpu)))
pms.cluster_state = 0;
cpu_pm_enter();
if (pms.cluster_state >= SHUTDOWN)
cpu_cluster_pm_enter();
cpu_suspend(&pms, suspend_finisher);
cpu_pm_exit();
if (pms.power_state >= SHUTDOWN)
cpu_cluster_pm_exit();
cpu_clear(cpu, cpu_idle_mask);
return 0;
}
v7 shutdown next
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
Introduction
ARM Common PM Code
Putting Everything Together (2/2)
int suspend_finisher(unsigned long arg)
{
struct pm_pms *pp = (struct pm_pms *) arg;
[...]
smc_down(...);
return 1;
}
smc_down:
ldr r0, =#SMC_NUMBER
smc #0
/*
* Pseudo code describing what secure world
* should do
*/
{
disable_clean_inv_dcache_louis();
if (cluster->cluster_down && cluster->power_state == SHUTDOWN) {
flush_cache_all();
outer_flush_all();
}
normal_memory_lock();
disable_cci_snoops();
normal_memory_unlock();
power_down_command();
cpu_do_idle();
}
prev
CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro

More Related Content

What's hot

LinuxCNC 入門簡介
LinuxCNC 入門簡介LinuxCNC 入門簡介
LinuxCNC 入門簡介
roboard
 
Robotix Tutorial 9
Robotix Tutorial 9Robotix Tutorial 9
Robotix Tutorial 9
ankuredkie
 
Arm architecture overview
Arm architecture overviewArm architecture overview
Arm architecture overview
Sunil Thorat
 

What's hot (20)

Power management
Power managementPower management
Power management
 
Cctk support for setting hdd password
Cctk support for setting hdd passwordCctk support for setting hdd password
Cctk support for setting hdd password
 
Dell Cctk support for newly added bios tokens
Dell Cctk support for newly added bios tokensDell Cctk support for newly added bios tokens
Dell Cctk support for newly added bios tokens
 
BKK16-TR08 How to generate power models for EAS and IPA
BKK16-TR08 How to generate power models for EAS and IPABKK16-TR08 How to generate power models for EAS and IPA
BKK16-TR08 How to generate power models for EAS and IPA
 
Getting Started with RS08 MCUs
Getting Started with RS08 MCUsGetting Started with RS08 MCUs
Getting Started with RS08 MCUs
 
Cyclone III FPGA Overview Part2
Cyclone III FPGA Overview Part2Cyclone III FPGA Overview Part2
Cyclone III FPGA Overview Part2
 
LinuxCNC 入門簡介
LinuxCNC 入門簡介LinuxCNC 入門簡介
LinuxCNC 入門簡介
 
The Theory and Implementation of DVFS on Linux
The Theory and Implementation of DVFS on LinuxThe Theory and Implementation of DVFS on Linux
The Theory and Implementation of DVFS on Linux
 
Arm cortex-m4 programmer model
Arm cortex-m4 programmer modelArm cortex-m4 programmer model
Arm cortex-m4 programmer model
 
Project ACRN CPU sharing BVT scheduler in ACRN hypervisor
Project ACRN CPU sharing BVT scheduler in ACRN hypervisorProject ACRN CPU sharing BVT scheduler in ACRN hypervisor
Project ACRN CPU sharing BVT scheduler in ACRN hypervisor
 
Embedded System Programming on ARM Cortex M3 and M4 Course
Embedded System Programming on ARM Cortex M3 and M4 CourseEmbedded System Programming on ARM Cortex M3 and M4 Course
Embedded System Programming on ARM Cortex M3 and M4 Course
 
Q2.12: Power Management Across OSs
Q2.12: Power Management Across OSsQ2.12: Power Management Across OSs
Q2.12: Power Management Across OSs
 
ARM7TDM
ARM7TDMARM7TDM
ARM7TDM
 
Robotix Tutorial 9
Robotix Tutorial 9Robotix Tutorial 9
Robotix Tutorial 9
 
伺服馬達控制
伺服馬達控制伺服馬達控制
伺服馬達控制
 
Interface gsm module with pic
Interface gsm module with picInterface gsm module with pic
Interface gsm module with pic
 
arm-cortex-a8
arm-cortex-a8arm-cortex-a8
arm-cortex-a8
 
TinyML - 4 speech recognition
TinyML - 4 speech recognition TinyML - 4 speech recognition
TinyML - 4 speech recognition
 
Arm architecture
Arm architectureArm architecture
Arm architecture
 
Arm architecture overview
Arm architecture overviewArm architecture overview
Arm architecture overview
 

Similar to LCA13: CPUIDLE: One driver to rule them all?

HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted FirmwareHKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
Linaro
 
Hardware Management Module
Hardware Management ModuleHardware Management Module
Hardware Management Module
Aero Plane
 
HKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with CoresightHKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with Coresight
Linaro
 
Lcu14 101- coresight overview
Lcu14 101- coresight overviewLcu14 101- coresight overview
Lcu14 101- coresight overview
Linaro
 

Similar to LCA13: CPUIDLE: One driver to rule them all? (20)

Nvidia tegra K1 Presentation
Nvidia tegra K1 PresentationNvidia tegra K1 Presentation
Nvidia tegra K1 Presentation
 
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted FirmwareHKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
 
SoC Idling for unconf COSCUP 2016
SoC Idling for unconf COSCUP 2016SoC Idling for unconf COSCUP 2016
SoC Idling for unconf COSCUP 2016
 
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted FirmwareHKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
HKG15-505: Power Management interactions with OP-TEE and Trusted Firmware
 
Arm architecture overview
Arm architecture overviewArm architecture overview
Arm architecture overview
 
OSMC 2014: Server Hardware Monitoring done right | Werner Fischer
OSMC 2014: Server Hardware Monitoring done right | Werner FischerOSMC 2014: Server Hardware Monitoring done right | Werner Fischer
OSMC 2014: Server Hardware Monitoring done right | Werner Fischer
 
BKK16-410 SoC Idling & CPU Cluster PM
BKK16-410 SoC Idling & CPU Cluster PMBKK16-410 SoC Idling & CPU Cluster PM
BKK16-410 SoC Idling & CPU Cluster PM
 
Presentation power vm common 2012
Presentation   power vm common 2012Presentation   power vm common 2012
Presentation power vm common 2012
 
Hardware Management Module
Hardware Management ModuleHardware Management Module
Hardware Management Module
 
Challenges in GPU compilers
Challenges in GPU compilersChallenges in GPU compilers
Challenges in GPU compilers
 
SDC Server Sao Jose
SDC Server Sao JoseSDC Server Sao Jose
SDC Server Sao Jose
 
ARM - Advance RISC Machine
ARM - Advance RISC MachineARM - Advance RISC Machine
ARM - Advance RISC Machine
 
arm
armarm
arm
 
HKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with CoresightHKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with Coresight
 
QEMU - Binary Translation
QEMU - Binary Translation QEMU - Binary Translation
QEMU - Binary Translation
 
ACRN vMeet-Up EU 2021 - Real Time Management and Performance Optimization
ACRN vMeet-Up EU 2021 - Real Time Management and Performance OptimizationACRN vMeet-Up EU 2021 - Real Time Management and Performance Optimization
ACRN vMeet-Up EU 2021 - Real Time Management and Performance Optimization
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailed
 
Introduction to stm32-part2
Introduction to stm32-part2Introduction to stm32-part2
Introduction to stm32-part2
 
Linux_swspnd_v0.3_pub1
Linux_swspnd_v0.3_pub1Linux_swspnd_v0.3_pub1
Linux_swspnd_v0.3_pub1
 
Lcu14 101- coresight overview
Lcu14 101- coresight overviewLcu14 101- coresight overview
Lcu14 101- coresight overview
 

More from Linaro

Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Deep Learning Neural Network Acceleration at the Edge - Andrea GalloDeep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Linaro
 
HPC network stack on ARM - Linaro HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018HPC network stack on ARM - Linaro HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018
Linaro
 
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Linaro
 
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Linaro
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
Linaro
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
Linaro
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
Linaro
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMU
Linaro
 
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation
Linaro
 
HKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootHKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted boot
Linaro
 

More from Linaro (20)

Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Deep Learning Neural Network Acceleration at the Edge - Andrea GalloDeep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
 
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta Vekaria
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta VekariaArm Architecture HPC Workshop Santa Clara 2018 - Kanta Vekaria
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta Vekaria
 
Huawei’s requirements for the ARM based HPC solution readiness - Joshua Mora
Huawei’s requirements for the ARM based HPC solution readiness - Joshua MoraHuawei’s requirements for the ARM based HPC solution readiness - Joshua Mora
Huawei’s requirements for the ARM based HPC solution readiness - Joshua Mora
 
Bud17 113: distribution ci using qemu and open qa
Bud17 113: distribution ci using qemu and open qaBud17 113: distribution ci using qemu and open qa
Bud17 113: distribution ci using qemu and open qa
 
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018
 
HPC network stack on ARM - Linaro HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018HPC network stack on ARM - Linaro HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018
 
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
 
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
 
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
 
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
 
HKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteHKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening Keynote
 
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopHKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP Workshop
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
 
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and allHKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMU
 
HKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8MHKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8M
 
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation
 
HKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootHKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted boot
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
Decarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational PerformanceDecarbonising Commercial Real Estate: The Role of Operational Performance
Decarbonising Commercial Real Estate: The Role of Operational Performance
 
Navigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern EnterpriseNavigating Identity and Access Management in the Modern Enterprise
Navigating Identity and Access Management in the Modern Enterprise
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

LCA13: CPUIDLE: One driver to rule them all?

  • 1. Introduction CPUidle: One Driver to Rule Them All D.Lezcano, L.Pieralisi LCA 2013 CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 2. Introduction Motivation CPUidle Common Driver: Goal The number of SoCs is increasing, so is their complexity Vendors started to implement fine grained power gating capabilities (per core) CPUidle framework is gaining momentum Unfortunately, each vendor is focused on their own solution without taking care of: Maintainability Code reuse Future improvements Consistency across the cpuidle drivers CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 3. Introduction Motivation CPUidle: Current issues copy/paste is commonplace to implement a driver from scratch Result is a lot of duplicate code (which may duplicate bugs) eg. ux500 vs imx6 cpuidle driver (mostly the same) CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 4. Introduction CPU idle status CPUidle: UP platforms WFI = Wait for interrupt (Clock gating) OMAP3 7 idle states very complex driver using an extra array with data AT91 2 idle states WFI WFI + DDR self refresh Kirkwood 2 idle states WFI WFI + DDR self refresh SH mobile 1 state WFI defines a custom function but actually it reimplements cpu do idle() For UP systems, apart from OMAP3, all other drivers are very similar A default idle driver state1 => WFI state2 => DDR self refresh ops CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 5. Introduction CPU idle status CPU idle: SMP platforms (1/2) WFI = Wait for interrupt (Clock gating) Calxeda 2 idle states WFI power gating (PSCI based) Tegra2 1 idle state WFI Tegra3 2 idle states WFI Power gating IMX5 1 state WFI custom but described as ”CPU state retained/ Powered off” IMX6 2 states Last man standing copy’n’pasted from u8500 WFI Clock Off CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 6. Introduction CPU idle status CPUidle: SMP platforms (2/2) WFI = Wait for interrupt (Clock gating) Exynos 2 states (CPU hotplug) WFI CPU power down u8500 2 states WFI CPU state retained OMAP4 3 states WFI custom CPU off/MPU on CPU off/MPU off using coupled C-states using an extra array CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 7. Introduction CPU idle status CPUidle status: maintainership drivers are under the SoC vendor maintainer umbrella not a single entry point reviews carried out by different people different origin from the merge tree CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 8. Introduction CPU idle status CPUidle status: internal The cpuidle drivers tend to manage the peripherals power Checks if the specific power domain could be powered down Override the governor’s decision Adds more complexity Introduces more dependencies CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 9. Introduction CPU idle status CPUidle Common Driver: guidelines pm runtime / generic power domain cpuidle attach to genpd device tree representation CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 10. Introduction CPU idle status CPUidle Common Driver: pm runtime / genpd use pm runtime for the peripherals use the generic power domain for the peripherals if something is missing in pm runtime or genpd : improve them, do not hack the driver 1 static struct rmobile pm domain sh7372 pm domains[] = { 2 ... 3 { 4 .genpd.name = ”A4S”, 5 ... 6 }; CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 11. Introduction CPU idle status CPUidle Common Driver: cpuidle attach Attach the generic power domain to a cpuidle state 1 int pm genpd attach cpuidle(struct generic pm domain ∗genpd, int state); 2 int pm genpd name attach cpuidle(const char ∗name, int state); Listing 1: example shmobile 1 pm genpd name attach cpuidle(”A4S”, 4); CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 12. Introduction CPU idle status CPUidle Common Driver: cpuidle attach Domain poweron/poweroff will disable the cpuidle state 1 int pm genpd poweron(struct generic pm domain ∗genpd) 2 { 3 ... 4 genpd−>cpu data−>idle state−>disabled = true; 5 ... 6 } 7 8 int pm genpd poweroff(struct generic pm domain ∗genpd) 9 { 10 ... 11 genpd−>cpu data−>idle state−>disabled = false; 12 ... 13 } CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 13. Introduction CPU idle status CPUidle Common Driver: cpuidle attach The cpuidle governor won’t choose the disabled state 1 int menu select(struct cpuidle driver ∗drv, struct cpuidle device ∗dev) 2 { 3 ... 4 for (i = CPUIDLE DRIVER STATE START; i < drv−>state count; i++) { 5 struct cpuidle state ∗s = &drv−>states[i]; 6 struct cpuidle state usage ∗su = &dev−>states usage[i]; 7 8 if (s−>disabled || su−>disable) 9 continue; 10 11 ... 12 } CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 14. Introduction CPU idle status CPUidle Common Driver: dts An array of callbacks for all the arch specific idle functions A cpuidle driver structure initialized with the dts information CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 15. Introduction CPU idle status CPUidle Common Driver: dts 1 cpuidle { 2 idlestates { 3 idlestate0: idlestate@0 { 4 enter = ”simple”; 5 exit latency = <1>; 6 target residency = <1>; 7 power usage = <0xffffffff>; 8 flags = <0x1>; 9 state name = ”WFI”; 10 desc = ”ARM WFI”; 11 }; 12 }; 13 }; CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 16. Introduction CPU idle status Conclusion CPUidle drivers need consolidation Use pm runtime for the peripherals Use the generic power domain with cpuidle Common code must be factorized DT to the rescue for idle states data Outlook DT states bindings Starting by creating a single driver for existing drivers Integrate ARM PSCI proposal CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 17. Introduction CPU idle status THANKS !!! CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 18. Introduction ARM Common PM Code ARM Common PM Code Components CPU PM notifiers Local timers save/restore CPU suspend/resume CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 19. Introduction ARM Common PM Code CPU PM notifiers (1/3) Introduced by C.Cross to overcome code duplication in idle and suspend code path CPU events and CLUSTER events GIC, VFP, PMU CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 20. Introduction ARM Common PM Code CPU PM notifiers (2/3) static int cpu_pm_notify(enum cpu_pm_event event, int nr_to_call, int *nr_calls) { int ret; ret = __raw_notifier_call_chain(&cpu_pm_notifier_chain, event, NULL, nr_to_call, nr_calls); return notifier_to_errno(ret); } int cpu_pm_enter(void) { [...] ret = cpu_pm_notify(CPU_PM_ENTER, -1, &nr_calls); if (ret) cpu_pm_notify(CPU_PM_ENTER_FAILED, nr_calls - 1, NULL); [...] return ret; } //CPU shutdown cpu_pm_{enter,exit}(); //Cluster shutdown cpu_cluster_pm_{enter,exit}(); CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 21. Introduction ARM Common PM Code CPU PM notifiers (3/3) static int gic_notifier(struct notifier_block *self, unsigned long cmd, void *v) { int i; [...] switch (cmd) { case CPU_PM_ENTER: gic_cpu_save(i); break; case CPU_PM_ENTER_FAILED: case CPU_PM_EXIT: gic_cpu_restore(i); break; case CPU_CLUSTER_PM_ENTER: gic_dist_save(i); break; case CPU_CLUSTER_PM_ENTER_FAILED: case CPU_CLUSTER_PM_EXIT: gic_dist_restore(i); break; } return NOTIFY_OK; } static struct notifier_block gic_notifier_block = { .notifier_call = gic_notifier, }; CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 22. Introduction ARM Common PM Code Local timers save/restore void enter_idle(...) { [...] clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu); [...] cpu_do_idle(); [...] clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu); [...] } void enter_idle(...) { struct tick_device *tdev = tick_get_device(cpu); [...] cpu_do_idle(); [...] /* Restore the per-cpu timer event */ clockevents_program_event(tdev->evtdev, tdev->evtdev->next_event, 1); } Enter broadcast mode if a global timer is available Rely on always-on firmware timer and restore timer through clock events programming API CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 23. Introduction ARM Common PM Code CPU suspend (1/3) Introduced by R.King to consolidate existing (and duplicated) code across diffent ARM platforms save/restore core registers, clean L1 and some bits of L2 L2 RAM retention handling poses further challenges CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 24. Introduction ARM Common PM Code CPU suspend (2/3) 1:1 mapping page tables cloned from init_mm C API, generic for all ARM architectures int cpu_suspend(unsigned long arg, int (*fn)(unsigned long)) { struct mm_struct *mm = current->active_mm; int ret; if (!suspend_pgd) return -EINVAL; [...] ret = __cpu_suspend(arg, fn); if (ret == 0) { cpu_switch_mm(mm->pgd, mm); local_flush_tlb_all(); } return ret; } CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 25. Introduction ARM Common PM Code CPU suspend (3/3) registers saved on the stack void __cpu_suspend_save(u32 *ptr, u32 ptrsz, u32 sp, u32 *save_ptr) { u32 *ctx = ptr; *save_ptr = virt_to_phys(ptr); /* This must correspond to the LDM in cpu_resume() assembly */ *ptr++ = virt_to_phys(suspend_pgd); *ptr++ = sp; *ptr++ = virt_to_phys(cpu_do_resume); cpu_do_suspend(ptr); } CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 26. Introduction ARM Common PM Code CPU suspend (3/3) registers saved on the stack L1 complete cleaning void __cpu_suspend_save(u32 *ptr, u32 ptrsz, u32 sp, u32 *save_ptr) { u32 *ctx = ptr; *save_ptr = virt_to_phys(ptr); /* This must correspond to the LDM in cpu_resume() assembly */ *ptr++ = virt_to_phys(suspend_pgd); *ptr++ = sp; *ptr++ = virt_to_phys(cpu_do_resume); cpu_do_suspend(ptr); flush_cache_louis(); } CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 27. Introduction ARM Common PM Code CPU suspend (3/3) registers saved on the stack L1 complete cleaning L2 partial cleaning void __cpu_suspend_save(u32 *ptr, u32 ptrsz, u32 sp, u32 *save_ptr) { u32 *ctx = ptr; *save_ptr = virt_to_phys(ptr); /* This must correspond to the LDM in cpu_resume() assembly */ *ptr++ = virt_to_phys(suspend_pgd); *ptr++ = sp; *ptr++ = virt_to_phys(cpu_do_resume); cpu_do_suspend(ptr); flush_cache_louis(); __cpuc_flush_dcache_area(ctx, ptrsz); __cpuc_flush_dcache_area(save_ptr, sizeof(*save_ptr)); outer_clean_range(*save_ptr, *save_ptr + ptrsz); outer_clean_range(virt_to_phys(save_ptr), virt_to_phys(save_ptr) + sizeof(*save_ptr)); } CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 28. Introduction ARM Common PM Code Security Management Most of the operations should be carried out in secure world non-secure cache-line clean/invalidate can be deferred Policy decisions made in Linux ARM PSCI implementation in the making CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 29. Introduction ARM Common PM Code Putting Everything Together (1/2) CPU idle skeleton state enter function struct pm_pms { unsigned int cluster_state; unsigned int cpu_state; }; void enter_idle(unsigned int cluster_state, unsigned int cpu_state) { int cpu = smp_processor_id(); struct pm_pms pms; struct cpumask tmp; [...] cpu_set(cpu, cpuidle_mask); cpumask_and(&tmp, &cpuidle_mask, topology_core_cpumask(cpu)); pms.cluster_state = cluster_state; pms.cpu_state = cpu_state; if (!cpu_weight(&tmp) == cpu_weight(topology_core_cpumask(cpu))) pms.cluster_state = 0; cpu_pm_enter(); if (pms.cluster_state >= SHUTDOWN) cpu_cluster_pm_enter(); cpu_suspend(&pms, suspend_finisher); cpu_pm_exit(); if (pms.power_state >= SHUTDOWN) cpu_cluster_pm_exit(); cpu_clear(cpu, cpu_idle_mask); return 0; } v7 shutdown next CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro
  • 30. Introduction ARM Common PM Code Putting Everything Together (2/2) int suspend_finisher(unsigned long arg) { struct pm_pms *pp = (struct pm_pms *) arg; [...] smc_down(...); return 1; } smc_down: ldr r0, =#SMC_NUMBER smc #0 /* * Pseudo code describing what secure world * should do */ { disable_clean_inv_dcache_louis(); if (cluster->cluster_down && cluster->power_state == SHUTDOWN) { flush_cache_all(); outer_flush_all(); } normal_memory_lock(); disable_cci_snoops(); normal_memory_unlock(); power_down_command(); cpu_do_idle(); } prev CPUidle: One Driver to Rule Them All ARM Ltd. - Linaro