From 609a031fc3b1fdf657fb15c22bd6346aa58c7bd6 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Fri, 27 Nov 2026 00:35:24 -0500 Subject: [PATCH 1/3] media: apple: ave: decide the firmware build admission in one function ave_fw_probe() decides in two places whether the preloaded firmware is a build the variant admits. Before TEXT is read, the segment sizes must select a build. After the TEXT identity CRC is known, that CRC must be in the known list and must be the selected build's own, or the variant's when it has no builds[]. A same-size build with this CRC is preferred. Move the size step into ave_fw_size_build(), which the probe still calls first because ave_fw_text_id() needs the build's per-boot word. Move the whole decision into ave_fw_admit(), which the probe calls once the CRC is known. The results and error codes are the same as before: -EINVAL for segment sizes that no build has, and -ENODEV for a CRC the variant does not admit. ave_fw_admit() needs no device, so KUnit now tests the gate itself: a variant without builds[], two builds that share sizes, build CRCs used with another build's sizes, a build that names no CRC, and the probe-only M3 generation. Signed-off-by: DjDeveloperr --- .../media/platform/apple/ave/ave-abi-test.c | 69 ++++++++++++++ drivers/media/platform/apple/ave/ave-fw.c | 89 ++++++++++++------- drivers/media/platform/apple/ave/ave.h | 2 + 3 files changed, 128 insertions(+), 32 deletions(-) diff --git a/drivers/media/platform/apple/ave/ave-abi-test.c b/drivers/media/platform/apple/ave/ave-abi-test.c index 1698e8a97ec94..754b13bbe3d6f 100644 --- a/drivers/media/platform/apple/ave/ave-abi-test.c +++ b/drivers/media/platform/apple/ave/ave-abi-test.c @@ -1633,6 +1633,74 @@ static void ave_t8112_26b123_build(struct kunit *test) &ave_layout_6070_11_1); } +/* + * The probe's firmware gate: the segment sizes pick the build, and the TEXT + * identity CRC must be a known one that is that build's own. + */ +static void ave_fw_admit_gate(struct kunit *test) +{ + /* Two builds of the same sizes, told apart by their CRCs. */ + static const struct ave_fw_build shared_builds[] = { + { "a", 0x10000, 0x20000, 0x460c7a7c }, + { "b", 0x10000, 0x20000, 0x25bfd039 }, + }; + static const struct ave_variant shared = { + .builds = shared_builds, + .build_count = ARRAY_SIZE(shared_builds), + .boot_qualified = true, + }; + const struct ave_variant *m2_272 = ave_t8112.next_build; + const struct ave_fw_build *b; + + /* A variant without builds[] takes its own sizes and CRC only. */ + b = shared_builds; + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t8112, 0xd0000, 0x128000, + 0x25bfd039, &b), 0); + KUNIT_EXPECT_NULL(test, b); + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t8112, 0xd0000, 0x128000, + 0x460c7a7c, &b), -ENODEV); + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t8112, 0xd0000, 0x128000, + 0x25bfd038, &b), -ENODEV); + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t8112, 0xd0000, 0x12c000, + 0x25bfd039, &b), -EINVAL); + + /* Builds of the same sizes: the CRC picks one and must be one of them. */ + KUNIT_EXPECT_EQ(test, ave_fw_admit(&shared, 0x10000, 0x20000, + 0x25bfd039, &b), 0); + KUNIT_EXPECT_PTR_EQ(test, b, &shared_builds[1]); + KUNIT_EXPECT_EQ(test, ave_fw_admit(&shared, 0x10000, 0x20000, + 0x460c7a7c, &b), 0); + KUNIT_EXPECT_PTR_EQ(test, b, &shared_builds[0]); + KUNIT_EXPECT_EQ(test, ave_fw_admit(&shared, 0x10000, 0x20000, + AVE_FW_TEXT_CRC_9003_78_0, &b), -ENODEV); + + /* Each build's CRC only with its own sizes. */ + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t6050, 0x158000, 0x134000, + AVE_FW_TEXT_CRC_T6050_26C5035, &b), 0); + KUNIT_EXPECT_PTR_EQ(test, b, &ave_t6050.builds[1]); + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t6050, 0x154000, 0x134000, + AVE_FW_TEXT_CRC_T6050_26C5035, &b), -ENODEV); + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t6050, 0x158000, 0x130000, + AVE_FW_TEXT_CRC_T6050_26C5035, &b), -EINVAL); + KUNIT_EXPECT_EQ(test, ave_fw_admit(m2_272, 0x11c000, 0x128000, + AVE_FW_TEXT_CRC_T8112_26B123, &b), 0); + KUNIT_EXPECT_PTR_EQ(test, b, &m2_272->builds[0]); + KUNIT_EXPECT_EQ(test, ave_fw_admit(m2_272, 0x11c000, 0x128000, + 0x25bfd039, &b), -ENODEV); + + /* A build that names no CRC takes any known one, never another. */ + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t6041, 0x14c000, 0x130000, + AVE_FW_TEXT_CRC_T6041_25G83, &b), 0); + KUNIT_EXPECT_PTR_EQ(test, b, &ave_t6041.builds[1]); + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t6041, 0x14c000, 0x130000, + 0x9a080cac, &b), -ENODEV); + + /* The probe-only M3 generation takes any sizes and CRC. */ + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_m3, 0x134000, 0x128000, + 0x12345678, &b), 0); + KUNIT_EXPECT_NULL(test, b); +} + /* * HEVC B flag with a PPS whose num_extra_slice_header_bits is 2. The PPS * comes with the IDR access unit; the B slice after it has two extra bits @@ -1747,6 +1815,7 @@ static struct kunit_case ave_abi_cases[] = { KUNIT_CASE(ave_m3_probe_only), KUNIT_CASE(ave_26b123_layout), KUNIT_CASE(ave_t8112_26b123_build), + KUNIT_CASE(ave_fw_admit_gate), KUNIT_CASE(ave_hevc_bframe_extra_bits), {} }; diff --git a/drivers/media/platform/apple/ave/ave-fw.c b/drivers/media/platform/apple/ave/ave-fw.c index 9522672040711..d23512003ae23 100644 --- a/drivers/media/platform/apple/ave/ave-fw.c +++ b/drivers/media/platform/apple/ave/ave-fw.c @@ -261,6 +261,53 @@ const struct ave_variant *ave_fw_select_build(const struct ave_variant *v, return v; } +/* + * The first of the variant's builds with these segment sizes, or NULL for a + * variant without builds[]. -EINVAL when the variant pins other sizes; a + * probe-only variant that pins none takes any. + */ +static int ave_fw_size_build(const struct ave_variant *v, size_t text, + size_t data, const struct ave_fw_build **build) +{ + *build = NULL; + if (v->build_count) { + *build = ave_fw_find_build(v, text, data, 0); + return *build ? 0 : -EINVAL; + } + if (!v->boot_qualified && !v->fw_text_size) + return 0; + return ave_fw_sizes_match(v, text, data) ? 0 : -EINVAL; +} + +/* + * Whether firmware with these segment sizes and TEXT identity CRC is a + * build the variant admits, and which (NULL for a variant without builds[]). + * Of the builds sharing these sizes, the one with this CRC is picked. A + * boot-qualified variant needs a CRC in the known list that is also the + * picked build's, or without builds the variant's, unless that names none; + * a probe-only variant takes any CRC. Returns -EINVAL when no build has + * these sizes and -ENODEV when the CRC is not admitted. + */ +int ave_fw_admit(const struct ave_variant *v, size_t text, size_t data, + u32 crc, const struct ave_fw_build **build) +{ + const struct ave_fw_build *b; + u32 want; + int ret; + + ret = ave_fw_size_build(v, text, data, &b); + if (ret) + return ret; + if (b) + b = ave_fw_find_build(v, text, data, crc) ?: b; + want = b ? b->text_crc : v->text_crc; + if ((v->boot_qualified && !ave_fw_known_crc(crc)) || + (want && crc != want)) + return -ENODEV; + *build = b; + return 0; +} + /* * Find the firmware, check that it is a build we speak to and that DATA is * still as the bootloader left it, and keep a copy of DATA for restarts. @@ -268,9 +315,8 @@ const struct ave_variant *ave_fw_select_build(const struct ave_variant *v, int ave_fw_probe(struct ave_dev *ave) { struct device *dev = ave->dev; - const struct ave_fw_build *build = NULL; - u32 text_crc, data_crc, want, want_crc; - bool known; + const struct ave_fw_build *build; + u32 text_crc, data_crc, want; int ret; if (of_count_phandle_with_args(dev->of_node, "memory-region", NULL) != @@ -285,24 +331,12 @@ int ave_fw_probe(struct ave_dev *ave) ave->variant = ave_fw_select_build(ave->variant, ave->text.size, ave->data.size); - want_crc = ave->variant->text_crc; - known = !ave->variant->boot_qualified; - if (ave->variant->build_count) { - build = ave_fw_find_build(ave->variant, ave->text.size, - ave->data.size, 0); - if (!build) - return dev_err_probe(dev, -EINVAL, - "unexpected firmware segment sizes (TEXT %#zx DATA %#zx)\n", - ave->text.size, ave->data.size); - want_crc = build->text_crc; - } else if (!ave->variant->boot_qualified && !ave->variant->fw_text_size) { - /* A probe-only variant that pins no build takes any segment sizes. */ - } else if (!ave_fw_sizes_match(ave->variant, ave->text.size, - ave->data.size)) { - return dev_err_probe(dev, -EINVAL, + ret = ave_fw_size_build(ave->variant, ave->text.size, ave->data.size, + &build); + if (ret) + return dev_err_probe(dev, ret, "unexpected firmware segment sizes (TEXT %#zx DATA %#zx)\n", ave->text.size, ave->data.size); - } if ((ave->text.phys < ave->data.phys + ave->data.size && ave->data.phys < ave->text.phys + ave->text.size) || (ave->text.iova < ave->data.iova + ave->data.size && @@ -339,19 +373,10 @@ int ave_fw_probe(struct ave_dev *ave) if (ret) return dev_err_probe(dev, ret, "firmware text link cell is not the DATA address\n"); - known |= ave_fw_known_crc(text_crc); - if (build) { - const struct ave_fw_build *same_size = - ave_fw_find_build(ave->variant, ave->text.size, - ave->data.size, text_crc); - - if (same_size) { - build = same_size; - want_crc = build->text_crc; - } - } - if (!known || (want_crc && text_crc != want_crc)) - return dev_err_probe(dev, -ENODEV, + ret = ave_fw_admit(ave->variant, ave->text.size, ave->data.size, + text_crc, &build); + if (ret) + return dev_err_probe(dev, ret, "unsupported firmware (text CRC %08x)\n", text_crc); ave->text_crc = text_crc; diff --git a/drivers/media/platform/apple/ave/ave.h b/drivers/media/platform/apple/ave/ave.h index 331c866381399..177b46f6e73de 100644 --- a/drivers/media/platform/apple/ave/ave.h +++ b/drivers/media/platform/apple/ave/ave.h @@ -587,6 +587,8 @@ int ave_fw_probe(struct ave_dev *ave); bool ave_fw_sizes_match(const struct ave_variant *v, size_t text, size_t data); const struct ave_variant *ave_fw_select_build(const struct ave_variant *v, size_t text, size_t data); +int ave_fw_admit(const struct ave_variant *v, size_t text, size_t data, + u32 crc, const struct ave_fw_build **build); int ave_fw_text_id_crc(const void *text, size_t size, u32 cell_off, u64 data_iova, u32 *crc); int ave_fw_text_boot_crc(const void *text, size_t size, u32 word_off, From 658ad317049c5c917e257b3bf36b1ec5ec6c7586 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Fri, 27 Nov 2026 00:37:03 -0500 Subject: [PATCH 2/3] media: apple: ave: admit the M1 Max (T6001) encoder firmware build The M1 Max's die 0 encoder uses the M1 Pro's compatible, coprocessor registers, boot sequence and 6070.11.1 command layout. The macOS 13.5 stub preloads a build of that firmware made for the M1 Max, though, with TEXT 0xec000 and DATA 0x134000 instead of 0xd0000 and 0x128000. ave_t6000 pins only the M1 Pro's sizes. On a J316c the probe therefore fails with "unexpected firmware segment sizes" (-EINVAL), and no encoder is registered. Give ave_t6000 one build per chip. The segment sizes select the build, and the TEXT identity CRC must then be that build's own: 460c7a7c for the M1 Pro and 65d16c38 for the M1 Max. As before, the identity CRC hashes the TEXT->DATA link cell at 0x423c as zero. Add 65d16c38 to the known list, and let it select the 6070.11.1 layout. No other check is relaxed. An image of the M1 Max's sizes with any other CRC is refused, including the M1 Pro's CRC. So are mixed sizes and other sizes. The DART window, link-cell, loader CRC and DATA boot-state checks are unchanged. The M1 Max shares the boot device, device type, extra-0 size and register layout of the M1 Pro, so ave_t6000 keeps them. Signed-off-by: DjDeveloperr --- Documentation/admin-guide/media/apple-ave.rst | 4 + drivers/media/platform/apple/ave/abi.rst | 5 +- .../media/platform/apple/ave/ave-abi-test.c | 79 ++++++++++++++++++- drivers/media/platform/apple/ave/ave-drv.c | 20 ++++- drivers/media/platform/apple/ave/ave-fw.c | 1 + drivers/media/platform/apple/ave/ave-layout.c | 3 + drivers/media/platform/apple/ave/ave.h | 6 ++ 7 files changed, 112 insertions(+), 6 deletions(-) diff --git a/Documentation/admin-guide/media/apple-ave.rst b/Documentation/admin-guide/media/apple-ave.rst index 52a44eaaa4e28..0555dad878dbc 100644 --- a/Documentation/admin-guide/media/apple-ave.rst +++ b/Documentation/admin-guide/media/apple-ave.rst @@ -49,6 +49,10 @@ T6000 (M1 Pro) and T8112 (M2) have probe-only support in this driver. Their device tree nodes and both encoder DARTs remain disabled. The firmware handoff must reserve their preloaded TEXT (0xd0000 bytes) and DATA (0x128000 bytes), preserve the ADT remap addresses and export both CRCs. +The M1 Max (T6001) encoder matches as T6000 but gets its own build of the +firmware, with TEXT 0xec000 and DATA 0x134000 bytes and TEXT CRC +``65d16c38``; the segment sizes select the build and only that CRC is +admitted with them. An enabled node with a valid handoff may bind, but encoding is refused with an informational message until per-SoC command constants, MCC DSID and the firmware CRCs have been qualified. The T8140 command constants are never a diff --git a/drivers/media/platform/apple/ave/abi.rst b/drivers/media/platform/apple/ave/abi.rst index 10cae4525125c..5e0a73b7e479c 100644 --- a/drivers/media/platform/apple/ave/abi.rst +++ b/drivers/media/platform/apple/ave/abi.rst @@ -15,8 +15,9 @@ at 1920x1080 with B-frames enabled/disabled, and 3840x2160 with B-frames enabled They compare both deterministic synthetic DART addresses and masked images. The constant image tables in ave-image.c are unchanged by this refactor. -6070.11.1 is selected only for T6000 TEXT CRC 460c7a7c or T8112 TEXT CRC 25bfd039, -with the corresponding SoC identity. Boot, seven-channel discovery, Config, +6070.11.1 is selected only for T6000 TEXT CRC 460c7a7c, the T6001 (M1 Max) build's +65d16c38 under the same T6000 match, or T8112 TEXT CRC 25bfd039, with the +corresponding SoC identity. Boot, seven-channel discovery, Config, Open, Close and scratch-confirmed Halt are implemented from the clean derived SPEC-6070-lifecycle.md ledger. Start and ordinary Process writers implement the clean revision-2/P1 field ledgers: fixed-capacity address banks, split output diff --git a/drivers/media/platform/apple/ave/ave-abi-test.c b/drivers/media/platform/apple/ave/ave-abi-test.c index 754b13bbe3d6f..8b920dafcff4c 100644 --- a/drivers/media/platform/apple/ave/ave-abi-test.c +++ b/drivers/media/platform/apple/ave/ave-abi-test.c @@ -1461,7 +1461,7 @@ static void ave_6070_variants(struct kunit *test) KUNIT_EXPECT_EQ(test, ave_t6000.device_type, 11U); KUNIT_EXPECT_EQ(test, ave_t6000.boot_arg_value, 0x400U); KUNIT_EXPECT_EQ(test, ave_t6000.timebase_multiplier, 1000000U); - KUNIT_EXPECT_EQ(test, ave_t6000.text_crc, 0x460c7a7cU); + KUNIT_EXPECT_EQ(test, ave_t6000.builds[0].text_crc, 0x460c7a7cU); KUNIT_EXPECT_EQ(test, ave_t6000.mbox_idle, 0x38U); KUNIT_EXPECT_EQ(test, ave_t8112.boot_device_id, 18U); KUNIT_EXPECT_EQ(test, ave_t8112.device_type, 15U); @@ -1701,6 +1701,82 @@ static void ave_fw_admit_gate(struct kunit *test) KUNIT_EXPECT_NULL(test, b); } +/* + * The M1 Max's encoder matches as the M1 Pro's and runs a larger build of + * the same firmware: its segment sizes pick that build, and only that + * build's CRC is admitted with them. + */ +static void ave_t6001_build(struct kunit *test) +{ + const u32 off = ave_t6000.text_link_cell, size = off + 0x100; + const struct ave_fw_build *pro, *max, *b; + u8 *text = kunit_kzalloc(test, size, GFP_KERNEL); + u32 image, crc; + + KUNIT_ASSERT_NOT_NULL(test, text); + KUNIT_ASSERT_EQ(test, ave_t6000.build_count, 2U); + pro = &ave_t6000.builds[0]; + max = &ave_t6000.builds[1]; + KUNIT_EXPECT_EQ(test, pro->text_size, 0xd0000U); + KUNIT_EXPECT_EQ(test, pro->data_size, 0x128000U); + KUNIT_EXPECT_EQ(test, max->text_size, 0xec000U); + KUNIT_EXPECT_EQ(test, max->data_size, 0x134000U); + KUNIT_EXPECT_EQ(test, max->text_crc, 0x65d16c38U); + /* No per-boot word: the CRCs match as they are. */ + KUNIT_EXPECT_EQ(test, pro->text_boot_word, 0U); + KUNIT_EXPECT_EQ(test, max->text_boot_word, 0U); + /* One start for both: no later variant to select. */ + KUNIT_EXPECT_NULL(test, ave_t6000.next_build); + KUNIT_EXPECT_PTR_EQ(test, ave_fw_select_build(&ave_t6000, 0xec000, 0x134000), + &ave_t6000); + + /* Each build with its own sizes and CRC. */ + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t6000, 0xd0000, 0x128000, + 0x460c7a7c, &b), 0); + KUNIT_EXPECT_PTR_EQ(test, b, pro); + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t6000, 0xec000, 0x134000, + AVE_FW_TEXT_CRC_T6001_6070, &b), 0); + KUNIT_EXPECT_PTR_EQ(test, b, max); + /* An image of the M1 Max's sizes with another CRC, a known one too. */ + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t6000, 0xec000, 0x134000, + AVE_FW_TEXT_CRC_T6001_6070 ^ 1, &b), -ENODEV); + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t6000, 0xec000, 0x134000, + 0x460c7a7c, &b), -ENODEV); + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t6000, 0xec000, 0x134000, + 0x25bfd039, &b), -ENODEV); + /* The M1 Max's CRC with the M1 Pro's sizes. */ + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t6000, 0xd0000, 0x128000, + AVE_FW_TEXT_CRC_T6001_6070, &b), -ENODEV); + /* Mixed and other sizes pick no build. */ + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t6000, 0xec000, 0x128000, + AVE_FW_TEXT_CRC_T6001_6070, &b), -EINVAL); + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t6000, 0xd0000, 0x134000, + AVE_FW_TEXT_CRC_T6001_6070, &b), -EINVAL); + KUNIT_EXPECT_EQ(test, ave_fw_admit(&ave_t6000, 0xf0000, 0x134000, + AVE_FW_TEXT_CRC_T6001_6070, &b), -EINVAL); + + /* + * DATA follows the M1 Max's larger TEXT, and the loader puts its + * address in the link cell; the identity hashes the cell as zero. + */ + for (u32 i = 0; i < size; i++) + text[i] = i * 5 + 1; + memset(text + off, 0, 8); + image = crc32_le(~0U, text, size) ^ ~0U; + put_unaligned_le64(max->text_size, text + off); + KUNIT_EXPECT_EQ(test, ave_fw_text_id_crc(text, size, off, max->text_size, + &crc), 0); + KUNIT_EXPECT_EQ(test, crc, image); + /* The M1 Pro's DATA address there is a different TEXT. */ + put_unaligned_le64(pro->text_size, text + off); + KUNIT_EXPECT_EQ(test, ave_fw_text_id_crc(text, size, off, max->text_size, + &crc), -ENODEV); + + KUNIT_EXPECT_PTR_EQ(test, ave_layout_for_crc(AVE_FW_TEXT_CRC_T6001_6070), + &ave_layout_6070_11_1); + KUNIT_EXPECT_NULL(test, ave_layout_for_crc(AVE_FW_TEXT_CRC_T6001_6070 ^ 1)); +} + /* * HEVC B flag with a PPS whose num_extra_slice_header_bits is 2. The PPS * comes with the IDR access unit; the B slice after it has two extra bits @@ -1816,6 +1892,7 @@ static struct kunit_case ave_abi_cases[] = { KUNIT_CASE(ave_26b123_layout), KUNIT_CASE(ave_t8112_26b123_build), KUNIT_CASE(ave_fw_admit_gate), + KUNIT_CASE(ave_t6001_build), KUNIT_CASE(ave_hevc_bframe_extra_bits), {} }; diff --git a/drivers/media/platform/apple/ave/ave-drv.c b/drivers/media/platform/apple/ave/ave-drv.c index bd3568d34deae..87f68017e092c 100644 --- a/drivers/media/platform/apple/ave/ave-drv.c +++ b/drivers/media/platform/apple/ave/ave-drv.c @@ -51,14 +51,28 @@ static const struct ave_coproc_regs ave_coproc_6070 = { .keep_mappings = 0x400808, }; +/* + * The M1 Pro (T6000) and the M1 Max (T6001) die 0 encoders, both + * apple,t6000-ave, start the same way and speak the 6070.11.1 command + * layout, but the macOS 13.5 (22G74) stub preloads each chip's own build of + * that firmware: the M1 Max's has TEXT 0xec000 and DATA 0x134000. The + * segment sizes select the build. Both builds have the TEXT->DATA link cell + * at 0x423c, and each one's TEXT CRC, with that cell hashed as zero, must + * match. + */ +static const struct ave_fw_build ave_t6000_builds[] = { + { "22G74", 0xd0000, 0x128000, 0x460c7a7c }, + /* The M1 Max's build */ + { "22G74", 0xec000, 0x134000, AVE_FW_TEXT_CRC_T6001_6070 }, +}; + const struct ave_variant ave_t6000 = { .regs = &ave_coproc_6070, - .fw_text_size = 0xd0000, - .fw_data_size = 0x128000, + .builds = ave_t6000_builds, + .build_count = ARRAY_SIZE(ave_t6000_builds), .boot_device_id = 14, .device_type = 11, .lfs_ref_scale = 1, - .text_crc = 0x460c7a7c, .boot_arg_value = 0x400, .timebase_multiplier = 1000000, .text_link_cell = 0x423c, diff --git a/drivers/media/platform/apple/ave/ave-fw.c b/drivers/media/platform/apple/ave/ave-fw.c index d23512003ae23..760ffb3659023 100644 --- a/drivers/media/platform/apple/ave/ave-fw.c +++ b/drivers/media/platform/apple/ave/ave-fw.c @@ -48,6 +48,7 @@ static const u32 ave_known_text_crc[] = { AVE_FW_TEXT_CRC_T8132_26B123, /* encoder firmware macOS 27.2 26B123 / T8132 */ AVE_FW_TEXT_CRC_T8142_26B123, /* encoder firmware 9013.55.1, macOS 27.2 26B123 / T8142 */ 0x460c7a7c, /* encoder firmware 6070.11.1 / T6000 */ + AVE_FW_TEXT_CRC_T6001_6070, /* encoder firmware 6070.11.1 / T6001 */ 0x25bfd039, /* encoder firmware 6070.11.1 / T8112 */ }; diff --git a/drivers/media/platform/apple/ave/ave-layout.c b/drivers/media/platform/apple/ave/ave-layout.c index b05103511532f..1e9840cb10078 100644 --- a/drivers/media/platform/apple/ave/ave-layout.c +++ b/drivers/media/platform/apple/ave/ave-layout.c @@ -992,6 +992,9 @@ const struct ave_fw_layout *ave_layout_for_crc(u32 crc) return &ave_layout_9003_78_0; if (crc == 0x460c7a7c || crc == 0x25bfd039) return &ave_layout_6070_11_1; + /* The M1 Max's build of 6070.11.1 takes the M1 Pro's commands. */ + if (crc == AVE_FW_TEXT_CRC_T6001_6070) + return &ave_layout_6070_11_1; /* * The macOS 27.0 build for the M5 Pro and Max, and the M5's build of the * same firmware version (9013.45.1): one macOS driver builds the diff --git a/drivers/media/platform/apple/ave/ave.h b/drivers/media/platform/apple/ave/ave.h index 177b46f6e73de..2713e450741d2 100644 --- a/drivers/media/platform/apple/ave/ave.h +++ b/drivers/media/platform/apple/ave/ave.h @@ -194,6 +194,12 @@ enum ave_opcode { * AppleAVE2FW 9013.55.1: TEXT 0x154000, DATA 0x12c000, as 26A428's. */ #define AVE_FW_TEXT_CRC_T8142_26B123 0x24eb4625 +/* + * The M1 Max (T6001) build of encoder firmware 6070.11.1, as the macOS 13.5 + * stub preloads it: TEXT 0xec000, DATA 0x134000. The TEXT CRC with the + * TEXT->DATA link cell at 0x423c zeroed. + */ +#define AVE_FW_TEXT_CRC_T6001_6070 0x65d16c38 struct ave_ctx; From 88860a0fd6cef65c041375aa0d5c9b4dd0b888ce Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Sat, 5 Dec 2026 03:05:08 -0500 Subject: [PATCH 3/3] media: apple: ave: keep the T6001 firmware probe-only Keep the exact segment and CRC admission for the M1 Max image. Leave its firmware command layout unqualified so the existing boot and streaming gates refuse it until the command path has been tested. Signed-off-by: DjDeveloperr --- Documentation/admin-guide/media/apple-ave.rst | 3 ++- drivers/media/platform/apple/ave/abi.rst | 8 +++++--- drivers/media/platform/apple/ave/ave-abi-test.c | 6 +++--- drivers/media/platform/apple/ave/ave-layout.c | 4 ++-- drivers/media/platform/apple/ave/tests/test.c | 10 ++++++++++ 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Documentation/admin-guide/media/apple-ave.rst b/Documentation/admin-guide/media/apple-ave.rst index 5746d1184593a..257b4c446e943 100644 --- a/Documentation/admin-guide/media/apple-ave.rst +++ b/Documentation/admin-guide/media/apple-ave.rst @@ -52,7 +52,8 @@ handoff must reserve their preloaded TEXT (0xd0000 bytes) and DATA The M1 Max (T6001) encoder matches as T6000 but gets its own build of the firmware, with TEXT 0xec000 and DATA 0x134000 bytes and TEXT CRC ``65d16c38``; the segment sizes select the build and only that CRC is -admitted with them. +admitted with them. The T6001 build is probe-only until its command path +is qualified. An enabled node with a valid handoff may bind, but encoding is refused with an informational message until per-SoC command constants, MCC DSID and the firmware CRCs have been qualified. The T8140 command constants are never a diff --git a/drivers/media/platform/apple/ave/abi.rst b/drivers/media/platform/apple/ave/abi.rst index f9b5e4a21d540..5ea1d59d21e5b 100644 --- a/drivers/media/platform/apple/ave/abi.rst +++ b/drivers/media/platform/apple/ave/abi.rst @@ -15,9 +15,11 @@ at 1920x1080 with B-frames enabled/disabled, and 3840x2160 with B-frames enabled They compare both deterministic synthetic DART addresses and masked images. The constant image tables in ave-image.c are unchanged by this refactor. -6070.11.1 is selected only for T6000 TEXT CRC 460c7a7c, the T6001 (M1 Max) build's -65d16c38 under the same T6000 match, or T8112 TEXT CRC 25bfd039, with the -corresponding SoC identity. Boot, seven-channel discovery, Config, +The T6001 (M1 Max) build with TEXT CRC 65d16c38 is admitted for probe. +Firmware boot and streaming require a qualified command layout. + +6070.11.1 is selected only for T6000 TEXT CRC 460c7a7c or T8112 TEXT CRC 25bfd039, +with the corresponding SoC identity. Boot, seven-channel discovery, Config, Open, Close and scratch-confirmed Halt are implemented from the clean derived SPEC-6070-lifecycle.md ledger. Start and ordinary Process writers implement the clean revision-2/P1 field ledgers: fixed-capacity address banks, split output diff --git a/drivers/media/platform/apple/ave/ave-abi-test.c b/drivers/media/platform/apple/ave/ave-abi-test.c index 646e459cd8d86..3ebf72ff60dc9 100644 --- a/drivers/media/platform/apple/ave/ave-abi-test.c +++ b/drivers/media/platform/apple/ave/ave-abi-test.c @@ -1831,7 +1831,7 @@ static void ave_t6001_build(struct kunit *test) /* No per-boot word: the CRCs match as they are. */ KUNIT_EXPECT_EQ(test, pro->text_boot_word, 0U); KUNIT_EXPECT_EQ(test, max->text_boot_word, 0U); - /* Both 22G74 builds use one start. The later stub has its own. */ + /* Both 22G74 builds share a probe profile. The later stub has its own. */ KUNIT_EXPECT_PTR_EQ(test, ave_fw_select_build(&ave_t6000, 0xd0000, 0x128000), &ave_t6000); KUNIT_ASSERT_NOT_NULL(test, ave_t6000.next_build); @@ -1871,8 +1871,8 @@ static void ave_t6001_build(struct kunit *test) KUNIT_EXPECT_EQ(test, ave_fw_text_id_crc(text, size, off, max->text_size, &crc), -ENODEV); - KUNIT_EXPECT_PTR_EQ(test, ave_layout_for_crc(AVE_FW_TEXT_CRC_T6001_6070), - &ave_layout_6070_11_1); + /* The M1 Max build can bind before its command path is qualified. */ + KUNIT_EXPECT_NULL(test, ave_layout_for_crc(AVE_FW_TEXT_CRC_T6001_6070)); KUNIT_EXPECT_NULL(test, ave_layout_for_crc(AVE_FW_TEXT_CRC_T6001_6070 ^ 1)); } diff --git a/drivers/media/platform/apple/ave/ave-layout.c b/drivers/media/platform/apple/ave/ave-layout.c index 0010a0fde1af8..eb36128218a84 100644 --- a/drivers/media/platform/apple/ave/ave-layout.c +++ b/drivers/media/platform/apple/ave/ave-layout.c @@ -1023,8 +1023,8 @@ const struct ave_fw_layout *ave_layout_for_crc(u32 crc) crc == AVE_FW_TEXT_CRC_T6041_25G83 || crc == AVE_FW_TEXT_CRC_T8132_25G83) return &ave_layout_9003_78_0; - if (crc == 0x460c7a7c || crc == AVE_FW_TEXT_CRC_T6001_6070 || - crc == 0x25bfd039 || crc == AVE_FW_TEXT_CRC_T6022_6070) + if (crc == 0x460c7a7c || crc == 0x25bfd039 || + crc == AVE_FW_TEXT_CRC_T6022_6070) return &ave_layout_6070_11_1; /* * The macOS 27.0 build for the M5 Pro and Max, and the M5's build of the diff --git a/drivers/media/platform/apple/ave/tests/test.c b/drivers/media/platform/apple/ave/tests/test.c index 174015c58884b..03809e0f883e6 100644 --- a/drivers/media/platform/apple/ave/tests/test.c +++ b/drivers/media/platform/apple/ave/tests/test.c @@ -66,6 +66,16 @@ static void facts(void) assert(!ave_layout_for_crc(0x2ce7359e)); assert(ave_layout_for_crc(0x69c54454) == &ave_layout_9003_78_0); assert(ave_fw_check_build(&dev) == -EOPNOTSUPP); + + /* The admitted M1 Max image stays probe-only. */ + dev.text_crc = AVE_FW_TEXT_CRC_T6001_6070; + dev.layout = ave_layout_for_crc(dev.text_crc); + assert(ave_fw_check_build(&dev) == -EOPNOTSUPP); + assert(ave_fw_check_boot(&dev) == -EOPNOTSUPP); + dev.text_crc = 0x460c7a7c; + dev.layout = ave_layout_for_crc(dev.text_crc); + assert(ave_fw_check_build(&dev) == 0); + dev.text_crc = 0x69c54454; assert(ave_fw_check_build(&dev) == -EOPNOTSUPP); dev.layout = ave_layout_for_crc(dev.text_crc);