From f7a02a63fb357a71e5f4af03a734881eeb49492d Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 23:01:17 +1100 Subject: [PATCH 1/4] kboot: M4 internal DCP on 27.2: publish its firmware clocks and the display maps On the macOS 27.2 stub the M4 MacBook Air's internal DCP runs the 26B123 image, which Linux drives through the firmware-27 backend. That backend needs the firmware clocks the OS gives the firmware (apple,clock-ids from /arm-io/disp0) and the display subsystem with its inherited SID0/SID16 mappings, which the M4 handoff published on 26.6.2 only. - dt_set_dcp_fw27_clocks() also serves a processor whose tree has no clocks at all (T8132), not only one with the single legacy display clock; it still does nothing below firmware 27. - dt_set_m4_dcp_handoff() publishes /arm-io/disp0's clocks that way. - The display-map walk runs on 27.2 as on 26.6.2. It checks every inherited page against this image's segments and publishes nothing unless all of them match, so a 27.2 image laid out differently keeps the display subsystem disabled as before. Signed-off-by: Ryan Murray --- src/kboot.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/kboot.c b/src/kboot.c index 1e8607c34..6b50275fd 100644 --- a/src/kboot.c +++ b/src/kboot.c @@ -7942,6 +7942,8 @@ static int dt_set_j713_display_maps(const struct adt_segment_ranges *segments, u return 0; } +static int dt_set_dcp_fw27_clocks(const char *alias, const char *adt_engine); + /* * Publish the inherited DCP firmware mapping without starting a display driver: on the J713 * on any firmware as before, and on any other M4 Mac with a panel on 26.6.2. @@ -8006,10 +8008,21 @@ static int dt_set_m4_dcp_handoff(void) if (ret) return ret; + /* + * Firmware 27 is given its clocks by the OS (/arm-io/disp0 clock-ids); without them it + * does not start, but the rest of the boot does. Nothing is published on 26.6.2. + */ + if (dt_set_dcp_fw27_clocks("dcp", "/arm-io/disp0")) + printf("FDT: M4 DCP firmware clocks not published\n"); + dcp_node = fdt_path_offset(dt, "dcp"); if (fdt_getprop(dt, dcp_node, "apple,j713-native-piodma", NULL)) { - /* The DCP image is per firmware, the same on every M4 Mac. */ - if (os_firmware.version != V26_6_2 || + /* + * The DCP image is per firmware, the same on every M4 Mac: 26.6.2 and the 27.2 stub. + * The walk checks every inherited SID0/SID16 page against this image's segments and + * publishes nothing unless all of them match. + */ + if ((os_firmware.version != V26_6_2 && os_firmware.version != V27_2) || dt_set_j713_display_maps(segments, count, dram_start, dram_size)) printf("FDT: M4 PIODMA handoff unqualified; retaining disabled device\n"); } @@ -8047,17 +8060,26 @@ static int dt_set_dcp_fw27_clocks(const char *alias, const char *adt_engine) return 0; } + /* + * A tree written for older firmware has the display clock alone; one written for a + * processor that only ever ran firmware-27-style interfaces (T8132) has no clocks at all. + */ int clen = 0; const fdt32_t *display = fdt_getprop(dt, node, "clocks", &clen); - if (!display || clen != sizeof(fdt32_t) || fdt_getprop(dt, node, "clock-names", NULL)) { + if ((display && clen != sizeof(fdt32_t)) || fdt_getprop(dt, node, "clock-names", NULL)) { printf("FDT: %s: unexpected clock properties; firmware clocks not published\n", alias); return 0; } fdt32_t clocks[9], ids[8]; char names[9 * 12]; - int names_len = snprintf(names, sizeof(names), "display") + 1; - clocks[0] = *display; + u32 first = 0; + int names_len = 0; + if (display) { + names_len = snprintf(names, sizeof(names), "display") + 1; + clocks[0] = *display; + first = 1; + } for (u32 i = 0; i < nclk; i++) { u32 id, hz; memcpy(&id, raw_ids + i * sizeof(u32), sizeof(id)); @@ -8086,7 +8108,7 @@ static int dt_set_dcp_fw27_clocks(const char *alias, const char *adt_engine) ret = ret ?: fdt_setprop_u32(dt, clk, "phandle", ph); if (ret) return ret; - clocks[i + 1] = cpu_to_fdt32(ph); + clocks[i + first] = cpu_to_fdt32(ph); ids[i] = cpu_to_fdt32(id); names_len += snprintf(names + names_len, sizeof(names) - names_len, "firmware-%u", i) + 1; } @@ -8094,7 +8116,7 @@ static int dt_set_dcp_fw27_clocks(const char *alias, const char *adt_engine) node = fdt_path_offset(dt, path); if (node < 0) return node; - int ret = fdt_setprop(dt, node, "clocks", clocks, (nclk + 1) * sizeof(*clocks)); + int ret = fdt_setprop(dt, node, "clocks", clocks, (nclk + first) * sizeof(*clocks)); node = fdt_path_offset(dt, path); ret = ret ?: fdt_setprop(dt, node, "clock-names", names, names_len); node = fdt_path_offset(dt, path); From bb3684bdea656f735535751fb94735ad15c429ff Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 23:28:16 +1100 Subject: [PATCH 2/4] tests: m4 dcp handoff: the J713 on the 27.2 stub Hand the J713 over on 27.2 with the 26B123 image: PIODMA, scanout and their inherited mappings as on 26.6.2, and /arm-io/disp0's firmware clocks (364 at 300 MHz, 431 at 0 Hz) as fixed clocks with clock-names firmware-0/1 and apple,clock-ids. A DART whose pages do not match the image's segments publishes no display mapping and keeps the firmware and its clocks. 26.x trees get no clocks; the other M4 Macs on 27.2 are still refused. Signed-off-by: Ryan Murray --- tests/python/test_m4_dcp_handoff.py | 63 +++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 7 deletions(-) diff --git a/tests/python/test_m4_dcp_handoff.py b/tests/python/test_m4_dcp_handoff.py index e910c43c6..b238a2e5d 100644 --- a/tests/python/test_m4_dcp_handoff.py +++ b/tests/python/test_m4_dcp_handoff.py @@ -23,6 +23,9 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): header = (ROOT / "src/adt.h").read_text() start = header.index("struct adt_segment_ranges {") layout = header[start:header.index("} PACKED;", start) + len("} PACKED;")] + # The clock publisher is declared ahead of the handoff; take its definition. + start = kboot.index("static int dt_set_dcp_fw27_clocks(const char *alias, const char *adt_engine)\n{") + clocks = kboot[start:kboot.index("\n}", start) + 2] + "\n" start = kboot.index("struct j713_display_maps {") maps = kboot[start:kboot.index("\n};", start) + 3] + "\n" production = ( @@ -31,7 +34,7 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): function(kboot, "dt_device_add_mem_region") + function(kboot, "dt_set_dcp_firmware") + function(kboot, "dt_reserve_asc_segments_at") + function(kboot, "dt_reserve_asc_segments") + function(kboot, "dt_reserve_asc_firmware") + maps + function(kboot, "j713_display_page") + function(kboot, "dt_set_j713_display_maps") + - function(kboot, "dt_set_m4_dcp_handoff")) + clocks + function(kboot, "dt_set_m4_dcp_handoff")) production = function(firmware, "firmware_set_fdt", "int ") + production assert not re.search(r"\bdt_set_j713_dcp_handoff\b", kboot) @@ -57,7 +60,7 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define bail(...) do { printf(__VA_ARGS__); return -1; } while (0) enum fw_version { V12_3, V12_3_1, V12_4, V13_5B4, V13_5, V13_6_1, V14_7, V26_5, V26_6, V26_6_2, - V27_0 }; + V27_0, V27_2 }; struct fw_version_info { enum fw_version version; const char *string; @@ -73,6 +76,7 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): [V26_6] = {V26_6, "26.6", {26, 6, 0}, 3, ""}, [V26_6_2] = {V26_6_2, "26.6.2", {26, 6, 2}, 3, ""}, [V27_0] = {V27_0, "27.0", {27, 0, 0}, 2, ""}, + [V27_2] = {V27_2, "27.2", {27, 2, 0}, 3, ""}, }; static struct fw_version_info os_firmware; ''' + layout + r''' @@ -126,13 +130,17 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): static struct board b; static u64 dram_base = 0x10000000000UL; +static const u32 disp0_clock_ids[] = {364, 431}; +static u32 clock_hz[200] = {[364 - 256] = 300000000, [431 - 256] = 0}; static const u32 one = 1; static int walks; +static u64 dart_skew; /* added to every inherited page's physical address */ static int adt_path_offset(void *tree, const char *path) { if (!strcmp(path, "/chosen")) return 1; if (!strcmp(path, "/arm-io/dcp/iop-dcp-nub")) return 2; if (!strcmp(path, "/arm-io/disp0")) return b.external < 0 ? -1 : 3; + if (!strcmp(path, "/arm-io")) return 4; return -1; } static const void *adt_getprop(void *tree, int node, const char *name, u32 *len) @@ -147,6 +155,9 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): } if (node == 2 && !strcmp(name, "uuid")) { *len = strlen(b.uuid) + 1; return b.uuid; } if (node == 3 && !strcmp(name, "external") && b.external > 0) { *len = 4; return &one; } + /* /arm-io/disp0 clock-ids index /arm-io clock-frequencies from 256 (every M4 ADT read). */ + if (node == 3 && !strcmp(name, "clock-ids")) { *len = sizeof(disp0_clock_ids); return disp0_clock_ids; } + if (node == 4 && !strcmp(name, "clock-frequencies")) { *len = sizeof(clock_hz); return clock_hz; } return NULL; } static int get_value(int node, const char *name, void *out, size_t capacity) @@ -174,7 +185,8 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): n++; if (!mapped) continue; for (u64 at = 0; at < ALIGN_UP((u64)b.segs[i].size, SZ_16K); at += SZ_16K) - if (visit((b.segs[i].remap & ((1UL << 36) - 1)) + at, b.segs[i].phys + at, opaque)) + if (visit((b.segs[i].remap & ((1UL << 36) - 1)) + at, b.segs[i].phys + at + dart_skew, + opaque)) return -1; } return 0; @@ -185,7 +197,7 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): static int phandle_of(const char *path) { return fdt_get_phandle(dt, fdt_path_offset(dt, path)); } static void world(const struct board *board, enum fw_version fw) { - b = *board; walks = 0; chip_id = T8132; + b = *board; walks = 0; dart_skew = 0; chip_id = T8132; os_firmware = fw_versions[fw]; dt = blob; memset(blob, 0, sizeof(blob)); @@ -285,7 +297,29 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): assert(!!fdt_getprop(dt, fdt_path_offset(dt, "disp0"), "apple,j713-inherited-mappings", NULL) == piodma); assert(!!fdt_getprop(dt, fdt_path_offset(dt, "disp0"), "memory-region", NULL) == piodma); - assert(walks == (b.native && os_firmware.version == V26_6_2 ? 2 : 0)); + assert(walks == (b.native && (os_firmware.version == V26_6_2 || + os_firmware.version == V27_2) ? 2 : 0)); + /* Firmware 27 is given /arm-io/disp0's clocks; 26.x trees are not touched. */ + const fdt32_t *ids = fdt_getprop(dt, dcp, "apple,clock-ids", &len); + if (os_firmware.version < V27_0) { + assert(!ids && !fdt_getprop(dt, dcp, "clocks", NULL) && + fdt_path_offset(dt, "/clock-dcp-firmware-364") < 0); + return; + } + assert(ids && len == 8 && fdt32_ld(&ids[0]) == 364 && fdt32_ld(&ids[1]) == 431); + const char *names = fdt_getprop(dt, dcp, "clock-names", &len); + assert(names && len == 22 && !memcmp(names, "firmware-0\0firmware-1\0", 22)); + const fdt32_t *clk = fdt_getprop(dt, dcp, "clocks", &len); + assert(clk && len == 8); + static const char *const clock_path[] = {"/clock-dcp-firmware-364", "/clock-dcp-firmware-431"}; + static const u32 rate[] = {300000000, 0}; + for (int i = 0; i < 2; i++) { + int node = fdt_path_offset(dt, clock_path[i]); + assert(node >= 0 && fdt32_ld(&clk[i]) == fdt_get_phandle(dt, node)); + assert(!fdt_node_check_compatible(dt, node, "fixed-clock")); + const fdt32_t *hz = fdt_getprop(dt, node, "clock-frequency", &len); + assert(hz && len == 4 && fdt32_ld(hz) == rate[i]); + } } static void handed_over(const struct board *board, enum fw_version fw, bool piodma) { @@ -316,6 +350,21 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): handed_over(&old, V26_5, false); handed_over(&old, V27_0, false); handed_over(&old, V26_6, false); + /* The 27.2 stub: the 26.6.2 path's PIODMA and scanout, plus the firmware-27 clocks. */ + struct board stub = j713; + stub.uuid = "B3BA603C-3CA7-3E21-B393-44EB20BD2AEF"; + handed_over(&stub, V27_2, true); + /* + * Inherited pages that do not match the image's segments: nothing of PIODMA or scanout is + * published (the walk stops at the first page), the DCP keeps its firmware and clocks. + */ + world(&stub, V27_2); + dart_skew = SZ_16K; + assert(!dt_set_m4_dcp_handoff()); + assert(walks == 1 && status_is("/soc/display-subsystem", "disabled") && + status_is("/soc/dcp@30ae00000/piodma", "disabled") && + status_is("/soc/iommu@30a300000", "disabled")); + assert(fdt_getprop(dt, fdt_path_offset(dt, "dcp"), "apple,clock-ids", NULL)); /* The J713's disp0 is never read. PIODMA follows the firmware version, not the image. */ old = j713; old.external = -1; handed_over(&old, V26_6, false); @@ -333,7 +382,7 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): handed_over(&imac, V26_6_2, false); /* Any other firmware: nothing, as before. */ - const enum fw_version others[] = {V26_5, V26_6, V27_0, V14_7}; + const enum fw_version others[] = {V26_5, V26_6, V27_0, V27_2, V14_7}; const struct board *panels[] = {&j604, &j715, &imac}; for (unsigned i = 0; i < ARRAY_SIZE(others); i++) for (unsigned k = 0; k < ARRAY_SIZE(panels); k++) { @@ -376,7 +425,7 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): ) result = subprocess.run([str(binary), str(tmp_path)], capture_output=True, text=True) assert result.returncode == 0, result.stdout + result.stderr - for name in ("j713-26.6.2", "j604-26.6.2", "j715-26.6.2", "j624-26.6.2", "j773g-26.6.2"): + for name in ("j713-27.2", "j713-26.6.2", "j604-26.6.2", "j715-26.6.2", "j624-26.6.2", "j773g-26.6.2"): assert (tmp_path / f"{name}.dtb").stat().st_size > 0 # The refusals say why. assert "no internal panel" in result.stdout From 72871702f3cc79decfc99a206efda98842eb1d0c Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 21 Nov 2026 17:39:02 +1100 Subject: [PATCH 3/4] kboot: M4 DCP on firmware 27: publish the clocks only with the display maps The kernel admits a T8132 DCP on the 27.2 image on apple,clock-ids. The clocks went out before the SID0/SID16 walk and whatever its result, so a J713 whose walk failed, or a firmware-27 version the walk does not run on, got the admission property without the inherited display maps: a DCP adopted without the mappings its DART needs. Run the walk first and publish the firmware clocks only when it succeeded. A failed walk now leaves the DCP with its firmware UUID and reserved segments but no clocks, and the kernel does not take it over. The success path is unchanged. The host test checks the failed walk publishes no apple,clock-ids, clocks or clock nodes, and that the older-image 27.0 case gets none. Signed-off-by: Ryan Murray --- src/kboot.c | 19 ++++++++++++------- tests/python/test_m4_dcp_handoff.py | 15 +++++++++++---- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/kboot.c b/src/kboot.c index 6b50275fd..a358d881e 100644 --- a/src/kboot.c +++ b/src/kboot.c @@ -8008,13 +8008,7 @@ static int dt_set_m4_dcp_handoff(void) if (ret) return ret; - /* - * Firmware 27 is given its clocks by the OS (/arm-io/disp0 clock-ids); without them it - * does not start, but the rest of the boot does. Nothing is published on 26.6.2. - */ - if (dt_set_dcp_fw27_clocks("dcp", "/arm-io/disp0")) - printf("FDT: M4 DCP firmware clocks not published\n"); - + bool maps = false; dcp_node = fdt_path_offset(dt, "dcp"); if (fdt_getprop(dt, dcp_node, "apple,j713-native-piodma", NULL)) { /* @@ -8025,8 +8019,19 @@ static int dt_set_m4_dcp_handoff(void) if ((os_firmware.version != V26_6_2 && os_firmware.version != V27_2) || dt_set_j713_display_maps(segments, count, dram_start, dram_size)) printf("FDT: M4 PIODMA handoff unqualified; retaining disabled device\n"); + else + maps = true; } + /* + * Firmware 27 is given its clocks by the OS (/arm-io/disp0 clock-ids); without them it + * does not start, but the rest of the boot does. Nothing is published on 26.6.2. + * The kernel admits a firmware-27 DCP on apple,clock-ids, so they go out only together + * with the inherited display maps: a DCP adopted without them faults on its DART. + */ + if (maps && dt_set_dcp_fw27_clocks("dcp", "/arm-io/disp0")) + printf("FDT: M4 DCP firmware clocks not published\n"); + printf("FDT: M4 DCP firmware mappings published; display device status unchanged\n"); return 0; } diff --git a/tests/python/test_m4_dcp_handoff.py b/tests/python/test_m4_dcp_handoff.py index b238a2e5d..0d7b03803 100644 --- a/tests/python/test_m4_dcp_handoff.py +++ b/tests/python/test_m4_dcp_handoff.py @@ -299,9 +299,12 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): assert(!!fdt_getprop(dt, fdt_path_offset(dt, "disp0"), "memory-region", NULL) == piodma); assert(walks == (b.native && (os_firmware.version == V26_6_2 || os_firmware.version == V27_2) ? 2 : 0)); - /* Firmware 27 is given /arm-io/disp0's clocks; 26.x trees are not touched. */ + /* + * Firmware 27 is given /arm-io/disp0's clocks, only with the inherited display maps (the + * kernel admits the DCP on apple,clock-ids); 26.x trees are not touched. + */ const fdt32_t *ids = fdt_getprop(dt, dcp, "apple,clock-ids", &len); - if (os_firmware.version < V27_0) { + if (os_firmware.version < V27_0 || !piodma) { assert(!ids && !fdt_getprop(dt, dcp, "clocks", NULL) && fdt_path_offset(dt, "/clock-dcp-firmware-364") < 0); return; @@ -356,7 +359,8 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): handed_over(&stub, V27_2, true); /* * Inherited pages that do not match the image's segments: nothing of PIODMA or scanout is - * published (the walk stops at the first page), the DCP keeps its firmware and clocks. + * published (the walk stops at the first page), and neither are the firmware clocks, so + * the kernel does not admit the DCP. It keeps its firmware. */ world(&stub, V27_2); dart_skew = SZ_16K; @@ -364,7 +368,10 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): assert(walks == 1 && status_is("/soc/display-subsystem", "disabled") && status_is("/soc/dcp@30ae00000/piodma", "disabled") && status_is("/soc/iommu@30a300000", "disabled")); - assert(fdt_getprop(dt, fdt_path_offset(dt, "dcp"), "apple,clock-ids", NULL)); + assert(!fdt_getprop(dt, fdt_path_offset(dt, "dcp"), "apple,clock-ids", NULL) && + !fdt_getprop(dt, fdt_path_offset(dt, "dcp"), "clocks", NULL) && + fdt_path_offset(dt, "/clock-dcp-firmware-364") < 0); + assert(fdt_getprop(dt, fdt_path_offset(dt, "dcp"), "apple,firmware-uuid", NULL)); /* The J713's disp0 is never read. PIODMA follows the firmware version, not the image. */ old = j713; old.external = -1; handed_over(&old, V26_6, false); From 189253d24165d9647755835610cda7e500fed4e6 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sun, 22 Nov 2026 04:47:42 +1100 Subject: [PATCH 4/4] kboot: M4 DCP handoff: decide the panel from the ADT, on any firmware dt_set_m4_dcp_handoff() handed the internal DCP over on the J713 on any firmware but on every other M4 Mac only on 26.6.2, and ran the inherited display-map walk only on 26.6.2 and the 27.2 stub. So the firmware-27 clocks and display maps reached the kernel on 27.2 for one board name, and an M4 MacBook Pro with the same DCP and the same image got nothing. Decide it from what the machine describes instead: - the internal panel from the ADT: /arm-io/disp0 present and not "external" (the rule the other boards already had). A Mac mini's disp0 drives a port and is still refused, on any firmware; - no firmware version list in front of the walk. It checks every inherited SID0/SID16 page against the segments of the image the DCP runs and publishes nothing unless all of them match, and the clocks still go out only together with the maps. The kernel then picks the backend from the firmware the DCP runs (apple,firmware-uuid/-compat). Nothing changes on the J713: its ADT has an internal disp0 and its inherited pages match on 26.6.2 and 27.2. The host test now runs the J604, J715 and an iMac-like board on every firmware, the J604 on 27.2 with the 27.2 image (maps + clocks), the Mac mini on 27.2 (refused), a J713 tree without disp0 (refused), and a skewed page on 26.6.2 (nothing published), and checks that the function names no board or firmware version. Signed-off-by: Ryan Murray --- src/kboot.c | 28 +++++++-------- tests/python/test_m4_dcp_handoff.py | 56 +++++++++++++++++++---------- 2 files changed, 49 insertions(+), 35 deletions(-) diff --git a/src/kboot.c b/src/kboot.c index a358d881e..7391be451 100644 --- a/src/kboot.c +++ b/src/kboot.c @@ -7945,24 +7945,21 @@ static int dt_set_j713_display_maps(const struct adt_segment_ranges *segments, u static int dt_set_dcp_fw27_clocks(const char *alias, const char *adt_engine); /* - * Publish the inherited DCP firmware mapping without starting a display driver: on the J713 - * on any firmware as before, and on any other M4 Mac with a panel on 26.6.2. + * Publish the inherited DCP firmware mapping without starting a display driver, on any M4 Mac + * whose ADT describes an internal panel on disp0, whatever its firmware. The kernel picks the + * display backend from the firmware the DCP runs. */ static int dt_set_m4_dcp_handoff(void) { int dcp_node = fdt_path_offset(dt, "dcp"); if (dcp_node < 0) return 0; /* Older DT with simple-framebuffer only. */ - bool j713 = !fdt_node_check_compatible(dt, 0, "apple,j713"); - if (chip_id != T8132 || (!j713 && os_firmware.version != V26_6_2) || - fdt_node_check_compatible(dt, dcp_node, "apple,t8132-dcp")) + if (chip_id != T8132 || fdt_node_check_compatible(dt, dcp_node, "apple,t8132-dcp")) bail("FDT: unsupported native DCP handoff target\n"); - /* The Mac mini's disp0 is external: its DCP drives a port, not a panel. */ - if (!j713) { - int disp0 = adt_path_offset(adt, "/arm-io/disp0"); - if (disp0 < 0 || adt_getprop(adt, disp0, "external", NULL)) - bail("FDT: no internal panel, no native DCP handoff\n"); - } + /* A Mac mini's disp0 is external: its DCP drives a port, not a panel. */ + int disp0 = adt_path_offset(adt, "/arm-io/disp0"); + if (disp0 < 0 || adt_getprop(adt, disp0, "external", NULL)) + bail("FDT: no internal panel, no native DCP handoff\n"); int nub = adt_path_offset(adt, "/arm-io/dcp/iop-dcp-nub"); if (nub < 0) @@ -8012,12 +8009,11 @@ static int dt_set_m4_dcp_handoff(void) dcp_node = fdt_path_offset(dt, "dcp"); if (fdt_getprop(dt, dcp_node, "apple,j713-native-piodma", NULL)) { /* - * The DCP image is per firmware, the same on every M4 Mac: 26.6.2 and the 27.2 stub. - * The walk checks every inherited SID0/SID16 page against this image's segments and - * publishes nothing unless all of them match. + * The walk checks every inherited SID0/SID16 page against the segments of the image + * the DCP runs and publishes nothing unless all of them match, so it needs no list of + * firmware versions. */ - if ((os_firmware.version != V26_6_2 && os_firmware.version != V27_2) || - dt_set_j713_display_maps(segments, count, dram_start, dram_size)) + if (dt_set_j713_display_maps(segments, count, dram_start, dram_size)) printf("FDT: M4 PIODMA handoff unqualified; retaining disabled device\n"); else maps = true; diff --git a/tests/python/test_m4_dcp_handoff.py b/tests/python/test_m4_dcp_handoff.py index 0d7b03803..f8b02b27d 100644 --- a/tests/python/test_m4_dcp_handoff.py +++ b/tests/python/test_m4_dcp_handoff.py @@ -297,8 +297,8 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): assert(!!fdt_getprop(dt, fdt_path_offset(dt, "disp0"), "apple,j713-inherited-mappings", NULL) == piodma); assert(!!fdt_getprop(dt, fdt_path_offset(dt, "disp0"), "memory-region", NULL) == piodma); - assert(walks == (b.native && (os_firmware.version == V26_6_2 || - os_firmware.version == V27_2) ? 2 : 0)); + /* The walk runs wherever the DT asks for PIODMA, on any firmware. */ + assert(walks == (b.native ? 2 : 0)); /* * Firmware 27 is given /arm-io/disp0's clocks, only with the inherited display maps (the * kernel admits the DCP on apple,clock-ids); 26.x trees are not touched. @@ -346,13 +346,17 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): assert(argc == 2); outdir = argv[1]; - /* The J713 as before: on 26.6.2 with PIODMA and scanout, and on any other firmware. */ + /* + * Every M4 Mac whose ADT has an internal panel on disp0, on any firmware: the J713 on + * 26.6.2 with PIODMA and scanout, and the same on older images. PIODMA follows the + * inherited pages, not a firmware version list. + */ handed_over(&j713, V26_6_2, true); struct board old = j713; - old.uuid = "0BC97BDD-E2FE-3A1B-96B4-8EA8FC5B8BE8"; /* 26.5.1: PIODMA unqualified */ - handed_over(&old, V26_5, false); - handed_over(&old, V27_0, false); - handed_over(&old, V26_6, false); + old.uuid = "0BC97BDD-E2FE-3A1B-96B4-8EA8FC5B8BE8"; /* 26.5.1 */ + handed_over(&old, V26_5, true); + handed_over(&old, V27_0, true); + handed_over(&old, V26_6, true); /* The 27.2 stub: the 26.6.2 path's PIODMA and scanout, plus the firmware-27 clocks. */ struct board stub = j713; stub.uuid = "B3BA603C-3CA7-3E21-B393-44EB20BD2AEF"; @@ -372,11 +376,16 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): !fdt_getprop(dt, fdt_path_offset(dt, "dcp"), "clocks", NULL) && fdt_path_offset(dt, "/clock-dcp-firmware-364") < 0); assert(fdt_getprop(dt, fdt_path_offset(dt, "dcp"), "apple,firmware-uuid", NULL)); - /* The J713's disp0 is never read. PIODMA follows the firmware version, not the image. */ - old = j713; old.external = -1; - handed_over(&old, V26_6, false); + /* The same pages on 26.6.2 are refused the same way. */ + world(&j713, V26_6_2); + dart_skew = SZ_16K; + assert(!dt_set_m4_dcp_handoff()); + assert(walks == 1 && status_is("/soc/display-subsystem", "disabled")); - /* Every other M4 Mac with a panel, on 26.6.2. The laptops' DT asks for PIODMA. */ + /* + * The other M4 Macs with a panel take the same handoff as the J713, decided by their ADT + * and not their board name. The laptops' DT asks for PIODMA. + */ handed_over(&j604, V26_6_2, true); handed_over(&j715, V26_6_2, true); struct board other = j604; @@ -387,22 +396,26 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): imac.name = "j624"; imac.native = false; handed_over(&imac, V26_6_2, false); - - /* Any other firmware: nothing, as before. */ + struct board pro = j604; + pro.name = "j604-27.2"; + pro.uuid = stub.uuid; + handed_over(&pro, V27_2, true); const enum fw_version others[] = {V26_5, V26_6, V27_0, V27_2, V14_7}; const struct board *panels[] = {&j604, &j715, &imac}; for (unsigned i = 0; i < ARRAY_SIZE(others); i++) - for (unsigned k = 0; k < ARRAY_SIZE(panels); k++) { - world(panels[k], others[i]); - refused(); - } + for (unsigned k = 0; k < ARRAY_SIZE(panels); k++) + handed_over(panels[k], others[i], panels[k]->native); - /* No internal panel: the Mac mini, or no disp0 at all. */ + /* No internal panel: the Mac mini on any firmware, or no disp0 at all, the J713 too. */ world(&j773g, V26_6_2); refused(); save("j773g-26.6.2"); world(&j773g, V26_6); refused(); + world(&j773g, V27_2); refused(); struct board bare = j604; bare.external = -1; world(&bare, V26_6_2); refused(); + bare = j713; + bare.external = -1; + world(&bare, V27_2); refused(); /* Not a T8132, or not its DCP. */ world(&j713, V26_6_2); chip_id = T8122; refused(); @@ -432,7 +445,12 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path): ) result = subprocess.run([str(binary), str(tmp_path)], capture_output=True, text=True) assert result.returncode == 0, result.stdout + result.stderr - for name in ("j713-27.2", "j713-26.6.2", "j604-26.6.2", "j715-26.6.2", "j624-26.6.2", "j773g-26.6.2"): + for name in ("j713-27.2", "j713-26.6.2", "j604-26.6.2", "j715-26.6.2", "j624-26.6.2", "j773g-26.6.2", + "j604-27.2-27.2", "j715-27.2"): assert (tmp_path / f"{name}.dtb").stat().st_size > 0 # The refusals say why. assert "no internal panel" in result.stdout + # No board name decides the handoff. + handoff = function(kboot, "dt_set_m4_dcp_handoff") + assert not re.search(r"check_compatible\(dt, 0,", handoff) + assert "V26_6_2" not in handoff and "V27_2" not in handoff