From eed1127967d0e6415dd70c8b9ef9815a3ac10b7c Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sun, 1 Nov 2026 16:02:52 +1100 Subject: [PATCH 01/14] arm64: dts: apple: expose J700 SoC and enclosure thermal readings Expose ten existing SMC temperature channels as reporting thermal zones, including SoC, charger and enclosure readings. The channels keep their existing order and the CPU zones retain their current policy. These zones have no trips or cooling maps. GPU cooling still needs a qualified firmware ceiling and board thermal policy. Check the compiled DTB by resolving zone phandles and channel indices to SMC keys, including the six CPU references. Add an arm64 KUnit config for the existing SMC parser, channel-preservation and fan-model tests. Assisted-by: LLM Signed-off-by: Ryan Murray Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> --- arch/arm64/boot/dts/apple/t8140-j700.dts | 69 ++++++++++ drivers/hwmon/.kunitconfig.macsmc | 11 ++ .../testing/selftests/drivers/apple/Makefile | 2 +- .../drivers/apple/j700-thermal-dt.py | 119 ++++++++++++++++++ 4 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 drivers/hwmon/.kunitconfig.macsmc create mode 100755 tools/testing/selftests/drivers/apple/j700-thermal-dt.py diff --git a/arch/arm64/boot/dts/apple/t8140-j700.dts b/arch/arm64/boot/dts/apple/t8140-j700.dts index 80dbb11d873ec..73f26ec5dcfe8 100644 --- a/arch/arm64/boot/dts/apple/t8140-j700.dts +++ b/arch/arm64/boot/dts/apple/t8140-j700.dts @@ -394,6 +394,75 @@ }; }; }; + + /* + * Reporting zones for the SoC, charger and enclosure sensors. These + * indices count temperature-* children of smc_hwmon, including the + * six CPU channels inherited from t8140.dtsi. Keep the sensor order. + * + * These zones have no trips: firmware die-temperature limits do not + * establish limits for these SMC readings. GPU cooling requires a + * qualified firmware ceiling and board-specific thermal policy. + */ + smc-tp0t-thermal { + polling-delay-passive = <1000>; + polling-delay = <1000>; + thermal-sensors = <&smc_hwmon 6>; + }; + + charger-thermal { + polling-delay-passive = <1000>; + polling-delay = <1000>; + thermal-sensors = <&smc_hwmon 11>; /* TCMz */ + }; + + chassis1-thermal { + polling-delay-passive = <1000>; + polling-delay = <1000>; + thermal-sensors = <&smc_hwmon 12>; /* Ts0A */ + }; + + chassis2-thermal { + polling-delay-passive = <1000>; + polling-delay = <1000>; + thermal-sensors = <&smc_hwmon 13>; /* Ts0I */ + }; + + chassis3-thermal { + polling-delay-passive = <1000>; + polling-delay = <1000>; + thermal-sensors = <&smc_hwmon 14>; /* Ts0M */ + }; + + smc-tp02-thermal { + polling-delay-passive = <1000>; + polling-delay = <1000>; + thermal-sensors = <&smc_hwmon 50>; + }; + + smc-tp06-thermal { + polling-delay-passive = <1000>; + polling-delay = <1000>; + thermal-sensors = <&smc_hwmon 52>; + }; + + smc-tp0e-thermal { + polling-delay-passive = <1000>; + polling-delay = <1000>; + thermal-sensors = <&smc_hwmon 56>; + }; + + smc-tpx1-thermal { + polling-delay-passive = <1000>; + polling-delay = <1000>; + thermal-sensors = <&smc_hwmon 63>; + }; + + smc-tpx3-thermal { + polling-delay-passive = <1000>; + polling-delay = <1000>; + thermal-sensors = <&smc_hwmon 65>; + }; }; /* diff --git a/drivers/hwmon/.kunitconfig.macsmc b/drivers/hwmon/.kunitconfig.macsmc new file mode 100644 index 0000000000000..dbc4f938d1715 --- /dev/null +++ b/drivers/hwmon/.kunitconfig.macsmc @@ -0,0 +1,11 @@ +CONFIG_KUNIT=y +CONFIG_ARCH_APPLE=y +CONFIG_PM=y +CONFIG_OF=y +CONFIG_APPLE_MAILBOX=y +CONFIG_APPLE_RTKIT=y +CONFIG_MFD_MACSMC=y +CONFIG_MFD_MACSMC_KUNIT_TEST=y +CONFIG_HWMON=y +CONFIG_SENSORS_MACSMC_HWMON=y +CONFIG_SENSORS_MACSMC_HWMON_KUNIT_TEST=y diff --git a/tools/testing/selftests/drivers/apple/Makefile b/tools/testing/selftests/drivers/apple/Makefile index a325eed4b3ba3..05156cf4830d4 100644 --- a/tools/testing/selftests/drivers/apple/Makefile +++ b/tools/testing/selftests/drivers/apple/Makefile @@ -10,7 +10,7 @@ TEST_PROGS := macsmc-j713.py atc-t8132-usb3.py pmgr-inherited.py dwc3-initial-role.py \ sn201202x-transport.py bcm4377-dma-window.py bcm4377-radio-sids.py \ bcm4377-state-wait.py bcm4377-rti-address.py aop-las.py \ - aop-motion.py + aop-motion.py j700-thermal-dt.py TEST_FILES := j813-peripherals.sh include ../../lib.mk diff --git a/tools/testing/selftests/drivers/apple/j700-thermal-dt.py b/tools/testing/selftests/drivers/apple/j700-thermal-dt.py new file mode 100755 index 0000000000000..dd8aebdf73588 --- /dev/null +++ b/tools/testing/selftests/drivers/apple/j700-thermal-dt.py @@ -0,0 +1,119 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-only OR MIT +"""Check sensor identities in a compiled J700 DTB without accessing hardware. + +The SMC hwmon binding numbers temperature children in their flattened-tree +order. Looking only at a board's source misses inherited and merged children. +Set APPLE_J700_DTB or pass --dtb after building apple/t8140-j700.dtb. +""" + +import argparse +import os +from pathlib import Path +import shutil +import subprocess +import sys + + +ZONES = { + "cpu-e0-thermal": "Te05", + "cpu-e1-thermal": "Te0S", + "cpu-p0-thermal": "Tp01", + "cpu-p1-thermal": "Tp05", + "cpu-p2-thermal": "Tp09", + "cpu-p3-thermal": "Tp0D", + "smc-tp0t-thermal": "Tp0t", + "charger-thermal": "TCMz", + "chassis1-thermal": "Ts0A", + "chassis2-thermal": "Ts0I", + "chassis3-thermal": "Ts0M", + "smc-tp02-thermal": "Tp02", + "smc-tp06-thermal": "Tp06", + "smc-tp0e-thermal": "Tp0E", + "smc-tpx1-thermal": "Tpx1", + "smc-tpx3-thermal": "Tpx3", +} + + +class Tree: + def __init__(self, path): + self.path = path + + def read(self, *args): + result = subprocess.run(["fdtget", *args[:2], str(self.path), *args[2:]], + check=True, capture_output=True, text=True) + return result.stdout.strip() + + def strings(self, node, prop): + return self.read("-t", "s", node, prop).split() + + def cells(self, node, prop): + return [int(value, 16) for value in + self.read("-t", "x", node, prop).split()] + + def children(self, node): + result = subprocess.run(["fdtget", "-l", str(self.path), node], + check=True, capture_output=True, text=True) + return result.stdout.split() + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--dtb", type=Path, default=os.environ.get("APPLE_J700_DTB")) + args = parser.parse_args() + print("TAP version 13") + if args.dtb is None or shutil.which("fdtget") is None: + print("1..0 # SKIP set APPLE_J700_DTB and install dtc/fdtget") + return 4 + + tree = Tree(args.dtb) + print(f"1..{len(ZONES) + 1}") + try: + require("apple,j700" in tree.strings("/", "compatible"), "not a J700 DTB") + # Find the SMC by its public node name rather than assuming its address. + providers = [f"/soc/{node}/hwmon" for node in tree.children("/soc") + if node.startswith("smc@")] + require(len(providers) == 1, "expected one SMC provider") + provider = providers[0] + require(tree.strings(provider, "compatible") == ["apple,smc-hwmon"], + "wrong hwmon provider") + require(tree.cells(provider, "#thermal-sensor-cells") == [1], + "wrong sensor-cell count") + phandle, = tree.cells(provider, "phandle") + channels = [node for node in tree.children(provider) + if node.startswith("temperature-")] + keys = [tree.strings(f"{provider}/{node}", "apple,key-id") + for node in channels] + require(all(key == [node.removeprefix("temperature-")] + for key, node in zip(keys, channels)), "sensor/key mismatch") + require(len({key[0] for key in keys}) == len(keys), "duplicate sensor keys") + except (ValueError, OSError, subprocess.CalledProcessError) as error: + print(f"not ok 1 - DTB setup: {str(error).splitlines()[0]}") + for number, zone in enumerate(ZONES, 2): + print(f"ok {number} - {zone} # SKIP DTB setup failed") + return 1 + + print("ok 1 - J700 indexed SMC temperature provider") + failed = False + for number, (zone, key) in enumerate(ZONES.items(), 2): + try: + reference = tree.cells(f"/thermal-zones/{zone}", "thermal-sensors") + require(len(reference) == 2, "expected one sensor with one argument") + owner, channel = reference + require(owner == phandle, "wrong sensor provider") + require(channel < len(channels), "sensor channel out of range") + require(keys[channel] == [key], f"channel {channel} is {keys[channel]}, expected {key}") + print(f"ok {number} - {zone} reads {key}") + except (ValueError, OSError, subprocess.CalledProcessError) as error: + print(f"not ok {number} - {zone}: {str(error).splitlines()[0]}") + failed = True + return int(failed) + + +if __name__ == "__main__": + sys.exit(main()) From c9fca630b03c1c10169c9ec8cadef3ec0079239f Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sun, 1 Nov 2026 16:03:08 +1100 Subject: [PATCH 02/14] drm/asahi: document GPU thermal integration and owner qualification Document the distinction between G17 firmware die-limiter configuration, SMC reporting and a live thermal cooling ceiling. State the shared G16S and G17P integration requirements and the remaining qualification work. Include offline sensor checks and a staged owner test plan covering actuator faults, transient response, sustained loads, frame times and matched macOS traces. The reporting zones do not establish GPU cooling. Assisted-by: LLM Signed-off-by: Ryan Murray Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> --- Documentation/gpu/asahi-gpu-thermal.rst | 123 ++++++++++++++++++++++++ Documentation/gpu/drivers.rst | 1 + 2 files changed, 124 insertions(+) create mode 100644 Documentation/gpu/asahi-gpu-thermal.rst diff --git a/Documentation/gpu/asahi-gpu-thermal.rst b/Documentation/gpu/asahi-gpu-thermal.rst new file mode 100644 index 0000000000000..88f3cb32b239d --- /dev/null +++ b/Documentation/gpu/asahi-gpu-thermal.rst @@ -0,0 +1,123 @@ +.. SPDX-License-Identifier: GPL-2.0-only OR MIT + +GPU thermal integration and qualification +========================================= + +J700 exposes additional SMC SoC, charger and enclosure readings through +reporting-only thermal zones. They have no trips or cooling maps and do not +throttle the GPU. The ``Tp*`` zone names identify keys, not verified physical +sensor locations. Do not infer a GPU junction temperature from their names. + +Source contracts +---------------- + +G17P/T8140 and G16S/T6040 share the ``g17`` backend. The ``g16`` backend is +the separate G16G/T8132 implementation; its PMP consumer and nine-state +ceiling must not be copied as a board policy for J700. + +The T8140 configuration selects 26A428. Its power configuration initializes +a die limiter with sensor mask ``0x82a``, a 110.00 C target and an 80.00 C +release point. T6040/25G83 instead initializes its power-state object with +101.00 C and 96.00 C. These describe the driver's firmware setup. They do +not establish macOS board policy, SMC sensor equivalence, or safe charger +and enclosure temperatures. + +The live effort input requests a performance floor. Reducing that request +does not establish a maximum performance state. Similarly, a maximum-power +value written while building firmware configuration does not establish a +live power-limit interface. A cooling device needs a qualified ceiling +interface, including units, update ordering and firmware ownership. + +Integration requirements +------------------------ + +Use a single cooling implementation for G17P and G16S, with a firmware +variant supplying any ABI differences. Derive the state range and conversion +from validated performance tables and loader/firmware data. Keep board +trips and cooling maps in DT. Do not add a module parameter or use direct +clock or voltage writes to implement a thermal limit. + +The cooling state is an upper bound, independent of the work-driven effort +request. State zero permits the full validated table; increasing cooling +must monotonically reduce the ceiling. Multiple zones must compose by the +most restrictive request, and any other budget must not relax that request. +Report requested and applied limits separately. A successful host write +alone is not evidence of firmware acceptance or achieved frequency. + +Thermal callbacks must not invert the GPU lock order. A bounded owner-side +service must enforce updates while already submitted work runs, including +a single long dispatch with no completions. Enforce the startup limit before +the first publication; cover direct submissions, render and compute, recovery, +idle wake and teardown. Firmware state must not be written after its owner +stops. Preserve a restrictive ceiling across provider faults, recovery and +missing policy until revalidated. Define which sensor errors can be detected: +repeated identical SMC values are not by themselves a freshness witness. + +SMC polling is an outer loop. Polling faster than the sensor refresh cannot +provide a fast-die backstop. Qualification must establish the independent +fast signal and actuator response before using SMC trips to protect rapid +load transients. Charger and enclosure policy requires its own evidence. + +Offline checks +-------------- + +Build ``apple/t8140-j700.dtb``, then run:: + + python3 tools/testing/selftests/drivers/apple/j700-thermal-dt.py \ + --dtb out/arch/arm64/boot/dts/apple/t8140-j700.dtb + +This resolves each compiled sensor reference to its key, including inherited +temperature children. It also checks the six existing CPU references. A +missing SMC key keeps its channel slot in the driver; it must never silently +move a later zone to another key. Exercise that driver behavior and the SMC +readers without an SMC using:: + + python3 tools/testing/kunit/kunit.py run --arch arm64 \ + --kunitconfig drivers/hwmon/.kunitconfig.macsmc 'macsmc*' + +Ceiling implementation tests must additionally cover every valid state and +invalid endpoint, composition of simultaneous requests, startup restriction, +provider failure and recovery, publication ordering and teardown races. Run +the same production policy in host tests and KUnit with a fake actuator that +can reject or delay updates. Tests must verify that failed application cannot +be reported as an applied limit. + +Owner qualification +------------------- + +First record the exact board, kernel, DTB, Mesa and both firmware versions. +Verify every zone's key identity, cooling binding and state range without a +GPU load. Missing sensors, missing bindings or an unconfirmed applied ceiling +must prevent progression to load tests. Retain the known-good boot entry and +one-shot boot fallback throughout qualification. + +On matching macOS and Linux configurations, record synchronized sensor, +power, requested/applied state, achieved frequency and frame-time traces. +Use the same workload, resolution, presentation mode, ambient conditions, +power source and comparable starting temperatures. Record sensor update +cadence, missing values and timestamp domains. Preserve raw traces for the +owner; publish only reviewed summaries without device identifiers. + +Before a Linux GPU experiment, obtain the required device approval and arm +a verified restrictive ceiling and independent temperature supervisor. Prove +the stop action and its latency before generating heat. Start with short, +bounded work at the lowest qualified ceiling. Stop before a non-CPU reading +reaches 100 C, with additional margin for refresh and stopping latency. The +owner's absolute abort rule also applies; it is not a normal control target. +If the available sampling cannot bound overshoot, do not extend the load. + +Once the actuator and trips have been independently qualified and integrated, +run vkmark cube for ten minutes, glmark2 terrain for ten minutes, and a fixed +game replay. Include warm starts, mixed CPU/GPU load, idle transitions and +both supported firmware variants. Plot temperature and limiting reason +against frame time; report maxima, time above each trip, cooling residency, +frame-time percentiles and sustained throughput. Require every relevant +non-CPU sensor to remain below 100 C and the derived board limits, with no +GPU fault or lost binding. Compare matched macOS traces without treating +unavailable telemetry as zero. These tests remain pending until the cooling +actuator and board policy exist. + +On any failure, stop the workload, retain the restrictive ceiling, preserve +traces and restore the known-good kernel/DTB through the boot fallback. Check +the restored identities and temperatures. A rollback is evidence of a failed +qualification, not a passing sustained-load result. diff --git a/Documentation/gpu/drivers.rst b/Documentation/gpu/drivers.rst index 38f99ddda7c83..d2a9ec8b75863 100644 --- a/Documentation/gpu/drivers.rst +++ b/Documentation/gpu/drivers.rst @@ -12,6 +12,7 @@ GPU Driver Documentation asahi-reclaim asahi-usage-stats asahi-m4-bringup + asahi-gpu-thermal apple-dcp-m4 i915 imagination/index From d762248227b54749a5be14d103262c9d38f11eee Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sun, 1 Nov 2026 17:17:31 +1100 Subject: [PATCH 03/14] dt-bindings: gpu: apple: describe firmware percent cooling ceilings Define the firmware percent interface and require a qualified ABI before a board requesting cooling may initialize its GPU. Assisted-by: LLM Signed-off-by: Ryan Murray Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> --- Documentation/devicetree/bindings/gpu/apple,agx.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/gpu/apple,agx.yaml b/Documentation/devicetree/bindings/gpu/apple,agx.yaml index 882756aa0067d..fcd11a60d8105 100644 --- a/Documentation/devicetree/bindings/gpu/apple,agx.yaml +++ b/Documentation/devicetree/bindings/gpu/apple,agx.yaml @@ -101,6 +101,14 @@ properties: $ref: /schemas/types.yaml#/definitions/phandle description: PMP firmware provider owning the GPU power vote and telemetry + "#cooling-cells": + const: 2 + description: | + GPU firmware percent ceiling. State N requests (100 - N) percent, + for N in 0..100. Firmware initialization fails if the live ceiling ABI + for the selected firmware is not established. A qualification backstop + may impose a stricter ceiling than requested by the thermal framework. + operating-points-v2: true apple,firmware-version: From 9b12783667119fba6384c572a63fbe093fb6cd5b Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sun, 1 Nov 2026 17:20:19 +1100 Subject: [PATCH 04/14] drm/asahi: prepare common firmware percent cooling with ABI admission Add a per-device three-mirror cooling owner, a retained 25 percent qualification ceiling, recovery rearming and callback teardown. Exercise the production cap mapping with host and KUnit fake-publication tests. The clean percent offsets still lack a qualified firmware-allocation base for either build. Keep both ABI capabilities absent and refuse GPU initialization on boards requiring cooling, before booting either processor. Do not issue speculative firmware writes or claim host publication is achieved power. Assisted-by: LLM Signed-off-by: Ryan Murray Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> --- .../testing/sysfs-driver-aurora-gpu-cooling | 22 +++ drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/asahi/.kunitconfig.cooling | 3 + drivers/gpu/drm/asahi/Kconfig | 12 ++ drivers/gpu/drm/asahi/Makefile | 2 +- drivers/gpu/drm/asahi/cooling.c | 148 +++++++++++++++++ drivers/gpu/drm/asahi/cooling.h | 13 ++ drivers/gpu/drm/asahi/cooling_policy.h | 67 ++++++++ drivers/gpu/drm/asahi/cooling_test.c | 152 ++++++++++++++++++ drivers/gpu/drm/asahi/g17/cooling.rs | 95 +++++++++++ drivers/gpu/drm/asahi/g17/fw/variant.rs | 7 + drivers/gpu/drm/asahi/g17/initdata.rs | 14 ++ drivers/gpu/drm/asahi/g17/mod.rs | 8 + drivers/gpu/drm/asahi/g17/runtime.rs | 2 + drivers/gpu/drm/asahi/g17/runtime/events.rs | 3 + 15 files changed, 548 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-driver-aurora-gpu-cooling create mode 100644 drivers/gpu/drm/asahi/.kunitconfig.cooling create mode 100644 drivers/gpu/drm/asahi/cooling.c create mode 100644 drivers/gpu/drm/asahi/cooling.h create mode 100644 drivers/gpu/drm/asahi/cooling_policy.h create mode 100644 drivers/gpu/drm/asahi/cooling_test.c create mode 100644 drivers/gpu/drm/asahi/g17/cooling.rs diff --git a/Documentation/ABI/testing/sysfs-driver-aurora-gpu-cooling b/Documentation/ABI/testing/sysfs-driver-aurora-gpu-cooling new file mode 100644 index 0000000000000..b4ca3748c8cd4 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-driver-aurora-gpu-cooling @@ -0,0 +1,22 @@ +What: /sys/devices/platform/.../gpu_power_ceiling +Date: November 2026 +Contact: Asahi Linux contributors +Description: + Read-only diagnostics for the common G16S/G17P firmware percent + ceiling. Present only after registration with a qualified firmware + layout. One key/value pair per line: + + requested_percent: 100 minus the thermal cooling state (0..100). + published_percent: the percent synchronously stored in all three + firmware mirrors, after composing the qualification backstop. + applied_percent: unsupported; host stores have no acknowledgement. + achieved_percent: unsupported; not inferred from a nominal OPP. + qualification_backstop_percent: maximum allowed host publication. + + All numeric values are interface percentages, not watts, frequency + or a proven achieved utilization. The qualification backstop cannot + be released through this attribute. Firmware-reported achieved + pstate, when available, is independently exposed in agx_stats and + does not acknowledge a percent ceiling. J700 initialization is + refused while its firmware allocation-relative layout is unknown; + this attribute is consequently absent on that board. diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index cd966b1b5b47e..101756c8f632e 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -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/ diff --git a/drivers/gpu/drm/asahi/.kunitconfig.cooling b/drivers/gpu/drm/asahi/.kunitconfig.cooling new file mode 100644 index 0000000000000..161a3a371082f --- /dev/null +++ b/drivers/gpu/drm/asahi/.kunitconfig.cooling @@ -0,0 +1,3 @@ +CONFIG_KUNIT=y +CONFIG_DRM=y +CONFIG_DRM_ASAHI_COOLING_KUNIT_TEST=y diff --git a/drivers/gpu/drm/asahi/Kconfig b/drivers/gpu/drm/asahi/Kconfig index 6c5c31de0528a..5fe24dad9c44a 100644 --- a/drivers/gpu/drm/asahi/Kconfig +++ b/drivers/gpu/drm/asahi/Kconfig @@ -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 @@ -89,3 +91,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 percent ceiling 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. diff --git a/drivers/gpu/drm/asahi/Makefile b/drivers/gpu/drm/asahi/Makefile index db13d06336b3c..5ed2d978a07b7 100644 --- a/drivers/gpu/drm/asahi/Makefile +++ b/drivers/gpu/drm/asahi/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_DRM_ASAHI) += aurora.o -aurora-y := asahi_core.o fwid.o sysfs.o g17/sync_input.o g17/sync_output.o g17/sync_scope.o g17/trace.o g17/clpc.o +aurora-y := asahi_core.o fwid.o sysfs.o cooling.o g17/sync_input.o g17/sync_output.o g17/sync_scope.o g17/trace.o g17/clpc.o CFLAGS_g17/trace.o := -I$(src)/g17 aurora-$(CONFIG_DRM_ASAHI_G15) += g15/glue.o diff --git a/drivers/gpu/drm/asahi/cooling.c b/drivers/gpu/drm/asahi/cooling.c new file mode 100644 index 0000000000000..47df25b87f0ad --- /dev/null +++ b/drivers/gpu/drm/asahi/cooling.c @@ -0,0 +1,148 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT + +#include +#include +#include +#include +#include +#include +#include + +#include "cooling.h" +#include "cooling_policy.h" + +struct asahi_gpu_cooling { + struct device *dev; + struct mutex lock; + struct asahi_gpu_cap cap; + u32 *mirrors[3]; + struct thermal_cooling_device *cdev; + struct device_attribute telemetry; +}; + +/* No mailbox or ACK exists. The caller validated all destinations before any + * write. The dedicated WC words are never modified by any other host path. + * One mutex covers all three stores, independently of the GPU device lock. + */ +static int asahi_gpu_publish_cap(void *context, unsigned int percent) +{ + struct asahi_gpu_cooling *cooling = context; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(cooling->mirrors); i++) + WRITE_ONCE(*cooling->mirrors[i], percent); + /* Complete all three WC stores before reporting host publication. */ + wmb(); + return 0; +} + +static int asahi_gpu_cooling_max(struct thermal_cooling_device *cdev, + unsigned long *state) +{ + *state = ASAHI_GPU_COOLING_MAX; + return 0; +} + +static int asahi_gpu_cooling_get(struct thermal_cooling_device *cdev, + unsigned long *state) +{ + struct asahi_gpu_cooling *cooling = cdev->devdata; + + guard(mutex)(&cooling->lock); + *state = cooling->cap.requested_state; + return 0; +} + +static int asahi_gpu_cooling_set(struct thermal_cooling_device *cdev, + unsigned long state) +{ + struct asahi_gpu_cooling *cooling = cdev->devdata; + + if (asahi_gpu_cap_percent(state) < 0) + return -EINVAL; + guard(mutex)(&cooling->lock); + return asahi_gpu_cap_update(&cooling->cap, state, 100, + asahi_gpu_publish_cap, cooling); +} + +static const struct thermal_cooling_device_ops asahi_gpu_cooling_ops = { + .get_max_state = asahi_gpu_cooling_max, + .get_cur_state = asahi_gpu_cooling_get, + .set_cur_state = asahi_gpu_cooling_set, +}; + +static ssize_t gpu_power_ceiling_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct asahi_gpu_cooling *cooling = + container_of(attr, struct asahi_gpu_cooling, telemetry); + + guard(mutex)(&cooling->lock); + return sysfs_emit(buf, "requested_percent %u\npublished_percent %u\n" + "applied_percent unsupported\nachieved_percent unsupported\n" + "qualification_backstop_percent %u\n", + 100 - cooling->cap.requested_state, + cooling->cap.published_percent, ASAHI_GPU_PREARM_PERCENT); +} + +struct asahi_gpu_cooling *asahi_gpu_cooling_register(struct device *dev, + u32 * const mirrors[3]) +{ + struct asahi_gpu_cooling *cooling; + int ret, i; + + if (!dev || !dev->of_node || !mirrors) + return ERR_PTR(-EINVAL); + for (i = 0; i < 3; i++) { + if (!mirrors[i] || !IS_ALIGNED((unsigned long)mirrors[i], sizeof(u32))) + return ERR_PTR(-EINVAL); + if (mirrors[i] == mirrors[(i + 1) % 3]) + return ERR_PTR(-EINVAL); + } + cooling = kzalloc_obj(*cooling); + if (!cooling) + return ERR_PTR(-ENOMEM); + cooling->dev = dev; + mutex_init(&cooling->lock); + memcpy(cooling->mirrors, mirrors, sizeof(cooling->mirrors)); + asahi_gpu_cap_init(&cooling->cap); + ret = asahi_gpu_cap_update(&cooling->cap, 0, 100, + asahi_gpu_publish_cap, cooling); + if (ret) + goto free; + cooling->cdev = thermal_of_cooling_device_register(dev->of_node, 0, + "aurora-gpu-power", cooling, &asahi_gpu_cooling_ops); + if (IS_ERR(cooling->cdev)) { + ret = PTR_ERR(cooling->cdev); + goto free; + } + sysfs_attr_init(&cooling->telemetry.attr); + cooling->telemetry.attr.name = "gpu_power_ceiling"; + cooling->telemetry.attr.mode = 0444; + cooling->telemetry.show = gpu_power_ceiling_show; + ret = device_create_file(dev, &cooling->telemetry); + if (ret) { + thermal_cooling_device_unregister(cooling->cdev); + goto free; + } + return cooling; +free: + kfree(cooling); + return ERR_PTR(ret); +} + +void asahi_gpu_cooling_rearm(struct asahi_gpu_cooling *cooling) +{ + guard(mutex)(&cooling->lock); + /* Keep a stronger governor request across recovery. */ + asahi_gpu_cap_update(&cooling->cap, cooling->cap.requested_state, 100, + asahi_gpu_publish_cap, cooling); +} + +void asahi_gpu_cooling_unregister(struct asahi_gpu_cooling *cooling) +{ + device_remove_file(cooling->dev, &cooling->telemetry); + /* Join all callbacks before Rust can release the firmware mapping. */ + thermal_cooling_device_unregister(cooling->cdev); + kfree(cooling); +} diff --git a/drivers/gpu/drm/asahi/cooling.h b/drivers/gpu/drm/asahi/cooling.h new file mode 100644 index 0000000000000..fc04731bedf5d --- /dev/null +++ b/drivers/gpu/drm/asahi/cooling.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ +#ifndef ASAHI_COOLING_H +#define ASAHI_COOLING_H +#include +struct device; +struct asahi_gpu_cooling; + +/* Caller owns three validated, host-writable WC words until unregister. */ +struct asahi_gpu_cooling *asahi_gpu_cooling_register(struct device *dev, + u32 * const mirrors[3]); +void asahi_gpu_cooling_unregister(struct asahi_gpu_cooling *cooling); +void asahi_gpu_cooling_rearm(struct asahi_gpu_cooling *cooling); +#endif diff --git a/drivers/gpu/drm/asahi/cooling_policy.h b/drivers/gpu/drm/asahi/cooling_policy.h new file mode 100644 index 0000000000000..20c93be006da2 --- /dev/null +++ b/drivers/gpu/drm/asahi/cooling_policy.h @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ +#ifndef ASAHI_COOLING_POLICY_H +#define ASAHI_COOLING_POLICY_H + +/* Firmware interface units, not an OPP index or a measured power in watts. */ +#define ASAHI_GPU_COOLING_MAX 100U +#define ASAHI_GPU_PREARM_PERCENT 25U +#define ASAHI_GPU_UNPUBLISHED 101U + +struct asahi_gpu_cap { + unsigned int requested_state; + unsigned int published_percent; +}; + +static inline void asahi_gpu_cap_init(struct asahi_gpu_cap *cap) +{ + cap->requested_state = 0; + cap->published_percent = ASAHI_GPU_UNPUBLISHED; +} + +/* State 0 permits 100%, state 100 requests 0%. Invalid states never wrap. */ +static inline int asahi_gpu_cap_percent(unsigned long state) +{ + if (state > ASAHI_GPU_COOLING_MAX) + return -1; + return ASAHI_GPU_COOLING_MAX - state; +} + +/* + * Keep the qualification backstop permanently armed. There is deliberately no + * userspace switch to lift it: an achieved pstate is not an acknowledgement of + * this percent ceiling, and source refresh cannot prove fast-die freshness. + */ +static inline unsigned int asahi_gpu_cap_effective(unsigned long state, + unsigned int budget_percent) +{ + int percent = asahi_gpu_cap_percent(state); + unsigned int limit = ASAHI_GPU_PREARM_PERCENT; + + if (percent < 0 || budget_percent > 100) + return 0; + if ((unsigned int)percent < limit) + limit = percent; + if (budget_percent < limit) + limit = budget_percent; + return limit; +} + +/* Commit host publication only on success; never call it applied/achieved. */ +static inline int asahi_gpu_cap_update(struct asahi_gpu_cap *cap, + unsigned long state, unsigned int budget_percent, + int (*publish)(void *context, unsigned int percent), void *context) +{ + unsigned int percent; + int ret; + + if (asahi_gpu_cap_percent(state) < 0 || budget_percent > 100) + return -1; + percent = asahi_gpu_cap_effective(state, budget_percent); + ret = publish(context, percent); + if (ret) + return ret; + cap->requested_state = state; + cap->published_percent = percent; + return 0; +} +#endif diff --git a/drivers/gpu/drm/asahi/cooling_test.c b/drivers/gpu/drm/asahi/cooling_test.c new file mode 100644 index 0000000000000..010b521755d97 --- /dev/null +++ b/drivers/gpu/drm/asahi/cooling_test.c @@ -0,0 +1,152 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT + +/* Build this same suite with -DASAHI_HOST_TEST or through KUnit. */ +#ifdef ASAHI_HOST_TEST +#include +#include +#include +struct kunit { int unused; }; +#define KUNIT_EXPECT_EQ(test, a, b) do { (void)(test); assert((a) == (b)); } while (0) +#define KUNIT_EXPECT_LT(test, a, b) do { (void)(test); assert((a) < (b)); } while (0) +#else +#include +#include +#include +#endif +#include "cooling_policy.h" + +struct fake_actuator { + unsigned int words[3]; + unsigned int calls; + int error; +}; + +static int fake_publish(void *context, unsigned int percent) +{ + struct fake_actuator *fake = context; + unsigned int i; + + fake->calls++; + if (fake->error) + return fake->error; + for (i = 0; i < 3; i++) + fake->words[i] = percent; + return 0; +} + +static void cap_mapping(struct kunit *test) +{ + unsigned long state; + + for (state = 0; state <= 100; state++) + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_percent(state), (int)(100 - state)); + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_percent(25), 75); + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_percent(50), 50); + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_percent(75), 25); + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_percent(99), 1); + KUNIT_EXPECT_LT(test, asahi_gpu_cap_percent(101), 0); + KUNIT_EXPECT_LT(test, asahi_gpu_cap_percent(ULONG_MAX), 0); +} + +static void cap_composition(struct kunit *test) +{ + unsigned int a, b; + + for (a = 0; a <= 100; a++) { + for (b = 0; b <= 100; b++) { + unsigned int expected = 100 - a; + + if (b < expected) + expected = b; + if (expected > 25) + expected = 25; + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_effective(a, b), expected); + } + } + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_effective(ULONG_MAX, 100), 0U); + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_effective(0, 101), 0U); +} + +static void cap_startup_and_mirrors(struct kunit *test) +{ + struct asahi_gpu_cap cap; + struct fake_actuator fake = {}; + unsigned int i; + + asahi_gpu_cap_init(&cap); + KUNIT_EXPECT_EQ(test, cap.published_percent, ASAHI_GPU_UNPUBLISHED); + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, 0, 100, fake_publish, &fake), 0); + KUNIT_EXPECT_EQ(test, cap.requested_state, 0U); + KUNIT_EXPECT_EQ(test, cap.published_percent, 25U); + for (i = 0; i < 3; i++) + KUNIT_EXPECT_EQ(test, fake.words[i], 25U); +} + +static void cap_failure_and_invalid(struct kunit *test) +{ + struct asahi_gpu_cap cap; + struct fake_actuator fake = {}; + unsigned int calls; + + asahi_gpu_cap_init(&cap); + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, 99, 100, fake_publish, &fake), 0); + fake.error = -5; + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, 0, 100, fake_publish, &fake), -5); + KUNIT_EXPECT_EQ(test, cap.requested_state, 99U); + KUNIT_EXPECT_EQ(test, cap.published_percent, 1U); + KUNIT_EXPECT_EQ(test, fake.words[0], 1U); + calls = fake.calls; + KUNIT_EXPECT_LT(test, asahi_gpu_cap_update(&cap, ULONG_MAX, 100, fake_publish, &fake), 0); + KUNIT_EXPECT_LT(test, asahi_gpu_cap_update(&cap, 0, 101, fake_publish, &fake), 0); + KUNIT_EXPECT_EQ(test, fake.calls, calls); + KUNIT_EXPECT_EQ(test, cap.published_percent, 1U); +} + +static void cap_recovery(struct kunit *test) +{ + struct asahi_gpu_cap cap; + struct fake_actuator fake = {}; + unsigned int i; + + asahi_gpu_cap_init(&cap); + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, 99, 100, fake_publish, &fake), 0); + for (i = 0; i < 3; i++) + fake.words[i] = 100; /* Firmware reset: rearm before reopening. */ + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, cap.requested_state, 100, + fake_publish, &fake), 0); + for (i = 0; i < 3; i++) + KUNIT_EXPECT_EQ(test, fake.words[i], 1U); + /* Removing a thermal demand still cannot lift qualification. */ + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, 0, 100, fake_publish, &fake), 0); + KUNIT_EXPECT_EQ(test, cap.published_percent, 25U); +} + +#ifdef ASAHI_HOST_TEST +int main(void) +{ + struct kunit test = {}; + + cap_mapping(&test); + cap_composition(&test); + cap_startup_and_mirrors(&test); + cap_failure_and_invalid(&test); + cap_recovery(&test); + puts("PASS: cap mapping, composition, startup, mirror transaction, failure, recovery"); + return 0; +} +#else +static struct kunit_case asahi_gpu_cooling_cases[] = { + KUNIT_CASE(cap_mapping), + KUNIT_CASE(cap_composition), + KUNIT_CASE(cap_startup_and_mirrors), + KUNIT_CASE(cap_failure_and_invalid), + KUNIT_CASE(cap_recovery), + {} +}; +static struct kunit_suite asahi_gpu_cooling_suite = { + .name = "asahi-gpu-cooling", + .test_cases = asahi_gpu_cooling_cases, +}; +kunit_test_suite(asahi_gpu_cooling_suite); +MODULE_LICENSE("Dual MIT/GPL"); +#endif diff --git a/drivers/gpu/drm/asahi/g17/cooling.rs b/drivers/gpu/drm/asahi/g17/cooling.rs new file mode 100644 index 0000000000000..6f203ff74376b --- /dev/null +++ b/drivers/gpu/drm/asahi/g17/cooling.rs @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT + +//! Common G16S/G17P percent-ceiling owner. No PMP vote or effort-floor write. + +use super::{fw::variant::Variant, initdata::InitData}; +use core::{ffi::c_void, ptr::NonNull}; +use kernel::{c_str, device, prelude::*, sync::aref::ARef}; + +extern "C" { + fn asahi_gpu_cooling_register(dev: *mut c_void, mirrors: *const *mut u32) -> *mut c_void; + fn asahi_gpu_cooling_unregister(cooling: *mut c_void); + fn asahi_gpu_cooling_rearm(cooling: *mut c_void); +} + +/// A fully resolved layout in the WC hardware-data bundle. Offsets include +/// the allocation-relative base, not an offset into a host driver object. +/// Only firmware ABI tables may supply these; DT never supplies addresses. +#[derive(Clone, Copy)] +pub(crate) struct Layout { + pub(crate) mirrors: [usize; 3], +} + +fn required(dev: &device::Device) -> Result { + let Some(node) = dev.of_node() else { + return Ok(false); + }; + match node.get_property::(c_str!("#cooling-cells")) { + Ok(2) => Ok(true), + Ok(_) => Err(EINVAL), + Err(ENOENT) => Ok(false), + Err(error) => Err(error), + } +} + +/// Check before starting either processor. A board requiring cooling must +/// never silently fall back to unrestricted submission with a missing ABI. +pub(super) fn admit(dev: &device::Device, variant: &Variant) -> Result { + if required(dev)? && variant.power_ceiling.is_none() { + dev_err!( + dev, + "GPU cooling ABI base unresolved; refusing GPU initialization\n" + ); + return Err(EOPNOTSUPP); + } + Ok(()) +} + +/// Dropped (and callbacks drained) before the firmware allocations. No C +/// callback takes the GPU mutex; thermal changes reach even a long dispatch. +pub(super) struct Cooling { + inner: NonNull, + _dev: ARef, +} + +// SAFETY: C serializes all shared access with its per-device mutex; Drop has +// unique ownership and drains thermal and sysfs callbacks. +unsafe impl Send for Cooling {} +// SAFETY: As for Send. Rearming uses the same C mutex as the callbacks. +unsafe impl Sync for Cooling {} + +impl Cooling { + pub(super) fn attach( + dev: &device::Device, + variant: &Variant, + init: &InitData, + ) -> Result> { + if !required(dev)? { + return Ok(None); + } + let layout = variant.power_ceiling.as_ref().ok_or(EOPNOTSUPP)?; + let mirrors = init.cooling_mirrors(layout)?; + // SAFETY: The owner keeps all validated WC words mapped until after + // Drop drains the C callbacks. Registration publishes the 25% backstop + // before INIT, port attachment or any work publication. + let inner = kernel::error::from_err_ptr(unsafe { + asahi_gpu_cooling_register(dev.as_raw().cast(), mirrors.as_ptr()) + })?; + Ok(Some(Self { + inner: NonNull::new(inner).ok_or(ENOMEM)?, + _dev: dev.into(), + })) + } + + pub(super) fn rearm(&self) { + // SAFETY: The C allocation and all three mappings are still owned. + unsafe { asahi_gpu_cooling_rearm(self.inner.as_ptr()) }; + } +} + +impl Drop for Cooling { + fn drop(&mut self) { + // SAFETY: Unique owner; drains callbacks before mappings are freed. + unsafe { asahi_gpu_cooling_unregister(self.inner.as_ptr()) }; + } +} diff --git a/drivers/gpu/drm/asahi/g17/fw/variant.rs b/drivers/gpu/drm/asahi/g17/fw/variant.rs index c5287e66a641d..61e76d1f6b89b 100644 --- a/drivers/gpu/drm/asahi/g17/fw/variant.rs +++ b/drivers/gpu/drm/asahi/g17/fw/variant.rs @@ -46,6 +46,9 @@ pub(crate) enum QueueRegistration { /// The layouts and rules of one G17 firmware build. #[derive(Copy, Clone)] pub(crate) struct Variant { + /// Resolved, allocation-relative, live percent-ceiling mirrors. + /// The clean setGPUMaxPower offsets alone do not identify an allocation. + pub(crate) power_ceiling: Option, /// The initialization graph. pub(crate) graph: InitGraph, /// How the firmware acknowledges its initialization. @@ -102,6 +105,8 @@ pub(crate) enum Firmware { /// The A18 Pro firmware (26A428). pub(crate) const V26A428: Variant = Variant { + // 0xf150/0xf2d0/0xf39c have no qualified allocation base yet. + power_ceiling: None, graph: InitGraph::G17P, init_ack: InitAck::Message, power_on_done: true, @@ -125,6 +130,8 @@ pub(crate) const V26A428: Variant = Variant { /// The M4 Pro firmware (25G83, `mBoot-18000.161.10`). pub(crate) const V25G83: Variant = Variant { + // No independently established 25G83 mirror layout. + power_ceiling: None, graph: InitGraph::V25G83, init_ack: InitAck::Status, // Never sent on the M4 Pro: the firmware has retired its opening record when it accepts diff --git a/drivers/gpu/drm/asahi/g17/initdata.rs b/drivers/gpu/drm/asahi/g17/initdata.rs index 56e7335a23bd2..2377bc4c72c38 100644 --- a/drivers/gpu/drm/asahi/g17/initdata.rs +++ b/drivers/gpu/drm/asahi/g17/initdata.rs @@ -1357,6 +1357,20 @@ impl InitData { Ok(()) } + /// Validate all three WC destinations before passing any pointer to C. + /// No partial transaction is possible on an invalid table entry. + pub(super) fn cooling_mirrors(&self, layout: &super::cooling::Layout) -> Result<[*mut u32; 3]> { + let bundle = self.object(self.bundle)?; + let mut mirrors = [core::ptr::null_mut(); 3]; + for (index, &offset) in layout.mirrors.iter().enumerate() { + if offset % 4 != 0 || layout.mirrors[..index].contains(&offset) { + return Err(EINVAL); + } + mirrors[index] = bundle.pointer(offset, 4)?.cast(); + } + Ok(mirrors) + } + pub(super) fn effort(&self) -> Result { Ok(self .object(self.region_c)? diff --git a/drivers/gpu/drm/asahi/g17/mod.rs b/drivers/gpu/drm/asahi/g17/mod.rs index ffb0c20d0267f..ba3174b713764 100644 --- a/drivers/gpu/drm/asahi/g17/mod.rs +++ b/drivers/gpu/drm/asahi/g17/mod.rs @@ -28,6 +28,7 @@ mod channel; mod command; pub(crate) use command::Attachments; mod completion; +mod cooling; pub(crate) mod context; mod data_segment; mod dependency; @@ -652,6 +653,8 @@ struct Firmware { /// Render kick ring storage, kept and reused for the life of the device. render_rings: Arc, render_ids: Arc, + // Drain independent thermal callbacks before dropping firmware storage. + cooling: Option, init: initdata::InitData, _render_global: mmu::Vm, _pm_metrics: Arc, @@ -660,6 +663,7 @@ struct Firmware { impl Drop for Firmware { fn drop(&mut self) { + drop(self.cooling.take()); if let Some(secondary) = self.secondary.as_mut() { secondary.stop(); } @@ -1174,6 +1178,7 @@ impl Gpu { None }; let variant = Self::firmware_variant(dev, &cfg.firmware)?; + cooling::admit(dev.as_ref().as_ref(), variant)?; let id = regs.get_g17_id()?; if let Some(calibration) = calibration { calibration.check_cores(&id.core_masks)?; @@ -1482,6 +1487,7 @@ impl Gpu { pool: object::Pool::new()?, render_rings: kick::RenderRings::new()?, render_ids: Arc::new(freelist::RenderIds::new(), GFP_KERNEL)?, + cooling: None, init: initdata::InitData::new(), _render_global: render_global, _pm_metrics: Arc::new(pm_metrics, GFP_KERNEL)?, @@ -1513,6 +1519,8 @@ impl Gpu { if let Some(root_entries) = root_entries { session.uat.confirm_firmware_root_entries(root_entries)?; } + session.cooling = + cooling::Cooling::attach(dev.as_ref().as_ref(), shared.variant, &session.init)?; let mailbox: *const Mailbox = &*session.primary.rtkit; session.port.attach( session.init.port_views(mailbox)?, diff --git a/drivers/gpu/drm/asahi/g17/runtime.rs b/drivers/gpu/drm/asahi/g17/runtime.rs index af76e8b62f040..56f49db088fd4 100644 --- a/drivers/gpu/drm/asahi/g17/runtime.rs +++ b/drivers/gpu/drm/asahi/g17/runtime.rs @@ -2250,6 +2250,7 @@ impl super::Shared { { let mut state = self.state.lock(); if let Some(firmware) = state.as_deref_mut() { + drop(firmware.cooling.take()); if let Some(secondary) = firmware.secondary.as_mut() { secondary.stop(); } @@ -2278,6 +2279,7 @@ impl super::Shared { let firmware = { let mut state = self.state.lock(); if let Some(firmware) = (*state).as_deref_mut() { + drop(firmware.cooling.take()); if let Some(secondary) = firmware.secondary.as_mut() { secondary.stop(); } diff --git a/drivers/gpu/drm/asahi/g17/runtime/events.rs b/drivers/gpu/drm/asahi/g17/runtime/events.rs index d6d811b410e89..4dce1ab41c5d1 100644 --- a/drivers/gpu/drm/asahi/g17/runtime/events.rs +++ b/drivers/gpu/drm/asahi/g17/runtime/events.rs @@ -419,6 +419,9 @@ impl crate::g17::Shared { return Err(EIO); } if recover { + if let Some(cooling) = firmware.cooling.as_ref() { + cooling.rearm(); + } firmware.service_runtime_recovery(deferred)?; if !firmware.recovery.pending() { if !self.preparations.reopen() { From 90da043a07e0b20e63f1aae8b4ae85479218821d Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sun, 1 Nov 2026 17:22:06 +1100 Subject: [PATCH 05/14] arm64: dts: apple: add provisional J700 GPU outer protection Bind all correlated SMC, charger and chassis zones to exact percent requests with 100 ms polling and independent critical shutdown. Use the existing power_allocator active-trip path for this non-power-actor device and lower the firmware fast-die target to 95 C without changing its release or gains. J700 now requires qualified GPU cooling and therefore intentionally refuses GPU initialization while the ABI tables are unresolved. Use a stricter zero final request pending a validated nonzero endpoint; do not claim zero is a proven stop action. Extend compiled-DTB checks and document the incomplete status, short-burst owner qualification and rollback. Assisted-by: LLM Signed-off-by: Ryan Murray Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> --- Documentation/gpu/asahi-gpu-thermal.rst | 273 ++++---- arch/arm64/boot/dts/apple/t8140-j700.dts | 632 +++++++++++++++++- drivers/gpu/drm/asahi/g17/fw/initdata.rs | 3 +- .../testing/selftests/drivers/apple/Makefile | 2 +- .../selftests/drivers/apple/gpu-cooling.py | 15 + .../drivers/apple/j700-thermal-dt.py | 41 +- 6 files changed, 827 insertions(+), 139 deletions(-) create mode 100755 tools/testing/selftests/drivers/apple/gpu-cooling.py diff --git a/Documentation/gpu/asahi-gpu-thermal.rst b/Documentation/gpu/asahi-gpu-thermal.rst index 88f3cb32b239d..73a9bac053b88 100644 --- a/Documentation/gpu/asahi-gpu-thermal.rst +++ b/Documentation/gpu/asahi-gpu-thermal.rst @@ -3,121 +3,170 @@ GPU thermal integration and qualification ========================================= -J700 exposes additional SMC SoC, charger and enclosure readings through -reporting-only thermal zones. They have no trips or cooling maps and do not -throttle the GPU. The ``Tp*`` zone names identify keys, not verified physical -sensor locations. Do not infer a GPU junction temperature from their names. - -Source contracts ----------------- - -G17P/T8140 and G16S/T6040 share the ``g17`` backend. The ``g16`` backend is -the separate G16G/T8132 implementation; its PMP consumer and nine-state -ceiling must not be copied as a board policy for J700. - -The T8140 configuration selects 26A428. Its power configuration initializes -a die limiter with sensor mask ``0x82a``, a 110.00 C target and an 80.00 C -release point. T6040/25G83 instead initializes its power-state object with -101.00 C and 96.00 C. These describe the driver's firmware setup. They do -not establish macOS board policy, SMC sensor equivalence, or safe charger -and enclosure temperatures. - -The live effort input requests a performance floor. Reducing that request -does not establish a maximum performance state. Similarly, a maximum-power -value written while building firmware configuration does not establish a -live power-limit interface. A cooling device needs a qualified ceiling -interface, including units, update ordering and firmware ownership. - -Integration requirements ------------------------- - -Use a single cooling implementation for G17P and G16S, with a firmware -variant supplying any ABI differences. Derive the state range and conversion -from validated performance tables and loader/firmware data. Keep board -trips and cooling maps in DT. Do not add a module parameter or use direct -clock or voltage writes to implement a thermal limit. - -The cooling state is an upper bound, independent of the work-driven effort -request. State zero permits the full validated table; increasing cooling -must monotonically reduce the ceiling. Multiple zones must compose by the -most restrictive request, and any other budget must not relax that request. -Report requested and applied limits separately. A successful host write -alone is not evidence of firmware acceptance or achieved frequency. - -Thermal callbacks must not invert the GPU lock order. A bounded owner-side -service must enforce updates while already submitted work runs, including -a single long dispatch with no completions. Enforce the startup limit before -the first publication; cover direct submissions, render and compute, recovery, -idle wake and teardown. Firmware state must not be written after its owner -stops. Preserve a restrictive ceiling across provider faults, recovery and -missing policy until revalidated. Define which sensor errors can be detected: -repeated identical SMC values are not by themselves a freshness witness. - -SMC polling is an outer loop. Polling faster than the sensor refresh cannot -provide a fast-die backstop. Qualification must establish the independent -fast signal and actuator response before using SMC trips to protect rapid -load transients. Charger and enclosure policy requires its own evidence. - -Offline checks --------------- - -Build ``apple/t8140-j700.dtb``, then run:: +Status +------ + +This branch is an incomplete cooling integration, with a deliberate safety +interlock. J700 requests GPU cooling in DT. Both firmware ABI variants still +lack a qualified allocation-relative ceiling layout, so J700 GPU probe fails +with ``EOPNOTSUPP`` before either GPU processor boots. This is expected and +must not be presented as successful hardware throttling. Existing G16S DTs +without cooling bindings retain their existing behavior. + +J700's SMC zones have independent critical shutdown trips. They register +through hwmon/thermal even when the GPU driver is absent or probe fails. +The firmware backstop target is provisionally lowered to 95 C with its +80 C release, sensor mask and gains preserved. It cannot take effect while +GPU probe is refused. Polling SMC at 100 ms does not accelerate its source +refresh or establish a fast transient safety guarantee. + +Source contract and unresolved ABI +---------------------------------- + +G17P/T8140 and G16S/T6040 use the same ``g17`` backend. G16G/T8132 and its +PMP cooling consumer are a separate backend. + +The clean facts from AGXG17G 353.14, macOS 26.6.2 build 25G83, +``AGXArmFirmware::setGPUMaxPower``, describe three synchronous u32 writes, +clamped to 0..100 percent, at offsets ``0xf150``, ``0xf2d0`` and ``0xf39c`` +from a power-control object. No mailbox, sequence or acknowledgement is +specified. This ceiling is separate from the effort floor, PMP and CLPC. + +Those offsets alone are insufficient to choose a Linux allocation. They +exceed both existing power configuration structures: 26A428 is ``0x2dc0`` +bytes, and 25G83 is ``0x6510`` bytes. The shared bundle also contains work +rings and control data; fitting in that larger allocation is not proof of +field ownership. The clean facts do not resolve the pointer chain from +that power-control object to the bundle, status block, firmware data or +another allocation. No G16S-specific ceiling layout or lowest validated +nonzero percent endpoint is established. + +``fw::Variant::power_ceiling`` therefore remains ``None`` for both builds. +Do not populate it by adding those offsets to an arbitrary mapped base. +A follow-up must supply a facts-only pointer/ownership contract and exact +per-build layout, validate the mapping and memory attributes, and then +populate the ABI tables. DT never supplies addresses or firmware offsets. + +Common cooling owner +-------------------- + +The common implementation accepts three checked, distinct, aligned WC +words from an admitted firmware ABI table. It validates every destination +before writing any of them. A per-device mutex serializes all three stores +and a write barrier; callbacks do not acquire the GPU mutex or wait for a +completion. Registration publishes a 25 percent backstop before INIT, +port attachment and work publication. Recovery republishes the strictest +retained cap before reopening queues. Stop and teardown unregister and drain +thermal/sysfs callbacks before stopping the processors or releasing mappings. + +Cooling state N requests ``100 - N`` percent for N in 0..100. It is an +interface percentage, not an OPP selector or measured watts. The thermal +framework composes multiple zones by maximum state. The effective host +publication also cannot exceed the 25 percent qualification backstop. +There is no userspace knob to release it. Failed publication does not commit +a new request or published value. Matching host words are never called +applied or achieved; the diagnostic attribute labels both unsupported. +A firmware-reported pstate alone cannot acknowledge this percent ceiling. + +Provisional J700 outer policy +---------------------------- + +These thresholds are a conservative Linux bring-up proposal, not recovered +Apple board limits or safety ratings. Independent zones make the most +restrictive correlated sensor win; they do not imply that SMC keys are +GPU-local MTR sensors. + +=================== ===================== ============= ======== +Zones Cap temperatures (C) Hot (C) Critical +=================== ===================== ============= ======== +Tp*/Tpx* 85, 88, 92, 95 92 98 C +Charger (TCMz) 80, 83, 88, 92 88 95 C +Chassis (Ts0A/I/M) 70, 75, 80, 85 80 88 C +=================== ===================== ============= ======== + +The four cap requests are 75, 50, 25 and 0 percent, with 5 C hysteresis. +The final zero request is deliberately stricter than the proposed lowest +validated nonzero endpoint, which remains unknown. Zero has no demonstrated +hardware stop semantics; critical shutdown must never depend on that request. +Do not replace zero with an invented minimum pstate or a percentage inferred +from an OPP's power. J700 GPU initialization remains refused independently. + +DT uses ``active`` trip types for this non-power-actor ladder, with equal +lower/upper cooling states. The tree's power_allocator governor explicitly +services such active instances, and step_wise also honors these exact +bounds. Passive trips on a device without power-actor callbacks would not +implement the requested cap under power_allocator. Hot trips carry policy +information; independent ``critical-action = "shutdown"`` provides the +shutdown action without any GPU callback. + +Offline verification +-------------------- + +Run the same production mapping and fake-publication suite on the host:: + + python3 tools/testing/selftests/drivers/apple/gpu-cooling.py + +Run it in arm64 QEMU without a GPU or Rust toolchain:: + + python3 tools/testing/kunit/kunit.py run --arch arm64 --jobs 8 \ + --kunitconfig drivers/gpu/drm/asahi/.kunitconfig.cooling \ + --make_options LLVM=1 'asahi-gpu-cooling*' + +The suite covers all 101 states, invalid endpoints, all pairs of demand and +budget, startup restriction, identical mirror transactions, rejected +publication, and restoration after reset. It does not qualify a live ABI, +firmware acceptance, a lowest nonzero endpoint, or a thermal response time. + +Compile ``apple/t8140-j700.dtb``, then verify sensor identities, all cap maps, +hysteresis, polling and critical actions in the flattened tree:: python3 tools/testing/selftests/drivers/apple/j700-thermal-dt.py \ --dtb out/arch/arm64/boot/dts/apple/t8140-j700.dtb -This resolves each compiled sensor reference to its key, including inherited -temperature children. It also checks the six existing CPU references. A -missing SMC key keeps its channel slot in the driver; it must never silently -move a later zone to another key. Exercise that driver behavior and the SMC -readers without an SMC using:: - - python3 tools/testing/kunit/kunit.py run --arch arm64 \ - --kunitconfig drivers/hwmon/.kunitconfig.macsmc 'macsmc*' - -Ceiling implementation tests must additionally cover every valid state and -invalid endpoint, composition of simultaneous requests, startup restriction, -provider failure and recovery, publication ordering and teardown races. Run -the same production policy in host tests and KUnit with a fake actuator that -can reject or delay updates. Tests must verify that failed application cannot -be reported as an applied limit. - -Owner qualification +Owner one-shot plan ------------------- -First record the exact board, kernel, DTB, Mesa and both firmware versions. -Verify every zone's key identity, cooling binding and state range without a -GPU load. Missing sensors, missing bindings or an unconfirmed applied ceiling -must prevent progression to load tests. Retain the known-good boot entry and -one-shot boot fallback throughout qualification. - -On matching macOS and Linux configurations, record synchronized sensor, -power, requested/applied state, achieved frequency and frame-time traces. -Use the same workload, resolution, presentation mode, ambient conditions, -power source and comparable starting temperatures. Record sensor update -cadence, missing values and timestamp domains. Preserve raw traces for the -owner; publish only reviewed summaries without device identifiers. - -Before a Linux GPU experiment, obtain the required device approval and arm -a verified restrictive ceiling and independent temperature supervisor. Prove -the stop action and its latency before generating heat. Start with short, -bounded work at the lowest qualified ceiling. Stop before a non-CPU reading -reaches 100 C, with additional margin for refresh and stopping latency. The -owner's absolute abort rule also applies; it is not a normal control target. -If the available sampling cannot bound overshoot, do not extend the load. - -Once the actuator and trips have been independently qualified and integrated, -run vkmark cube for ten minutes, glmark2 terrain for ten minutes, and a fixed -game replay. Include warm starts, mixed CPU/GPU load, idle transitions and -both supported firmware variants. Plot temperature and limiting reason -against frame time; report maxima, time above each trip, cooling residency, -frame-time percentiles and sustained throughput. Require every relevant -non-CPU sensor to remain below 100 C and the derived board limits, with no -GPU fault or lost binding. Compare matched macOS traces without treating -unavailable telemetry as zero. These tests remain pending until the cooling -actuator and board policy exist. - -On any failure, stop the workload, retain the restrictive ceiling, preserve -traces and restore the known-good kernel/DTB through the boot fallback. Check -the restored identities and temperatures. A rollback is evidence of a failed -qualification, not a passing sustained-load result. +No device run is performed by the implementation worker. The owner first +reviews the missing ABI/endpoint facts and requests a device-specific test +through the controller. Preserve a known-good kernel/DTB and bootguard's +one-shot fallback. Record exact candidate and baseline source commits, +firmware identities, kernel, DTB, Mesa, workload, power source and ambient +conditions. Preserve hashes and the rollback entry before staging a candidate. + +For this incomplete revision, the only candidate check is a no-load boot: +verify independent thermal zones, critical trips and the expected GPU probe +refusal, then restore the known-good entry. Do not use this revision for a +rendering or performance acceptance test and do not remove its cooling +binding to bypass the interlock. + +After a qualified ABI and nonzero endpoint are integrated, rebuild and review +that exact candidate. Prove all three mirror publications and independent +achieved pstate/power readback with the pre-armed 25 percent ceiling. Prove +sensor-error handling, restrictive reset/recovery, callback teardown and the +independent shutdown path with no heat-generating workload first. Keep missing +or implausible fast-die information restrictive; repeated SMC values alone do +not identify a stale source. + +Use existing baseline traces from the current kernel; do not recreate an +uncapped baseline. With a separately approved capped baseline and candidate, +start at matched cool temperatures and issue only short, bounded bursts +(initially at most 100 ms), one workload at a time. Keep a temperature +supervisor independent of GPU progress and prove its stop latency before +load. Do not extend bursts if source-refresh and stopping delay cannot bound +overshoot below every critical threshold and 100 C. No sustained games, +full CTS, or multi-minute benchmarks belong to this plan. + +Capture monotonic timestamps, all relevant SMC temperatures and read errors, +firmware die readings if qualified, requested/published/applied cap quality, +achieved pstate or power, frame times and limiting reasons. Never substitute +zero for unsupported telemetry. Compare the same workload's frame-time +p50/p95/p99/max and throughput against the capped current kernel, together +with peak temperatures, time above each trip and cooling residency. A 25 +percent retained backstop is expected to affect throughput; report that limit. + +Stop on missing telemetry, a failed cap update, a lost binding, GPU fault, +excessive excursion or an independent supervisor action. Retain the strongest +cap, preserve failure traces and restore the known-good kernel/DTB through +the fallback. Verify the restored boot identity, zone identities and cooldown. +Record the rollback as a failed qualification, not a passing result. Sustained +load remains outside authorization until a separate thermal qualification. diff --git a/arch/arm64/boot/dts/apple/t8140-j700.dts b/arch/arm64/boot/dts/apple/t8140-j700.dts index 73f26ec5dcfe8..ee670b8e479ec 100644 --- a/arch/arm64/boot/dts/apple/t8140-j700.dts +++ b/arch/arm64/boot/dts/apple/t8140-j700.dts @@ -81,7 +81,7 @@ }; /* - * The J700 is fanless: the CPUs are the only cooling devices. Every + * The J700 is fanless. Every * 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 @@ -400,68 +400,651 @@ * indices count temperature-* children of smc_hwmon, including the * six CPU channels inherited from t8140.dtsi. Keep the sensor order. * - * These zones have no trips: firmware die-temperature limits do not - * establish limits for these SMC readings. GPU cooling requires a - * qualified firmware ceiling and board-specific thermal policy. + * Provisional outer protection, not recovered Apple board limits. + * The active-trip ladder works with the power_allocator governor's + * non-power-actor path as well as step_wise. Equal map bounds give + * exact percent requests, with the strictest zone winning. Critical + * shutdown remains independent of GPU probe and forward progress. + * The last rung requests zero until a nonzero endpoint is qualified. */ smc-tp0t-thermal { - polling-delay-passive = <1000>; - polling-delay = <1000>; + polling-delay-passive = <100>; + polling-delay = <100>; thermal-sensors = <&smc_hwmon 6>; + critical-action = "shutdown"; + + trips { + smc_tp0t_thermal_0: cap-0 { + temperature = <85000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tp0t_thermal_1: cap-1 { + temperature = <88000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tp0t_thermal_2: cap-2 { + temperature = <92000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tp0t_thermal_3: cap-3 { + temperature = <95000>; + hysteresis = <5000>; + type = "active"; + }; + + trip-hot { + temperature = <92000>; + hysteresis = <5000>; + type = "hot"; + }; + + trip-critical { + temperature = <98000>; + hysteresis = <0>; + type = "critical"; + }; + }; + + cooling-maps { + map0 { + trip = <&smc_tp0t_thermal_0>; + cooling-device = <&gpu 25 25>; + }; + map1 { + trip = <&smc_tp0t_thermal_1>; + cooling-device = <&gpu 50 50>; + }; + map2 { + trip = <&smc_tp0t_thermal_2>; + cooling-device = <&gpu 75 75>; + }; + map3 { + trip = <&smc_tp0t_thermal_3>; + cooling-device = <&gpu 100 100>; + }; + }; }; charger-thermal { - polling-delay-passive = <1000>; - polling-delay = <1000>; + polling-delay-passive = <100>; + polling-delay = <100>; thermal-sensors = <&smc_hwmon 11>; /* TCMz */ + critical-action = "shutdown"; + + trips { + charger_thermal_0: cap-0 { + temperature = <80000>; + hysteresis = <5000>; + type = "active"; + }; + + charger_thermal_1: cap-1 { + temperature = <83000>; + hysteresis = <5000>; + type = "active"; + }; + + charger_thermal_2: cap-2 { + temperature = <88000>; + hysteresis = <5000>; + type = "active"; + }; + + charger_thermal_3: cap-3 { + temperature = <92000>; + hysteresis = <5000>; + type = "active"; + }; + + trip-hot { + temperature = <88000>; + hysteresis = <5000>; + type = "hot"; + }; + + trip-critical { + temperature = <95000>; + hysteresis = <0>; + type = "critical"; + }; + }; + + cooling-maps { + map0 { + trip = <&charger_thermal_0>; + cooling-device = <&gpu 25 25>; + }; + map1 { + trip = <&charger_thermal_1>; + cooling-device = <&gpu 50 50>; + }; + map2 { + trip = <&charger_thermal_2>; + cooling-device = <&gpu 75 75>; + }; + map3 { + trip = <&charger_thermal_3>; + cooling-device = <&gpu 100 100>; + }; + }; }; chassis1-thermal { - polling-delay-passive = <1000>; - polling-delay = <1000>; + polling-delay-passive = <100>; + polling-delay = <100>; thermal-sensors = <&smc_hwmon 12>; /* Ts0A */ + critical-action = "shutdown"; + + trips { + chassis1_thermal_0: cap-0 { + temperature = <70000>; + hysteresis = <5000>; + type = "active"; + }; + + chassis1_thermal_1: cap-1 { + temperature = <75000>; + hysteresis = <5000>; + type = "active"; + }; + + chassis1_thermal_2: cap-2 { + temperature = <80000>; + hysteresis = <5000>; + type = "active"; + }; + + chassis1_thermal_3: cap-3 { + temperature = <85000>; + hysteresis = <5000>; + type = "active"; + }; + + trip-hot { + temperature = <80000>; + hysteresis = <5000>; + type = "hot"; + }; + + trip-critical { + temperature = <88000>; + hysteresis = <0>; + type = "critical"; + }; + }; + + cooling-maps { + map0 { + trip = <&chassis1_thermal_0>; + cooling-device = <&gpu 25 25>; + }; + map1 { + trip = <&chassis1_thermal_1>; + cooling-device = <&gpu 50 50>; + }; + map2 { + trip = <&chassis1_thermal_2>; + cooling-device = <&gpu 75 75>; + }; + map3 { + trip = <&chassis1_thermal_3>; + cooling-device = <&gpu 100 100>; + }; + }; }; chassis2-thermal { - polling-delay-passive = <1000>; - polling-delay = <1000>; + polling-delay-passive = <100>; + polling-delay = <100>; thermal-sensors = <&smc_hwmon 13>; /* Ts0I */ + critical-action = "shutdown"; + + trips { + chassis2_thermal_0: cap-0 { + temperature = <70000>; + hysteresis = <5000>; + type = "active"; + }; + + chassis2_thermal_1: cap-1 { + temperature = <75000>; + hysteresis = <5000>; + type = "active"; + }; + + chassis2_thermal_2: cap-2 { + temperature = <80000>; + hysteresis = <5000>; + type = "active"; + }; + + chassis2_thermal_3: cap-3 { + temperature = <85000>; + hysteresis = <5000>; + type = "active"; + }; + + trip-hot { + temperature = <80000>; + hysteresis = <5000>; + type = "hot"; + }; + + trip-critical { + temperature = <88000>; + hysteresis = <0>; + type = "critical"; + }; + }; + + cooling-maps { + map0 { + trip = <&chassis2_thermal_0>; + cooling-device = <&gpu 25 25>; + }; + map1 { + trip = <&chassis2_thermal_1>; + cooling-device = <&gpu 50 50>; + }; + map2 { + trip = <&chassis2_thermal_2>; + cooling-device = <&gpu 75 75>; + }; + map3 { + trip = <&chassis2_thermal_3>; + cooling-device = <&gpu 100 100>; + }; + }; }; chassis3-thermal { - polling-delay-passive = <1000>; - polling-delay = <1000>; + polling-delay-passive = <100>; + polling-delay = <100>; thermal-sensors = <&smc_hwmon 14>; /* Ts0M */ + critical-action = "shutdown"; + + trips { + chassis3_thermal_0: cap-0 { + temperature = <70000>; + hysteresis = <5000>; + type = "active"; + }; + + chassis3_thermal_1: cap-1 { + temperature = <75000>; + hysteresis = <5000>; + type = "active"; + }; + + chassis3_thermal_2: cap-2 { + temperature = <80000>; + hysteresis = <5000>; + type = "active"; + }; + + chassis3_thermal_3: cap-3 { + temperature = <85000>; + hysteresis = <5000>; + type = "active"; + }; + + trip-hot { + temperature = <80000>; + hysteresis = <5000>; + type = "hot"; + }; + + trip-critical { + temperature = <88000>; + hysteresis = <0>; + type = "critical"; + }; + }; + + cooling-maps { + map0 { + trip = <&chassis3_thermal_0>; + cooling-device = <&gpu 25 25>; + }; + map1 { + trip = <&chassis3_thermal_1>; + cooling-device = <&gpu 50 50>; + }; + map2 { + trip = <&chassis3_thermal_2>; + cooling-device = <&gpu 75 75>; + }; + map3 { + trip = <&chassis3_thermal_3>; + cooling-device = <&gpu 100 100>; + }; + }; }; smc-tp02-thermal { - polling-delay-passive = <1000>; - polling-delay = <1000>; + polling-delay-passive = <100>; + polling-delay = <100>; thermal-sensors = <&smc_hwmon 50>; + critical-action = "shutdown"; + + trips { + smc_tp02_thermal_0: cap-0 { + temperature = <85000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tp02_thermal_1: cap-1 { + temperature = <88000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tp02_thermal_2: cap-2 { + temperature = <92000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tp02_thermal_3: cap-3 { + temperature = <95000>; + hysteresis = <5000>; + type = "active"; + }; + + trip-hot { + temperature = <92000>; + hysteresis = <5000>; + type = "hot"; + }; + + trip-critical { + temperature = <98000>; + hysteresis = <0>; + type = "critical"; + }; + }; + + cooling-maps { + map0 { + trip = <&smc_tp02_thermal_0>; + cooling-device = <&gpu 25 25>; + }; + map1 { + trip = <&smc_tp02_thermal_1>; + cooling-device = <&gpu 50 50>; + }; + map2 { + trip = <&smc_tp02_thermal_2>; + cooling-device = <&gpu 75 75>; + }; + map3 { + trip = <&smc_tp02_thermal_3>; + cooling-device = <&gpu 100 100>; + }; + }; }; smc-tp06-thermal { - polling-delay-passive = <1000>; - polling-delay = <1000>; + polling-delay-passive = <100>; + polling-delay = <100>; thermal-sensors = <&smc_hwmon 52>; + critical-action = "shutdown"; + + trips { + smc_tp06_thermal_0: cap-0 { + temperature = <85000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tp06_thermal_1: cap-1 { + temperature = <88000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tp06_thermal_2: cap-2 { + temperature = <92000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tp06_thermal_3: cap-3 { + temperature = <95000>; + hysteresis = <5000>; + type = "active"; + }; + + trip-hot { + temperature = <92000>; + hysteresis = <5000>; + type = "hot"; + }; + + trip-critical { + temperature = <98000>; + hysteresis = <0>; + type = "critical"; + }; + }; + + cooling-maps { + map0 { + trip = <&smc_tp06_thermal_0>; + cooling-device = <&gpu 25 25>; + }; + map1 { + trip = <&smc_tp06_thermal_1>; + cooling-device = <&gpu 50 50>; + }; + map2 { + trip = <&smc_tp06_thermal_2>; + cooling-device = <&gpu 75 75>; + }; + map3 { + trip = <&smc_tp06_thermal_3>; + cooling-device = <&gpu 100 100>; + }; + }; }; smc-tp0e-thermal { - polling-delay-passive = <1000>; - polling-delay = <1000>; + polling-delay-passive = <100>; + polling-delay = <100>; thermal-sensors = <&smc_hwmon 56>; + critical-action = "shutdown"; + + trips { + smc_tp0e_thermal_0: cap-0 { + temperature = <85000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tp0e_thermal_1: cap-1 { + temperature = <88000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tp0e_thermal_2: cap-2 { + temperature = <92000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tp0e_thermal_3: cap-3 { + temperature = <95000>; + hysteresis = <5000>; + type = "active"; + }; + + trip-hot { + temperature = <92000>; + hysteresis = <5000>; + type = "hot"; + }; + + trip-critical { + temperature = <98000>; + hysteresis = <0>; + type = "critical"; + }; + }; + + cooling-maps { + map0 { + trip = <&smc_tp0e_thermal_0>; + cooling-device = <&gpu 25 25>; + }; + map1 { + trip = <&smc_tp0e_thermal_1>; + cooling-device = <&gpu 50 50>; + }; + map2 { + trip = <&smc_tp0e_thermal_2>; + cooling-device = <&gpu 75 75>; + }; + map3 { + trip = <&smc_tp0e_thermal_3>; + cooling-device = <&gpu 100 100>; + }; + }; }; smc-tpx1-thermal { - polling-delay-passive = <1000>; - polling-delay = <1000>; + polling-delay-passive = <100>; + polling-delay = <100>; thermal-sensors = <&smc_hwmon 63>; + critical-action = "shutdown"; + + trips { + smc_tpx1_thermal_0: cap-0 { + temperature = <85000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tpx1_thermal_1: cap-1 { + temperature = <88000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tpx1_thermal_2: cap-2 { + temperature = <92000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tpx1_thermal_3: cap-3 { + temperature = <95000>; + hysteresis = <5000>; + type = "active"; + }; + + trip-hot { + temperature = <92000>; + hysteresis = <5000>; + type = "hot"; + }; + + trip-critical { + temperature = <98000>; + hysteresis = <0>; + type = "critical"; + }; + }; + + cooling-maps { + map0 { + trip = <&smc_tpx1_thermal_0>; + cooling-device = <&gpu 25 25>; + }; + map1 { + trip = <&smc_tpx1_thermal_1>; + cooling-device = <&gpu 50 50>; + }; + map2 { + trip = <&smc_tpx1_thermal_2>; + cooling-device = <&gpu 75 75>; + }; + map3 { + trip = <&smc_tpx1_thermal_3>; + cooling-device = <&gpu 100 100>; + }; + }; }; smc-tpx3-thermal { - polling-delay-passive = <1000>; - polling-delay = <1000>; + polling-delay-passive = <100>; + polling-delay = <100>; thermal-sensors = <&smc_hwmon 65>; + critical-action = "shutdown"; + + trips { + smc_tpx3_thermal_0: cap-0 { + temperature = <85000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tpx3_thermal_1: cap-1 { + temperature = <88000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tpx3_thermal_2: cap-2 { + temperature = <92000>; + hysteresis = <5000>; + type = "active"; + }; + + smc_tpx3_thermal_3: cap-3 { + temperature = <95000>; + hysteresis = <5000>; + type = "active"; + }; + + trip-hot { + temperature = <92000>; + hysteresis = <5000>; + type = "hot"; + }; + + trip-critical { + temperature = <98000>; + hysteresis = <0>; + type = "critical"; + }; + }; + + cooling-maps { + map0 { + trip = <&smc_tpx3_thermal_0>; + cooling-device = <&gpu 25 25>; + }; + map1 { + trip = <&smc_tpx3_thermal_1>; + cooling-device = <&gpu 50 50>; + }; + map2 { + trip = <&smc_tpx3_thermal_2>; + cooling-device = <&gpu 75 75>; + }; + map3 { + trip = <&smc_tpx3_thermal_3>; + cooling-device = <&gpu 100 100>; + }; + }; }; }; @@ -1951,6 +2534,7 @@ }; &gpu { + #cooling-cells = <2>; status = "okay"; }; diff --git a/drivers/gpu/drm/asahi/g17/fw/initdata.rs b/drivers/gpu/drm/asahi/g17/fw/initdata.rs index 387cebb28a368..89b618f244daa 100644 --- a/drivers/gpu/drm/asahi/g17/fw/initdata.rs +++ b/drivers/gpu/drm/asahi/g17/fw/initdata.rs @@ -1603,7 +1603,8 @@ static_assert!(private::STATUS_B + size_of::() == private::SECO /// Die temperature sensors read by the die temperature limiter. const TEMP_SENSOR_MASK: u64 = 0x82a; /// Die temperature the limiter holds the GPU below, in 0.01 °C. -const TEMP_TARGET: u32 = 11_000; +// Conservative J700 bring-up policy; retain the native gains and 16 ms period. +const TEMP_TARGET: u32 = 9_500; /// Die temperature below which the limiter releases, in 0.01 °C. const TEMP_RELEASE: u32 = 8_000; /// Proportional gain of the limiter: 20.34 as an IEEE-754 single. diff --git a/tools/testing/selftests/drivers/apple/Makefile b/tools/testing/selftests/drivers/apple/Makefile index 05156cf4830d4..cfb0c3a696cec 100644 --- a/tools/testing/selftests/drivers/apple/Makefile +++ b/tools/testing/selftests/drivers/apple/Makefile @@ -10,7 +10,7 @@ TEST_PROGS := macsmc-j713.py atc-t8132-usb3.py pmgr-inherited.py dwc3-initial-role.py \ sn201202x-transport.py bcm4377-dma-window.py bcm4377-radio-sids.py \ bcm4377-state-wait.py bcm4377-rti-address.py aop-las.py \ - aop-motion.py j700-thermal-dt.py + aop-motion.py j700-thermal-dt.py gpu-cooling.py TEST_FILES := j813-peripherals.sh include ../../lib.mk diff --git a/tools/testing/selftests/drivers/apple/gpu-cooling.py b/tools/testing/selftests/drivers/apple/gpu-cooling.py new file mode 100755 index 0000000000000..3fa4483f63c06 --- /dev/null +++ b/tools/testing/selftests/drivers/apple/gpu-cooling.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-only OR MIT +"""Run the production percent-cap suite on the host, without a GPU.""" +import os +from pathlib import Path +import subprocess +import tempfile + +root = Path(__file__).resolve().parents[5] +source = root / "drivers/gpu/drm/asahi/cooling_test.c" +with tempfile.TemporaryDirectory(prefix="asahi-cooling-") as work: + binary = str(Path(work) / "cap-tests") + subprocess.run([os.environ.get("HOSTCC", "cc"), "-std=gnu11", "-Wall", "-Wextra", + "-Werror", "-DASAHI_HOST_TEST", str(source), "-o", binary], check=True) + subprocess.run([binary], check=True) diff --git a/tools/testing/selftests/drivers/apple/j700-thermal-dt.py b/tools/testing/selftests/drivers/apple/j700-thermal-dt.py index dd8aebdf73588..e7e196f757012 100755 --- a/tools/testing/selftests/drivers/apple/j700-thermal-dt.py +++ b/tools/testing/selftests/drivers/apple/j700-thermal-dt.py @@ -62,6 +62,43 @@ def require(condition, message): raise ValueError(message) +def check_policy(tree, zone): + path = f"/thermal-zones/{zone}" + if zone == "charger-thermal": + temps = [80000, 83000, 88000, 92000, 95000] + elif zone.startswith("chassis"): + temps = [70000, 75000, 80000, 85000, 88000] + else: + temps = [85000, 88000, 92000, 95000, 98000] + require(tree.cells(path, "polling-delay") == [100], "polling too slow") + require(tree.cells(path, "polling-delay-passive") == [100], "passive polling too slow") + require(tree.strings(path, "critical-action") == ["shutdown"], "wrong critical action") + gpu_nodes = [f"/soc/{n}" for n in tree.children("/soc") if n.startswith("gpu@")] + require(len(gpu_nodes) == 1, "expected one GPU") + gpu = gpu_nodes[0] + require(tree.cells(gpu, "#cooling-cells") == [2], "GPU cooling admission missing") + gpu_phandle, = tree.cells(gpu, "phandle") + for index, state in enumerate([25, 50, 75, 100]): + trip = f"{path}/trips/cap-{index}" + require(tree.cells(trip, "temperature") == [temps[index]], "wrong cap temperature") + require(tree.cells(trip, "hysteresis") == [5000], "wrong cap hysteresis") + require(tree.strings(trip, "type") == ["active"], "non-power-actor ladder required") + phandle, = tree.cells(trip, "phandle") + mapping = f"{path}/cooling-maps/map{index}" + require(tree.cells(mapping, "trip") == [phandle], "wrong trip reference") + require(tree.cells(mapping, "cooling-device") == [gpu_phandle, state, state], + "wrong GPU or non-exact cap request") + require(tree.cells(f"{path}/trips/trip-hot", "temperature") == [temps[2]], + "wrong hot temperature") + require(tree.strings(f"{path}/trips/trip-hot", "type") == ["hot"], "missing hot trip") + require(tree.cells(f"{path}/trips/trip-hot", "hysteresis") == [5000], + "wrong hot hysteresis") + critical = f"{path}/trips/trip-critical" + require(tree.cells(critical, "temperature") == [temps[4]], "wrong critical temperature") + require(tree.strings(critical, "type") == ["critical"], "missing critical shutdown") + require(tree.cells(critical, "hysteresis") == [0], "wrong critical hysteresis") + + def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--dtb", type=Path, default=os.environ.get("APPLE_J700_DTB")) @@ -108,7 +145,9 @@ def main(): require(owner == phandle, "wrong sensor provider") require(channel < len(channels), "sensor channel out of range") require(keys[channel] == [key], f"channel {channel} is {keys[channel]}, expected {key}") - print(f"ok {number} - {zone} reads {key}") + if not zone.startswith("cpu-"): + check_policy(tree, zone) + print(f"ok {number} - {zone} reads {key} with expected policy") except (ValueError, OSError, subprocess.CalledProcessError) as error: print(f"not ok {number} - {zone}: {str(error).splitlines()[0]}") failed = True From 940825b310fbac2b97fbd6857f0ff529c2d6f501 Mon Sep 17 00:00:00 2001 From: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Date: Sat, 7 Nov 2026 00:02:35 +1100 Subject: [PATCH 06/14] drm/asahi: publish live absolute GPU power ceilings Replace the obsolete host mirror model with typed RegionC and separate PowerState PPM publications. Serialize requester ceilings by their minimum, clean write-back mappings before reporting publication, and retain requests across recovery. Bound the unqualified low end at a provisional nonzero quarter of initialized maximum power. Admit the common G17P 26A428 and G16S 25G83 layout, leaving other builds unadmitted. The G17 fast die limiter is already initialized before submission with the conservative bring-up policy. Expose publication/readback diagnostics and update the offline tests and bounded owner qualification plan. Assisted-by: LLM Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> --- .../testing/sysfs-driver-aurora-gpu-cooling | 30 +- .../devicetree/bindings/gpu/apple,agx.yaml | 10 +- Documentation/gpu/asahi-gpu-thermal.rst | 274 +++++++++--------- arch/arm64/boot/dts/apple/t8140-j700.dts | 4 +- drivers/gpu/drm/asahi/Kconfig | 2 +- drivers/gpu/drm/asahi/cooling.c | 150 +++++++--- drivers/gpu/drm/asahi/cooling.h | 15 +- drivers/gpu/drm/asahi/cooling_policy.h | 124 +++++--- drivers/gpu/drm/asahi/cooling_test.c | 181 +++++++----- drivers/gpu/drm/asahi/g17/cooling.rs | 43 +-- drivers/gpu/drm/asahi/g17/fw/initdata.rs | 17 +- drivers/gpu/drm/asahi/g17/fw/mod.rs | 1 + drivers/gpu/drm/asahi/g17/fw/power.rs | 30 ++ drivers/gpu/drm/asahi/g17/fw/variant.rs | 13 +- drivers/gpu/drm/asahi/g17/initdata.rs | 45 ++- drivers/gpu/drm/asahi/g17/initdata/v25g83.rs | 1 + .../selftests/drivers/apple/gpu-cooling.py | 24 +- 17 files changed, 610 insertions(+), 354 deletions(-) create mode 100644 drivers/gpu/drm/asahi/g17/fw/power.rs diff --git a/Documentation/ABI/testing/sysfs-driver-aurora-gpu-cooling b/Documentation/ABI/testing/sysfs-driver-aurora-gpu-cooling index b4ca3748c8cd4..5301191cc341b 100644 --- a/Documentation/ABI/testing/sysfs-driver-aurora-gpu-cooling +++ b/Documentation/ABI/testing/sysfs-driver-aurora-gpu-cooling @@ -2,21 +2,19 @@ What: /sys/devices/platform/.../gpu_power_ceiling Date: November 2026 Contact: Asahi Linux contributors Description: - Read-only diagnostics for the common G16S/G17P firmware percent - ceiling. Present only after registration with a qualified firmware - layout. One key/value pair per line: + Read-only diagnostics for the admitted G16S/G17P absolute-power + actuator. One key/value pair per line: - requested_percent: 100 minus the thermal cooling state (0..100). - published_percent: the percent synchronously stored in all three - firmware mirrors, after composing the qualification backstop. - applied_percent: unsupported; host stores have no acknowledgement. - achieved_percent: unsupported; not inferred from a nominal OPP. - qualification_backstop_percent: maximum allowed host publication. + requested_state: thermal cooling state, 0..100. + requested_ceiling_mw: minimum of all retained requester ceilings. + applied_ceiling_mw: last completed host shared-memory publication. + provisional_floor_mw: 25 percent of the initialized maximum, + rounded down, but never zero. Pending hardware qualification. + achieved_ceiling_mw: unsupported; not inferred from a nominal OPP. - All numeric values are interface percentages, not watts, frequency - or a proven achieved utilization. The qualification backstop cannot - be released through this attribute. Firmware-reported achieved - pstate, when available, is independently exposed in agx_stats and - does not acknowledge a percent ceiling. J700 initialization is - refused while its firmware allocation-relative layout is unknown; - this attribute is consequently absent on that board. + Applied is a host publication, not firmware acknowledgement or + measured GPU power. The debugfs asahi--power/ceiling + file also reports separate RegionC/PPM readbacks, initialized max, + PPM enable and the thermal/fast-die/system/manual request slots. + State N requests max(25, 100 - N) percent of initialized power. + Critical shutdown never relies on the provisional floor. diff --git a/Documentation/devicetree/bindings/gpu/apple,agx.yaml b/Documentation/devicetree/bindings/gpu/apple,agx.yaml index fcd11a60d8105..ecec0e3f96f4a 100644 --- a/Documentation/devicetree/bindings/gpu/apple,agx.yaml +++ b/Documentation/devicetree/bindings/gpu/apple,agx.yaml @@ -104,10 +104,12 @@ properties: "#cooling-cells": const: 2 description: | - GPU firmware percent ceiling. State N requests (100 - N) percent, - for N in 0..100. Firmware initialization fails if the live ceiling ABI - for the selected firmware is not established. A qualification backstop - may impose a stricter ceiling than requested by the thermal framework. + GPU firmware absolute-power ceiling. State N requests (100 - N) + percent of initialized maximum power, for N in 0..100, bounded below + by a provisional nonzero minimum until hardware qualifies the low end. + Firmware initialization fails if the live power layout for the selected + firmware is not established. Other policy owners may impose a stricter + ceiling than the thermal framework requests. operating-points-v2: true diff --git a/Documentation/gpu/asahi-gpu-thermal.rst b/Documentation/gpu/asahi-gpu-thermal.rst index 73a9bac053b88..535e9d6d34863 100644 --- a/Documentation/gpu/asahi-gpu-thermal.rst +++ b/Documentation/gpu/asahi-gpu-thermal.rst @@ -3,78 +3,66 @@ GPU thermal integration and qualification ========================================= -Status ------- - -This branch is an incomplete cooling integration, with a deliberate safety -interlock. J700 requests GPU cooling in DT. Both firmware ABI variants still -lack a qualified allocation-relative ceiling layout, so J700 GPU probe fails -with ``EOPNOTSUPP`` before either GPU processor boots. This is expected and -must not be presented as successful hardware throttling. Existing G16S DTs -without cooling bindings retain their existing behavior. - -J700's SMC zones have independent critical shutdown trips. They register -through hwmon/thermal even when the GPU driver is absent or probe fails. -The firmware backstop target is provisionally lowered to 95 C with its -80 C release, sensor mask and gains preserved. It cannot take effect while -GPU probe is refused. Polling SMC at 100 ms does not accelerate its source -refresh or establish a fast transient safety guarantee. - -Source contract and unresolved ABI ----------------------------------- - -G17P/T8140 and G16S/T6040 use the same ``g17`` backend. G16G/T8132 and its -PMP cooling consumer are a separate backend. - -The clean facts from AGXG17G 353.14, macOS 26.6.2 build 25G83, -``AGXArmFirmware::setGPUMaxPower``, describe three synchronous u32 writes, -clamped to 0..100 percent, at offsets ``0xf150``, ``0xf2d0`` and ``0xf39c`` -from a power-control object. No mailbox, sequence or acknowledgement is -specified. This ceiling is separate from the effort floor, PMP and CLPC. - -Those offsets alone are insufficient to choose a Linux allocation. They -exceed both existing power configuration structures: 26A428 is ``0x2dc0`` -bytes, and 25G83 is ``0x6510`` bytes. The shared bundle also contains work -rings and control data; fitting in that larger allocation is not proof of -field ownership. The clean facts do not resolve the pointer chain from -that power-control object to the bundle, status block, firmware data or -another allocation. No G16S-specific ceiling layout or lowest validated -nonzero percent endpoint is established. - -``fw::Variant::power_ceiling`` therefore remains ``None`` for both builds. -Do not populate it by adding those offsets to an arbitrary mapped base. -A follow-up must supply a facts-only pointer/ownership contract and exact -per-build layout, validate the mapping and memory attributes, and then -populate the ABI tables. DT never supplies addresses or firmware offsets. - -Common cooling owner --------------------- - -The common implementation accepts three checked, distinct, aligned WC -words from an admitted firmware ABI table. It validates every destination -before writing any of them. A per-device mutex serializes all three stores -and a write barrier; callbacks do not acquire the GPU mutex or wait for a -completion. Registration publishes a 25 percent backstop before INIT, -port attachment and work publication. Recovery republishes the strictest -retained cap before reopening queues. Stop and teardown unregister and drain -thermal/sysfs callbacks before stopping the processors or releasing mappings. - -Cooling state N requests ``100 - N`` percent for N in 0..100. It is an -interface percentage, not an OPP selector or measured watts. The thermal -framework composes multiple zones by maximum state. The effective host -publication also cannot exceed the 25 percent qualification backstop. -There is no userspace knob to release it. Failed publication does not commit -a new request or published value. Matching host words are never called -applied or achieved; the diagnostic attribute labels both unsupported. -A firmware-reported pstate alone cannot acknowledge this percent ceiling. - -Provisional J700 outer policy ----------------------------- - -These thresholds are a conservative Linux bring-up proposal, not recovered -Apple board limits or safety ratings. Independent zones make the most -restrictive correlated sensor win; they do not imply that SMC keys are -GPU-local MTR sensors. +Live power owner +---------------- + +G17P/T8140 and G16S/T604x share the ``g17`` backend. The admitted live +actuator publishes an absolute ``u32`` milliwatt ceiling to the separately +allocated ``RegionC::max_power_mw`` at +0x84 for G17P 26A428 and G16S 25G83. +These are firmware fields, not offsets in a host service object. The obsolete +host-object mirror model has been removed. G16S 26A428 has a distinct typed ++0x88 prefix but no admitted initialization graph or live actuator. V25F84 +also has no live-power admission. Never reuse the common field for either. + +``PowerState::ppm_enabled`` (+0x128) and ``ppm_target_mw`` (+0x12c) are +separate typed fields in another object. The owner retains the initialized +PPM budget and bounds its published target by the composed ceiling. It never +aliases the RegionC maximum with the PPM target, a percent, an OPP, a PMP vote +or the performance effort floor. A zero/uninitialized PPM budget uses the +initialized RegionC maximum; a zero RegionC maximum rejects registration. +G16S uses the initialized per-chip maximum, not the zero placeholder in its +static configuration. + +A dedicated mutex serializes thermal, fast-die host-policy, system-budget +and manual request slots and their publications. The thermal framework +aggregates zone demands by maximum cooling state. The owner takes the minimum +of all absolute requests, so one requester relaxing cannot lift another's +ceiling. All future host budget/manual producers must use this owner rather +than write the fields directly. The firmware fast-die limiter operates +independently and is not replaced by the host fast-die request slot. + +State N requests ``max(25, 100 - N)`` percent of the initialized maximum, +rounded down in milliwatts, with a minimum of one milliwatt for tiny test +inputs. The 25 percent floor is **provisional**, not a qualified board minimum +or a claim about a physical pstate. State 100 does not publish zero or stop +the GPU. Absolute requests below the provisional floor are rejected, preserving +the previous restriction. Critical shutdown remains independent of GPU work. + +Registration publishes the floor before INIT, port attachment and submission; +its initial cooling state is 100. The governor may subsequently relax its own +request. The previous applied value and all requests survive a failed +publication. The current mapped stores are infallible after registration +validates every destination. Recovery republishes the committed restriction +before reopening consumption. Teardown drains debugfs, sysfs and thermal +callbacks before stopping processors or freeing mappings. + +RegionC is CPU write-back memory, so publication includes a clean to the point +of coherency. G17P PowerState also needs cleaning; G16S 25G83 PowerState is +write-combined. Store ordering is completed before host publication is +reported. There is no firmware mailbox, doorbell or acknowledgement for these +inputs. Shared-memory readback proves publication, not achieved GPU power. + +Fast and outer protection +------------------------- + +Before submission opens, the G17 firmware die limiter is initialized with +sensor mask ``0x82a``, target 95 C, release 80 C and its native 16 ms period. +The existing gains are preserved. These temperatures are provisional Linux +bring-up policy, not device safety ratings. The intentional missing-actuator +J700 initialization refusal is removed for the admitted layout; invalid +mappings, absent initialized power and unknown firmware still fail closed. + +J700 has independent SMC thermal zones and critical shutdown actions: =================== ===================== ============= ======== Zones Cap temperatures (C) Hot (C) Critical @@ -84,89 +72,91 @@ Charger (TCMz) 80, 83, 88, 92 88 95 C Chassis (Ts0A/I/M) 70, 75, 80, 85 80 88 C =================== ===================== ============= ======== -The four cap requests are 75, 50, 25 and 0 percent, with 5 C hysteresis. -The final zero request is deliberately stricter than the proposed lowest -validated nonzero endpoint, which remains unknown. Zero has no demonstrated -hardware stop semantics; critical shutdown must never depend on that request. -Do not replace zero with an invented minimum pstate or a percentage inferred -from an OPP's power. J700 GPU initialization remains refused independently. - -DT uses ``active`` trip types for this non-power-actor ladder, with equal -lower/upper cooling states. The tree's power_allocator governor explicitly -services such active instances, and step_wise also honors these exact -bounds. Passive trips on a device without power-actor callbacks would not -implement the requested cap under power_allocator. Hot trips carry policy -information; independent ``critical-action = "shutdown"`` provides the -shutdown action without any GPU callback. +Cooling states 25, 50, 75 and 100 apply 75, 50, 25 and the provisional +25 percent floor, with 5 C hysteresis. The last two states deliberately +coalesce until hardware qualifies a lower minimum. DT uses ``active`` trips +with equal lower/upper states, supported by both power_allocator and +step_wise for this non-power-actor device. SMC polling at 100 ms cannot +accelerate source refresh and does not replace the fast firmware limiter. + +Diagnostics +----------- + +``/sys/devices/platform/.../gpu_power_ceiling`` reports the requested thermal +state, composed requested and applied ceilings in mW, and provisional floor. +``/sys/kernel/debug/asahi--power/ceiling`` additionally reports +the initialized maximum, both live words, PPM enable and each request slot +(0 thermal, 1 fast-die host policy, 2 system, 3 manual). Applied means the host +completed the shared-memory publication; achieved power remains explicitly +unsupported. These diagnostics are read-only. A firmware pstate alone is not +an acknowledgement of either power input. Offline verification -------------------- -Run the same production mapping and fake-publication suite on the host:: +Run on a build host, without a GPU:: python3 tools/testing/selftests/drivers/apple/gpu-cooling.py -Run it in arm64 QEMU without a GPU or Rust toolchain:: +The host suite exercises the production C policy plus the exact typed Rust +PPM and unadmitted G16S 26A428 layouts. It covers all 101 states, floor +rounding, integer limits, every thermal/non-thermal request pair in both +orders, four-owner composition, separate PPM budgets, startup, failed +publication and recovery. Run the same C suite under arm64 QEMU:: python3 tools/testing/kunit/kunit.py run --arch arm64 --jobs 8 \ --kunitconfig drivers/gpu/drm/asahi/.kunitconfig.cooling \ --make_options LLVM=1 'asahi-gpu-cooling*' -The suite covers all 101 states, invalid endpoints, all pairs of demand and -budget, startup restriction, identical mirror transactions, rejected -publication, and restoration after reset. It does not qualify a live ABI, -firmware acceptance, a lowest nonzero endpoint, or a thermal response time. - -Compile ``apple/t8140-j700.dtb``, then verify sensor identities, all cap maps, -hysteresis, polling and critical actions in the flattened tree:: +Compile ``apple/t8140-j700.dtb`` and check the outer policy:: python3 tools/testing/selftests/drivers/apple/j700-thermal-dt.py \ --dtb out/arch/arm64/boot/dts/apple/t8140-j700.dtb -Owner one-shot plan -------------------- - -No device run is performed by the implementation worker. The owner first -reviews the missing ABI/endpoint facts and requests a device-specific test -through the controller. Preserve a known-good kernel/DTB and bootguard's -one-shot fallback. Record exact candidate and baseline source commits, -firmware identities, kernel, DTB, Mesa, workload, power source and ambient -conditions. Preserve hashes and the rollback entry before staging a candidate. - -For this incomplete revision, the only candidate check is a no-load boot: -verify independent thermal zones, critical trips and the expected GPU probe -refusal, then restore the known-good entry. Do not use this revision for a -rendering or performance acceptance test and do not remove its cooling -binding to bypass the interlock. - -After a qualified ABI and nonzero endpoint are integrated, rebuild and review -that exact candidate. Prove all three mirror publications and independent -achieved pstate/power readback with the pre-armed 25 percent ceiling. Prove -sensor-error handling, restrictive reset/recovery, callback teardown and the -independent shutdown path with no heat-generating workload first. Keep missing -or implausible fast-die information restrictive; repeated SMC values alone do -not identify a stale source. - -Use existing baseline traces from the current kernel; do not recreate an -uncapped baseline. With a separately approved capped baseline and candidate, -start at matched cool temperatures and issue only short, bounded bursts -(initially at most 100 ms), one workload at a time. Keep a temperature -supervisor independent of GPU progress and prove its stop latency before -load. Do not extend bursts if source-refresh and stopping delay cannot bound -overshoot below every critical threshold and 100 C. No sustained games, -full CTS, or multi-minute benchmarks belong to this plan. - -Capture monotonic timestamps, all relevant SMC temperatures and read errors, -firmware die readings if qualified, requested/published/applied cap quality, -achieved pstate or power, frame times and limiting reasons. Never substitute -zero for unsupported telemetry. Compare the same workload's frame-time -p50/p95/p99/max and throughput against the capped current kernel, together -with peak temperatures, time above each trip and cooling residency. A 25 -percent retained backstop is expected to affect throughput; report that limit. - -Stop on missing telemetry, a failed cap update, a lost binding, GPU fault, -excessive excursion or an independent supervisor action. Retain the strongest -cap, preserve failure traces and restore the known-good kernel/DTB through -the fallback. Verify the restored boot identity, zone identities and cooldown. -Record the rollback as a failed qualification, not a passing result. Sustained -load remains outside authorization until a separate thermal qualification. +These tests do not qualify firmware-achieved power or a safe minimum. + +Owner Neo one-shot plan +----------------------- + +This revision performs no device test. Request a separate controller-approved +Neo one-shot, identifying the device, exact source and boot artifacts. Build +with the unique release suffix ``-aurora-t5062-gpu-cooling-v2-01``; verify +``uname -r`` matches it after boot. Preserve the fleet-default kernel/DTB, +artifact hashes, boot entry and bootguard fallback before staging. Record +candidate and fleet commits, firmware identity, Mesa, workload, power source, +ambient conditions and starting temperatures. Keep private lab records outside +the public source tree. + +First boot with no GPU load. Verify the cooling device, independent thermal +zones, all critical trips, requested/applied/readback agreement and nonzero +PPM target. Set state 100 and verify the initialized maximum's 25 percent +floor (2387 mW for a 9550 mW maximum), never zero. Check states 75, 50, 25 and +0 at no load, returning to 100 after each. Confirm the PPM word remains a +separate target and never exceeds its retained budget or the applied ceiling. +Test that one thermal zone relaxing cannot release another zone's demand. +Capture invalid-state rejection, restrictive reset/recovery and callback +teardown. Prove the independent supervisor's stop latency before applying load. + +Use existing fleet-default traces for the first comparison. If matched traces +are unavailable, request a separate bounded baseline test; do not recreate a +sustained unrestricted baseline. For both fleet default and candidate, record +the actual cap and compare identical workloads from matched cool temperatures. +Start with at most 100 ms GPU bursts, one workload at a time, with state 100 +applied. Only step toward higher allowed power after readback and cooldown +succeed. No games, full CTS or multi-minute benchmarks in this one-shot. + +Capture monotonic timestamps, requested/applied RegionC ceilings, PPM target, +all relevant temperatures and read errors, available firmware die telemetry, +achieved pstate/power quality, frame times and limiting reasons. Compare +frame-time p50/p95/p99/max, throughput, peak temperature, time above each trip +and cooling residency against fleet default, labeling different power caps. +Readback is not achieved-power evidence. Qualifying a lower floor requires +independent achieved-state evidence and a separately reviewed test. + +Stop bursts on a failed cap update, readback mismatch, missing or implausible +telemetry, lost binding, GPU fault or supervisor action. Keep the strongest +request, preserve traces and restore the fleet-default kernel/DTB using the +one-shot fallback. Do not extend bursts unless source refresh and stop delay +bound overshoot below every critical trip and 100 C. After rollback verify +the restored release, boot entry, zone identities and cooldown. Retain failure +and rollback evidence; a rollback is a failed qualification, not a pass. diff --git a/arch/arm64/boot/dts/apple/t8140-j700.dts b/arch/arm64/boot/dts/apple/t8140-j700.dts index ee670b8e479ec..07393fc40a1bd 100644 --- a/arch/arm64/boot/dts/apple/t8140-j700.dts +++ b/arch/arm64/boot/dts/apple/t8140-j700.dts @@ -403,9 +403,9 @@ * Provisional outer protection, not recovered Apple board limits. * The active-trip ladder works with the power_allocator governor's * non-power-actor path as well as step_wise. Equal map bounds give - * exact percent requests, with the strictest zone winning. Critical + * exact policy requests, with the strictest zone winning. Critical * shutdown remains independent of GPU probe and forward progress. - * The last rung requests zero until a nonzero endpoint is qualified. + * The actuator bounds the last rung at its provisional nonzero floor. */ smc-tp0t-thermal { polling-delay-passive = <100>; diff --git a/drivers/gpu/drm/asahi/Kconfig b/drivers/gpu/drm/asahi/Kconfig index 5fe24dad9c44a..4f0c696b01e5a 100644 --- a/drivers/gpu/drm/asahi/Kconfig +++ b/drivers/gpu/drm/asahi/Kconfig @@ -97,7 +97,7 @@ config DRM_ASAHI_COOLING_KUNIT_TEST depends on KUNIT default KUNIT_ALL_TESTS help - Exercise percent ceiling mapping, composition and failed publication + 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. diff --git a/drivers/gpu/drm/asahi/cooling.c b/drivers/gpu/drm/asahi/cooling.c index 47df25b87f0ad..a60d027d85bcc 100644 --- a/drivers/gpu/drm/asahi/cooling.c +++ b/drivers/gpu/drm/asahi/cooling.c @@ -1,41 +1,74 @@ // SPDX-License-Identifier: GPL-2.0-only OR MIT +#include #include #include #include +#include #include +#include #include #include -#include +#include #include "cooling.h" -#include "cooling_policy.h" struct asahi_gpu_cooling { struct device *dev; struct mutex lock; struct asahi_gpu_cap cap; - u32 *mirrors[3]; + struct asahi_gpu_power_words words; + u32 ppm_budget_mw; struct thermal_cooling_device *cdev; struct device_attribute telemetry; + struct dentry *debugfs; }; -/* No mailbox or ACK exists. The caller validated all destinations before any - * write. The dedicated WC words are never modified by any other host path. - * One mutex covers all three stores, independently of the GPU device lock. +static void clean_word(u32 *word) +{ + dcache_clean_poc((unsigned long)word, (unsigned long)(word + 1)); +} + +/* No mailbox or ACK exists. All pointers are checked before registration. + * The cooling mutex owns every ceiling requester and both power publications; + * it never takes the GPU mutex or waits for GPU work. RegionC is write-back, + * so a WC store barrier alone would not publish this word to firmware. */ -static int asahi_gpu_publish_cap(void *context, unsigned int percent) +static int asahi_gpu_publish_cap(void *context, unsigned int mw) { struct asahi_gpu_cooling *cooling = context; - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(cooling->mirrors); i++) - WRITE_ONCE(*cooling->mirrors[i], percent); - /* Complete all three WC stores before reporting host publication. */ + struct asahi_gpu_power_words *words = &cooling->words; + u32 ppm = min(mw, cooling->ppm_budget_mw); + + lockdep_assert_held(&cooling->lock); + /* Independent absolute-power inputs. PPM retains its own budget, bounded + * by the composed ceiling; neither word is a percent or an effort floor. + */ + WRITE_ONCE(*words->ppm_target_mw, ppm); + WRITE_ONCE(*words->ppm_enabled, 1); + if (words->ppm_writeback) { + clean_word(words->ppm_target_mw); + clean_word(words->ppm_enabled); + } + WRITE_ONCE(*words->max_power_mw, mw); + clean_word(words->max_power_mw); wmb(); return 0; } +int asahi_gpu_cooling_request(struct asahi_gpu_cooling *cooling, + enum asahi_gpu_cap_source source, u32 mw) +{ + /* Thermal requests also need a state; only the cooling callback sets it. */ + if (source <= ASAHI_GPU_CAP_THERMAL || source >= ASAHI_GPU_CAP_SOURCES) + return -EINVAL; + guard(mutex)(&cooling->lock); + if (mw < cooling->cap.floor_mw || mw > cooling->cap.max_mw) + return -ERANGE; + return asahi_gpu_cap_request(&cooling->cap, source, mw, + asahi_gpu_publish_cap, cooling); +} + static int asahi_gpu_cooling_max(struct thermal_cooling_device *cdev, unsigned long *state) { @@ -61,8 +94,7 @@ static int asahi_gpu_cooling_set(struct thermal_cooling_device *cdev, if (asahi_gpu_cap_percent(state) < 0) return -EINVAL; guard(mutex)(&cooling->lock); - return asahi_gpu_cap_update(&cooling->cap, state, 100, - asahi_gpu_publish_cap, cooling); + return asahi_gpu_cap_update(&cooling->cap, state, asahi_gpu_publish_cap, cooling); } static const struct thermal_cooling_device_ops asahi_gpu_cooling_ops = { @@ -71,6 +103,29 @@ static const struct thermal_cooling_device_ops asahi_gpu_cooling_ops = { .set_cur_state = asahi_gpu_cooling_set, }; +static int ceiling_show(struct seq_file *m, void *unused) +{ + struct asahi_gpu_cooling *cooling = m->private; + unsigned int i; + + guard(mutex)(&cooling->lock); + seq_printf(m, "requested_state %u\nrequested_ceiling_mw %u\napplied_ceiling_mw %u\n" + "region_c_readback_mw %u\nppm_target_readback_mw %u\nppm_enabled %u\n" + "initialized_ppm_budget_mw %u\n" + "initialized_max_mw %u\nprovisional_floor_mw %u\n" + "achieved_ceiling_mw unsupported\n", + cooling->cap.requested_state, asahi_gpu_cap_effective(&cooling->cap), + cooling->cap.applied_mw, READ_ONCE(*cooling->words.max_power_mw), + READ_ONCE(*cooling->words.ppm_target_mw), + READ_ONCE(*cooling->words.ppm_enabled), cooling->ppm_budget_mw, + cooling->cap.max_mw, + cooling->cap.floor_mw); + for (i = 0; i < ASAHI_GPU_CAP_SOURCES; i++) + seq_printf(m, "request_%u_mw %u\n", i, cooling->cap.requests[i]); + return 0; +} +DEFINE_SHOW_ATTRIBUTE(ceiling); + static ssize_t gpu_power_ceiling_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -78,36 +133,54 @@ static ssize_t gpu_power_ceiling_show(struct device *dev, container_of(attr, struct asahi_gpu_cooling, telemetry); guard(mutex)(&cooling->lock); - return sysfs_emit(buf, "requested_percent %u\npublished_percent %u\n" - "applied_percent unsupported\nachieved_percent unsupported\n" - "qualification_backstop_percent %u\n", - 100 - cooling->cap.requested_state, - cooling->cap.published_percent, ASAHI_GPU_PREARM_PERCENT); + return sysfs_emit(buf, "requested_state %u\nrequested_ceiling_mw %u\n" + "applied_ceiling_mw %u\nprovisional_floor_mw %u\n" + "achieved_ceiling_mw unsupported\n", + cooling->cap.requested_state, + asahi_gpu_cap_effective(&cooling->cap), cooling->cap.applied_mw, + cooling->cap.floor_mw); } struct asahi_gpu_cooling *asahi_gpu_cooling_register(struct device *dev, - u32 * const mirrors[3]) + const struct asahi_gpu_power_words *words) { struct asahi_gpu_cooling *cooling; - int ret, i; - - if (!dev || !dev->of_node || !mirrors) + char *name; + int ret; + + if (!dev || !dev->of_node || !words || !words->max_power_mw || + !words->ppm_enabled || !words->ppm_target_mw || + !IS_ALIGNED((unsigned long)words->max_power_mw, sizeof(u32)) || + !IS_ALIGNED((unsigned long)words->ppm_enabled, sizeof(u32)) || + !IS_ALIGNED((unsigned long)words->ppm_target_mw, sizeof(u32)) || + words->max_power_mw == words->ppm_enabled || + words->max_power_mw == words->ppm_target_mw || + words->ppm_enabled == words->ppm_target_mw) return ERR_PTR(-EINVAL); - for (i = 0; i < 3; i++) { - if (!mirrors[i] || !IS_ALIGNED((unsigned long)mirrors[i], sizeof(u32))) - return ERR_PTR(-EINVAL); - if (mirrors[i] == mirrors[(i + 1) % 3]) - return ERR_PTR(-EINVAL); - } cooling = kzalloc_obj(*cooling); if (!cooling) return ERR_PTR(-ENOMEM); cooling->dev = dev; + cooling->words = *words; mutex_init(&cooling->lock); - memcpy(cooling->mirrors, mirrors, sizeof(cooling->mirrors)); - asahi_gpu_cap_init(&cooling->cap); - ret = asahi_gpu_cap_update(&cooling->cap, 0, 100, + ret = asahi_gpu_cap_init(&cooling->cap, READ_ONCE(*words->max_power_mw)); + if (ret) { + ret = -EINVAL; + goto free; + } + cooling->ppm_budget_mw = cooling->cap.max_mw; + if (READ_ONCE(*words->ppm_enabled) && READ_ONCE(*words->ppm_target_mw)) + cooling->ppm_budget_mw = READ_ONCE(*words->ppm_target_mw); + if (cooling->ppm_budget_mw < cooling->cap.floor_mw) { + ret = -ERANGE; + goto free; + } + cooling->cap.requests[ASAHI_GPU_CAP_SYSTEM] = + min(cooling->cap.max_mw, cooling->ppm_budget_mw); + mutex_lock(&cooling->lock); + ret = asahi_gpu_cap_update(&cooling->cap, ASAHI_GPU_COOLING_MAX, asahi_gpu_publish_cap, cooling); + mutex_unlock(&cooling->lock); if (ret) goto free; cooling->cdev = thermal_of_cooling_device_register(dev->of_node, 0, @@ -125,6 +198,12 @@ struct asahi_gpu_cooling *asahi_gpu_cooling_register(struct device *dev, thermal_cooling_device_unregister(cooling->cdev); goto free; } + name = kasprintf(GFP_KERNEL, "asahi-%s-power", dev_name(dev)); + if (name) { + cooling->debugfs = debugfs_create_dir(name, NULL); + debugfs_create_file("ceiling", 0444, cooling->debugfs, cooling, &ceiling_fops); + kfree(name); + } return cooling; free: kfree(cooling); @@ -134,15 +213,14 @@ struct asahi_gpu_cooling *asahi_gpu_cooling_register(struct device *dev, void asahi_gpu_cooling_rearm(struct asahi_gpu_cooling *cooling) { guard(mutex)(&cooling->lock); - /* Keep a stronger governor request across recovery. */ - asahi_gpu_cap_update(&cooling->cap, cooling->cap.requested_state, 100, - asahi_gpu_publish_cap, cooling); + /* Preserve every requester across recovery, before consumption resumes. */ + asahi_gpu_cap_rearm(&cooling->cap, asahi_gpu_publish_cap, cooling); } void asahi_gpu_cooling_unregister(struct asahi_gpu_cooling *cooling) { + debugfs_remove_recursive(cooling->debugfs); device_remove_file(cooling->dev, &cooling->telemetry); - /* Join all callbacks before Rust can release the firmware mapping. */ thermal_cooling_device_unregister(cooling->cdev); kfree(cooling); } diff --git a/drivers/gpu/drm/asahi/cooling.h b/drivers/gpu/drm/asahi/cooling.h index fc04731bedf5d..c0fe65ada52d0 100644 --- a/drivers/gpu/drm/asahi/cooling.h +++ b/drivers/gpu/drm/asahi/cooling.h @@ -2,12 +2,23 @@ #ifndef ASAHI_COOLING_H #define ASAHI_COOLING_H #include +#include "cooling_policy.h" struct device; struct asahi_gpu_cooling; -/* Caller owns three validated, host-writable WC words until unregister. */ +/* Separate typed fields, retained until unregister drains every callback. + * RegionC is WB; PowerState may be WC (25G83) or WB (G17P). + */ +struct asahi_gpu_power_words { + u32 *max_power_mw; + u32 *ppm_enabled; + u32 *ppm_target_mw; + bool ppm_writeback; +}; struct asahi_gpu_cooling *asahi_gpu_cooling_register(struct device *dev, - u32 * const mirrors[3]); + const struct asahi_gpu_power_words *words); +int asahi_gpu_cooling_request(struct asahi_gpu_cooling *cooling, + enum asahi_gpu_cap_source source, u32 mw); void asahi_gpu_cooling_unregister(struct asahi_gpu_cooling *cooling); void asahi_gpu_cooling_rearm(struct asahi_gpu_cooling *cooling); #endif diff --git a/drivers/gpu/drm/asahi/cooling_policy.h b/drivers/gpu/drm/asahi/cooling_policy.h index 20c93be006da2..a57fa240158b0 100644 --- a/drivers/gpu/drm/asahi/cooling_policy.h +++ b/drivers/gpu/drm/asahi/cooling_policy.h @@ -2,23 +2,26 @@ #ifndef ASAHI_COOLING_POLICY_H #define ASAHI_COOLING_POLICY_H -/* Firmware interface units, not an OPP index or a measured power in watts. */ #define ASAHI_GPU_COOLING_MAX 100U -#define ASAHI_GPU_PREARM_PERCENT 25U -#define ASAHI_GPU_UNPUBLISHED 101U +/* Provisional until the minimum useful absolute power is qualified per board. */ +#define ASAHI_GPU_MIN_PERCENT 25U + +enum asahi_gpu_cap_source { + ASAHI_GPU_CAP_THERMAL, + ASAHI_GPU_CAP_FAST_DIE, + ASAHI_GPU_CAP_SYSTEM, + ASAHI_GPU_CAP_MANUAL, + ASAHI_GPU_CAP_SOURCES, +}; struct asahi_gpu_cap { + unsigned int max_mw; + unsigned int floor_mw; + unsigned int requests[ASAHI_GPU_CAP_SOURCES]; unsigned int requested_state; - unsigned int published_percent; + unsigned int applied_mw; }; -static inline void asahi_gpu_cap_init(struct asahi_gpu_cap *cap) -{ - cap->requested_state = 0; - cap->published_percent = ASAHI_GPU_UNPUBLISHED; -} - -/* State 0 permits 100%, state 100 requests 0%. Invalid states never wrap. */ static inline int asahi_gpu_cap_percent(unsigned long state) { if (state > ASAHI_GPU_COOLING_MAX) @@ -26,42 +29,91 @@ static inline int asahi_gpu_cap_percent(unsigned long state) return ASAHI_GPU_COOLING_MAX - state; } -/* - * Keep the qualification backstop permanently armed. There is deliberately no - * userspace switch to lift it: an achieved pstate is not an acknowledgement of - * this percent ceiling, and source refresh cannot prove fast-die freshness. - */ -static inline unsigned int asahi_gpu_cap_effective(unsigned long state, - unsigned int budget_percent) +static inline unsigned int asahi_gpu_cap_scale(unsigned int max_mw, + unsigned int percent) { - int percent = asahi_gpu_cap_percent(state); - unsigned int limit = ASAHI_GPU_PREARM_PERCENT; + /* Divide first so even UINT_MAX never overflows. Round down. */ + return max_mw / 100 * percent + max_mw % 100 * percent / 100; +} + +static inline int asahi_gpu_cap_init(struct asahi_gpu_cap *cap, + unsigned int max_mw) +{ + unsigned int i; + + if (!max_mw) + return -1; + cap->max_mw = max_mw; + cap->floor_mw = asahi_gpu_cap_scale(max_mw, ASAHI_GPU_MIN_PERCENT); + if (!cap->floor_mw) + cap->floor_mw = 1; + for (i = 0; i < ASAHI_GPU_CAP_SOURCES; i++) + cap->requests[i] = max_mw; + /* Start restrictive, before INIT. The thermal governor may subsequently + * relax its own request; it cannot relax another requester's ceiling. + */ + cap->requests[ASAHI_GPU_CAP_THERMAL] = cap->floor_mw; + cap->requested_state = ASAHI_GPU_COOLING_MAX; + cap->applied_mw = 0; /* No publication yet; never a firmware zero request. */ + return 0; +} - if (percent < 0 || budget_percent > 100) - return 0; - if ((unsigned int)percent < limit) - limit = percent; - if (budget_percent < limit) - limit = budget_percent; +static inline unsigned int asahi_gpu_cap_effective(const struct asahi_gpu_cap *cap) +{ + unsigned int i, limit = cap->max_mw; + + for (i = 0; i < ASAHI_GPU_CAP_SOURCES; i++) + if (cap->requests[i] < limit) + limit = cap->requests[i]; return limit; } -/* Commit host publication only on success; never call it applied/achieved. */ -static inline int asahi_gpu_cap_update(struct asahi_gpu_cap *cap, - unsigned long state, unsigned int budget_percent, - int (*publish)(void *context, unsigned int percent), void *context) +/* Publisher validates before any store and cannot partially fail. Commit only + * after successful publication. A weaker requester never overrides another. + * Absolute requests below the provisional floor are rejected, never rounded up. + */ +static inline int asahi_gpu_cap_request(struct asahi_gpu_cap *cap, + unsigned int source, unsigned int mw, + int (*publish)(void *context, unsigned int mw), void *context) { - unsigned int percent; + struct asahi_gpu_cap next = *cap; + unsigned int effective; int ret; - if (asahi_gpu_cap_percent(state) < 0 || budget_percent > 100) + if (source >= ASAHI_GPU_CAP_SOURCES || mw < cap->floor_mw || mw > cap->max_mw) return -1; - percent = asahi_gpu_cap_effective(state, budget_percent); - ret = publish(context, percent); + next.requests[source] = mw; + effective = asahi_gpu_cap_effective(&next); + ret = publish(context, effective); if (ret) return ret; - cap->requested_state = state; - cap->published_percent = percent; + next.applied_mw = effective; + *cap = next; return 0; } + +static inline int asahi_gpu_cap_update(struct asahi_gpu_cap *cap, + unsigned long state, + int (*publish)(void *context, unsigned int mw), void *context) +{ + int percent = asahi_gpu_cap_percent(state); + unsigned int mw; + int ret; + + if (percent < 0) + return -1; + mw = asahi_gpu_cap_scale(cap->max_mw, percent); + if (mw < cap->floor_mw) + mw = cap->floor_mw; + ret = asahi_gpu_cap_request(cap, ASAHI_GPU_CAP_THERMAL, mw, publish, context); + if (!ret) + cap->requested_state = state; + return ret; +} +/* Restore the committed restriction before queues reopen after recovery. */ +static inline int asahi_gpu_cap_rearm(const struct asahi_gpu_cap *cap, + int (*publish)(void *context, unsigned int mw), void *context) +{ + return publish(context, cap->applied_mw); +} #endif diff --git a/drivers/gpu/drm/asahi/cooling_test.c b/drivers/gpu/drm/asahi/cooling_test.c index 010b521755d97..fa87ddd9a8060 100644 --- a/drivers/gpu/drm/asahi/cooling_test.c +++ b/drivers/gpu/drm/asahi/cooling_test.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only OR MIT -/* Build this same suite with -DASAHI_HOST_TEST or through KUnit. */ +/* Build this same production-policy suite with ASAHI_HOST_TEST or KUnit. */ #ifdef ASAHI_HOST_TEST #include #include @@ -16,109 +16,154 @@ struct kunit { int unused; }; #include "cooling_policy.h" struct fake_actuator { - unsigned int words[3]; + unsigned int region_c_mw; + unsigned int ppm_target_mw; + unsigned int ppm_budget_mw; unsigned int calls; int error; }; -static int fake_publish(void *context, unsigned int percent) +static int fake_publish(void *context, unsigned int mw) { struct fake_actuator *fake = context; - unsigned int i; fake->calls++; if (fake->error) - return fake->error; - for (i = 0; i < 3; i++) - fake->words[i] = percent; + return fake->error; /* Fail before either store. */ + fake->region_c_mw = mw; + fake->ppm_target_mw = mw < fake->ppm_budget_mw ? mw : fake->ppm_budget_mw; return 0; } static void cap_mapping(struct kunit *test) { + struct asahi_gpu_cap cap; + struct fake_actuator fake = { .ppm_budget_mw = 9750 }; unsigned long state; - - for (state = 0; state <= 100; state++) - KUNIT_EXPECT_EQ(test, asahi_gpu_cap_percent(state), (int)(100 - state)); - KUNIT_EXPECT_EQ(test, asahi_gpu_cap_percent(25), 75); - KUNIT_EXPECT_EQ(test, asahi_gpu_cap_percent(50), 50); - KUNIT_EXPECT_EQ(test, asahi_gpu_cap_percent(75), 25); - KUNIT_EXPECT_EQ(test, asahi_gpu_cap_percent(99), 1); + unsigned int previous = 9550; + + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_init(&cap, 9550), 0); + for (state = 0; state <= 100; state++) { + unsigned int expected = 9550 * (100 - state) / 100; + + if (expected < 2387) + expected = 2387; + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, state, fake_publish, &fake), 0); + KUNIT_EXPECT_EQ(test, cap.applied_mw, expected); + KUNIT_EXPECT_EQ(test, fake.region_c_mw, expected); + KUNIT_EXPECT_EQ(test, fake.ppm_target_mw, expected); + KUNIT_EXPECT_EQ(test, cap.applied_mw <= previous, 1); + previous = cap.applied_mw; + } + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_percent(100), 0); KUNIT_EXPECT_LT(test, asahi_gpu_cap_percent(101), 0); KUNIT_EXPECT_LT(test, asahi_gpu_cap_percent(ULONG_MAX), 0); } static void cap_composition(struct kunit *test) { - unsigned int a, b; - - for (a = 0; a <= 100; a++) { - for (b = 0; b <= 100; b++) { - unsigned int expected = 100 - a; - - if (b < expected) - expected = b; - if (expected > 25) - expected = 25; - KUNIT_EXPECT_EQ(test, asahi_gpu_cap_effective(a, b), expected); + struct asahi_gpu_cap cap; + struct fake_actuator fake = { .ppm_budget_mw = 10000 }; + unsigned int a, b, source; + + /* Every demand pair, for every non-thermal requester, in both orders. */ + for (source = ASAHI_GPU_CAP_FAST_DIE; source < ASAHI_GPU_CAP_SOURCES; source++) { + for (a = 25; a <= 100; a++) { + for (b = 25; b <= 100; b++) { + unsigned int expected = (a < b ? a : b) * 100; + + asahi_gpu_cap_init(&cap, 10000); + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_request(&cap, source, b * 100, fake_publish, &fake), 0); + KUNIT_EXPECT_EQ(test, cap.applied_mw, 2500U); + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, 100 - a, fake_publish, &fake), 0); + KUNIT_EXPECT_EQ(test, cap.applied_mw, expected); + asahi_gpu_cap_init(&cap, 10000); + asahi_gpu_cap_update(&cap, 100 - a, fake_publish, &fake); + asahi_gpu_cap_request(&cap, source, b * 100, fake_publish, &fake); + KUNIT_EXPECT_EQ(test, cap.applied_mw, expected); + } } } - KUNIT_EXPECT_EQ(test, asahi_gpu_cap_effective(ULONG_MAX, 100), 0U); - KUNIT_EXPECT_EQ(test, asahi_gpu_cap_effective(0, 101), 0U); + /* All four owners remain independent when one relaxes. */ + asahi_gpu_cap_init(&cap, 10000); + asahi_gpu_cap_update(&cap, 0, fake_publish, &fake); + asahi_gpu_cap_request(&cap, ASAHI_GPU_CAP_FAST_DIE, 3000, fake_publish, &fake); + asahi_gpu_cap_request(&cap, ASAHI_GPU_CAP_SYSTEM, 5000, fake_publish, &fake); + asahi_gpu_cap_request(&cap, ASAHI_GPU_CAP_MANUAL, 4000, fake_publish, &fake); + KUNIT_EXPECT_EQ(test, cap.applied_mw, 3000U); + asahi_gpu_cap_request(&cap, ASAHI_GPU_CAP_FAST_DIE, 10000, fake_publish, &fake); + KUNIT_EXPECT_EQ(test, cap.applied_mw, 4000U); + asahi_gpu_cap_update(&cap, 1, fake_publish, &fake); + KUNIT_EXPECT_EQ(test, cap.applied_mw, 4000U); + asahi_gpu_cap_request(&cap, ASAHI_GPU_CAP_MANUAL, 10000, fake_publish, &fake); + KUNIT_EXPECT_EQ(test, cap.applied_mw, 5000U); } -static void cap_startup_and_mirrors(struct kunit *test) +static void cap_startup_and_ppm(struct kunit *test) { struct asahi_gpu_cap cap; - struct fake_actuator fake = {}; - unsigned int i; - - asahi_gpu_cap_init(&cap); - KUNIT_EXPECT_EQ(test, cap.published_percent, ASAHI_GPU_UNPUBLISHED); - KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, 0, 100, fake_publish, &fake), 0); - KUNIT_EXPECT_EQ(test, cap.requested_state, 0U); - KUNIT_EXPECT_EQ(test, cap.published_percent, 25U); - for (i = 0; i < 3; i++) - KUNIT_EXPECT_EQ(test, fake.words[i], 25U); + struct fake_actuator fake = { .ppm_budget_mw = 7000 }; + + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_init(&cap, 9550), 0); + KUNIT_EXPECT_EQ(test, cap.applied_mw, 0U); + KUNIT_EXPECT_EQ(test, cap.requested_state, 100U); + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, 100, fake_publish, &fake), 0); + KUNIT_EXPECT_EQ(test, fake.region_c_mw, 2387U); + asahi_gpu_cap_update(&cap, 0, fake_publish, &fake); + KUNIT_EXPECT_EQ(test, fake.region_c_mw, 9550U); + KUNIT_EXPECT_EQ(test, fake.ppm_target_mw, 7000U); + KUNIT_EXPECT_EQ(test, fake.ppm_budget_mw, 7000U); } static void cap_failure_and_invalid(struct kunit *test) { struct asahi_gpu_cap cap; - struct fake_actuator fake = {}; + struct fake_actuator fake = { .ppm_budget_mw = 10000 }; unsigned int calls; - asahi_gpu_cap_init(&cap); - KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, 99, 100, fake_publish, &fake), 0); + asahi_gpu_cap_init(&cap, 10000); + asahi_gpu_cap_update(&cap, 70, fake_publish, &fake); fake.error = -5; - KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, 0, 100, fake_publish, &fake), -5); - KUNIT_EXPECT_EQ(test, cap.requested_state, 99U); - KUNIT_EXPECT_EQ(test, cap.published_percent, 1U); - KUNIT_EXPECT_EQ(test, fake.words[0], 1U); + /* Failed relaxation and failed tightening both keep the old restriction. */ + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, 0, fake_publish, &fake), -5); + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, 100, fake_publish, &fake), -5); + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_request(&cap, ASAHI_GPU_CAP_MANUAL, 2500, fake_publish, &fake), -5); + KUNIT_EXPECT_EQ(test, cap.requested_state, 70U); + KUNIT_EXPECT_EQ(test, cap.applied_mw, 3000U); + KUNIT_EXPECT_EQ(test, cap.requests[ASAHI_GPU_CAP_MANUAL], 10000U); + KUNIT_EXPECT_EQ(test, fake.region_c_mw, 3000U); + KUNIT_EXPECT_EQ(test, fake.ppm_target_mw, 3000U); calls = fake.calls; - KUNIT_EXPECT_LT(test, asahi_gpu_cap_update(&cap, ULONG_MAX, 100, fake_publish, &fake), 0); - KUNIT_EXPECT_LT(test, asahi_gpu_cap_update(&cap, 0, 101, fake_publish, &fake), 0); + KUNIT_EXPECT_LT(test, asahi_gpu_cap_update(&cap, ULONG_MAX, fake_publish, &fake), 0); + KUNIT_EXPECT_LT(test, asahi_gpu_cap_request(&cap, ASAHI_GPU_CAP_SOURCES, 3000, fake_publish, &fake), 0); + KUNIT_EXPECT_LT(test, asahi_gpu_cap_request(&cap, ASAHI_GPU_CAP_SYSTEM, 0, fake_publish, &fake), 0); + KUNIT_EXPECT_LT(test, asahi_gpu_cap_request(&cap, ASAHI_GPU_CAP_SYSTEM, 2499, fake_publish, &fake), 0); + KUNIT_EXPECT_LT(test, asahi_gpu_cap_request(&cap, ASAHI_GPU_CAP_SYSTEM, 10001, fake_publish, &fake), 0); KUNIT_EXPECT_EQ(test, fake.calls, calls); - KUNIT_EXPECT_EQ(test, cap.published_percent, 1U); + KUNIT_EXPECT_EQ(test, cap.applied_mw, 3000U); } -static void cap_recovery(struct kunit *test) +static void cap_recovery_and_limits(struct kunit *test) { struct asahi_gpu_cap cap; - struct fake_actuator fake = {}; - unsigned int i; - - asahi_gpu_cap_init(&cap); - KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, 99, 100, fake_publish, &fake), 0); - for (i = 0; i < 3; i++) - fake.words[i] = 100; /* Firmware reset: rearm before reopening. */ - KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, cap.requested_state, 100, - fake_publish, &fake), 0); - for (i = 0; i < 3; i++) - KUNIT_EXPECT_EQ(test, fake.words[i], 1U); - /* Removing a thermal demand still cannot lift qualification. */ - KUNIT_EXPECT_EQ(test, asahi_gpu_cap_update(&cap, 0, 100, fake_publish, &fake), 0); - KUNIT_EXPECT_EQ(test, cap.published_percent, 25U); + struct fake_actuator fake = { .ppm_budget_mw = UINT_MAX }; + + KUNIT_EXPECT_LT(test, asahi_gpu_cap_init(&cap, 0), 0); + asahi_gpu_cap_init(&cap, 1); + asahi_gpu_cap_update(&cap, 100, fake_publish, &fake); + KUNIT_EXPECT_EQ(test, cap.applied_mw, 1U); + asahi_gpu_cap_init(&cap, UINT_MAX); + asahi_gpu_cap_update(&cap, 0, fake_publish, &fake); + KUNIT_EXPECT_EQ(test, cap.applied_mw, UINT_MAX); + asahi_gpu_cap_init(&cap, 10000); + asahi_gpu_cap_update(&cap, 0, fake_publish, &fake); + asahi_gpu_cap_request(&cap, ASAHI_GPU_CAP_MANUAL, 3000, fake_publish, &fake); + fake.region_c_mw = 10000; + fake.ppm_target_mw = 10000; + KUNIT_EXPECT_EQ(test, asahi_gpu_cap_rearm(&cap, fake_publish, &fake), 0); + KUNIT_EXPECT_EQ(test, fake.region_c_mw, 3000U); + KUNIT_EXPECT_EQ(test, fake.ppm_target_mw, 3000U); + KUNIT_EXPECT_EQ(test, cap.requested_state, 0U); } #ifdef ASAHI_HOST_TEST @@ -128,19 +173,19 @@ int main(void) cap_mapping(&test); cap_composition(&test); - cap_startup_and_mirrors(&test); + cap_startup_and_ppm(&test); cap_failure_and_invalid(&test); - cap_recovery(&test); - puts("PASS: cap mapping, composition, startup, mirror transaction, failure, recovery"); + cap_recovery_and_limits(&test); + puts("PASS: mW mapping, all-owner composition, startup, separate PPM, failure, recovery, limits"); return 0; } #else static struct kunit_case asahi_gpu_cooling_cases[] = { KUNIT_CASE(cap_mapping), KUNIT_CASE(cap_composition), - KUNIT_CASE(cap_startup_and_mirrors), + KUNIT_CASE(cap_startup_and_ppm), KUNIT_CASE(cap_failure_and_invalid), - KUNIT_CASE(cap_recovery), + KUNIT_CASE(cap_recovery_and_limits), {} }; static struct kunit_suite asahi_gpu_cooling_suite = { diff --git a/drivers/gpu/drm/asahi/g17/cooling.rs b/drivers/gpu/drm/asahi/g17/cooling.rs index 6f203ff74376b..bd8e5f1fd6966 100644 --- a/drivers/gpu/drm/asahi/g17/cooling.rs +++ b/drivers/gpu/drm/asahi/g17/cooling.rs @@ -1,23 +1,31 @@ // SPDX-License-Identifier: GPL-2.0-only OR MIT -//! Common G16S/G17P percent-ceiling owner. No PMP vote or effort-floor write. +//! Common G16S/G17P absolute-power ceiling owner. use super::{fw::variant::Variant, initdata::InitData}; use core::{ffi::c_void, ptr::NonNull}; use kernel::{c_str, device, prelude::*, sync::aref::ARef}; extern "C" { - fn asahi_gpu_cooling_register(dev: *mut c_void, mirrors: *const *mut u32) -> *mut c_void; + fn asahi_gpu_cooling_register(dev: *mut c_void, words: *const PowerWords) -> *mut c_void; fn asahi_gpu_cooling_unregister(cooling: *mut c_void); fn asahi_gpu_cooling_rearm(cooling: *mut c_void); } -/// A fully resolved layout in the WC hardware-data bundle. Offsets include -/// the allocation-relative base, not an offset into a host driver object. -/// Only firmware ABI tables may supply these; DT never supplies addresses. +/// Exact RegionC/PowerState pairing admitted for live publication. #[derive(Clone, Copy)] -pub(crate) struct Layout { - pub(crate) mirrors: [usize; 3], +pub(crate) enum Layout { + /// G17P 26A428 and G16S 25G83, RegionC::max_power_mw at +0x84. + Common, +} + +/// C ABI; these are independent typed members, never numeric bundle offsets. +#[repr(C)] +pub(super) struct PowerWords { + pub(super) max_power_mw: *mut u32, + pub(super) ppm_enabled: *mut u32, + pub(super) ppm_target_mw: *mut u32, + pub(super) ppm_writeback: bool, } fn required(dev: &device::Device) -> Result { @@ -35,11 +43,8 @@ fn required(dev: &device::Device) -> Result { /// Check before starting either processor. A board requiring cooling must /// never silently fall back to unrestricted submission with a missing ABI. pub(super) fn admit(dev: &device::Device, variant: &Variant) -> Result { - if required(dev)? && variant.power_ceiling.is_none() { - dev_err!( - dev, - "GPU cooling ABI base unresolved; refusing GPU initialization\n" - ); + if required(dev)? && variant.live_power.is_none() { + dev_err!(dev, "GPU live power layout not admitted\n"); return Err(EOPNOTSUPP); } Ok(()) @@ -67,13 +72,13 @@ impl Cooling { if !required(dev)? { return Ok(None); } - let layout = variant.power_ceiling.as_ref().ok_or(EOPNOTSUPP)?; - let mirrors = init.cooling_mirrors(layout)?; - // SAFETY: The owner keeps all validated WC words mapped until after - // Drop drains the C callbacks. Registration publishes the 25% backstop - // before INIT, port attachment or any work publication. + let layout = variant.live_power.as_ref().ok_or(EOPNOTSUPP)?; + let words = init.cooling_words(layout)?; + // SAFETY: The owner keeps all validated shared words mapped until after + // Drop drains the C callbacks. Registration publishes the provisional + // 25% floor before INIT, port attachment or any work publication. let inner = kernel::error::from_err_ptr(unsafe { - asahi_gpu_cooling_register(dev.as_raw().cast(), mirrors.as_ptr()) + asahi_gpu_cooling_register(dev.as_raw().cast(), &words) })?; Ok(Some(Self { inner: NonNull::new(inner).ok_or(ENOMEM)?, @@ -82,7 +87,7 @@ impl Cooling { } pub(super) fn rearm(&self) { - // SAFETY: The C allocation and all three mappings are still owned. + // SAFETY: The C allocation and the power mappings are still owned. unsafe { asahi_gpu_cooling_rearm(self.inner.as_ptr()) }; } } diff --git a/drivers/gpu/drm/asahi/g17/fw/initdata.rs b/drivers/gpu/drm/asahi/g17/fw/initdata.rs index 89b618f244daa..976db04e66aeb 100644 --- a/drivers/gpu/drm/asahi/g17/fw/initdata.rs +++ b/drivers/gpu/drm/asahi/g17/fw/initdata.rs @@ -1385,6 +1385,7 @@ static_assert!(core::mem::offset_of!(RegionC, idle_power_off_delay) == 0x9bc); static_assert!(core::mem::offset_of!(RegionC, compute_watchdog) == 0x9cc); static_assert!(core::mem::offset_of!(RegionC, power_assert_tally) == 0xe51); static_assert!(size_of::() == 0x1000); +static_assert!(core::mem::offset_of!(RegionC, max_power_mw) == 0x84); // SAFETY: `RegionC` consists of integers and arrays of integers only. unsafe impl Zeroable for RegionC {} @@ -1813,8 +1814,6 @@ const POWER_STATE_WORDS: Words = &[ (0x108, 0x42c80000, 1), (0x10c, 0x43c80000, 1), (0x110, 0xc8, 1), - (0x128, 1, 1), - (0x12c, 0x2616, 1), (0x130, 0x3f000000, 1), (0x134, 0x40cccccd, 1), (0x14c, 1, 1), @@ -1900,15 +1899,21 @@ const SECONDARY_CONFIG_WORDS: Words = &[ /// Power state the primary status B carries for the secondary instance, /// named by [`SecondaryRoot::power_state_va`]. -#[repr(C)] -pub(crate) struct PowerState(pub(crate) [u8; 0x6c0]); +pub(crate) use super::power::PowerState; -// SAFETY: `PowerState` is a byte array. +// SAFETY: `PowerState` contains only integers and byte arrays. unsafe impl Zeroable for PowerState {} impl PowerState { fn init(&mut self) { - fill_words(&mut self.0, POWER_STATE_WORDS); + // SAFETY: The repr(C) object consists entirely of initialized integer + // and byte-array storage; every bit pattern is valid. + let bytes = unsafe { + core::slice::from_raw_parts_mut(core::ptr::from_mut(self).cast(), size_of::()) + }; + fill_words(bytes, POWER_STATE_WORDS); + self.ppm_enabled = 1; + self.ppm_target_mw = 9750; } } diff --git a/drivers/gpu/drm/asahi/g17/fw/mod.rs b/drivers/gpu/drm/asahi/g17/fw/mod.rs index 1cb46fce2d602..042eb261acde5 100644 --- a/drivers/gpu/drm/asahi/g17/fw/mod.rs +++ b/drivers/gpu/drm/asahi/g17/fw/mod.rs @@ -19,6 +19,7 @@ pub(crate) mod context; pub(crate) mod freelist; pub(crate) mod initdata; pub(crate) mod kick; +pub(crate) mod power; pub(crate) mod queue; pub(crate) mod render; pub(crate) mod render_rt; diff --git a/drivers/gpu/drm/asahi/g17/fw/power.rs b/drivers/gpu/drm/asahi/g17/fw/power.rs new file mode 100644 index 0000000000000..46d39ab5db7f2 --- /dev/null +++ b/drivers/gpu/drm/asahi/g17/fw/power.rs @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT + +//! Typed absolute-power inputs. These are separate firmware objects/fields. + +/// Power-state layout shared by the admitted G17P and G16S builds. +/// Alignment stays one for embedding in packed PrimaryStatusB. The live +/// publisher separately validates the natural alignment of each u32 mapping. +#[repr(C, packed)] +pub(crate) struct PowerState { + pub(crate) prefix: [u8; 0x128], + pub(crate) ppm_enabled: u32, + /// Absolute ApplePPM budget in milliwatts, independent of RegionC's maximum. + pub(crate) ppm_target_mw: u32, + pub(crate) suffix: [u8; 0x590], +} + +/// G16S 26A428 has a different RegionC prefix. This type records that boundary +/// only: there is no admitted graph/variant for it, so it cannot be published. +#[repr(C)] +pub(crate) struct RegionCPowerG16S26A428 { + pub(crate) prefix: [u8; 0x88], + pub(crate) max_power_mw: u32, +} + +const _: () = { + assert!(core::mem::offset_of!(PowerState, ppm_enabled) == 0x128); + assert!(core::mem::offset_of!(PowerState, ppm_target_mw) == 0x12c); + assert!(core::mem::size_of::() == 0x6c0); + assert!(core::mem::offset_of!(RegionCPowerG16S26A428, max_power_mw) == 0x88); +}; diff --git a/drivers/gpu/drm/asahi/g17/fw/variant.rs b/drivers/gpu/drm/asahi/g17/fw/variant.rs index 61e76d1f6b89b..1ac6e55df3f77 100644 --- a/drivers/gpu/drm/asahi/g17/fw/variant.rs +++ b/drivers/gpu/drm/asahi/g17/fw/variant.rs @@ -46,9 +46,8 @@ pub(crate) enum QueueRegistration { /// The layouts and rules of one G17 firmware build. #[derive(Copy, Clone)] pub(crate) struct Variant { - /// Resolved, allocation-relative, live percent-ceiling mirrors. - /// The clean setGPUMaxPower offsets alone do not identify an allocation. - pub(crate) power_ceiling: Option, + /// Admitted live RegionC/PowerState layout. No host-object mirror model. + pub(crate) live_power: Option, /// The initialization graph. pub(crate) graph: InitGraph, /// How the firmware acknowledges its initialization. @@ -105,8 +104,7 @@ pub(crate) enum Firmware { /// The A18 Pro firmware (26A428). pub(crate) const V26A428: Variant = Variant { - // 0xf150/0xf2d0/0xf39c have no qualified allocation base yet. - power_ceiling: None, + live_power: Some(crate::g17::cooling::Layout::Common), graph: InitGraph::G17P, init_ack: InitAck::Message, power_on_done: true, @@ -130,8 +128,7 @@ pub(crate) const V26A428: Variant = Variant { /// The M4 Pro firmware (25G83, `mBoot-18000.161.10`). pub(crate) const V25G83: Variant = Variant { - // No independently established 25G83 mirror layout. - power_ceiling: None, + live_power: Some(crate::g17::cooling::Layout::Common), graph: InitGraph::V25G83, init_ack: InitAck::Status, // Never sent on the M4 Pro: the firmware has retired its opening record when it accepts @@ -162,6 +159,8 @@ pub(crate) const V25G83: Variant = Variant { }; pub(crate) const V25F84: Variant = Variant { + // This build has not been admitted for the live power actuator. + live_power: None, qid_floor: 0, registration: QueueRegistration::Mailbox, compute: super::compute::ComputeProgram::V25F84, diff --git a/drivers/gpu/drm/asahi/g17/initdata.rs b/drivers/gpu/drm/asahi/g17/initdata.rs index 2377bc4c72c38..24ad43e96d8dc 100644 --- a/drivers/gpu/drm/asahi/g17/initdata.rs +++ b/drivers/gpu/drm/asahi/g17/initdata.rs @@ -157,8 +157,9 @@ impl WorkPublication<'_> { /// Session-long storage and mappings. Aliases are released before their backing objects. pub(super) struct InitData { - // Live publication uses interior writes under the device mutex. This owner is Send but not - // Sync, so safe host code cannot issue those writes concurrently through shared references. + // Live effort publication uses interior writes under the device mutex. Power-ceiling + // fields are handed to the cooling owner and serialized by its separate mutex. This owner + // is Send but not Sync; safe host code cannot publish effort concurrently through &self. _single_publisher: core::marker::PhantomData>, aliases: KVec, objects: KVec, @@ -166,6 +167,7 @@ pub(super) struct InitData { cluster: usize, bundle: usize, region_c: usize, + power_state: Option<(usize, usize, bool)>, qos: usize, pb: usize, page_pool: usize, @@ -269,6 +271,7 @@ impl InitData { cluster: 0, bundle: 0, region_c: 0, + power_state: None, qos: 0, pb: 0, page_pool: 0, @@ -1193,6 +1196,11 @@ impl InitData { .write(abi::private::PRIMARY_STATUS_A, abi::StatusBlock::new())?; self.object_mut(self.cluster)? .write(abi::private::SECONDARY_STATUS_A, abi::StatusBlock::new())?; + self.power_state = Some(( + self.cluster, + abi::private::STATUS_B + abi::PrimaryStatusB::POWER_STATE, + true, + )); let fwctl_va = self.object(tables.fwctl)?.gpu_va(); self.object_mut(self.cluster)? .initialize::(abi::private::STATUS_B, |status| { @@ -1357,18 +1365,27 @@ impl InitData { Ok(()) } - /// Validate all three WC destinations before passing any pointer to C. - /// No partial transaction is possible on an invalid table entry. - pub(super) fn cooling_mirrors(&self, layout: &super::cooling::Layout) -> Result<[*mut u32; 3]> { - let bundle = self.object(self.bundle)?; - let mut mirrors = [core::ptr::null_mut(); 3]; - for (index, &offset) in layout.mirrors.iter().enumerate() { - if offset % 4 != 0 || layout.mirrors[..index].contains(&offset) { - return Err(EINVAL); - } - mirrors[index] = bundle.pointer(offset, 4)?.cast(); - } - Ok(mirrors) + /// Resolve typed fields from their retained objects before any store. + pub(super) fn cooling_words( + &self, + layout: &super::cooling::Layout, + ) -> Result { + let super::cooling::Layout::Common = layout; + let region = self.object(self.region_c)?; + let (index, offset, ppm_writeback) = self.power_state.ok_or(EOPNOTSUPP)?; + let power = self.object(index)?; + Ok(super::cooling::PowerWords { + max_power_mw: region + .pointer(core::mem::offset_of!(abi::RegionC, max_power_mw), 4)? + .cast(), + ppm_enabled: power + .pointer(offset + core::mem::offset_of!(abi::PowerState, ppm_enabled), 4)? + .cast(), + ppm_target_mw: power + .pointer(offset + core::mem::offset_of!(abi::PowerState, ppm_target_mw), 4)? + .cast(), + ppm_writeback, + }) } pub(super) fn effort(&self) -> Result { diff --git a/drivers/gpu/drm/asahi/g17/initdata/v25g83.rs b/drivers/gpu/drm/asahi/g17/initdata/v25g83.rs index f7b1952685761..e07b9cfff5f56 100644 --- a/drivers/gpu/drm/asahi/g17/initdata/v25g83.rs +++ b/drivers/gpu/drm/asahi/g17/initdata/v25g83.rs @@ -104,6 +104,7 @@ impl InitData { false => self.object(objects.aon)?.gpu_va(), }; let power_state_va = self.object(objects.power_state)?.gpu_va(); + self.power_state = Some((objects.power_state, 0, false)); let firmware_area_va = self.object(objects.firmware_area)?.gpu_va(); let firmware_area_2_va = match objects.firmware_area_2 { Some(index) => self.object(index)?.gpu_va(), diff --git a/tools/testing/selftests/drivers/apple/gpu-cooling.py b/tools/testing/selftests/drivers/apple/gpu-cooling.py index 3fa4483f63c06..4b3ed0a7075a8 100755 --- a/tools/testing/selftests/drivers/apple/gpu-cooling.py +++ b/tools/testing/selftests/drivers/apple/gpu-cooling.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0-only OR MIT -"""Run the production percent-cap suite on the host, without a GPU.""" +"""Run the production absolute-power cap suite on the host, without a GPU.""" import os from pathlib import Path import subprocess @@ -13,3 +13,25 @@ subprocess.run([os.environ.get("HOSTCC", "cc"), "-std=gnu11", "-Wall", "-Wextra", "-Werror", "-DASAHI_HOST_TEST", str(source), "-o", binary], check=True) subprocess.run([binary], check=True) + + # Compile the exact typed firmware members independently of the kernel. + power = root / "drivers/gpu/drm/asahi/g17/fw/power.rs" + rust = Path(work) / "power.rs" + rust.write_text(f'''#![allow(dead_code)] +#[path = "{power}"] mod power; +fn main() {{ + assert_eq!(core::mem::offset_of!(power::PowerState, ppm_target_mw), 0x12c); + assert_eq!(core::mem::offset_of!(power::RegionCPowerG16S26A428, max_power_mw), 0x88); + let mut p = power::PowerState {{ prefix: [0xa5; 0x128], ppm_enabled: 1, + ppm_target_mw: 9750, suffix: [0x5a; 0x590] }}; + p.ppm_target_mw = 2387; + let enabled = p.ppm_enabled; + assert_eq!(enabled, 1); + assert!(p.prefix.iter().all(|v| *v == 0xa5)); + assert!(p.suffix.iter().all(|v| *v == 0x5a)); + println!("PASS: separate typed PPM fields, canaries, unadmitted G16S 26A428 +0x88"); +}} +''') + subprocess.run([os.environ.get("RUSTC", "rustc"), "--edition=2021", str(rust), + "-o", binary], check=True) + subprocess.run([binary], check=True) From 6f11998df45b9424e0174ce61e7f8154eb8cb5fa Mon Sep 17 00:00:00 2001 From: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Date: Sat, 7 Nov 2026 00:03:31 +1100 Subject: [PATCH 07/14] drm/asahi: preserve WC ordering for both PPM mappings Both admitted PowerState objects use write-combined CPU mappings. Keep cache cleaning confined to the write-back RegionC allocation and complete the PPM stores with the publication barrier. Assisted-by: LLM Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> --- Documentation/gpu/asahi-gpu-thermal.rst | 4 ++-- drivers/gpu/drm/asahi/cooling.c | 4 ---- drivers/gpu/drm/asahi/cooling.h | 3 +-- drivers/gpu/drm/asahi/g17/cooling.rs | 1 - drivers/gpu/drm/asahi/g17/initdata.rs | 6 ++---- drivers/gpu/drm/asahi/g17/initdata/v25g83.rs | 2 +- 6 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Documentation/gpu/asahi-gpu-thermal.rst b/Documentation/gpu/asahi-gpu-thermal.rst index 535e9d6d34863..95dd3ad3ad0ef 100644 --- a/Documentation/gpu/asahi-gpu-thermal.rst +++ b/Documentation/gpu/asahi-gpu-thermal.rst @@ -47,8 +47,8 @@ before reopening consumption. Teardown drains debugfs, sysfs and thermal callbacks before stopping processors or freeing mappings. RegionC is CPU write-back memory, so publication includes a clean to the point -of coherency. G17P PowerState also needs cleaning; G16S 25G83 PowerState is -write-combined. Store ordering is completed before host publication is +of coherency. Both admitted PowerState mappings are write-combined and use +store ordering rather than cache cleaning. Ordering is completed before publication is reported. There is no firmware mailbox, doorbell or acknowledgement for these inputs. Shared-memory readback proves publication, not achieved GPU power. diff --git a/drivers/gpu/drm/asahi/cooling.c b/drivers/gpu/drm/asahi/cooling.c index a60d027d85bcc..a5d945e7cb36f 100644 --- a/drivers/gpu/drm/asahi/cooling.c +++ b/drivers/gpu/drm/asahi/cooling.c @@ -46,10 +46,6 @@ static int asahi_gpu_publish_cap(void *context, unsigned int mw) */ WRITE_ONCE(*words->ppm_target_mw, ppm); WRITE_ONCE(*words->ppm_enabled, 1); - if (words->ppm_writeback) { - clean_word(words->ppm_target_mw); - clean_word(words->ppm_enabled); - } WRITE_ONCE(*words->max_power_mw, mw); clean_word(words->max_power_mw); wmb(); diff --git a/drivers/gpu/drm/asahi/cooling.h b/drivers/gpu/drm/asahi/cooling.h index c0fe65ada52d0..5c15f76347be6 100644 --- a/drivers/gpu/drm/asahi/cooling.h +++ b/drivers/gpu/drm/asahi/cooling.h @@ -7,13 +7,12 @@ struct device; struct asahi_gpu_cooling; /* Separate typed fields, retained until unregister drains every callback. - * RegionC is WB; PowerState may be WC (25G83) or WB (G17P). + * RegionC is WB; both admitted PowerState mappings are WC. */ struct asahi_gpu_power_words { u32 *max_power_mw; u32 *ppm_enabled; u32 *ppm_target_mw; - bool ppm_writeback; }; struct asahi_gpu_cooling *asahi_gpu_cooling_register(struct device *dev, const struct asahi_gpu_power_words *words); diff --git a/drivers/gpu/drm/asahi/g17/cooling.rs b/drivers/gpu/drm/asahi/g17/cooling.rs index bd8e5f1fd6966..63ce24b8490ee 100644 --- a/drivers/gpu/drm/asahi/g17/cooling.rs +++ b/drivers/gpu/drm/asahi/g17/cooling.rs @@ -25,7 +25,6 @@ pub(super) struct PowerWords { pub(super) max_power_mw: *mut u32, pub(super) ppm_enabled: *mut u32, pub(super) ppm_target_mw: *mut u32, - pub(super) ppm_writeback: bool, } fn required(dev: &device::Device) -> Result { diff --git a/drivers/gpu/drm/asahi/g17/initdata.rs b/drivers/gpu/drm/asahi/g17/initdata.rs index 24ad43e96d8dc..f5930c1f3854b 100644 --- a/drivers/gpu/drm/asahi/g17/initdata.rs +++ b/drivers/gpu/drm/asahi/g17/initdata.rs @@ -167,7 +167,7 @@ pub(super) struct InitData { cluster: usize, bundle: usize, region_c: usize, - power_state: Option<(usize, usize, bool)>, + power_state: Option<(usize, usize)>, qos: usize, pb: usize, page_pool: usize, @@ -1199,7 +1199,6 @@ impl InitData { self.power_state = Some(( self.cluster, abi::private::STATUS_B + abi::PrimaryStatusB::POWER_STATE, - true, )); let fwctl_va = self.object(tables.fwctl)?.gpu_va(); self.object_mut(self.cluster)? @@ -1372,7 +1371,7 @@ impl InitData { ) -> Result { let super::cooling::Layout::Common = layout; let region = self.object(self.region_c)?; - let (index, offset, ppm_writeback) = self.power_state.ok_or(EOPNOTSUPP)?; + let (index, offset) = self.power_state.ok_or(EOPNOTSUPP)?; let power = self.object(index)?; Ok(super::cooling::PowerWords { max_power_mw: region @@ -1384,7 +1383,6 @@ impl InitData { ppm_target_mw: power .pointer(offset + core::mem::offset_of!(abi::PowerState, ppm_target_mw), 4)? .cast(), - ppm_writeback, }) } diff --git a/drivers/gpu/drm/asahi/g17/initdata/v25g83.rs b/drivers/gpu/drm/asahi/g17/initdata/v25g83.rs index e07b9cfff5f56..b34c2703aedb7 100644 --- a/drivers/gpu/drm/asahi/g17/initdata/v25g83.rs +++ b/drivers/gpu/drm/asahi/g17/initdata/v25g83.rs @@ -104,7 +104,7 @@ impl InitData { false => self.object(objects.aon)?.gpu_va(), }; let power_state_va = self.object(objects.power_state)?.gpu_va(); - self.power_state = Some((objects.power_state, 0, false)); + self.power_state = Some((objects.power_state, 0)); let firmware_area_va = self.object(objects.firmware_area)?.gpu_va(); let firmware_area_2_va = match objects.firmware_area_2 { Some(index) => self.object(index)?.gpu_va(), From 5e23eb258cd056486e1cfb3910cc38e056070eac Mon Sep 17 00:00:00 2001 From: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Date: Sat, 7 Nov 2026 13:15:47 +1100 Subject: [PATCH 08/14] docs: describe PWR qualification for Neo and J616s cooling Require board binding, bounded load transitions, matched gpubench parity, boot-log warning parity and enforcing SELinux audit evidence per board. Record the missing J616s GPU binding as a prerequisite for a separate board-policy change. Assisted-by: LLM Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> --- Documentation/gpu/asahi-gpu-thermal.rst | 42 ++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/Documentation/gpu/asahi-gpu-thermal.rst b/Documentation/gpu/asahi-gpu-thermal.rst index 95dd3ad3ad0ef..b1a191df80089 100644 --- a/Documentation/gpu/asahi-gpu-thermal.rst +++ b/Documentation/gpu/asahi-gpu-thermal.rst @@ -115,18 +115,29 @@ Compile ``apple/t8140-j700.dtb`` and check the outer policy:: These tests do not qualify firmware-achieved power or a safe minimum. -Owner Neo one-shot plan ------------------------ +PWR owner qualification: Neo and J616s +------------------------------------- -This revision performs no device test. Request a separate controller-approved -Neo one-shot, identifying the device, exact source and boot artifacts. Build -with the unique release suffix ``-aurora-t5062-gpu-cooling-v2-01``; verify +This revision performs no device test. Request separate controller-approved +one-shots for Neo (G17P) and J616s (G16S), identifying each device, exact +source and boot artifacts. Build +with the unique release suffix ``-aurora-t5402-gpu-cooling-v2-01``; verify ``uname -r`` matches it after boot. Preserve the fleet-default kernel/DTB, artifact hashes, boot entry and bootguard fallback before staging. Record candidate and fleet commits, firmware identity, Mesa, workload, power source, ambient conditions and starting temperatures. Keep private lab records outside the public source tree. +J700 supplies the GPU cooling binding and outer policy in this series. +J616s currently has no GPU ``#cooling-cells`` or GPU cooling-map references; +the actuator is therefore not attached there. Before qualifying J616s, +the PWR owner must review a separate board policy with indexed sensor +identities, trips, hysteresis, independent critical actions and exact GPU +cooling states. Validate its compiled DTB and firmware admission before +requesting a one-shot. Existing CPU cooling maps do not qualify GPU binding. +An absent GPU cooling device or zone link is a failed prerequisite, never +evidence that G16S thermal integration passed. + First boot with no GPU load. Verify the cooling device, independent thermal zones, all critical trips, requested/applied/readback agreement and nonzero PPM target. Set state 100 and verify the initialized maximum's 25 percent @@ -153,6 +164,27 @@ and cooling residency against fleet default, labeling different power caps. Readback is not achieved-power evidence. Qualifying a lower floor requires independent achieved-state evidence and a separately reviewed test. +For each board, retain a thermal-zone-to-cooling-device inventory and a +timestamped trace of governor-driven state transitions under the bounded +GPU load, including hysteresis and overlapping zone demands. Exercise both +restriction and relaxation without lowering critical trips. Keep load +bounded by the independent supervisor and the initial burst limits above. + +After those stages pass, request a separately bounded gpubench comparison +using the same Mesa, workload, resolution, power cap, power source and cool +starting conditions on fleet default and candidate. Use repeated samples; +retain throughput and frame-time distributions. Accept only no regression +outside the matched baseline's measured repeatability; differing caps or +conditions require a new matched comparison. Do not treat expected throttling +at a different cap as a performance-parity result. + +Capture complete boot logs and SELinux audit evidence for both kernels on +each device. Require zero new boot-log warnings against the matched baseline +and zero AVCs with SELinux enforcing throughout boot and the workload. Keep +all failures and the restored-kernel checks with the qualification receipt. +Neither board is qualified until binding, load transitions, gpubench parity, +boot-log comparison and SELinux checks have all passed on that board. + Stop bursts on a failed cap update, readback mismatch, missing or implausible telemetry, lost binding, GPU fault or supervisor action. Keep the strongest request, preserve traces and restore the fleet-default kernel/DTB using the From df7f7f1ced3d40d0a6dfb35cc4c6ae9cd111af87 Mon Sep 17 00:00:00 2001 From: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Date: Sun, 8 Nov 2026 06:52:07 +1100 Subject: [PATCH 09/14] arm64: dts: apple: t8140-j700: no critical trips on the new SMC zones The ten SMC thermal zones added for GPU cooling (Tp0t, TCMz, Ts0A/I/M, Tp02/06/0E, Tpx1/3) each had a critical trip with a shutdown action. Their sensors are referenced by index into the SMC hwmon channel list, and none of them has been read on hardware against its key yet. If an index points at the wrong channel, or a key reads a bogus value at boot, the thermal core powers the machine off, and a powered-off Mac recovers from neither the boot watchdog nor a trial fallback. A J700 went down that way during a trial boot of this tree. Drop the critical trips and the critical-action properties from those ten zones. The cap ladder and the hot trips stay, so the GPU cooling policy is unchanged. The six CPU zones are untouched. Critical trips come back per zone once its sensor has been checked on hardware with the trips disabled; until then the SMC and the platform firmware keep their own overtemperature protection. The selftest now requires that these zones carry no critical trip, and the documentation says why. Assisted-by: LLM Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> --- Documentation/gpu/asahi-gpu-thermal.rst | 28 +++++--- arch/arm64/boot/dts/apple/t8140-j700.dts | 67 ++----------------- .../drivers/apple/j700-thermal-dt.py | 13 ++-- 3 files changed, 30 insertions(+), 78 deletions(-) diff --git a/Documentation/gpu/asahi-gpu-thermal.rst b/Documentation/gpu/asahi-gpu-thermal.rst index b1a191df80089..440709312fe84 100644 --- a/Documentation/gpu/asahi-gpu-thermal.rst +++ b/Documentation/gpu/asahi-gpu-thermal.rst @@ -36,7 +36,7 @@ rounded down in milliwatts, with a minimum of one milliwatt for tiny test inputs. The 25 percent floor is **provisional**, not a qualified board minimum or a claim about a physical pstate. State 100 does not publish zero or stop the GPU. Absolute requests below the provisional floor are rejected, preserving -the previous restriction. Critical shutdown remains independent of GPU work. +the previous restriction. Registration publishes the floor before INIT, port attachment and submission; its initial cooling state is 100. The governor may subsequently relax its own @@ -62,15 +62,21 @@ bring-up policy, not device safety ratings. The intentional missing-actuator J700 initialization refusal is removed for the admitted layout; invalid mappings, absent initialized power and unknown firmware still fail closed. -J700 has independent SMC thermal zones and critical shutdown actions: +J700 has independent SMC thermal zones: -=================== ===================== ============= ======== -Zones Cap temperatures (C) Hot (C) Critical -=================== ===================== ============= ======== -Tp*/Tpx* 85, 88, 92, 95 92 98 C -Charger (TCMz) 80, 83, 88, 92 88 95 C -Chassis (Ts0A/I/M) 70, 75, 80, 85 80 88 C -=================== ===================== ============= ======== +=================== ===================== ============= +Zones Cap temperatures (C) Hot (C) +=================== ===================== ============= +Tp*/Tpx* 85, 88, 92, 95 92 +Charger (TCMz) 80, 83, 88, 92 88 +Chassis (Ts0A/I/M) 70, 75, 80, 85 80 +=================== ===================== ============= + +These zones have no critical trips. A sensor index that reads the wrong +channel, or a value the driver misparses, must never power the machine off. +Critical trips are added per zone only after its sensor has been read and +matched to its key on hardware with the trips disabled. Until then the SMC +and the platform firmware keep their own overtemperature protection. Cooling states 25, 50, 75 and 100 apply 75, 50, 25 and the provisional 25 percent floor, with 5 C hysteresis. The last two states deliberately @@ -132,14 +138,14 @@ J700 supplies the GPU cooling binding and outer policy in this series. J616s currently has no GPU ``#cooling-cells`` or GPU cooling-map references; the actuator is therefore not attached there. Before qualifying J616s, the PWR owner must review a separate board policy with indexed sensor -identities, trips, hysteresis, independent critical actions and exact GPU +identities, trips, hysteresis and exact GPU cooling states. Validate its compiled DTB and firmware admission before requesting a one-shot. Existing CPU cooling maps do not qualify GPU binding. An absent GPU cooling device or zone link is a failed prerequisite, never evidence that G16S thermal integration passed. First boot with no GPU load. Verify the cooling device, independent thermal -zones, all critical trips, requested/applied/readback agreement and nonzero +zones, sensor readings against their keys, requested/applied/readback agreement and nonzero PPM target. Set state 100 and verify the initialized maximum's 25 percent floor (2387 mW for a 9550 mW maximum), never zero. Check states 75, 50, 25 and 0 at no load, returning to 100 after each. Confirm the PPM word remains a diff --git a/arch/arm64/boot/dts/apple/t8140-j700.dts b/arch/arm64/boot/dts/apple/t8140-j700.dts index 07393fc40a1bd..5bae4c04032b6 100644 --- a/arch/arm64/boot/dts/apple/t8140-j700.dts +++ b/arch/arm64/boot/dts/apple/t8140-j700.dts @@ -403,15 +403,17 @@ * Provisional outer protection, not recovered Apple board limits. * The active-trip ladder works with the power_allocator governor's * non-power-actor path as well as step_wise. Equal map bounds give - * exact policy requests, with the strictest zone winning. Critical - * shutdown remains independent of GPU probe and forward progress. + * exact policy requests, with the strictest zone winning. These + * zones carry no critical trips: a sensor index that reads wrong + * must not power the machine off. Add them once each sensor has + * been checked against its key on hardware; until then the SMC and + * the platform firmware keep their own overtemperature protection. * The actuator bounds the last rung at its provisional nonzero floor. */ smc-tp0t-thermal { polling-delay-passive = <100>; polling-delay = <100>; thermal-sensors = <&smc_hwmon 6>; - critical-action = "shutdown"; trips { smc_tp0t_thermal_0: cap-0 { @@ -444,11 +446,6 @@ type = "hot"; }; - trip-critical { - temperature = <98000>; - hysteresis = <0>; - type = "critical"; - }; }; cooling-maps { @@ -475,7 +472,6 @@ polling-delay-passive = <100>; polling-delay = <100>; thermal-sensors = <&smc_hwmon 11>; /* TCMz */ - critical-action = "shutdown"; trips { charger_thermal_0: cap-0 { @@ -508,11 +504,6 @@ type = "hot"; }; - trip-critical { - temperature = <95000>; - hysteresis = <0>; - type = "critical"; - }; }; cooling-maps { @@ -539,7 +530,6 @@ polling-delay-passive = <100>; polling-delay = <100>; thermal-sensors = <&smc_hwmon 12>; /* Ts0A */ - critical-action = "shutdown"; trips { chassis1_thermal_0: cap-0 { @@ -572,11 +562,6 @@ type = "hot"; }; - trip-critical { - temperature = <88000>; - hysteresis = <0>; - type = "critical"; - }; }; cooling-maps { @@ -603,7 +588,6 @@ polling-delay-passive = <100>; polling-delay = <100>; thermal-sensors = <&smc_hwmon 13>; /* Ts0I */ - critical-action = "shutdown"; trips { chassis2_thermal_0: cap-0 { @@ -636,11 +620,6 @@ type = "hot"; }; - trip-critical { - temperature = <88000>; - hysteresis = <0>; - type = "critical"; - }; }; cooling-maps { @@ -667,7 +646,6 @@ polling-delay-passive = <100>; polling-delay = <100>; thermal-sensors = <&smc_hwmon 14>; /* Ts0M */ - critical-action = "shutdown"; trips { chassis3_thermal_0: cap-0 { @@ -700,11 +678,6 @@ type = "hot"; }; - trip-critical { - temperature = <88000>; - hysteresis = <0>; - type = "critical"; - }; }; cooling-maps { @@ -731,7 +704,6 @@ polling-delay-passive = <100>; polling-delay = <100>; thermal-sensors = <&smc_hwmon 50>; - critical-action = "shutdown"; trips { smc_tp02_thermal_0: cap-0 { @@ -764,11 +736,6 @@ type = "hot"; }; - trip-critical { - temperature = <98000>; - hysteresis = <0>; - type = "critical"; - }; }; cooling-maps { @@ -795,7 +762,6 @@ polling-delay-passive = <100>; polling-delay = <100>; thermal-sensors = <&smc_hwmon 52>; - critical-action = "shutdown"; trips { smc_tp06_thermal_0: cap-0 { @@ -828,11 +794,6 @@ type = "hot"; }; - trip-critical { - temperature = <98000>; - hysteresis = <0>; - type = "critical"; - }; }; cooling-maps { @@ -859,7 +820,6 @@ polling-delay-passive = <100>; polling-delay = <100>; thermal-sensors = <&smc_hwmon 56>; - critical-action = "shutdown"; trips { smc_tp0e_thermal_0: cap-0 { @@ -892,11 +852,6 @@ type = "hot"; }; - trip-critical { - temperature = <98000>; - hysteresis = <0>; - type = "critical"; - }; }; cooling-maps { @@ -923,7 +878,6 @@ polling-delay-passive = <100>; polling-delay = <100>; thermal-sensors = <&smc_hwmon 63>; - critical-action = "shutdown"; trips { smc_tpx1_thermal_0: cap-0 { @@ -956,11 +910,6 @@ type = "hot"; }; - trip-critical { - temperature = <98000>; - hysteresis = <0>; - type = "critical"; - }; }; cooling-maps { @@ -987,7 +936,6 @@ polling-delay-passive = <100>; polling-delay = <100>; thermal-sensors = <&smc_hwmon 65>; - critical-action = "shutdown"; trips { smc_tpx3_thermal_0: cap-0 { @@ -1020,11 +968,6 @@ type = "hot"; }; - trip-critical { - temperature = <98000>; - hysteresis = <0>; - type = "critical"; - }; }; cooling-maps { diff --git a/tools/testing/selftests/drivers/apple/j700-thermal-dt.py b/tools/testing/selftests/drivers/apple/j700-thermal-dt.py index e7e196f757012..48ca3d3d05a3f 100755 --- a/tools/testing/selftests/drivers/apple/j700-thermal-dt.py +++ b/tools/testing/selftests/drivers/apple/j700-thermal-dt.py @@ -51,6 +51,11 @@ def cells(self, node, prop): return [int(value, 16) for value in self.read("-t", "x", node, prop).split()] + def has(self, node, prop): + result = subprocess.run(["fdtget", str(self.path), node, prop], + capture_output=True, text=True) + return result.returncode == 0 + def children(self, node): result = subprocess.run(["fdtget", "-l", str(self.path), node], check=True, capture_output=True, text=True) @@ -72,7 +77,7 @@ def check_policy(tree, zone): temps = [85000, 88000, 92000, 95000, 98000] require(tree.cells(path, "polling-delay") == [100], "polling too slow") require(tree.cells(path, "polling-delay-passive") == [100], "passive polling too slow") - require(tree.strings(path, "critical-action") == ["shutdown"], "wrong critical action") + require(not tree.has(path, "critical-action"), "critical action on an unvalidated sensor") gpu_nodes = [f"/soc/{n}" for n in tree.children("/soc") if n.startswith("gpu@")] require(len(gpu_nodes) == 1, "expected one GPU") gpu = gpu_nodes[0] @@ -93,10 +98,8 @@ def check_policy(tree, zone): require(tree.strings(f"{path}/trips/trip-hot", "type") == ["hot"], "missing hot trip") require(tree.cells(f"{path}/trips/trip-hot", "hysteresis") == [5000], "wrong hot hysteresis") - critical = f"{path}/trips/trip-critical" - require(tree.cells(critical, "temperature") == [temps[4]], "wrong critical temperature") - require(tree.strings(critical, "type") == ["critical"], "missing critical shutdown") - require(tree.cells(critical, "hysteresis") == [0], "wrong critical hysteresis") + require("trip-critical" not in tree.children(f"{path}/trips"), + "critical trip on an unvalidated sensor") def main(): From 1fbf7af28b0223b89584501d1fcd7bba7beb352a Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 00:54:54 +1100 Subject: [PATCH 10/14] tools/asahi: t6040 calibration test: build g17/fw/power.rs too g17/fw/initdata.rs now takes PowerState from g17/fw/power.rs, so the host build of the T6040 wire builders failed with an unresolved super::power import. Copy power.rs into the test crate. Signed-off-by: Ryan Murray --- tools/asahi/t6040-calibration-tests.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/asahi/t6040-calibration-tests.py b/tools/asahi/t6040-calibration-tests.py index d802013175b97..e9e80ed0634bc 100644 --- a/tools/asahi/t6040-calibration-tests.py +++ b/tools/asahi/t6040-calibration-tests.py @@ -64,6 +64,7 @@ } mod float; mod initdata; +mod power; mod g17 { pub mod fw { pub(crate) use crate::initdata; } mod calibration; @@ -170,6 +171,7 @@ def main(): for source, target in [ ("g17/fw/initdata.rs", "initdata.rs"), ("g17/fw/initdata/v25g83.rs", "initdata/v25g83.rs"), + ("g17/fw/power.rs", "power.rs"), ]: text = (DRIVER / source).read_text() (root / target).write_text(text.replace("use kernel::prelude::*;", "use crate::prelude::*;")) From 0166fa35c328c03af9b332a1d3fe55e32b6642d1 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 00:55:46 +1100 Subject: [PATCH 11/14] drm/asahi: g17: no live power layout for the M5 firmware V26A428_M5 inherits from V26A428 and so took its live_power layout, whose RegionC max_power_mw is at +0x84. The common M5 graph moves the region C fields from +0x38 up by four, so that word is not the M5 build's. Mark the M5 build as not admitted: a GPU node that asks for cooling on it fails the probe instead of writing the wrong word. Also give the cooling KUnit module a MODULE_DESCRIPTION (modpost warns without one). Signed-off-by: Ryan Murray --- drivers/gpu/drm/asahi/cooling_test.c | 1 + drivers/gpu/drm/asahi/g17/fw/variant.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/drivers/gpu/drm/asahi/cooling_test.c b/drivers/gpu/drm/asahi/cooling_test.c index fa87ddd9a8060..a3abb7121f632 100644 --- a/drivers/gpu/drm/asahi/cooling_test.c +++ b/drivers/gpu/drm/asahi/cooling_test.c @@ -193,5 +193,6 @@ static struct kunit_suite asahi_gpu_cooling_suite = { .test_cases = asahi_gpu_cooling_cases, }; kunit_test_suite(asahi_gpu_cooling_suite); +MODULE_DESCRIPTION("Aurora GPU power-cap policy tests"); MODULE_LICENSE("Dual MIT/GPL"); #endif diff --git a/drivers/gpu/drm/asahi/g17/fw/variant.rs b/drivers/gpu/drm/asahi/g17/fw/variant.rs index 89b1eb20cff9b..4eef1e64c07a5 100644 --- a/drivers/gpu/drm/asahi/g17/fw/variant.rs +++ b/drivers/gpu/drm/asahi/g17/fw/variant.rs @@ -210,6 +210,9 @@ pub(crate) const V25G83: Variant = Variant { /// The 26A428 firmware of the M5 GPUs, which runs the M5 protocol (the M5 graph, queues and /// command set). pub(crate) const V26A428_M5: Variant = Variant { + // The common M5 graph moves region C's fields from +0x38 up by four, so the G17P + // max_power_mw word at +0x84 is not this build's: not admitted for the live power actuator. + live_power: None, m5_commands: true, // Not measured on the M5 firmware. traversal_exclusion: false, From 45b5650296a90dc94e7f04ed8071329fc8cd0f1b Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 01:38:56 +1100 Subject: [PATCH 12/14] drm/asahi: g17: give the M5 session an empty cooling owner The merge with integration/aurora brought in boot_m5(), whose Firmware initializer has no cooling field, so the driver does not compile. The packed M5-profile graphs have no admitted live power layout and never attach a cooling owner; initialize the field to None as boot() does. Signed-off-by: Ryan Murray --- drivers/gpu/drm/asahi/g17/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/asahi/g17/mod.rs b/drivers/gpu/drm/asahi/g17/mod.rs index 4ebb4e6634dd3..93fe42e9cdf5e 100644 --- a/drivers/gpu/drm/asahi/g17/mod.rs +++ b/drivers/gpu/drm/asahi/g17/mod.rs @@ -2104,6 +2104,7 @@ impl Gpu { pool: object::Pool::new(shared.variant.objects_after_release)?, render_rings: kick::RenderRings::new()?, render_ids: freelist::RenderIds::new()?, + cooling: None, init: initdata::InitData::new(), _render_global: render_global, _pm_metrics: session_metrics, From ab10dc1b01736667e41f0f782332853cfab1d307 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 01:39:01 +1100 Subject: [PATCH 13/14] drm/asahi: g17: start the GPU without cooling when the layout has none admit() refused the probe with EOPNOTSUPP when the GPU node has #cooling-cells but the selected firmware has no live power layout. The cooling device is optional: the firmware die limiter and the board's SMC thermal zones protect the GPU without it, as they did before this series. Refusing the probe turns a missing optional feature into no GPU. Log it once and continue without a cooling device. Decide from the firmware layout data actually selected, not from the variant alone. The common layout names objects of the G17P and G16S 25G83 graphs. The packed M5-profile graphs (boot_m5) place RegionC and the power state elsewhere and never attach, so a variant that inherits live_power from V26A428 while its build selects a packed graph (the J700 26B123 build in aurora-silicon/linux#1997) has no live power state. Before, such a build passed admit() and then ran without a cooling device and without a word in the log. cooling_words() now reports an unbuilt power state as None, checked before RegionC is resolved, and attach() warns and continues. A malformed #cooling-cells, invalid mappings and a zero initialized maximum still fail initialization. Signed-off-by: Ryan Murray --- .../devicetree/bindings/gpu/apple,agx.yaml | 4 +- Documentation/gpu/asahi-gpu-thermal.rst | 11 ++++-- drivers/gpu/drm/asahi/g17/cooling.rs | 38 +++++++++++++++---- drivers/gpu/drm/asahi/g17/initdata.rs | 13 ++++--- drivers/gpu/drm/asahi/g17/mod.rs | 2 +- 5 files changed, 49 insertions(+), 19 deletions(-) diff --git a/Documentation/devicetree/bindings/gpu/apple,agx.yaml b/Documentation/devicetree/bindings/gpu/apple,agx.yaml index d7da6345b8c4d..4cacd38490c8f 100644 --- a/Documentation/devicetree/bindings/gpu/apple,agx.yaml +++ b/Documentation/devicetree/bindings/gpu/apple,agx.yaml @@ -142,8 +142,8 @@ properties: GPU firmware absolute-power ceiling. State N requests (100 - N) percent of initialized maximum power, for N in 0..100, bounded below by a provisional nonzero minimum until hardware qualifies the low end. - Firmware initialization fails if the live power layout for the selected - firmware is not established. Other policy owners may impose a stricter + A firmware layout without a live power state leaves the GPU without + this cooling device. Other policy owners may impose a stricter ceiling than the thermal framework requests. operating-points-v2: true diff --git a/Documentation/gpu/asahi-gpu-thermal.rst b/Documentation/gpu/asahi-gpu-thermal.rst index 440709312fe84..3e309577f92dd 100644 --- a/Documentation/gpu/asahi-gpu-thermal.rst +++ b/Documentation/gpu/asahi-gpu-thermal.rst @@ -58,9 +58,14 @@ Fast and outer protection Before submission opens, the G17 firmware die limiter is initialized with sensor mask ``0x82a``, target 95 C, release 80 C and its native 16 ms period. The existing gains are preserved. These temperatures are provisional Linux -bring-up policy, not device safety ratings. The intentional missing-actuator -J700 initialization refusal is removed for the admitted layout; invalid -mappings, absent initialized power and unknown firmware still fail closed. +bring-up policy, not device safety ratings. + +The cooling device is optional. A board with ``#cooling-cells`` whose selected +firmware layout has no live power state (V25F84 and the packed M5-profile +graphs, among them the M5 26A428 and the common 26B123 graph) starts the GPU +without a cooling device and logs that once at probe; the firmware die limiter +and the SMC zones below still apply. A malformed ``#cooling-cells``, invalid +mappings and a zero initialized maximum still fail initialization. J700 has independent SMC thermal zones: diff --git a/drivers/gpu/drm/asahi/g17/cooling.rs b/drivers/gpu/drm/asahi/g17/cooling.rs index 63ce24b8490ee..ac297331bf929 100644 --- a/drivers/gpu/drm/asahi/g17/cooling.rs +++ b/drivers/gpu/drm/asahi/g17/cooling.rs @@ -39,12 +39,25 @@ fn required(dev: &device::Device) -> Result { } } -/// Check before starting either processor. A board requiring cooling must -/// never silently fall back to unrestricted submission with a missing ABI. -pub(super) fn admit(dev: &device::Device, variant: &Variant) -> Result { - if required(dev)? && variant.live_power.is_none() { - dev_err!(dev, "GPU live power layout not admitted\n"); - return Err(EOPNOTSUPP); +/// The live power layout of the selected firmware. [`Layout::Common`] names objects of the +/// G17P and G16S 25G83 graphs; a packed (M5-profile) graph places RegionC and its power state +/// elsewhere, so it has no common layout whatever its variant inherits. +fn live_layout(variant: &Variant, packed_graph: bool) -> Option { + match packed_graph { + true => None, + false => variant.live_power, + } +} + +/// Check before starting either processor. The cooling device is optional: when the board asks +/// for one but the firmware layout describes no live power state, say so once and start the +/// GPU without it. The firmware die limiter and the board's other thermal zones still apply. +pub(super) fn admit(dev: &device::Device, variant: &Variant, packed_graph: bool) -> Result { + if required(dev)? && live_layout(variant, packed_graph).is_none() { + dev_info!( + dev, + "GPU firmware layout has no live power state: no GPU cooling device\n" + ); } Ok(()) } @@ -71,8 +84,17 @@ impl Cooling { if !required(dev)? { return Ok(None); } - let layout = variant.live_power.as_ref().ok_or(EOPNOTSUPP)?; - let words = init.cooling_words(layout)?; + // Only the unpacked graphs boot through here; admit() reported a missing layout. + let Some(layout) = variant.live_power else { + return Ok(None); + }; + let Some(words) = init.cooling_words(&layout)? else { + dev_warn!( + dev, + "GPU initialization data has no power state: no GPU cooling device\n" + ); + return Ok(None); + }; // SAFETY: The owner keeps all validated shared words mapped until after // Drop drains the C callbacks. Registration publishes the provisional // 25% floor before INIT, port attachment or any work publication. diff --git a/drivers/gpu/drm/asahi/g17/initdata.rs b/drivers/gpu/drm/asahi/g17/initdata.rs index f1b000f4025c1..649426cd726b4 100644 --- a/drivers/gpu/drm/asahi/g17/initdata.rs +++ b/drivers/gpu/drm/asahi/g17/initdata.rs @@ -1701,16 +1701,19 @@ impl InitData { Ok(()) } - /// Resolve typed fields from their retained objects before any store. + /// Resolve typed fields from their retained objects before any store. `None` when the built + /// graph has no power state. pub(super) fn cooling_words( &self, layout: &super::cooling::Layout, - ) -> Result { + ) -> Result> { let super::cooling::Layout::Common = layout; + let Some((index, offset)) = self.power_state else { + return Ok(None); + }; let region = self.object(self.region_c)?; - let (index, offset) = self.power_state.ok_or(EOPNOTSUPP)?; let power = self.object(index)?; - Ok(super::cooling::PowerWords { + Ok(Some(super::cooling::PowerWords { max_power_mw: region .pointer(core::mem::offset_of!(abi::RegionC, max_power_mw), 4)? .cast(), @@ -1720,7 +1723,7 @@ impl InitData { ppm_target_mw: power .pointer(offset + core::mem::offset_of!(abi::PowerState, ppm_target_mw), 4)? .cast(), - }) + })) } pub(super) fn effort(&self) -> Result { diff --git a/drivers/gpu/drm/asahi/g17/mod.rs b/drivers/gpu/drm/asahi/g17/mod.rs index 93fe42e9cdf5e..b3372ebc94717 100644 --- a/drivers/gpu/drm/asahi/g17/mod.rs +++ b/drivers/gpu/drm/asahi/g17/mod.rs @@ -1631,9 +1631,9 @@ impl Gpu { let active_cores: u32 = id.core_masks.iter().map(|mask| mask.count_ones()).sum(); let (variant, build_cfg) = Self::firmware_variant(dev, &cfg.firmware, (id.num_clusters, active_cores))?; - cooling::admit(dev.as_ref().as_ref(), variant)?; // A build with its own configuration of the SoC runs with that one. let cfg = build_cfg.unwrap_or(cfg); + cooling::admit(dev.as_ref().as_ref(), variant, cfg.profile.is_m5())?; if let Some(calibration) = calibration { calibration.check_cores(&id.core_masks)?; calibration.check_opps(&initdata::InitData::opps(dev, cfg.opps, id.num_clusters)?)?; From 00e0a702b2f6510af913b7fe33ccb8b1aa466715 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 01:39:07 +1100 Subject: [PATCH 14/14] drm/asahi: g17: restore the 110 C die limiter target "arm64: dts: apple: add provisional J700 GPU outer protection" lowered TEMP_TARGET from 110 C to 95 C. The value is shared by every board on the G17P graph, sits in driver code rather than board data, and no measurement backs it: the Neo J700 baseline under sustained GPU load peaks at 107.7 C on the hottest GPU key and macOS holds about 105.5 C, so a 95 C firmware target throttles the GPU well below both, at a performance cost nobody has measured. The 110 C target matches the driver before this series and the status-config words of the M5 firmware tables (+0xc8 11000, +0xcc 8000). Restore 110 C and keep the release, gains and period. The cooling device and the SMC zones remain the outer loop; a lower firmware target needs its own sustained-load temperature and performance measurement. Signed-off-by: Ryan Murray --- Documentation/gpu/asahi-gpu-thermal.rst | 7 ++++--- drivers/gpu/drm/asahi/g17/fw/initdata.rs | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/gpu/asahi-gpu-thermal.rst b/Documentation/gpu/asahi-gpu-thermal.rst index 3e309577f92dd..c71021626a173 100644 --- a/Documentation/gpu/asahi-gpu-thermal.rst +++ b/Documentation/gpu/asahi-gpu-thermal.rst @@ -56,9 +56,10 @@ Fast and outer protection ------------------------- Before submission opens, the G17 firmware die limiter is initialized with -sensor mask ``0x82a``, target 95 C, release 80 C and its native 16 ms period. -The existing gains are preserved. These temperatures are provisional Linux -bring-up policy, not device safety ratings. +sensor mask ``0x82a``, target 110 C, release 80 C and its native 16 ms period, +with its existing gains: the values the driver used before this cooling work. +They are not device safety ratings. Changing the target needs a sustained-load +temperature and performance measurement on the board. The cooling device is optional. A board with ``#cooling-cells`` whose selected firmware layout has no live power state (V25F84 and the packed M5-profile diff --git a/drivers/gpu/drm/asahi/g17/fw/initdata.rs b/drivers/gpu/drm/asahi/g17/fw/initdata.rs index ff3d33f139227..461e6574d461a 100644 --- a/drivers/gpu/drm/asahi/g17/fw/initdata.rs +++ b/drivers/gpu/drm/asahi/g17/fw/initdata.rs @@ -1605,8 +1605,7 @@ static_assert!(private::STATUS_B + size_of::() == private::SECO /// Die temperature sensors read by the die temperature limiter. const TEMP_SENSOR_MASK: u64 = 0x82a; /// Die temperature the limiter holds the GPU below, in 0.01 °C. -// Conservative J700 bring-up policy; retain the native gains and 16 ms period. -const TEMP_TARGET: u32 = 9_500; +const TEMP_TARGET: u32 = 11_000; /// Die temperature below which the limiter releases, in 0.01 °C. const TEMP_RELEASE: u32 = 8_000; /// Proportional gain of the limiter: 20.34 as an IEEE-754 single.