From 4ea6b7f3269d2b97b6afd62aabac99d480bc5d35 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 05:50:27 +1100 Subject: [PATCH 1/4] dt-bindings: gpu: apple,agx: describe the die temperature limit The GPU firmware runs a die temperature limiter: above its target it lowers the GPU state on its own, below its release temperature it lets go. Its target and release are firmware defaults today, the same for every board. A board whose enclosure must run the GPU cooler has no way to say so. Describe both on the GPU node, in degrees Celsius like the release temperature the older generations already read (apple,fast-die0-release-temp). Both are optional and can only lower the firmware default. Signed-off-by: Ryan Murray --- .../devicetree/bindings/gpu/apple,agx.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Documentation/devicetree/bindings/gpu/apple,agx.yaml b/Documentation/devicetree/bindings/gpu/apple,agx.yaml index 7195523c1bd7..0d3c289b6153 100644 --- a/Documentation/devicetree/bindings/gpu/apple,agx.yaml +++ b/Documentation/devicetree/bindings/gpu/apple,agx.yaml @@ -132,6 +132,25 @@ properties: backend extends the firmware's native delay with its host idle-hold control; an absent property preserves the native policy. + apple,fast-die0-target-temp: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 85 + maximum: 110 + description: + Die temperature, in degrees Celsius, that the GPU firmware's die + temperature limiter holds the GPU below. A board whose enclosure must + run the GPU cooler than the firmware default sets it. It can only + lower the firmware default (110 C on the G17 family); absent, the + default applies. + + apple,fast-die0-release-temp: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 40 + description: + Die temperature, in degrees Celsius, below which the GPU firmware's die + temperature limiter releases the GPU. Must be below the target. It can + only lower the firmware default; absent, the default applies. + apple,pmp: $ref: /schemas/types.yaml#/definitions/phandle description: PMP firmware provider owning the GPU power vote and telemetry From c261d6d2e52f3cb0eea66ab785e7c801b3b99fcf Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 05:50:27 +1100 Subject: [PATCH 2/4] drm/asahi: g17: take the die temperature limit from the device tree Every G17 firmware build carries a die temperature limiter whose target and release temperatures the host writes from constants (26A428: 110 C / 80 C in the power configuration and the power state; 25G83: 110 C / 80 C in the power configuration, 101 C / 96 C in the power state). A board has no say in them, so a machine whose enclosure must stay cooler than the default runs at the firmware's limit no matter what its thermal zones ask for: on the J700 the host power ceiling lowers the mean die temperature but bursts still climb to the limiter's clamp. Read apple,fast-die0-target-temp and apple,fast-die0-release-temp from the GPU node once per build and apply them to every limiter table of the running build, never above that table's default and with the release kept below the target. A target above 110 C is clamped with a warning, one below 85 C or a release out of range is ignored with a warning. Without the properties every table keeps its default, so no board changes behaviour until its device tree asks for it. The M5 graph's limiter words move with its firmware's layout and are not located here; a board limit on such a build is reported and not applied. Signed-off-by: Ryan Murray --- drivers/gpu/drm/asahi/g17/die_limit.rs | 209 ++++++++++++++++++ drivers/gpu/drm/asahi/g17/fw/initdata.rs | 43 ++-- .../gpu/drm/asahi/g17/fw/initdata/v25g83.rs | 25 ++- drivers/gpu/drm/asahi/g17/initdata.rs | 7 +- drivers/gpu/drm/asahi/g17/initdata/v25g83.rs | 4 + drivers/gpu/drm/asahi/g17/mod.rs | 6 + 6 files changed, 273 insertions(+), 21 deletions(-) create mode 100644 drivers/gpu/drm/asahi/g17/die_limit.rs diff --git a/drivers/gpu/drm/asahi/g17/die_limit.rs b/drivers/gpu/drm/asahi/g17/die_limit.rs new file mode 100644 index 000000000000..ae11b87a9ac5 --- /dev/null +++ b/drivers/gpu/drm/asahi/g17/die_limit.rs @@ -0,0 +1,209 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT + +//! Per-board die temperature limit of the G17-family firmware builds. +//! +//! Every G17 build runs a die temperature limiter in the firmware: above its target the firmware +//! lowers the GPU state on its own, below its release temperature it lets go. Each build's tables +//! carry a default. A board whose enclosure must stay cooler describes its limit on the GPU node +//! with `apple,fast-die0-target-temp` and `apple,fast-die0-release-temp`, in degrees Celsius like +//! the older generations' `apple,fast-die0-release-temp`. Both are optional; a board value only +//! ever lowers a build's default, so a node without them runs every build as before. + +use kernel::{c_str, device, prelude::*}; + +/// Highest accepted target, in 0.01 °C: the 26A428 default, which no board may raise. +const TARGET_MAX_CC: u32 = super::fw::initdata::DIE_LIMIT.target_cc; +/// Lowest accepted target, in 0.01 °C. A lower limit would hold the GPU at its lowest state at +/// ordinary load temperatures; such a value is a mistake, not a policy. +const TARGET_MIN_CC: u32 = 8_500; +/// Lowest accepted release temperature, in 0.01 °C. +const RELEASE_MIN_CC: u32 = 4_000; +/// Smallest gap kept between a lowered target and the release temperature, in 0.01 °C. +const MIN_GAP_CC: u32 = 100; + +/// Limiter temperatures as one firmware table holds them, in 0.01 °C. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct Limits { + pub(crate) target_cc: u32, + pub(crate) release_cc: u32, +} + +/// The board's limit from the device tree, validated; `None` where the board sets nothing. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub(crate) struct DieLimit { + target_cc: Option, + release_cc: Option, +} + +/// A device-tree value the driver did not take as written. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum Problem { + /// Target above [`TARGET_MAX_CC`], clamped to it. + TargetClamped(u32), + /// Target below [`TARGET_MIN_CC`], ignored. + TargetIgnored(u32), + /// Release temperature below [`RELEASE_MIN_CC`] or not below the target, ignored. + ReleaseIgnored(u32), +} + +impl DieLimit { + /// Reads and validates the GPU node's limit. Values out of range are clamped or ignored + /// with a warning; an unreadable node leaves every build's default. + pub(crate) fn read(dev: &device::Device) -> Self { + let Some(node) = dev.of_node() else { + return Self::default(); + }; + let read = |name: &'static CStr| match node.get_property::(name) { + Ok(value) => Some(value), + Err(ENOENT) => None, + Err(error) => { + dev_warn!(dev, "Ignoring unreadable GPU {:?}: {:?}\n", name, error); + None + } + }; + let target = read(c_str!("apple,fast-die0-target-temp")); + let release = read(c_str!("apple,fast-die0-release-temp")); + let limit = Self::from_celsius(target, release, |problem| match problem { + Problem::TargetClamped(t) => dev_warn!( + dev, + "GPU die target {} C above the firmware default, using {} C\n", + t, + TARGET_MAX_CC / 100 + ), + Problem::TargetIgnored(t) => dev_warn!( + dev, + "GPU die target {} C below {} C, ignored\n", + t, + TARGET_MIN_CC / 100 + ), + Problem::ReleaseIgnored(r) => { + dev_warn!(dev, "GPU die release temperature {} C out of range, ignored\n", r) + } + }); + if let Some(target_cc) = limit.target_cc { + dev_info!(dev, "GPU die limiter target {} C from the device tree\n", target_cc / 100); + } + limit + } + + /// Validates device-tree values in degrees Celsius. + fn from_celsius( + target: Option, + release: Option, + mut problem: impl FnMut(Problem), + ) -> Self { + let target_cc = target.and_then(|t| match t.saturating_mul(100) { + cc if cc > TARGET_MAX_CC => { + problem(Problem::TargetClamped(t)); + Some(TARGET_MAX_CC) + } + cc if cc < TARGET_MIN_CC => { + problem(Problem::TargetIgnored(t)); + None + } + cc => Some(cc), + }); + let ceiling = target_cc.unwrap_or(TARGET_MAX_CC); + let release_cc = release.and_then(|r| match r.saturating_mul(100) { + cc if (RELEASE_MIN_CC..ceiling).contains(&cc) => Some(cc), + _ => { + problem(Problem::ReleaseIgnored(r)); + None + } + }); + Self { target_cc, release_cc } + } + + /// Whether the board sets any limit. + pub(crate) fn is_set(&self) -> bool { + *self != Self::default() + } + + /// The limiter temperatures for a firmware table whose build default is `default`: the + /// board's where set, never above the build's, with the release below the target. + pub(crate) fn apply(&self, default: Limits) -> Limits { + if !self.is_set() { + return default; + } + let target_cc = self.target_cc.map_or(default.target_cc, |t| t.min(default.target_cc)); + let release_cc = self + .release_cc + .map_or(default.release_cc, |r| r.min(default.release_cc)) + .min(target_cc.saturating_sub(MIN_GAP_CC)); + Limits { target_cc, release_cc } + } + + /// Writes the limiter temperatures for `default` at `target` and `release`, byte offsets + /// of 32-bit little-endian words in `bytes`. + pub(crate) fn write(&self, bytes: &mut [u8], default: Limits, target: usize, release: usize) { + let limits = self.apply(default); + bytes[target..target + 4].copy_from_slice(&limits.target_cc.to_le_bytes()); + bytes[release..release + 4].copy_from_slice(&limits.release_cc.to_le_bytes()); + } +} + +#[kunit_tests(asahi_g17_die_limit)] +mod tests { + use super::*; + + const BUILD: Limits = Limits { target_cc: 11_000, release_cc: 8_000 }; + const STATE_25G83: Limits = Limits { target_cc: 10_100, release_cc: 9_600 }; + + fn parse(target: Option, release: Option) -> (DieLimit, KVec) { + let mut problems = KVec::new(); + let limit = DieLimit::from_celsius(target, release, |p| { + let _ = problems.push(p, GFP_KERNEL); + }); + (limit, problems) + } + + #[test] + fn absent_keeps_every_build_default() { + let (limit, problems) = parse(None, None); + assert!(problems.is_empty()); + assert!(!limit.is_set()); + assert_eq!(limit.apply(BUILD), BUILD); + assert_eq!(limit.apply(STATE_25G83), STATE_25G83); + } + + #[test] + fn board_target_lowers_but_never_raises() { + let (limit, problems) = parse(Some(108), None); + assert!(problems.is_empty()); + assert_eq!(limit.apply(BUILD), Limits { target_cc: 10_800, release_cc: 8_000 }); + // A build whose own default is lower keeps it. + assert_eq!(limit.apply(STATE_25G83), STATE_25G83); + } + + #[test] + fn nonsense_is_clamped_or_ignored() { + let (limit, problems) = parse(Some(150), None); + assert_eq!(&problems[..], &[Problem::TargetClamped(150)]); + assert_eq!(limit.apply(BUILD), BUILD); + + let (limit, problems) = parse(Some(20), None); + assert_eq!(&problems[..], &[Problem::TargetIgnored(20)]); + assert!(!limit.is_set()); + + let (limit, problems) = parse(Some(u32::MAX), Some(u32::MAX)); + assert_eq!( + &problems[..], + &[Problem::TargetClamped(u32::MAX), Problem::ReleaseIgnored(u32::MAX)] + ); + assert_eq!(limit.apply(BUILD), BUILD); + + let (_, problems) = parse(Some(100), Some(100)); + assert_eq!(&problems[..], &[Problem::ReleaseIgnored(100)]); + } + + #[test] + fn release_stays_below_a_lowered_target() { + let (limit, problems) = parse(Some(95), Some(70)); + assert!(problems.is_empty()); + assert_eq!(limit.apply(BUILD), Limits { target_cc: 9_500, release_cc: 7_000 }); + // 25G83 power state: target 95, its 96 C release pulled below the target. + assert_eq!(limit.apply(STATE_25G83), Limits { target_cc: 9_500, release_cc: 7_000 }); + let (limit, _) = parse(Some(95), None); + assert_eq!(limit.apply(STATE_25G83), Limits { target_cc: 9_500, release_cc: 9_400 }); + } +} diff --git a/drivers/gpu/drm/asahi/g17/fw/initdata.rs b/drivers/gpu/drm/asahi/g17/fw/initdata.rs index 461e6574d461..32bd0d3f942f 100644 --- a/drivers/gpu/drm/asahi/g17/fw/initdata.rs +++ b/drivers/gpu/drm/asahi/g17/fw/initdata.rs @@ -26,6 +26,7 @@ use kernel::prelude::*; use super::clear; +use crate::g17::die_limit::{DieLimit, Limits}; pub(crate) mod v25g83; @@ -1558,14 +1559,14 @@ impl PrimaryStatusB { pub(crate) const POWER_STATE: usize = 0xe440; /// Initializes the primary status B; `fwctl_va` is the zeroed - /// firmware-control page ([`FWCTL_SIZE`] bytes). - pub(crate) fn init(&mut self, fwctl_va: u64) { + /// firmware-control page ([`FWCTL_SIZE`] bytes), `limit` the board's die limit. + pub(crate) fn init(&mut self, fwctl_va: u64, limit: &DieLimit) { clear(self); self.status = StatusBlock::new(); self.fwctl_state_va = fwctl_va; self.fwctl_ring_va = fwctl_va + FWCTL_RING; self.unk_e434 = 1; - self.power.init(); + self.power.init(limit); } } @@ -1604,10 +1605,18 @@ 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; -/// Die temperature below which the limiter releases, in 0.01 °C. -const TEMP_RELEASE: u32 = 8_000; +/// Default die temperatures of the limiter, in 0.01 °C: it holds the GPU below the target and +/// releases below the release temperature. A board may lower them +/// ([`DieLimit`](crate::g17::die_limit::DieLimit)). +pub(crate) const DIE_LIMIT: Limits = Limits { target_cc: 11_000, release_cc: 8_000 }; +const TEMP_TARGET: u32 = DIE_LIMIT.target_cc; +const TEMP_RELEASE: u32 = DIE_LIMIT.release_cc; +/// Offsets of the limiter target and release in the [`PowerConfigTail`]. +const TAIL_TEMP_TARGET: usize = 0x5ac; +const TAIL_TEMP_RELEASE: usize = 0x558; +/// Offsets of the limiter target and release in the [`PowerState`]. +const STATE_TEMP_TARGET: usize = 0xc8; +const STATE_TEMP_RELEASE: usize = 0xcc; /// Proportional gain of the limiter: 20.34 as an IEEE-754 single. const TEMP_KP: u32 = 0x41a2_b852; /// Integral gain of the limiter, per control period: 9.376 as an IEEE-754 @@ -1715,7 +1724,7 @@ const POWER_CONFIG_TAIL_WORDS: Words = &[ (0x50c, 0x3f4ccccd, 1), (0x510, 0x3e4ccccd, 1), (0x550, TEMP_SENSOR_MASK as u32, 1), - (0x558, TEMP_RELEASE, 1), + (TAIL_TEMP_RELEASE, TEMP_RELEASE, 1), (0x560, 4, 1), (0x574, 0x3f800000, 1), (0x57c, TEMP_KI, 1), @@ -1723,7 +1732,7 @@ const POWER_CONFIG_TAIL_WORDS: Words = &[ (0x58c, TEMP_KP, 1), (0x598, 0x28, 1), (0x59c, 0x3e8, 2), - (0x5ac, TEMP_TARGET, 1), + (TAIL_TEMP_TARGET, TEMP_TARGET, 1), (0x5e0, 0x3e8, 1), (0x7fc, 0x42000006, 1), (0xa10, 0xb8520000, 1), @@ -1805,8 +1814,8 @@ const POWER_STATE_WORDS: Words = &[ (0x18, 0x40880000, 1), (0x1c, 0x28, 1), (0x20, 1, 1), - (0xc8, TEMP_TARGET, 1), - (0xcc, TEMP_RELEASE, 1), + (STATE_TEMP_TARGET, TEMP_TARGET, 1), + (STATE_TEMP_RELEASE, TEMP_RELEASE, 1), (0xd8, TEMP_KP, 1), (0xdc, TEMP_KI, 1), (0xf0, 0x26ac, 1), @@ -1905,13 +1914,14 @@ pub(crate) use super::power::PowerState; unsafe impl Zeroable for PowerState {} impl PowerState { - fn init(&mut self) { + fn init(&mut self, limit: &DieLimit) { // 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); + limit.write(bytes, DIE_LIMIT, STATE_TEMP_TARGET, STATE_TEMP_RELEASE); self.ppm_enabled = 1; self.ppm_target_mw = 9750; } @@ -1957,8 +1967,9 @@ pub(crate) struct PowerConfigTail(pub(crate) [u8; 0x1000]); unsafe impl Zeroable for PowerConfigTail {} impl PowerConfigTail { - fn init(&mut self) { + fn init(&mut self, limit: &DieLimit) { fill_words(&mut self.0, POWER_CONFIG_TAIL_WORDS); + limit.write(&mut self.0, DIE_LIMIT, TAIL_TEMP_TARGET, TAIL_TEMP_RELEASE); } } @@ -1998,10 +2009,10 @@ static_assert!(bundle::VIEWS[2] + 0xe40 == bundle::POWER_CONFIG); unsafe impl Zeroable for PowerConfig {} impl PowerConfig { - /// Initializes the power configuration. - pub(crate) fn init(&mut self) { + /// Initializes the power configuration with the board's die limit. + pub(crate) fn init(&mut self, limit: &DieLimit) { self.head.init(); - self.tail.init(); + self.tail.init(limit); } } diff --git a/drivers/gpu/drm/asahi/g17/fw/initdata/v25g83.rs b/drivers/gpu/drm/asahi/g17/fw/initdata/v25g83.rs index 18ff53cb4eaf..0d781c0af073 100644 --- a/drivers/gpu/drm/asahi/g17/fw/initdata/v25g83.rs +++ b/drivers/gpu/drm/asahi/g17/fw/initdata/v25g83.rs @@ -21,6 +21,7 @@ use super::{ RegisterMapEntry, Words, COMPLETION_RING_ENTRIES, COMPLETION_RING_ENTRY_SIZE, COMPLETION_RING_INDEX, PERF_STATES, REGISTER_MAP_SLOTS, }; +use crate::g17::die_limit::{DieLimit, Limits}; use kernel::prelude::*; /// Kernel-window objects whose placement differs from the A18 Pro's, as offsets in the upper @@ -415,6 +416,11 @@ fn overlay_words(bytes: &mut [u8], words: Words) -> Result { const PERIOD_CLOCKS: u32 = 200_000; /// Temperature sensors read by the die and MTR temperature limiters. const TEMP_SENSOR_MASK: u32 = 0x2a22_2aa2; +/// Default die limiter temperatures of the power configuration, in 0.01 °C. +const CONFIG_DIE_LIMIT: Limits = Limits { target_cc: 11_000, release_cc: 8_000 }; +/// Offsets of the die limiter target and release in the power configuration. +const CONFIG_TEMP_TARGET: usize = 0x22c4; +const CONFIG_TEMP_RELEASE: usize = 0x2270; pub(crate) struct Chip { pub(crate) max_power_mw: u32, @@ -506,7 +512,7 @@ const POWER_CONFIG_WORDS: Words = &[ (0x2224, 0x3f4ccccd, 1), (0x2228, 0x3e4ccccd, 1), (0x2268, TEMP_SENSOR_MASK, 1), - (0x2270, 0x1f40, 1), + (CONFIG_TEMP_RELEASE, CONFIG_DIE_LIMIT.release_cc, 1), (0x2278, 0x4, 1), (0x228c, 0x3f800000, 1), (0x2294, 0x414eeeee, 1), @@ -514,7 +520,7 @@ const POWER_CONFIG_WORDS: Words = &[ (0x22a4, 0x42140000, 1), (0x22b0, 0x64, 1), (0x22b4, 0x3e8, 2), - (0x22c4, 0x2af8, 1), + (CONFIG_TEMP_TARGET, CONFIG_DIE_LIMIT.target_cc, 1), (0x22f8, 0x3e8, 1), (0x2728, 0xb8520000, 1), (0x272c, 0x3f7e, 1), @@ -643,6 +649,11 @@ impl PowerConfig25G83 { pub(crate) fn apply_chip(&mut self, chip: &Chip) -> Result { overlay_words(&mut self.0, chip.power_config_words) } + + /// Applies the board's die limit, after any chip overlay. + pub(crate) fn apply_die_limit(&mut self, limit: &DieLimit) { + limit.write(&mut self.0, CONFIG_DIE_LIMIT, CONFIG_TEMP_TARGET, CONFIG_TEMP_RELEASE); + } } /// The AON temperature-source rows the power configuration names: the GPU cluster 0, GPU @@ -662,4 +673,12 @@ pub(crate) const AON_TABLE: [u32; 9] = [ /// Nonzero words of the power-state object. The fast-die limiter reads its target /// (`+0xc8`, 101.00 °C) and release (`+0xcc`, 96.00 °C) temperatures in 0.01 °C; left at zero /// the limit is 0 °C and the GPU stays at its lowest state whenever the PMP runs. -pub(crate) const POWER_STATE_WORDS: Words = &[(0xc8, 10_100, 1), (0xcc, 9_600, 1)]; +pub(crate) const POWER_STATE_WORDS: Words = &[ + (STATE_TEMP_TARGET, STATE_DIE_LIMIT.target_cc, 1), + (STATE_TEMP_RELEASE, STATE_DIE_LIMIT.release_cc, 1), +]; +/// Default die limiter temperatures of the power state, in 0.01 °C. +pub(crate) const STATE_DIE_LIMIT: Limits = Limits { target_cc: 10_100, release_cc: 9_600 }; +/// Offsets of the die limiter target and release in the power state. +pub(crate) const STATE_TEMP_TARGET: usize = 0xc8; +pub(crate) const STATE_TEMP_RELEASE: usize = 0xcc; diff --git a/drivers/gpu/drm/asahi/g17/initdata.rs b/drivers/gpu/drm/asahi/g17/initdata.rs index f1b000f4025c..0ce8cc8c7d17 100644 --- a/drivers/gpu/drm/asahi/g17/initdata.rs +++ b/drivers/gpu/drm/asahi/g17/initdata.rs @@ -233,6 +233,8 @@ struct BuildEnv<'a> { dynamic: Range, /// GPU clusters, as the GPU reports them. clusters: u32, + /// The board's die temperature limit, applied to every limiter table of the build. + die_limit: super::die_limit::DieLimit, } impl BuildEnv<'_> { @@ -1184,6 +1186,7 @@ impl InitData { base: range.start, dynamic: t8140::dynamic::upper(range.clone()), clusters, + die_limit: super::die_limit::DieLimit::read(dev.as_ref().as_ref()), }; if variant.graph == super::fw::variant::InitGraph::V25G83 { return self.build_25g83(&env, cfg, metrics, active_cores, variant); @@ -1524,7 +1527,7 @@ impl InitData { let fwctl_va = self.object(tables.fwctl)?.gpu_va(); self.object_mut(self.cluster)? .initialize::(abi::private::STATUS_B, |status| { - status.init(fwctl_va); + status.init(fwctl_va, &env.die_limit); Ok(()) })?; self.object_mut(self.cluster)? @@ -1537,7 +1540,7 @@ impl InitData { )?; self.object_mut(self.bundle)? .initialize::(abi::bundle::POWER_CONFIG, |power| { - power.init(); + power.init(&env.die_limit); Ok(()) })?; let secondary_status = base diff --git a/drivers/gpu/drm/asahi/g17/initdata/v25g83.rs b/drivers/gpu/drm/asahi/g17/initdata/v25g83.rs index 72d2c6d017c5..10d750c64436 100644 --- a/drivers/gpu/drm/asahi/g17/initdata/v25g83.rs +++ b/drivers/gpu/drm/asahi/g17/initdata/v25g83.rs @@ -162,6 +162,7 @@ impl InitData { if let Some(chip) = chip { power.apply_chip(chip)?; } + power.apply_die_limit(&env.die_limit); Ok(()) })?; self.object_mut(self.region_c)? @@ -244,6 +245,9 @@ impl InitData { .write(offset + 4 * index, value)?; } } + let state = env.die_limit.apply(v::STATE_DIE_LIMIT); + self.object_mut(objects.power_state)?.write(v::STATE_TEMP_TARGET, state.target_cc)?; + self.object_mut(objects.power_state)?.write(v::STATE_TEMP_RELEASE, state.release_cc)?; let producer = match variant.opening_record { true => abi::OPENING_PRODUCER, diff --git a/drivers/gpu/drm/asahi/g17/mod.rs b/drivers/gpu/drm/asahi/g17/mod.rs index f3dc0d32e5f9..243ea360ab7c 100644 --- a/drivers/gpu/drm/asahi/g17/mod.rs +++ b/drivers/gpu/drm/asahi/g17/mod.rs @@ -35,6 +35,7 @@ mod cooling; pub(crate) mod context; mod data_segment; mod dependency; +mod die_limit; mod sync_input; pub(crate) mod exec_share; pub(crate) mod sync_output; @@ -2146,6 +2147,11 @@ impl Gpu { .uat .adopt_firmware_root_entries() .inspect_err(at("root adoption"))?; + if die_limit::DieLimit::read(dev.as_ref().as_ref()).is_set() { + // The M5 graph's limiter words move with its firmware's layout (common26 bands); + // they are not located here, so its own defaults stay. + dev_warn!(dev.as_ref(), "GPU die limit not applied on this firmware build\n"); + } session .init .build_m5(dev, &session.uat, id, board) From 2971197e0e2452ac7f22fb7317bcbcce7cfa8fcb Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 05:50:27 +1100 Subject: [PATCH 3/4] arm64: dts: apple: t8140-j700: hold the GPU die at the macOS level Under a sustained GPU load our own macOS measurement on this machine holds the hottest GPU die key at or below 105.5 C. Linux, with the firmware die limiter at its default 110 C target, reads a clamp of about 107.7 C on the same keys, and the GPU power ceiling cannot pull the peak down: the firmware averages the ceiling over a window longer than the bursts that reach the clamp. Set the limiter target to 108 C, which moves that clamp near the macOS level. Signed-off-by: Ryan Murray --- arch/arm64/boot/dts/apple/t8140-j700.dts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t8140-j700.dts b/arch/arm64/boot/dts/apple/t8140-j700.dts index 3075d4ec8963..0e9925809985 100644 --- a/arch/arm64/boot/dts/apple/t8140-j700.dts +++ b/arch/arm64/boot/dts/apple/t8140-j700.dts @@ -2179,6 +2179,14 @@ &gpu { status = "okay"; + /* + * Our macOS reference measurement on this machine (sustained GPU + * load) holds the hottest GPU die key at or below 105.5 C. With the + * firmware limiter's default 110 C target, Linux reads a clamp of + * about 107.7 C on the same keys, about 2.3 C below the target; a + * 108 C target puts that clamp near the macOS level. + */ + apple,fast-die0-target-temp = <108>; }; #include "hwmon-common.dtsi" From 2020f6fe5c0b2b24d726c943d1fb59c60de03dda Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 06:30:15 +1100 Subject: [PATCH 4/4] arm64: dts: apple: t8140-j700: lower the GPU die target to 107 C Our own 10 minute sustained GPU load rows on this machine: with the 108 C target the hottest GPU die key still peaks at 105.78 C (fps -5.9 %), above the 105.5 C macOS holds it at. A 107 C target peaks at 104.73 C (mean 104.64 C, 417 fps against 460 fps without the limit change), within the macOS level. Signed-off-by: Ryan Murray --- arch/arm64/boot/dts/apple/t8140-j700.dts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8140-j700.dts b/arch/arm64/boot/dts/apple/t8140-j700.dts index 0e9925809985..23a948337a58 100644 --- a/arch/arm64/boot/dts/apple/t8140-j700.dts +++ b/arch/arm64/boot/dts/apple/t8140-j700.dts @@ -2180,13 +2180,14 @@ &gpu { status = "okay"; /* - * Our macOS reference measurement on this machine (sustained GPU - * load) holds the hottest GPU die key at or below 105.5 C. With the - * firmware limiter's default 110 C target, Linux reads a clamp of - * about 107.7 C on the same keys, about 2.3 C below the target; a - * 108 C target puts that clamp near the macOS level. + * Our own measurements on this machine, 10 min sustained GPU load: + * macOS holds the hottest GPU die key at or below 105.5 C. Linux + * with the firmware limiter's default 110 C target peaks at 107.75 C + * (base600 row); a 108 C target peaks at 105.78 C, a 107 C target at + * 104.73 C (die107-600 row, 417 fps vs 460 fps). 107 C is the + * highest target that stays within the macOS level. */ - apple,fast-die0-target-temp = <108>; + apple,fast-die0-target-temp = <107>; }; #include "hwmon-common.dtsi"