From 855f86267e46ddccebafc2e6bc81c15e4d02bd02 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 14 Nov 2026 00:46:55 +1100 Subject: [PATCH 1/8] drm/apple: admit the M1/M2/M3 display processors on firmware 27.2 The T8103, T600x, T8112, T602x, T8122, T6030 and T603x display processors share one firmware-27 wire generation with the T6050: the same IOMobileFramebuffer method numbering, AFK wire v2 and v27 drive record. On exact firmware-compat 27.2.0 they should run that generation instead of the 14.7-era session the boot loader previously handed them. Give each of these processors' DCP and dcpext a version-aware firmware-27 admission. dcp_check_firmware_version() now selects DCP_FIRMWARE_V_27_0 with the in-tree 27.2.0 method table before the 14.7 board and special-profile checks, so the T8122 and T6030 14.7-only rejections no longer apply to the 27.2 arm. The older admissions stay in place unchanged for the firmware those boards still boot, and the probe keeps each processor's port count, tunnel-flow flag, connector topology, DMA width and DART resources from its own match data; only the live-session adoption is version-selected. The shared v27 method-table validation is factored into one helper reused by both firmware-27 arms. Add an apple-dcp-v27 KUnit suite covering which compatibles the admission recognises, that the non-refmac firmware-27 processors keep their own paths, and that the 27.2.0 method table is complete. Signed-off-by: Ryan Murray [Dj: rebased onto main, using main's dcp_v27_method_table() and keeping adoption ahead of main's per-SoC firmware-27 profiles.] Signed-off-by: Dj <43033058+DjDeveloperr@users.noreply.github.com> --- drivers/gpu/drm/apple/Makefile | 1 + drivers/gpu/drm/apple/dcp.c | 56 ++++++++++++ drivers/gpu/drm/apple/dcp.h | 7 ++ drivers/gpu/drm/apple/iomfb_v27_test.c | 117 +++++++++++++++++++++++++ 4 files changed, 181 insertions(+) create mode 100644 drivers/gpu/drm/apple/iomfb_v27_test.c diff --git a/drivers/gpu/drm/apple/Makefile b/drivers/gpu/drm/apple/Makefile index c040f80df8e80..a6521dc75b9e7 100644 --- a/drivers/gpu/drm/apple/Makefile +++ b/drivers/gpu/drm/apple/Makefile @@ -23,6 +23,7 @@ appledrm-$(CONFIG_DRM_APPLE_DCP_T8152) += t8152_hdmi.o t8152_typec.o appledrm-$(CONFIG_DRM_APPLE_DCP_T8152) += iomfb_iboot.o iboot_drm.o appledrm-y += iomfb_h17p.o appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += iomfb_h17p_test.o parser_test.o +appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += iomfb_v27_test.o appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += iomfb_external_hdr_hints_test.o appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += apple_resume_test.o appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += apple_boot_display_test.o diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 4e48c4574624f..c6771cfbf9a2e 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -6178,6 +6178,40 @@ static bool dcp_v27_sleep_transport_supported(struct apple_dcp *dcp) return iomfb_v27_sleep_methods_complete(dcp->v27_methods); } +/* + * The M1/M2/M3 display processors share the T6050 firmware-27 wire generation. + * @compat_is answers whether a device node carries a compatible string, so the + * same list is used by probe and by the host test. + */ +bool dcp_refmac_v27_compat(dcp_compat_fn compat_is, const void *ctx) +{ + static const char * const compats[] = { + "apple,t8103-dcp", "apple,t8103-dcpext", + "apple,t6000-dcp", "apple,t6000-dcpext", + "apple,t8112-dcp", "apple,t8112-dcpext", + "apple,t6020-dcp", "apple,t6020-dcpext", + "apple,t8122-dcp", "apple,t8122-dcpext", + "apple,t6030-dcp", "apple,t6030-dcpext", + "apple,t6031-dcp", "apple,t6031-dcpext", + }; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(compats); i++) + if (compat_is(ctx, compats[i])) + return true; + return false; +} + +static bool dcp_node_compat_is(const void *np, const char *compat) +{ + return of_device_is_compatible(np, compat); +} + +static bool dcp_node_is_refmac_v27(const struct device_node *np) +{ + return dcp_refmac_v27_compat(dcp_node_compat_is, np); +} + /* * Firmware 27, if firmware-compat @compat_str has a 27.x method table with an * ID for every method the driver calls: the firmware panics on an unknown tag. @@ -6236,6 +6270,19 @@ static enum dcp_firmware_version dcp_check_firmware_version(struct device *dev) return dcp_v27_method_table(dev, compat_str); } + /* + * The M1/M2/M3 processors are one firmware-27 wire generation with the + * T6050. On exact firmware-compat 27.2.0 they run that generation, so + * admit it before the 14.7 board and special-profile paths below. The + * older admissions stay in place for the firmware those boards still + * boot. + */ + if (dcp_node_is_refmac_v27(dev->of_node)) { + ret = dcp_read_fw_version(dev, "apple,firmware-compat", compat_str); + if (ret >= 0 && !strcmp(compat_str, "27.2.0")) + return dcp_v27_method_table(dev, compat_str); + } + if (hw->firmware_compat == DCP_FIRMWARE_V_27_0) { ret = dcp_read_fw_version(dev, "apple,firmware-compat", compat_str); if (ret < 0) { @@ -7994,6 +8041,15 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev) if (fw_compat == DCP_FIRMWARE_V_27_0 && of_device_is_compatible(dev->of_node, "apple,t8142-dcp")) dcp->hw.iomfb_method_profile = DCP_IOMFB_METHODS_DEFAULT; + /* + * An M1/M2/M3 processor on firmware 27 inherits the live session the + * boot loader handed over, like the T6050. Its match data keeps the + * per-SoC port count, tunnel-flow flag and DART resources; only the + * firmware-27 session adoption is version-selected here, before the + * per-SoC firmware-27 profiles below, which may override it. + */ + if (fw_compat == DCP_FIRMWARE_V_27_0 && dcp_node_is_refmac_v27(dev->of_node)) + dcp->hw.adopt_live_session = true; /* * T6041 internal panel on firmware 27 adopts the running DCP session * with 41-bit firmware DMA addressing and no DPTX port services, diff --git a/drivers/gpu/drm/apple/dcp.h b/drivers/gpu/drm/apple/dcp.h index 6c1c258c3c54e..171eda68c817d 100644 --- a/drivers/gpu/drm/apple/dcp.h +++ b/drivers/gpu/drm/apple/dcp.h @@ -94,6 +94,13 @@ bool dcp_fw_compat_is_desktop(struct platform_device *pdev); bool dcp_panel_edr(struct platform_device *pdev); bool dcp_ext_color_props_supported(struct platform_device *pdev); unsigned int dcp_gamma_lut_size(struct platform_device *pdev); +/* + * The M1/M2/M3 display processors admitted into the firmware-27 wire + * generation. @compat_is answers whether a context (a device node in the + * driver, a fixture in the test) carries a compatible string. + */ +typedef bool (*dcp_compat_fn)(const void *ctx, const char *compat); +bool dcp_refmac_v27_compat(dcp_compat_fn compat_is, const void *ctx); /* T6041 external display processors may join the DRM device. */ bool dcp_t6041_ext_enabled(void); void dcp_backlight_takeover_registered(struct platform_device *pdev); diff --git a/drivers/gpu/drm/apple/iomfb_v27_test.c b/drivers/gpu/drm/apple/iomfb_v27_test.c new file mode 100644 index 0000000000000..6ca01f3436f95 --- /dev/null +++ b/drivers/gpu/drm/apple/iomfb_v27_test.c @@ -0,0 +1,117 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT +/* Copyright 2026 Aurora Silicon */ + +/* + * The M1/M2/M3 display processors are admitted into the firmware-27 wire + * generation on exact firmware-compat 27.2.0, sharing the T6050 method table. + * These tests cover which compatibles that admission recognises and that the + * 27.2.0 method table is complete, so a recognised processor starts. + */ + +#include +#include +#include + +#include "dcp.h" +#include "iomfb.h" +#include "iomfb_v27.h" + +/* A fixture node: the compatible strings the device tree would carry. */ +struct refmac_node { + const char *const *compats; /* NULL-terminated */ +}; + +static bool refmac_node_compat_is(const void *ctx, const char *compat) +{ + const struct refmac_node *node = ctx; + const char *const *c; + + for (c = node->compats; *c; c++) + if (!strcmp(*c, compat)) + return true; + return false; +} + +static bool refmac_admits(const char *const *compats) +{ + const struct refmac_node node = { .compats = compats }; + + return dcp_refmac_v27_compat(refmac_node_compat_is, &node); +} + +/* Both the per-SoC and the generic compatible of each refmac node. */ +static const char *const t8103_dcp[] = { "apple,t8103-dcp", "apple,dcp", NULL }; +static const char *const t8103_dcpext[] = { "apple,t8103-dcpext", "apple,dcpext", NULL }; +static const char *const t6000_dcp[] = { "apple,t6000-dcp", "apple,dcp", NULL }; +static const char *const t6000_dcpext[] = { "apple,t6000-dcpext", "apple,dcpext", NULL }; +static const char *const t8112_dcp[] = { "apple,t8112-dcp", "apple,dcp", NULL }; +static const char *const t8112_dcpext[] = { "apple,t8112-dcpext", "apple,dcpext", NULL }; +static const char *const t6020_dcp[] = { "apple,t6020-dcp", "apple,dcp", NULL }; +static const char *const t6020_dcpext[] = { "apple,t6020-dcpext", "apple,dcpext", NULL }; +static const char *const t8122_dcp[] = { "apple,t8122-dcp", "apple,dcp", NULL }; +static const char *const t8122_dcpext[] = { "apple,t8122-dcpext", "apple,dcpext", NULL }; +static const char *const t6030_dcp[] = { "apple,t6030-dcp", "apple,dcp", NULL }; +static const char *const t6030_dcpext[] = { "apple,t6030-dcpext", "apple,dcpext", NULL }; +static const char *const t6031_dcp[] = { "apple,t6031-dcp", "apple,dcp", NULL }; +static const char *const t6031_dcpext[] = { "apple,t6031-dcpext", "apple,dcpext", NULL }; + +static void v27_refmac_admits_test(struct kunit *test) +{ + KUNIT_EXPECT_TRUE(test, refmac_admits(t8103_dcp)); + KUNIT_EXPECT_TRUE(test, refmac_admits(t8103_dcpext)); + KUNIT_EXPECT_TRUE(test, refmac_admits(t6000_dcp)); + KUNIT_EXPECT_TRUE(test, refmac_admits(t6000_dcpext)); + KUNIT_EXPECT_TRUE(test, refmac_admits(t8112_dcp)); + KUNIT_EXPECT_TRUE(test, refmac_admits(t8112_dcpext)); + KUNIT_EXPECT_TRUE(test, refmac_admits(t6020_dcp)); + KUNIT_EXPECT_TRUE(test, refmac_admits(t6020_dcpext)); + KUNIT_EXPECT_TRUE(test, refmac_admits(t8122_dcp)); + KUNIT_EXPECT_TRUE(test, refmac_admits(t8122_dcpext)); + KUNIT_EXPECT_TRUE(test, refmac_admits(t6030_dcp)); + KUNIT_EXPECT_TRUE(test, refmac_admits(t6030_dcpext)); + KUNIT_EXPECT_TRUE(test, refmac_admits(t6031_dcp)); + KUNIT_EXPECT_TRUE(test, refmac_admits(t6031_dcpext)); +} + +/* The T6050 and T8142 keep their own firmware-27 paths; T6041 and M4 do not. */ +static const char *const t6050_dcp[] = { "apple,t6050-dcp", NULL }; +static const char *const t8142_dcp[] = { "apple,t8142-dcp", NULL }; +static const char *const t6041_dcp[] = { "apple,t6041-dcp", "apple,dcpext", NULL }; +static const char *const t8140_dcp[] = { "apple,t8140-dcp", NULL }; + +static void v27_refmac_rejects_test(struct kunit *test) +{ + KUNIT_EXPECT_FALSE(test, refmac_admits(t6050_dcp)); + KUNIT_EXPECT_FALSE(test, refmac_admits(t8142_dcp)); + KUNIT_EXPECT_FALSE(test, refmac_admits(t6041_dcp)); + KUNIT_EXPECT_FALSE(test, refmac_admits(t8140_dcp)); +} + +/* The 27.2.0 table a recognised processor runs is complete, so it may start. */ +static void v27_method_table_test(struct kunit *test) +{ + const struct dcp_method_entry *methods; + unsigned int missing; + + methods = iomfb_v27_methods("27.2.0"); + KUNIT_ASSERT_NOT_NULL(test, methods); + KUNIT_EXPECT_PTR_EQ(test, iomfb_v27_missing_method(methods, &missing), NULL); + KUNIT_EXPECT_EQ(test, missing, 0U); + KUNIT_EXPECT_PTR_EQ(test, iomfb_v27_methods("27.1.0"), NULL); +} + +static struct kunit_case v27_cases[] = { + KUNIT_CASE(v27_refmac_admits_test), + KUNIT_CASE(v27_refmac_rejects_test), + KUNIT_CASE(v27_method_table_test), + {} +}; + +static struct kunit_suite v27_suite = { + .name = "apple-dcp-v27", + .test_cases = v27_cases, +}; + +kunit_test_suite(v27_suite); + +MODULE_LICENSE("Dual MIT/GPL"); From 65ff2bc384a9b971efc1ddfc83cfb8238be4190d Mon Sep 17 00:00:00 2001 From: Ryan <81541646+RyanTheTide@users.noreply.github.com> Date: Fri, 20 Nov 2026 02:42:38 +1100 Subject: [PATCH 2/8] drm/apple: select firmware 27 by the firmware the DCP reports Firmware 27 was admitted three ways: T6050 by its match data, T8142 by its compatible on exact 27.0.0, and the M1/M2/M3 processors through a list of fourteen DCP and dcpext compatibles on exact 27.2.0. The deciding facts are the same everywhere: the DCP reports firmware-compat 27 or later, and the driver has a complete method table for that build. Replace the compatible list and the T8142 arm with one helper, dcp_v27_admission(), used for every DCP and dcpext before any per-SoC selection. A firmware-compat of 27 or later runs the firmware-27 instance when iomfb_v27_methods() has a complete table for the build, and is not started otherwise: the interfaces written for older firmware make it panic (T8142 on 27.0 with H17P). Older firmware keeps the existing 26.x, 14.x and 13.x selection unchanged. Every processor on firmware 27 adopts the live session the loader handed over. What stays per SoC has a hardware reason: the T6050 has no interface older than firmware 27; the T8140 dcpext is refused before selection on anything but 26.6.2; T8142 on firmware 27 keeps the default method profile, since with H17G every swap fails with status 4. This also admits T6041, T8132, T8140 and T8142 on firmware 27 builds with a complete table (T8142 newly on 27.2.0); none has been run on 27.2. The T8140's method profile on firmware 27 is left to a separate change. Rewrite the apple-dcp-v27 KUnit suite for the rule: complete 27.x tables are admitted, 27.x and later builds without a usable table are refused, older firmware is left to the older selection. Signed-off-by: Ryan [Dj: rebased onto main: main's T8142 and T8122 firmware-27 arms are kept ahead of dcp_firmware_27(), which reports a refused build through main's dcp_v27_method_table(); the blanket adoption comes before main's per-SoC firmware-27 profiles, so the T8122 dcpext still starts cold.] Signed-off-by: Dj <43033058+DjDeveloperr@users.noreply.github.com> --- drivers/gpu/drm/apple/dcp.c | 115 ++++++++++++----------- drivers/gpu/drm/apple/dcp.h | 20 ++-- drivers/gpu/drm/apple/iomfb_v27_test.c | 124 +++++++++---------------- 3 files changed, 122 insertions(+), 137 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index c6771cfbf9a2e..1c68499311d27 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -6178,40 +6178,6 @@ static bool dcp_v27_sleep_transport_supported(struct apple_dcp *dcp) return iomfb_v27_sleep_methods_complete(dcp->v27_methods); } -/* - * The M1/M2/M3 display processors share the T6050 firmware-27 wire generation. - * @compat_is answers whether a device node carries a compatible string, so the - * same list is used by probe and by the host test. - */ -bool dcp_refmac_v27_compat(dcp_compat_fn compat_is, const void *ctx) -{ - static const char * const compats[] = { - "apple,t8103-dcp", "apple,t8103-dcpext", - "apple,t6000-dcp", "apple,t6000-dcpext", - "apple,t8112-dcp", "apple,t8112-dcpext", - "apple,t6020-dcp", "apple,t6020-dcpext", - "apple,t8122-dcp", "apple,t8122-dcpext", - "apple,t6030-dcp", "apple,t6030-dcpext", - "apple,t6031-dcp", "apple,t6031-dcpext", - }; - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(compats); i++) - if (compat_is(ctx, compats[i])) - return true; - return false; -} - -static bool dcp_node_compat_is(const void *np, const char *compat) -{ - return of_device_is_compatible(np, compat); -} - -static bool dcp_node_is_refmac_v27(const struct device_node *np) -{ - return dcp_refmac_v27_compat(dcp_node_compat_is, np); -} - /* * Firmware 27, if firmware-compat @compat_str has a 27.x method table with an * ID for every method the driver calls: the firmware panics on an unknown tag. @@ -6237,12 +6203,64 @@ static enum dcp_firmware_version dcp_v27_method_table(struct device *dev, return DCP_FIRMWARE_V_27_0; } +/* + * Firmware 27 is selected by the ABI the DCP reports, the same on every SoC: + * a DCP or dcpext whose firmware-compat is 27 or later runs the common + * firmware-27 instance with the method table of that build. The interfaces + * written for older firmware make it panic (T8142 on 27.0 with H17P: "ap_link: + * callback failed with: 0x5"), so a 27 or later build without a complete + * table is not started at all. Pure, so the host test runs the same rule. + */ +enum dcp_v27_admission dcp_v27_admission(const char *compat, + const struct dcp_method_entry **methods, + const char **missing, + unsigned int *num_missing) +{ + unsigned int major; + + *methods = NULL; + *missing = NULL; + *num_missing = 0; + if (sscanf(compat, "%u.", &major) != 1 || major < 27) + return DCP_V27_NOT_V27; + *methods = iomfb_v27_methods(compat); + if (!*methods) + return DCP_V27_NO_TABLE; + *missing = iomfb_v27_missing_method(*methods, num_missing); + if (*missing) + return DCP_V27_INCOMPLETE; + return DCP_V27_ADMITTED; +} + +/* + * Returns true if the DCP reports firmware 27 or later, with @version the + * firmware-27 instance or DCP_FIRMWARE_UNKNOWN if this build cannot be started. + */ +static bool dcp_firmware_27(struct device *dev, + enum dcp_firmware_version *version) +{ + char compat[DCP_FW_VERSION_STR_LEN]; + const struct dcp_method_entry *methods; + unsigned int num_missing; + const char *missing; + + if (dcp_read_fw_version(dev, "apple,firmware-compat", compat) < 0) + return false; + if (dcp_v27_admission(compat, &methods, &missing, &num_missing) == + DCP_V27_NOT_V27) + return false; + /* Logs why a build without a complete table is not started. */ + *version = dcp_v27_method_table(dev, compat); + return true; +} + static enum dcp_firmware_version dcp_check_firmware_version(struct device *dev) { const struct apple_dcp_hw_data *hw = of_device_get_match_data(dev); const struct dcp_v14_board *v14_board; char compat_str[DCP_FW_VERSION_STR_LEN]; char fw_str[DCP_FW_VERSION_STR_LEN]; + enum dcp_firmware_version version; int ret; /* @@ -6270,19 +6288,10 @@ static enum dcp_firmware_version dcp_check_firmware_version(struct device *dev) return dcp_v27_method_table(dev, compat_str); } - /* - * The M1/M2/M3 processors are one firmware-27 wire generation with the - * T6050. On exact firmware-compat 27.2.0 they run that generation, so - * admit it before the 14.7 board and special-profile paths below. The - * older admissions stay in place for the firmware those boards still - * boot. - */ - if (dcp_node_is_refmac_v27(dev->of_node)) { - ret = dcp_read_fw_version(dev, "apple,firmware-compat", compat_str); - if (ret >= 0 && !strcmp(compat_str, "27.2.0")) - return dcp_v27_method_table(dev, compat_str); - } + if (dcp_firmware_27(dev, &version)) + return version; + /* The T6050 was introduced on firmware 27 and has no older interface. */ if (hw->firmware_compat == DCP_FIRMWARE_V_27_0) { ret = dcp_read_fw_version(dev, "apple,firmware-compat", compat_str); if (ret < 0) { @@ -8042,13 +8051,15 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev) of_device_is_compatible(dev->of_node, "apple,t8142-dcp")) dcp->hw.iomfb_method_profile = DCP_IOMFB_METHODS_DEFAULT; /* - * An M1/M2/M3 processor on firmware 27 inherits the live session the - * boot loader handed over, like the T6050. Its match data keeps the - * per-SoC port count, tunnel-flow flag and DART resources; only the - * firmware-27 session adoption is version-selected here, before the - * per-SoC firmware-27 profiles below, which may override it. + * Every processor on firmware 27 inherits the live session the boot + * loader handed over. Its match data keeps the per-SoC port count, + * tunnel-flow flag and DART resources; only the session adoption follows + * the firmware. The per-SoC firmware-27 profiles below come after it and + * may override it: the T8122 dcpext, which the loader leaves unpowered, + * does not adopt. (The T8140 dcpext, whose match data does not adopt, is + * refused above on anything but 26.6.2.) */ - if (fw_compat == DCP_FIRMWARE_V_27_0 && dcp_node_is_refmac_v27(dev->of_node)) + if (fw_compat == DCP_FIRMWARE_V_27_0) dcp->hw.adopt_live_session = true; /* * T6041 internal panel on firmware 27 adopts the running DCP session diff --git a/drivers/gpu/drm/apple/dcp.h b/drivers/gpu/drm/apple/dcp.h index 171eda68c817d..f2745dde65580 100644 --- a/drivers/gpu/drm/apple/dcp.h +++ b/drivers/gpu/drm/apple/dcp.h @@ -94,13 +94,19 @@ bool dcp_fw_compat_is_desktop(struct platform_device *pdev); bool dcp_panel_edr(struct platform_device *pdev); bool dcp_ext_color_props_supported(struct platform_device *pdev); unsigned int dcp_gamma_lut_size(struct platform_device *pdev); -/* - * The M1/M2/M3 display processors admitted into the firmware-27 wire - * generation. @compat_is answers whether a context (a device node in the - * driver, a fixture in the test) carries a compatible string. - */ -typedef bool (*dcp_compat_fn)(const void *ctx, const char *compat); -bool dcp_refmac_v27_compat(dcp_compat_fn compat_is, const void *ctx); +/* Whether a DCP reporting firmware-compat @compat runs the firmware-27 instance. */ +enum dcp_v27_admission { + DCP_V27_NOT_V27, /* older than 27: the older interfaces decide */ + DCP_V27_NO_TABLE, /* 27 or later, no method table for the build */ + DCP_V27_INCOMPLETE, /* 27 or later, a method has no known ID */ + DCP_V27_ADMITTED, +}; + +struct dcp_method_entry; +enum dcp_v27_admission dcp_v27_admission(const char *compat, + const struct dcp_method_entry **methods, + const char **missing, + unsigned int *num_missing); /* T6041 external display processors may join the DRM device. */ bool dcp_t6041_ext_enabled(void); void dcp_backlight_takeover_registered(struct platform_device *pdev); diff --git a/drivers/gpu/drm/apple/iomfb_v27_test.c b/drivers/gpu/drm/apple/iomfb_v27_test.c index 6ca01f3436f95..0c20e9c0d1f89 100644 --- a/drivers/gpu/drm/apple/iomfb_v27_test.c +++ b/drivers/gpu/drm/apple/iomfb_v27_test.c @@ -2,10 +2,10 @@ /* Copyright 2026 Aurora Silicon */ /* - * The M1/M2/M3 display processors are admitted into the firmware-27 wire - * generation on exact firmware-compat 27.2.0, sharing the T6050 method table. - * These tests cover which compatibles that admission recognises and that the - * 27.2.0 method table is complete, so a recognised processor starts. + * Firmware 27 is selected by the firmware-compat a DCP reports, on every SoC: + * 27 or later runs the firmware-27 instance when the build has a complete + * method table and is not started otherwise; older firmware is left to the + * older interfaces. These tests cover that rule and the in-tree tables. */ #include @@ -16,94 +16,62 @@ #include "iomfb.h" #include "iomfb_v27.h" -/* A fixture node: the compatible strings the device tree would carry. */ -struct refmac_node { - const char *const *compats; /* NULL-terminated */ -}; - -static bool refmac_node_compat_is(const void *ctx, const char *compat) +static enum dcp_v27_admission admission(const char *compat) { - const struct refmac_node *node = ctx; - const char *const *c; + const struct dcp_method_entry *methods; + unsigned int num_missing; + const char *missing; - for (c = node->compats; *c; c++) - if (!strcmp(*c, compat)) - return true; - return false; + return dcp_v27_admission(compat, &methods, &missing, &num_missing); } -static bool refmac_admits(const char *const *compats) +/* Builds with a complete table start, whatever SoC reports them. */ +static void v27_complete_table_admits_test(struct kunit *test) { - const struct refmac_node node = { .compats = compats }; - - return dcp_refmac_v27_compat(refmac_node_compat_is, &node); -} - -/* Both the per-SoC and the generic compatible of each refmac node. */ -static const char *const t8103_dcp[] = { "apple,t8103-dcp", "apple,dcp", NULL }; -static const char *const t8103_dcpext[] = { "apple,t8103-dcpext", "apple,dcpext", NULL }; -static const char *const t6000_dcp[] = { "apple,t6000-dcp", "apple,dcp", NULL }; -static const char *const t6000_dcpext[] = { "apple,t6000-dcpext", "apple,dcpext", NULL }; -static const char *const t8112_dcp[] = { "apple,t8112-dcp", "apple,dcp", NULL }; -static const char *const t8112_dcpext[] = { "apple,t8112-dcpext", "apple,dcpext", NULL }; -static const char *const t6020_dcp[] = { "apple,t6020-dcp", "apple,dcp", NULL }; -static const char *const t6020_dcpext[] = { "apple,t6020-dcpext", "apple,dcpext", NULL }; -static const char *const t8122_dcp[] = { "apple,t8122-dcp", "apple,dcp", NULL }; -static const char *const t8122_dcpext[] = { "apple,t8122-dcpext", "apple,dcpext", NULL }; -static const char *const t6030_dcp[] = { "apple,t6030-dcp", "apple,dcp", NULL }; -static const char *const t6030_dcpext[] = { "apple,t6030-dcpext", "apple,dcpext", NULL }; -static const char *const t6031_dcp[] = { "apple,t6031-dcp", "apple,dcp", NULL }; -static const char *const t6031_dcpext[] = { "apple,t6031-dcpext", "apple,dcpext", NULL }; - -static void v27_refmac_admits_test(struct kunit *test) -{ - KUNIT_EXPECT_TRUE(test, refmac_admits(t8103_dcp)); - KUNIT_EXPECT_TRUE(test, refmac_admits(t8103_dcpext)); - KUNIT_EXPECT_TRUE(test, refmac_admits(t6000_dcp)); - KUNIT_EXPECT_TRUE(test, refmac_admits(t6000_dcpext)); - KUNIT_EXPECT_TRUE(test, refmac_admits(t8112_dcp)); - KUNIT_EXPECT_TRUE(test, refmac_admits(t8112_dcpext)); - KUNIT_EXPECT_TRUE(test, refmac_admits(t6020_dcp)); - KUNIT_EXPECT_TRUE(test, refmac_admits(t6020_dcpext)); - KUNIT_EXPECT_TRUE(test, refmac_admits(t8122_dcp)); - KUNIT_EXPECT_TRUE(test, refmac_admits(t8122_dcpext)); - KUNIT_EXPECT_TRUE(test, refmac_admits(t6030_dcp)); - KUNIT_EXPECT_TRUE(test, refmac_admits(t6030_dcpext)); - KUNIT_EXPECT_TRUE(test, refmac_admits(t6031_dcp)); - KUNIT_EXPECT_TRUE(test, refmac_admits(t6031_dcpext)); + const struct dcp_method_entry *methods; + unsigned int num_missing; + const char *missing; + + KUNIT_EXPECT_EQ(test, dcp_v27_admission("27.2.0", &methods, &missing, + &num_missing), + DCP_V27_ADMITTED); + KUNIT_EXPECT_PTR_EQ(test, methods, iomfb_v27_methods("27.2.0")); + KUNIT_EXPECT_PTR_EQ(test, missing, NULL); + KUNIT_EXPECT_EQ(test, num_missing, 0U); + KUNIT_EXPECT_EQ(test, admission("27.0.0"), DCP_V27_ADMITTED); } -/* The T6050 and T8142 keep their own firmware-27 paths; T6041 and M4 do not. */ -static const char *const t6050_dcp[] = { "apple,t6050-dcp", NULL }; -static const char *const t8142_dcp[] = { "apple,t8142-dcp", NULL }; -static const char *const t6041_dcp[] = { "apple,t6041-dcp", "apple,dcpext", NULL }; -static const char *const t8140_dcp[] = { "apple,t8140-dcp", NULL }; - -static void v27_refmac_rejects_test(struct kunit *test) +/* 27 or later without a usable table is refused, never handed down. */ +static void v27_unusable_table_refuses_test(struct kunit *test) { - KUNIT_EXPECT_FALSE(test, refmac_admits(t6050_dcp)); - KUNIT_EXPECT_FALSE(test, refmac_admits(t8142_dcp)); - KUNIT_EXPECT_FALSE(test, refmac_admits(t6041_dcp)); - KUNIT_EXPECT_FALSE(test, refmac_admits(t8140_dcp)); + const struct dcp_method_entry *methods; + unsigned int num_missing; + const char *missing; + + KUNIT_EXPECT_EQ(test, admission("27.1.0"), DCP_V27_NO_TABLE); + KUNIT_EXPECT_EQ(test, admission("28.0.0"), DCP_V27_NO_TABLE); + KUNIT_EXPECT_EQ(test, dcp_v27_admission("27.3.0", &methods, &missing, + &num_missing), + DCP_V27_INCOMPLETE); + KUNIT_EXPECT_NOT_NULL(test, missing); + KUNIT_EXPECT_GT(test, num_missing, 0U); } -/* The 27.2.0 table a recognised processor runs is complete, so it may start. */ -static void v27_method_table_test(struct kunit *test) +/* Older firmware keeps the 26.x, 14.x and 13.x selection. */ +static void v27_older_firmware_not_v27_test(struct kunit *test) { - const struct dcp_method_entry *methods; - unsigned int missing; - - methods = iomfb_v27_methods("27.2.0"); - KUNIT_ASSERT_NOT_NULL(test, methods); - KUNIT_EXPECT_PTR_EQ(test, iomfb_v27_missing_method(methods, &missing), NULL); - KUNIT_EXPECT_EQ(test, missing, 0U); - KUNIT_EXPECT_PTR_EQ(test, iomfb_v27_methods("27.1.0"), NULL); + KUNIT_EXPECT_EQ(test, admission("26.6.2"), DCP_V27_NOT_V27); + KUNIT_EXPECT_EQ(test, admission("26.5.2"), DCP_V27_NOT_V27); + KUNIT_EXPECT_EQ(test, admission("14.7.0"), DCP_V27_NOT_V27); + KUNIT_EXPECT_EQ(test, admission("13.5.0"), DCP_V27_NOT_V27); + KUNIT_EXPECT_EQ(test, admission("12.3.0"), DCP_V27_NOT_V27); + KUNIT_EXPECT_EQ(test, admission("UNKNOWN"), DCP_V27_NOT_V27); } static struct kunit_case v27_cases[] = { - KUNIT_CASE(v27_refmac_admits_test), - KUNIT_CASE(v27_refmac_rejects_test), - KUNIT_CASE(v27_method_table_test), + KUNIT_CASE(v27_complete_table_admits_test), + KUNIT_CASE(v27_unusable_table_refuses_test), + KUNIT_CASE(v27_older_firmware_not_v27_test), {} }; From 48aaad34f58cf030cd64da10352d3ee3e67d7290 Mon Sep 17 00:00:00 2001 From: Dj <43033058+DjDeveloperr@users.noreply.github.com> Date: Tue, 24 Nov 2026 18:27:35 -0500 Subject: [PATCH 3/8] soc: apple: display-gate: take the T6030 macOS 27.2 PMP image On the macOS 27.2 (26B123) system firmware the boot loader passes the T6030 PMP values with tunable-uuid 5D66805B-E4AD-335E-BDC3-26828C682AAC, the PMP image the J516S ADT names for that release (iop-pmp-nub). The gate takes only the 14.x image (2F4EB4C4-...), so on a 27.2 J516s it stops with "PMP not added: this Mac's PMP firmware image is 5D66805B-..." and the internal display and both dcpext stay disabled. Take the 27.2 image as well, as for the T8122. The 27.2 PMP PTD map only inserts LTS-VOLT-CAP and leaves the SOC-DEV-PS-REQ, PS-ACK and PMP-STATUS offsets the T6030 PMP report reads unchanged, and the soc-device records are byte-identical to the J516S overlay's. The PMP report driver checks the running image in SRAM against the image the values name before it starts the PMP, so the same support serves both images. Add a KUnit case for the 27.2 image beside the one that refuses the T8122 image. Signed-off-by: Dj <43033058+DjDeveloperr@users.noreply.github.com> --- drivers/soc/apple/display-gate-test.c | 12 ++++++++++++ drivers/soc/apple/display-gate.c | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/soc/apple/display-gate-test.c b/drivers/soc/apple/display-gate-test.c index 7e736522740b0..da24641472994 100644 --- a/drivers/soc/apple/display-gate-test.c +++ b/drivers/soc/apple/display-gate-test.c @@ -790,6 +790,17 @@ static void __init gate_t6030_other_pmp_image(struct kunit *test) gt_expect_untouched(test); } +/* The 27.2 (26B123) T6030 PMP image is taken as well. */ +static void __init gate_t6030_pmp_image_27_2(struct kunit *test) +{ + struct gate_test *t = test->priv; + + t->pmp_uuid = "5D66805B-E4AD-335E-BDC3-26828C682AAC"; + gt_set_string(test, gt_t6030.values, "apple,tunable-uuid", t->pmp_uuid); + gt_run(test); + gt_expect_enabled(test); +} + static void __init gate_t6030_enabled_again(struct kunit *test) { gt_run(test); @@ -1185,6 +1196,7 @@ static struct kunit_case gate_t6030_cases[] __refdata = { KUNIT_CASE(gate_t6030_no_marker), KUNIT_CASE(gate_t6030_t6031_power_layout), KUNIT_CASE(gate_t6030_other_pmp_image), + KUNIT_CASE(gate_t6030_pmp_image_27_2), KUNIT_CASE(gate_t6030_enabled_again), {} }; diff --git a/drivers/soc/apple/display-gate.c b/drivers/soc/apple/display-gate.c index dc57af0dd1651..931fe3ef1adf8 100644 --- a/drivers/soc/apple/display-gate.c +++ b/drivers/soc/apple/display-gate.c @@ -161,6 +161,14 @@ static struct device_node *gate_pmp_values __initdata; */ static const char gate_pmp_uuid[] __initconst = "2F4EB4C4-001B-3ACF-A9A0-68D8E42FC3A7"; +/* + * The T6030 PMP image of the 27.2 (26B123) system firmware, as the J516S ADT + * names it. Its soc-device records are those of the J516S overlay, and the PMP + * report driver checks the running image against the values the boot loader + * passes, so the same PMP support takes either image. + */ +static const char gate_t6030_pmp_uuid_27_2[] __initconst = "5D66805B-E4AD-335E-BDC3-26828C682AAC"; + /* The T8122 PMP image of the 14.x system firmware. */ static const char gate_t8122_pmp_uuid[] __initconst = "3B18C886-4C70-349B-B1C4-70F35DE2C5CD"; @@ -255,6 +263,7 @@ static const struct gate_soc gate_t6030 __initconst = { .dcp_full_name = "dcp@28ec00000", .pmp_values = "/chosen/asahi,t6030-pmp", .pmp_uuid = gate_pmp_uuid, + .pmp_uuid_alt = gate_t6030_pmp_uuid_27_2, .report_compat = "apple,t6030-pmp-v2-report", .disp_entry = "report@7", .pmp_dtbo = __dtbo_t6030_pmp_begin, From 7879c0947f8041307bce285cf956306b2a945555 Mon Sep 17 00:00:00 2001 From: Dj <43033058+DjDeveloperr@users.noreply.github.com> Date: Tue, 24 Nov 2026 22:59:49 -0500 Subject: [PATCH 4/8] drm/apple: enforce v27 pins terminally and configure panels by DT capability Keep explicit match-data pins (T6050, T8142, T8132 M4, T8140 H17P) and image-UUID pins (T6041, T8122) ahead of generic dcp_firmware_27() admission in dcp_check_firmware_version(), making T8122 wrong or missing 27.2 UUIDs and internal T8142 unknown 27.x builds terminal refusals rather than taking generic firmware-27 or H17P. Configure firmware-27 internal panels from DT capabilities instead of SoC allowlists: verify available child routes inside typec-routes, derive firmware DMA width from the DCP DART apple,dma-range aperture when match data does not already set one (keeping DART-derived DMA widths on external profiles and only falling back when no aperture is supplied), exempt firmware-27 from the legacy apple,bw-scratch check, and restrict the single-clock disp0 fallback to internal-panel-only DCPs with exactly one unnamed clock so non-panel paths never fabricate clocks. Factor apple_t8122_dcpext_v27_2_for_internal() in include/linux/soc/apple/display.h and add KUnit coverage for T8122 internal/external, T6041 internal/external, T8142 (DCP_FIRMWARE_H17P on 26.6), T8132 pin precedence, terminal refusals, and typec-routes child availability. Signed-off-by: Dj <43033058+DjDeveloperr@users.noreply.github.com> --- drivers/gpu/drm/apple/dcp-firmware-test.c | 185 ++++++++++++++++++++++ drivers/gpu/drm/apple/dcp.c | 177 ++++++++++++++------- include/linux/soc/apple/display.h | 19 ++- 3 files changed, 316 insertions(+), 65 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp-firmware-test.c b/drivers/gpu/drm/apple/dcp-firmware-test.c index b0990bb1c0f68..9a51e23fb6b7f 100644 --- a/drivers/gpu/drm/apple/dcp-firmware-test.c +++ b/drivers/gpu/drm/apple/dcp-firmware-test.c @@ -100,10 +100,195 @@ static void dcp_firmware_27_empty_clock_table(struct kunit *test) KUNIT_EXPECT_EQ(test, dcp_firmware_clocks_v27(dcp), -EINVAL); } +/* + * Explicit match-data and image-UUID pins stay ahead of generic firmware-27 + * admission: T8122 wrong/missing 27.2 UUIDs and internal T8142 unknown 27.x + * builds are terminally refused rather than using generic v27 or H17P, + * while generic refmac DCPs (T6030, T8112) take firmware 27 on complete 27.x + * method tables and refuse incomplete ones. + */ +static void dcp_firmware_27_pin_precedence(struct kunit *test) +{ + static const char t6030[] = "apple,t6030-dcp"; + static const char t6041[] = "apple,t6041-dcp\0apple,dcp"; + static const char t6041_ext[] = "apple,t6041-dcpext\0apple,dcpext"; + static const char t8122[] = "apple,t8122-dcp\0apple,dcp"; + static const char t8122_ext[] = "apple,t8122-dcpext\0apple,dcpext"; + static const char t8142[] = "apple,t8142-dcp"; +#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T8132) + static const char t8132[] = "apple,t8132-dcp"; +#endif + static const char bad_uuid[] = "00000000-0000-0000-0000-000000000000"; + __be32 compat_26_6[] = { cpu_to_be32(26), cpu_to_be32(6), cpu_to_be32(2) }; + __be32 compat_27_0[] = { cpu_to_be32(27), 0, 0 }; + __be32 compat_27_1[] = { cpu_to_be32(27), cpu_to_be32(1), 0 }; + __be32 compat_27_2[] = { cpu_to_be32(27), cpu_to_be32(2), 0 }; + __be32 compat_27_3[] = { cpu_to_be32(27), cpu_to_be32(3), 0 }; + struct property props[] = { + { .name = "apple,firmware-compat", .length = sizeof(compat_27_2), + .value = compat_27_2, .next = &props[1] }, + { .name = "apple,firmware-version", .length = sizeof(compat_27_2), + .value = compat_27_2, .next = &props[2] }, + { .name = "apple,firmware-uuid", .length = sizeof(bad_uuid), + .value = (void *)bad_uuid, .next = &props[3] }, + { .name = "compatible", .length = sizeof(t6030), + .value = (void *)t6030 }, + }; + struct property ext_props[] = { + { .name = "apple,firmware-compat", .length = sizeof(compat_27_2), + .value = compat_27_2, .next = &ext_props[1] }, + { .name = "apple,firmware-version", .length = sizeof(compat_27_2), + .value = compat_27_2, .next = &ext_props[2] }, + { .name = "compatible", .length = sizeof(t8122_ext), + .value = (void *)t8122_ext }, + }; + struct device_node node = { .properties = props }; + struct device_node ext_node = { .properties = ext_props }; + struct device dev = { + .init_name = "dcp-firmware-test", + .of_node = &node, + .driver = &apple_platform_driver.driver, + }; + + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_V_27_0); + + props[0].value = compat_27_3; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_UNKNOWN); + props[0].value = compat_27_2; + + /* T6041 internal and external UUID pins remain enforced on 27.2. */ + props[3].length = sizeof(t6041); + props[3].value = (void *)t6041; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_UNKNOWN); + + props[2].length = sizeof(APPLE_T6041_DCP_26B123_UUID); + props[2].value = (void *)APPLE_T6041_DCP_26B123_UUID; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_V_27_0); + + props[3].length = sizeof(t6041_ext); + props[3].value = (void *)t6041_ext; + props[2].length = sizeof(bad_uuid); + props[2].value = (void *)bad_uuid; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_UNKNOWN); + + props[2].name = "apple,unrelated"; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_UNKNOWN); + + props[2].name = "apple,firmware-uuid"; + props[2].length = sizeof(APPLE_T6041_DCP_26B123_UUID); + props[2].value = (void *)APPLE_T6041_DCP_26B123_UUID; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_V_27_0); + + /* T8122 wrong or missing 27.2 UUID is terminally refused (never takes generic v27). */ + props[3].length = sizeof(t8122); + props[3].value = (void *)t8122; + props[2].name = "apple,firmware-uuid"; + props[2].length = sizeof(bad_uuid); + props[2].value = (void *)bad_uuid; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_UNKNOWN); + KUNIT_EXPECT_FALSE(test, + apple_t8122_dcpext_v27_2_for_internal(&ext_node, &node)); + + props[2].name = "apple,unrelated"; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_UNKNOWN); + KUNIT_EXPECT_FALSE(test, + apple_t8122_dcpext_v27_2_for_internal(&ext_node, &node)); + + props[2].name = "apple,firmware-uuid"; + props[2].length = sizeof(APPLE_T8122_DCP_26B123_UUID); + props[2].value = (void *)APPLE_T8122_DCP_26B123_UUID; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_V_27_0); + KUNIT_EXPECT_TRUE(test, + apple_t8122_dcpext_v27_2_for_internal(&ext_node, &node)); + + /* T8122 external with mismatched version is terminally refused regardless of live tree. */ + ext_props[1].value = compat_27_0; + KUNIT_EXPECT_FALSE(test, + apple_t8122_dcpext_v27_2_for_internal(&ext_node, &node)); + dev.of_node = &ext_node; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_UNKNOWN); + ext_props[1].value = compat_27_2; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + apple_t8122_dcpext_v27_2(&ext_node) ? + DCP_FIRMWARE_V_27_0 : DCP_FIRMWARE_UNKNOWN); + dev.of_node = &node; + + /* Internal T8142: known 27.x takes v27, unknown 27.x is refused (never takes H17P). */ + props[3].length = sizeof(t8142); + props[3].value = (void *)t8142; + props[0].value = compat_27_0; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_V_27_0); + props[0].value = compat_27_2; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_V_27_0); + props[0].value = compat_27_1; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_UNKNOWN); + props[0].value = compat_27_3; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_UNKNOWN); + props[0].value = compat_26_6; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_H17P); + props[0].value = compat_27_2; + +#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T8132) + /* T8132 keeps its M4 match-data pin on 27.2. */ + props[3].length = sizeof(t8132); + props[3].value = (void *)t8132; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + DCP_FIRMWARE_M4); +#endif +} + +static void dcp_typec_routes_available_children(struct kunit *test) +{ + static const char disabled[] = "disabled"; + static const char okay[] = "okay"; + struct property child_status = { + .name = "status", .length = sizeof(disabled), .value = (void *)disabled, + }; + struct device_node child = { + .name = "route", .full_name = "route@0", .properties = &child_status, + }; + struct device_node routes = { + .name = "typec-routes", .full_name = "typec-routes", + }; + struct device_node parent = { + .name = "dcp", .full_name = "dcp", .child = &routes, + }; + + /* Empty typec-routes container has no available route children. */ + KUNIT_EXPECT_FALSE(test, dcp_has_available_typec_routes(&parent)); + + /* Container with only disabled child routes has no available routes. */ + routes.child = &child; + KUNIT_EXPECT_FALSE(test, dcp_has_available_typec_routes(&parent)); + + /* Available child route activates Type-C route detection. */ + child_status.length = sizeof(okay); + child_status.value = (void *)okay; + KUNIT_EXPECT_TRUE(test, dcp_has_available_typec_routes(&parent)); +} + static struct kunit_case dcp_firmware_cases[] = { KUNIT_CASE(dcp_firmware_13_5_compat), KUNIT_CASE(dcp_firmware_27_method_admission), KUNIT_CASE(dcp_firmware_27_empty_clock_table), + KUNIT_CASE(dcp_firmware_27_pin_precedence), + KUNIT_CASE(dcp_typec_routes_available_children), {} }; diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 1c68499311d27..0db75e9b22217 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -6264,34 +6264,9 @@ static enum dcp_firmware_version dcp_check_firmware_version(struct device *dev) int ret; /* - * T8142 (J813) on macOS 27.0: the H17P interface written for its 26.x - * firmware makes the 27.0 DCP firmware panic right after the first - * hotplug ("ap_link: callback failed with: 0x5"). It runs the T6050's - * firmware-27 generation, and so does 27.2, with the 27.2 method table. + * T6050 and T8142 dcpext were introduced on firmware 27 and have no + * older interface. */ - if (of_device_is_compatible(dev->of_node, "apple,t8142-dcp")) { - ret = dcp_read_fw_version(dev, "apple,firmware-compat", compat_str); - if (ret >= 0 && (!strcmp(compat_str, "27.0.0") || - !strcmp(compat_str, "27.2.0"))) - return DCP_FIRMWARE_V_27_0; - } - - /* - * The T8122 (M3 MacBook Air) internal DCP on the 27.2 (26B123) image - * runs the firmware-27 backend with the 27.2 table, as the T6041's - * 27.2 internal DCP does. Its 14.x image keeps the native 14.7 path - * and the 25G83 profile its own, below. - */ - if (apple_t8122_dcp_v27_2(dev->of_node)) { - /* Checked by apple_t8122_dcp_v27_2(). */ - dcp_read_fw_version(dev, "apple,firmware-compat", compat_str); - return dcp_v27_method_table(dev, compat_str); - } - - if (dcp_firmware_27(dev, &version)) - return version; - - /* The T6050 was introduced on firmware 27 and has no older interface. */ if (hw->firmware_compat == DCP_FIRMWARE_V_27_0) { ret = dcp_read_fw_version(dev, "apple,firmware-compat", compat_str); if (ret < 0) { @@ -6302,8 +6277,20 @@ static enum dcp_firmware_version dcp_check_firmware_version(struct device *dev) } /* - * SoCs introduced with H17-generation firmware pin its interface; the - * loader may not recognise their boot firmware version. + * T8142 (J813) on firmware 27 or later: the H17P interface written for + * its 26.x firmware makes 27.x firmware panic right after the first + * hotplug ("ap_link: callback failed with: 0x5"). Keep ahead of its + * H17P match-data pin so known 27.x builds take the common firmware-27 + * backend and unknown 27.x builds are terminally refused. + */ + if (of_device_is_compatible(dev->of_node, "apple,t8142-dcp") && + dcp_firmware_27(dev, &version)) + return version; + + /* + * SoCs introduced with M4 or H17-generation firmware pin their + * interface; keep explicit match-data pins ahead of the generic + * firmware-27 rule below so T8132/T8140 stay on their pinned backend. */ if (hw->firmware_compat != DCP_FIRMWARE_UNKNOWN) return hw->firmware_compat; @@ -6315,7 +6302,8 @@ static enum dcp_firmware_version dcp_check_firmware_version(struct device *dev) * T6041 (M4 Pro/Max) uses its desktop IOMFB instance on 26.5.2 and * 26.6.2 firmware, where boot firmware and compatibility versions must * match. The pinned 27.2 (26B123) T6041 DCP image uses the firmware-27 - * backend on internal and external display processors. + * backend on internal and external display processors. Keep ahead of + * dcp_firmware_27() so the T6041 image UUID pin remains enforced. */ if (of_device_is_compatible(dev->of_node, "apple,t6041-dcp") || of_device_is_compatible(dev->of_node, "apple,t6041-dcpext")) { @@ -6334,6 +6322,25 @@ static enum dcp_firmware_version dcp_check_firmware_version(struct device *dev) return DCP_FIRMWARE_UNKNOWN; } + /* + * T8122 (M3 MacBook Air) internal and external DCPs pin the 27.2 + * (26B123) image UUID on firmware 27.x: any wrong or missing UUID on a + * firmware 27+ build is terminally refused rather than falling through + * to generic firmware-27 or legacy 14.x selection. + */ + if ((of_device_is_compatible(dev->of_node, "apple,t8122-dcp") || + of_device_is_compatible(dev->of_node, "apple,t8122-dcpext")) && + dcp_firmware_27(dev, &version)) { + if (apple_t8122_dcp_v27_2(dev->of_node) || + apple_t8122_dcpext_v27_2(dev->of_node)) + return version; + dev_err(dev, "T8122 display not started: unpinned 27.x DCP firmware UUID\n"); + return DCP_FIRMWARE_UNKNOWN; + } + + if (dcp_firmware_27(dev, &version)) + return version; + ret = dcp_read_fw_version(dev, "apple,firmware-compat", compat_str); if (ret < 0) { dev_err(dev, "Could not read 'apple,firmware-compat': %d\n", ret); @@ -6528,6 +6535,56 @@ VISIBLE_IF_KUNIT void dcp_enable_typec_work(struct apple_dcp *dcp) } } +static bool dcp_has_available_typec_routes(struct device_node *np) +{ + struct device_node *routes, *child; + bool avail = false; + + routes = of_get_child_by_name(np, "typec-routes"); + if (!routes) + return false; + if (of_device_is_available(routes)) { + for_each_available_child_of_node(routes, child) { + of_node_put(child); + avail = true; + break; + } + } + of_node_put(routes); + return avail; +} + +static bool dcp_is_internal_panel_only(const struct apple_dcp *dcp) +{ + struct device_node *np = dcp->dev->of_node; + + return dcp->panel_identity && !dcp->dcpext && + !of_property_present(np, "phys") && + !dcp_has_available_typec_routes(np); +} + +static u8 dcp_dart_dma_bits(struct device_node *np) +{ + struct of_phandle_args args; + u32 range[4]; + u64 base, size, end; + int ret; + + ret = of_parse_phandle_with_args(np, "iommus", "#iommu-cells", 0, &args); + if (ret) + return 0; + ret = of_property_read_u32_array(args.np, "apple,dma-range", range, 4); + of_node_put(args.np); + if (ret) + return 0; + base = ((u64)range[0] << 32) | range[1]; + size = ((u64)range[2] << 32) | range[3]; + if (!size || base + size < base) + return 0; + end = base + size - 1; + return clamp_t(u8, fls64(end), 32, 48); +} + /* * The provider clocks firmware 27 asks for by index (getClockFrequency): * apple,clock-ids, published by the boot loader from the ADT. @@ -6538,24 +6595,20 @@ static int dcp_firmware_clocks_v27(struct apple_dcp *dcp) int clocks, index, ret; /* - * T6041 device trees carry the single 712 MHz disp0 clock unless the - * boot loader publishes the two /arm-io/disp0 provider clocks - * (376 at 712 MHz and 460 at 0 Hz). Expose the same two-entry table - * when apple,clock-ids is absent so getClockFrequency(0/1) matches. - */ - /* - * The T8122 /arm-io/disp0 names the same pair (345 at 712 MHz, the - * device tree's disp0 clock, and 416 at 0 Hz). + * Internal panels whose device tree carries only the single unnamed + * disp0 clock without apple,clock-ids (T6041, T8122, T6030, T6031, + * T8112): expose the two-entry [disp0, 0 Hz] table so + * getClockFrequency(0/1) matches /arm-io/disp0. Non-panel paths or + * nodes without a single unnamed clock still require apple,clock-ids. */ if (!of_property_present(dev->of_node, "apple,clock-ids") && - (of_device_is_compatible(dev->of_node, "apple,t6041-dcp") || - of_device_is_compatible(dev->of_node, "apple,t8122-dcp"))) { - struct clk *clk = devm_clk_get_optional(dev, NULL); + dcp_is_internal_panel_only(dcp) && + !of_property_present(dev->of_node, "clock-names") && + of_count_phandle_with_args(dev->of_node, "clocks", "#clock-cells") == 1) { + struct clk *clk = devm_clk_get(dev, NULL); if (IS_ERR(clk)) return PTR_ERR(clk); - if (!clk) - return 0; dcp->firmware_clocks = devm_kcalloc(dev, 2, sizeof(*dcp->firmware_clocks), GFP_KERNEL); @@ -7924,6 +7977,7 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev) */ if (fw_compat != DCP_FIRMWARE_V_14_7 && fw_compat != DCP_FIRMWARE_V_26_6 && + fw_compat != DCP_FIRMWARE_V_27_0 && fw_compat != DCP_FIRMWARE_M4 && !of_property_present(dev->of_node, "apple,bw-scratch") && !hw->firmware_clock) @@ -8059,27 +8113,26 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev) * does not adopt. (The T8140 dcpext, whose match data does not adopt, is * refused above on anything but 26.6.2.) */ - if (fw_compat == DCP_FIRMWARE_V_27_0) - dcp->hw.adopt_live_session = true; - /* - * T6041 internal panel on firmware 27 adopts the running DCP session - * with 41-bit firmware DMA addressing and no DPTX port services, - * matching the H17-generation internal-panel profile. - */ - if (fw_compat == DCP_FIRMWARE_V_27_0 && - of_device_is_compatible(dev->of_node, "apple,t6041-dcp")) { - dcp->hw.firmware_dma_bits = 41; - dcp->hw.num_dptx_ports = 0; + if (fw_compat == DCP_FIRMWARE_V_27_0) { dcp->hw.adopt_live_session = true; + /* + * Derive firmware DMA width from the DCP DART aperture when + * match data does not already pin a hardware profile width. + */ + if (!dcp->hw.firmware_dma_bits) { + u8 dma_bits = dcp_dart_dma_bits(dev->of_node); + + if (dma_bits) + dcp->hw.firmware_dma_bits = dma_bits; + } } /* - * The same for the T8122 internal panel on firmware 27: its DART - * window is 0x100_0000_0000 + 64 GiB, and dcpext drives the external - * ports. + * Internal laptop panels on firmware 27 (an internal DCP with a panel + * child and no external DPTX/Type-C routes): the boot loader hands the + * panel over running and it has no DP port. */ if (fw_compat == DCP_FIRMWARE_V_27_0 && - of_device_is_compatible(dev->of_node, "apple,t8122-dcp")) { - dcp->hw.firmware_dma_bits = 41; + dcp_is_internal_panel_only(dcp)) { dcp->hw.num_dptx_ports = 0; dcp->hw.adopt_live_session = true; } @@ -8093,14 +8146,16 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev) */ if (fw_compat == DCP_FIRMWARE_V_27_0 && of_device_is_compatible(dev->of_node, "apple,t8122-dcpext")) { - dcp->hw.firmware_dma_bits = 41; + if (!dcp->hw.firmware_dma_bits) + dcp->hw.firmware_dma_bits = 41; dcp->hw.num_dptx_ports = 2; dcp->hw.fw_14_7_endpoints = false; dcp->hw.adopt_live_session = false; } if (fw_compat == DCP_FIRMWARE_V_27_0 && of_device_is_compatible(dev->of_node, "apple,t6041-dcpext")) { - dcp->hw.firmware_dma_bits = 41; + if (!dcp->hw.firmware_dma_bits) + dcp->hw.firmware_dma_bits = 41; dcp->hw.num_dptx_ports = 2; dcp->hw.adopt_live_session = true; dcp->hw.sink_metadata_edid = true; diff --git a/include/linux/soc/apple/display.h b/include/linux/soc/apple/display.h index c0ae42df744cd..86a12be7bc1c9 100644 --- a/include/linux/soc/apple/display.h +++ b/include/linux/soc/apple/display.h @@ -93,11 +93,11 @@ static inline bool apple_t8122_dcp_v27_2(const struct device_node *np) * DCP's region). So it qualifies when both of its own are 27.2.0 and the * internal DCP was handed over on the 27.2 image. */ -static inline bool apple_t8122_dcpext_v27_2(const struct device_node *np) +static inline bool +apple_t8122_dcpext_v27_2_for_internal(const struct device_node *np, + const struct device_node *internal_dcp) { - struct device_node *dcp; u32 fw[3], compat[3]; - bool internal; if (!np || !of_device_is_compatible(np, "apple,t8122-dcpext") || of_property_count_u32_elems(np, "apple,firmware-version") != 3 || @@ -108,8 +108,19 @@ static inline bool apple_t8122_dcpext_v27_2(const struct device_node *np) compat[0] != 27 || compat[1] != 2 || compat[2] != 0) return false; + return apple_t8122_dcp_v27_2(internal_dcp); +} + +static inline bool apple_t8122_dcpext_v27_2(const struct device_node *np) +{ + struct device_node *dcp; + bool internal; + + if (!np || !of_device_is_compatible(np, "apple,t8122-dcpext")) + return false; + dcp = of_find_compatible_node(NULL, NULL, "apple,t8122-dcp"); - internal = apple_t8122_dcp_v27_2(dcp); + internal = apple_t8122_dcpext_v27_2_for_internal(np, dcp); of_node_put(dcp); return internal; } From 2737d4be66618291a785aedf0c0953fa4e17d039 Mon Sep 17 00:00:00 2001 From: Dj <43033058+DjDeveloperr@users.noreply.github.com> Date: Wed, 25 Nov 2026 00:49:53 -0500 Subject: [PATCH 5/8] arm64: dts: apple: wire the T6030 DCP bandwidth scratch slot The internal display uses slot 1 in the PMGR bandwidth window for bandwidth requests on firmware 27.2. Point the DCP at that slot in disp-5 so the driver can resolve the scratch register. Signed-off-by: Dj <43033058+DjDeveloperr@users.noreply.github.com> --- arch/arm64/boot/dts/apple/t6030-dcp.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t6030-dcp.dtsi b/arch/arm64/boot/dts/apple/t6030-dcp.dtsi index c2324b1083a61..511ebabee55b3 100644 --- a/arch/arm64/boot/dts/apple/t6030-dcp.dtsi +++ b/arch/arm64/boot/dts/apple/t6030-dcp.dtsi @@ -87,6 +87,8 @@ <0x2 0x8e850000 0x0 0x4000>; power-domains = <&ps_disp_cpu>; clocks = <&clk_disp0>; + /* Display bandwidth request slot in the disp-5 window. */ + apple,bw-scratch = <&pmgr_dcp 0 5 0x988>; #address-cells = <2>; #size-cells = <2>; ranges; @@ -97,6 +99,12 @@ }; }; + pmgr_dcp: power-management@3503d0000 { + reg = <0x3 0x503d0000 0x0 0x4000>; + reg-names = "dcp-fw-pmgr"; + #apple,bw-scratch-cells = <3>; + }; + dcpext_dart: iommu@2d130c000 { compatible = "apple,t6030-dart", "apple,t8110-dart"; reg = <0x2 0xd130c000 0x0 0x4000>; From 15841a22b2de928a71407416579ac79fb872b168 Mon Sep 17 00:00:00 2001 From: Dj <43033058+DjDeveloperr@users.noreply.github.com> Date: Wed, 25 Nov 2026 02:12:38 -0500 Subject: [PATCH 6/8] selftests: apple-dcp: exercise full v27 firmware admission The T6041 host test omits helpers now needed by the firmware selector. The T8122 dcpext test omits the new internal-image helper and extracts the legacy branch, which valid 27.2 firmware returns before reaching. Use the complete selector and its firmware-27 dependencies in both tests. Verify that the pinned images are admitted, that bad UUIDs and builds are refused before any fallback, and that legacy firmware still selects its corresponding backend. Signed-off-by: Dj <43033058+DjDeveloperr@users.noreply.github.com> --- .../selftests/drivers/gpu/apple-dcp/boot.py | 181 +++++++++--------- .../selftests/drivers/gpu/apple-dcp/run.py | 2 +- 2 files changed, 90 insertions(+), 93 deletions(-) diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py b/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py index 28533a70b2292..e6ff1f887d88d 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py @@ -196,25 +196,41 @@ def syslog(root): ''' -def _v27_prelude(root, helpers): - """Host stand-ins for the OF and DCP calls, then the production display.h - helpers named in @helpers, the firmware-27 method tables and - dcp_v27_method_table().""" +def _v27_prelude(root): + """Host stand-ins for OF and legacy board checks, then the live selector.""" display_h = (root / 'include/linux/soc/apple/display.h').read_text() uuid_defines = [line for line in display_h.splitlines() if line.startswith(('#define APPLE_T6041_DCP_26B123_UUID ', '#define APPLE_T8122_DCP_26B123_UUID '))] assert len(uuid_defines) == 2 - helper = '\n'.join((*uuid_defines, *( - block(display_h, 'static inline bool ' + name + '(') for name in helpers))) + helpers = ('static inline bool apple_dcp_image_v27_2(', + 'static inline bool apple_t6041_dcp_any_v27_2(', + 'static inline bool apple_t6041_dcp_v27_2(', + 'static inline bool apple_t6041_dcpext_v27_2(', + 'static inline bool apple_t8122_dcp_v27_2(', + 'static inline bool\napple_t8122_dcpext_v27_2_for_internal(', + 'static inline bool apple_t8122_dcpext_v27_2(') + helper = '\n'.join((*uuid_defines, *(block(display_h, marker) for marker in helpers))) iomfb_h = (root / 'drivers/gpu/drm/apple/iomfb.h').read_text() methods_decl = iomfb_h[iomfb_h.index('enum dcpep_method {'): iomfb_h.index('#define IOMFB_MAX_CB')] v27_c = (root / 'drivers/gpu/drm/apple/iomfb_v27.c').read_text() v27_tables = v27_c[v27_c.index('static const struct dcp_method_entry dcp_methods_27_0'): v27_c.index('/* The template\'s calls resolve through')] - dcp_c = (root / 'drivers/gpu/drm/apple/dcp.c').read_text() - method_table = block(dcp_c, 'static enum dcp_firmware_version dcp_v27_method_table(') + apple = root / 'drivers/gpu/drm/apple' + dcp_c = (apple / 'dcp.c').read_text() + version_defs = '\n'.join(line for line in dcp_c.splitlines() + if line.startswith('#define DCP_FW_VERSION_')) + version_enum = block((apple / 'version_utils.h').read_text(), + 'enum dcp_firmware_version {') + ';' + admission_enum = block((apple / 'dcp.h').read_text(), 'enum dcp_v27_admission {') + ';' + selector = '\n'.join(block(dcp_c, marker) for marker in ( + 'static int dcp_read_fw_version(', + 'static enum dcp_firmware_version dcp_v27_method_table(', + 'enum dcp_v27_admission dcp_v27_admission(', + 'static bool dcp_firmware_27(', + 'static enum dcp_firmware_version dcp_check_firmware_version(', + )) return r''' #include #include @@ -224,20 +240,16 @@ def _v27_prelude(root, helpers): #include #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) typedef uint32_t u32; -enum dcp_firmware_version { - DCP_FIRMWARE_UNKNOWN, - DCP_FIRMWARE_V_26_6_DESKTOP, - DCP_FIRMWARE_V_27_0, -}; +''' + version_defs + '\n' + version_enum + '\n' + admission_enum + r''' struct dcp_v14_board; struct apple_dcp_hw_data { enum dcp_firmware_version firmware_compat; }; struct device_node { const char *compatible; const char *uuid; int uuid_count; - u32 fw[3]; + u32 fw[DCP_FW_VERSION_MAX_LEN]; int fw_cells; - u32 compat[3]; + u32 compat[DCP_FW_VERSION_MAX_LEN]; int compat_cells; }; struct device { @@ -248,11 +260,11 @@ def _v27_prelude(root, helpers): { return np && np->compatible && !strcmp(np->compatible, s); } -/* The tree's display processors, for of_find_compatible_node(); unused by some units. */ +/* The tree's display processors, for of_find_compatible_node(). */ static struct device_node *of_nodes[2]; static int of_node_refs; -__attribute__((unused)) static struct device_node *of_find_compatible_node(struct device_node *from, - const char *type, const char *s) +static struct device_node *of_find_compatible_node(struct device_node *from, + const char *type, const char *s) { assert(!from && !type); for (unsigned i = 0; i < 2; i++) @@ -262,7 +274,7 @@ def _v27_prelude(root, helpers): } return NULL; } -__attribute__((unused)) static void of_node_put(struct device_node *np) +static void of_node_put(struct device_node *np) { if (np) assert(of_node_refs-- > 0); @@ -290,29 +302,30 @@ def _v27_prelude(root, helpers): return np->compat_cells; return -1; } -static int of_property_read_u32_array(const struct device_node *np, const char *name, u32 *out, size_t n) +static int of_property_read_variable_u32_array(const struct device_node *np, const char *name, + u32 *out, int min, int max) { + int cells = of_property_count_u32_elems(np, name); const u32 *src; - int cells; - if (!np || n != 3) - return -1; - if (!strcmp(name, "apple,firmware-version")) { - src = np->fw; - cells = np->fw_cells; - } else if (!strcmp(name, "apple,firmware-compat")) { - src = np->compat; - cells = np->compat_cells; - } else { - return -1; - } - if (cells != 3) - return -1; - memcpy(out, src, 3 * sizeof(u32)); - return 0; + + if (cells < min || cells > max) + return -EINVAL; + src = !strcmp(name, "apple,firmware-version") ? np->fw : np->compat; + memcpy(out, src, cells * sizeof(*out)); + return cells; +} +static int of_property_read_u32_array(const struct device_node *np, const char *name, u32 *out, int n) +{ + int ret = of_property_read_variable_u32_array(np, name, out, n, n); + + return ret < 0 ? ret : 0; } -#define DCP_FW_VERSION_STR_LEN 32 +#define scnprintf snprintf +#define strscpy(dst, src, size) snprintf((dst), (size), "%s", (src)) #define GFP_KERNEL 0 -#define dev_err(...) ((void)0) +#define dev_warn(...) ((void)0) +#define IS_ERR(ptr) false +static void dev_err(struct device *dev, const char *format, ...) {} static void *devm_kmemdup(struct device *dev, const void *src, size_t len, unsigned int gfp) { (void)dev; (void)src; (void)len; (void)gfp; @@ -322,29 +335,29 @@ def _v27_prelude(root, helpers): { return dev->hw; } -static int dcp_read_fw_version(struct device *dev, const char *name, char *out) +/* No internal board profile is present in these fixtures. */ +static bool of_property_present(struct device_node *np, const char *name) { - u32 v[3]; - if (of_property_count_u32_elems(dev->of_node, name) != 3 || - of_property_read_u32_array(dev->of_node, name, v, 3)) - return -1; - snprintf(out, DCP_FW_VERSION_STR_LEN, "%u.%u.%u", v[0], v[1], v[2]); - return 3; + assert(!strcmp(name, "apple,j613-25g83-profile")); + return false; +} +static bool apple_t8122_25g83_board(void) { return false; } +static int of_property_read_u32(struct device_node *np, const char *name, u32 *out) +{ + return -ENOENT; } -''' + helper + '\n' + methods_decl + '\n' + v27_tables + '\n' + method_table + '\n' +static const struct dcp_v14_board *iomfb_v14_7_board(struct device *dev) { return NULL; } +static const char *iomfb_v14_7_board_name(const struct dcp_v14_board *board) { return ""; } +static bool ext26; +static bool dcp_ext26_admitted(struct device_node *np) { return ext26; } +''' + helper + '\n' + methods_decl + '\n' + v27_tables + '\n' + selector + '\n' def t6041_v27_admission(root): - dcp_c = (root / 'drivers/gpu/drm/apple/dcp.c').read_text() - selector_full = block(dcp_c, 'static enum dcp_firmware_version dcp_check_firmware_version(') - cutoff = '\n\tret = dcp_read_fw_version(dev, "apple,firmware-compat", compat_str);\n\tif (ret < 0)' - selector = selector_full[:selector_full.index(cutoff)] + '\n\t(void)v14_board;\n\treturn DCP_FIRMWARE_UNKNOWN;\n}\n' - return _v27_prelude(root, ('apple_dcp_image_v27_2', - 'apple_t6041_dcp_any_v27_2', 'apple_t6041_dcp_v27_2', - 'apple_t6041_dcpext_v27_2', 'apple_t8122_dcp_v27_2')) + selector + r''' + return _v27_prelude(root) + r''' static struct device_node node; -static struct apple_dcp_hw_data hw_t6041; -static struct device dev = { .of_node = &node, .hw = &hw_t6041 }; +static const struct apple_dcp_hw_data hw; +static struct device dev = { .of_node = &node, .hw = &hw }; static void reset_t6041_26b123(bool ext) { @@ -387,10 +400,14 @@ def t6041_v27_admission(root): assert(apple_t6041_dcpext_v27_2(&node)); assert(dcp_check_firmware_version(&dev) == DCP_FIRMWARE_V_27_0); - for (unsigned ext = 0; ext < 2; ext++) { - /* Reject non-T6041 DCP compatibles. */ - reset_t6041_26b123(ext); node.compatible = "apple,t6031-dcp"; expect_rejected(); + /* A different SoC follows generic admission, without the T6041 UUID pin. */ + node.compatible = "apple,t6031-dcp"; + node.uuid_count = 0; + assert(!apple_t6041_dcp_v27_2(&node)); + assert(!apple_t6041_dcpext_v27_2(&node)); + assert(dcp_check_firmware_version(&dev) == DCP_FIRMWARE_V_27_0); + for (unsigned ext = 0; ext < 2; ext++) { /* Reject missing, multi-string, or non-26B123 firmware UUIDs (including 26B131). */ reset_t6041_26b123(ext); node.uuid_count = 0; expect_rejected(); reset_t6041_26b123(ext); node.uuid_count = 2; expect_rejected(); @@ -419,11 +436,9 @@ def t6041_v27_admission(root): } /* * The M3 Air's (T8122) internal DCP handed over with its 27.2 image runs - * the 27.2 table, on any T8122 board; its dcpext, another image, its - * 14.x image and other releases do not. + * the 27.2 table. The external processor needs the internal handoff, + * other firmware-27 images are refused and 14.7 stays on a legacy ABI. */ - static struct apple_dcp_hw_data hw_t8122; - dev.hw = &hw_t8122; reset_t6041_26b123(false); node.compatible = "apple,t8122-dcp"; node.uuid = APPLE_T8122_DCP_26B123_UUID; @@ -439,53 +454,33 @@ def t6041_v27_admission(root): assert(dcp_check_firmware_version(&dev) == DCP_FIRMWARE_UNKNOWN); node.uuid = APPLE_T8122_DCP_26B123_UUID; node.uuid_count = 0; assert(!apple_t8122_dcp_v27_2(&node)); + assert(dcp_check_firmware_version(&dev) == DCP_FIRMWARE_UNKNOWN); node.uuid_count = 2; assert(!apple_t8122_dcp_v27_2(&node)); + assert(dcp_check_firmware_version(&dev) == DCP_FIRMWARE_UNKNOWN); node.uuid_count = 1; node.fw[0] = 14; node.fw[1] = 7; node.fw[2] = 0; node.compat[0] = 14; node.compat[1] = 7; node.compat[2] = 0; assert(!apple_t8122_dcp_v27_2(&node)); - assert(dcp_check_firmware_version(&dev) == DCP_FIRMWARE_UNKNOWN); + assert(dcp_check_firmware_version(&dev) == DCP_FIRMWARE_V_14_7_TEMPLATE); node.fw[0] = 27; node.fw[1] = 2; node.fw[2] = 1; node.compat[0] = 27; node.compat[1] = 2; node.compat[2] = 1; assert(!apple_t8122_dcp_v27_2(&node)); + assert(dcp_check_firmware_version(&dev) == DCP_FIRMWARE_UNKNOWN); node.fw[2] = 0; node.compat[2] = 0; assert(apple_t8122_dcp_v27_2(&node)); - dev.hw = &hw_t6041; puts("PASS T6041 26B123 v27.2 internal/external admission, refusal controls, and desktop 26.x preservation"); - puts("PASS T8122 internal DCP on its 27.2 image alone runs the 27.2 table"); + puts("PASS T8122 internal DCP needs its 27.2 image for the 27.2 table"); return 0; } ''' def t8122_dcpext_v27_admission(root): - """apple_t8122_dcpext_v27_2() and the apple,t8122-dcpext arm of - dcp_check_firmware_version(), both as the tree has them.""" - dcp_c = (root / 'drivers/gpu/drm/apple/dcp.c').read_text() - selector = block(dcp_c, 'static enum dcp_firmware_version dcp_check_firmware_version(') - arm = block(selector, selector.index( - 'if (of_device_is_compatible(dev->of_node, "apple,t8122-dcpext")) {')) - unit = _v27_prelude(root, ('apple_dcp_image_v27_2', 'apple_t8122_dcp_v27_2', - 'apple_t8122_dcpext_v27_2')) - # The arm runs with the firmware-compat the selector read before it. - return r''' -#define DCP_FIRMWARE_H17P 0x17 -#define DCP_FIRMWARE_V_14_7_TEMPLATE 0x147 -''' + unit + r''' -static bool ext26; -static bool dcp_ext26_admitted(struct device_node *np) { (void)np; return ext26; } -static enum dcp_firmware_version t8122_dcpext_arm(struct device *dev) -{ - char compat_str[DCP_FW_VERSION_STR_LEN] = ""; - - dcp_read_fw_version(dev, "apple,firmware-compat", compat_str); - ''' + arm + r''' - return DCP_FIRMWARE_UNKNOWN; -} - + return _v27_prelude(root) + r''' static struct device_node dcp, dcpext; -static struct device dev = { .of_node = &dcpext }; +static const struct apple_dcp_hw_data hw; +static struct device dev = { .of_node = &dcpext, .hw = &hw }; static void set(u32 *v, u32 a, u32 b, u32 c) { v[0] = a; v[1] = b; v[2] = c; } @@ -509,7 +504,7 @@ def t8122_dcpext_v27_admission(root): static void expect(bool v27_2, enum dcp_firmware_version want) { assert(apple_t8122_dcpext_v27_2(&dcpext) == v27_2); - assert(t8122_dcpext_arm(&dev) == want); + assert(dcp_check_firmware_version(&dev) == want); assert(!of_node_refs); } @@ -546,14 +541,16 @@ def t8122_dcpext_v27_admission(root): expect(false, DCP_FIRMWARE_UNKNOWN); reset(); dcpext.fw_cells = 0; expect(false, DCP_FIRMWARE_UNKNOWN); reset(); dcpext.compat_cells = 4; expect(false, DCP_FIRMWARE_UNKNOWN); + /* A 27.x refusal is terminal even if the legacy gate would admit it. */ + reset(); ext26 = true; dcp.uuid_count = 0; expect(false, DCP_FIRMWARE_UNKNOWN); puts("PASS T8122 dcpext 27.2 refuses other or malformed versions"); /* The 14.7 template and the native 26.x path are as before. */ reset(); set(dcpext.fw, 14, 7, 0); set(dcpext.compat, 14, 7, 0); expect(false, DCP_FIRMWARE_V_14_7_TEMPLATE); - reset(); ext26 = true; expect(true, DCP_FIRMWARE_H17P); reset(); set(dcpext.fw, 26, 6, 2); set(dcpext.compat, 26, 6, 2); expect(false, DCP_FIRMWARE_UNKNOWN); + ext26 = true; expect(false, DCP_FIRMWARE_H17P); puts("PASS T8122 dcpext 14.7.0 keeps the template, native 26.x keeps H17P"); return 0; } diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/run.py b/tools/testing/selftests/drivers/gpu/apple-dcp/run.py index f62924a6d8443..7dd5ba9affd9b 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/run.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/run.py @@ -93,7 +93,7 @@ def main(): ('boot', 'oslog-events', boot.oslog, ((),), ()), ('boot', 'syslog-policy', boot.syslog, ((),), ()), ('boot', 't6041-v27-admission', boot.t6041_v27_admission, ((),), ()), - ('boot', 't8122-dcpext-v27-admission', boot.t8122_dcpext_v27_admission, ((),), ('-Wno-unused-function',)), + ('boot', 't8122-dcpext-v27-admission', boot.t8122_dcpext_v27_admission, ((),), ()), ('boot', 'v27-tag-translation', boot.v27_tag_translation, ((),), ()), ('edid', 'dpavserv-start', edid.startup, ((),), ()), ('edid', 'service-rebind', edid.rebind, ((),), ()), From 030b3844c926fad13af1876fc70228455b1228d4 Mon Sep 17 00:00:00 2001 From: Dj <43033058+DjDeveloperr@users.noreply.github.com> Date: Wed, 25 Nov 2026 04:06:00 -0500 Subject: [PATCH 7/8] drm/apple: require a bootloader handoff for generic v27 DCP adoption Firmware 27 and a panel child describe the interface and port layout. They can also be present on a cold DCP. Inferring a running session from either makes the driver refuse to start that processor. Keep the RTKit session handoff check. For firmware 27, also accept the single-cell marker that the bootloader sets to 1 on an internal DCP after validating the running processor and its DARTs. Select the marker from the DCP match data. This lets the J516s keep its iBoot display without implying that the bootloader already negotiated RTKit. Derive DMA width and panel port count independently. Exercise marked and cold probes across the four internal profiles, including zero and foreign markers. Signed-off-by: Dj <43033058+DjDeveloperr@users.noreply.github.com> --- drivers/gpu/drm/apple/dcp-internal.h | 2 + drivers/gpu/drm/apple/dcp.c | 64 ++++++------- .../selftests/drivers/gpu/apple-dcp/boot.py | 92 +++++++++++++++++++ .../selftests/drivers/gpu/apple-dcp/run.py | 1 + 4 files changed, 124 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp-internal.h b/drivers/gpu/drm/apple/dcp-internal.h index cb77aa8eabd5a..24dbe1812727e 100644 --- a/drivers/gpu/drm/apple/dcp-internal.h +++ b/drivers/gpu/drm/apple/dcp-internal.h @@ -322,6 +322,8 @@ struct apple_dcp_hw_data { * standard RTKit wake instead of starting or restarting the ASC. */ bool adopt_live_session; + /* Bootloader property marking this DCP as running under iBoot. */ + const char *iboot_handoff; enum dcp_firmware_version firmware_compat; /* Firmware-visible clock aperture, independent of the AP PMGR window. */ const struct resource *firmware_clock; diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 0db75e9b22217..fa6a9f824ce9d 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -6585,6 +6585,30 @@ static u8 dcp_dart_dma_bits(struct device_node *np) return clamp_t(u8, fls64(end), 32, 48); } +static void dcp_apply_dt_profile(struct apple_dcp *dcp) +{ + struct device_node *np = dcp->dev->of_node; + u32 running; + + if (of_property_present(np, "apple,rtkit-handoff")) + dcp->hw.adopt_live_session = true; + + if (dcp->fw_compat != DCP_FIRMWARE_V_27_0) + return; + + /* iBoot can leave the ASC running without negotiating RTKit. */ + if (dcp->hw.iboot_handoff && + of_property_read_variable_u32_array(np, dcp->hw.iboot_handoff, + &running, 1, 1) == 1 && + running == 1) + dcp->hw.adopt_live_session = true; + + if (!dcp->hw.firmware_dma_bits) + dcp->hw.firmware_dma_bits = dcp_dart_dma_bits(np); + if (dcp_is_internal_panel_only(dcp)) + dcp->hw.num_dptx_ports = 0; +} + /* * The provider clocks firmware 27 asks for by index (getClockFrequency): * apple,clock-ids, published by the boot loader from the ADT. @@ -8091,9 +8115,7 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev) if (ret) return ret; dcp->hw = *(struct apple_dcp_hw_data *)of_device_get_match_data(dev); - /* A boot stage handed this DCP over running: keep its session. */ - if (of_property_present(dev->of_node, "apple,rtkit-handoff")) - dcp->hw.adopt_live_session = true; + dcp_apply_dt_profile(dcp); /* The link report: on the board it has run on (dcp_j714s_ext()). */ if (!dcp_j714s_ext(dev)) dcp->hw.link_report = false; @@ -8104,38 +8126,6 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev) if (fw_compat == DCP_FIRMWARE_V_27_0 && of_device_is_compatible(dev->of_node, "apple,t8142-dcp")) dcp->hw.iomfb_method_profile = DCP_IOMFB_METHODS_DEFAULT; - /* - * Every processor on firmware 27 inherits the live session the boot - * loader handed over. Its match data keeps the per-SoC port count, - * tunnel-flow flag and DART resources; only the session adoption follows - * the firmware. The per-SoC firmware-27 profiles below come after it and - * may override it: the T8122 dcpext, which the loader leaves unpowered, - * does not adopt. (The T8140 dcpext, whose match data does not adopt, is - * refused above on anything but 26.6.2.) - */ - if (fw_compat == DCP_FIRMWARE_V_27_0) { - dcp->hw.adopt_live_session = true; - /* - * Derive firmware DMA width from the DCP DART aperture when - * match data does not already pin a hardware profile width. - */ - if (!dcp->hw.firmware_dma_bits) { - u8 dma_bits = dcp_dart_dma_bits(dev->of_node); - - if (dma_bits) - dcp->hw.firmware_dma_bits = dma_bits; - } - } - /* - * Internal laptop panels on firmware 27 (an internal DCP with a panel - * child and no external DPTX/Type-C routes): the boot loader hands the - * panel over running and it has no DP port. - */ - if (fw_compat == DCP_FIRMWARE_V_27_0 && - dcp_is_internal_panel_only(dcp)) { - dcp->hw.num_dptx_ports = 0; - dcp->hw.adopt_live_session = true; - } /* * The T8122 external processor on firmware 27: the boot loader leaves * it unpowered (its DISPEXT domains are off at handoff), so Linux @@ -10981,15 +10971,18 @@ static const struct apple_dcp_hw_data apple_dcp_hw_dcp = { }; static const struct apple_dcp_hw_data apple_dcp_hw_t6030 = { + .iboot_handoff = "apple,t6030-handoff", .num_dptx_ports = 1, }; static const struct apple_dcp_hw_data apple_dcp_hw_t8122 = { + .iboot_handoff = "apple,t8122-handoff", .num_dptx_ports = 2, }; /* The internal panel only, through the 14.x IOMFB, as on T6030. */ static const struct apple_dcp_hw_data apple_dcp_hw_t6031 = { + .iboot_handoff = "apple,t6031-handoff", .num_dptx_ports = 1, }; @@ -11022,6 +11015,7 @@ static const struct apple_dcp_hw_data apple_dcp_hw_t8132_dcpext = { /* T6041 (M4 Pro/Max), desktop 26.6 firmware */ static const struct apple_dcp_hw_data apple_dcp_hw_t6041 = { + .iboot_handoff = "apple,t6041-handoff", .num_dptx_ports = 2, }; diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py b/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py index e6ff1f887d88d..74a7a11da1940 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py @@ -353,6 +353,98 @@ def _v27_prelude(root): ''' + helper + '\n' + methods_decl + '\n' + v27_tables + '\n' + selector + '\n' +def v27_panel_handoff(root): + source = (root / 'drivers/gpu/drm/apple/dcp.c').read_text() + profiles = ('t6030', 't8122', 't6031', 't6041') + match = '\n'.join(block(source, f'static const struct apple_dcp_hw_data apple_dcp_hw_{soc} =') + + ';' for soc in profiles) + profile = block(source, 'static void dcp_apply_dt_profile(') + return r''' +#include +#include +#include +#include +typedef uint8_t u8; +typedef uint32_t u32; +enum { DCP_FIRMWARE_V_27_0 = 27 }; +struct device_node { + bool rtkit_handoff; + const char *marker; + u32 value; +}; +struct device { struct device_node *of_node; }; +struct apple_dcp_hw_data { + bool adopt_live_session; + const char *iboot_handoff; + unsigned num_dptx_ports; + u8 firmware_dma_bits; +}; +struct apple_dcp { + struct device *dev; + struct apple_dcp_hw_data hw; + int fw_compat; +}; +static bool of_property_present(struct device_node *np, const char *name) +{ + assert(!strcmp(name, "apple,rtkit-handoff")); + return np->rtkit_handoff; +} +static int of_property_read_variable_u32_array(struct device_node *np, const char *name, + u32 *value, int min, int max) +{ + assert(min == 1 && max == 1); + if (!np->marker || strcmp(name, np->marker)) + return -1; + *value = np->value; + return 1; +} +/* All probes see the same DART aperture and panel-only topology. */ +static u8 dcp_dart_dma_bits(struct device_node *np) { return 41; } +static bool dcp_is_internal_panel_only(struct apple_dcp *dcp) { return true; } +''' + match + '\n' + profile + r''' +static void check(struct apple_dcp_hw_data hw, struct device_node node, bool live) +{ + struct device dev = { .of_node = &node }; + struct apple_dcp dcp = { .dev = &dev, .hw = hw, .fw_compat = DCP_FIRMWARE_V_27_0 }; + + dcp_apply_dt_profile(&dcp); + assert(dcp.hw.adopt_live_session == live); + assert(dcp.hw.firmware_dma_bits == 41); + assert(dcp.hw.num_dptx_ports == 0); +} + +int main(void) +{ + const struct { + const struct apple_dcp_hw_data *hw; + const char *marker; + } panels[] = { + { &apple_dcp_hw_t6030, "apple,t6030-handoff" }, + { &apple_dcp_hw_t8122, "apple,t8122-handoff" }, + { &apple_dcp_hw_t6031, "apple,t6031-handoff" }, + { &apple_dcp_hw_t6041, "apple,t6041-handoff" }, + }; + + for (unsigned i = 0; i < sizeof(panels) / sizeof(panels[0]); i++) { + struct apple_dcp_hw_data hw = *panels[i].hw; + struct device_node node = {}; + + check(hw, node, false); + node.rtkit_handoff = true; + check(hw, node, true); + node.rtkit_handoff = false; + node.marker = panels[i].marker; + check(hw, node, false); + node.value = 1; + check(hw, node, true); + node.marker = panels[i ? 0 : 1].marker; + check(hw, node, false); + } + return 0; +} +''' + + def t6041_v27_admission(root): return _v27_prelude(root) + r''' static struct device_node node; diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/run.py b/tools/testing/selftests/drivers/gpu/apple-dcp/run.py index 7dd5ba9affd9b..2d111c5bed964 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/run.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/run.py @@ -92,6 +92,7 @@ def main(): ('m4', 'm4-panel-timing', m4.timing, ((),), ('-Wno-unused-function', '-Wno-unused-const-variable')), ('boot', 'oslog-events', boot.oslog, ((),), ()), ('boot', 'syslog-policy', boot.syslog, ((),), ()), + ('boot', 'v27-panel-handoff', boot.v27_panel_handoff, ((),), ()), ('boot', 't6041-v27-admission', boot.t6041_v27_admission, ((),), ()), ('boot', 't8122-dcpext-v27-admission', boot.t8122_dcpext_v27_admission, ((),), ()), ('boot', 'v27-tag-translation', boot.v27_tag_translation, ((),), ()), From 5a86f018f9d78a503d1ac93b9841d70e0f37de2b Mon Sep 17 00:00:00 2001 From: Dj <43033058+DjDeveloperr@users.noreply.github.com> Date: Wed, 25 Nov 2026 07:21:50 -0500 Subject: [PATCH 8/8] drm/apple: allocate dcp_firmware_27_pin_precedence fixture with kunit_kzalloc Keep the mock device, device nodes, and property arrays off the stack in dcp_firmware_27_pin_precedence() so arm64 GCC builds with CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST enabled stay well under the 2,048-byte frame-size limit (272 bytes vs 2,144 bytes). Signed-off-by: Dj <43033058+DjDeveloperr@users.noreply.github.com> --- drivers/gpu/drm/apple/dcp-firmware-test.c | 195 +++++++++++++--------- 1 file changed, 113 insertions(+), 82 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp-firmware-test.c b/drivers/gpu/drm/apple/dcp-firmware-test.c index 9a51e23fb6b7f..1b411f88c84f7 100644 --- a/drivers/gpu/drm/apple/dcp-firmware-test.c +++ b/drivers/gpu/drm/apple/dcp-firmware-test.c @@ -124,131 +124,162 @@ static void dcp_firmware_27_pin_precedence(struct kunit *test) __be32 compat_27_1[] = { cpu_to_be32(27), cpu_to_be32(1), 0 }; __be32 compat_27_2[] = { cpu_to_be32(27), cpu_to_be32(2), 0 }; __be32 compat_27_3[] = { cpu_to_be32(27), cpu_to_be32(3), 0 }; - struct property props[] = { - { .name = "apple,firmware-compat", .length = sizeof(compat_27_2), - .value = compat_27_2, .next = &props[1] }, - { .name = "apple,firmware-version", .length = sizeof(compat_27_2), - .value = compat_27_2, .next = &props[2] }, - { .name = "apple,firmware-uuid", .length = sizeof(bad_uuid), - .value = (void *)bad_uuid, .next = &props[3] }, - { .name = "compatible", .length = sizeof(t6030), - .value = (void *)t6030 }, + struct dcp_pin_precedence_fixture { + struct property props[4]; + struct property ext_props[3]; + struct device_node node; + struct device_node ext_node; + struct device dev; + } *fx; + + fx = kunit_kzalloc(test, sizeof(*fx), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, fx); + + fx->props[0] = (struct property) { + .name = "apple,firmware-compat", + .length = sizeof(compat_27_2), + .value = compat_27_2, + .next = &fx->props[1], }; - struct property ext_props[] = { - { .name = "apple,firmware-compat", .length = sizeof(compat_27_2), - .value = compat_27_2, .next = &ext_props[1] }, - { .name = "apple,firmware-version", .length = sizeof(compat_27_2), - .value = compat_27_2, .next = &ext_props[2] }, - { .name = "compatible", .length = sizeof(t8122_ext), - .value = (void *)t8122_ext }, + fx->props[1] = (struct property) { + .name = "apple,firmware-version", + .length = sizeof(compat_27_2), + .value = compat_27_2, + .next = &fx->props[2], }; - struct device_node node = { .properties = props }; - struct device_node ext_node = { .properties = ext_props }; - struct device dev = { - .init_name = "dcp-firmware-test", - .of_node = &node, - .driver = &apple_platform_driver.driver, + fx->props[2] = (struct property) { + .name = "apple,firmware-uuid", + .length = sizeof(bad_uuid), + .value = (void *)bad_uuid, + .next = &fx->props[3], + }; + fx->props[3] = (struct property) { + .name = "compatible", + .length = sizeof(t6030), + .value = (void *)t6030, + }; + fx->ext_props[0] = (struct property) { + .name = "apple,firmware-compat", + .length = sizeof(compat_27_2), + .value = compat_27_2, + .next = &fx->ext_props[1], + }; + fx->ext_props[1] = (struct property) { + .name = "apple,firmware-version", + .length = sizeof(compat_27_2), + .value = compat_27_2, + .next = &fx->ext_props[2], + }; + fx->ext_props[2] = (struct property) { + .name = "compatible", + .length = sizeof(t8122_ext), + .value = (void *)t8122_ext, }; + fx->node.properties = fx->props; + fx->ext_node.properties = fx->ext_props; + fx->dev.init_name = "dcp-firmware-test"; + fx->dev.of_node = &fx->node; + fx->dev.driver = &apple_platform_driver.driver; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_V_27_0); - props[0].value = compat_27_3; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + fx->props[0].value = compat_27_3; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_UNKNOWN); - props[0].value = compat_27_2; + fx->props[0].value = compat_27_2; /* T6041 internal and external UUID pins remain enforced on 27.2. */ - props[3].length = sizeof(t6041); - props[3].value = (void *)t6041; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + fx->props[3].length = sizeof(t6041); + fx->props[3].value = (void *)t6041; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_UNKNOWN); - props[2].length = sizeof(APPLE_T6041_DCP_26B123_UUID); - props[2].value = (void *)APPLE_T6041_DCP_26B123_UUID; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + fx->props[2].length = sizeof(APPLE_T6041_DCP_26B123_UUID); + fx->props[2].value = (void *)APPLE_T6041_DCP_26B123_UUID; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_V_27_0); - props[3].length = sizeof(t6041_ext); - props[3].value = (void *)t6041_ext; - props[2].length = sizeof(bad_uuid); - props[2].value = (void *)bad_uuid; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + fx->props[3].length = sizeof(t6041_ext); + fx->props[3].value = (void *)t6041_ext; + fx->props[2].length = sizeof(bad_uuid); + fx->props[2].value = (void *)bad_uuid; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_UNKNOWN); - props[2].name = "apple,unrelated"; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + fx->props[2].name = "apple,unrelated"; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_UNKNOWN); - props[2].name = "apple,firmware-uuid"; - props[2].length = sizeof(APPLE_T6041_DCP_26B123_UUID); - props[2].value = (void *)APPLE_T6041_DCP_26B123_UUID; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + fx->props[2].name = "apple,firmware-uuid"; + fx->props[2].length = sizeof(APPLE_T6041_DCP_26B123_UUID); + fx->props[2].value = (void *)APPLE_T6041_DCP_26B123_UUID; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_V_27_0); /* T8122 wrong or missing 27.2 UUID is terminally refused (never takes generic v27). */ - props[3].length = sizeof(t8122); - props[3].value = (void *)t8122; - props[2].name = "apple,firmware-uuid"; - props[2].length = sizeof(bad_uuid); - props[2].value = (void *)bad_uuid; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + fx->props[3].length = sizeof(t8122); + fx->props[3].value = (void *)t8122; + fx->props[2].name = "apple,firmware-uuid"; + fx->props[2].length = sizeof(bad_uuid); + fx->props[2].value = (void *)bad_uuid; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_UNKNOWN); KUNIT_EXPECT_FALSE(test, - apple_t8122_dcpext_v27_2_for_internal(&ext_node, &node)); + apple_t8122_dcpext_v27_2_for_internal(&fx->ext_node, &fx->node)); - props[2].name = "apple,unrelated"; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + fx->props[2].name = "apple,unrelated"; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_UNKNOWN); KUNIT_EXPECT_FALSE(test, - apple_t8122_dcpext_v27_2_for_internal(&ext_node, &node)); + apple_t8122_dcpext_v27_2_for_internal(&fx->ext_node, &fx->node)); - props[2].name = "apple,firmware-uuid"; - props[2].length = sizeof(APPLE_T8122_DCP_26B123_UUID); - props[2].value = (void *)APPLE_T8122_DCP_26B123_UUID; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + fx->props[2].name = "apple,firmware-uuid"; + fx->props[2].length = sizeof(APPLE_T8122_DCP_26B123_UUID); + fx->props[2].value = (void *)APPLE_T8122_DCP_26B123_UUID; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_V_27_0); KUNIT_EXPECT_TRUE(test, - apple_t8122_dcpext_v27_2_for_internal(&ext_node, &node)); + apple_t8122_dcpext_v27_2_for_internal(&fx->ext_node, &fx->node)); /* T8122 external with mismatched version is terminally refused regardless of live tree. */ - ext_props[1].value = compat_27_0; + fx->ext_props[1].value = compat_27_0; KUNIT_EXPECT_FALSE(test, - apple_t8122_dcpext_v27_2_for_internal(&ext_node, &node)); - dev.of_node = &ext_node; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + apple_t8122_dcpext_v27_2_for_internal(&fx->ext_node, &fx->node)); + fx->dev.of_node = &fx->ext_node; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_UNKNOWN); - ext_props[1].value = compat_27_2; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), - apple_t8122_dcpext_v27_2(&ext_node) ? + fx->ext_props[1].value = compat_27_2; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), + apple_t8122_dcpext_v27_2(&fx->ext_node) ? DCP_FIRMWARE_V_27_0 : DCP_FIRMWARE_UNKNOWN); - dev.of_node = &node; + fx->dev.of_node = &fx->node; /* Internal T8142: known 27.x takes v27, unknown 27.x is refused (never takes H17P). */ - props[3].length = sizeof(t8142); - props[3].value = (void *)t8142; - props[0].value = compat_27_0; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + fx->props[3].length = sizeof(t8142); + fx->props[3].value = (void *)t8142; + fx->props[0].value = compat_27_0; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_V_27_0); - props[0].value = compat_27_2; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + fx->props[0].value = compat_27_2; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_V_27_0); - props[0].value = compat_27_1; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + fx->props[0].value = compat_27_1; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_UNKNOWN); - props[0].value = compat_27_3; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + fx->props[0].value = compat_27_3; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_UNKNOWN); - props[0].value = compat_26_6; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + fx->props[0].value = compat_26_6; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_H17P); - props[0].value = compat_27_2; + fx->props[0].value = compat_27_2; #if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T8132) /* T8132 keeps its M4 match-data pin on 27.2. */ - props[3].length = sizeof(t8132); - props[3].value = (void *)t8132; - KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&dev), + fx->props[3].length = sizeof(t8132); + fx->props[3].value = (void *)t8132; + KUNIT_EXPECT_EQ(test, dcp_check_firmware_version(&fx->dev), DCP_FIRMWARE_M4); #endif }