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 1/5] 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 2/5] 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 3/5] 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 4/5] 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 5/5] 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")