Skip to content

RFC: PL1/PL2 through the MMIO copy on Surface devices without the processor thermal device #214

Backlog

Description

@larsschellhas

@qzed, I have a prototype module that I would like to turn into a PR. Before I do, I'd like your view on whether and how it should go into linux-surface.

Problem

Intel keeps the package power limits PL1/PL2 twice: in an MSR and in MMIO (MCHBAR + 0x59a0). The lower enabled copy applies. The Windows Surface power management writes the MMIO copy (evidence). The kernel offers it as intel-rapl-mmio only through the processor thermal device 00:04.0, which does not show up on the Surface devices tested so far.

On some of them the firmware leaves the MMIO copy enabled, so Linux is held by a limit it cannot reach:

Device MMIO PL1/PL2 MSR PL1/PL2 Package power at full load
Surface Pro 8 30 / 60 W 35 / 60 W about 30 W
Surface Pro 10 for Business 28 / 35 W 35 / 64 W 28 W

Prototype

surface_rapl_mmio registers a powercap zone intel-rapl-mmio (package PL1, PL2, PL1 time window) on top of intel_rapl_common:

  • opt-in per device by DMI SKU, and it only maps the MCHBAR if the address read from the host bridge is the expected one;
  • does nothing if 00:04.0 is present;
  • writes only the limit, enable, clamp and PL1 window bits, never the lock bits, nothing below 3 W;
  • puts the register back as it was at unload.

Tested on 7.3-based linux-surface kernels:

  • Surface Book 3 15" (Ice Lake): reads and writes, s2idle, warm and cold boot (the firmware copy is disabled there, so it is the test bed).
  • Surface Pro 10 (Meteor Lake, by its owner): writes, and two longer runs with a user-space controller.
  • Surface Pro 8 (Tiger Lake, by its owner): reads and one PL1 write with restore.

Still open, and I want to close these before a PR: PL2 and window writes on the Pro 8, and hibernation.

Edit: I listed two more points here that are checked now. The access width is no difference: the Surface CPU driver in Windows also writes this register with 64-bit read-modify-writes (checked in the builds for the three devices above). What I had written, that it mostly uses a 32-bit access for PL2, was wrong. For PL2 it addresses 0x59a4, while we and the kernel's int340x driver address 0x59a0; the bits changed are the same. thermald: its adaptive mode needs an INT3400 device with a data vault, and the public ACPI dumps of these three devices have none. thermald 2.5.6 then falls back to its default engine, which by its source leaves the MMIO zone alone unless a thermald configuration file matches the machine or it is started with --workaround-enabled (not the default).

The prototype was written with the help of an LLM; the patch will say so (Assisted-by).

Proposed form

  • Devices in the table get a writable zone directly, without a module parameter.
  • Autoload and device selection as in surface_gpe: an own DMI table with exact SKUs and a hand-written MODULE_ALIAS. I would not use the aggregator registry: it matches the ACPI ID, which also covers variants nobody has tested, it only creates SSAM clients, and this register has nothing to do with the EC.

Questions

  1. Would you take such a module into linux-surface?
  2. Do you agree with the surface_gpe pattern, or would you rather see the activation somewhere else?
  3. Where should it live: drivers/platform/surface/, or next to the other RAPL drivers?
  4. Are you fine with the zone being writable by default on listed devices?
  5. For mainline: would you ask linux-pm and the int340x maintainers early, or carry it in linux-surface for a while first?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions