Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Documentation/ABI/testing/sysfs-driver-aurora-gpu-cooling
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
What: /sys/devices/platform/.../gpu_power_ceiling
Date: November 2026
Contact: Asahi Linux contributors <asahi@lists.linux.dev>
Description:
Read-only. Present when the GPU's device-tree node is a
cooling device (#cooling-cells). One key/value pair per line:

requested_state: thermal cooling state, 0..100.
requested_ceiling_mw: minimum of all requester ceilings.
applied_ceiling_mw: ceiling last written to the firmware.
provisional_floor_mw: lowest ceiling, 25 percent of the
initialized maximum (never zero).
achieved_ceiling_mw: always "unsupported"; the firmware does
not acknowledge the ceiling.

State N requests max(25, 100 - N) percent of the initialized
maximum power. The debugfs file asahi-<device>-power/ceiling
adds the read-back firmware words and each requester's ceiling.
10 changes: 10 additions & 0 deletions Documentation/devicetree/bindings/gpu/apple,agx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ properties:
$ref: /schemas/types.yaml#/definitions/phandle
description: PMP firmware provider owning the GPU power vote and telemetry

"#cooling-cells":
const: 2
description: |
The GPU as a thermal cooling device: an absolute power ceiling the GPU
firmware applies. Cooling state N, for N in 0..100, requests (100 - N)
percent of the GPU's initialized maximum power, bounded below at 25
percent. State 0 leaves the firmware's own policy unchanged. Where the
running firmware's power inputs are unknown to the driver, a GPU with
this property does not start.

operating-points-v2: true

apple,csafr-min-sram-microvolt:
Expand Down
63 changes: 63 additions & 0 deletions Documentation/gpu/asahi-gpu-thermal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
.. SPDX-License-Identifier: GPL-2.0-only OR MIT

=====================================
Apple GPU power ceiling and thermals
=====================================

The GPU firmware takes two absolute power inputs from the host: the maximum
GPU power in Region C and the power-management budget in the primary power
state. Both are written once at initialization. The driver turns them into
a thermal cooling device, so device-tree thermal zones can lower the GPU's
power the same way they lower CPU frequencies.

Device tree
===========

A GPU node with ``#cooling-cells = <2>`` is a cooling device. Cooling state
``N`` (0..100) requests ``100 - N`` percent of the initialized maximum power,
never less than 25 percent. State 0 republishes the initialized values, so a
GPU that no thermal zone references keeps the firmware's own policy. The
policy itself (sensors, trips, the states each trip asks for) belongs to the
board's thermal zones. The GPU is not a power actor; under the
``power_allocator`` governor its zones are ladders of ``active`` trips, which
the governor runs bang-bang, as it runs fans.

The firmware keeps its own die-temperature limiter, so the host ceiling is
an outer loop, not the overtemperature protection.

Firmware builds
===============

The driver writes the power inputs only where the running build's layout is
described (``Variant::live_power`` in ``g17/fw/variant.rs``): the A18 Pro
(26A428) and M4 Pro (25G83) builds. On any other build the GPU still starts
under the firmware's own die limiter, warns once, and does not register as a
cooling device, so its thermal zones get no GPU ceiling. The M5 firmware takes its host budget at a different
Region C offset, which its own governor (``g17/thermal.rs``) writes; moving
that governor onto this cooling device is separate work.

The requesters (thermal, firmware fast-die, system, manual) compose by
minimum: one cannot relax another's ceiling. Recovery republishes the
committed ceiling before queues reopen.

Diagnostics
===========

``/sys/class/thermal/cooling_device*/`` with type ``gpu-power`` shows the
requested state. The GPU device's read-only ``gpu_power_ceiling`` attribute
and ``/sys/kernel/debug/asahi-<device>-power/ceiling`` report the requested
and published ceilings and the read-back words. A published ceiling is what
the host wrote; the firmware does not acknowledge it, so measured GPU power
and clocks are the evidence that it took effect.

Tests
=====

``drivers/gpu/drm/asahi/.kunitconfig.cooling`` runs the mapping, composition,
failure and recovery cases under KUnit::

./tools/testing/kunit/kunit.py run --arch=arm64 \
--kunitconfig=drivers/gpu/drm/asahi/.kunitconfig.cooling

``tools/testing/selftests/drivers/apple/gpu-cooling.py`` runs the same cases
and the typed power-state layout checks on the build host.
1 change: 1 addition & 0 deletions Documentation/gpu/drivers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ GPU Driver Documentation
asahi-reclaim
asahi-usage-stats
asahi-m4-bringup
asahi-gpu-thermal
apple-dcp-m4
i915
imagination/index
Expand Down
90 changes: 89 additions & 1 deletion arch/arm64/boot/dts/apple/t8140-j700.dts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,84 @@
#include "t8140.dtsi"
#include <dt-bindings/thermal/thermal.h>

/*
* GPU die zones. The SMC publishes eight GPU die temperatures (channels
* 83-90 of smc_hwmon below); each gets a zone, so whichever is hottest
* sets the GPU's power ceiling (the deepest state any zone asks for wins).
*
* Under a sustained GPU load macOS lets the hottest GPU key reach about
* 107.7 C, then holds it at 104.5-106.3 C (mean 105.5 C) with the GPU
* drawing 4.3-4.7 W, down from 6.0 W. Without a host ceiling Linux sits
* at 107.6 C, where the firmware's own die limiter holds it. The ladder
* below steps the GPU's absolute power ceiling (state N = 100 - N percent
* of its initialized maximum power) from 102 C on, so the ceiling lands
* in the 4.3-4.7 W band near 104 C, and reaches the actuator's floor at
* 106 C. The zones are active-trip ladders: the power allocator runs
* them bang-bang, like a fan curve, since the GPU is not a power actor.
*
* The GPU keys read placeholders while the GPU is powered down; the SMC
* driver reports those as no data, and the zones skip those updates. No
* critical trip: the firmware's die limiter and the SMC keep their own
* overtemperature protection, and the CPU zones keep theirs.
*/
#define J700_GPU_ZONE(node, n, ch) \
node { \
polling-delay-passive = <500>; \
polling-delay = <500>; \
thermal-sensors = <&smc_hwmon ch>; \
\
trips { \
gpu##n##_cap0: trip-cap0 { \
temperature = <102000>; \
hysteresis = <1500>; \
type = "active"; \
}; \
gpu##n##_cap1: trip-cap1 { \
temperature = <103000>; \
hysteresis = <1500>; \
type = "active"; \
}; \
gpu##n##_cap2: trip-cap2 { \
temperature = <104000>; \
hysteresis = <1500>; \
type = "active"; \
}; \
gpu##n##_cap3: trip-cap3 { \
temperature = <105000>; \
hysteresis = <1500>; \
type = "active"; \
}; \
gpu##n##_cap4: trip-cap4 { \
temperature = <106000>; \
hysteresis = <1500>; \
type = "active"; \
}; \
}; \
\
cooling-maps { \
map0 { \
trip = <&gpu##n##_cap0>; \
cooling-device = <&gpu 40 40>; \
}; \
map1 { \
trip = <&gpu##n##_cap1>; \
cooling-device = <&gpu 48 48>; \
}; \
map2 { \
trip = <&gpu##n##_cap2>; \
cooling-device = <&gpu 55 55>; \
}; \
map3 { \
trip = <&gpu##n##_cap3>; \
cooling-device = <&gpu 62 62>; \
}; \
map4 { \
trip = <&gpu##n##_cap4>; \
cooling-device = <&gpu 75 75>; \
}; \
}; \
}

/ {
compatible = "apple,j700", "apple,t8140", "apple,arm-platform";
model = "Apple MacBook Neo";
Expand Down Expand Up @@ -87,7 +165,8 @@
};

/*
* The J700 is fanless: the CPUs are the only cooling devices. Every
* The J700 is fanless: the CPUs and the GPU are the only cooling
* devices. The GPU zones follow the CPU ones. Every CPU
* die sensor gets a zone that throttles both clusters, since they share
* one die and one heat spreader. The power allocator splits the budget
* by the energy models, with the E cluster weighted three to one: its
Expand Down Expand Up @@ -405,6 +484,15 @@
};
};
};

J700_GPU_ZONE(gpu0-thermal, gpu0, 83); /* Tg04 */
J700_GPU_ZONE(gpu1-thermal, gpu1, 84); /* Tg05 */
J700_GPU_ZONE(gpu2-thermal, gpu2, 85); /* Tg0C */
J700_GPU_ZONE(gpu3-thermal, gpu3, 86); /* Tg0D */
J700_GPU_ZONE(gpu4-thermal, gpu4, 87); /* Tg0K */
J700_GPU_ZONE(gpu5-thermal, gpu5, 88); /* Tg0L */
J700_GPU_ZONE(gpu6-thermal, gpu6, 89); /* Tg0d */
J700_GPU_ZONE(gpu7-thermal, gpu7, 90); /* Tg0e */
};

/*
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/boot/dts/apple/t8140.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,7 @@
operating-points-v2 = <&gpu_opp>;
apple,clpc = <&clpc>;
apple,pmp-report-entry = <&pmp_report_gfx>;
#cooling-cells = <2>;
status = "disabled";
};

Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ obj-$(CONFIG_DRM_PL111) += pl111/
obj-$(CONFIG_DRM_TVE200) += tve200/
obj-$(CONFIG_DRM_ADP) += adp/
obj-$(CONFIG_DRM_ASAHI) += asahi/
obj-$(CONFIG_DRM_ASAHI_COOLING_KUNIT_TEST) += asahi/cooling_test.o
obj-$(CONFIG_DRM_XEN) += xen/
obj-$(CONFIG_DRM_VBOXVIDEO) += vboxvideo/
obj-$(CONFIG_DRM_LIMA) += lima/
Expand Down
3 changes: 3 additions & 0 deletions drivers/gpu/drm/asahi/.kunitconfig.cooling
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_KUNIT=y
CONFIG_DRM=y
CONFIG_DRM_ASAHI_COOLING_KUNIT_TEST=y
12 changes: 12 additions & 0 deletions drivers/gpu/drm/asahi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ config DRM_ASAHI
depends on MMU
depends on IOMMU_SUPPORT
depends on PAGE_SIZE_16KB
select THERMAL
select THERMAL_OF if OF
select APPLE_PMP_REPORT
select RUST_DRM_SCHED
select RUST_DRM_GEM_SHMEM_HELPER
Expand Down Expand Up @@ -111,3 +113,13 @@ config DRM_ASAHI_G15
The native display driver must be built in, or both drivers must
be modules, so a modular display provider finishes initialization
before the GPU module can probe through its direct helper import.

config DRM_ASAHI_COOLING_KUNIT_TEST
tristate "Aurora GPU power-cap policy tests" if !KUNIT_ALL_TESTS
depends on KUNIT
default KUNIT_ALL_TESTS
help
Exercise absolute-power mapping, composition and failed publication
without a GPU or Rust toolchain. The same production mapping and
fake actuator cases also run on a host compiler.
These tests do not qualify firmware layouts or thermal response.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/asahi/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0

obj-$(CONFIG_DRM_ASAHI) += aurora.o
aurora-y := asahi_core.o fwid.o legacy_sched.o sysfs.o g17/sync_input.o g17/sync_output.o g17/sync_scope.o g17/trace.o g17/clpc.o g17/fans.o g17/sleep.o g17/pmpdash.o
aurora-y := asahi_core.o fwid.o legacy_sched.o sysfs.o cooling.o g17/sync_input.o g17/sync_output.o g17/sync_scope.o g17/trace.o g17/clpc.o g17/fans.o g17/sleep.o g17/pmpdash.o
CFLAGS_g17/trace.o := -I$(src)/g17

aurora-$(CONFIG_DRM_ASAHI_G15) += g15/glue.o
Expand Down
Loading
Loading