Skip to content
Merged
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
2 changes: 2 additions & 0 deletions src/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ const struct fw_version_info fw_versions[NUM_FW_VERSIONS] = {
// Same iBoot string as 27.0: detect_firmware() always picks V27_0. Verified from the J575D
// (M3 Ultra) 27.0.1 iBoot (26A434): both report "mBoot-20457.1.29", so no V27_0_1 exists.
[V27_0] = {V27_0, "27.0", {27, 0, 0}, 3, "mBoot-20457.1.29"},
// macOS 27.2 (26B123), read from a J813 stub booted by it (system and OS iBoot alike).
[V27_2] = {V27_2, "27.2", {27, 2, 0}, 3, "mBoot-20457.41.3"},
// clang-format on
};

Expand Down
1 change: 1 addition & 0 deletions src/firmware.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ enum fw_version {
V26_7,
V26_7_1,
V27_0,
V27_2,
NUM_FW_VERSIONS,
};

Expand Down
4 changes: 2 additions & 2 deletions src/isp.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,10 @@ int isp_init(void)
/* The J813 revision is not known yet; it is printed above. */
/*
* 27.0's ISP firmware moves the __TEXT/__DATA split but still ends at ISP_T8142_SEG_END
* (J813 ADTs of both), which the segment check below still verifies.
* (J813 ADTs of both), which the segment check below still verifies. So does 27.2's.
*/
if (os_firmware.version != V26_6 && os_firmware.version != V26_6_2 &&
os_firmware.version != V27_0) {
os_firmware.version != V27_0 && os_firmware.version != V27_2) {
reason = "unsupported T8142 firmware";
goto out;
}
Expand Down
40 changes: 39 additions & 1 deletion src/kboot_gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3099,6 +3099,43 @@ static int g17_set_fw_data(void *dt, int sgx, const u64 data_base[2], const u64
return 0;
}

/*
* iBoot loads the primary's and the secondary's __TEXT back to back (gfx-asc and gfx1-asc
* segment-ranges, __TEXT first), at an address that depends on the macOS release (27.0 and 27.2
* differ by 64 KiB on T8142). A DT with a /reserved-memory/fw-text node, which Linux uses to
* identify the firmware build before it starts it, gets the span iBoot used. TEXT placed apart
* leaves the node as the DT has it.
*/
static int g17_set_fw_text(void *dt)
{
static const char *const asc[2] = {"/arm-io/gfx-asc", "/arm-io/gfx1-asc"};
static const char path[] = "/reserved-memory/fw-text";
u64 text_base[2], text_size[2];

if (fdt_path_offset(dt, path) < 0)
return 0;
for (int i = 0; i < 2; i++) {
int node = adt_path_offset(adt, asc[i]);
if (node < 0)
return 0;
u32 len = 0;
const struct adt_segment_ranges *seg = adt_getprop(adt, node, "segment-ranges", &len);
const char *names = adt_getprop(adt, node, "segment-names", NULL);
if (!seg || len < sizeof(*seg) || !names || strncmp(names, "__TEXT;", 7))
return 0;
text_base[i] = seg[0].phys;
text_size[i] = seg[0].size;
if (!text_base[i] || !text_size[i] || (text_base[i] & (SZ_16K - 1)) ||
(text_size[i] & (SZ_16K - 1)))
return 0;
}
if (text_base[0] + text_size[0] != text_base[1]) {
printf("FDT: GPU: firmware text segments are not contiguous, leaving %s\n", path);
return 0;
}
return dt_set_resvmem(dt, path, text_base[0], text_size[0] + text_size[1]);
}

static int dt_set_gpu_g17(void *dt, const struct g17_soc *soc)
{
int gpu = fdt_path_offset(dt, "gpu");
Expand Down Expand Up @@ -3186,7 +3223,8 @@ static int dt_set_gpu_g17(void *dt, const struct g17_soc *soc)
goto disable;
/* gfx-data and gfx1-data are the last two regions. */
if (soc->firmware_data &&
g17_set_fw_data(dt, sgx, &base[ARRAY_SIZE(regions) - 2], &size[ARRAY_SIZE(regions) - 2]))
(g17_set_fw_data(dt, sgx, &base[ARRAY_SIZE(regions) - 2], &size[ARRAY_SIZE(regions) - 2]) ||
g17_set_fw_text(dt)))
goto disable;

if (soc->firmware_known) {
Expand Down
10 changes: 10 additions & 0 deletions tests/python/test_isp_heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#define V26_6 7
#define V26_6_2 6
#define V27_0 8
#define V27_2 9
#define PMGR_PS_ACTIVE 15
#define PMGR_PS_PWRGATE 0
#define SZ_16K 0x4000
Expand Down Expand Up @@ -279,6 +280,15 @@
assert(isp_get_heap(&phys, &iova, &size) == 0);
assert(iova == 0x16ec000 && size == 0x114000);
assert(dapf_calls == 1 && allocations == 1);

/* 27.2's firmware ends there too; the segment check is what admits it. */
reset(); chip_id = T8142;
os_firmware.version = V27_2; os_firmware.string = "27.2";
segments[0].size = 0xd68000;
segments[1].iova = 0xd68000; segments[1].size = 0x984000;
assert(isp_init() == 0);
assert(isp_get_heap(&phys, &iova, &size) == 0);
assert(iova == 0x16ec000 && size == 0x114000);
return 0;
}
"""
Expand Down
Loading