From 7bc0ece9b507b1581c69f5c4073b95c4802906fc Mon Sep 17 00:00:00 2001 From: Nikita Konkov <95355711+javanoo6@users.noreply.github.com> Date: Thu, 5 Nov 2026 12:11:51 +0300 Subject: [PATCH 01/13] drm/asahi: g15: pin J514S cd05 firmware TEXT The J514S 14.7 boot chain can load a T6030 firmware build whose full TEXT digest is not in the admission table. Probe refuses it and no GPU render node is created. Desktop use with the explicit prefix override reaches firmware READY and reduces Hyprland CPU use from several cores to single-digit percentages. Pin the complete measured digest only for J514S, with its segment sizes and marker, rather than requiring a persistent bring-up override. Exercise the production firmware table and exact lookup with the override disabled. Reject other boards, altered digest suffixes, sizes and markers. Link: https://github.com/omacom/linux-aurora/issues/247 Signed-off-by: Nikita Konkov <95355711+javanoo6@users.noreply.github.com> Signed-off-by: Scott Jones --- drivers/gpu/drm/asahi/g15/hw.rs | 15 ++++++++++ tools/asahi/g15-maintained-handoff-tests.py | 31 +++++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/asahi/g15/hw.rs b/drivers/gpu/drm/asahi/g15/hw.rs index b211088310210..36310376e12b5 100644 --- a/drivers/gpu/drm/asahi/g15/hw.rs +++ b/drivers/gpu/drm/asahi/g15/hw.rs @@ -175,6 +175,21 @@ pub(crate) mod t6030 { 0xe7, 0x9b, 0xb9, 0xb0, 0x22, 0x09, 0xdb, 0x53, ], }, + // J514S firmware measured on the 14.7 boot chain; desktop rendering + // was verified with the bring-up prefix override (issue #247). + FirmwareBuild { + name: "J514S cd05 firmware (14.7 boot chain)", + machine: Some(kernel::c_str!("apple,j514s")), + text_size: 0x5c000, + data_size: 0x114000, + marker: 0x58e88, + text_sha256: [ + 0xcd, 0x05, 0xaf, 0x6a, 0x82, 0x8b, 0x52, 0xe4, + 0xc2, 0xfe, 0xd2, 0x00, 0x86, 0xd3, 0xd1, 0x8a, + 0x7d, 0xb4, 0x2e, 0x03, 0xa8, 0xfd, 0x6f, 0x83, + 0x54, 0xf9, 0xf0, 0x6e, 0x0a, 0x61, 0x36, 0x3e, + ], + }, ], machine: kernel::c_str!("apple,t6030"), platform: super::Platform::AdtWithPmp, diff --git a/tools/asahi/g15-maintained-handoff-tests.py b/tools/asahi/g15-maintained-handoff-tests.py index fdafd799645cb..e0fb4438de379 100644 --- a/tools/asahi/g15-maintained-handoff-tests.py +++ b/tools/asahi/g15-maintained-handoff-tests.py @@ -137,12 +137,38 @@ def item(s, marker): OWNER_CALLS.set(0); let bytes = fixture(kind); assert!(parse(&dev, &Adt { data: &bytes }).is_err()); assert_eq!(OWNER_CALLS.get(), 0); } - assert_eq!(BUILDS.len(), 3, "maintained B0 firmware row must not require an absent profile symbol"); + assert_eq!(BUILDS.len(), 4, "maintained B0 firmware row must not require an absent profile symbol"); for (row, machine) in [(1, &b"apple,j516s"[..]), (2, &b"apple,j514s"[..])] { assert_eq!(BUILDS[row].machine.unwrap().to_bytes(), machine); assert_eq!((BUILDS[row].text_size, BUILDS[row].data_size, BUILDS[row].marker), (0x5c000, 0x114000, 0x58e88)); assert_eq!(BUILDS[row].text_sha256, [0xda,0x26,0xec,0xca,0xb1,0xf8,0x59,0x8d,0xa8,0x0c,0x85,0x5e,0xca,0x91,0x65,0x20,0x40,0x6d,0x1d,0x06,0x70,0xf1,0xd4,0x70,0xe7,0x9b,0xb9,0xb0,0x22,0x09,0xdb,0x53]); } + // Issue #247: this J514S build must pin without the bring-up override. + use identity::lookup::{Measured, Verdict, verdict}; + let measured = Measured { + text_size: 0x5c000, data_size: 0x114000, marker: 0x58e88, + sha256: [0xcd,0x05,0xaf,0x6a,0x82,0x8b,0x52,0xe4, + 0xc2,0xfe,0xd2,0x00,0x86,0xd3,0xd1,0x8a, + 0x7d,0xb4,0x2e,0x03,0xa8,0xfd,0x6f,0x83, + 0x54,0xf9,0xf0,0x6e,0x0a,0x61,0x36,0x3e], + }; + let identify = |m: &Measured, machine: &[u8]| verdict(m, BUILDS.iter().map(|b| ( + Measured { text_size: b.text_size, data_size: b.data_size, + marker: b.marker, sha256: b.text_sha256 }, + b.machine.map_or(true, |board| board.to_bytes() == machine), + )), 0); + assert!(matches!(identify(&measured, b"apple,j514s"), Verdict::Pinned(_)), + "J514S cd05 firmware must pin without a prefix override"); + assert_eq!(identify(&measured, b"apple,j516s"), Verdict::Refused); + let mut changed = measured; + changed.sha256[31] ^= 1; + assert_eq!(identify(&changed, b"apple,j514s"), Verdict::Refused); + changed = measured; changed.text_size += 0x1000; + assert_eq!(identify(&changed, b"apple,j514s"), Verdict::Refused); + changed = measured; changed.data_size += 0x1000; + assert_eq!(identify(&changed, b"apple,j514s"), Verdict::Refused); + changed = measured; changed.marker += 8; + assert_eq!(identify(&changed, b"apple,j514s"), Verdict::Refused); for error in [0, -517, -12] { INIT_ERROR.set(error); let shared = Arc::new(Shared); let result = Rtkit::new(&dev, &shared); assert_eq!(result.is_ok(), error == 0); @@ -167,7 +193,8 @@ def main(): while depth: depth+=(hw[end]=='[')-(hw[end]==']'); end+=1 firmware='static BUILDS: &[FirmwareBuild] = &'+hw[start:end]+';\n'+item(hw,'pub(crate) struct FirmwareBuild') constructor=item(boot,' fn new(dev: &device::Device, shared: &Arc)') - source=PREFIX+'\nmod hw {\n'+constants+'\n}\nmod record {\n'+record_constants+'\n}\n'+helpers+'\n'+firmware+'\nimpl Rtkit {\n'+constructor+'\n}\n'+CASES + identity='mod identity {\n'+''.join(f'#[path = "{G15 / "identity" / (name + ".rs")}"] pub(crate) mod {name};\n' for name in ['matching', 'lookup'])+'}\n' + source=PREFIX+'\nmod hw {\n'+constants+'\n}\nmod record {\n'+record_constants+'\n}\n'+helpers+'\n'+firmware+'\nimpl Rtkit {\n'+constructor+'\n}\n'+identity+CASES variants={'actual':source} if a.mutations: variants['skip-owner-check']=source.replace('if !glue::reserved_uat(i as u32, r.start, r.end - r.start) {','if false {') From daec11fda43a04f38556a52c21d3d4f4ce96533f Mon Sep 17 00:00:00 2001 From: Scott Jones Date: Sun, 8 Nov 2026 00:39:01 -0500 Subject: [PATCH 02/13] tools/asahi: refresh T6030 golden pins for the J514S cd05 row The J514S cd05 FirmwareBuild row adds 15 lines to the T6030 firmware table, which changes the pinned hw.rs file and t6030 module digests. With that row removed both digests are their previous values, so the T6030 profile itself is unchanged. Refresh the two pins and record why. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Scott Jones --- tools/asahi/g15-zero-words-tests.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/asahi/g15-zero-words-tests.py b/tools/asahi/g15-zero-words-tests.py index c6e32d76cb415..2a73390f55282 100644 --- a/tools/asahi/g15-zero-words-tests.py +++ b/tools/asahi/g15-zero-words-tests.py @@ -18,9 +18,11 @@ renumbering margins became tuning constants (the tables are unchanged). Its T6030 configuration module is independently pinned to the original bytes, -except for the J514S B0 FirmwareBuild row added to its firmware table: the -module is the original pinned bytes (0079ae08) plus that one 15-line row, and -the whole hw.rs pin was refreshed with it. prepare_board() is pinned too; +except for the J514S B0 FirmwareBuild row and the J514S cd05 FirmwareBuild row +added to its firmware table: the module is the original pinned bytes (0079ae08) +plus those two 15-line rows, and the whole hw.rs pin was refreshed with each +(with the cd05 row removed, both pins are their earlier values e9b80be9 and +cab592b5). prepare_board() is pinned too; it was refreshed for the same Board change (its T6030 arm is unchanged). """ @@ -37,11 +39,11 @@ GOLDEN_FILES = { "board/data.rs": "7c5ff1077ca3296cbfc9e7144294162b6dea78a3774c38eeed4b0f59a14d7a5c", "board/template.rs": "286872f5474a67534f214e83e659253299f85143f3dc59035fa80894022e2549", - "hw.rs": "c54a4f8342fb466f82f4b9cfed6a137ee1ca1f4d80ede4e1b7f397d39223558e", + "hw.rs": "82ee9d163da888e6dc506635e8e4a59cd3f4b4c34b3879e162702b8561093d9e", "power/idle.rs": "4928ecf7699b3ca85ff5143eb6e996efd40d47321e29a238a02c8873bc9f102c", } GOLDEN_FUNCTIONS = { - ("hw.rs", "pub(crate) mod t6030 {"): "cab592b5d776be9ede93b96b1b0526c1d838ef2948a5e4a86caa4ec71f71c2ca", + ("hw.rs", "pub(crate) mod t6030 {"): "d6c3020007646cba504db26bdfe5232e45185aba1d4603931da9a8d29bec40de", ("initdata.rs", "fn templates("): "c3115c9926d3d7d93317cb8510e93b04f30b0c256811d7137568e822dd93b8ee", ("initdata.rs", "pub(crate) fn prepare_board("): "ebef64ab87ef7b1f994eb7fa2a2424d05bc4fc9e88cbfbf18e51570bdfc4222d", ("board.rs", "pub(crate) fn from_adt("): "cecd0b28db5bd94d3b75c1bbb5f35204e8bf0699f74e5b3d08228c59025f6ac2", From a7cd22984b9cb1853965e64514c17c5b1a4dc8f4 Mon Sep 17 00:00:00 2001 From: joel cristobal Date: Fri, 6 Nov 2026 02:07:57 -0500 Subject: [PATCH 03/13] drm/asahi: g15: pin the cd05 firmware TEXT on the J516S Some 16-inch M3 Pro (J516S) units on the 14.7 boot chain load a B0 GPU firmware image whose TEXT digest differs from the pinned J516S row: TEXT 0x5c000, DATA 0x114000, GKTS marker 0x58e88 and TEXT sha256 cd05af6a828b52e4c2fed20086d3d18a7db42e03a8fd6f8354f9f06e0a61363e. The build is refused with "loaded GFX TEXT identity mismatch", so there is no render node and the compositor falls back to llvmpipe. The GPU only starts with the g15_accept_text_prefix bring-up override. Add this build as a J516S-only row. Rows still pin on the machine they name; nothing changes on the J514S or on other machines. Extend the maintained-handoff host test to check the new row and refresh the zero-words golden pins for hw.rs and the T6030 module, which change by exactly this one row. Measured on a J516S (apple,j516s apple,t6030; os-fw 14.7, system-fw 15.5, iBoot2 iBoot-10151.140.19.700.2) with linux-aurora 7.2.11.aurora14-1 and the override: the admission line reports the identical sizes, marker and digest, and the GPU reaches READY with renderD128 present. Link: https://github.com/omacom/linux-aurora/issues/247 Link: https://github.com/omacom/omarchy/issues/17739 Signed-off-by: joel cristobal Signed-off-by: Scott Jones --- drivers/gpu/drm/asahi/g15/hw.rs | 16 ++++++++++++++++ tools/asahi/g15-maintained-handoff-tests.py | 9 ++++++--- tools/asahi/g15-zero-words-tests.py | 14 +++++++------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/asahi/g15/hw.rs b/drivers/gpu/drm/asahi/g15/hw.rs index 36310376e12b5..14e4c92a60888 100644 --- a/drivers/gpu/drm/asahi/g15/hw.rs +++ b/drivers/gpu/drm/asahi/g15/hw.rs @@ -190,6 +190,22 @@ pub(crate) mod t6030 { 0x54, 0xf9, 0xf0, 0x6e, 0x0a, 0x61, 0x36, 0x3e, ], }, + // Some J516S units on the same 14.7 boot chain load a different B0 + // TEXT image with identical sizes and marker. Pin its complete + // measured digest for the J516S only. + FirmwareBuild { + name: "J516S cd05 firmware (14.7 boot chain)", + machine: Some(kernel::c_str!("apple,j516s")), + text_size: 0x5c000, + data_size: 0x114000, + marker: 0x58e88, + text_sha256: [ + 0xcd, 0x05, 0xaf, 0x6a, 0x82, 0x8b, 0x52, 0xe4, + 0xc2, 0xfe, 0xd2, 0x00, 0x86, 0xd3, 0xd1, 0x8a, + 0x7d, 0xb4, 0x2e, 0x03, 0xa8, 0xfd, 0x6f, 0x83, + 0x54, 0xf9, 0xf0, 0x6e, 0x0a, 0x61, 0x36, 0x3e, + ], + }, ], machine: kernel::c_str!("apple,t6030"), platform: super::Platform::AdtWithPmp, diff --git a/tools/asahi/g15-maintained-handoff-tests.py b/tools/asahi/g15-maintained-handoff-tests.py index e0fb4438de379..f2e344697dc3d 100644 --- a/tools/asahi/g15-maintained-handoff-tests.py +++ b/tools/asahi/g15-maintained-handoff-tests.py @@ -137,12 +137,15 @@ def item(s, marker): OWNER_CALLS.set(0); let bytes = fixture(kind); assert!(parse(&dev, &Adt { data: &bytes }).is_err()); assert_eq!(OWNER_CALLS.get(), 0); } - assert_eq!(BUILDS.len(), 4, "maintained B0 firmware row must not require an absent profile symbol"); + assert_eq!(BUILDS.len(), 5, "maintained B0 firmware row must not require an absent profile symbol"); for (row, machine) in [(1, &b"apple,j516s"[..]), (2, &b"apple,j514s"[..])] { assert_eq!(BUILDS[row].machine.unwrap().to_bytes(), machine); assert_eq!((BUILDS[row].text_size, BUILDS[row].data_size, BUILDS[row].marker), (0x5c000, 0x114000, 0x58e88)); assert_eq!(BUILDS[row].text_sha256, [0xda,0x26,0xec,0xca,0xb1,0xf8,0x59,0x8d,0xa8,0x0c,0x85,0x5e,0xca,0x91,0x65,0x20,0x40,0x6d,0x1d,0x06,0x70,0xf1,0xd4,0x70,0xe7,0x9b,0xb9,0xb0,0x22,0x09,0xdb,0x53]); } + assert_eq!(BUILDS[4].machine.unwrap().to_bytes(), b"apple,j516s"); + assert_eq!((BUILDS[4].text_size, BUILDS[4].data_size, BUILDS[4].marker), (0x5c000, 0x114000, 0x58e88)); + assert_eq!(BUILDS[4].text_sha256, [0xcd,0x05,0xaf,0x6a,0x82,0x8b,0x52,0xe4,0xc2,0xfe,0xd2,0x00,0x86,0xd3,0xd1,0x8a,0x7d,0xb4,0x2e,0x03,0xa8,0xfd,0x6f,0x83,0x54,0xf9,0xf0,0x6e,0x0a,0x61,0x36,0x3e]); // Issue #247: this J514S build must pin without the bring-up override. use identity::lookup::{Measured, Verdict, verdict}; let measured = Measured { @@ -157,9 +160,9 @@ def item(s, marker): marker: b.marker, sha256: b.text_sha256 }, b.machine.map_or(true, |board| board.to_bytes() == machine), )), 0); - assert!(matches!(identify(&measured, b"apple,j514s"), Verdict::Pinned(_)), + assert!(matches!(identify(&measured, b"apple,j514s"), Verdict::Pinned(3)), "J514S cd05 firmware must pin without a prefix override"); - assert_eq!(identify(&measured, b"apple,j516s"), Verdict::Refused); + assert_eq!(identify(&measured, b"apple,j516s"), Verdict::Pinned(4)); let mut changed = measured; changed.sha256[31] ^= 1; assert_eq!(identify(&changed, b"apple,j514s"), Verdict::Refused); diff --git a/tools/asahi/g15-zero-words-tests.py b/tools/asahi/g15-zero-words-tests.py index 2a73390f55282..ae40a73974969 100644 --- a/tools/asahi/g15-zero-words-tests.py +++ b/tools/asahi/g15-zero-words-tests.py @@ -18,11 +18,11 @@ renumbering margins became tuning constants (the tables are unchanged). Its T6030 configuration module is independently pinned to the original bytes, -except for the J514S B0 FirmwareBuild row and the J514S cd05 FirmwareBuild row -added to its firmware table: the module is the original pinned bytes (0079ae08) -plus those two 15-line rows, and the whole hw.rs pin was refreshed with each -(with the cd05 row removed, both pins are their earlier values e9b80be9 and -cab592b5). prepare_board() is pinned too; +except for the J514S B0 FirmwareBuild row and the J514S cd05 and J516S cd05 +FirmwareBuild rows added to its firmware table: the module is the original +pinned bytes (0079ae08) plus those three rows, and the whole hw.rs pin was +refreshed with each (with the cd05 rows removed, both pins are their earlier +values e9b80be9 and cab592b5). prepare_board() is pinned too; it was refreshed for the same Board change (its T6030 arm is unchanged). """ @@ -39,11 +39,11 @@ GOLDEN_FILES = { "board/data.rs": "7c5ff1077ca3296cbfc9e7144294162b6dea78a3774c38eeed4b0f59a14d7a5c", "board/template.rs": "286872f5474a67534f214e83e659253299f85143f3dc59035fa80894022e2549", - "hw.rs": "82ee9d163da888e6dc506635e8e4a59cd3f4b4c34b3879e162702b8561093d9e", + "hw.rs": "95e745970891153307a8d6bbc04749d553de7fb490b9ef2ff0563cde7252d8bc", "power/idle.rs": "4928ecf7699b3ca85ff5143eb6e996efd40d47321e29a238a02c8873bc9f102c", } GOLDEN_FUNCTIONS = { - ("hw.rs", "pub(crate) mod t6030 {"): "d6c3020007646cba504db26bdfe5232e45185aba1d4603931da9a8d29bec40de", + ("hw.rs", "pub(crate) mod t6030 {"): "2667963ad7a0957bacf8118965a500586637b622a99e49916f111fcd02670fcd", ("initdata.rs", "fn templates("): "c3115c9926d3d7d93317cb8510e93b04f30b0c256811d7137568e822dd93b8ee", ("initdata.rs", "pub(crate) fn prepare_board("): "ebef64ab87ef7b1f994eb7fa2a2424d05bc4fc9e88cbfbf18e51570bdfc4222d", ("board.rs", "pub(crate) fn from_adt("): "cecd0b28db5bd94d3b75c1bbb5f35204e8bf0699f74e5b3d08228c59025f6ac2", From 35bf7a1895f4e05f4b58d08445b5aef460167230 Mon Sep 17 00:00:00 2001 From: Scott Jones Date: Sun, 8 Nov 2026 15:32:06 -0500 Subject: [PATCH 04/13] drm/asahi: g15: pin the 4118 firmware TEXT on the J514S and J516S Some 14-inch (J514S) and 16-inch (J516S) M3 Pro units on the 14.7 boot chain load a third B0 GPU firmware image: TEXT 0x5c000, DATA 0x114000, GKTS marker 0x58e88 and TEXT sha256 411833a7ded773feeac4a181552e3ff5582eaf4435f2dd8f620c1ed0b31df1b0. No row pins it, so probe fails with "loaded GFX TEXT identity mismatch", there is no render node and the compositor falls back to llvmpipe. Three machines have reported it in issue omacom/linux-aurora#247, all on the 14.7 stub with system firmware 26.6.2: a J514S and a J516S (both iBoot-10151.140.19.700.2, mBoot-18000.161.10), which logged the identical sizes, marker and digest, and a second 14-inch M3 Pro. With g15_accept_text_prefix=0x411833a7ded773fe all three reached firmware READY with renderD128 present. The boot chain matches the J514S cd05 reports, so the chain alone does not select the image. Add one row per board, J514S then J516S, so each pin still names the machine it was measured on; nothing changes for other machines. Extend the maintained-handoff host test: both boards pin to their own row with the override disabled, other boards are refused, and an altered digest suffix, TEXT or DATA size or marker is refused. Refresh the zero-words golden pins for hw.rs and the T6030 module; with the two rows removed both are their previous values. Link: https://github.com/omacom/linux-aurora/issues/247 Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Scott Jones --- drivers/gpu/drm/asahi/g15/hw.rs | 32 +++++++++++++++++++++ tools/asahi/g15-maintained-handoff-tests.py | 32 ++++++++++++++++++++- tools/asahi/g15-zero-words-tests.py | 15 +++++----- 3 files changed, 71 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/asahi/g15/hw.rs b/drivers/gpu/drm/asahi/g15/hw.rs index 14e4c92a60888..be319b0cd2702 100644 --- a/drivers/gpu/drm/asahi/g15/hw.rs +++ b/drivers/gpu/drm/asahi/g15/hw.rs @@ -206,6 +206,38 @@ pub(crate) mod t6030 { 0x54, 0xf9, 0xf0, 0x6e, 0x0a, 0x61, 0x36, 0x3e, ], }, + // J514S (14-inch) firmware measured on the 14.7 boot chain with + // system firmware 26.6.2; the GPU reached READY with the bring-up + // prefix override (issue #247). + FirmwareBuild { + name: "J514S 4118 firmware (14.7 boot chain)", + machine: Some(kernel::c_str!("apple,j514s")), + text_size: 0x5c000, + data_size: 0x114000, + marker: 0x58e88, + text_sha256: [ + 0x41, 0x18, 0x33, 0xa7, 0xde, 0xd7, 0x73, 0xfe, + 0xea, 0xc4, 0xa1, 0x81, 0x55, 0x2e, 0x3f, 0xf5, + 0x58, 0x2e, 0xaf, 0x44, 0x35, 0xf2, 0xdd, 0x8f, + 0x62, 0x0c, 0x1e, 0xd0, 0xb3, 0x1d, 0xf1, 0xb0, + ], + }, + // J516S (16-inch) firmware measured on the 14.7 boot chain with + // system firmware 26.6.2; the GPU reached READY with the bring-up + // prefix override (issue #247). + FirmwareBuild { + name: "J516S 4118 firmware (14.7 boot chain)", + machine: Some(kernel::c_str!("apple,j516s")), + text_size: 0x5c000, + data_size: 0x114000, + marker: 0x58e88, + text_sha256: [ + 0x41, 0x18, 0x33, 0xa7, 0xde, 0xd7, 0x73, 0xfe, + 0xea, 0xc4, 0xa1, 0x81, 0x55, 0x2e, 0x3f, 0xf5, + 0x58, 0x2e, 0xaf, 0x44, 0x35, 0xf2, 0xdd, 0x8f, + 0x62, 0x0c, 0x1e, 0xd0, 0xb3, 0x1d, 0xf1, 0xb0, + ], + }, ], machine: kernel::c_str!("apple,t6030"), platform: super::Platform::AdtWithPmp, diff --git a/tools/asahi/g15-maintained-handoff-tests.py b/tools/asahi/g15-maintained-handoff-tests.py index f2e344697dc3d..738facb331e52 100644 --- a/tools/asahi/g15-maintained-handoff-tests.py +++ b/tools/asahi/g15-maintained-handoff-tests.py @@ -137,7 +137,7 @@ def item(s, marker): OWNER_CALLS.set(0); let bytes = fixture(kind); assert!(parse(&dev, &Adt { data: &bytes }).is_err()); assert_eq!(OWNER_CALLS.get(), 0); } - assert_eq!(BUILDS.len(), 5, "maintained B0 firmware row must not require an absent profile symbol"); + assert_eq!(BUILDS.len(), 7, "maintained B0 firmware row must not require an absent profile symbol"); for (row, machine) in [(1, &b"apple,j516s"[..]), (2, &b"apple,j514s"[..])] { assert_eq!(BUILDS[row].machine.unwrap().to_bytes(), machine); assert_eq!((BUILDS[row].text_size, BUILDS[row].data_size, BUILDS[row].marker), (0x5c000, 0x114000, 0x58e88)); @@ -172,6 +172,36 @@ def item(s, marker): assert_eq!(identify(&changed, b"apple,j514s"), Verdict::Refused); changed = measured; changed.marker += 8; assert_eq!(identify(&changed, b"apple,j514s"), Verdict::Refused); + // Issue #247: the 4118 build pins on the J514S and the J516S, each to + // its own row, without the bring-up override. + let digest = [0x41,0x18,0x33,0xa7,0xde,0xd7,0x73,0xfe, + 0xea,0xc4,0xa1,0x81,0x55,0x2e,0x3f,0xf5, + 0x58,0x2e,0xaf,0x44,0x35,0xf2,0xdd,0x8f, + 0x62,0x0c,0x1e,0xd0,0xb3,0x1d,0xf1,0xb0]; + for (row, machine) in [(5, &b"apple,j514s"[..]), (6, &b"apple,j516s"[..])] { + assert_eq!(BUILDS[row].machine.unwrap().to_bytes(), machine); + assert_eq!((BUILDS[row].text_size, BUILDS[row].data_size, BUILDS[row].marker), (0x5c000, 0x114000, 0x58e88)); + assert_eq!(BUILDS[row].text_sha256, digest); + } + let measured = Measured { text_size: 0x5c000, data_size: 0x114000, marker: 0x58e88, sha256: digest }; + assert_eq!(identify(&measured, b"apple,j514s"), Verdict::Pinned(5), + "J514S 4118 firmware must pin without a prefix override"); + assert_eq!(identify(&measured, b"apple,j516s"), Verdict::Pinned(6), + "J516S 4118 firmware must pin without a prefix override"); + for other in [&b"apple,j514c"[..], b"apple,j516c", b"apple,j514m", b"apple,j516m", b"apple,t6030"] { + assert_eq!(identify(&measured, other), Verdict::Refused); + } + for machine in [&b"apple,j514s"[..], b"apple,j516s"] { + let mut changed = measured; + changed.sha256[31] ^= 1; + assert_eq!(identify(&changed, machine), Verdict::Refused); + changed = measured; changed.text_size += 0x1000; + assert_eq!(identify(&changed, machine), Verdict::Refused); + changed = measured; changed.data_size += 0x1000; + assert_eq!(identify(&changed, machine), Verdict::Refused); + changed = measured; changed.marker += 8; + assert_eq!(identify(&changed, machine), Verdict::Refused); + } for error in [0, -517, -12] { INIT_ERROR.set(error); let shared = Arc::new(Shared); let result = Rtkit::new(&dev, &shared); assert_eq!(result.is_ok(), error == 0); diff --git a/tools/asahi/g15-zero-words-tests.py b/tools/asahi/g15-zero-words-tests.py index ae40a73974969..3a31cba6958bf 100644 --- a/tools/asahi/g15-zero-words-tests.py +++ b/tools/asahi/g15-zero-words-tests.py @@ -18,11 +18,12 @@ renumbering margins became tuning constants (the tables are unchanged). Its T6030 configuration module is independently pinned to the original bytes, -except for the J514S B0 FirmwareBuild row and the J514S cd05 and J516S cd05 -FirmwareBuild rows added to its firmware table: the module is the original -pinned bytes (0079ae08) plus those three rows, and the whole hw.rs pin was -refreshed with each (with the cd05 rows removed, both pins are their earlier -values e9b80be9 and cab592b5). prepare_board() is pinned too; +except for the J514S B0 FirmwareBuild row, the J514S cd05 and J516S cd05 +FirmwareBuild rows and the J514S 4118 and J516S 4118 FirmwareBuild rows added +to its firmware table: the module is the original pinned bytes (0079ae08) plus +those five rows, and the whole hw.rs pin was refreshed with each (with the 4118 +rows removed, both pins are their earlier values fb2118b6 and 2667963a; with +the cd05 rows also removed, e9b80be9 and cab592b5). prepare_board() is pinned too; it was refreshed for the same Board change (its T6030 arm is unchanged). """ @@ -39,11 +40,11 @@ GOLDEN_FILES = { "board/data.rs": "7c5ff1077ca3296cbfc9e7144294162b6dea78a3774c38eeed4b0f59a14d7a5c", "board/template.rs": "286872f5474a67534f214e83e659253299f85143f3dc59035fa80894022e2549", - "hw.rs": "95e745970891153307a8d6bbc04749d553de7fb490b9ef2ff0563cde7252d8bc", + "hw.rs": "f45a0f11f952fea4e36809267ffd240ee1e381e8f3400de5e8527cd316b9f225", "power/idle.rs": "4928ecf7699b3ca85ff5143eb6e996efd40d47321e29a238a02c8873bc9f102c", } GOLDEN_FUNCTIONS = { - ("hw.rs", "pub(crate) mod t6030 {"): "2667963ad7a0957bacf8118965a500586637b622a99e49916f111fcd02670fcd", + ("hw.rs", "pub(crate) mod t6030 {"): "4016ec0d46831482382a92791b625e10fb2f6e4e28115a9498fdde0776f82e52", ("initdata.rs", "fn templates("): "c3115c9926d3d7d93317cb8510e93b04f30b0c256811d7137568e822dd93b8ee", ("initdata.rs", "pub(crate) fn prepare_board("): "ebef64ab87ef7b1f994eb7fa2a2424d05bc4fc9e88cbfbf18e51570bdfc4222d", ("board.rs", "pub(crate) fn from_adt("): "cecd0b28db5bd94d3b75c1bbb5f35204e8bf0699f74e5b3d08228c59025f6ac2", From 147001c39e7f4e0efce47d1e139641abfa791add Mon Sep 17 00:00:00 2001 From: Scott Jones Date: Fri, 13 Nov 2026 14:06:58 -0500 Subject: [PATCH 05/13] drm/asahi: g15: decline probes before activation with -ENODEV Before the module's final activate() step, the G15 probe returned -EPROBE_DEFER. That put the GPU on the driver core's deferred-probe list. activate() then runs the real probe through driver_attach(), but if that probe fails for good, for example because the firmware is rejected, the driver core does not take the device off the list. It stays in /sys/kernel/debug/devices_deferred until the deferred-probe work next runs, so anything that waits on that list keeps waiting. Return -ENODEV instead. activate() already reprobes every unbound device once MODULE_READY is set, and a device added later sees it set, so nothing needs the deferred list to retry. The display and PMP waits inside the real probe still return -EPROBE_DEFER. g15-probe-init-tests.py now checks that every probe before activation returns -ENODEV, and adds a mutant that defers again. Assisted-by: Claude:claude-opus-5-5 Co-Authored-By: Claude Opus 5.5 Signed-off-by: Scott Jones (cherry picked from commit 6447458068e3 on omacom/linux-aurora, omacom/linux-aurora#470) [7.3 base: the probe-init test also runs with the G16 registration here, so its pre-activation probe count follows the registration order; the new mutant is added to this base's expected-failure table.] --- drivers/gpu/drm/asahi/g15/mod.rs | 5 ++++- tools/asahi/g15-probe-init-tests.py | 25 +++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/asahi/g15/mod.rs b/drivers/gpu/drm/asahi/g15/mod.rs index 4cb221fb0a5df..9553dc46f3c55 100644 --- a/drivers/gpu/drm/asahi/g15/mod.rs +++ b/drivers/gpu/drm/asahi/g15/mod.rs @@ -202,8 +202,11 @@ impl platform::Driver for Driver<'_> { // after probe_g15 started firmware would return an unbound device. try_pin_init!(Driver { _driver: { + // Not EPROBE_DEFER: a deferred device stays listed in devices_deferred until the + // deferred-probe work runs, even after activate()'s probe fails for good. Activation + // reprobes every unbound device; a device added later sees MODULE_READY set. if !MODULE_READY.load(Ordering::Acquire) { - return Err(EPROBE_DEFER); + return Err(ENODEV); } let cfg = *info.ok_or(ENODEV)?; dev_info!(pdev.as_ref(), "G15: probing ({})\n", cfg.name); diff --git a/tools/asahi/g15-probe-init-tests.py b/tools/asahi/g15-probe-init-tests.py index a7b9b900b7af5..133df94793352 100644 --- a/tools/asahi/g15-probe-init-tests.py +++ b/tools/asahi/g15-probe-init-tests.py @@ -82,6 +82,7 @@ def item(text, marker): static EXEC_SHARE_READY: Cell = const { Cell::new(false) }; static ATTACH_ERROR: Cell = const { Cell::new(false) }; static PROBE_ERROR: Cell = const { Cell::new(0) }; + static PRE_ACTIVATION: Cell = const { Cell::new(0) }; } struct Core<'a>(PhantomData<&'a ()>); struct Device { data: Cell<*mut core::ffi::c_void> } @@ -184,7 +185,16 @@ def item(text, marker): }; // Model driver_attach and a late driver_add_groups failure. A deferred // worker can also retry G15 while the other registration is in progress. - let _ = callback::>(&PDEV, Some(&&CFG)); + let ready = MODULE_READY.load(Ordering::Acquire); + let started = PROBES.get(); + let result = callback::>(&PDEV, Some(&&CFG)); + // A probe that started firmware here is the readiness-gate failure, checked below. + if !ready && PROBES.get() == started { + // A deferral would keep the GPU in devices_deferred after a later + // terminal failure; before activation the probe must decline outright. + assert_eq!(result, Err(ENODEV), "pre-activation probe deferred instead of ENODEV"); + PRE_ACTIVATION.set(PRE_ACTIVATION.get() + 1); + } if FAIL_REGISTRATION.get() == stage { return Err(-5); } COMPLETED_REGISTRATION.set(stage); stage @@ -252,7 +262,7 @@ def item(text, marker): PDEV.base.data.set(core::ptr::null_mut()); MODULE_READY.store(false, Ordering::Release); COMPLETED_REGISTRATION.set(0); FAIL_REGISTRATION.set(failure); - ACTIVATED.set(false); ATTACH_ERROR.set(failure == 0); + ACTIVATED.set(false); ATTACH_ERROR.set(failure == 0); PRE_ACTIVATION.set(0); let init = ::init(&MODULE); assert_eq!(PROBES.get(), 0, "module initializer eagerly started firmware"); let result = KBox::pin_init(init, GFP_KERNEL); @@ -269,6 +279,12 @@ def item(text, marker): assert!(!PDEV.base.data.get().is_null()); unsafe { drop(Box::from_raw(PDEV.base.data.get().cast::>())); } } + // Every probe before activation declined: one per completed or failing registration. + // The registrations run G15 (1), the generic driver (2), then G16 (3) where it is built. + let expected = if cfg!(CONFIG_DRM_ASAHI_G16) { + match failure { 1 => 1, 2 => 2, _ => 3 } + } else if failure == 1 { 1 } else { 2 }; + assert_eq!(PRE_ACTIVATION.get(), expected, "pre-activation probes"); println!("module-registration-{failure}: PASS"); } } @@ -415,9 +431,10 @@ def main(): needle = " None\n" assert probe.count(needle) == 1 variants["retained-error-unbinds"] = (probe.replace(needle, " return Err(error);\n"), module_code) - gate = " if !MODULE_READY.load(Ordering::Acquire) {\n return Err(EPROBE_DEFER);\n }\n" + gate = " if !MODULE_READY.load(Ordering::Acquire) {\n return Err(ENODEV);\n }\n" assert probe.count(gate) == 1 variants["no-registration-readiness-gate"] = (probe.replace(gate, ""), module_code) + variants["pre-activation-defers"] = (probe.replace(gate, gate.replace("ENODEV", "EPROBE_DEFER")), module_code) late = " #[cfg(CONFIG_DRM_ASAHI_G15)]\n _g15_ready: g15::activate(),\n" assert module_code.count(late) == 1 early = module_code.replace(late, "").replace(" _driver <-", late + " _driver <-", 1) @@ -446,7 +463,7 @@ def main(): else: receipt["mutants"][label] = result if r.returncode == 0: raise SystemExit("SURVIVED: " + name) - intended = {"eager-probe-before-allocation": "allocation-before-start: firmware probe before drvdata allocation", "retained-error-unbinds": "retained-start-failure-binds: callback result", "no-registration-readiness-gate": "late registration failure started firmware", "activation-before-last-registration": "activation before all registrations completed", "activation-before-g16-registration": "activation before all registrations completed"}[name] + intended = {"pre-activation-defers": "pre-activation probe deferred instead of ENODEV", "eager-probe-before-allocation": "allocation-before-start: firmware probe before drvdata allocation", "retained-error-unbinds": "retained-start-failure-binds: callback result", "no-registration-readiness-gate": "late registration failure started firmware", "activation-before-last-registration": "activation before all registrations completed", "activation-before-g16-registration": "activation before all registrations completed"}[name] result["intended_failure"] = intended in r.stderr if not result["intended_failure"]: raise SystemExit("INVALID unrelated failure: " + name + "\n" + r.stderr) (out / "result.json").write_text(json.dumps(receipt, indent=2) + "\n") From 24e790b1255d65be1e8d655a09fc0ddeccbeec30 Mon Sep 17 00:00:00 2001 From: Scott Jones Date: Fri, 23 Oct 2026 00:24:18 -0400 Subject: [PATCH 06/13] pmdomain: apple: pmp-report: keep the T8122 14.x GPU readiness for the M3 runtime The 7.2 rebase replaced the T8122 14.x branch of apple_pmp_report_wait_supplier_ready() with a T6030-only one, so on an M3 MacBook Air every GPU power vote returns -ENODEV even with the PMP running. With the new hidden APPLE_T8122_GPU_PMP_LINK, which DRM_ASAHI_M3_T8122 selects (as DRM_ASAHI_G15 selects APPLE_T6030_GPU_PMP_LINK), wait for the unique T8122 report's display request (DISP, reg 7) to be ready and acknowledged before AGX, as on the 7.1.12 kernel the runtime was qualified with. The PMP graph and supplier host tests copy the dispatch, so they copy the T8122 wait too, built off there; their mutations still target the T6030 path. Generated-by: LLM Co-Authored-By: Claude Opus 5.5 Signed-off-by: Scott Jones --- drivers/gpu/drm/asahi/Kconfig | 1 + drivers/pmdomain/apple/pmp-report.c | 43 ++++++++++++++++++++++++- drivers/soc/apple/Kconfig | 9 ++++++ tools/asahi/t6030-pmp-graph-tests.c | 1 + tools/asahi/t6030-pmp-graph-tests.py | 12 +++++-- tools/asahi/t6030-pmp-supplier-tests.py | 12 +++++++ 6 files changed, 74 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/asahi/Kconfig b/drivers/gpu/drm/asahi/Kconfig index d383802ee8825..03939a732fc24 100644 --- a/drivers/gpu/drm/asahi/Kconfig +++ b/drivers/gpu/drm/asahi/Kconfig @@ -84,6 +84,7 @@ config DRM_ASAHI_M3_T8122 depends on DRM_ASAHI # The runtime adopts the firmware's UAT through the G15 backend's handoff helpers. depends on DRM_ASAHI_G15 + select APPLE_T8122_GPU_PMP_LINK select CRYPTO_LIB_SHA256 default n help diff --git a/drivers/pmdomain/apple/pmp-report.c b/drivers/pmdomain/apple/pmp-report.c index 42bff817bfa78..b375a83b9e0a2 100644 --- a/drivers/pmdomain/apple/pmp-report.c +++ b/drivers/pmdomain/apple/pmp-report.c @@ -687,6 +687,44 @@ static int apple_pmp_report_wait_t6030_14(struct device *supplier, unsigned int return ret; } +/* + * The T8122 (M3 MacBook Air) GPU on its 14.8.3 firmware, for the M3 runtime + * (APPLE_T8122_GPU_PMP_LINK): the unique T8122 report linked to this PMP, and + * its display request (DISP, reg 7) READY and acknowledged before AGX, as on + * the 7.1.12 kernel that runtime was qualified with. + */ +static int apple_pmp_report_wait_t8122_14(struct device *supplier, unsigned int timeout_ms) +{ + struct device_node *np, *report = NULL, *pmp, *entry; + int ret; + + if (!IS_ENABLED(CONFIG_APPLE_T8122_GPU_PMP_LINK) || + !of_machine_is_compatible("apple,t8122") || + !of_device_is_compatible(supplier->of_node, "apple,t8122-pmp-v2")) + return -ENODEV; + for_each_compatible_node(np, NULL, "apple,t8122-pmp-v2-report") { + if (report) { + of_node_put(np); + of_node_put(report); + return -ENODEV; + } + report = of_node_get(np); + } + if (!report || !of_device_is_available(report) || + of_property_count_u32_elems(report, "apple,pmp") != 1) { + of_node_put(report); + return -ENODEV; + } + pmp = of_parse_phandle(report, "apple,pmp", 0); + entry = apple_pmp_report_t6030_entry(report); + ret = pmp == supplier->of_node && entry ? + apple_pmp_report_wait_ready(entry, msecs_to_jiffies(timeout_ms)) : -ENODEV; + of_node_put(entry); + of_node_put(pmp); + of_node_put(report); + return ret; +} + /* The native 25G83 PMP starts through its supplier topology, after requests * are seeded. Its report is pinned against removal while readiness is read. */ @@ -701,8 +739,11 @@ int apple_pmp_report_wait_supplier_ready(struct device *supplier, unsigned int t int ret; /* A declared report always takes the existing native25 path below. */ - if (!np && !of_property_present(supplier->of_node, "apple,pmp-report")) + if (!np && !of_property_present(supplier->of_node, "apple,pmp-report")) { + if (of_machine_is_compatible("apple,t8122")) + return apple_pmp_report_wait_t8122_14(supplier, timeout_ms); return apple_pmp_report_wait_t6030_14(supplier, timeout_ms); + } if (!np || !of_device_is_compatible(np, t8132 ? "apple,t8132-pmp-v2-report" : "apple,j613-25g83-pmp-report")) { of_node_put(np); diff --git a/drivers/soc/apple/Kconfig b/drivers/soc/apple/Kconfig index c8b50840a7dda..3f6db5ef17ad8 100644 --- a/drivers/soc/apple/Kconfig +++ b/drivers/soc/apple/Kconfig @@ -368,6 +368,15 @@ config APPLE_DISPLAY_GATE Say 'y' if you want the native display on M3 Pro, M3 Max, M3 and M4 Pro Macs. +config APPLE_T8122_GPU_PMP_LINK + bool + depends on APPLE_PMP_REPORT + default n + help + Let T8122 (M3 MacBook Air) GPU power commands wait for the display + request the PMP report acknowledges on the 14.8.3 firmware, as the + M3 runtime of DRM_ASAHI_M3_T8122 requires. + config APPLE_T6030_GPU_PMP_LINK bool depends on APPLE_DISPLAY_GATE diff --git a/tools/asahi/t6030-pmp-graph-tests.c b/tools/asahi/t6030-pmp-graph-tests.c index e89d982d2d0a6..89a6ac0efc8e7 100644 --- a/tools/asahi/t6030-pmp-graph-tests.c +++ b/tools/asahi/t6030-pmp-graph-tests.c @@ -20,6 +20,7 @@ typedef uint8_t u8; #define BIT(n) (1U << (n)) #define IS_ENABLED(x) (x) #define CONFIG_APPLE_T6030_GPU_PMP_LINK 1 +#define CONFIG_APPLE_T8122_GPU_PMP_LINK 0 #define PMP_REPORT_READY 1 #define GFP_KERNEL 0 #define GENPD_FLAG_ACTIVE_WAKEUP 1 diff --git a/tools/asahi/t6030-pmp-graph-tests.py b/tools/asahi/t6030-pmp-graph-tests.py index 4c85001acf1a8..c8a58b302e727 100644 --- a/tools/asahi/t6030-pmp-graph-tests.py +++ b/tools/asahi/t6030-pmp-graph-tests.py @@ -60,6 +60,12 @@ def main(): 'static int apple_pmp_report_entry_resume_noirq('] offsets = re.search(r'static const struct apple_pmp_report_offsets apple_pmp_offsets_t6030 = \{.*?\n\};', source, re.S)[0] functions = '\n'.join(extract.function(source, n) for n in names) + # The T8122 14.x wait (CONFIG_APPLE_T8122_GPU_PMP_LINK=0 here) precedes the dispatch; it is + # added after the mutations are placed, so they target the T6030 path only. + t8122 = extract.function(source, 'static int apple_pmp_report_wait_t8122_14(') + '\n' + dispatch = 'int apple_pmp_report_wait_supplier_ready(' + def with_t8122(text): + return text.replace(dispatch, t8122 + dispatch, 1) validation = re.sub(r'^#include .*\n', '', (ROOT / 'drivers/pmdomain/apple/pmp-report-validation.h').read_text(), flags=re.M) dram_type = re.search(r'struct apple_pmp_dram \{.*?\n\};', (ROOT / 'drivers/pmdomain/apple/pmp-dram.h').read_text(), re.S)[0] @@ -78,7 +84,7 @@ def main(): '\n' + dram_attrs + '\n' + functions) # The actual overlay must still describe a halted supplier and disabled DMA/mailbox. assert overlay.count('status = \"disabled\";') >= 3 - (args.output / 'production.h').write_text(code) + (args.output / 'production.h').write_text(with_t8122(code)) (args.output / 'overlay.h').write_text('static const struct overlay_entry overlay_entries[] = {\n' + entry_data + '\n};\n') compiler = shlex.split(os.environ.get('CC', 'clang')) command = compiler + ['-std=gnu11', '-g', '-O1', '-Wall', '-Wextra', '-Werror', @@ -133,13 +139,13 @@ def main(): ] for name, old, new in controls: assert code.count(old) == 1, (name, code.count(old)) - (args.output / 'production.h').write_text(code.replace(old, new)) + (args.output / 'production.h').write_text(with_t8122(code.replace(old, new))) built = subprocess.run(command, capture_output=True, text=True) # A mutant must compile; compilation failure is not regression evidence. ran = subprocess.run([str(args.output / 'graph')], capture_output=True, text=True) if not built.returncode else None (args.output / (name + '.log')).write_text(built.stdout + built.stderr + (ran.stdout + ran.stderr if ran else '')) mutations.append({'name': name, 'build_rc': built.returncode, 'run_rc': ran.returncode if ran else None}) - (args.output / 'production.h').write_text(code) + (args.output / 'production.h').write_text(with_t8122(code)) assert all(m['build_rc'] == 0 and m['run_rc'] != 0 for m in mutations), mutations (args.output / 'receipt.json').write_text(json.dumps({'source_ref': args.ref, 'source_sha256': hashlib.sha256(code.encode()).hexdigest(), 'overlay_sha256': hashlib.sha256(overlay.encode()).hexdigest(), 'overlay_entries': entries, diff --git a/tools/asahi/t6030-pmp-supplier-tests.py b/tools/asahi/t6030-pmp-supplier-tests.py index 269006b36aa4f..725e37e24f6cf 100755 --- a/tools/asahi/t6030-pmp-supplier-tests.py +++ b/tools/asahi/t6030-pmp-supplier-tests.py @@ -56,6 +56,7 @@ def run(out, name, code, compiler, configs=(0, 1)): command = compiler + ["-std=gnu11", "-g", "-O1", "-Wall", "-Wextra", "-Werror", "-fsanitize=address,undefined", "-fno-omit-frame-pointer", f"-DCONFIG_APPLE_T6030_GPU_PMP_LINK={config}", + "-DCONFIG_APPLE_T8122_GPU_PMP_LINK=0", "-I", str(dest), str(ROOT / "tools/asahi/t6030-pmp-supplier-tests.c"), "-o", str(binary)] @@ -148,6 +149,17 @@ def main(): assert code.count(old) == 1, (name, code.count(old)) variants.append((name, code.replace(old, new))) variants.append(("control-after", code)) + # The T8122 14.x wait is built with CONFIG_APPLE_T8122_GPU_PMP_LINK=0 here; it is added to + # every variant after the T6030 mutations are placed, so they target the T6030 path only. + dispatch = "int apple_pmp_report_wait_supplier_ready(" + t8122 = function(report, "static int apple_pmp_report_wait_t8122_14(") + "\n" + def with_t8122(source): + if dispatch not in source: + return source + return source.replace(dispatch, t8122 + dispatch, 1) + variants = [(name, with_t8122(source)) for name, source in variants] + if baseline_code and "apple_pmp_report_wait_t8122_14(" in baseline_code: + baseline_code = with_t8122(baseline_code) results = [run(args.output, name, source, compiler) for name, source in variants] if baseline_code: results.append(run(args.output, "control-prior-config-off", baseline_code, compiler, (0,))) From 66f845e1f3cc909b9d020b9853858492c2f7dd41 Mon Sep 17 00:00:00 2001 From: Scott Jones Date: Fri, 23 Oct 2026 11:00:54 -0400 Subject: [PATCH 07/13] tools/asahi: test the T8122 14.x PMP wait in the supplier suite The supplier suite built apple_pmp_report_wait_t8122_14() only with APPLE_T8122_GPU_PMP_LINK off, so every case returned at its first check. Build it also as the M3 runtime does (T6030 and T8122 links on) and run the T8122 graph: the unique, available report linked to this PMP, with DISP (reg 7) acked, and its failures (machine, supplier and report compatibles, a duplicate or disabled report, the apple,pmp shape and identity, a missing, duplicate, disabled, incompatible or no-ack DISP entry, the managed start and its readiness). With the link off, a well-formed T8122 graph is refused. Mutants cover the wait's config scope, compatibles, report checks, readiness result and entry reference, and the dispatch's machine scope in both directions. Reported-by: Marcelo Alcantara Generated-by: LLM Co-Authored-By: Claude Opus 5.5 (1M context) Signed-off-by: Scott Jones --- tools/asahi/t6030-pmp-supplier-tests.c | 60 +++++++++++++++++++++++-- tools/asahi/t6030-pmp-supplier-tests.py | 47 +++++++++++++++---- 2 files changed, 95 insertions(+), 12 deletions(-) diff --git a/tools/asahi/t6030-pmp-supplier-tests.c b/tools/asahi/t6030-pmp-supplier-tests.c index 59c2c0d3cd430..f9ad353872de1 100644 --- a/tools/asahi/t6030-pmp-supplier-tests.c +++ b/tools/asahi/t6030-pmp-supplier-tests.c @@ -489,6 +489,17 @@ static void reset(void) lockable = present_device = link_ok = 1; status_word = PMP_REPORT_READY; } +/* The T8122 (M3 Air) 14.x graph: the same report shape, with T8122 compatibles. */ +static void t8122(void) +{ + machine = "apple,t8122"; + gate_soc = &gate_t8122; + supplier_node.compatible = "apple,t8122-pmp-v2"; + other_node.compatible = "apple,t8122-pmp-v2"; + gpu.compatible = "apple,agx-t8122"; + report14.compatible = "apple,t8122-pmp-v2-report"; + apple_pmp_starts.first = &managed_start; +} static int power(void) { return apple_pmp_set_device_power(0x0f, 5, 1); @@ -518,6 +529,7 @@ int main(void) (void)gate_find_one; (void)apple_pmp_report_t6030_entry; (void)apple_pmp_report_wait_t6030_14; + (void)apple_pmp_report_wait_t8122_14; reset(); assert(apple_pmp_offsets_t6030.starts_pmp == !!CONFIG_APPLE_T6030_GPU_PMP_LINK); @@ -574,9 +586,50 @@ int main(void) RUN((void)0, -ENODEV, 0, 0); assert(!find_calls); #endif - /* T8122 current14 remains unsupported by this supplier API. */ + /* A T8122 supplier never takes the T6030 report. */ RUN(machine = "apple,t8122"; supplier_node.compatible = "apple,t8122-pmp-v2", -ENODEV, 0, 0); +#if CONFIG_APPLE_T8122_GPU_PMP_LINK + /* The T8122 14.x wait: one available report linked to this PMP, DISP (reg 7) acked. */ + RUN(t8122(), 0, 0, 1); + RUN(t8122(); report14.child = &entry7; entry7.sibling = &entry17; + entry17.sibling = NULL, 0, 0, 1); + RUN(t8122(); apple_pmp_starts.first = NULL, -ENODEV, 0, 0); + RUN(t8122(); apple_pmp_starts.first = NULL; + apple_pmp_reports.first = NULL, -EPROBE_DEFER, 0, 0); + RUN(t8122(); managed_start.stopping = true, -ENODEV, 0, 0); + RUN(t8122(); ready_result = -ETIMEDOUT, -ETIMEDOUT, 0, 0); + RUN(t8122(); passive_words[apple_pmp_offsets_t6030.status / 8] = 0, -EIO, + 0, 0); + RUN(t8122(); passive_words[apple_pmp_offsets_t6030.actual / 8] = 0, -EIO, + 0, 0); + RUN(t8122(); power_result = -EIO, -EIO, 0, 1); + RUN(t8122(); machine = "apple,t6030", -ENODEV, 0, 0); + RUN(t8122(); machine = "apple,t8112", -ENODEV, 0, 0); + RUN(t8122(); supplier_node.compatible = "apple,t6030-pmp-v2", -ENODEV, 0, + 0); + RUN(t8122(); report14.compatible = NULL, -ENODEV, 0, 0); + RUN(t8122(); report14.compatible = "apple,t6030-pmp-v2-report", -ENODEV, + 0, 0); + RUN(t8122(); extra_report = report14, -ENODEV, 0, 0); + RUN(t8122(); extra_report = report14; extra_report.available = false, + -ENODEV, 0, 0); + RUN(t8122(); report14.available = false, -ENODEV, 0, 0); + RUN(t8122(); report14.has_pmp = false, -ENODEV, 0, 0); + RUN(t8122(); report14.pmp_cells = 0, -ENODEV, 0, 0); + RUN(t8122(); report14.pmp_cells = 2, -ENODEV, 0, 0); + RUN(t8122(); report14.pmp = NULL, -ENODEV, 0, 0); + RUN(t8122(); report14.pmp = &other_node, -ENODEV, 0, 0); + RUN(t8122(); entry17.sibling = NULL, -ENODEV, 0, 0); + RUN(t8122(); entry7.reg = 8, -ENODEV, 0, 0); + RUN(t8122(); entry7.available = false, -ENODEV, 0, 0); + RUN(t8122(); entry7.compatible = "apple,other", -ENODEV, 0, 0); + RUN(t8122(); entry7.no_ack = true, -ENODEV, 0, 0); + RUN(t8122(); entry17.reg = 7, -ENODEV, 0, 0); +#else + /* Without APPLE_T8122_GPU_PMP_LINK, even a well-formed T8122 graph is refused. */ + RUN(t8122(), -ENODEV, 0, 0); +#endif /* A declared report, including malformed/unresolved data, never falls back. */ RUN(supplier_node.has_report = true; supplier_node.report_cells = 0, -ENODEV, 0, 0); @@ -716,7 +769,8 @@ int main(void) assert(apple_pmp_link_device(&consumer) == -EINVAL); balanced(); case_count++; - printf("PASS: %d T6030 PMP cases, config=%d; reference, lock and command boundaries checked\n", - case_count, CONFIG_APPLE_T6030_GPU_PMP_LINK); + printf("PASS: %d T6030/T8122 PMP cases, config=%d/%d; reference, lock and command boundaries checked\n", + case_count, CONFIG_APPLE_T6030_GPU_PMP_LINK, + CONFIG_APPLE_T8122_GPU_PMP_LINK); return 0; } diff --git a/tools/asahi/t6030-pmp-supplier-tests.py b/tools/asahi/t6030-pmp-supplier-tests.py index 725e37e24f6cf..aee98f9c59953 100755 --- a/tools/asahi/t6030-pmp-supplier-tests.py +++ b/tools/asahi/t6030-pmp-supplier-tests.py @@ -46,17 +46,23 @@ def no_core(): resource.setrlimit(resource.RLIMIT_CORE, (0, 0)) -def run(out, name, code, compiler, configs=(0, 1)): +# (CONFIG_APPLE_T6030_GPU_PMP_LINK, CONFIG_APPLE_T8122_GPU_PMP_LINK): off, G15 only, and G15 +# with the M3 runtime (DRM_ASAHI_M3_T8122 depends on DRM_ASAHI_G15). +CONFIGS = ((0, 0), (1, 0), (1, 1)) + + +def run(out, name, code, compiler, configs=CONFIGS): dest = out / name dest.mkdir() (dest / "t6030-pmp-production.h").write_text(code) results = [] - for config in configs: + for t6030, t8122 in configs: + config = f"{t6030}{t8122}" binary = dest / f"config-{config}" command = compiler + ["-std=gnu11", "-g", "-O1", "-Wall", "-Wextra", "-Werror", "-fsanitize=address,undefined", "-fno-omit-frame-pointer", - f"-DCONFIG_APPLE_T6030_GPU_PMP_LINK={config}", - "-DCONFIG_APPLE_T8122_GPU_PMP_LINK=0", + f"-DCONFIG_APPLE_T6030_GPU_PMP_LINK={t6030}", + f"-DCONFIG_APPLE_T8122_GPU_PMP_LINK={t8122}", "-I", str(dest), str(ROOT / "tools/asahi/t6030-pmp-supplier-tests.c"), "-o", str(binary)] @@ -149,20 +155,43 @@ def main(): assert code.count(old) == 1, (name, code.count(old)) variants.append((name, code.replace(old, new))) variants.append(("control-after", code)) - # The T8122 14.x wait is built with CONFIG_APPLE_T8122_GPU_PMP_LINK=0 here; it is added to - # every variant after the T6030 mutations are placed, so they target the T6030 path only. + # The T8122 14.x wait mirrors the T6030 one, so it is added to every variant after the + # T6030 mutations are placed; its own mutants change only its text. dispatch = "int apple_pmp_report_wait_supplier_ready(" t8122 = function(report, "static int apple_pmp_report_wait_t8122_14(") + "\n" - def with_t8122(source): + def with_t8122(source, text=t8122): if dispatch not in source: return source - return source.replace(dispatch, t8122 + dispatch, 1) + return source.replace(dispatch, text + dispatch, 1) variants = [(name, with_t8122(source)) for name, source in variants] + if args.mutations: + t8122_mutations = [ + ("t8122-config-scope", "if (!IS_ENABLED(CONFIG_APPLE_T8122_GPU_PMP_LINK) ||", "if (false ||"), + ("t8122-supplier-compat", '!of_device_is_compatible(supplier->of_node, "apple,t8122-pmp-v2"))', "false)"), + ("t8122-report-compat", 'for_each_compatible_node(np, NULL, "apple,t8122-pmp-v2-report")', + 'for_each_compatible_node(np, NULL, "apple,t6030-pmp-v2-report")'), + ("t8122-duplicate-report", "\t\tif (report) {", "\t\tif (false) {"), + ("t8122-disabled-report", "!of_device_is_available(report) ||", "false ||"), + ("t8122-report-phandle-shape", 'of_property_count_u32_elems(report, "apple,pmp") != 1', "false"), + ("t8122-supplier-identity", "pmp == supplier->of_node && entry ?", "entry ?"), + ("t8122-readiness-error", "apple_pmp_report_wait_ready(entry, msecs_to_jiffies(timeout_ms)) : -ENODEV;", + "(apple_pmp_report_wait_ready(entry, msecs_to_jiffies(timeout_ms)), 0) : -ENODEV;"), + ("t8122-entry-reference", "\tof_node_put(entry);\n\tof_node_put(pmp);", "\tof_node_put(pmp);"), + ] + for name, old, new in t8122_mutations: + assert t8122.count(old) == 1, (name, t8122.count(old)) + variants.insert(-1, (name, with_t8122(code, t8122.replace(old, new)))) + # The dispatch owns the machine scope: T8122 takes the T8122 wait, every other SoC the + # T6030 one. (The wait's own machine check repeats it and cannot be reached otherwise.) + machine = 'if (of_machine_is_compatible("apple,t8122"))' + assert code.count(machine) == 1 + for name, new in (("t8122-dispatch-never", "if (false)"), ("t8122-dispatch-always", "if (true)")): + variants.insert(-1, (name, with_t8122(code.replace(machine, new)))) if baseline_code and "apple_pmp_report_wait_t8122_14(" in baseline_code: baseline_code = with_t8122(baseline_code) results = [run(args.output, name, source, compiler) for name, source in variants] if baseline_code: - results.append(run(args.output, "control-prior-config-off", baseline_code, compiler, (0,))) + results.append(run(args.output, "control-prior-config-off", baseline_code, compiler, ((0, 0),))) valid = True for item in results: control = item["name"].startswith("control-") From 3749fdbec0b572f4cc9241a8953a48c3de5e9b6d Mon Sep 17 00:00:00 2001 From: Scott Jones Date: Thu, 5 Nov 2026 13:07:46 -0500 Subject: [PATCH 08/13] drm/apple: add the J504 internal panel record The 14" M3 MacBook Pro (J504) runs the same T8122 DCP image as the M3 MacBook Airs (90F849E1-..., named by the J504 ADT), so the 14.x IOMFB path can drive its panel once the boot loader hands the display over. Its panel is the J514S mini-LED panel: 3024x1964 with 74 notch rows, at 60 or 120 Hz. Add a J504 record with that geometry, ProMotion allowed, bring-up logging on, and this image's colour matrix methods. The panel level block is not qualified on this board, so brightness stays closed, and its swaps keep zero timestamps as on the Airs. Other T8122 Macs (the J433 and J434 iMacs) still have no record. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Scott Jones --- drivers/gpu/drm/apple/iomfb_v14_7.c | 25 ++++++++++++++++ drivers/gpu/drm/apple/v14-board-test.c | 41 ++++++++++++++++++++++++++ tools/asahi/dcp14-panel-tests.py | 22 ++++++++++++-- 3 files changed, 86 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/apple/iomfb_v14_7.c b/drivers/gpu/drm/apple/iomfb_v14_7.c index a99bfed67183f..b7de4b21e60a5 100644 --- a/drivers/gpu/drm/apple/iomfb_v14_7.c +++ b/drivers/gpu/drm/apple/iomfb_v14_7.c @@ -140,6 +140,30 @@ static const struct dcp_v14_board dcp_v14_board_j615 = { .ctm_get = A(420), }; +/* + * J504 (MacBook Pro 14", M3): the J613 DCP image on the same T8122 DCP (the + * J504 ADT names it), driving the 14" mini-LED panel of the J514S: 3024x1964 + * with 74 notch rows above the 3024x1890 boot framebuffer, at 60 or 120 Hz. + * The colour matrix methods are this image's. The panel level block is not + * qualified on this board, so brightness stays closed (no panel_nits), and + * its swaps keep zero timestamps as on the Airs. Every panel timing and the + * display clock are logged for the first boots. + */ +static const struct dcp_v14_board dcp_v14_board_j504 = { + .name = "J504", + .debugfs = "dcp-j504", + .dcp_compatible = "apple,t8122-dcp", + .machine = "apple,j504", + .firmware_uuid = DCP_V14_J613_FIRMWARE_UUID, + .handoff = "apple,t8122-handoff", + .panel_width = 3024, + .panel_height = 1964, + .promotion = true, + .log_bringup = true, + .ctm_set = A(421), + .ctm_get = A(420), +}; + /* * J516C (MacBook Pro 16", M3 Max): the J516S panel, 3456x2234 with 74 notch * rows above the 3456x2160 boot framebuffer, at 60 or 120 Hz, on the T6031 @@ -193,6 +217,7 @@ static const struct dcp_v14_board *const dcp_v14_boards[] = { &dcp_v14_board_t6030, &dcp_v14_board_j613, &dcp_v14_board_j615, + &dcp_v14_board_j504, &dcp_v14_board_j516c, &dcp_v14_board_j514c, }; diff --git a/drivers/gpu/drm/apple/v14-board-test.c b/drivers/gpu/drm/apple/v14-board-test.c index f9b84ab36a7cc..2a41853d76dd2 100644 --- a/drivers/gpu/drm/apple/v14-board-test.c +++ b/drivers/gpu/drm/apple/v14-board-test.c @@ -54,6 +54,8 @@ static const char *const j514c[] = { "apple,j514c", "apple,t6031", "apple,arm-pl static const char *const j516m[] = { "apple,j516m", "apple,t6034", "apple,arm-platform", NULL }; static const char *const j516s[] = { "apple,j516s", "apple,t6030", "apple,arm-platform", NULL }; static const char *const j613[] = { "apple,j613", "apple,t8122", "apple,arm-platform", NULL }; +static const char *const j504[] = { "apple,j504", "apple,t8122", "apple,arm-platform", NULL }; +static const char *const j433[] = { "apple,j433", "apple,t8122", "apple,arm-platform", NULL }; static void v14_board_j516c(struct kunit *test) { @@ -247,7 +249,46 @@ static void v14_swap_timestamps_encoding(struct kunit *test) } } +/* + * J504 (14" M3 MacBook Pro): the J613 image on the T8122 DCP, its own 3024x1964 + * ProMotion panel, brightness closed and unstamped swaps. The other T8122 + * Macs (J433, J434) have no record. + */ +static void v14_board_j504(struct kunit *test) +{ + const struct dcp_v14_board *b, *air; + bool known; + + b = board_for("apple,t8122-dcp", j504, &known); + KUNIT_ASSERT_NOT_NULL(test, b); + air = board_for("apple,t8122-dcp", j613, &known); + KUNIT_ASSERT_NOT_NULL(test, air); + KUNIT_EXPECT_PTR_NE(test, b, air); + KUNIT_EXPECT_STREQ(test, b->name, "J504"); + KUNIT_EXPECT_STREQ(test, b->machine, "apple,j504"); + KUNIT_EXPECT_STREQ(test, b->handoff, "apple,t8122-handoff"); + KUNIT_EXPECT_STREQ(test, b->firmware_uuid, J613_DCP_IMAGE); + KUNIT_EXPECT_EQ(test, b->panel_width, 3024); + KUNIT_EXPECT_EQ(test, b->panel_height, 1964); + KUNIT_EXPECT_TRUE(test, b->promotion); + KUNIT_EXPECT_TRUE(test, b->log_bringup); + KUNIT_EXPECT_FALSE(test, b->panel_nits); + KUNIT_EXPECT_FALSE(test, b->base_edid); + KUNIT_EXPECT_EQ(test, b->ctm_set, air->ctm_set); + KUNIT_EXPECT_EQ(test, b->ctm_get, air->ctm_get); + KUNIT_EXPECT_TRUE(test, dcp_v14_board_admits(b, J613_DCP_IMAGE)); + KUNIT_EXPECT_FALSE(test, dcp_v14_board_admits(b, T6030_DCP_IMAGE)); + KUNIT_EXPECT_FALSE(test, dcp_v14_board_admits(b, J516C_DCP_IMAGE)); + KUNIT_EXPECT_FALSE(test, dcp_v14_board_stamps_swaps(b, false)); + + KUNIT_EXPECT_NULL(test, board_for("apple,t8122-dcp", j433, &known)); + KUNIT_EXPECT_TRUE(test, known); + /* A J504 root with another SoC's DCP gets no J504 record. */ + KUNIT_EXPECT_NULL(test, board_for("apple,t6031-dcp", j504, &known)); +} + static struct kunit_case v14_board_cases[] = { + KUNIT_CASE(v14_board_j504), KUNIT_CASE(v14_board_j516c), KUNIT_CASE(v14_board_j514c), KUNIT_CASE(v14_board_t6031_other_boards), diff --git a/tools/asahi/dcp14-panel-tests.py b/tools/asahi/dcp14-panel-tests.py index 0abcd1e89d3f9..b6c5979b11714 100755 --- a/tools/asahi/dcp14-panel-tests.py +++ b/tools/asahi/dcp14-panel-tests.py @@ -87,7 +87,25 @@ machine="apple,j613";const struct dcp_v14_board*j=iomfb_v14_7_board(&dev); assert(!IS_ERR(j)&&j->panel_width==2560 && j->panel_height==1664); machine="apple,j700";assert(IS_ERR(iomfb_v14_7_board(&dev))); - machine="apple,j504";assert(IS_ERR(iomfb_v14_7_board(&dev))); + /* J504 (14" M3 MacBook Pro): the J613 image, the J514 panel, 60 or 120 Hz. */ + machine="apple,j504";const struct dcp_v14_board*p14=iomfb_v14_7_board(&dev); + assert(!IS_ERR(p14)&&p14&&!strcmp(p14->name,"J504")&&!strcmp(p14->debugfs,"dcp-j504")); + assert(p14->panel_width==3024&&p14->panel_height==1964&&p14->promotion&&p14->log_bringup); + assert(!strcmp(p14->firmware_uuid,"90F849E1-B422-367E-B389-50246F8DEC47")); + assert(!strcmp(p14->handoff,"apple,t8122-handoff")&&!p14->panel_nits&&!p14->swap_timestamps); + assert(p14->ctm_set==A(421)&&p14->ctm_get==A(420)); + image_uuid=p14->firmware_uuid;assert(probe_gate(&dev,p14)==0); + image_uuid="C042E95C-B9D8-3F0E-94B3-582A08AA6FDD";assert(probe_gate(&dev,p14)==-ENODEV); + image_uuid="F493F03E-CC40-3D89-9A08-5F259BA2B246";assert(probe_gate(&dev,p14)==-ENODEV); + image_uuid=NULL;assert(probe_gate(&dev,p14)==-ENODEV); + image_uuid=p14->firmware_uuid;marker_value=0;assert(probe_gate(&dev,p14)==-ENODEV);marker_value=1; + {struct apple_dcp_v14 q={.dev=&dev,.board=p14};width=3024;height=1890;stride=width*4;notch=74; + assert(dcp_v14_geometry(&q)==0&&q.panel_height==1964&&q.notch_rows==74); + height=1964;notch=0;assert(dcp_v14_geometry(&q)==0&&q.panel_height==1964); + width=2560;height=1600;stride=width*4;notch=64;assert(dcp_v14_geometry(&q)==-EINVAL);} + /* Other T8122 Macs (J433/J434 iMacs) have no record. */ + machine="apple,j433";assert(IS_ERR(iomfb_v14_7_board(&dev))); + machine="apple,j434";assert(IS_ERR(iomfb_v14_7_board(&dev))); dcp.compatible="apple,t6030-dcp";machine="apple,j516s";assert(iomfb_v14_7_board(&dev)==&dcp_v14_board_t6030); dcp.compatible="apple,t8122-dcp"; struct apple_dcp_v14 v={.dev=&dev,.board=b};width=2880;height=1800;stride=width*4;notch=64; @@ -139,7 +157,7 @@ machine="apple,j613";assert(IS_ERR(iomfb_v14_7_board(&dev))); machine="apple,j516m";assert(IS_ERR(iomfb_v14_7_board(&dev))); dcp.compatible="apple,t6030-dcp";machine="apple,j516s";assert(iomfb_v14_7_board(&dev)==&dcp_v14_board_t6030); - puts("current J615/J613/T6030/J516C/J514C admission + hidden/full notch, wrong geometry controls: PASS"); + puts("current J615/J613/J504/T6030/J516C/J514C admission + hidden/full notch, wrong geometry controls: PASS"); #endif } ''' From 1cb77d66548521361a7658a646f106b0e8a7b761 Mon Sep 17 00:00:00 2001 From: Scott Jones Date: Thu, 5 Nov 2026 13:07:46 -0500 Subject: [PATCH 09/13] drm/asahi: start the T8122 GPU runtime on the J504 The J504 (14" M3 MacBook Pro) loads the same 14.8.3 G15G firmware image as the M3 MacBook Airs (UUID DF697F05-..., TEXT 0x64000, from its ADT). Move the T8122 board list into t8122_admission as T8122_BOARDS, add the J504, and test the exact list on the host. Firmware identity, resource admission, the performance-state cap and the thermal limit are unchanged; the J504 starts at the same conservative cap (state 2) as the Airs. The J433 and J434 iMacs stay unlisted. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Scott Jones --- drivers/gpu/drm/asahi/m3/m3_params.rs | 8 ++++---- drivers/gpu/drm/asahi/m3/m3_soc.rs | 7 ++++--- drivers/gpu/drm/asahi/m3/m3_thermal_policy.rs | 1 + drivers/gpu/drm/asahi/m3/t8122_admission.rs | 17 +++++++++++++++++ drivers/gpu/drm/asahi/m3/t8122_start.rs | 4 ++-- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/asahi/m3/m3_params.rs b/drivers/gpu/drm/asahi/m3/m3_params.rs index 85033c88e4192..be675d60a730c 100644 --- a/drivers/gpu/drm/asahi/m3/m3_params.rs +++ b/drivers/gpu/drm/asahi/m3/m3_params.rs @@ -589,9 +589,9 @@ pub(crate) fn thermal_hot_param() -> (u64, bool) { /// Whether to start the runtime backend on a T8122 (`asahi.m3_backend`), and say why not. /// -/// The runtime starts only on the boards the T8122 table allows (the M3 MacBook Airs), with -/// `auto` and `runtime` alike: it has not run on any T8122, so nothing forces it onto another -/// board. The G15 manager backend is T6030-only. +/// The runtime starts only on the boards the T8122 table allows (the M3 MacBook Airs and the +/// 14" M3 MacBook Pro, `t8122_admission::T8122_BOARDS`), with `auto` and `runtime` alike: +/// nothing forces it onto another board. The G15 manager backend is T6030-only. pub(crate) fn t8122_backend(pdev: &platform::Device>) -> bool { let dev = pdev.as_ref(); match M3_BACKEND.load(Ordering::Relaxed) { @@ -610,7 +610,7 @@ pub(crate) fn t8122_backend(pdev: &platform::Device>) -> bool { _ => { dev_info!( dev, - "M3: no GPU backend on this T8122 board: the runtime backend may start only on the M3 MacBook Airs (J613, J615)\n" + "M3: no GPU backend on this T8122 board: the runtime backend may start only on the M3 MacBook Airs (J613, J615) and the 14\" M3 MacBook Pro (J504)\n" ); false } diff --git a/drivers/gpu/drm/asahi/m3/m3_soc.rs b/drivers/gpu/drm/asahi/m3/m3_soc.rs index 7500822c4124c..3dcd15c896a48 100644 --- a/drivers/gpu/drm/asahi/m3/m3_soc.rs +++ b/drivers/gpu/drm/asahi/m3/m3_soc.rs @@ -284,9 +284,10 @@ pub(crate) static T8122: Soc = Soc { gpu_revision_id: hw::GpuRevisionID::C0, board: "apple,t8122", gpu: "apple,agx-t8122", - // The M3 MacBook Airs (13" J613, 15" J615). Allowed, not validated: the runtime has not run - // on either, and starts only behind a boot loader that hands the GPU over. - validated_boards: &[b"apple,j613", b"apple,j615"], + // The M3 MacBook Airs (13" J613, 15" J615) and the 14" M3 MacBook Pro (J504), which loads + // the same G15G image (`t8122_admission::T8122_BOARDS`). The runtime starts only behind a + // boot loader that hands the GPU over. + validated_boards: &crate::m3::t8122_admission::T8122_BOARDS, clusters: 1, cores_per_cluster: 10, mailbox_compatibles: &[ diff --git a/drivers/gpu/drm/asahi/m3/m3_thermal_policy.rs b/drivers/gpu/drm/asahi/m3/m3_thermal_policy.rs index 2ae70634ff556..1b2412b7f7809 100644 --- a/drivers/gpu/drm/asahi/m3/m3_thermal_policy.rs +++ b/drivers/gpu/drm/asahi/m3/m3_thermal_policy.rs @@ -271,6 +271,7 @@ mod zone_tests { } assert_eq!(required_zones(b"apple,j613\0"), 1); assert_eq!(required_zones(b"apple,j615\0"), 1); + assert_eq!(required_zones(b"apple,j504\0apple,t8122\0"), 1); } #[test] diff --git a/drivers/gpu/drm/asahi/m3/t8122_admission.rs b/drivers/gpu/drm/asahi/m3/t8122_admission.rs index fb280ebcde520..ff6d098f50a3c 100644 --- a/drivers/gpu/drm/asahi/m3/t8122_admission.rs +++ b/drivers/gpu/drm/asahi/m3/t8122_admission.rs @@ -4,6 +4,12 @@ use super::m3_profile::Profile; +/// The T8122 boards the M3 runtime starts on by default: the M3 MacBook Airs (13" J613, 15" J615) +/// and the 14" M3 MacBook Pro (J504). All three load the same 14.8.3 G15G image (UUID +/// `DF697F05-…`, checked separately by firmware admission). The other T8122 Macs (the J433 and +/// J434 iMacs) are not listed. +pub(crate) const T8122_BOARDS: [&[u8]; 3] = [b"apple,j613", b"apple,j615", b"apple,j504"]; + #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub(crate) struct Identity { pub(crate) active_cores: u32, @@ -195,6 +201,17 @@ pub(crate) fn read_identity_for( #[cfg(test)] mod tests { + use super::T8122_BOARDS; + + #[test] + fn the_t8122_runtime_boards_are_exactly_the_airs_and_the_14_inch_pro() { + // Exact: dropping the J504 or adding another T8122 Mac (J433, J434) must fail here. + assert_eq!(T8122_BOARDS, [&b"apple,j613"[..], b"apple,j615", b"apple,j504"]); + for other in [&b"apple,j433"[..], b"apple,j434", b"apple,t8122"] { + assert!(!T8122_BOARDS.contains(&other)); + } + } + use super::*; const G15G_C0: u32 = 0x0702_2000; diff --git a/drivers/gpu/drm/asahi/m3/t8122_start.rs b/drivers/gpu/drm/asahi/m3/t8122_start.rs index 737034dd6f8c1..f4fe2bae341aa 100644 --- a/drivers/gpu/drm/asahi/m3/t8122_start.rs +++ b/drivers/gpu/drm/asahi/m3/t8122_start.rs @@ -301,8 +301,8 @@ pub(crate) fn arm(dev: &device::Device, soc: &Soc) -> Result> e.mapping_count(), storage::IOMAP_BASE ); - // J613/J615 have no SoC die temperature zone yet, so a cap above the no-feedback limit runs - // the fanless GPU without any temperature feedback (`m3_thermal` holds the cap but gets no + // J615 and J504 have no SoC die temperature zone yet, so a cap above the no-feedback limit + // runs the GPU without any temperature feedback (`m3_thermal` holds the cap but gets no // reading). The runtime cap and the firmware ceiling stay equal, because the cap is at most // the no-feedback limit. if v.pstate_cap > knobs::PSTATE_CAP { From 4e742a9f181c3dcd61b2668843694c54cd599e4c Mon Sep 17 00:00:00 2001 From: Scott Jones Date: Thu, 5 Nov 2026 13:07:47 -0500 Subject: [PATCH 10/13] arm64: dts: apple: t8122-j504: describe the internal panel Give the J504 DCP its panel node (the J514S 14" mini-LED panel: 302 x 196 mm, 189 mm below the notch, 500 nits) and point the boot framebuffer at it, as on the J613, so simpledrm and the DCP driver use the same physical size. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Scott Jones --- arch/arm64/boot/dts/apple/t8122-j504.dts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/apple/t8122-j504.dts b/arch/arm64/boot/dts/apple/t8122-j504.dts index f8258ba3a2f54..f290f01120677 100644 --- a/arch/arm64/boot/dts/apple/t8122-j504.dts +++ b/arch/arm64/boot/dts/apple/t8122-j504.dts @@ -39,13 +39,23 @@ &dcp { panel: panel { compatible = "apple,panel-j504", "apple,panel-mini-led", "apple,panel"; + /* + * The J514S panel: 3024x1964 at 254 ppi; 189 mm high without the + * 74 notch rows. The J504 boot framebuffer is 3024x1890 below them. + */ width-mm = <302>; height-mm = <196>; adj-height-mm = <189>; - apple,max-brightness = <600>; + apple,max-brightness = <500>; }; }; +/* The boot framebuffer is the same panel, as on the J613 (HiDPI scale for simpledrm). */ +&framebuffer0 { + panel = <&panel>; + post-init-providers = <&panel>; +}; + &wifi0 { brcm,board-type = "apple,tresco"; }; From de895c58e11b060117403fd33c12d044315e8628 Mon Sep 17 00:00:00 2001 From: Scott Jones Date: Thu, 5 Nov 2026 14:05:23 -0500 Subject: [PATCH 11/13] drm/apple: open the J504 panel brightness path The J504 runs the J613's DCP image, whose panel level block (brightness in nits) is qualified on the J613. Mark the J504 record panel_nits and admit the J504 machine for it, with the KUnit and host tests. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Scott Jones --- drivers/gpu/drm/apple/iomfb_v14_7.c | 10 ++++++---- drivers/gpu/drm/apple/iomfb_v14_7_backlight_test.c | 8 +++++++- drivers/gpu/drm/apple/v14-board-test.c | 4 ++-- tools/asahi/dcp14-panel-tests.py | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/apple/iomfb_v14_7.c b/drivers/gpu/drm/apple/iomfb_v14_7.c index b7de4b21e60a5..b520b0a2c3afa 100644 --- a/drivers/gpu/drm/apple/iomfb_v14_7.c +++ b/drivers/gpu/drm/apple/iomfb_v14_7.c @@ -144,9 +144,9 @@ static const struct dcp_v14_board dcp_v14_board_j615 = { * J504 (MacBook Pro 14", M3): the J613 DCP image on the same T8122 DCP (the * J504 ADT names it), driving the 14" mini-LED panel of the J514S: 3024x1964 * with 74 notch rows above the 3024x1890 boot framebuffer, at 60 or 120 Hz. - * The colour matrix methods are this image's. The panel level block is not - * qualified on this board, so brightness stays closed (no panel_nits), and - * its swaps keep zero timestamps as on the Airs. Every panel timing and the + * The colour matrix methods are this image's, and so is the panel level + * block the J613 qualified (brightness in nits, 500 at most here). Its swaps + * keep zero timestamps as on the Airs. Every panel timing and the * display clock are logged for the first boots. */ static const struct dcp_v14_board dcp_v14_board_j504 = { @@ -160,6 +160,7 @@ static const struct dcp_v14_board dcp_v14_board_j504 = { .panel_height = 1964, .promotion = true, .log_bringup = true, + .panel_nits = true, .ctm_set = A(421), .ctm_get = A(420), }; @@ -1719,7 +1720,8 @@ static bool dcp_v14_panel_nits_admit(const struct dcp_v14_board *board, { return board && board->panel_nits && (machine_is(ctx, "apple,j514s") || machine_is(ctx, "apple,j516s") || - machine_is(ctx, "apple,j516c") || machine_is(ctx, "apple,j613")); + machine_is(ctx, "apple,j516c") || machine_is(ctx, "apple,j613") || + machine_is(ctx, "apple,j504")); } const char *iomfb_v14_7_board_name(const struct dcp_v14_board *board) diff --git a/drivers/gpu/drm/apple/iomfb_v14_7_backlight_test.c b/drivers/gpu/drm/apple/iomfb_v14_7_backlight_test.c index 3c1fc2f45d534..6f1b6ad2bfe96 100644 --- a/drivers/gpu/drm/apple/iomfb_v14_7_backlight_test.c +++ b/drivers/gpu/drm/apple/iomfb_v14_7_backlight_test.c @@ -122,13 +122,14 @@ static bool v14_bl_ctx_machine_is(const void *ctx, const char *compat) return !strcmp(((const char *const *)ctx)[1], compat); } -/* Only admitted T6030, J516C and J613 internal panels carry levels. */ +/* Only admitted T6030, J516C, J613 and J504 internal panels carry levels. */ static void v14_bl_boards(struct kunit *test) { static const char *const t6030_j516s[] = { "apple,t6030-dcp", "apple,j516s" }; static const char *const t6030_j514s[] = { "apple,t6030-dcp", "apple,j514s" }; static const char *const j613[] = { "apple,t8122-dcp", "apple,j613" }; static const char *const j615[] = { "apple,t8122-dcp", "apple,j615" }; + static const char *const j504[] = { "apple,t8122-dcp", "apple,j504" }; static const char *const j516c[] = { "apple,t6031-dcp", "apple,j516c" }; static const char *const other_t6030[] = { "apple,t6030-dcp", "apple,other" }; const struct dcp_v14_board *board; @@ -156,6 +157,11 @@ static void v14_bl_boards(struct kunit *test) board = dcp_v14_board_select(v14_bl_ctx_dcp_is, v14_bl_ctx_machine_is, j615, &known); KUNIT_ASSERT_NOT_NULL(test, board); KUNIT_EXPECT_FALSE(test, board->panel_nits); + board = dcp_v14_board_select(v14_bl_ctx_dcp_is, v14_bl_ctx_machine_is, j504, &known); + KUNIT_ASSERT_NOT_NULL(test, board); + KUNIT_EXPECT_TRUE(test, board->panel_nits); + KUNIT_EXPECT_TRUE(test, dcp_v14_panel_nits_admit(board, v14_bl_ctx_machine_is, j504)); + KUNIT_EXPECT_FALSE(test, dcp_v14_panel_nits_admit(board, v14_bl_ctx_machine_is, j615)); board = dcp_v14_board_select(v14_bl_ctx_dcp_is, v14_bl_ctx_machine_is, j516c, &known); KUNIT_ASSERT_NOT_NULL(test, board); KUNIT_EXPECT_TRUE(test, board->panel_nits); diff --git a/drivers/gpu/drm/apple/v14-board-test.c b/drivers/gpu/drm/apple/v14-board-test.c index 2a41853d76dd2..d79c2b79a9cbc 100644 --- a/drivers/gpu/drm/apple/v14-board-test.c +++ b/drivers/gpu/drm/apple/v14-board-test.c @@ -251,7 +251,7 @@ static void v14_swap_timestamps_encoding(struct kunit *test) /* * J504 (14" M3 MacBook Pro): the J613 image on the T8122 DCP, its own 3024x1964 - * ProMotion panel, brightness closed and unstamped swaps. The other T8122 + * ProMotion panel, the qualified level block (brightness) and unstamped swaps. The other T8122 * Macs (J433, J434) have no record. */ static void v14_board_j504(struct kunit *test) @@ -272,7 +272,7 @@ static void v14_board_j504(struct kunit *test) KUNIT_EXPECT_EQ(test, b->panel_height, 1964); KUNIT_EXPECT_TRUE(test, b->promotion); KUNIT_EXPECT_TRUE(test, b->log_bringup); - KUNIT_EXPECT_FALSE(test, b->panel_nits); + KUNIT_EXPECT_TRUE(test, b->panel_nits); KUNIT_EXPECT_FALSE(test, b->base_edid); KUNIT_EXPECT_EQ(test, b->ctm_set, air->ctm_set); KUNIT_EXPECT_EQ(test, b->ctm_get, air->ctm_get); diff --git a/tools/asahi/dcp14-panel-tests.py b/tools/asahi/dcp14-panel-tests.py index b6c5979b11714..19c02cafd8201 100755 --- a/tools/asahi/dcp14-panel-tests.py +++ b/tools/asahi/dcp14-panel-tests.py @@ -92,7 +92,7 @@ assert(!IS_ERR(p14)&&p14&&!strcmp(p14->name,"J504")&&!strcmp(p14->debugfs,"dcp-j504")); assert(p14->panel_width==3024&&p14->panel_height==1964&&p14->promotion&&p14->log_bringup); assert(!strcmp(p14->firmware_uuid,"90F849E1-B422-367E-B389-50246F8DEC47")); - assert(!strcmp(p14->handoff,"apple,t8122-handoff")&&!p14->panel_nits&&!p14->swap_timestamps); + assert(!strcmp(p14->handoff,"apple,t8122-handoff")&&p14->panel_nits&&!p14->swap_timestamps); assert(p14->ctm_set==A(421)&&p14->ctm_get==A(420)); image_uuid=p14->firmware_uuid;assert(probe_gate(&dev,p14)==0); image_uuid="C042E95C-B9D8-3F0E-94B3-582A08AA6FDD";assert(probe_gate(&dev,p14)==-ENODEV); From 15c5d4d09bd0596ce5cd6dd642460653a758bdc5 Mon Sep 17 00:00:00 2001 From: Scott Jones Date: Tue, 10 Nov 2026 19:39:45 -0500 Subject: [PATCH 12/13] drm/asahi: m3: map the adopted handoff regions as the 7.2 runtime did On 7.3 the M3 MacBook Air runtime adopts the firmware's UAT through Uat::new_adopted_with_user_upper(), which always asks for a write-combined mapping of the handoff and TTBAT regions. On these Macs the boot loader leaves both regions in the kernel's memory map as reserved RAM, and memremap() refuses a write-combined mapping of RAM: memremap attempted on ram 0x00000103fff70000 size: 0x4000 aurora 292400000.gpu: probe with driver aurora failed with error -12 On 7.2 the same helper chose the mapping per region: write-back for reserved RAM, write-combined for a carveout. Uat::new_adopted() still does that on 7.3. Add Uat::new_adopted_ram_with_user_upper(), which makes the same per-region choice and keeps the caller's choice of user upper half, and use it for the M3 runtime. The M4 caller keeps the write-combined constructor; no other backend calls either. Seen on a J613 with a 7.3 kernel on the m1n1 1.6.1.aurora23 handoff. Co-Authored-By: Claude Fable 5.2 Signed-off-by: Scott Jones --- drivers/gpu/drm/asahi/m3/m3_runtime.rs | 2 +- drivers/gpu/drm/asahi/mmu.rs | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/asahi/m3/m3_runtime.rs b/drivers/gpu/drm/asahi/m3/m3_runtime.rs index 762c8bc26e75b..e521089c9ec46 100644 --- a/drivers/gpu/drm/asahi/m3/m3_runtime.rs +++ b/drivers/gpu/drm/asahi/m3/m3_runtime.rs @@ -1411,7 +1411,7 @@ fn adopt_uat(drm: &driver::AsahiDrmDevice, soc: &'static crate::m3::m3_soc::Soc, let range = |r: crate::m3::agx_resources::Region| r.base..r.base + r.size; let geometry = mmu::UatGeometry { ias: cfg.uat_ias.into(), oas: cfg.uat_oas }; let regions = mmu::AdoptedRegions { handoff: range(handoff), ttbs: range(ttbs), kernel_root: tables.base }; - let uat = mmu::Uat::new_adopted_with_user_upper(drm, geometry, ®ions, + let uat = mmu::Uat::new_adopted_ram_with_user_upper(drm, geometry, ®ions, profile == super::m3_profile::Profile::Legacy)?; let mut window = crate::g15::uat::Window::from_regions(handoff.base, ttbs.base, tables.base, shared_l2.base)?; window.bootstrap(drm.as_ref().as_ref(), &uat)?; diff --git a/drivers/gpu/drm/asahi/mmu.rs b/drivers/gpu/drm/asahi/mmu.rs index 4337024993025..dcb46d6080ad4 100644 --- a/drivers/gpu/drm/asahi/mmu.rs +++ b/drivers/gpu/drm/asahi/mmu.rs @@ -3571,7 +3571,7 @@ impl Uat { /// Creates the same owned-RAM adopted UAT, choosing whether application contexts also /// name the firmware upper root. M4 qualifies only context 0 for firmware-upper access; /// its application TTBAT upper words stay zero. G15 preserves its existing shared upper. - #[cfg(any(CONFIG_DRM_ASAHI_G16, CONFIG_DRM_ASAHI_M3_T8122))] + #[cfg(CONFIG_DRM_ASAHI_G16)] pub(crate) fn new_adopted_with_user_upper( dev: &driver::AsahiDrmDevice, geometry: UatGeometry, @@ -3581,6 +3581,20 @@ impl Uat { Self::new_adopted_inner(dev, geometry, regions, map_kernel_to_user, false) } + /// As [`Self::new_adopted_with_user_upper`], for regions that may be reserved System RAM: + /// each is mapped write-back when it is RAM and write-combined when it is a carveout, as + /// [`Self::new_adopted`] does. The M3 boot loaders leave the handoff and TTBAT regions in + /// the kernel's memory map as reserved RAM, which a write-combined mapping is refused for. + #[cfg(CONFIG_DRM_ASAHI_M3_T8122)] + pub(crate) fn new_adopted_ram_with_user_upper( + dev: &driver::AsahiDrmDevice, + geometry: UatGeometry, + regions: &AdoptedRegions, + map_kernel_to_user: bool, + ) -> Result { + Self::new_adopted_inner(dev, geometry, regions, map_kernel_to_user, true) + } + #[cfg(any(CONFIG_DRM_ASAHI_G15, CONFIG_DRM_ASAHI_G16))] fn new_adopted_inner( dev: &driver::AsahiDrmDevice, From 98897fac88abbc9b382d22ea7764adb5bfe94b4d Mon Sep 17 00:00:00 2001 From: Scott Jones Date: Sat, 24 Oct 2026 02:23:50 -0400 Subject: [PATCH 13/13] drm/asahi: build the T8122 runtime without the G15 backend DRM_ASAHI_M3_T8122 depended on DRM_ASAHI_G15 only because the T8122 runtime adopts the firmware's UAT with the G15 backend's handoff helpers (g15::uat::Window and g15::memory_mode). Turning the M3 Air on therefore also turned the G15 backend on for M3 Pro/Max. Split the adoption out behind a hidden DRM_ASAHI_UAT_ADOPTION, selected by both options: - without G15, g15/adopt.rs builds only g15/{uat,regs,hw}.rs (no probe, no driver registration); what in them needs G15's Config or ADT (adopt(), Window::new, Regs::identity and the T6030/T6031 tables) stays under G15; - the RAM helpers memory_mode needs move from g15/glue.c to g15/uat_glue.c, so the runtime doesn't take glue.c's display helpers; - M3_T8122 now states its own dependency on APPLE_PMP, whose PMP votes the runtime calls directly (before, it was implied by nothing); - the mmu and pgtable items the runtime uses (the adopted Uat, with_tracked_status, read_user and point-of-coherency cleaning) are built with UAT_ADOPTION instead of G15. G15 selects UAT_ADOPTION, so every configuration that builds today is unchanged: off, G15 only and G15 with T8122 give the same warnings as before, and M3_T8122 alone now builds without warnings. The asahi-g15 selftest reads the helpers from their new file, and the g15-zero-words test pins the new hw.rs (its separate T6030 table pin is unchanged). Co-Authored-By: Claude Opus 5.5 (1M context) Signed-off-by: Scott Jones (ported from commit 9dff537d173 on omacom/linux-aurora) [7.3 base: G15 keeps this base's "default y" and selects the new option. The base builds what the runtime shares with G15 under "G15 or G16" and keeps the point-of-coherency cleaning unconditional, so the mmu and pgtable gates become "UAT_ADOPTION or G16" and gain no new #[cfg] on clean_poc. The module is aurora.ko here. g15-zero-words-tests pins hw.rs after the test's own normalisation. Built with G15 and T8122 (same warnings as before) and with T8122 alone: that builds, and none of its dead-code warnings is in g15/, m3/, mmu.rs or pgtable.rs. Not run on hardware.] Co-Authored-By: Claude Fable 5.2 --- drivers/gpu/drm/asahi/Kconfig | 14 ++++- drivers/gpu/drm/asahi/Makefile | 1 + drivers/gpu/drm/asahi/asahi_core.rs | 4 ++ drivers/gpu/drm/asahi/g15/adopt.rs | 32 ++++++++++ drivers/gpu/drm/asahi/g15/glue.c | 46 --------------- drivers/gpu/drm/asahi/g15/hw.rs | 2 + drivers/gpu/drm/asahi/g15/regs.rs | 3 +- drivers/gpu/drm/asahi/g15/uat.rs | 6 +- drivers/gpu/drm/asahi/g15/uat_glue.c | 59 +++++++++++++++++++ drivers/gpu/drm/asahi/mmu.rs | 28 ++++----- drivers/gpu/drm/asahi/pgtable.rs | 2 +- tools/asahi/g15-zero-words-tests.py | 6 +- .../selftests/drivers/gpu/asahi-g15/run.py | 8 ++- 13 files changed, 141 insertions(+), 70 deletions(-) create mode 100644 drivers/gpu/drm/asahi/g15/adopt.rs create mode 100644 drivers/gpu/drm/asahi/g15/uat_glue.c diff --git a/drivers/gpu/drm/asahi/Kconfig b/drivers/gpu/drm/asahi/Kconfig index 03939a732fc24..0df72bf32ae5b 100644 --- a/drivers/gpu/drm/asahi/Kconfig +++ b/drivers/gpu/drm/asahi/Kconfig @@ -79,11 +79,20 @@ config DRM_ASAHI_DEBUG_ALLOCATOR Say N unless you are debugging firmware structures or porting to a new firmware version. +config DRM_ASAHI_UAT_ADOPTION + bool + help + The firmware UAT handoff adoption shared by the G15 backend and the + T8122 runtime (g15/uat.rs, g15/regs.rs). + config DRM_ASAHI_M3_T8122 bool "M3 MacBook Air GPU runtime (T8122, 14.8.3 firmware)" depends on DRM_ASAHI - # The runtime adopts the firmware's UAT through the G15 backend's handoff helpers. - depends on DRM_ASAHI_G15 + # The runtime adopts the firmware's UAT as the G15 backend does, without + # needing that backend: M3 Pro/Max keep their own setting. + # Its PMP votes call apple-pmp directly (m3_device.rs). + depends on APPLE_PMP=y || (APPLE_PMP=m && DRM_ASAHI=m) + select DRM_ASAHI_UAT_ADOPTION select APPLE_T8122_GPU_PMP_LINK select CRYPTO_LIB_SHA256 default n @@ -102,6 +111,7 @@ config DRM_ASAHI_G15 depends on DRM_APPLE=y || (DRM_APPLE=m && DRM_ASAHI=m) select APPLE_T6030_GPU_PMP_LINK select CRYPTO_LIB_SHA256 + select DRM_ASAHI_UAT_ADOPTION default y help Backend for the M3 Pro (T6030) and M3 Max (T6031) GPUs on the diff --git a/drivers/gpu/drm/asahi/Makefile b/drivers/gpu/drm/asahi/Makefile index 890d47c40af6b..b39d2552dd900 100644 --- a/drivers/gpu/drm/asahi/Makefile +++ b/drivers/gpu/drm/asahi/Makefile @@ -5,6 +5,7 @@ aurora-y := asahi_core.o fwid.o legacy_sched.o sysfs.o g17/sync_input.o g17/sync CFLAGS_g17/trace.o := -I$(src)/g17 aurora-$(CONFIG_DRM_ASAHI_G15) += g15/glue.o +aurora-$(CONFIG_DRM_ASAHI_UAT_ADOPTION) += g15/uat_glue.o aurora-$(CONFIG_DRM_ASAHI_G16) += g16/glue.o diff --git a/drivers/gpu/drm/asahi/asahi_core.rs b/drivers/gpu/drm/asahi/asahi_core.rs index b970691651032..bd69152c3ce75 100644 --- a/drivers/gpu/drm/asahi/asahi_core.rs +++ b/drivers/gpu/drm/asahi/asahi_core.rs @@ -17,6 +17,10 @@ mod fw; mod fwid; #[cfg(CONFIG_DRM_ASAHI_G15)] mod g15; +// Without the G15 backend, only the UAT adoption the T8122 runtime shares with it. +#[cfg(all(CONFIG_DRM_ASAHI_UAT_ADOPTION, not(CONFIG_DRM_ASAHI_G15)))] +#[path = "g15/adopt.rs"] +mod g15; mod g17; mod gem; diff --git a/drivers/gpu/drm/asahi/g15/adopt.rs b/drivers/gpu/drm/asahi/g15/adopt.rs new file mode 100644 index 0000000000000..5dd54b04aaec6 --- /dev/null +++ b/drivers/gpu/drm/asahi/g15/adopt.rs @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT + +//! Without the G15 backend (`CONFIG_DRM_ASAHI_G15=n`), the parts of it the T8122 runtime uses to +//! adopt the firmware's UAT: the handoff window ([`uat`]), its mappings ([`regs`]) and the +//! hardware constants they name ([`hw`]). Nothing here probes a device. + +// Only the adoption is used; the rest of these files serves the G15 backend. +#![allow(dead_code)] + +// hw.rs's `t6031` submodule is cfg-gated on G15; were it built here, a #[path]-loaded file +// would look for it at g15/t6031.rs, not g15/hw/t6031.rs. +#[path = "hw.rs"] +pub(crate) mod hw; +#[path = "regs.rs"] +pub(crate) mod regs; +#[path = "uat.rs"] +pub(crate) mod uat; + +use kernel::prelude::*; + +extern "C" { + fn asahi_g15_memory_mode(start: u64, size: u64) -> u32; +} + +/// WB for complete reserved RAM, WC for aligned non-RAM carveouts; reject everything else. +pub(crate) fn memory_mode(start: u64, size: u64) -> Result { + // SAFETY: Only queries resources and page metadata; it does not create a mapping. + match unsafe { asahi_g15_memory_mode(start, size) } { + 0 => Err(EINVAL), + mode => Ok(mode), + } +} diff --git a/drivers/gpu/drm/asahi/g15/glue.c b/drivers/gpu/drm/asahi/g15/glue.c index 2a0346228c1e5..a12a5e6fa2fe7 100644 --- a/drivers/gpu/drm/asahi/g15/glue.c +++ b/drivers/gpu/drm/asahi/g15/glue.c @@ -29,9 +29,6 @@ void asahi_g15_release_power(struct device *dev); void asahi_g15_reprobe(void); void asahi_g15_report_loader_gpu(void); int asahi_g15_adt_phram(u64 *start, u64 *size); -bool asahi_g15_ram_disjoint(u64 start, u64 size); -bool asahi_g15_ram_within(u64 start, u64 size); -unsigned int asahi_g15_memory_mode(u64 start, u64 size); void __iomem *asahi_g15_ioremap_wc(u64 start, size_t size); bool asahi_g15_dma_coherent(struct device *dev); int asahi_g15_pmp_prepare(struct device *dev); @@ -275,13 +272,6 @@ int asahi_g15_adt_phram(u64 *start, u64 *size) return 0; } -/* The range is disjoint from System RAM (ADT region admission). */ -bool asahi_g15_ram_disjoint(u64 start, u64 size) -{ - return region_intersects(start, size, IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE) == - REGION_DISJOINT; -} - /* * Whether DMA mappings of the device skip cache maintenance. The G15 firmware * objects rely on the DMA mapping cleaning their pages to the point of @@ -292,42 +282,6 @@ bool asahi_g15_dma_coherent(struct device *dev) return dev_is_dma_coherent(dev); } -/* - * Every page must be valid, System RAM and still reserved from the allocator. - * REGION_INTERSECTS alone also accepts RAM mixed with undefined memory holes. - */ -bool asahi_g15_ram_within(u64 start, u64 size) -{ - u64 end, pa; - - if (!size || !IS_ALIGNED(start, PAGE_SIZE) || - !IS_ALIGNED(size, PAGE_SIZE) || check_add_overflow(start, size, &end)) - return false; - for (pa = start; pa < end; pa += PAGE_SIZE) { - unsigned long pfn = PHYS_PFN(pa); - - if (!pfn_valid(pfn) || !page_is_ram(pfn) || - !PageReserved(pfn_to_page(pfn))) - return false; - } - return true; -} - -/* One classification for every adopted-UAT and firmware-region CPU mapping. */ -unsigned int asahi_g15_memory_mode(u64 start, u64 size) -{ - u64 end; - - if (!size || !IS_ALIGNED(start, PAGE_SIZE) || - !IS_ALIGNED(size, PAGE_SIZE) || check_add_overflow(start, size, &end)) - return 0; - if (asahi_g15_ram_within(start, size)) - return MEMREMAP_WB; - if (asahi_g15_ram_disjoint(start, size)) - return MEMREMAP_WC; - return 0; -} - /* The inherited RTKit buffer inside firmware DATA. */ void __iomem *asahi_g15_ioremap_wc(u64 start, size_t size) { diff --git a/drivers/gpu/drm/asahi/g15/hw.rs b/drivers/gpu/drm/asahi/g15/hw.rs index be319b0cd2702..cac11c55d3ca0 100644 --- a/drivers/gpu/drm/asahi/g15/hw.rs +++ b/drivers/gpu/drm/asahi/g15/hw.rs @@ -7,6 +7,7 @@ use core::ops::Range; +#[cfg(CONFIG_DRM_ASAHI_G15)] pub(crate) mod t6031; /// Identification register values of a qualified G15S. @@ -91,6 +92,7 @@ pub(crate) struct ComputeRegs { } /// The T6030 configuration. +#[cfg(CONFIG_DRM_ASAHI_G15)] pub(crate) mod t6030 { use super::super::Config; use super::{ComputeRegs, FirmwareBuild, HwId, Layout}; diff --git a/drivers/gpu/drm/asahi/g15/regs.rs b/drivers/gpu/drm/asahi/g15/regs.rs index 05a1b390b3dff..98e7d4c8cf78a 100644 --- a/drivers/gpu/drm/asahi/g15/regs.rs +++ b/drivers/gpu/drm/asahi/g15/regs.rs @@ -125,7 +125,7 @@ impl Mapping { if size == 0 { return Err(EINVAL); } - let mode = super::boot::glue::memory_mode(phys, size as u64)?; + let mode = super::memory_mode(phys, size as u64)?; if mode == bindings::MEMREMAP_WC as u32 { return Self::write_combined(phys, size); } @@ -252,6 +252,7 @@ impl Regs { /// Reads the identification words and the enabled-core mask (once the GPU is powered). A /// SoC with more than 32 core slots carries the mask in two words. + #[cfg(CONFIG_DRM_ASAHI_G15)] pub(crate) fn identity(&self, cfg: &super::Config) -> Result { let version = self.sgx.io().try_read32(SGX_ID)?; let counts = self.sgx.io().try_read32(SGX_ID + 0x10)?; diff --git a/drivers/gpu/drm/asahi/g15/uat.rs b/drivers/gpu/drm/asahi/g15/uat.rs index 0f91f7c9f0610..0f0aa01e23517 100644 --- a/drivers/gpu/drm/asahi/g15/uat.rs +++ b/drivers/gpu/drm/asahi/g15/uat.rs @@ -38,12 +38,14 @@ use kernel::{ bindings, device, io::Io, prelude::*, - sync::Arc, time::{delay::fsleep, Delta, Instant, Monotonic}, }; +#[cfg(CONFIG_DRM_ASAHI_G15)] +use kernel::sync::Arc; use super::hw; use super::regs::{mb, rmb, wmb, Mapping}; +#[cfg(CONFIG_DRM_ASAHI_G15)] use crate::driver::AsahiDrmDevice as AsahiDevice; use crate::{mmu, pgtable}; @@ -69,6 +71,7 @@ const fn indices(va: u64) -> [usize; 3] { } /// Creates the adopted UAT over the ADT regions (step 2 above). +#[cfg(CONFIG_DRM_ASAHI_G15)] pub(crate) fn adopt( dev: &AsahiDevice, cfg: &'static super::Config, @@ -201,6 +204,7 @@ pub(crate) struct Window { impl Window { /// Maps the UAT handoff regions ([`Mapping::region`]). + #[cfg(CONFIG_DRM_ASAHI_G15)] pub(crate) fn new(adt: &super::adt::GpuAdt) -> Result { Self::from_regions(adt.handoff.start, adt.ttbs.start, adt.tables.start, adt.shared_l2.start) } diff --git a/drivers/gpu/drm/asahi/g15/uat_glue.c b/drivers/gpu/drm/asahi/g15/uat_glue.c new file mode 100644 index 0000000000000..134ff4bb28ab6 --- /dev/null +++ b/drivers/gpu/drm/asahi/g15/uat_glue.c @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT +/* + * C helpers of the UAT adoption (g15/uat.rs, g15/regs.rs), built for the G15 + * backend and for the T8122 runtime, which adopts the firmware's UAT the same + * way (CONFIG_DRM_ASAHI_UAT_ADOPTION). + */ +#include +#include +#include +#include +#include +#include + +bool asahi_g15_ram_disjoint(u64 start, u64 size); +bool asahi_g15_ram_within(u64 start, u64 size); +unsigned int asahi_g15_memory_mode(u64 start, u64 size); + +/* The range is disjoint from System RAM (ADT region admission). */ +bool asahi_g15_ram_disjoint(u64 start, u64 size) +{ + return region_intersects(start, size, IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE) == + REGION_DISJOINT; +} + +/* + * Every page must be valid, System RAM and still reserved from the allocator. + * REGION_INTERSECTS alone also accepts RAM mixed with undefined memory holes. + */ +bool asahi_g15_ram_within(u64 start, u64 size) +{ + u64 end, pa; + + if (!size || !IS_ALIGNED(start, PAGE_SIZE) || + !IS_ALIGNED(size, PAGE_SIZE) || check_add_overflow(start, size, &end)) + return false; + for (pa = start; pa < end; pa += PAGE_SIZE) { + unsigned long pfn = PHYS_PFN(pa); + + if (!pfn_valid(pfn) || !page_is_ram(pfn) || + !PageReserved(pfn_to_page(pfn))) + return false; + } + return true; +} + +/* One classification for every adopted-UAT and firmware-region CPU mapping. */ +unsigned int asahi_g15_memory_mode(u64 start, u64 size) +{ + u64 end; + + if (!size || !IS_ALIGNED(start, PAGE_SIZE) || + !IS_ALIGNED(size, PAGE_SIZE) || check_add_overflow(start, size, &end)) + return 0; + if (asahi_g15_ram_within(start, size)) + return MEMREMAP_WB; + if (asahi_g15_ram_disjoint(start, size)) + return MEMREMAP_WC; + return 0; +} diff --git a/drivers/gpu/drm/asahi/mmu.rs b/drivers/gpu/drm/asahi/mmu.rs index dcb46d6080ad4..34c697be9bdb7 100644 --- a/drivers/gpu/drm/asahi/mmu.rs +++ b/drivers/gpu/drm/asahi/mmu.rs @@ -505,10 +505,10 @@ fn lock_vm( Ok(VmExecGuard(unsafe { gpuvm.exec_lock(obj, interruptible)? })) } -#[cfg(any(CONFIG_DRM_ASAHI_G15, CONFIG_DRM_ASAHI_G16))] +#[cfg(any(CONFIG_DRM_ASAHI_UAT_ADOPTION, CONFIG_DRM_ASAHI_G16))] pub(crate) struct VmReadGuard(VmExecGuard); -#[cfg(any(CONFIG_DRM_ASAHI_G15, CONFIG_DRM_ASAHI_G16))] +#[cfg(any(CONFIG_DRM_ASAHI_UAT_ADOPTION, CONFIG_DRM_ASAHI_G16))] impl VmReadGuard { #[cfg(CONFIG_DRM_ASAHI_G15)] pub(crate) fn covers_range(&mut self, address: u64, size: u64, read: bool, write: bool) -> bool { @@ -2596,7 +2596,7 @@ impl Vm { /// Attach a status and job lifetime tracking before sharing a newly created user VM with /// queues, without the G17 canonical context views, shared-object footprints and idle /// residency reclaim of [`Self::with_status`]. Used by G15, whose user objects stay pinned. - #[cfg(any(CONFIG_DRM_ASAHI_G15, CONFIG_DRM_ASAHI_G16))] + #[cfg(any(CONFIG_DRM_ASAHI_UAT_ADOPTION, CONFIG_DRM_ASAHI_G16))] pub(crate) fn with_tracked_status(mut self) -> Result { self.status = Some(Arc::pin_init( crate::g17::status::VmStatus::new(), @@ -2624,17 +2624,17 @@ impl Vm { /// and invalidated to the point of coherency first (never only invalidated: CPU-written lines /// may be dirty), so the copy sees what the GPU or a write-combined CPU view stored. The /// mappings cannot change during the copy (GPUVM exec lock). - #[cfg(any(CONFIG_DRM_ASAHI_G15, CONFIG_DRM_ASAHI_G16))] + #[cfg(any(CONFIG_DRM_ASAHI_UAT_ADOPTION, CONFIG_DRM_ASAHI_G16))] pub(crate) fn read_user(&self, va: u64, buf: &mut [u8]) -> Result { self.read_lock()?.read_user(va, buf) } - #[cfg(any(CONFIG_DRM_ASAHI_G15, CONFIG_DRM_ASAHI_G16))] + #[cfg(any(CONFIG_DRM_ASAHI_UAT_ADOPTION, CONFIG_DRM_ASAHI_G16))] pub(crate) fn read_lock(&self) -> Result { Ok(VmReadGuard(lock_vm(&self.gpuvm, None, false)?)) } - #[cfg(any(CONFIG_DRM_ASAHI_G15, CONFIG_DRM_ASAHI_G16))] + #[cfg(any(CONFIG_DRM_ASAHI_UAT_ADOPTION, CONFIG_DRM_ASAHI_G16))] fn read_user_locked(inner: &mut VmInner, va: u64, buf: &mut [u8]) -> Result { let mut done = 0usize; while done < buf.len() { @@ -3477,7 +3477,7 @@ impl Drop for VmInner { /// Physical regions of a UAT whose handoff the generation has already established itself /// ([`Uat::new_adopted`]). None of them needs to be in the kernel linear map. -#[cfg(any(CONFIG_DRM_ASAHI_G15, CONFIG_DRM_ASAHI_G16))] +#[cfg(any(CONFIG_DRM_ASAHI_UAT_ADOPTION, CONFIG_DRM_ASAHI_G16))] pub(crate) struct AdoptedRegions { /// The handoff region (PPL magic, lock and flush requests). pub(crate) handoff: Range, @@ -3500,7 +3500,7 @@ impl Uat { }) } - #[cfg(any(CONFIG_DRM_ASAHI_G15, CONFIG_DRM_ASAHI_G16))] + #[cfg(any(CONFIG_DRM_ASAHI_UAT_ADOPTION, CONFIG_DRM_ASAHI_G16))] /// Map a region given by its physical range, write-combined. fn map_physical( range: &Range, @@ -3521,7 +3521,7 @@ impl Uat { let res: io::resource::Resource = unsafe { core::mem::transmute(kernel::types::Opaque::new(raw)) }; let flags = io::mem::MemFlag::WC; - #[cfg(CONFIG_DRM_ASAHI_G15)] + #[cfg(CONFIG_DRM_ASAHI_UAT_ADOPTION)] let flags = if reserved_ram { // G15 admits only whole reserved RAM pages or wholly non-RAM carveouts. if crate::g15::memory_mode(range.start, size as u64)? @@ -3534,7 +3534,7 @@ impl Uat { } else { flags }; - #[cfg(not(CONFIG_DRM_ASAHI_G15))] + #[cfg(not(CONFIG_DRM_ASAHI_UAT_ADOPTION))] let _ = reserved_ram; // SAFETY: The UAT regions are only accessed through this mapping by the CPU; // the GPU reaches them through its own translation. @@ -3545,7 +3545,7 @@ impl Uat { }) } - #[cfg(any(CONFIG_DRM_ASAHI_G15, CONFIG_DRM_ASAHI_G16))] + #[cfg(any(CONFIG_DRM_ASAHI_UAT_ADOPTION, CONFIG_DRM_ASAHI_G16))] /// Creates a `Uat` for a handoff that the caller establishes itself (G15). /// /// This only maps the handoff and the TTBAT (write-combined); neither is written here. The @@ -3595,7 +3595,7 @@ impl Uat { Self::new_adopted_inner(dev, geometry, regions, map_kernel_to_user, true) } - #[cfg(any(CONFIG_DRM_ASAHI_G15, CONFIG_DRM_ASAHI_G16))] + #[cfg(any(CONFIG_DRM_ASAHI_UAT_ADOPTION, CONFIG_DRM_ASAHI_G16))] fn new_adopted_inner( dev: &driver::AsahiDrmDevice, geometry: UatGeometry, @@ -3686,13 +3686,13 @@ impl Uat { }) } - #[cfg(any(CONFIG_DRM_ASAHI_G15, CONFIG_DRM_ASAHI_G16))] + #[cfg(any(CONFIG_DRM_ASAHI_UAT_ADOPTION, CONFIG_DRM_ASAHI_G16))] /// Root of the kernel lower `Vm`, for TTBAT context 0 of an adopted handoff. pub(crate) fn kernel_lower_root(&self) -> PhysicalAddr { self.kernel_lower_vm.ttb() } - #[cfg(any(CONFIG_DRM_ASAHI_G15, CONFIG_DRM_ASAHI_G16))] + #[cfg(any(CONFIG_DRM_ASAHI_UAT_ADOPTION, CONFIG_DRM_ASAHI_G16))] /// Root whose driver-window entry names the second-level table of [`Self::kernel_vm`]'s /// driver window. With [`Self::new_adopted`] this is the shadow root that no context names. pub(crate) fn kernel_window_root(&self) -> PhysicalAddr { diff --git a/drivers/gpu/drm/asahi/pgtable.rs b/drivers/gpu/drm/asahi/pgtable.rs index 9fb2d0652e01e..0cc2fac3b340a 100644 --- a/drivers/gpu/drm/asahi/pgtable.rs +++ b/drivers/gpu/drm/asahi/pgtable.rs @@ -369,7 +369,7 @@ impl Prot { /// The protection bits of a leaf with this protection (no address, table type or non-global /// bits), for checking that a firmware leaf word round-trips through [`Self::from_pte`]. - #[cfg(any(CONFIG_DRM_ASAHI_G15, CONFIG_DRM_ASAHI_G16))] + #[cfg(any(CONFIG_DRM_ASAHI_UAT_ADOPTION, CONFIG_DRM_ASAHI_G16))] pub(crate) const fn leaf_bits(&self) -> u64 { self.as_pte() } diff --git a/tools/asahi/g15-zero-words-tests.py b/tools/asahi/g15-zero-words-tests.py index 3a31cba6958bf..f4d18bc9685ac 100644 --- a/tools/asahi/g15-zero-words-tests.py +++ b/tools/asahi/g15-zero-words-tests.py @@ -15,7 +15,9 @@ (one #[cfg] line; the tables are unchanged), and when the initial PB posting and the idle reclaim became fixed tuning constants instead of module parameters (four constants; the tables are unchanged), and when the two stamp -renumbering margins became tuning constants (the tables are unchanged). Its T6030 +renumbering margins became tuning constants (the tables are unchanged), and when +the T6030/T6031 tables were gated on CONFIG_DRM_ASAHI_G15 for the T8122 runtime's +UAT adoption (two #[cfg] lines; the tables are unchanged). Its T6030 configuration module is independently pinned to the original bytes, except for the J514S B0 FirmwareBuild row, the J514S cd05 and J516S cd05 @@ -40,7 +42,7 @@ GOLDEN_FILES = { "board/data.rs": "7c5ff1077ca3296cbfc9e7144294162b6dea78a3774c38eeed4b0f59a14d7a5c", "board/template.rs": "286872f5474a67534f214e83e659253299f85143f3dc59035fa80894022e2549", - "hw.rs": "f45a0f11f952fea4e36809267ffd240ee1e381e8f3400de5e8527cd316b9f225", + "hw.rs": "9fa2d6e5f5d14127574448cafd6523d2151dab77c66d16e74500fafde21e8d92", "power/idle.rs": "4928ecf7699b3ca85ff5143eb6e996efd40d47321e29a238a02c8873bc9f102c", } GOLDEN_FUNCTIONS = { diff --git a/tools/testing/selftests/drivers/gpu/asahi-g15/run.py b/tools/testing/selftests/drivers/gpu/asahi-g15/run.py index b0c3105235f7b..80b7174635b5d 100644 --- a/tools/testing/selftests/drivers/gpu/asahi-g15/run.py +++ b/tools/testing/selftests/drivers/gpu/asahi-g15/run.py @@ -260,13 +260,15 @@ def main(): with tempfile.TemporaryDirectory(prefix="asahi-g15-host-") as temp: temp = Path(temp) glue = (G15 / "glue.c").read_text() + # The UAT adoption's helpers, shared with the T8122 runtime. + uat_glue = (G15 / "uat_glue.c").read_text() functions = [] for signature in ["bool asahi_g15_ram_disjoint", "bool asahi_g15_ram_within", "unsigned int asahi_g15_memory_mode"]: marker = signature + "(u64 start, u64 size)\n{" - start = glue.index(marker) - end = glue.index("\n}", start) + 2 - functions.append(glue[start:end]) + start = uat_glue.index(marker) + end = uat_glue.index("\n}", start) + 2 + functions.append(uat_glue[start:end]) c_source = temp / "memory.c" c_source.write_text(MEMORY_PREFIX + "\n".join(functions) + MEMORY_CASES) subprocess.run([os.environ.get("HOSTCC", "cc"), "-std=gnu11", "-Wall", "-Wextra",