Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
45b05cd
soc: apple: pmp: detect retained T8132 PMP bridge from the device tree
DjDeveloperr Nov 21, 2026
9717482
drm/asahi: g16: admit J773g 25G83 images, derive DVFS table from ADT,…
DjDeveloperr Nov 21, 2026
0fb2697
drm/asahi: g16: reuse PB epochs, keep compute in flight, share 64 MiB…
DjDeveloperr Nov 21, 2026
b0b5e93
drm/asahi: g16: run the M4 GPU on 26B123 firmware with ADT config and…
DjDeveloperr Nov 21, 2026
ed41e08
selftests: drm/asahi-m4: add 26B123 ABI offset-oracle and update host…
DjDeveloperr Nov 21, 2026
2244998
drm/asahi: g16: Write all four 26B123 power-up words, so the GPU surv…
RyanTheTide Nov 21, 2026
02370c0
drm/asahi: g16: defer recovery snapshot/fault_scan to phase 1 and cle…
DjDeveloperr Nov 23, 2026
20cf248
drm/asahi: g16: set 26B123 MAIN +0x277e as macOS 27.2 does
DjDeveloperr Nov 23, 2026
b0dd36f
drm/asahi: g16: decouple PbEpoch standby pool from per-job Prepared
DjDeveloperr Nov 21, 2026
a8444b4
drm/asahi: g16: skip redundant same-VM WC scrubs and use word-width W…
DjDeveloperr Nov 21, 2026
de219d8
drm/asahi: g16: pipeline timed compute commands and expand compute un…
DjDeveloperr Nov 21, 2026
8a125d5
drm/asahi: g16: inline ready submit, pin completion worker, and tight…
DjDeveloperr Nov 21, 2026
4c0aaf1
drm/asahi: g16: expand render pass slots to 8, isolate scene_list, an…
DjDeveloperr Nov 21, 2026
fee0f3e
drm/asahi: g16: enable multi-flight same-VM render pipelining, fragme…
DjDeveloperr Nov 21, 2026
4f44fd6
drm/asahi: g16: drop Shared::state across retire tail delay and signa…
DjDeveloperr Nov 21, 2026
29b2312
drm/asahi: g16: support DRM_ASAHI_FEATURE_COMPUTE_NO_QUERY_ACCESS
DjDeveloperr Nov 21, 2026
05d7362
drm/asahi: g16: coalesce mailbox doorbells across multi-command publi…
DjDeveloperr Nov 21, 2026
b3d0336
drm/asahi: g16: trim redundant WC writes for compute work and render …
DjDeveloperr Nov 21, 2026
9f14889
drm/asahi: g16: fix scheduler job retention, PB quarantine, scrub_gen…
DjDeveloperr Nov 23, 2026
abf980d
Merge integration/aurora into djdev/g16-272
DjDeveloperr Nov 24, 2026
674d1bc
Merge djdev/g16-272 into djdev/g16-perf-272-pr
DjDeveloperr Nov 24, 2026
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
43 changes: 43 additions & 0 deletions drivers/gpu/drm/asahi/fwid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,49 @@ mod tests {
assert!(measured(builds, 0x13c000, &[[0x5c8df, 0x5c9c2]], [0; 32]).is_none());
}

#[cfg(CONFIG_DRM_ASAHI_G16)]
#[test]
fn j773g_accepts_its_loaded_image() {
let builds = crate::g16::hw::t8132::CONFIG.firmware;
let digest = [
0x91, 0x54, 0xc7, 0xf8, 0x4b, 0xce, 0x32, 0x15, 0x1e, 0x8a, 0x97, 0x41, 0x7d, 0x6a,
0x20, 0x7a, 0x9e, 0xaf, 0x03, 0x54, 0xb4, 0xb8, 0xd6, 0xf0, 0x2a, 0xf5, 0x29, 0x95,
0x40, 0xd3, 0xe8, 0x5a,
];
let found = measured(builds, 0x13c000, &[[0x5c8df, 0x5c9c2]], digest).unwrap();
assert_eq!(found.name, "Apple GFX 25G83 (normalized loaded image, J773g)");
assert_eq!(found.boot_filled, &[(0x224, 4), (0x5c917, 8)]);
assert!(measured(builds, 0x138000, &[[0x5c8df, 0x5c9c2]], digest).is_none());
}

#[cfg(CONFIG_DRM_ASAHI_G16)]
#[test]
fn t8132_25g83_b000_zeroes_what_iboot_fills() {
let builds = crate::g16::hw::t8132::CONFIG.firmware;
let filled = crate::g16::hw::t8132::BOOT_FILLED_25G83_B000;
let build = builds.iter().find(|b| b.boot_filled == filled).unwrap();
let [gkts, ecap] = build.entropy[0];
// The header's per-boot word and DATA address, then one value per parameter record:
// each follows its 8-byte tag and length, back to back from the GKTS record.
assert_eq!(filled[..2], [(0x224, 4), (0x23c, 8)]);
let mut next = gkts;
for &(off, len) in &filled[2..filled.len() - 4] {
assert_eq!(off, next + 8);
next = off + len;
}
assert_eq!(next, 0x5c8df + 0x231);
assert!(filled.contains(&(gkts + 8, 8)));
assert!(filled.contains(&(ecap + 8, 8)));
// Then each tunable table's count byte and body, 0x350 bytes from its header.
for (i, table) in [next, next + 0x350].into_iter().enumerate() {
let at = filled.len() - 4 + 2 * i;
assert_eq!(filled[at..at + 2], [(table + 3, 1), (table + 4, 0x34c)]);
}
let found = measured(builds, 0x13c000, &[[gkts, ecap]], build.text_sha256).unwrap();
assert!(core::ptr::eq(found, build));
assert!(measured(builds, 0x138000, &[[gkts, ecap]], build.text_sha256).is_none());
}

#[test]
fn t6050_admits_only_its_pinned_image() {
for cfg in [
Expand Down
45 changes: 37 additions & 8 deletions drivers/gpu/drm/asahi/g16/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ pub(crate) struct GpuAdt {
pub(crate) text: Range<u64>,
pub(crate) data: Range<u64>,
pub(crate) performance: perf::Source,
/// The firmware layout the boot loader's handoff describes.
pub(crate) layout: &'static hw::FwLayout,
}

/// Find the one original-ADT phram export, with explicit 64-bit reservation cells.
Expand Down Expand Up @@ -118,18 +120,44 @@ fn performance_source(regions: &[Range<u64>]) -> Result<(KVVec<u8>, u64)> {
Ok((copy?, start))
}

/// Validates the FDT contract and returns the reserved physical regions, read-only.
pub(crate) fn read(dev: &device::Device) -> Result<GpuAdt> {
/// The boot loader's handoff for the loaded firmware: its version, segment VAs and flags.
fn handoff(dev: &device::Device) -> Result<(u32, KVec<u64>, KVec<u32>)> {
let node = dev.of_node().ok_or(EINVAL)?;
let version: u32 = node.get_property(c_str!("apple,g16-handoff-version"))?;
let vas: KVec<u64> = node.get_property(c_str!("apple,firmware-segment-vas"))?;
let flags: KVec<u32> = node.get_property(c_str!("apple,firmware-segment-flags"))?;
Ok((version, vas, flags))
}

/// The firmware layout the boot loader's handoff describes, if it describes a known one.
pub(crate) fn layout(dev: &device::Device) -> Option<&'static hw::FwLayout> {
let (version, vas, flags) = handoff(dev).ok()?;
hw::FW_LAYOUTS
.iter()
.copied()
.find(|layout| layout.matches(version, &vas, &flags))
}

/// Validates the FDT contract and returns the reserved physical regions, read-only.
pub(crate) fn read(dev: &device::Device) -> Result<GpuAdt> {
let node = dev.of_node().ok_or(EINVAL)?;
let (version, vas, flags) = handoff(dev)?;
let names: KVec<u8> = node.get_property(c_str!("memory-region-names"))?;
let phandles: KVec<u32> = node.get_property(c_str!("memory-region"))?;
if version != 1
|| vas.as_slice() != [hw::UPPER, hw::UPPER + 0x60000]
|| flags.as_slice() != [1, 0]
|| phandles.len() != 6
let layout = hw::FW_LAYOUTS
.iter()
.copied()
.find(|layout| layout.matches(version, &vas, &flags));
let Some(layout) = layout else {
dev_err!(
dev,
"G16: unsupported boot-loader handoff (version {}, {} segments)\n",
version,
vas.len()
);
return Err(EINVAL);
};
if phandles.len() != 6
|| names.as_slice() != b"ttbs\0pagetables\0handoff\0shared-l2\0fw-text\0fw-data\0"
{
dev_err!(dev, "G16: unsupported boot-loader handoff contract\n");
Expand All @@ -148,8 +176,8 @@ pub(crate) fn read(dev: &device::Device) -> Result<GpuAdt> {
hw::TABLES_SIZE,
hw::HANDOFF_SIZE,
hw::SHARED_L2_SIZE,
0x60000,
0x13c000,
layout.text_size,
layout.data_size,
];
let mut regions: [Range<u64>; 6] = Default::default();
for (index, (name, expected)) in names.iter().zip(sizes).enumerate() {
Expand Down Expand Up @@ -203,5 +231,6 @@ pub(crate) fn read(dev: &device::Device) -> Result<GpuAdt> {
text,
data,
performance,
layout,
})
}
77 changes: 77 additions & 0 deletions drivers/gpu/drm/asahi/g16/adt/perf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@ pub(crate) struct Source {
pub(crate) core_mv: [u32; MAX_STATES],
pub(crate) sram_frequency_mhz: [u32; MAX_STATES],
pub(crate) sram_mv: [u32; MAX_STATES],
/// The sgx node's `gpu-pwr-sample-period-aic-clks`: exact GPU power sample period in ticks
/// of the system counter, where the tree has it.
pub(crate) power_sample_clks: Option<u32>,
/// The sgx node's `gpu-power-sample-period`: coarse integer millisecond GPU power sample
/// period, where the tree has it.
pub(crate) power_sample_period_ms: Option<u32>,
/// `/arm-io/pmgr/clpc` `cpu-avg-limiter-input-tc`: average-power filter time constant in
/// milliseconds, where the tree has it.
pub(crate) avg_power_filter_tc_ms: Option<u32>,
/// `/arm-io/pmgr/clpc` `cpu-lowpeak-limiter-input-tc`: low-peak power limiter filter time
/// constant in milliseconds, where the tree has it.
pub(crate) lowpeak_limiter_tc_ms: Option<u32>,
/// `/arm-io/pmgr/clpc` `cpu-lowpeak-limiter-ki`: low-peak power limiter integral gain in
/// Q16.16 fixed point, where the tree has it.
pub(crate) lowpeak_limiter_ki_q16: Option<u32>,
/// `/arm-io/pmgr/clpc` `cpu-lowpeak-limiter-kp`: low-peak power limiter proportional gain
/// in Q16.16 fixed point, where the tree has it.
pub(crate) lowpeak_limiter_kp_q16: Option<u32>,
/// `/arm-io/gfx-asc/iop-gfx-nub` `coredump-copy-buffer`: size in bytes of the host crash
/// copy buffer, where the tree has it.
pub(crate) coredump_copy_size: Option<u32>,
}

fn u32_at(data: &[u8], at: usize) -> Result<u32, Error> {
Expand Down Expand Up @@ -129,6 +150,15 @@ impl<'a> Tree<'a> {
}
u32_at(data, 0)
}

fn opt_nonzero_cell(&self, node: usize, name: &[u8]) -> Result<Option<u32>, Error> {
match self.cell(node, name) {
Ok(0) => Err(Error::Range),
Ok(value) => Ok(Some(value)),
Err(Error::Missing) => Ok(None),
Err(error) => Err(error),
}
}
}

fn decode_record(data: &[u8], state: usize) -> Result<(u32, u32), Error> {
Expand Down Expand Up @@ -174,12 +204,59 @@ pub(crate) fn parse(data: &[u8]) -> Result<Source, Error> {
if core.len() != count * 8 || sram.len() != count * 8 {
return Err(Error::Shape);
}
let power_sample_clks = tree.opt_nonzero_cell(sgx, b"gpu-pwr-sample-period-aic-clks")?;
let power_sample_period_ms = tree.opt_nonzero_cell(sgx, b"gpu-power-sample-period")?;
let clpc = match tree.child(armio, b"pmgr") {
Ok(pmgr) => match tree.child(pmgr, b"clpc") {
Ok(clpc) => Some(clpc),
Err(Error::Missing) => None,
Err(error) => return Err(error),
},
Err(Error::Missing) => None,
Err(error) => return Err(error),
};
let (
avg_power_filter_tc_ms,
lowpeak_limiter_tc_ms,
lowpeak_limiter_ki_q16,
lowpeak_limiter_kp_q16,
) = if let Some(clpc) = clpc {
(
tree.opt_nonzero_cell(clpc, b"cpu-avg-limiter-input-tc")?,
tree.opt_nonzero_cell(clpc, b"cpu-lowpeak-limiter-input-tc")?,
tree.opt_nonzero_cell(clpc, b"cpu-lowpeak-limiter-ki")?,
tree.opt_nonzero_cell(clpc, b"cpu-lowpeak-limiter-kp")?,
)
} else {
(None, None, None, None)
};
let coredump_copy_size = match tree.child(armio, b"gfx-asc") {
Ok(asc) => match tree.child(asc, b"iop-gfx-nub") {
Ok(nub) => match tree.opt_nonzero_cell(nub, b"coredump-copy-buffer")? {
Some(bytes) if bytes & 0xfff != 0 || bytes > 0x10_0000 => {
return Err(Error::Range);
}
other => other,
},
Err(Error::Missing) => None,
Err(error) => return Err(error),
},
Err(Error::Missing) => None,
Err(error) => return Err(error),
};
let mut source = Source {
count,
frequency_mhz: [0; MAX_STATES],
core_mv: [0; MAX_STATES],
sram_frequency_mhz: [0; MAX_STATES],
sram_mv: [0; MAX_STATES],
power_sample_clks,
power_sample_period_ms,
avg_power_filter_tc_ms,
lowpeak_limiter_tc_ms,
lowpeak_limiter_ki_q16,
lowpeak_limiter_kp_q16,
coredump_copy_size,
};
for i in 0..count {
(source.frequency_mhz[i], source.core_mv[i]) = decode_record(core, i)?;
Expand Down
19 changes: 12 additions & 7 deletions drivers/gpu/drm/asahi/g16/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

//! M4 board admission for the qualified firmware graph.
//!
//! M4 uses ten firmware rows selected from sixteen source states, including off, and sixteen
//! voltage lanes. The source values belong to this machine's preserved original ADT.
//! M4 uses ten (J713, J604) or eleven (J773g) firmware rows selected from sixteen source
//! states, including off, and sixteen voltage lanes. The source values belong to this
//! machine's preserved original ADT.

pub(crate) mod data;

use super::adt::GpuAdt;
use super::fw::initdata::{Performance, PERF_STATES};
use super::fw::initdata::Performance;
use kernel::{device, prelude::*};

/// Admit the qualified table layout while preserving every machine-specific source value.
/// Differently shaped tables and inconsistent voltage pairs fail before publication.
/// The firmware DVFS row count is derived directly from the preserved ADT table shape rather
/// than from a board compatible check; differently shaped tables or inconsistent voltage pairs
/// fail before publication.
pub(crate) fn qualify(dev: &device::Device, adt: &GpuAdt) -> Result<Performance> {
let (performance, layout) = data::select_named(&adt.performance).map_err(|error| {
dev_err!(
Expand All @@ -24,11 +27,13 @@ pub(crate) fn qualify(dev: &device::Device, adt: &GpuAdt) -> Result<Performance>
})?;
dev_info!(
dev,
"M4 ADT DVFS: 16 source states -> 10 firmware rows ({} layout), top {} MHz\n",
"M4 ADT DVFS: {} source states -> {} firmware rows ({} layout), top {} MHz\n",
adt.performance.count,
performance.count,
layout,
performance.frequency[PERF_STATES - 1]
performance.frequency[performance.count - 1]
);
for i in 0..PERF_STATES {
for i in 0..performance.count {
dev_info!(
dev,
"M4 ADT DVFS S{}: main={} MHz auxiliary={} MHz core={} mV SRAM={} mV\n",
Expand Down
41 changes: 23 additions & 18 deletions drivers/gpu/drm/asahi/g16/board/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,40 @@

//! Qualified selections of the original ADT's sixteen performance states for 25G83.
//!
//! The firmware takes ten rows, each a main and an auxiliary frequency at one voltage. Every
//! qualified layout maps the sixteen ADT states onto those rows by index; the values are always
//! this machine's own, never frequencies or voltages copied from a reference machine.
//! The firmware takes ten or eleven rows, each a main and an auxiliary frequency at one voltage.
//! Every qualified layout maps the sixteen ADT states onto those rows by index; the values are
//! always this machine's own, never frequencies or voltages copied from a reference machine.

pub(crate) const SOURCE_STATES: usize = 16;

/// One qualified mapping of the ADT states onto the firmware rows.
/// One qualified mapping of the ADT states onto the first `rows` firmware rows.
pub(crate) struct Layout {
pub(crate) name: &'static str,
pub(crate) rows: usize,
pub(crate) main: [usize; PERF_STATES],
pub(crate) auxiliary: [usize; PERF_STATES],
}

/// Tried in order; a layout matches only when each row's two states share frequency, SRAM
/// frequency and both voltages, so the shapes below cannot be mistaken for each other.
/// frequency and both voltages. The 10-row (6 equal-voltage pairs) and 11-row (5 equal-voltage
/// pairs plus a single top state) ADT shapes are mutually exclusive, so the row count is
/// derived directly from the ADT table without any board check.
pub(crate) const LAYOUTS: [Layout; 2] = [
// J713: four common low states followed by six equal-voltage pairs.
// 10-row ADT shape (e.g. J713/J715): four common low states followed by six equal-voltage
// pairs (4/5 through 14/15).
Layout {
name: "J713",
main: [0, 1, 2, 3, 5, 7, 9, 11, 13, 15],
auxiliary: [0, 1, 2, 3, 4, 6, 8, 10, 12, 14],
name: "10-row",
rows: 10,
main: [0, 1, 2, 3, 5, 7, 9, 11, 13, 15, 0],
auxiliary: [0, 1, 2, 3, 4, 6, 8, 10, 12, 14, 0],
},
// J604 (MacBook Pro 14-inch, M4): five low states, five equal-voltage pairs (5/6 to
// 13/14) and a single top state 15. Eleven distinct rows do not fit in ten, so the fifth
// low state (4) is left out; the four lowest states, every pair and the top state keep
// their own ADT values.
// 11-row ADT shape (e.g. J604/J773g): five low states, five equal-voltage pairs (5/6
// through 13/14) and a single top state 15, with every distinct state kept.
Layout {
name: "J604",
main: [0, 1, 2, 3, 6, 8, 10, 12, 14, 15],
auxiliary: [0, 1, 2, 3, 5, 7, 9, 11, 13, 15],
name: "11-row",
rows: 11,
main: [0, 1, 2, 3, 4, 6, 8, 10, 12, 14, 15],
auxiliary: [0, 1, 2, 3, 4, 5, 7, 9, 11, 13, 15],
},
];

Expand All @@ -44,7 +48,7 @@ pub(crate) fn select(
select_named(source).map(|(performance, _)| performance)
}

/// As [`select`], with the name of the layout that matched.
/// As [`select`], with the name of the ADT shape that matched.
pub(crate) fn select_named(
source: &super::super::adt::perf::Source,
) -> core::result::Result<(Performance, &'static str), super::super::adt::perf::Error> {
Expand All @@ -68,12 +72,13 @@ fn select_layout(
) -> core::result::Result<Performance, super::super::adt::perf::Error> {
use super::super::adt::perf::Error;
let mut performance = Performance {
count: layout.rows,
frequency: [0; PERF_STATES],
auxiliary: [0; PERF_STATES],
voltage: [0; PERF_STATES],
sram: [0; PERF_STATES],
};
for i in 0..PERF_STATES {
for i in 0..layout.rows {
let (main, aux) = (layout.main[i], layout.auxiliary[i]);
if source.frequency_mhz[main] != source.sram_frequency_mhz[main]
|| source.frequency_mhz[aux] != source.sram_frequency_mhz[aux]
Expand Down
Loading