Skip to content

Mobile APUs: allow deep P-state floor and faster step-down - #195

Closed
totemofwolf wants to merge 1 commit into
trulyspinach:masterfrom
totemofwolf:mobile-apu-pstate-floor
Closed

totemofwolf wants to merge 1 commit into
trulyspinach:masterfrom
totemofwolf:mobile-apu-pstate-floor

Conversation

@totemofwolf

Copy link
Copy Markdown

Problem

On mobile APUs the governor can effectively never leave P0/P1:

  1. PSTATE_LIMIT is 1, so set_PState() clamps requests to P1.
  2. pmRyzen_init_PState() rewrites P1 to 80% of P0 — on a Ryzen 7 5800H that is ~3.4 GHz.
  3. The step-down threshold is PSTATE_STEPDOWN_TIME + hpcpus * PSTATE_STEPDOWN_MP_GAIN windows. With all cores in P0 that is 16 + 40 = 56 windows (~8.4 s) of consecutive sub-12% per-core activity — never met under normal desktop background load, so cores never step down at all.

Net result on a Cezanne laptop (Ryzen 7 5800H): every core sits near base clock at desktop idle, ~24 W package power and 85–90 °C.

Fix

  • PSTATE_LIMIT 1 → 2: on Cezanne the firmware P2 state is the deep idle state (1.2 GHz).
  • PSTATE_STEPDOWN_TIME 16 → 4, PSTATE_STEPDOWN_MP_GAIN 5 → 0: cores can leave P0 after ~0.6 s of quiet.
  • The pmRyzen_PState_reset() normalize path now uses PSTATE_LIMIT instead of a hardcoded 1.

Result (Ryzen 7 5800H, Legion R7000P 2021, Ventura 13.7.8)

Desktop idle drops from ~3.4 GHz / 24 W / 90 °C to the firmware P2 state (1.2 GHz, ~9 W, and the machine is finally cool); stepping back up to P0 + boost on load remains instantaneous.

Note

Firmware P2 (and P1/P0) definitions are read from the PstateDef MSRs at init and are safe targets — these are the same states Windows/Linux request through CPPC/legacy P-state interfaces.

- PSTATE_LIMIT 1 -> 2: the governor could never request below P1, and
  pmRyzen_init_PState() rewrites P1 to 80% of P0 (3.4GHz on a 5800H),
  pinning every core near base clock at idle (~24W, ~90C).
- PSTATE_STEPDOWN_TIME 16 -> 4, PSTATE_STEPDOWN_MP_GAIN 5 -> 0: the
  step-down threshold of 16 + hpcpus*5 windows (8.4s with all cores in
  P0) is never met under normal desktop background load, so cores never
  left P0 at all.

With this, an idle 5800H reaches the firmware P2 state (1.2GHz, ~9W)
and boosts back to P0 instantly on load.
@trulyspinach

Copy link
Copy Markdown
Owner

I need to hear your reasoning and review of the code. Not from AIs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants