* [PATCH v2] riscv: acpi: Handle LPI architectural context loss flags
@ 2026-07-28 11:47 Peixin Xie
2026-07-28 12:54 ` Sunil V L
2026-07-29 1:34 ` lihuisong (C)
0 siblings, 2 replies; 4+ messages in thread
From: Peixin Xie @ 2026-07-28 11:47 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Yixun Lan, Sudeep Holla, Oza Pawandeep, Will Deacon,
Rafael J. Wysocki
Cc: linux-acpi, linux-riscv, linux-kernel, spacemit, stable, Peixin Xie
Commit 4785aa802853 ("cpuidle, ACPI: Evaluate LPI arch_flags for
broadcast timer") replaced the generic nonzero check for LPI
architectural context loss flags with arch_get_idle_state_flags().
RISC-V does not implement the helper, so it falls back to the stub
that returns 0. Consequently, CPUIDLE_FLAG_TIMER_STOP is not set when
an LPI state loses the hart timer context, preventing cpuidle from
using a broadcast timer for that state.
Implement the RISC-V helper and map the hart timer context loss flag
to CPUIDLE_FLAG_TIMER_STOP.
Fixes: 4785aa802853 ("cpuidle, ACPI: Evaluate LPI arch_flags for broadcast timer")
Cc: stable@vger.kernel.org
Acked-by: Sudeep Holla <sudeep.holla@kernel.org>
Reviewed-by: Yixun Lan <dlan@kernel.org>
Signed-off-by: Peixin Xie <peixin.xie@linux.spacemit.com>
---
Changes in v2:
- Correct the FFH specification reference to Chapter 2.1.1.2,
Table 3, as suggested by Yixun.
- Link to v1: https://patch.msgid.link/20260728-riscv-acpi-lpi-timer-v1-1-c722bce01e48@linux.spacemit.com
---
arch/riscv/include/asm/acpi.h | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h
index 26ab37c171bc..2643e28fc08c 100644
--- a/arch/riscv/include/asm/acpi.h
+++ b/arch/riscv/include/asm/acpi.h
@@ -12,6 +12,8 @@
#ifndef _ASM_ACPI_H
#define _ASM_ACPI_H
+#include <linux/cpuidle.h>
+
/* Basic configuration for ACPI */
#ifdef CONFIG_ACPI
@@ -67,6 +69,23 @@ int acpi_get_riscv_isa(struct acpi_table_header *table,
void acpi_get_cbo_block_size(struct acpi_table_header *table, u32 *cbom_size,
u32 *cboz_size, u32 *cbop_size);
+
+/*
+ * RISC-V Functional Fixed Hardware Specification Version v1.0.1,
+ * Chapter 2.1.1.2. Arch. Context Lost Flags, Table 3
+ */
+#define RISCV_LPI_HART_TIMER_CTXT_LOST BIT(0)
+
+static inline unsigned int arch_get_idle_state_flags(u32 arch_flags)
+{
+ if (arch_flags & RISCV_LPI_HART_TIMER_CTXT_LOST)
+ return CPUIDLE_FLAG_TIMER_STOP;
+
+ return 0;
+}
+
+#define arch_get_idle_state_flags arch_get_idle_state_flags
+
#else
static inline void acpi_init_rintc_map(void) { }
static inline struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu)
---
base-commit: 1d6f0a217c662693d2307ee06851cb4bfcbf9529
change-id: 20260727-riscv-acpi-lpi-timer-6f1739a6c831
Best regards,
--
Peixin Xie <peixin.xie@linux.spacemit.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] riscv: acpi: Handle LPI architectural context loss flags
2026-07-28 11:47 [PATCH v2] riscv: acpi: Handle LPI architectural context loss flags Peixin Xie
@ 2026-07-28 12:54 ` Sunil V L
2026-07-28 13:19 ` Sunil V L
2026-07-29 1:34 ` lihuisong (C)
1 sibling, 1 reply; 4+ messages in thread
From: Sunil V L @ 2026-07-28 12:54 UTC (permalink / raw)
To: Peixin Xie
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Yixun Lan, Sudeep Holla, Oza Pawandeep, Will Deacon,
Rafael J. Wysocki, linux-acpi, linux-riscv, linux-kernel,
spacemit, stable
On Tue, Jul 28, 2026 at 5:24 PM Peixin Xie
<peixin.xie@linux.spacemit.com> wrote:
>
> Commit 4785aa802853 ("cpuidle, ACPI: Evaluate LPI arch_flags for
> broadcast timer") replaced the generic nonzero check for LPI
> architectural context loss flags with arch_get_idle_state_flags().
> RISC-V does not implement the helper, so it falls back to the stub
> that returns 0. Consequently, CPUIDLE_FLAG_TIMER_STOP is not set when
> an LPI state loses the hart timer context, preventing cpuidle from
> using a broadcast timer for that state.
>
> Implement the RISC-V helper and map the hart timer context loss flag
> to CPUIDLE_FLAG_TIMER_STOP.
>
> Fixes: 4785aa802853 ("cpuidle, ACPI: Evaluate LPI arch_flags for broadcast timer")
> Cc: stable@vger.kernel.org
> Acked-by: Sudeep Holla <sudeep.holla@kernel.org>
> Reviewed-by: Yixun Lan <dlan@kernel.org>
> Signed-off-by: Peixin Xie <peixin.xie@linux.spacemit.com>
> ---
> Changes in v2:
> - Correct the FFH specification reference to Chapter 2.1.1.2,
> Table 3, as suggested by Yixun.
> - Link to v1: https://patch.msgid.link/20260728-riscv-acpi-lpi-timer-v1-1-c722bce01e48@linux.spacemit.com
> ---
> arch/riscv/include/asm/acpi.h | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h
> index 26ab37c171bc..2643e28fc08c 100644
> --- a/arch/riscv/include/asm/acpi.h
> +++ b/arch/riscv/include/asm/acpi.h
> @@ -12,6 +12,8 @@
> #ifndef _ASM_ACPI_H
> #define _ASM_ACPI_H
>
> +#include <linux/cpuidle.h>
> +
> /* Basic configuration for ACPI */
> #ifdef CONFIG_ACPI
>
> @@ -67,6 +69,23 @@ int acpi_get_riscv_isa(struct acpi_table_header *table,
>
> void acpi_get_cbo_block_size(struct acpi_table_header *table, u32 *cbom_size,
> u32 *cboz_size, u32 *cbop_size);
> +
> +/*
> + * RISC-V Functional Fixed Hardware Specification Version v1.0.1,
> + * Chapter 2.1.1.2. Arch. Context Lost Flags, Table 3
>
Isn't it Chapter 3.1.2, Table 4?
> + */
> +#define RISCV_LPI_HART_TIMER_CTXT_LOST BIT(0)
> +
> +static inline unsigned int arch_get_idle_state_flags(u32 arch_flags)
> +{
> + if (arch_flags & RISCV_LPI_HART_TIMER_CTXT_LOST)
> + return CPUIDLE_FLAG_TIMER_STOP;
> +
> + return 0;
> +}
> +
> +#define arch_get_idle_state_flags arch_get_idle_state_flags
> +
Otherwise, LGTM.
Reviewed-by: Sunil V L <sunilvl@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] riscv: acpi: Handle LPI architectural context loss flags
2026-07-28 12:54 ` Sunil V L
@ 2026-07-28 13:19 ` Sunil V L
0 siblings, 0 replies; 4+ messages in thread
From: Sunil V L @ 2026-07-28 13:19 UTC (permalink / raw)
To: Peixin Xie
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Yixun Lan, Sudeep Holla, Oza Pawandeep, Will Deacon,
Rafael J. Wysocki, linux-acpi, linux-riscv, linux-kernel,
spacemit, stable
On Tue, Jul 28, 2026 at 6:24 PM Sunil V L <sunilvl@oss.qualcomm.com> wrote:
>
> On Tue, Jul 28, 2026 at 5:24 PM Peixin Xie
> <peixin.xie@linux.spacemit.com> wrote:
> >
> > Commit 4785aa802853 ("cpuidle, ACPI: Evaluate LPI arch_flags for
> > broadcast timer") replaced the generic nonzero check for LPI
> > architectural context loss flags with arch_get_idle_state_flags().
> > RISC-V does not implement the helper, so it falls back to the stub
> > that returns 0. Consequently, CPUIDLE_FLAG_TIMER_STOP is not set when
> > an LPI state loses the hart timer context, preventing cpuidle from
> > using a broadcast timer for that state.
> >
> > Implement the RISC-V helper and map the hart timer context loss flag
> > to CPUIDLE_FLAG_TIMER_STOP.
> >
> > Fixes: 4785aa802853 ("cpuidle, ACPI: Evaluate LPI arch_flags for broadcast timer")
> > Cc: stable@vger.kernel.org
> > Acked-by: Sudeep Holla <sudeep.holla@kernel.org>
> > Reviewed-by: Yixun Lan <dlan@kernel.org>
> > Signed-off-by: Peixin Xie <peixin.xie@linux.spacemit.com>
> > ---
> > Changes in v2:
> > - Correct the FFH specification reference to Chapter 2.1.1.2,
> > Table 3, as suggested by Yixun.
> > - Link to v1: https://patch.msgid.link/20260728-riscv-acpi-lpi-timer-v1-1-c722bce01e48@linux.spacemit.com
> > ---
> > arch/riscv/include/asm/acpi.h | 19 +++++++++++++++++++
> > 1 file changed, 19 insertions(+)
> >
> > diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h
> > index 26ab37c171bc..2643e28fc08c 100644
> > --- a/arch/riscv/include/asm/acpi.h
> > +++ b/arch/riscv/include/asm/acpi.h
> > @@ -12,6 +12,8 @@
> > #ifndef _ASM_ACPI_H
> > #define _ASM_ACPI_H
> >
> > +#include <linux/cpuidle.h>
> > +
> > /* Basic configuration for ACPI */
> > #ifdef CONFIG_ACPI
> >
> > @@ -67,6 +69,23 @@ int acpi_get_riscv_isa(struct acpi_table_header *table,
> >
> > void acpi_get_cbo_block_size(struct acpi_table_header *table, u32 *cbom_size,
> > u32 *cboz_size, u32 *cbop_size);
> > +
> > +/*
> > + * RISC-V Functional Fixed Hardware Specification Version v1.0.1,
> > + * Chapter 2.1.1.2. Arch. Context Lost Flags, Table 3
> >
> Isn't it Chapter 3.1.2, Table 4?
>
It appears there is an issue with the HTML version regarding the
chapter numbering. I have reported this to the documentation team. In
the meantime, I recommend using the PDF version as the reference for
any citations.
Thanks,
Sunil
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] riscv: acpi: Handle LPI architectural context loss flags
2026-07-28 11:47 [PATCH v2] riscv: acpi: Handle LPI architectural context loss flags Peixin Xie
2026-07-28 12:54 ` Sunil V L
@ 2026-07-29 1:34 ` lihuisong (C)
1 sibling, 0 replies; 4+ messages in thread
From: lihuisong (C) @ 2026-07-29 1:34 UTC (permalink / raw)
To: Peixin Xie, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Yixun Lan, Sudeep Holla, Oza Pawandeep,
Will Deacon, Rafael J. Wysocki
Cc: linux-acpi, linux-riscv, linux-kernel, spacemit, stable, lihuisong
On 7/28/2026 7:47 PM, Peixin Xie wrote:
> Commit 4785aa802853 ("cpuidle, ACPI: Evaluate LPI arch_flags for
> broadcast timer") replaced the generic nonzero check for LPI
> architectural context loss flags with arch_get_idle_state_flags().
> RISC-V does not implement the helper, so it falls back to the stub
> that returns 0. Consequently, CPUIDLE_FLAG_TIMER_STOP is not set when
> an LPI state loses the hart timer context, preventing cpuidle from
> using a broadcast timer for that state.
>
> Implement the RISC-V helper and map the hart timer context loss flag
> to CPUIDLE_FLAG_TIMER_STOP.
>
> Fixes: 4785aa802853 ("cpuidle, ACPI: Evaluate LPI arch_flags for broadcast timer")
> Cc: stable@vger.kernel.org
> Acked-by: Sudeep Holla <sudeep.holla@kernel.org>
> Reviewed-by: Yixun Lan <dlan@kernel.org>
> Signed-off-by: Peixin Xie <peixin.xie@linux.spacemit.com>
> ---
LGTM,
Reviewed-by: Huisong Li <lihuisong@huawei.com>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-29 1:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-28 11:47 [PATCH v2] riscv: acpi: Handle LPI architectural context loss flags Peixin Xie
2026-07-28 12:54 ` Sunil V L
2026-07-28 13:19 ` Sunil V L
2026-07-29 1:34 ` lihuisong (C)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®