Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPI: RISC-V: Fix false warning in cppc_read_ffh() for same-CPU reads
@ 2026-06-09 11:28 wang.yechao255
  2026-06-25 12:10 ` Jie Zhan
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: wang.yechao255 @ 2026-06-09 11:28 UTC (permalink / raw)
  To: linux-acpi, linux-riscv, linux-kernel
  Cc: zhanjie9, aou, alex, rafael, viresh.kumar, zhenglifeng1,
	pierre.gondois, palmer, pjw, lenb

From: Wang Yechao <wang.yechao255@zte.com.cn>

Commit 997c021abc6e ("cpufreq: CPPC: Update FIE arch_freq_scale in
ticks for non-PCC regs") changed the CPPC Frequency Invariance Engine
to read AMU counters directly from the scheduler tick for non-PCC
register spaces (like FFH), instead of deferring to a kthread. This
means cppc_read_ffh() is now called with IRQs disabled from the tick
handler, triggering the warning.

This is the same fix as commit df6e4ab654dc ("arm64: topology: Fix
false warning in counters_read_on_cpu() for same-CPU reads").

Fixes: 997c021abc6e ("cpufreq: CPPC: Update FIE arch_freq_scale in ticks for non-PCC regs")
Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
---
 drivers/acpi/riscv/cppc.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/riscv/cppc.c b/drivers/acpi/riscv/cppc.c
index 42c1a9052470..5dce0377a8df 100644
--- a/drivers/acpi/riscv/cppc.c
+++ b/drivers/acpi/riscv/cppc.c
@@ -98,16 +98,19 @@ int cpc_read_ffh(int cpu, struct cpc_reg *reg, u64 *val)
 {
 	struct sbi_cppc_data data;

-	if (WARN_ON_ONCE(irqs_disabled()))
-		return -EPERM;
-
 	if (FFH_CPPC_TYPE(reg->address) == FFH_CPPC_SBI) {
 		if (!cppc_ext_present)
 			return -EINVAL;

 		data.reg = FFH_CPPC_SBI_REG(reg->address);

-		smp_call_function_single(cpu, sbi_cppc_read, &data, 1);
+		if (irqs_disabled()) {
+			if (WARN_ON_ONCE(cpu != smp_processor_id()))
+				return -EPERM;
+			sbi_cppc_read(&data);
+		} else {
+			smp_call_function_single(cpu, sbi_cppc_read, &data, 1);
+		}

 		*val = data.ret.value;

@@ -115,7 +118,13 @@ int cpc_read_ffh(int cpu, struct cpc_reg *reg, u64 *val)
 	} else if (FFH_CPPC_TYPE(reg->address) == FFH_CPPC_CSR) {
 		data.reg = FFH_CPPC_CSR_NUM(reg->address);

-		smp_call_function_single(cpu, cppc_ffh_csr_read, &data, 1);
+		if (irqs_disabled()) {
+			if (WARN_ON_ONCE(cpu != smp_processor_id()))
+				return -EPERM;
+			cppc_ffh_csr_read(&data);
+		} else {
+			smp_call_function_single(cpu, cppc_ffh_csr_read, &data, 1);
+		}

 		*val = data.ret.value;

-- 
2.43.5

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ACPI: RISC-V: Fix false warning in cppc_read_ffh() for same-CPU reads
  2026-06-09 11:28 [PATCH] ACPI: RISC-V: Fix false warning in cppc_read_ffh() for same-CPU reads wang.yechao255
@ 2026-06-25 12:10 ` Jie Zhan
  2026-07-01  3:14 ` Sunil V L
  2026-12-01  1:18 ` Paul Walmsley
  2 siblings, 0 replies; 5+ messages in thread
From: Jie Zhan @ 2026-06-25 12:10 UTC (permalink / raw)
  To: wang.yechao255, linux-acpi, linux-riscv, linux-kernel
  Cc: aou, alex, rafael, viresh.kumar, zhenglifeng1, pierre.gondois,
	palmer, pjw, lenb



On 6/9/2026 7:28 PM, wang.yechao255@zte.com.cn wrote:
> From: Wang Yechao <wang.yechao255@zte.com.cn>
> 
> Commit 997c021abc6e ("cpufreq: CPPC: Update FIE arch_freq_scale in
> ticks for non-PCC regs") changed the CPPC Frequency Invariance Engine
> to read AMU counters directly from the scheduler tick for non-PCC
> register spaces (like FFH), instead of deferring to a kthread. This
> means cppc_read_ffh() is now called with IRQs disabled from the tick
> handler, triggering the warning.
> 
> This is the same fix as commit df6e4ab654dc ("arm64: topology: Fix
> false warning in counters_read_on_cpu() for same-CPU reads").
> 
> Fixes: 997c021abc6e ("cpufreq: CPPC: Update FIE arch_freq_scale in ticks for non-PCC regs")
> Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
Indeed.  Thanks for the fix.

Acked-by: Jie Zhan <zhanjie9@hisilicon.com>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ACPI: RISC-V: Fix false warning in cppc_read_ffh() for same-CPU reads
  2026-06-09 11:28 [PATCH] ACPI: RISC-V: Fix false warning in cppc_read_ffh() for same-CPU reads wang.yechao255
  2026-06-25 12:10 ` Jie Zhan
@ 2026-07-01  3:14 ` Sunil V L
  2026-12-01  1:18 ` Paul Walmsley
  2 siblings, 0 replies; 5+ messages in thread
From: Sunil V L @ 2026-07-01  3:14 UTC (permalink / raw)
  To: wang.yechao255
  Cc: zhanjie9, aou, alex, rafael, viresh.kumar, zhenglifeng1,
	linux-kernel, pierre.gondois, linux-acpi, palmer, linux-riscv,
	pjw, lenb

On Tue, Jun 9, 2026 at 5:20 PM <wang.yechao255@zte.com.cn> wrote:
>
> From: Wang Yechao <wang.yechao255@zte.com.cn>
>
> Commit 997c021abc6e ("cpufreq: CPPC: Update FIE arch_freq_scale in
> ticks for non-PCC regs") changed the CPPC Frequency Invariance Engine
> to read AMU counters directly from the scheduler tick for non-PCC
> register spaces (like FFH), instead of deferring to a kthread. This
> means cppc_read_ffh() is now called with IRQs disabled from the tick
> handler, triggering the warning.
>
> This is the same fix as commit df6e4ab654dc ("arm64: topology: Fix
> false warning in counters_read_on_cpu() for same-CPU reads").
>
> Fixes: 997c021abc6e ("cpufreq: CPPC: Update FIE arch_freq_scale in ticks for non-PCC regs")
> Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
> ---
>  drivers/acpi/riscv/cppc.c | 19 ++++++++++++++-----
>  1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/acpi/riscv/cppc.c b/drivers/acpi/riscv/cppc.c
> index 42c1a9052470..5dce0377a8df 100644
> --- a/drivers/acpi/riscv/cppc.c
> +++ b/drivers/acpi/riscv/cppc.c
> @@ -98,16 +98,19 @@ int cpc_read_ffh(int cpu, struct cpc_reg *reg, u64 *val)
>  {
>         struct sbi_cppc_data data;
>
> -       if (WARN_ON_ONCE(irqs_disabled()))
> -               return -EPERM;
> -
>         if (FFH_CPPC_TYPE(reg->address) == FFH_CPPC_SBI) {
>                 if (!cppc_ext_present)
>                         return -EINVAL;
>
>                 data.reg = FFH_CPPC_SBI_REG(reg->address);
>
> -               smp_call_function_single(cpu, sbi_cppc_read, &data, 1);
> +               if (irqs_disabled()) {
> +                       if (WARN_ON_ONCE(cpu != smp_processor_id()))
> +                               return -EPERM;
> +                       sbi_cppc_read(&data);
> +               } else {
> +                       smp_call_function_single(cpu, sbi_cppc_read, &data, 1);
> +               }
>
>                 *val = data.ret.value;
>
> @@ -115,7 +118,13 @@ int cpc_read_ffh(int cpu, struct cpc_reg *reg, u64 *val)
>         } else if (FFH_CPPC_TYPE(reg->address) == FFH_CPPC_CSR) {
>                 data.reg = FFH_CPPC_CSR_NUM(reg->address);
>
> -               smp_call_function_single(cpu, cppc_ffh_csr_read, &data, 1);
> +               if (irqs_disabled()) {
> +                       if (WARN_ON_ONCE(cpu != smp_processor_id()))
> +                               return -EPERM;
> +                       cppc_ffh_csr_read(&data);
> +               } else {
> +                       smp_call_function_single(cpu, cppc_ffh_csr_read, &data, 1);
> +               }
>
LGTM.
Reviewed-by: Sunil V L <sunilvl@oss.qualcomm.com>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ACPI: RISC-V: Fix false warning in cppc_read_ffh() for same-CPU reads
  2026-06-09 11:28 [PATCH] ACPI: RISC-V: Fix false warning in cppc_read_ffh() for same-CPU reads wang.yechao255
  2026-06-25 12:10 ` Jie Zhan
  2026-07-01  3:14 ` Sunil V L
@ 2026-12-01  1:18 ` Paul Walmsley
  2026-12-01 20:58   ` Nathan Chancellor
  2 siblings, 1 reply; 5+ messages in thread
From: Paul Walmsley @ 2026-12-01  1:18 UTC (permalink / raw)
  To: wang.yechao255
  Cc: linux-acpi, linux-riscv, linux-kernel, zhanjie9, aou, alex,
	rafael, viresh.kumar, zhenglifeng1, pierre.gondois, palmer, pjw,
	lenb

On Tue, 9 Jun 2026, wang.yechao255@zte.com.cn wrote:

> Commit 997c021abc6e ("cpufreq: CPPC: Update FIE arch_freq_scale in
> ticks for non-PCC regs") changed the CPPC Frequency Invariance Engine
> to read AMU counters directly from the scheduler tick for non-PCC
> register spaces (like FFH), instead of deferring to a kthread. This
> means cppc_read_ffh() is now called with IRQs disabled from the tick
> handler, triggering the warning.
> 
> This is the same fix as commit df6e4ab654dc ("arm64: topology: Fix
> false warning in counters_read_on_cpu() for same-CPU reads").
> 
> Fixes: 997c021abc6e ("cpufreq: CPPC: Update FIE arch_freq_scale in ticks for non-PCC regs")
> Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>

Thanks, queued for v7.4-rc.


- Paul

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ACPI: RISC-V: Fix false warning in cppc_read_ffh() for same-CPU reads
  2026-12-01  1:18 ` Paul Walmsley
@ 2026-12-01 20:58   ` Nathan Chancellor
  0 siblings, 0 replies; 5+ messages in thread
From: Nathan Chancellor @ 2026-12-01 20:58 UTC (permalink / raw)
  To: Paul Walmsley
  Cc: wang.yechao255, linux-acpi, linux-riscv, linux-kernel, zhanjie9,
	aou, alex, rafael, viresh.kumar, zhenglifeng1, pierre.gondois,
	palmer, lenb

On Mon, Nov 30, 2026 at 06:18:16PM -0700, Paul Walmsley wrote:
> On Tue, 9 Jun 2026, wang.yechao255@zte.com.cn wrote:
> 
> > Commit 997c021abc6e ("cpufreq: CPPC: Update FIE arch_freq_scale in
> > ticks for non-PCC regs") changed the CPPC Frequency Invariance Engine
> > to read AMU counters directly from the scheduler tick for non-PCC
> > register spaces (like FFH), instead of deferring to a kthread. This
> > means cppc_read_ffh() is now called with IRQs disabled from the tick
> > handler, triggering the warning.
> > 
> > This is the same fix as commit df6e4ab654dc ("arm64: topology: Fix
> > false warning in counters_read_on_cpu() for same-CPU reads").
> > 
> > Fixes: 997c021abc6e ("cpufreq: CPPC: Update FIE arch_freq_scale in ticks for non-PCC regs")
> > Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
> 
> Thanks, queued for v7.4-rc.

This patch breaks the -Werror clang build in -next with:

  drivers/acpi/riscv/cppc.c:112:8: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
    112 |                         if (WARN_ON_ONCE(cpu != smp_processor_id()))
        |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  include/asm-generic/bug.h:119:33: note: expanded from macro 'WARN_ON_ONCE'
    119 | #define WARN_ON_ONCE(condition) ({                                      \
        |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    120 |         int __ret_warn_on = !!(condition);                              \
        |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    121 |         if (unlikely(__ret_warn_on))                                    \
        |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    122 |                 __WARN_FLAGS(#condition,                                \
        |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    123 |                              BUGFLAG_ONCE |                             \
        |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    124 |                              BUGFLAG_TAINT(TAINT_WARN));                \
        |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    125 |         unlikely(__ret_warn_on);                                        \
        |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    126 | })
        | ~~
  drivers/acpi/riscv/cppc.c:120:7: note: uninitialized use occurs here
    120 |                 if (ret)
        |                     ^~~
  drivers/acpi/riscv/cppc.c:112:4: note: remove the 'if' if its condition is always true
    112 |                         if (WARN_ON_ONCE(cpu != smp_processor_id()))
        |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    113 |                                 return -EPERM;
  drivers/acpi/riscv/cppc.c:100:9: note: initialize the variable 'ret' to silence this warning
    100 |         int ret;
        |                ^
        |                 = 0
  1 error generated.

Seems legitimate?

-- 
Cheers,
Nathan

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-01 20:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-09 11:28 [PATCH] ACPI: RISC-V: Fix false warning in cppc_read_ffh() for same-CPU reads wang.yechao255
2026-06-25 12:10 ` Jie Zhan
2026-07-01  3:14 ` Sunil V L
2026-12-01  1:18 ` Paul Walmsley
2026-12-01 20:58   ` Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox