Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Documentation/admin-guide/media/apple-ave.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ 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. 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
Expand Down
3 changes: 3 additions & 0 deletions drivers/media/platform/apple/ave/abi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +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.

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
Expand Down
72 changes: 71 additions & 1 deletion drivers/media/platform/apple/ave/ave-abi-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1807,6 +1807,75 @@ static void ave_t6041_26b123_build(struct kunit *test)
&ave_layout_9003_78_0);
}

/*
* 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;
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);
/* 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);
KUNIT_EXPECT_PTR_EQ(test, ave_fw_select_build(&ave_t6000, 0x13c000, 0x134000),
ave_t6000.next_build);
KUNIT_EXPECT_PTR_EQ(test, ave_fw_select_build(&ave_t6000, 0xec000, 0x134000),
&ave_t6000);

/*
* Each build's sizes, never mixed or other ones. The two builds' sizes
* differ, so the probe wants each one's own CRC with them.
*/
KUNIT_EXPECT_TRUE(test, ave_fw_sizes_match(&ave_t6000, 0xd0000, 0x128000));
KUNIT_EXPECT_TRUE(test, ave_fw_sizes_match(&ave_t6000, 0xec000, 0x134000));
KUNIT_EXPECT_FALSE(test, ave_fw_sizes_match(&ave_t6000, 0xec000, 0x128000));
KUNIT_EXPECT_FALSE(test, ave_fw_sizes_match(&ave_t6000, 0xd0000, 0x134000));
KUNIT_EXPECT_FALSE(test, ave_fw_sizes_match(&ave_t6000, 0xf0000, 0x134000));
KUNIT_EXPECT_EQ(test, pro->text_crc, 0x460c7a7cU);
KUNIT_EXPECT_TRUE(test, ave_fw_known_crc(pro->text_crc));
KUNIT_EXPECT_TRUE(test, ave_fw_known_crc(max->text_crc));
KUNIT_EXPECT_FALSE(test, ave_fw_known_crc(max->text_crc ^ 1));

/*
* 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);

/* 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));
}

/*
* 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
Expand Down Expand Up @@ -2434,6 +2503,7 @@ static struct kunit_case ave_abi_cases[] = {
KUNIT_CASE(ave_t8112_26b123_build),
KUNIT_CASE(ave_t8132_25g83_build),
KUNIT_CASE(ave_t6041_26b123_build),
KUNIT_CASE(ave_t6001_build),
KUNIT_CASE(ave_hevc_bframe_extra_bits),
KUNIT_CASE(ave_t8103_26b123_build),
KUNIT_CASE(ave_t8103_cpu_dart_filter),
Expand Down
20 changes: 17 additions & 3 deletions drivers/media/platform/apple/ave/ave-drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ 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 },
};

/*
* The M1 Pro/Max (T6000/T6001) with the macOS 27.2 (26B123) stub, as on the
* MacBook Pro (J316c): iBoot preloads shared TEXT 0x13c000 and per-engine
Expand Down Expand Up @@ -79,12 +94,11 @@ static const struct ave_variant ave_t6000_26b123 = {

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,
Expand Down
1 change: 1 addition & 0 deletions drivers/media/platform/apple/ave/ave-fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,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 */
AVE_FW_TEXT_CRC_T6022_6070, /* encoder firmware 6070.11.1 / T6022 */
};
Expand Down
7 changes: 7 additions & 0 deletions drivers/media/platform/apple/ave/ave.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ enum ave_opcode {
*/
#define AVE_FW_TEXT_CRC_T6022_6070 0xc74f7bcc

/*
* 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;

/* Register offsets for the shared 0x40 coprocessor architecture. */
Expand Down
10 changes: 10 additions & 0 deletions drivers/media/platform/apple/ave/tests/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading