[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240614034433.602622-11-liaochang1@huawei.com>
Date: Fri, 14 Jun 2024 03:44:33 +0000
From: Liao Chang <liaochang1@...wei.com>
To: <catalin.marinas@....com>, <will@...nel.org>, <ryabinin.a.a@...il.com>,
<glider@...gle.com>, <andreyknvl@...il.com>, <dvyukov@...gle.com>,
<vincenzo.frascino@....com>, <maz@...nel.org>, <oliver.upton@...ux.dev>,
<james.morse@....com>, <suzuki.poulose@....com>, <yuzenghui@...wei.com>,
<mark.rutland@....com>, <lpieralisi@...nel.org>, <tglx@...utronix.de>,
<ardb@...nel.org>, <broonie@...nel.org>, <liaochang1@...wei.com>,
<steven.price@....com>, <ryan.roberts@....com>, <pcc@...gle.com>,
<anshuman.khandual@....com>, <eric.auger@...hat.com>,
<miguel.luis@...cle.com>, <shiqiliu@...t.edu.cn>, <quic_jiles@...cinc.com>,
<rafael@...nel.org>, <sudeep.holla@....com>, <dwmw@...zon.co.uk>,
<joey.gouly@....com>, <jeremy.linton@....com>, <robh@...nel.org>,
<scott@...amperecomputing.com>, <songshuaishuai@...ylab.org>,
<swboyd@...omium.org>, <dianders@...omium.org>,
<shijie@...amperecomputing.com>, <bhe@...hat.com>,
<akpm@...ux-foundation.org>, <rppt@...nel.org>, <mhiramat@...nel.org>,
<mcgrof@...nel.org>, <rmk+kernel@...linux.org.uk>,
<Jonathan.Cameron@...wei.com>, <takakura@...inux.co.jp>,
<sumit.garg@...aro.org>, <frederic@...nel.org>, <tabba@...gle.com>,
<kristina.martsenko@....com>, <ruanjinjie@...wei.com>
CC: <linux-arm-kernel@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
<kasan-dev@...glegroups.com>, <kvmarm@...ts.linux.dev>
Subject: [PATCH v4 10/10] arm64: Migrate idle context save/restore to logical interrupt masking
This patch is part of migration series, replaces the low-level hardware
interrupt masking operations used during CPU idle context save/restore
with the new helper functions starting from local_allint_, it can ensure
the compatibility with future FEAT_NMI feature.
Signed-off-by: Liao Chang <liaochang1@...wei.com>
---
arch/arm64/include/asm/cpuidle.h | 24 +++++-------------------
arch/arm64/include/asm/daifflags.h | 17 ++++++++++++++---
arch/arm64/kernel/idle.c | 2 +-
arch/arm64/kernel/suspend.c | 2 +-
drivers/firmware/psci/psci.c | 2 +-
5 files changed, 22 insertions(+), 25 deletions(-)
diff --git a/arch/arm64/include/asm/cpuidle.h b/arch/arm64/include/asm/cpuidle.h
index 2047713e097d..b4e230fc8a7b 100644
--- a/arch/arm64/include/asm/cpuidle.h
+++ b/arch/arm64/include/asm/cpuidle.h
@@ -5,32 +5,18 @@
#include <asm/proc-fns.h>
#ifdef CONFIG_ARM64_PSEUDO_NMI
-#include <asm/arch_gicv3.h>
-
-struct arm_cpuidle_irq_context {
- unsigned long pmr;
- unsigned long daif_bits;
-};
+#include <asm/daifflags.h>
#define arm_cpuidle_save_irq_context(__c) \
do { \
- struct arm_cpuidle_irq_context *c = __c; \
- if (system_uses_irq_prio_masking()) { \
- c->daif_bits = read_sysreg(daif); \
- write_sysreg(c->daif_bits | PSR_I_BIT | PSR_F_BIT, \
- daif); \
- c->pmr = gic_read_pmr(); \
- gic_write_pmr(GIC_PRIO_IRQON | GIC_PRIO_PSR_I_SET); \
- } \
+ arch_irqflags_t *c = __c; \
+ *c = local_allint_save_notrace(); \
} while (0)
#define arm_cpuidle_restore_irq_context(__c) \
do { \
- struct arm_cpuidle_irq_context *c = __c; \
- if (system_uses_irq_prio_masking()) { \
- gic_write_pmr(c->pmr); \
- write_sysreg(c->daif_bits, daif); \
- } \
+ arch_irqflags_t *c = __c; \
+ local_allint_restore_notrace(*c); \
} while (0)
#else
struct arm_cpuidle_irq_context { };
diff --git a/arch/arm64/include/asm/daifflags.h b/arch/arm64/include/asm/daifflags.h
index 01c7123d5604..f60f933b88e3 100644
--- a/arch/arm64/include/asm/daifflags.h
+++ b/arch/arm64/include/asm/daifflags.h
@@ -84,9 +84,9 @@ static inline void __local_nmi_mask(void)
msr_pstate_allint(1);
}
-static inline void local_allint_mask_notrace(void)
+static inline void local_allint_mask_notrace(unsigned long daif_bits)
{
- asm volatile ("msr daifset, #0xf" : : : "memory");
+ write_sysreg(daif_bits, daif);
if (system_uses_irq_prio_masking())
__local_pmr_mask();
@@ -97,7 +97,7 @@ static inline void local_allint_mask_notrace(void)
/* mask/save/unmask/restore all exceptions, including interrupts. */
static inline void local_allint_mask(void)
{
- local_allint_mask_notrace();
+ local_allint_mask_notrace(DAIF_MASK);
trace_hardirqs_off();
}
@@ -172,6 +172,17 @@ static inline arch_irqflags_t local_allint_save(void)
return irqflags;
}
+static inline arch_irqflags_t local_allint_save_notrace(void)
+{
+ arch_irqflags_t irqflags;
+
+ irqflags = local_allint_save_flags();
+
+ local_allint_mask_notrace(irqflags.fields.daif | PSR_I_BIT | PSR_F_BIT);
+
+ return irqflags;
+}
+
static inline void __local_pmr_restore(arch_irqflags_t irqflags)
{
/*
diff --git a/arch/arm64/kernel/idle.c b/arch/arm64/kernel/idle.c
index 05cfb347ec26..69b8aa30273e 100644
--- a/arch/arm64/kernel/idle.c
+++ b/arch/arm64/kernel/idle.c
@@ -22,7 +22,7 @@
*/
void __cpuidle cpu_do_idle(void)
{
- struct arm_cpuidle_irq_context context;
+ arch_irqflags_t context;
arm_cpuidle_save_irq_context(&context);
diff --git a/arch/arm64/kernel/suspend.c b/arch/arm64/kernel/suspend.c
index 559f1eb1ae2e..ff6ac032b377 100644
--- a/arch/arm64/kernel/suspend.c
+++ b/arch/arm64/kernel/suspend.c
@@ -99,7 +99,7 @@ int cpu_suspend(unsigned long arg, int (*fn)(unsigned long))
int ret = 0;
arch_irqflags_t flags;
struct sleep_stack_data state;
- struct arm_cpuidle_irq_context context;
+ arch_irqflags_t context;
/*
* Some portions of CPU state (e.g. PSTATE.{PAN,DIT}) are initialized
diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
index d9629ff87861..b5089d4d9478 100644
--- a/drivers/firmware/psci/psci.c
+++ b/drivers/firmware/psci/psci.c
@@ -471,7 +471,7 @@ int psci_cpu_suspend_enter(u32 state)
int ret;
if (!psci_power_state_loses_context(state)) {
- struct arm_cpuidle_irq_context context;
+ arch_irqflags_t context;
ct_cpuidle_enter();
arm_cpuidle_save_irq_context(&context);
--
2.34.1
Powered by blists - more mailing lists