From 9f1d55b83b4ffd383bdc08d27895d4c7bbdd2bcb Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Wed, 25 Nov 2026 00:33:54 +1100 Subject: [PATCH] drm/asahi: let the G14 27.2 GPU use its full performance-state range The G14 27.2 runtime wrote the board's performance-state ceiling to two of the three Globals state selectors (+0x88, +0x8c) but left the third (+0x98) at 100, the first state above idle. That held the GPU at its lowest active state (about a third of its top clock on the M2) for every workload. G14 13.5, M3 27.2 and M4 27.2 write the ceiling to all three selectors. Do the same: the value comes from the board's performance-state table in the device tree, and the firmware's power and thermal controller (fast-die loop, thermal thresholds, SoC-hot alarm, all unchanged) decides how much of that range the GPU may use. The selector offsets move into the 27.2 ABI module so the host test checks them against the progress-check words. Signed-off-by: Ryan Murray --- drivers/gpu/drm/asahi/g14_v27_2_abi.rs | 19 +++++++++++++++++-- drivers/gpu/drm/asahi/gpu/v27_2.rs | 11 +++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/asahi/g14_v27_2_abi.rs b/drivers/gpu/drm/asahi/g14_v27_2_abi.rs index 4e7fd8de186e5..20f172fdb52e9 100644 --- a/drivers/gpu/drm/asahi/g14_v27_2_abi.rs +++ b/drivers/gpu/drm/asahi/g14_v27_2_abi.rs @@ -93,6 +93,12 @@ pub(crate) const GLOBALS_PROGRESS: [(usize, u32); 8] = [ /// Size of the 27.2 Globals object. pub(crate) const GLOBALS_BYTES: usize = 0xe48; +/// Globals words of the three performance-state selectors, in hundredths of a state. All three +/// take the ceiling of the board's performance-state table, as G14 13.5 (`initdata`), M3 27.2 +/// (`m3_power_26`) and M4 27.2 (`g16/fw/initdata`) write them; a lower value here caps the GPU +/// clock below what the firmware's power and thermal controller would allow. +pub(crate) const GLOBALS_PSTATE_SELECTORS: [usize; 3] = [0x88, 0x8c, 0x98]; + #[cfg_attr(not(test), kunit_tests(asahi_g14_fw_queues))] #[cfg_attr(test, allow(dead_code))] mod tests { @@ -173,12 +179,12 @@ mod tests { #[test] fn progress_words_fit_the_globals_and_leave_power_words_alone() { - let power = [0x58usize, 0x5a, 0x5c, 0x6e, 0x84, 0x88, 0x8c, 0x98]; + let power = [0x58usize, 0x5a, 0x5c, 0x6e, 0x84]; for (i, &(at, value)) in GLOBALS_PROGRESS.iter().enumerate() { assert_eq!(at % 4, 0); assert!(at + 4 <= GLOBALS_BYTES); assert_ne!(value, 0); - assert!(power.iter().all(|&p| p + 4 <= at || at + 4 <= p)); + assert!(power.iter().chain(&GLOBALS_PSTATE_SELECTORS).all(|&p| p + 4 <= at || at + 4 <= p)); assert!(GLOBALS_PROGRESS[i + 1..].iter().all(|&(other, _)| other != at)); } // Every progress interval is set: a zero interval is what stopped work in a poll. @@ -186,4 +192,13 @@ mod tests { assert!(GLOBALS_PROGRESS.iter().any(|&(o, v)| o == at && v != 0)); } } + + #[test] + fn pstate_selectors_are_aligned_distinct_words_of_the_globals() { + for (i, &at) in GLOBALS_PSTATE_SELECTORS.iter().enumerate() { + assert_eq!(at % 4, 0); + assert!(at + 4 <= GLOBALS_BYTES); + assert!(GLOBALS_PSTATE_SELECTORS[i + 1..].iter().all(|&o| o + 4 <= at || at + 4 <= o)); + } + } } diff --git a/drivers/gpu/drm/asahi/gpu/v27_2.rs b/drivers/gpu/drm/asahi/gpu/v27_2.rs index 32d11d7ae6e74..70e9207001035 100644 --- a/drivers/gpu/drm/asahi/gpu/v27_2.rs +++ b/drivers/gpu/drm/asahi/gpu/v27_2.rs @@ -42,9 +42,6 @@ const TRACE_RECORDS: u32 = 512; const RING_RECORDS: u32 = 256; /// Queue capacity at position block +0x50 (16 x the 0x50 channels). const QUEUE_CAPACITY: u32 = 0x500; -/// Upper performance-state cap, in hundredths, at globals +0x98: the first state above idle. -/// Only this cap has run on hardware. -const STATE_CAP: u32 = 100; /// Board facts the root needs, read from the device tree at probe. pub(crate) struct BoardV27_2 { @@ -1067,9 +1064,11 @@ impl RootV27_2 { for (offset, value) in [(0x58, 0xffffu16), (0x5a, 0x28), (0x5c, 0xffff)] { data[offset..offset + 2].copy_from_slice(&value.to_le_bytes()); } - let ceiling = pwr.perf_max_pstate * 100; - for (at, value) in [(0x84, pwr.max_power_mw), (0x88, ceiling), (0x8c, ceiling), (0x98, STATE_CAP)] { - put32(data, at, value); + put32(data, 0x84, pwr.max_power_mw); + // The performance-state ceiling the board's table describes; the power and thermal + // controller below decides how much of it the GPU may use. + for at in g14_v27_2_abi::GLOBALS_PSTATE_SELECTORS { + put32(data, at, pwr.perf_max_pstate * 100); } put32(data, 0x6e, 1); // The firmware's progress checks and compute watchdog, as M3 and M4 27.2 set them.