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
17 changes: 10 additions & 7 deletions src/kboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -10811,19 +10811,22 @@ static int dt_set_j713_isp_one(unsigned int unused)
}

/*
* Only a disabled ISP with the placeholders is a handoff target. A tree without them (no camera,
* or a kernel that reserves the firmware itself and enables the ISP) is left as it is. A refused
* handoff leaves the camera disabled; the boot goes on.
* Only a disabled ISP with the placeholders is a handoff target, on any T8132 machine: the tree
* asks for the handoff by describing the ISP disabled with isp-firmware-text, isp-firmware-data
* and the isp-heap window, as t8132-isp.dtsi does for every T8132 laptop. A tree without them (no
* camera, or a kernel that reserves the firmware itself and enables the ISP) is left as it is. A
* refused handoff leaves the camera disabled; the boot goes on.
*/
static void dt_set_j713_isp(void)
{
if (chip_id != T8132 || (fdt_node_check_compatible(dt, 0, "apple,j713") &&
fdt_node_check_compatible(dt, 0, "apple,j604")))
return; /* No other M4 board's camera handoff is qualified. */
if (chip_id != T8132)
return;
int isp = fdt_node_offset_by_compatible(dt, -1, "apple,t8132-isp");
const char *status = isp < 0 ? NULL : fdt_getprop(dt, isp, "status", NULL);
if (!status || strcmp(status, "disabled") ||
fdt_path_offset(dt, "/reserved-memory/isp-firmware-text") < 0)
fdt_path_offset(dt, "/reserved-memory/isp-firmware-text") < 0 ||
fdt_path_offset(dt, "/reserved-memory/isp-firmware-data") < 0 ||
fdt_path_offset(dt, "/reserved-memory/isp-heap") < 0)
return;
if (dt_display_transaction(dt_set_j713_isp_one, 0))
printf("FDT: J713 ISP handoff refused; keeping the camera disabled\n");
Expand Down
26 changes: 23 additions & 3 deletions tests/python/test_j713_isp_handoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ def function(name, kind="static int "):
dtb = tmp_path / "j713.dtb"
subprocess.run(["dtc", "-q", "-I", "dts", "-O", "dtb", "-o", str(dtb), "-"],
input=TREE, text=True, check=True)
run_c(tmp_path, "j713-isp-handoff", '#define DTB_PATH "%s"\n' % dtb + r'''
# The J715 (15-inch M4 Air) carries the same camera description; only the board differs.
dtb_j715 = tmp_path / "j715.dtb"
subprocess.run(["dtc", "-q", "-I", "dts", "-O", "dtb", "-o", str(dtb_j715), "-"],
input=TREE.replace('"apple,j713"', '"apple,j715"'), text=True, check=True)
run_c(tmp_path, "j713-isp-handoff", '#define DTB_PATH "%s"\n' % dtb +
'#define DTB_J715_PATH "%s"\n' % dtb_j715 + r'''
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
Expand Down Expand Up @@ -204,6 +209,17 @@ def function(name, kind="static int "):
assert(heap && len == 20 && fdt32_ld(heap + 4) == 0x1400000);
assert(!fdt_getprop(dt, fdt_path_offset(dt, "/reserved-memory/isp-heap"), "reg", NULL));

/* The tree decides, not the board: a J715 tree with the same description is handed over. */
world(DTB_J715_PATH);
dt_set_j713_isp();
check_region("/reserved-memory/isp-firmware-text", 0x10000d30000ULL, 0x10000000000ULL,
0xca4000);
check_region("/reserved-memory/isp-firmware-data", 0x10001f40000ULL, 0x10000ca4000ULL,
0x748000);
assert(!strcmp(status("/soc/isp@48c000000"), "okay"));
for (int i = 0; i < 3; i++)
assert(!strcmp(status(darts[i]), "okay"));

/*
* 27.2 (26B123) on this J713: DATA ends at 0x1aec000, past the tree's 20 MiB window. The
* window grows to the next 2 MiB boundary (28 MiB) and the ISP is handed over.
Expand Down Expand Up @@ -283,14 +299,18 @@ def function(name, kind="static int "):
}

/* Trees that are not handoff targets are left alone: an enabled ISP (a kernel that
* reserves its own firmware), no placeholders, another machine. */
for (fault = 20; fault <= 22; fault++) {
* reserves its own firmware), a missing placeholder or heap window, another SoC. */
for (fault = 20; fault <= 24; fault++) {
world(DTB_PATH);
int isp = fdt_path_offset(dt, "/soc/isp@48c000000");
if (fault == 20) assert(!fdt_setprop_string(dt, isp, "status", "okay"));
if (fault == 21)
assert(!fdt_del_node(dt, fdt_path_offset(dt, "/reserved-memory/isp-firmware-text")));
if (fault == 22) chip_id = 0x8122;
if (fault == 23)
assert(!fdt_del_node(dt, fdt_path_offset(dt, "/reserved-memory/isp-firmware-data")));
if (fault == 24)
assert(!fdt_del_node(dt, fdt_path_offset(dt, "/reserved-memory/isp-heap")));
memcpy(original, blob, sizeof(blob));
dt_set_j713_isp();
assert(!memcmp(original, blob, sizeof(blob)));
Expand Down
Loading