mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v6 0/2] cpufreq: acpi-cpufreq: fix P-state index mismatch between perf->states[] and freq_table[]
@ 2026-11-14 14:07 lirongqing
  2026-11-14 14:07 ` [PATCH v6 1/2] cpufreq: acpi-cpufreq: fix P-state index mismatch in get_cur_freq_on_cpu() lirongqing
  2026-11-14 14:07 ` [PATCH v6 2/2] cpufreq: acpi-cpufreq: report filtered-out P-states in extract_msr() lirongqing
  0 siblings, 2 replies; 3+ messages in thread
From: lirongqing @ 2026-11-14 14:07 UTC (permalink / raw)
  To: Rafael J . Wysocki, Viresh Kumar, linux-pm, linux-kernel
  Cc: zhongqiu.han, Li RongQing

From: Li RongQing <lirongqing@baidu.com>

policy->freq_table is built by filtering out _PSS entries that are not
lower in frequency than the previous one, and the original ACPI P-state
index of each remaining entry is kept in freq_table[].driver_data.  The
index spaces of perf->states[] and freq_table[] therefore differ, and
mixing them up leads to the frequency of one P-state being attributed to
another.

Patch 1/2 has no functional change from v5 and fixes the cached
frequency used by get_cur_freq_on_cpu() to detect a firmware frequency
change behind the OS's back.

Patch 2/2 is reworked.  In v5 it made extract_msr() return 0 for an
unmatched status and had get_cur_freq_on_cpu() set data->resume and
return the cached frequency instead.  As pointed out in the v5 review,
this cannot work: the returned value equals policy->cur, so
cpufreq_verify_current_freq() does not resynchronize policy->cur and
__cpufreq_driver_target() returns early before acpi_cpufreq_target()
can consume data->resume.  It also regressed the case where the OS is at
a lower P-state, which the old freq_table[0] fallback did get the core
to notice.

v6 instead lets extract_msr() look the status up in all of
perf->states[], so ->get() reports the real frequency of a filtered-out
P-state and the cpufreq core detects the mismatch itself.  The
freq_table[0] fallback is kept for a status that matches no _PSS entry,
and get_cur_freq_on_cpu() is left as in 1/2.

v5: <link to v5>

Changes since v5:
 - 1/2: no functional change; drop the changelog paragraph saying the
   extract_msr() fallback is addressed by the next patch.
 - 2/2: look the status up in perf->states[] instead of returning 0
   from extract_msr(); drop the get_cur_freq_on_cpu() change; new
   subject.
 - 2/2: changelog rewritten; drop the incorrect claim that the
   ACPI_ADR_SPACE_SYSTEM_IO path is covered, as ->get() is only
   registered for ACPI_ADR_SPACE_FIXED_HARDWARE.

Li RongQing (2):
  cpufreq: acpi-cpufreq: fix P-state index mismatch in
    get_cur_freq_on_cpu()
  cpufreq: acpi-cpufreq: report filtered-out P-states in extract_msr()

 drivers/cpufreq/acpi-cpufreq.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

-- 
2.9.4


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

end of thread, other threads:[~2026-11-14 14:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-14 14:07 [PATCH v6 0/2] cpufreq: acpi-cpufreq: fix P-state index mismatch between perf->states[] and freq_table[] lirongqing
2026-11-14 14:07 ` [PATCH v6 1/2] cpufreq: acpi-cpufreq: fix P-state index mismatch in get_cur_freq_on_cpu() lirongqing
2026-11-14 14:07 ` [PATCH v6 2/2] cpufreq: acpi-cpufreq: report filtered-out P-states in extract_msr() lirongqing

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®