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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions drivers/gpu/drm/asahi/g14_v27_2_abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ 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 {
Expand Down Expand Up @@ -179,26 +173,17 @@ mod tests {

#[test]
fn progress_words_fit_the_globals_and_leave_power_words_alone() {
let power = [0x58usize, 0x5a, 0x5c, 0x6e, 0x84];
let power = [0x58usize, 0x5a, 0x5c, 0x6e, 0x84, 0x88, 0x8c, 0x98];
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().chain(&GLOBALS_PSTATE_SELECTORS).all(|&p| p + 4 <= at || at + 4 <= p));
assert!(power.iter().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.
for at in [0x998, 0x99c, 0x9a0] {
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));
}
}
}
11 changes: 6 additions & 5 deletions drivers/gpu/drm/asahi/gpu/v27_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ 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 {
Expand Down Expand Up @@ -1064,11 +1067,9 @@ impl RootV27_2 {
for (offset, value) in [(0x58, 0xffffu16), (0x5a, 0x28), (0x5c, 0xffff)] {
data[offset..offset + 2].copy_from_slice(&value.to_le_bytes());
}
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);
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, 0x6e, 1);
// The firmware's progress checks and compute watchdog, as M3 and M4 27.2 set them.
Expand Down
Loading