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
9 changes: 6 additions & 3 deletions src/kboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ static int dt_set_t8140_wfx_args(int node)
* changes: every check behind it (board, firmware, identity, reservations, PMP values, resources)
* still runs, and a failed check still leaves the boot framebuffer and a disabled GPU node.
*
* The Air switches are the recipe the boot package wrote on these Macs: the display handoff
* The Air switches, which the J504 (the 14" M3 MacBook Pro, the same T8122 and the same 14.x
* DCP and GPU images) shares, are the recipe the boot package wrote on these Macs: the display handoff
* (which also passes the PMP values), the GPU, and the stand-in power model with this Mac's
* leakage fuse. It wrote the GPU lines only beside a display line of 1, so an owner's
* chosen.asahi,t8122-dcp=0 keeps the default GPU switches off as well; an owner's own GPU line
Expand All @@ -403,7 +404,8 @@ struct m3_default_board {
const char *const *graphics;
};

static const char *const m3_air_boards[] = {"apple,j613", "apple,j615", NULL};
/* The M3 MacBook Airs (J613, J615) and the 14" M3 MacBook Pro (J504): one T8122 recipe. */
static const char *const m3_air_boards[] = {"apple,j613", "apple,j615", "apple,j504", NULL};
static const char *const m3_air_switches[] = {
"asahi,t8122-dcp", "asahi,t8122-gpu", "asahi,t8122-gpu-power-standin",
"asahi,t8122-gpu-fuse-leakage", NULL};
Expand Down Expand Up @@ -5597,7 +5599,8 @@ static int dt_set_pmp_t8122(void)

if (!opt || len != 2 || opt[0] != '1' || opt[1] != '\0' ||
(fdt_node_check_compatible(dt, 0, "apple,j613") &&
fdt_node_check_compatible(dt, 0, "apple,j615")))
fdt_node_check_compatible(dt, 0, "apple,j615") &&
fdt_node_check_compatible(dt, 0, "apple,j504")))
return 0;
dt_pass_pmp(&pmp_values_t8122);
return 0;
Expand Down
7 changes: 4 additions & 3 deletions src/kboot_display_handoff.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,20 +265,21 @@ static const struct dcp_soc dcp_soc_t6030 = {
};

/*
* T8122 (M3 MacBook Air J613/J615). Addresses, segments, DART windows and the display power state
* T8122 (M3 MacBook Air J613/J615, 14" M3 MacBook Pro J504; the J504 runs the same DCP image,
* DCP8_UUID). Addresses, segments, DART windows and the display power state
* come from the ADT. pmgr_disp_cpu is ps_disp_cpu of the open T8122 PMGR device tree (pmgr
* 0x2d0700000, state 0x10000); it is only compared with the ADT's, for the device tree. The DCP
* image iBoot leaves running is pinned (DCP8_UUID), so the generalised handoff publishes when
* armed and every check passes; otherwise it publishes nothing and the Mac keeps the framebuffer.
*/
static const char *const dcp_boards_t8122[] = {"apple,j613", "apple,j615", NULL};
static const char *const dcp_boards_t8122[] = {"apple,j613", "apple,j615", "apple,j504", NULL};

static const struct dcp_soc dcp_soc_t8122 = {
.name = "T8122",
.chip = T8122,
.compat = "apple,t8122",
.boards = dcp_boards_t8122,
.boards_desc = "J613/J615",
.boards_desc = "J613/J615/J504",
.dcp_compat = "apple,t8122-dcp",
.disp_compat = "apple,t8122-display-subsystem",
.marker = "apple,t8122-handoff",
Expand Down
5 changes: 3 additions & 2 deletions src/kboot_gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2495,7 +2495,7 @@ static int dt_set_gpu_g15(void *dt, const struct g15_soc *soc)
static int dt_set_gpu_t8122(void *dt);

/*
* On a J613 or J615, read the same T8122 leakage fuse words under the
* On a J613, J615 or J504, read the same T8122 leakage fuse words under the
* exception guard, before anything powers the GPU, then log and export the decoded values (see
* t8122_leak_fuse_decode()). It changes nothing else: the GPU setup uses them only with
* chosen.asahi,t8122-gpu-fuse-leakage=1. A fault or a full device tree is logged, and the boot
Expand All @@ -2506,7 +2506,8 @@ static void t8122_leak_fuse_export(void *dt)
t8122_fuse_valid = false;
t8122_fuse_use = g15_optin(dt, T8122_LEAK_FUSE_OPTIN);
if (chip_id != T8122 || (fdt_node_check_compatible(dt, 0, "apple,j613") &&
fdt_node_check_compatible(dt, 0, "apple,j615")))
fdt_node_check_compatible(dt, 0, "apple,j615") &&
fdt_node_check_compatible(dt, 0, "apple,j504")))
return;

int before = g15_guard_begin();
Expand Down
3 changes: 2 additions & 1 deletion src/kboot_gpu_t8122_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ int t8122_full_identity_prepare(void *dt)
int len = 0;
const char *armed = chosen < 0 ? NULL : fdt_getprop(dt, chosen, "asahi,t8122-gpu", &len);
if ((fdt_node_check_compatible(dt, 0, "apple,j613") &&
fdt_node_check_compatible(dt, 0, "apple,j615")) ||
fdt_node_check_compatible(dt, 0, "apple,j615") &&
fdt_node_check_compatible(dt, 0, "apple,j504")) ||
fdt_node_check_compatible(dt, 0, "apple,t8122") || !armed || len != 2 || armed[0] != '1' ||
armed[1] != '\0')
return -1;
Expand Down
7 changes: 4 additions & 3 deletions src/kboot_pmp_t8122.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
* Nothing is written to the hardware. SRAM is read with aligned 32-bit loads and the PTD with
* aligned 64-bit loads, under an exception guard, and only after every PMGR power state of the
* /arm-io/pmp clock-gates read as actually on. The PTD update page is never accessed. After a
* guarded fault, or once the node cannot be published, nothing more is read. Only on a J613
* with chosen.asahi,t8122-dcp=1; the caller selects T8122. Each node is built on a copy of the
* guarded fault, or once the node cannot be published, nothing more is read. Only on a J613,
* J615 or J504 with chosen.asahi,t8122-dcp=1; the caller selects T8122. Each node is built on a copy of the
* FDT and published only if complete. Failure is non-fatal to kboot, and an existing node is
* never replaced.
*/
Expand Down Expand Up @@ -305,7 +305,8 @@ static bool facts_wanted(void *dt)
return opt && len == 2 && opt[0] == '1' && opt[1] == '\0' &&
!fdt_node_check_compatible(dt, 0, "apple,t8122") &&
(!fdt_node_check_compatible(dt, 0, "apple,j613") ||
!fdt_node_check_compatible(dt, 0, "apple,j615"));
!fdt_node_check_compatible(dt, 0, "apple,j615") ||
!fdt_node_check_compatible(dt, 0, "apple,j504"));
}

/* ---- asahi,t8122-pmp-facts ---- */
Expand Down
18 changes: 18 additions & 0 deletions tests/kboot_gpu_g15_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -1670,6 +1670,23 @@ static void t8122_fuse_not_j613(void)
assert(!trace_len && !mmio_reads && !log_has("leakage fuse"));
}

/* The J504 (14" M3 MacBook Pro) reads and exports the same fuse; a J433 (M3 iMac) root does not */
static void t8122_j504_fuse_export(void)
{
prepare_fuse(0, 0xa0000000, 0x000aaaaa, 0);
CHK(fdt_setprop_string(dtbuf, 0, "compatible", "apple,j504"));
run();
expect_fuse_prop(10924, 342);
assert(!strcmp(trace_buf, "read32 0x2e42c8128\nread32 0x2e42c812c\n"));
assert(mmio_reads == 2 && !pmgr_enables && !exc_count && !unguarded_faults);

prepare_fuse(0, 0xa0000000, 0x000aaaaa, 0);
CHK(fdt_setprop_string(dtbuf, 0, "compatible", "apple,j433"));
run();
assert(prop_len(dtbuf, "/chosen", "asahi,t8122-gpu-leak-fuse") < 0);
assert(!trace_len && !mmio_reads && !log_has("leakage fuse"));
}

static void t8122_j613_fuse_fault(void)
{
/* A faulting read is caught, logged, and the boot goes on without the property */
Expand Down Expand Up @@ -2037,6 +2054,7 @@ static const struct {
{"t8122-fuse-decode", t8122_fuse_decode},
{"t8122-j613-fuse-export", t8122_j613_fuse_export},
{"t8122-fuse-not-j613", t8122_fuse_not_j613},
{"t8122-j504-fuse-export", t8122_j504_fuse_export},
{"t8122-j613-fuse-fault", t8122_j613_fuse_fault},
{"t8122-j613-standin-fuse-off", t8122_j613_standin_fuse_off},
{"t8122-j613-standin-fuse-on", t8122_j613_standin_fuse_on},
Expand Down
21 changes: 13 additions & 8 deletions tests/python/test_m3_defaults_optout.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
BOARDS = {
"j613": ("J613", "apple,j613;apple,t8122;apple,arm-platform"),
"j615": ("J615", "apple,j615;apple,t8122;apple,arm-platform"),
"j504": ("J504", "apple,j504;apple,t8122;apple,arm-platform"),
"j433": ("J433", "apple,j433;apple,t8122;apple,arm-platform"),
"j514s": ("J514S", "apple,j514s;apple,t6030;apple,arm-platform"),
"j516s": ("J516S", "apple,j516s;apple,t6030;apple,arm-platform"),
"j516c": ("J516C", "apple,j516c;apple,t6031;apple,arm-platform"),
Expand All @@ -37,10 +39,11 @@
"j516m": ("J516M", "apple,j516m;apple,t6034;apple,arm-platform"),
"j293": ("J293", "apple,j293;apple,t8103;apple,arm-platform"),
}
CHIP = {"j613": "8122", "j615": "8122", "j514s": "6030", "j516s": "6030", "j516c": "6031",
CHIP = {"j613": "8122", "j615": "8122", "j504": "8122", "j433": "8122", "j514s": "6030", "j516s": "6030", "j516c": "6031",
"j514c": "6031", "j514m": "6034", "j516m": "6034", "j293": "8103"}
FAMILY = {"j613": ("asahi,t8122-", "asahi,j613-", "asahi,j615-"),
"j615": ("asahi,t8122-", "asahi,j613-", "asahi,j615-"),
"j504": ("asahi,t8122-", "asahi,j613-", "asahi,j615-"),
"j514s": ("asahi,t6030-",),
"j516s": ("asahi,t6030-",),
"j516c": ("asahi,t6031-",)}
Expand Down Expand Up @@ -415,7 +418,7 @@ def graphics_off(r, board="j613"):
assert r.rc == 0 and r.booted, r.stdout
for name in r.chosen:
assert not name.startswith(FAMILY[board]), (name, r.stdout)
if board in ("j613", "j615"):
if board in ("j613", "j615", "j504"):
assert r.select == "reservation-only", r.stdout
if board == "j516c": # no image read, no identity probe, GPU node disabled
assert r.select == "t6031-disabled" and not r.probes, r.stdout
Expand All @@ -427,9 +430,10 @@ def booted(r):

# ---- a complete config: unchanged ----

@pytest.mark.parametrize("board", ["j613", "j615", "j504"])
@pytest.mark.parametrize("build", STAGE2)
def test_no_config_gets_the_whole_air_recipe(tools, build):
b = boot(tools, build, b"")
def test_no_config_gets_the_whole_air_recipe(tools, build, board):
b = boot(tools, build, b"", board=board)
booted(b)
assert set(AIR) <= b.armed and b.select == "g15-standin"

Expand Down Expand Up @@ -495,15 +499,15 @@ def test_j516c_owner_lines_are_kept(tools, build, config, lines, select):
assert b.armed & {MAX_DCP, MAX_GPU} == {k for k, v in lines.items() if v == "1"}


@pytest.mark.parametrize("board", ["j514c", "j514m", "j516m", "j293"])
@pytest.mark.parametrize("board", ["j514c", "j514m", "j516m", "j293", "j433"])
@pytest.mark.parametrize("build", STAGE2)
def test_other_maxes_and_macs_get_no_default(tools, build, board):
b = boot(tools, build, b"", board=board)
booted(b)
assert not any(n.startswith(M3_LINES) for n in b.chosen), b.stdout
assert not b.probes
# the J514C reaches the T6031 entry, which needs its line as before; T6034 has no GPU path
assert b.select == ("t6031-disabled" if board == "j514c" else "none")
assert b.select == {"j514c": "t6031-disabled", "j433": "reservation-only"}.get(board, "none")


@pytest.mark.parametrize("config,lines", [
Expand Down Expand Up @@ -579,10 +583,11 @@ def test_literal_display_zero_is_the_framebuffer_setting(tools, build):
}


@pytest.mark.parametrize("board", ["j613", "j504"])
@pytest.mark.parametrize("loss", sorted(LOSSES))
@pytest.mark.parametrize("build", STAGE2)
def test_a_lost_line_keeps_air_graphics_off_and_boots(tools, build, loss):
graphics_off(boot(tools, build, LOSSES[loss](build)))
def test_a_lost_line_keeps_air_graphics_off_and_boots(tools, build, loss, board):
graphics_off(boot(tools, build, LOSSES[loss](build), board=board), board=board)


@pytest.mark.parametrize("build", STAGE2)
Expand Down
6 changes: 6 additions & 0 deletions tests/python/test_m3_graphics_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def harness():
#define N(a) ((int)(sizeof(a) / sizeof((a)[0])))
#define J613 "apple,j613\0apple,t8122\0apple,arm-platform"
#define J615 "apple,j615\0apple,t8122\0apple,arm-platform"
#define J504 "apple,j504\0apple,t8122\0apple,arm-platform"
#define J433 "apple,j433\0apple,t8122\0apple,arm-platform"
#define J514S "apple,j514s\0apple,t6030\0apple,arm-platform"
#define J516S "apple,j516s\0apple,t6030\0apple,arm-platform"
#define J516C "apple,j516c\0apple,t6031\0apple,arm-platform"
Expand Down Expand Up @@ -154,6 +156,7 @@ def harness():
/* the five boards get their own recipe and nothing else */
RESET(J613); assert(!run()); expect_only(air, 4);
RESET(J615); assert(!run()); expect_only(air, 4);
RESET(J504); assert(!run()); expect_only(air, 4);
RESET(J516S); assert(!run()); expect_only(pro, 2);
RESET(J514S); assert(!run()); expect_only(pro, 2);
RESET(J516C); assert(!run()); expect_only(max, 2);
Expand All @@ -164,6 +167,9 @@ def harness():
board without its SoC, M1/M2: untouched */
UNTOUCHED(J514C);
UNTOUCHED(J514M);
UNTOUCHED(J433);
UNTOUCHED("apple,j504\0apple,arm-platform");
UNTOUCHED("apple,j504\0apple,t6030\0apple,arm-platform");
UNTOUCHED(J516M);
UNTOUCHED("apple,j516c\0apple,t6034\0apple,arm-platform");
UNTOUCHED("apple,j516c\0apple,arm-platform");
Expand Down
31 changes: 31 additions & 0 deletions tests/run-t8122-display-handoff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ ${DTC:-dtc} -q -I dts -O dtb -o "$tmp/fixture.dtb" "$root/tests/t8122-j613-displ
dtbs="$tmp/fixture.dtb"
[ -n "${J613_DTB:-}" ] && dtbs="$dtbs $J613_DTB"

# The J504 (14" M3 MacBook Pro) runs the same DCP image: the same scenarios on the fixture with
# its root. The J433 (an M3 iMac, also T8122) is outside the board list: armed, nothing is published.
sed '14s/"apple,j613"/"apple,j504"/' "$root/tests/t8122-j613-display.dts" > "$tmp/j504.dts"
sed '14s/"apple,j613"/"apple,j433"/' "$root/tests/t8122-j613-display.dts" > "$tmp/j433.dts"
grep -q '"apple,j504", "apple,t8122"' "$tmp/j504.dts" && grep -q '"apple,j433", "apple,t8122"' "$tmp/j433.dts"
${DTC:-dtc} -q -I dts -O dtb -o "$tmp/j504.dtb" "$tmp/j504.dts"
${DTC:-dtc} -q -I dts -O dtb -o "$tmp/j433.dtb" "$tmp/j433.dts"

fail=0
extra=""
[ -n "${J613_25G83:-}" ] && extra="missing-clock wrong-os missing-profile"
Expand All @@ -48,5 +56,28 @@ for dtb in $dtbs; do
fi
done
done
if [ -z "${J613_25G83:-}" ]; then
echo "### j504.dtb"
for s in unarmed publish repeat wrong-image not-running outside-segment power-off \
contract-selftest; do
if ! T8122_BOARD=apple,j504 "$tmp/t8122-display-host" "$tmp/j504.dtb" "$s" \
> "$tmp/j504-$s.log" 2>&1; then
fail=1
cat "$tmp/j504-$s.log"
else
tail -n 1 "$tmp/j504-$s.log" | sed "s/^/j504 $s: /"
fi
done
echo "### j433.dtb"
for s in unarmed other-board; do
if ! T8122_BOARD=apple,j433 "$tmp/t8122-display-host" "$tmp/j433.dtb" "$s" \
> "$tmp/j433-$s.log" 2>&1; then
fail=1
cat "$tmp/j433-$s.log"
else
tail -n 1 "$tmp/j433-$s.log" | sed "s/^/j433 $s: /"
fi
done
fi
[ $fail = 0 ] && echo "T8122 display handoff: every scenario passes"
exit $fail
12 changes: 8 additions & 4 deletions tests/t8122_air_pmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ static void setup(char *tree, const char *board, bool armed)
}
int main(void)
{
char tree[4096]; const char *boards[] = {"apple,j613", "apple,j615"};
for (unsigned b = 0; b < 2; b++) {
char tree[4096]; const char *boards[] = {"apple,j613", "apple,j615", "apple,j504"};
for (unsigned b = 0; b < 3; b++) {
setup(tree, boards[b], true); board_value = 0x40 + b;
assert(facts_wanted(dt)); assert(!dt_set_pmp_t8122()); assert(fills == 1);
int node = fdt_path_offset(dt, "/chosen/asahi,t8122-pmp"); assert(node >= 0);
Expand All @@ -62,10 +62,14 @@ int main(void)
node = fdt_path_offset(dt, "/chosen/asahi,t8122-pmp"); assert(node >= 0);
assert(!fdt_getprop(dt, node, "apple,board-id", NULL));
}
setup(tree, "apple,j504", true); assert(!facts_wanted(dt));
/* Other base-M3 boards (the J433/J434 iMacs) stay refused. */
setup(tree, "apple,j433", true); assert(!facts_wanted(dt));
assert(!dt_set_pmp_t8122() && !fills);
setup(tree, "apple,j504", true);
assert(!fdt_setprop_string(dt, 0, "compatible", "apple,j504"));
assert(!facts_wanted(dt)); assert(!dt_set_pmp_t8122() && !fills);
setup(tree, "apple,j615", true);
assert(!fdt_setprop_string(dt, 0, "compatible", "apple,j615"));
assert(!facts_wanted(dt)); assert(!dt_set_pmp_t8122() && !fills);
puts("actual Air PMP admission/callers: both boards, explicit intent, own data and resource refusal PASS");
puts("actual Air PMP admission/callers: J613/J615/J504, explicit intent, own data and resource refusal PASS");
}
9 changes: 7 additions & 2 deletions tests/t8122_display_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,8 +824,9 @@ static int contract_check(const void *dt)
status_is(dt, mbox, "disabled"),
"gate: dcp, display, both DARTs and the mailbox are still disabled");

/* drm/apple, 14.x IOMFB, J613 board */
check(!fdt_node_check_compatible(dt, 0, "apple,j613"), "drm: the root is apple,j613");
/* drm/apple, 14.x IOMFB, the fixture's board (J613 unless T8122_BOARD names another) */
const char *board = getenv("T8122_BOARD") ? getenv("T8122_BOARD") : "apple,j613";
check(!fdt_node_check_compatible(dt, 0, board), "drm: the root is %s", board);
const char *uuid = fdt_getprop(dt, dcp, "apple,firmware-uuid", NULL);
check(uuid && !strcmp(uuid, J613_UUID), "drm: dcp apple,firmware-uuid is %s", J613_UUID);
int len;
Expand Down Expand Up @@ -1002,6 +1003,10 @@ int main(int argc, char **argv)
} else if (!strcmp(sc, "power-off")) {
o.armed = o.power_off = true;
publish = false;
} else if (!strcmp(sc, "other-board")) {
/* armed on a T8122 board outside dcp_boards_t8122 (the fixture's root says which) */
o.armed = true;
publish = false;
} else if (!strcmp(sc, "missing-clock") || !strcmp(sc, "wrong-os") ||
!strcmp(sc, "missing-profile")) {
o.armed = true;
Expand Down
29 changes: 29 additions & 0 deletions tests/t8122_full_identity.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ static void tree(void *dt, int size, const char *compatible, const char *intent)
} else if (!strcmp(compatible, "apple,j615")) {
static const char compat[] = "apple,j615\0apple,t8122";
assert(!fdt_setprop(dt, 0, "compatible", compat, sizeof(compat)));
} else if (!strcmp(compatible, "apple,j504")) {
static const char compat[] = "apple,j504\0apple,t8122";
assert(!fdt_setprop(dt, 0, "compatible", compat, sizeof(compat)));
}
int chosen = fdt_add_subnode(dt, 0, "chosen");
assert(chosen >= 0);
Expand Down Expand Up @@ -121,6 +124,32 @@ int main(int argc, char **argv)
assert(!fdt_setprop_string(dt, 0, "compatible", "apple,j615"));
assert(t8122_full_identity_prepare(dt) < 0); /* Exact chip is mandatory. */

/* The 14-inch M3 MacBook Pro (J504) takes the same path with its own measured mask. */
for (unsigned i = 0; i < sizeof(j615_masks) / sizeof(j615_masks[0]); i++) {
struct fixture f = supported;
f.raw.core_mask[0] = j615_masks[i];
tree(dt, sizeof(dt), "apple,j504", "1");
assert(t8122_full_identity_prepare(dt) >= 0);
assert(property(dt, "probe-result") == T8122_ID_NOT_RUN);
struct t8122_powered_identity identity;
assert(!t8122_full_identity_read(read_identity, &f, &identity));
assert(!t8122_full_identity_publish(dt, &identity));
check_fields(dt, &f.raw);
t8122_full_identity_invalidate(dt);
}
for (unsigned i = 0; i < sizeof(intents) / sizeof(intents[0]); i++) {
tree(dt, sizeof(dt), "apple,j504", intents[i]);
assert(t8122_full_identity_prepare(dt) < 0);
}
tree(dt, sizeof(dt), "apple,j504", "1");
assert(!fdt_setprop_string(dt, 0, "compatible", "apple,j504"));
assert(t8122_full_identity_prepare(dt) < 0); /* Exact chip is mandatory. */
/* Other base-M3 boards (the J433/J434 iMacs) stay refused. */
tree(dt, sizeof(dt), "apple,j433", "1");
static const char j433[] = "apple,j433\0apple,t8122";
assert(!fdt_setprop(dt, 0, "compatible", j433, sizeof(j433)));
assert(t8122_full_identity_prepare(dt) < 0);

const u32 masks[] = {0x3ff, 0x37e, 0xff};
for (unsigned i = 0; i < sizeof(masks) / sizeof(masks[0]); i++) {
struct fixture f = supported;
Expand Down
Loading