Skip to content

Commit d4dc102

Browse files
Marc Zyngierwilldeacon
authored andcommitted
arm64: Convert cpu_do_idle() to using cpuidle context helpers
Now that we have helpers that are aware of the pseudo-NMI feature, introduce them to cpu_do_idle(). This allows for some nice cleanup. No functional change intended. Tested-by: Valentin Schneider <valentin.schneider@arm.com> Reviewed-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20210615111227.2454465-3-maz@kernel.org Signed-off-by: Will Deacon <will@kernel.org>
1 parent 8848f06 commit d4dc102

1 file changed

Lines changed: 9 additions & 32 deletions

File tree

arch/arm64/kernel/process.c

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
#include <linux/prctl.h>
4747

4848
#include <asm/alternative.h>
49-
#include <asm/arch_gicv3.h>
5049
#include <asm/compat.h>
5150
#include <asm/cpufeature.h>
51+
#include <asm/cpuidle.h>
5252
#include <asm/cacheflush.h>
5353
#include <asm/exec.h>
5454
#include <asm/fpsimd.h>
@@ -74,33 +74,6 @@ EXPORT_SYMBOL_GPL(pm_power_off);
7474

7575
void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
7676

77-
static void noinstr __cpu_do_idle(void)
78-
{
79-
dsb(sy);
80-
wfi();
81-
}
82-
83-
static void noinstr __cpu_do_idle_irqprio(void)
84-
{
85-
unsigned long pmr;
86-
unsigned long daif_bits;
87-
88-
daif_bits = read_sysreg(daif);
89-
write_sysreg(daif_bits | PSR_I_BIT | PSR_F_BIT, daif);
90-
91-
/*
92-
* Unmask PMR before going idle to make sure interrupts can
93-
* be raised.
94-
*/
95-
pmr = gic_read_pmr();
96-
gic_write_pmr(GIC_PRIO_IRQON | GIC_PRIO_PSR_I_SET);
97-
98-
__cpu_do_idle();
99-
100-
gic_write_pmr(pmr);
101-
write_sysreg(daif_bits, daif);
102-
}
103-
10477
/*
10578
* cpu_do_idle()
10679
*
@@ -112,10 +85,14 @@ static void noinstr __cpu_do_idle_irqprio(void)
11285
*/
11386
void noinstr cpu_do_idle(void)
11487
{
115-
if (system_uses_irq_prio_masking())
116-
__cpu_do_idle_irqprio();
117-
else
118-
__cpu_do_idle();
88+
struct arm_cpuidle_irq_context context;
89+
90+
arm_cpuidle_save_irq_context(&context);
91+
92+
dsb(sy);
93+
wfi();
94+
95+
arm_cpuidle_restore_irq_context(&context);
11996
}
12097

12198
/*

0 commit comments

Comments
 (0)