From 0ab9ac9d70c85a92a41ba7c24a71813054c5639a Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Thu, 12 Nov 2026 11:21:06 +0100 Subject: [PATCH 1/3] drm/asahi: g17: M5: InitData for the macOS 27.2 (26B123) common firmware The J813 runs the common 26A428 InitData graph, the J873's interface. macOS 27.2 (26B123) ships a new G17G build (RTKit 3514.41.1), which never acknowledges that graph: the secondary's InitData times out. The 26B123 interface differs from 26A428 in three places, the same three as the J873's G18G build of this release: - both roles expect the InitData root version word with bit 45 set, 0x0c8b_6339_83a0_04c0; - the policy grows by 0x60 and the status config by 8; the other 22 allocations keep their sizes. Everything after the policy in the shared cluster moves by 0x80; the page total and the private cluster (0x6d8 still packs to 0x700) stay as they are; - policy fields +0x2f0c..+0x2f17 move by 0x10 and +0x2fb4..+0x6d9f by 0x18, with a new word at +0x2f28; status-config fields +0x59c..+0x5b3 move by 4 and +0x5b4 to the end by 8, with a new word at +0x5b8 and +0x59c left zero. The new words carry a new accelerator power-controller field, which the generic power and performance setup sets to 5000 and the G17G one leaves alone. The HW data, the roots, the main configs, status B and region C keep their field offsets. Add the 26B123 profile and graph. The 26A428 encoders run unchanged and their policy and status config are moved in place by bands; a nonzero byte no band carries is refused. Compile-time checks keep the bands ascending and inside the new sizes. The board for it is J813_26B123; no configuration selects it yet, and the 26A428 encoding is unchanged. Signed-off-by: Thomas Glanzmann --- drivers/gpu/drm/asahi/g17/fw/m5/initdata.rs | 314 ++++++++++++++++++-- drivers/gpu/drm/asahi/g17/initdata/m5.rs | 2 +- 2 files changed, 284 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/asahi/g17/fw/m5/initdata.rs b/drivers/gpu/drm/asahi/g17/fw/m5/initdata.rs index e4de37f639579..dda570401f0a7 100644 --- a/drivers/gpu/drm/asahi/g17/fw/m5/initdata.rs +++ b/drivers/gpu/drm/asahi/g17/fw/m5/initdata.rs @@ -36,6 +36,11 @@ pub(crate) enum RootProfile { J873G18G26A428, J714G17S26A428, + + /// The common interface of macOS 27.2 (26B123, RTKit 3514.41.1): the + /// [`Self::J873G18G26A428`] graph with a longer policy and status config + /// ([`COMMON26B123_LAYOUTS`]). The J813's G17G build runs it as the J873's G18G one does. + J873G18G26B123, } impl RootProfile { @@ -44,13 +49,28 @@ impl RootProfile { Self::J700G17P => INITDATA_VERSION_WORD, Self::J813G17G25G76 => 0x0c8a_a322_039e_04c0, Self::J873G18G26A428 => COMMON26_INITDATA_VERSION_WORD, + Self::J873G18G26B123 => COMMON26B123_INITDATA_VERSION_WORD, Self::J714G17S26A428 => M5_INITDATA_VERSION_WORD, } } + /// Either common-interface build, 26A428 or 26B123. + pub(crate) const fn is_common26(self) -> bool { + matches!(self, Self::J873G18G26A428 | Self::J873G18G26B123) + } + + /// The shared, private and per-object layouts of a common-interface build. + pub(crate) const fn common26_layouts(self) -> Option<&'static Common26Layouts> { + match self { + Self::J873G18G26A428 => Some(&COMMON26_LAYOUTS), + Self::J873G18G26B123 => Some(&COMMON26B123_LAYOUTS), + Self::J700G17P | Self::J813G17G25G76 | Self::J714G17S26A428 => None, + } + } + pub(crate) const fn root_size(self, role: InstanceRole) -> usize { match self { - Self::J873G18G26A428 => COMMON26_ROOT_SIZE, + Self::J873G18G26A428 | Self::J873G18G26B123 => COMMON26_ROOT_SIZE, Self::J714G17S26A428 => M5_ROOT_SIZE, Self::J700G17P | Self::J813G17G25G76 => root_size(role), } @@ -58,10 +78,10 @@ impl RootProfile { pub(crate) const fn control_opening_opcode(self, role: InstanceRole) -> u32 { match (self, role) { - (Self::J873G18G26A428, InstanceRole::Primary) => { + (Self::J873G18G26A428 | Self::J873G18G26B123, InstanceRole::Primary) => { COMMON26_CONTROL_OPENING_OPCODE_PRIMARY } - (Self::J873G18G26A428, InstanceRole::Secondary) => { + (Self::J873G18G26A428 | Self::J873G18G26B123, InstanceRole::Secondary) => { COMMON26_CONTROL_OPENING_OPCODE_SECONDARY } (Self::J714G17S26A428, InstanceRole::Primary) => M5_CONTROL_OPENING_OPCODE_PRIMARY, @@ -75,7 +95,7 @@ impl RootProfile { pub(crate) const fn control_register_opcode(self) -> Option { match self { - Self::J873G18G26A428 | Self::J714G17S26A428 => None, + Self::J873G18G26A428 | Self::J873G18G26B123 | Self::J714G17S26A428 => None, Self::J700G17P | Self::J813G17G25G76 => Some(CONTROL_OPENING_PRIMARY_REGISTER_OPCODE), } } @@ -83,6 +103,7 @@ impl RootProfile { pub(crate) const fn bundle_view_offsets(self) -> [usize; 5] { match self { Self::J873G18G26A428 => COMMON26_BUNDLE_VIEW_OFFSETS, + Self::J873G18G26B123 => COMMON26B123_BUNDLE_VIEW_OFFSETS, Self::J714G17S26A428 => M5_BUNDLE_VIEW_OFFSETS, Self::J700G17P | Self::J813G17G25G76 => BUNDLE_VIEW_OFFSETS, } @@ -90,7 +111,8 @@ impl RootProfile { pub(crate) const fn bundle_view_extents(self) -> [usize; 5] { match self { - Self::J873G18G26A428 => COMMON26_BUNDLE_VIEW_EXTENTS, + // 26B123 grows only the policy and the status config; the five views keep their sizes. + Self::J873G18G26A428 | Self::J873G18G26B123 => COMMON26_BUNDLE_VIEW_EXTENTS, Self::J714G17S26A428 => M5_BUNDLE_VIEW_EXTENTS, Self::J700G17P | Self::J813G17G25G76 => BUNDLE_VIEW_EXTENTS, } @@ -99,7 +121,7 @@ impl RootProfile { /// The GPU-visible aliases of the firmware's own tables the main config names. pub(crate) const fn region_view_low_addrs(self) -> [u64; 2] { match self { - Self::J873G18G26A428 => COMMON26_REGION_VIEW_LOW_ADDRS, + Self::J873G18G26A428 | Self::J873G18G26B123 => COMMON26_REGION_VIEW_LOW_ADDRS, Self::J714G17S26A428 | Self::J700G17P | Self::J813G17G25G76 => REGION_VIEW_LOW_ADDRS, } } @@ -107,6 +129,7 @@ impl RootProfile { pub(crate) const fn repeated_region_bundle_offset(self) -> usize { match self { Self::J873G18G26A428 => COMMON26_SHARED_LAYOUT.block_88, + Self::J873G18G26B123 => COMMON26B123_SHARED_LAYOUT.block_88, Self::J714G17S26A428 => M5_SHARED_LAYOUT.block_88, Self::J700G17P | Self::J813G17G25G76 => MAIN_REPEATED_REGION_BUNDLE_OFFSET, } @@ -115,6 +138,7 @@ impl RootProfile { pub(crate) const fn work_ring_bundle_offsets(self) -> [usize; WORK_CHANNEL_COUNT] { match self { Self::J873G18G26A428 => COMMON26_WORK_RING_BUNDLE_OFFSETS, + Self::J873G18G26B123 => COMMON26B123_WORK_RING_BUNDLE_OFFSETS, Self::J714G17S26A428 => M5_WORK_RING_BUNDLE_OFFSETS, Self::J700G17P | Self::J813G17G25G76 => WORK_RING_BUNDLE_OFFSETS, } @@ -876,18 +900,17 @@ pub(crate) fn encode_main_config_for_profile( RootProfile::J700G17P => MAIN_SECONDARY_KIND_VALUE, RootProfile::J813G17G25G76 => 0xc, - RootProfile::J873G18G26A428 | RootProfile::J714G17S26A428 => { - COMMON26_MAIN_SECONDARY_KIND - } + RootProfile::J873G18G26A428 | RootProfile::J873G18G26B123 + | RootProfile::J714G17S26A428 => COMMON26_MAIN_SECONDARY_KIND, }); if profile == RootProfile::J714G17S26A428 { put_u64(out, COMMON26_MAIN_SECONDARY_POLICY_PTR, bundle + M5_SHARED_LAYOUT.policy as u64); - } else if profile == RootProfile::J873G18G26A428 { + } else if let Some(layouts) = profile.common26_layouts() { put_u64(out, COMMON26_MAIN_SECONDARY_POLICY_PTR, - bundle + COMMON26_SHARED_LAYOUT.policy as u64); + bundle + layouts.shared.policy as u64); } else { let extra = bundle @@ -909,7 +932,7 @@ pub(crate) fn encode_region_c_for_profile( if out.len() != REGION_C_SIZE { return Err(InitdataError::BufferSize); } - if profile == RootProfile::J873G18G26A428 { + if profile.is_common26() { return encode_common26_region_c(out); } @@ -976,7 +999,7 @@ pub(crate) fn encode_secondary_root_extra_1_for_profile( out.fill(0); write_runs(out, SECONDARY_ROOT_EXTRA_1_RUNS); - if matches!(profile, RootProfile::J813G17G25G76 | RootProfile::J873G18G26A428) { + if profile == RootProfile::J813G17G25G76 || profile.is_common26() { put_u32(out, 0x10, 2); } Ok(()) @@ -1904,16 +1927,213 @@ const _: () = { <= COMMON26_STATUS_B_SPAN); }; +// --- The common interface of macOS 27.2 (26B123, RTKit 3514.41.1) ------------------------------- +// +// Against 26A428, the same changes as the J873's G18G build of this release: +// +// - Both roles expect the InitData root version word with bit 45 set. +// - The policy grows by 0x60 (0x7168 -> 0x71c8 for G17G; 0x7800 -> 0x7860 in the common table) +// and the status config by 8 (0x6d0 -> 0x6d8); the other 22 allocations keep their sizes. +// - Policy and status-config fields move as the bands below describe. The new words carry a new +// accelerator power-controller field (accel +0x1122c), which the generic power and performance +// setup sets to 5000 and the G17G one leaves alone. +// - Every other InitData object keeps its field offsets. + +/// FW_PROVEN 26B123: u16 {0x04c0, 0x83a0, 0x6339, 0x0c8b}. +pub(crate) const COMMON26B123_INITDATA_VERSION_WORD: u64 = 0x0c8b_6339_83a0_04c0; + +/// The common 26A428 table with the 26B123 policy and status config. +pub(crate) const ABI_ALLOCATION_SIZES_26B123: [usize; 24] = [ + 0x2848, 0x0c18, 0x1048, 0x0e10, 0x7860, 0x0068, 0x0800, 0x0088, 0x1800, 0x04c0, 0x4000, 0x0030, + 0xe730, 0x06d8, 0x0020, 0x01b0, 0x4800, 0x28800, 0x79800, 0x9000, 0x0060, 0x0008, 0x0e80, 0x00e4, +]; + +/// Everything after the policy in the shared cluster moves by 0x80 (64-byte packing); the page +/// total is unchanged. +pub(crate) const COMMON26B123_SHARED_LAYOUT: SharedClusterLayout = + shared_cluster_layout(&ABI_ALLOCATION_SIZES_26B123); +/// 0x6d8 packs to the 0x700 that 0x6d0 took: the private cluster is the 26A428 one. +pub(crate) const COMMON26B123_PRIVATE_LAYOUT: PrivateClusterLayout = + private_cluster_layout(&ABI_ALLOCATION_SIZES_26B123); + +pub(crate) const COMMON26B123_BUNDLE_VIEW_OFFSETS: [usize; 5] = [ + COMMON26B123_SHARED_LAYOUT.block_c18, + COMMON26B123_SHARED_LAYOUT.block_1048, + COMMON26B123_SHARED_LAYOUT.block_e10, + COMMON26B123_SHARED_LAYOUT.block_68, + COMMON26B123_SHARED_LAYOUT.block_800, +]; + +pub(crate) const COMMON26B123_WORK_RING_BUNDLE_OFFSETS: [usize; WORK_CHANNEL_COUNT] = + work_ring_offsets(&COMMON26B123_SHARED_LAYOUT); + +/// Policy 26A428 -> 26B123. +/// +/// - +0x2f08 stays; the accelerator's power-controller words at +0x2f0c..+0x2f17 move by 0x10 +/// and the new field is the u32 at +0x2f28. +/// - +0x2f18..+0x2fb3 holds nothing the host writes in either build. +/// - From +0x2fb4 to the last 26A428 store (+0x6d98, u64) everything moves by 0x18, among them +/// the policy state pointer, the AON PTD pointer and the boot timestamp. The host writes +/// nothing past +0x6da0. +const COMMON26B123_POLICY_BANDS: &[LayoutBand] = &[ + band(0x0000, 0x2f0c, 0, Evidence::ProducerChecked), + band(0x2f0c, 0x2f18, 0x10, Evidence::ProducerChecked), + band(0x2fb4, 0x6da0, 0x18, Evidence::ProducerChecked), +]; +const COMMON26B123_POLICY_NEW_WORDS: &[(usize, u32)] = &[(0x2f28, 5000)]; + +/// Status config 26A428 -> 26B123: +0x59c..+0x5b3 move by 4 and +0x5b4 to the end by 8 (the +/// link word and pointer among them). The new +0x59c stays zero (only the zeroing of +/// +0x590..+0x59f covers it); +0x5b8 is the new accelerator field. +const COMMON26B123_STATUS_CONFIG_BANDS: &[LayoutBand] = &[ + band(0x000, 0x59c, 0, Evidence::ProducerChecked), + band(0x59c, 0x5b4, 4, Evidence::ProducerChecked), + band(0x5b4, 0x6d0, 8, Evidence::ProducerChecked), +]; +const COMMON26B123_STATUS_CONFIG_NEW_WORDS: &[(usize, u32)] = &[(0x5b8, 5000)]; + +/// How a later build moves the blocks the 26A428 encoders produce. +pub(crate) struct Common26Relayout { + policy_bands: &'static [LayoutBand], + policy_new_words: &'static [(usize, u32)], + status_config_bands: &'static [LayoutBand], + status_config_new_words: &'static [(usize, u32)], +} + +/// The layouts of one common-interface build. +pub(crate) struct Common26Layouts { + pub(crate) shared: SharedClusterLayout, + pub(crate) private: PrivateClusterLayout, + pub(crate) policy_size: usize, + pub(crate) status_config_size: usize, + /// None for 26A428, which the encoders produce directly. + relayout: Option, +} + +pub(crate) const COMMON26_LAYOUTS: Common26Layouts = Common26Layouts { + shared: COMMON26_SHARED_LAYOUT, + private: COMMON26_PRIVATE_LAYOUT, + policy_size: COMMON26_POLICY_SIZE, + status_config_size: COMMON26_STATUS_CONFIG_SIZE, + relayout: None, +}; + +pub(crate) const COMMON26B123_LAYOUTS: Common26Layouts = Common26Layouts { + shared: COMMON26B123_SHARED_LAYOUT, + private: COMMON26B123_PRIVATE_LAYOUT, + policy_size: ABI_ALLOCATION_SIZES_26B123[ALLOC_POLICY], + status_config_size: ABI_ALLOCATION_SIZES_26B123[ALLOC_STATUS_CONFIG], + relayout: Some(Common26Relayout { + policy_bands: COMMON26B123_POLICY_BANDS, + policy_new_words: COMMON26B123_POLICY_NEW_WORDS, + status_config_bands: COMMON26B123_STATUS_CONFIG_BANDS, + status_config_new_words: COMMON26B123_STATUS_CONFIG_NEW_WORDS, + }), +}; + +/// The common 26B123 build (macOS 27.2; the J813). +pub(crate) const COMMON26B123_GRAPH: Graph = Graph { + profile: RootProfile::J873G18G26B123, + private: COMMON26B123_PRIVATE_LAYOUT, + shared: COMMON26B123_SHARED_LAYOUT, + policy_size: COMMON26B123_LAYOUTS.policy_size, + bundle_view_offsets: COMMON26B123_BUNDLE_VIEW_OFFSETS, + bundle_view_extents: COMMON26_BUNDLE_VIEW_EXTENTS, + work_ring_offsets: COMMON26B123_WORK_RING_BUNDLE_OFFSETS, + state_grids: state_grids(&COMMON26B123_PRIVATE_LAYOUT), + power_assert_tally: COMMON26_GRAPH.power_assert_tally, +}; + +const _: () = { + let (old, new) = (COMMON26_SHARED_LAYOUT, COMMON26B123_SHARED_LAYOUT); + assert!(new.total == old.total && new.policy == old.policy); + assert!(new.block_68 == old.block_68 + 0x80 && new.main_config[0] == old.main_config[0] + 0x80); + assert!(COMMON26B123_PRIVATE_LAYOUT.total == COMMON26_PRIVATE_LAYOUT.total); + assert!(COMMON26B123_PRIVATE_LAYOUT.status_config == COMMON26_PRIVATE_LAYOUT.status_config); + assert!(COMMON26B123_PRIVATE_LAYOUT.roles[0].status_a == COMMON26_PRIVATE_LAYOUT.roles[0].status_a); + assert!(COMMON26B123_PRIVATE_LAYOUT.policy_state == COMMON26_PRIVATE_LAYOUT.policy_state); + assert!(COMMON26_STATUS_CONFIG_IN_STATUS_B + COMMON26B123_LAYOUTS.status_config_size + <= COMMON26_STATUS_B_SPAN); + assert!(bands_fit(COMMON26B123_POLICY_BANDS, COMMON26_POLICY_SIZE, + COMMON26B123_LAYOUTS.policy_size)); + assert!(bands_fit(COMMON26B123_STATUS_CONFIG_BANDS, COMMON26_STATUS_CONFIG_SIZE, + COMMON26B123_LAYOUTS.status_config_size)); +}; + +/// Whether `bands` are ascending, move no byte down, keep their order once moved and land +/// inside `new_size`, so [`relayout_by_bands`] can move them in place. +const fn bands_fit(bands: &[LayoutBand], old_size: usize, new_size: usize) -> bool { + let mut index = 0; + while index < bands.len() { + let band = bands[index]; + if band.delta < 0 || band.start >= band.end || band.end > old_size + || band.end + band.delta as usize > new_size { + return false; + } + if index > 0 { + let previous = bands[index - 1]; + if previous.end > band.start + || previous.end + previous.delta as usize > band.start + band.delta as usize { + return false; + } + } + index += 1; + } + true +} + +/// Move a block encoded in the 26A428 layout (the first `old_size` bytes of `out`) to the layout +/// `bands` describe, in place, and zero what the bands leave behind. A nonzero byte no band +/// carries has no place in the new layout and is refused. +fn relayout_by_bands(bands: &[LayoutBand], old_size: usize, out: &mut [u8]) + -> Result<(), InitdataError> { + let old = out.get(..old_size).ok_or(InitdataError::BufferSize)?; + if old.iter().enumerate().any(|(offset, byte)| { + *byte != 0 && relocate_by_bands(bands, offset).is_none() + }) { + return Err(InitdataError::InterfaceMismatch); + } + for band in bands.iter().rev() { + let delta = band.delta as usize; + if delta == 0 { + continue; + } + let target = band.start + delta; + if target + (band.end - band.start) > out.len() { + return Err(InitdataError::BufferSize); + } + out.copy_within(band.start..band.end, target); + out[band.start..band.end.min(target)].fill(0); + } + Ok(()) +} + +/// Bring a block the 26A428 encoder produced to the build's layout and set the words the build +/// added. +fn relayout_common26( + bands: &[LayoutBand], + new_words: &[(usize, u32)], + old_size: usize, + out: &mut [u8], +) -> Result<(), InitdataError> { + relayout_by_bands(bands, old_size, out)?; + for &(offset, value) in new_words { + put_u32(out, offset, value); + } + Ok(()) +} + impl Graph { pub(crate) fn is_common26(&self) -> bool { - self.profile == RootProfile::J873G18G26A428 + self.profile.is_common26() } } -/// Encode the common 26A428 primary status-B span: status B, status config and the gap to -/// status A. The status config carries the board's 25G76 words relocated, the fields 26A428 -/// added and its new cross-link to status B. +/// Encode the common primary status-B span: status B, status config and the gap to status A. The +/// status config carries the board's 25G76 words relocated, the fields 26A428 added and its new +/// cross-link to status B, moved to the layout of the build `layouts` describes. fn encode_common26_primary_status_b( + layouts: &Common26Layouts, fwctl_state: u64, fwctl_ring: u64, status_b: u64, @@ -1926,15 +2146,24 @@ fn encode_common26_primary_status_b( required_address(fwctl_ring)?; required_address(status_b)?; let config = COMMON26_STATUS_CONFIG_IN_STATUS_B; + // Where the build keeps the status config's half of the cross-link. + let link_word = match &layouts.relayout { + Some(relayout) => relocate_by_bands(relayout.status_config_bands, + COMMON26_STATUS_CONFIG_LINK_WORD) + .ok_or(InitdataError::InterfaceMismatch)?, + None => COMMON26_STATUS_CONFIG_LINK_WORD, + }; out.fill(0); encode_status_block(&mut out[..STATUS_BLOCK_SIZE])?; put_u64(out, COMMON26_STATUS_B_FWCTL_STATE, fwctl_state); put_u64(out, COMMON26_STATUS_B_FWCTL_RING, fwctl_ring); put_u32(out, COMMON26_STATUS_B_CONFIG_HEADER, 1); put_u32(out, COMMON26_STATUS_B_LINK_WORD, 0); - put_u64(out, COMMON26_STATUS_B_LINK_PTR, - status_b + (config + COMMON26_STATUS_CONFIG_LINK_WORD) as u64); - let status_config = &mut out[config..config + COMMON26_STATUS_CONFIG_SIZE]; + put_u64(out, COMMON26_STATUS_B_LINK_PTR, status_b + (config + link_word) as u64); + // The 26A428 encoding fills the first COMMON26_STATUS_CONFIG_SIZE bytes; a later build's + // layout is made from it below. + let status_config = out.get_mut(config..config + layouts.status_config_size) + .ok_or(InitdataError::BufferSize)?; write_relocated_words(M5_25G76_STATUS_CONFIG_WORDS, 0, COMMON26_STATUS_CONFIG_BANDS, status_config)?; for (offset, value) in COMMON26_STATUS_CONFIG_NEW_WORDS { @@ -1964,18 +2193,24 @@ fn encode_common26_primary_status_b( put_u32(status_config, COMMON26_STATUS_CONFIG_LINK_WORD, 1); put_u64(status_config, COMMON26_STATUS_CONFIG_LINK_PTR, status_b + COMMON26_STATUS_B_LINK_WORD as u64); + if let Some(relayout) = &layouts.relayout { + relayout_common26(relayout.status_config_bands, relayout.status_config_new_words, + COMMON26_STATUS_CONFIG_SIZE, status_config)?; + } Ok(()) } -/// Encode the common 26A428 private cluster mapped at `private_base`: the status-B span, both -/// status A blocks, the secondary root's 0x60 object and one opening-producer entry per control -/// channel. +/// Encode the private cluster of the common build `profile` mapped at `private_base`: the +/// status-B span, both status A blocks, the secondary root's 0x60 object and one opening-producer +/// entry per control channel. pub(crate) fn encode_common26_private_cluster( + profile: RootProfile, private_base: u64, fwctl_state: u64, out: &mut [u8], ) -> Result<(), InitdataError> { - let layout = COMMON26_PRIVATE_LAYOUT; + let layouts = profile.common26_layouts().ok_or(InitdataError::InterfaceMismatch)?; + let layout = layouts.private; if out.len() != layout.total { return Err(InitdataError::BufferSize); } @@ -1995,13 +2230,14 @@ pub(crate) fn encode_common26_private_cluster( out.fill(0); let status_b = layout.status_b; let status_a = layout.roles[0].status_a; - encode_common26_primary_status_b(fwctl_state, fwctl_ring, private_base + status_b as u64, + encode_common26_primary_status_b(layouts, fwctl_state, fwctl_ring, + private_base + status_b as u64, &mut out[status_b..status_a])?; for role in layout.roles { encode_status_block(&mut out[role.status_a..role.status_a + STATUS_BLOCK_SIZE])?; } let extra = layout.secondary_extra_1; - encode_secondary_root_extra_1_for_profile(RootProfile::J873G18G26A428, + encode_secondary_root_extra_1_for_profile(profile, &mut out[extra..extra + STATUS_BLOCK_SIZE])?; put_u32(out, layout.control_state + CHANNEL_STATE_PRODUCER * CHANNEL_STATE_SPACING, CONTROL_OPENING_PRIMARY_PRODUCER); @@ -2010,15 +2246,18 @@ pub(crate) fn encode_common26_private_cluster( Ok(()) } -/// Encode the six common 26A428 blocks after the HW data (0xc18, 0x1048, 0xe10, perf/policy, -/// 0x68, 0x800): the board's 25G76 policy words relocated, the fields 26A428 added and the owned -/// pointers. Preserves the HW data and everything from the BRN table on. +/// Encode the six common blocks after the HW data (0xc18, 0x1048, 0xe10, perf/policy, 0x68, +/// 0x800): the board's 25G76 policy words relocated, the fields 26A428 added and the owned +/// pointers, in the layout of the board's build. Preserves the HW data and everything from the +/// BRN table on. pub(crate) fn encode_common26_bundle_policy( board: &Board, bindings: M5PolicyBindings, out: &mut [u8], ) -> Result<(), InitdataError> { - let layout = COMMON26_SHARED_LAYOUT; + let layouts = board.graph.profile.common26_layouts() + .ok_or(InitdataError::InterfaceMismatch)?; + let layout = layouts.shared; if out.len() < layout.brn_table { return Err(InitdataError::BufferSize); } @@ -2043,7 +2282,10 @@ pub(crate) fn encode_common26_bundle_policy( return Err(InitdataError::BufferSize); } } - let policy = &mut out[layout.policy..layout.policy + COMMON26_POLICY_SIZE]; + // The 26A428 encoding fills the first COMMON26_POLICY_SIZE bytes; a later build's layout is + // made from it below. + let policy = out.get_mut(layout.policy..layout.policy + layouts.policy_size) + .ok_or(InitdataError::BufferSize)?; for &(offset, value) in M5_25G76_POLICY_WORDS { if (m5.policy..m5_policy_end).contains(&offset) { write_relocated_words(&[(offset, value)], m5.policy, COMMON26_POLICY_BANDS, policy)?; @@ -2067,6 +2309,10 @@ pub(crate) fn encode_common26_bundle_policy( put_u64(policy, COMMON26_POLICY_STATE_PTR, bindings.state); put_u64(policy, COMMON26_POLICY_AON_PTD_PTR, bindings.aon_ptd); put_u64(policy, COMMON26_POLICY_BOOT_TIMESTAMP, bindings.boot_timestamp); + if let Some(relayout) = &layouts.relayout { + relayout_common26(relayout.policy_bands, relayout.policy_new_words, COMMON26_POLICY_SIZE, + policy)?; + } Ok(()) } @@ -2311,6 +2557,12 @@ pub(crate) const J813: Board = Board { completion_inputs: false, }; +/// The J813 on its macOS 27.2 (26B123) firmware: the same board on the common 26B123 graph. +pub(crate) const J813_26B123: Board = Board { + graph: &COMMON26B123_GRAPH, + ..J813 +}; + const _: () = { use super::target::min_parameter_buffer_pages; assert!(J714.min_parameter_buffer as u64 == min_parameter_buffer_pages(J714.clusters) << 15); diff --git a/drivers/gpu/drm/asahi/g17/initdata/m5.rs b/drivers/gpu/drm/asahi/g17/initdata/m5.rs index 5c3200fefce19..9352e5ec32f3e 100644 --- a/drivers/gpu/drm/asahi/g17/initdata/m5.rs +++ b/drivers/gpu/drm/asahi/g17/initdata/m5.rs @@ -205,7 +205,7 @@ impl InitData { m::encode_common26_board_region_c( &mut self.object_mut(self.region_c)?.bytes_mut()[..m::REGION_C_SIZE]) .map_err(|_| EINVAL)?; - m::encode_common26_private_cluster(PRIVATE, FWCTL, + m::encode_common26_private_cluster(board.graph.profile, PRIVATE, FWCTL, &mut self.object_mut(self.cluster)?.bytes_mut()[..private.total]) .map_err(|_| EINVAL)?; } else { From e15c9526047d7fb3ddbbd320cfe00afc489a5180 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Mon, 16 Nov 2026 01:15:15 +1100 Subject: [PATCH 2/3] drm/asahi: t8140: identify and describe 26B123 G17P firmware MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Identify the current 25G83 and macOS 27.2 26B123 J700 images from both roles’ normalized TEXT. Keep 25G83 on its existing graph and select the common 26B123 graph only for the exact newer image. Describe the J700 hardware data, performance rows, register map and Region C in the packed graph. Reuse the shared 27.2 policy and status-config relocation, with tests for both firmware identities and the changed layouts. Assisted-by: LLM Signed-off-by: Ryan Murray --- drivers/gpu/drm/asahi/fwid.rs | 30 ++++ drivers/gpu/drm/asahi/g17/fw/m5/initdata.rs | 172 +++++++++++++++++++- drivers/gpu/drm/asahi/g17/fw/variant.rs | 14 ++ drivers/gpu/drm/asahi/g17/initdata/m5.rs | 2 +- drivers/gpu/drm/asahi/hw/t8140.rs | 92 ++++++++++- 5 files changed, 301 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/asahi/fwid.rs b/drivers/gpu/drm/asahi/fwid.rs index c7d2e84797cfb..ce0fff033a84a 100644 --- a/drivers/gpu/drm/asahi/fwid.rs +++ b/drivers/gpu/drm/asahi/fwid.rs @@ -590,4 +590,34 @@ mod tests { assert!(admit(t, d, &e[..1], h).is_none()); } } + + #[test] + fn t8140_identifies_current_and_26b123_graphs() { + use crate::g17::fw::m5::initdata::RootProfile; + let crate::g17::fw::variant::Firmware::Identified(builds) = + crate::hw::t8140::CONFIG.firmware + else { + panic!("T8140 must identify its loaded firmware"); + }; + assert_eq!(builds.len(), 2); + assert_eq!(builds[0].os_version, [27, 2, 0]); + assert_eq!(builds[1].os_version, [26, 6, 2]); + t6050_admits_only(builds); + + let [b123, g83] = [&builds[0].images[0], &builds[1].images[0]]; + assert_eq!((b123.text_size, b123.data_size), (0x9c000, 0x188000)); + assert_eq!((g83.text_size, g83.data_size), (0x98000, 0x260000)); + assert_ne!(b123.text_sha256, g83.text_sha256); + + assert!(builds[1].config.is_none()); + let config = builds[0].config.expect("26B123 needs its own graph"); + assert_eq!( + config + .m5 + .expect("26B123 needs a common-graph board") + .graph + .profile, + RootProfile::J873G18G26B123 + ); + } } diff --git a/drivers/gpu/drm/asahi/g17/fw/m5/initdata.rs b/drivers/gpu/drm/asahi/g17/fw/m5/initdata.rs index dda570401f0a7..77297c983253c 100644 --- a/drivers/gpu/drm/asahi/g17/fw/m5/initdata.rs +++ b/drivers/gpu/drm/asahi/g17/fw/m5/initdata.rs @@ -2319,11 +2319,19 @@ pub(crate) fn encode_common26_bundle_policy( /// Encode a common 26A428 region C from the board's 25G76 one: the fields from +0x38 on move up /// by four, plus the fields 26A428 added. Unlike [`encode_common26_region_c`] it keeps the /// board's own tunables (standby timer, minimum confidence, state counts). -pub(crate) fn encode_common26_board_region_c(out: &mut [u8]) -> Result<(), InitdataError> { +pub(crate) fn encode_common26_board_region_c( + board: &Board, + out: &mut [u8], +) -> Result<(), InitdataError> { if out.len() != REGION_C_SIZE { return Err(InitdataError::BufferSize); } - encode_region_c_for_profile(RootProfile::J813G17G25G76, out)?; + let source = if board.chip_id == 0x8140 { + RootProfile::J700G17P + } else { + RootProfile::J813G17G25G76 + }; + encode_region_c_for_profile(source, out)?; let shifted = ABI_ALLOCATION_SIZES_25G76[ALLOC_REGION_C]; if out[shifted..].iter().any(|byte| *byte != 0) { return Err(InitdataError::BufferSize); @@ -2346,8 +2354,8 @@ const fn hw_offset(board: &Board, offset: usize) -> usize { } } -/// What the M5 graph's HW data and power policy depend on per board. Every board is a T6050 -/// running the same firmware build; [`crate::g17::Config::m5`] names the board's. +/// What a packed G17 graph's HW data and power policy depend on per board. +/// [`crate::g17::Config::m5`] names the board selected by the identified build. pub(crate) struct Board { /// The chip ID the HW data names. chip_id: u32, @@ -2411,6 +2419,9 @@ pub(crate) struct Board { /// Whether explicit waits on other kicks take the completion class /// ([`Board::completion_inputs`]). completion_inputs: bool, + /// Whether queues and register programs use the single-cluster G17 forms shared by J700 + /// and J813 rather than the multi-cluster M5 Pro forms. + j813_forms: bool, } /// M5 Pro: two clusters of ten cores. @@ -2441,6 +2452,7 @@ pub(crate) const J714: Board = Board { fan_curve_start_mc: 84_000, g17d_forms: false, completion_inputs: true, + j813_forms: false, }; /// M5 Max: four clusters of ten cores. @@ -2473,6 +2485,7 @@ pub(crate) const J716C: Board = Board { fan_curve_start_mc: 84_000, g17d_forms: false, completion_inputs: false, + j813_forms: false, }; /// J775D's performance controllers run from P3. @@ -2515,6 +2528,108 @@ pub(crate) const J775D: Board = Board { fan_curve_start_mc: 97_000, g17d_forms: true, completion_inputs: false, + j813_forms: false, +}; + +/// A18 Pro (J700) on the common 26B123 graph. The performance rows are the eleven states the +/// existing J700 table A selects from the device tree; unused rows stay zero. +const J700_GPU_PERF_STATES: [M5PerfState; 14] = one_table([ + (0, 125, 765), (338, 605, 765), (492, 630, 765), (618, 650, 765), + (796, 695, 765), (928, 745, 765), (1056, 800, 800), (1170, 845, 845), + (1278, 885, 885), (1338, 905, 905), (1470, 975, 975), + (1470, 975, 975), (1470, 975, 975), (1470, 975, 975), +]); + +/// Relative performance of the J700 table-A rows, in percent. +const J700_GPU_RELATIVE_POWER: [u32; 14] = + [0, 15, 22, 29, 42, 56, 74, 86, 90, 92, 100, 0, 0, 0]; + +/// Relative performance of the J700 table-B rows, in percent. +const J700_GPU_RELATIVE_FREQUENCY: [u32; 16] = + [0, 0, 13, 24, 40, 52, 63, 73, 83, 88, 100, 0, 0, 0, 0, 0]; + +const J700_GPU_BASE: u64 = 0x4_8000_0000; + +/// J700's existing register windows expressed in the packed common-graph form. +const J700_REGISTER_WINDOWS: [M5RegisterWindowSpec; 18] = { + const G: u64 = J700_GPU_BASE; + [ + jw(0, &[0x3_0101_4000], 0x4000, 0, 2), + jw(3, &[0x2_2010_4000], 0x18000, 0, 2), + jw(9, &[0x3_003d_0000], 0x1000, 0, 2), + jw(10, &[0x3_003c_0000], 0x2000, 0, 0), + jw(12, &[0x4_0165_c000], 0x4000, 0, 2), + jw(14, &[0x3_0028_0000], 0x8000, 0, 0), + jw(17, &[G], 0x21400, 0, 2), + jw(22, &[G + 0x100_0000], 0x8000, 0, 2), + jw(26, &[G + 0xd0_4000], 0x8000, 0xd0_4000, 2), + jw(27, &[G + 0xd0_d000], 0x1000, 0xd0_d000, 2), + jw(28, &[G + 0xd5_8000], 0x8000, 0xd5_8000, 2), + jw(29, &[G + 0xd1_0000], 0x4000, 0xd1_0000, 2), + jw(31, &[G + 0xd4_0000], 0x4000, 0xd4_0000, 2), + jw(32, &[G + 0xd6_0000], 0x4000, 0xd6_0000, 2), + jw(35, &[G + 0xe0_0000], 0x4000, 0xe0_0000, 2), + jw(39, &[G + 0xe0_8000], 0x8000, 0, 2), + jw(40, &[G + 0xe1_c000], 0x4000, 0xe1_c000, 2), + jw(41, &[G + 0xe1_f800], 0x4000, 0, 0), + ] +}; + +/// Register-map slots reserved by the J700 graph but not backed by a window. +const J700_RESERVED_REGISTER_SLOTS: [usize; 17] = + [2, 5, 6, 7, 8, 30, 33, 34, 37, 38, 42, 43, 46, 47, 48, 49, 52]; + +const fn j700_register_slot_flags() -> [u32; COMMON26_HW_REGISTER_MAP_SLOTS] { + let mut flags = [0; COMMON26_HW_REGISTER_MAP_SLOTS]; + let mut index = 0; + while index < J700_REGISTER_WINDOWS.len() { + let window = J700_REGISTER_WINDOWS[index]; + flags[window.slot] = window.flag; + index += 1; + } + index = 0; + while index < J700_RESERVED_REGISTER_SLOTS.len() { + flags[J700_RESERVED_REGISTER_SLOTS[index]] = 2; + index += 1; + } + flags +} + +const J700_HW_REGISTER_SLOT_FLAGS: [u32; COMMON26_HW_REGISTER_MAP_SLOTS] = + j700_register_slot_flags(); + +/// The common graph requires an AON row even when the board has no separate AON tuning table. +const J700_AON_RECORDS: [[u32; 3]; 1] = [[0; 3]]; + +/// J700 on macOS 27.2 (26B123): one cluster with six cores on the common 27.2 graph. +pub(crate) const J700_26B123: Board = Board { + chip_id: 0x8140, + graph: &COMMON26B123_GRAPH, + hw_data_insert: false, + clusters: 1, + gpu_cores: 6, + core_revision: (0x1e, 4), + perf_state_count: 10, + perf_states: &J700_GPU_PERF_STATES, + perf_tables: 1, + aux_perf_states: None, + relative_frequency: J700_GPU_RELATIVE_FREQUENCY, + relative_power: Some(&J700_GPU_RELATIVE_POWER), + aon_records: &J700_AON_RECORDS, + register_windows: &J700_REGISTER_WINDOWS, + register_slot_flags: Some(&J700_HW_REGISTER_SLOT_FLAGS), + min_parameter_buffer: (super::target::min_parameter_buffer_pages(1) << 15) as u32, + render_pool: (0x10_0000, 1 << 31), + calibration: None, + controller_defaults: None, + idle_standby_us: None, + mcc_mask: Some(1), + topology_words: None, + hw_words: &[], + fan_curve_start_mc: 84_000, + g17d_forms: false, + completion_inputs: false, + j813_forms: true, }; /// M5 (T8142, MacBook Air J813): one cluster of ten core slots, eight enabled. Values from the @@ -2555,6 +2670,7 @@ pub(crate) const J813: Board = Board { fan_curve_start_mc: 84_000, g17d_forms: false, completion_inputs: false, + j813_forms: true, }; /// The J813 on its macOS 27.2 (26B123) firmware: the same board on the common 26B123 graph. @@ -2933,10 +3049,10 @@ impl Board { self.completion_inputs } - /// Whether this is the J813, whose register programs macOS 27.0 writes in the common 26A428 - /// forms rather than the M5 Pro's (read out of its own kicks under aura). + /// Whether the board uses the single-cluster common-G17 register-program and queue forms + /// rather than the M5 Pro's multi-cluster forms. pub(crate) const fn j813_forms(&self) -> bool { - self.chip_id == 0x8142 + self.j813_forms } /// The board's `index`th register window. @@ -3661,3 +3777,45 @@ pub(crate) fn encode_m5_policy_controller_defaults_j775d(out: &mut [u8]) -> Resu } Ok(()) } + +use kernel::prelude::kunit_tests; + +#[kunit_tests(asahi_g17_fw272_layout)] +mod fw272_tests { + use super::*; + + #[test] + fn j700_26b123_uses_the_common_layout_delta() { + assert_eq!(J700_26B123.graph.profile, RootProfile::J873G18G26B123); + assert_eq!(J700_26B123.graph.profile.version_word(), 0x0c8b_6339_83a0_04c0); + assert_eq!( + COMMON26B123_LAYOUTS.policy_size, + COMMON26_LAYOUTS.policy_size + 0x60 + ); + assert_eq!( + COMMON26B123_LAYOUTS.status_config_size, + COMMON26_LAYOUTS.status_config_size + 8 + ); + assert_eq!( + COMMON26B123_SHARED_LAYOUT.block_68, + COMMON26_SHARED_LAYOUT.block_68 + 0x80 + ); + assert_eq!(COMMON26B123_SHARED_LAYOUT.total, COMMON26_SHARED_LAYOUT.total); + assert_eq!(COMMON26B123_PRIVATE_LAYOUT.total, COMMON26_PRIVATE_LAYOUT.total); + } + + #[test] + fn j700_26b123_region_c_keeps_board_values() { + let mut region = [0u8; REGION_C_SIZE]; + encode_common26_board_region_c(&J700_26B123, &mut region).unwrap(); + let word = |offset| { + u32::from_le_bytes(region[offset..offset + 4].try_into().unwrap()) + }; + // The common graph inserts its enable word at +0x38; the J700 maximum-power input therefore + // moves from +0x84 to +0x88. The 27.2-only controller word is at +0x2f28 in policy, + // not Region C, so this board value stays 9550 mW. + assert_eq!(word(0x38), 1); + assert_eq!(word(0x88), 9550); + assert_eq!(word(0x7c8), 2000); + } +} diff --git a/drivers/gpu/drm/asahi/g17/fw/variant.rs b/drivers/gpu/drm/asahi/g17/fw/variant.rs index d5d37e8e06698..52231f399dc3e 100644 --- a/drivers/gpu/drm/asahi/g17/fw/variant.rs +++ b/drivers/gpu/drm/asahi/g17/fw/variant.rs @@ -197,6 +197,19 @@ pub(crate) const V26A428_M5: Variant = Variant { ..V26A428 }; +/// The common G17 interface shipped for J700 in macOS 27.2 (26B123). +/// +/// Its queue and command protocol is the common two-role protocol. The exact InitData graph is +/// selected by the build's [`crate::g17::Config`], so the current J700 build remains on +/// [`V26A428`] and its existing graph. +pub(crate) const V26B123: Variant = Variant { + m5_commands: true, + traversal_exclusion: false, + render_ray_query: false, + registration_power_hold: false, + ..V26A428 +}; + pub(crate) const V25F84: Variant = Variant { qid_floor: 0, registration: QueueRegistration::Mailbox, @@ -208,6 +221,7 @@ pub(crate) const V25F84: Variant = Variant { const _: () = { assert!(super::queue::PointerBlock::valid_layout(&V26A428.pointers)); + assert!(super::queue::PointerBlock::valid_layout(&V26B123.pointers)); assert!(super::queue::PointerBlock::valid_layout(&V25G83.pointers)); assert!(super::queue::PointerBlock::valid_layout(&V25F84.pointers)); }; diff --git a/drivers/gpu/drm/asahi/g17/initdata/m5.rs b/drivers/gpu/drm/asahi/g17/initdata/m5.rs index 9352e5ec32f3e..e79ee2c6664e1 100644 --- a/drivers/gpu/drm/asahi/g17/initdata/m5.rs +++ b/drivers/gpu/drm/asahi/g17/initdata/m5.rs @@ -202,7 +202,7 @@ impl InitData { m::encode_common26_aon_ptd(board, &mut self.object_mut(aon)?.bytes_mut()[..m::M5_AON_PTD_SIZE]) .map_err(|_| EINVAL)?; if common26 { - m::encode_common26_board_region_c( + m::encode_common26_board_region_c(board, &mut self.object_mut(self.region_c)?.bytes_mut()[..m::REGION_C_SIZE]) .map_err(|_| EINVAL)?; m::encode_common26_private_cluster(board.graph.profile, PRIVATE, FWCTL, diff --git a/drivers/gpu/drm/asahi/hw/t8140.rs b/drivers/gpu/drm/asahi/hw/t8140.rs index 23b2c344a37f3..62b1628f16ebb 100644 --- a/drivers/gpu/drm/asahi/hw/t8140.rs +++ b/drivers/gpu/drm/asahi/hw/t8140.rs @@ -10,8 +10,14 @@ use crate::g17::{ }; use crate::hw::{GpuGen, GpuVariant}; -/// Static configuration of the T8140 GPU. +/// Static configuration of the T8140 GPU. The exact loaded firmware selects the graph below. pub(crate) const CONFIG: Config = Config { + firmware: crate::g17::fw::variant::Firmware::Identified(&BUILDS), + ..BASE +}; + +/// The J700 hardware before a firmware build has been selected. +const BASE: Config = Config { chip_id: CHIP_ID, identity: Identity { family: 0xa, @@ -58,6 +64,8 @@ pub(crate) const CONFIG: Config = Config { adopt_root_entries: true, fabric_bridge: true, sleep_restart: true, + // Replaced by CONFIG. Keeping the old graph here makes every field of the 25G83 + // configuration explicit and gives the 26B123 override a non-recursive base. firmware: crate::g17::fw::variant::Firmware::Fixed(&crate::g17::fw::variant::V26A428), // The layouts the A18 Pro has always run with. core_layout: crate::g17::CoreLayout { @@ -69,6 +77,88 @@ pub(crate) const CONFIG: Config = Config { }, }; +/// J700 on the common macOS 27.2 graph. Only the exactly identified 26B123 image selects it; +/// the current 25G83 image continues to use [`BASE`] unchanged. +const CONFIG_26B123: Config = Config { + profile: crate::g17::FirmwareProfile::M5PublishedRoots, + pm_metrics: None, + windows: &[], + reserved_slots: &[], + perf: None, + opps: 0, + region_c: None, + m5: Some(&crate::g17::fw::m5::initdata::J700_26B123), + firmware: crate::g17::fw::variant::Firmware::Identified(&[BUILD_26B123]), + ..BASE +}; + +/// Exact J700 builds, newest first. iBoot loads the primary and secondary b100 TEXT segments +/// back to back. The digest excludes each role's load fields, boot arguments and entropy records, +/// the same normalization used by the M5 build table. +const BUILDS: [crate::g17::fw::variant::Build; 2] = [ + crate::g17::fw::variant::Build { + config: Some(&CONFIG_26B123), + ..BUILD_26B123 + }, + BUILD_25G83, +]; + +const BUILD_25G83: crate::g17::fw::variant::Build = crate::g17::fw::variant::Build { + os_version: [26, 6, 2], + name: "26.6.2 (25G83), G17P", + images: &[crate::fwid::FirmwareBuild { + name: "25G83 for T8140 G17P, primary then secondary", + text_size: 0x98000, + data_size: 0x260000, + entropy: &[[0x46251, 0x46334], [0x91bd9, 0x91cbc]], + boot_filled: &[ + (0x224, 4), + (0x23c, 8), + (0x45b11, 0x740), + (0x46251, 0x231), + (0x4c224, 4), + (0x4c23c, 8), + (0x91499, 0x740), + (0x91bd9, 0x231), + ], + text_sha256: [ + 0xc8, 0x8c, 0x3f, 0x28, 0x72, 0xd5, 0xfc, 0x12, 0x35, 0x5f, 0x42, 0x14, 0x86, 0xd0, + 0xdb, 0x9d, 0xe0, 0x88, 0x87, 0x65, 0xab, 0xe9, 0x62, 0x0d, 0x28, 0x87, 0x17, 0x9f, + 0x67, 0x98, 0x92, 0x06, + ], + }], + variant: &crate::g17::fw::variant::V26A428, + config: None, +}; + +const BUILD_26B123: crate::g17::fw::variant::Build = crate::g17::fw::variant::Build { + os_version: [27, 2, 0], + name: "27.2 (26B123), G17P", + images: &[crate::fwid::FirmwareBuild { + name: "26B123 for T8140 G17P, primary then secondary", + text_size: 0x9c000, + data_size: 0x188000, + entropy: &[[0x4629c, 0x4637f], [0x95bcc, 0x95caf]], + boot_filled: &[ + (0x224, 4), + (0x23c, 8), + (0x45b5c, 0x740), + (0x4629c, 0x231), + (0x4c224, 4), + (0x4c23c, 8), + (0x9548c, 0x740), + (0x95bcc, 0x231), + ], + text_sha256: [ + 0xfd, 0xec, 0xca, 0x8b, 0x92, 0x35, 0x8d, 0x89, 0x13, 0x6f, 0x69, 0xda, 0x5e, 0x90, + 0xe5, 0xbd, 0xe5, 0x0a, 0x64, 0x78, 0xf6, 0x47, 0x45, 0x6c, 0x79, 0xac, 0x47, 0x84, + 0x68, 0x5a, 0x36, 0xe1, + ], + }], + variant: &crate::g17::fw::variant::V26B123, + config: None, +}; + use crate::g17::fw::initdata::{PerfConfig, RegisterWindow, PERF_STATES}; /// Chip identifier written to the hardware data. From dcf22f8d62bed629edef626d2eb6235f990c3700 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 00:16:40 +1100 Subject: [PATCH 3/3] drm/asahi: g17: M5: take the region C source from the board encode_common26_board_region_c() picked the 25G76-era region C layout by chip ID (0x8140 -> J700 G17P, else J813 G17G). Which layout a board starts from follows its firmware generation, so carry it in the Board data (region_c_source) instead of testing the chip ID. No change in the encoded bytes for any board. Signed-off-by: Ryan Murray --- drivers/gpu/drm/asahi/g17/fw/m5/initdata.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/asahi/g17/fw/m5/initdata.rs b/drivers/gpu/drm/asahi/g17/fw/m5/initdata.rs index d60d44a36c6c6..84519cabea175 100644 --- a/drivers/gpu/drm/asahi/g17/fw/m5/initdata.rs +++ b/drivers/gpu/drm/asahi/g17/fw/m5/initdata.rs @@ -2326,12 +2326,7 @@ pub(crate) fn encode_common26_board_region_c( if out.len() != REGION_C_SIZE { return Err(InitdataError::BufferSize); } - let source = if board.chip_id == 0x8140 { - RootProfile::J700G17P - } else { - RootProfile::J813G17G25G76 - }; - encode_region_c_for_profile(source, out)?; + encode_region_c_for_profile(board.region_c_source, out)?; let shifted = ABI_ALLOCATION_SIZES_25G76[ALLOC_REGION_C]; if out[shifted..].iter().any(|byte| *byte != 0) { return Err(InitdataError::BufferSize); @@ -2419,6 +2414,10 @@ pub(crate) struct Board { /// Whether queues and register programs use the single-cluster G17 forms shared by J700 /// and J813 rather than the multi-cluster M5 Pro forms. j813_forms: bool, + /// The 25G76-era region C layout the board's tunables come from, which + /// [`encode_common26_board_region_c`] moves to the common 26A428 layout: the board's own + /// firmware generation, not its chip ID. + region_c_source: RootProfile, } /// M5 Pro: two clusters of ten cores. @@ -2449,6 +2448,7 @@ pub(crate) const J714: Board = Board { g17d_forms: false, completion_inputs: true, j813_forms: false, + region_c_source: RootProfile::J813G17G25G76, }; /// M5 Max: four clusters of ten cores. @@ -2481,6 +2481,7 @@ pub(crate) const J716C: Board = Board { g17d_forms: false, completion_inputs: false, j813_forms: false, + region_c_source: RootProfile::J813G17G25G76, }; /// J775D's performance controllers run from P3. @@ -2523,6 +2524,7 @@ pub(crate) const J775D: Board = Board { g17d_forms: true, completion_inputs: false, j813_forms: false, + region_c_source: RootProfile::J813G17G25G76, }; /// A18 Pro (J700) on the common 26B123 graph. The performance rows are the eleven states the @@ -2624,6 +2626,7 @@ pub(crate) const J700_26B123: Board = Board { g17d_forms: false, completion_inputs: false, j813_forms: true, + region_c_source: RootProfile::J700G17P, }; /// M5 (T8142, MacBook Air J813): one cluster of ten core slots, eight enabled. Values from the @@ -2664,6 +2667,7 @@ pub(crate) const J813: Board = Board { g17d_forms: false, completion_inputs: false, j813_forms: true, + region_c_source: RootProfile::J813G17G25G76, }; /// The J813 on its macOS 27.2 (26B123) firmware: the same board on the common 26B123 graph.