diff --git a/Documentation/devicetree/bindings/npu/apple,ane.yaml b/Documentation/devicetree/bindings/npu/apple,ane.yaml index 364a050265460..b78d29bde4330 100644 --- a/Documentation/devicetree/bindings/npu/apple,ane.yaml +++ b/Documentation/devicetree/bindings/npu/apple,ane.yaml @@ -148,11 +148,12 @@ properties: maxItems: 2 description: On T602x, the IOVA-only reservation of the firmware entry alias. - On T6041, T6050, T8132 and T8140, and on T8112 when the bootloader - hands the preload over, bootloader-provided physical TEXT - and DATA preload reservations in that order. Each reservation must have no-map, must - not be reusable, and must remain reserved until reboot. Physical - addresses vary per boot and must not be hard-coded in a board DTS. + On T6030, T6041, T6050, T8132 and T8140, and on T8112 when the + bootloader hands the preload over, bootloader-provided physical TEXT + and DATA preload reservations in that order. Each reservation must + have no-map, must not be reusable, and must remain reserved until + reboot. Physical addresses vary per boot and must not be hard-coded + in a board DTS. memory-region-names: items: @@ -584,8 +585,6 @@ allOf: power-domains: minItems: 5 maxItems: 5 - memory-region: false - memory-region-names: false apple,exclave-assigned: false required: - mboxes @@ -603,8 +602,21 @@ allOf: const: 0xc0 apple,dapf-ranges: minItems: 5 + memory-region: + minItems: 2 required: - apple,dapf-ranges + if: + anyOf: + - required: + - memory-region + - required: + - memory-region-names + then: + required: + - memory-region + - memory-region-names + - apple,firmware-iovas - if: properties: compatible: @@ -615,6 +627,8 @@ allOf: minItems: 5 apple,ane-type: const: 0xe0 + memory-region: false + memory-region-names: false apple,firmware-iovas: false apple,dapf-ranges: false diff --git a/arch/arm64/boot/dts/apple/t6030-j516s.dts b/arch/arm64/boot/dts/apple/t6030-j516s.dts index 0753e8dee8e00..9898a58ed9042 100644 --- a/arch/arm64/boot/dts/apple/t6030-j516s.dts +++ b/arch/arm64/boot/dts/apple/t6030-j516s.dts @@ -282,3 +282,19 @@ enable-gpios = <&smc_gpio 0xe GPIO_ACTIVE_HIGH>; }; }; + +&ane_dart0 { + status = "okay"; +}; + +&ane_dart1 { + status = "okay"; +}; + +&ane_dart2 { + status = "okay"; +}; + +&ane { + status = "okay"; +}; diff --git a/arch/arm64/boot/dts/apple/t6030-peripherals.dtsi b/arch/arm64/boot/dts/apple/t6030-peripherals.dtsi index 9e3f1d7520af9..0a17f4d9f15dd 100644 --- a/arch/arm64/boot/dts/apple/t6030-peripherals.dtsi +++ b/arch/arm64/boot/dts/apple/t6030-peripherals.dtsi @@ -563,6 +563,7 @@ interrupt-parent = <&aic>; interrupts = ; iommus = <&ane_dart0 0>, <&ane_dart1 0>, <&ane_dart2 0>; + dma-coherent; power-domains = <&ps_ane_sys>, <&ps_ane_cpu>, <&ps_ane_mpm>, <&ps_ane_td>, <&ps_ane_base>; mboxes = <&ane_mbox>; @@ -575,7 +576,7 @@ /bits/ 64 <0x2c9468000 0x2c9468003>, /bits/ 64 <0x292468000 0x292468003>; /* Default layout; the loader supplies per-boot physical reservations. */ - apple,firmware-iovas = /bits/ 64 <0x10000000000 0x100000b0000>; + apple,firmware-iovas = /bits/ 64 <0x10000000000 0x100000c8000>; status = "disabled"; }; }; diff --git a/drivers/accel/ane/ane_fw_platform.c b/drivers/accel/ane/ane_fw_platform.c index 996d6ed8046c8..dfc53778d13f9 100644 --- a/drivers/accel/ane/ane_fw_platform.c +++ b/drivers/accel/ane/ane_fw_platform.c @@ -47,6 +47,20 @@ static const u32 ane_t8122_power_words[] = { 0x438, 0xc008, 0xc000, 0xc010, 0xc018, }; +/* T6030 (M3 Pro) H15: six ADT windows (no second engine aux-3). */ +static const char * const ane_t6030_reg_names[] = { + "engine", "pmgr", "aux-0", "aux-1", "aux-2", "aux-4", +}; + +static const u32 ane_t6030_reg_sizes[] = { + 0x2000000, 0x18000, 0x4000, 0x24000, 0xf74000, 0x4000, +}; + +/* The same five domains; ANE_SYS sits at +0x498 in the T6030 PMGR. */ +static const u32 ane_t6030_power_words[] = { + 0x498, 0xc008, 0xc000, 0xc010, 0xc018, +}; + /* T8112 (M2): the legacy H14 windows: engine, PMGR, power gate set, fuse. */ static const char * const ane_t8112_reg_names[] = { "engine", "pmgr", "set", "fuse", @@ -194,18 +208,59 @@ const struct ane_fw_platform ane_t8112_platform = { }; /* - * M3 Pro (T6030) and M3 Max (T6031, also the T6034 package and both dies of - * T6032): the H15 engine, preloaded like T8122. T6030 DAPF records, PWGATE - * sequencing (aux-0 + 0x2b6c), 7 MiB firmware span, and J514s preload pin are - * captured and verified through cold-boot READY; full backend qualification - * lands separately, so the platform stays unqualified here: preflight refuses - * the start before resources, power or MMIO, logs the refusal, and leaves the - * engine idle. + * M3 Pro (T6030): H15 engine running the macOS 27.2 (26B123) firmware on the + * shared H16 backend, matching T8122 with six ADT reg windows, ANE_SYS at + * PMGR +0x498, and PWGATE at aux-0 +0x2b6c on the ANE_CPU domain (index 1). + * Cold restart + program replay across sleep. */ const struct ane_fw_platform ane_t6030_platform = { - .soc = 0xc0, + .h16_profiles = ane_t6030_profiles_26b123, + .h16_profile_count = ARRAY_SIZE(ane_t6030_profiles_26b123), + .h16_mmio = ane_h15_mmio_t8122, + .h16_mmio_count = ARRAY_SIZE(ane_h15_mmio_t8122), + .dart_params = 0x8, + .dapf_dart = 0, + .dapf_offset = 0x4000, + .dapf_size = SZ_16K, + .dapf_count = 5, + .soc = 0x6030, + .chip_family = 15, + .ane_type = 0xc0, + .hwx_subtype = 6, + .task_generation = 15, + .interrupt_count = 1, + .irq_role = ANE_FW_IRQ_UNKNOWN, + .owner = ANE_FW_OWNER_AP, + .reg_names = ane_t6030_reg_names, + .reg_sizes = ane_t6030_reg_sizes, + .reg_count = ARRAY_SIZE(ane_t6030_reg_names), + .wrapper = 0x1400000, + .mailbox = 0x1408000, + .scratch = 0x1840050, + .doorbell = 0x1844000, + .irq_status = 0x184c000, + .irq_ack = 0x1850000, + .power_words = ane_t6030_power_words, + .power_count = ARRAY_SIZE(ane_t6030_power_words), + .pwgate_window = "aux-0", + .pwgate_offset = 0x2b6c, + .pwgate_domain = 1, + .build_name = "27.2 26B123", + .preload_dva = { 0x10000000000, 0x100000c8000 }, + .preload_size = { 0xc8000, 0x2a4000 }, + .stream_mask = BIT(0), + .sleep_cold = true, + .boot_qualified = true, + .firmware_preloaded = true, + .safe_reset = false, + .require_cold_boot = true, }; +/* + * M3 Max (T6031, also the T6034 package and both dies of T6032): unqualified + * until its preload pin, DAPF set and power sequencing are verified on + * hardware. + */ const struct ane_fw_platform ane_t6031_platform = { .soc = 0xe0, }; @@ -768,6 +823,10 @@ int ane_fw_platform_preflight(struct platform_device *pdev, dev_info(dev, "ANE: exclave-assigned device has no Linux ownership provider\n"); return -EOPNOTSUPP; } + if (soc->require_cold_boot && !ane_fw_raw_boot()) { + dev_info(dev, "ANE: cold-boot ownership evidence missing; refusing preload boot\n"); + return -ENODEV; + } if (!of_property_read_bool(np, "apple,firmware-preloaded") || of_property_read_u32(np, "apple,ane-type", &ane_type) || diff --git a/drivers/accel/ane/ane_fw_platform.h b/drivers/accel/ane/ane_fw_platform.h index 99720958c9190..a1b087cac09a0 100644 --- a/drivers/accel/ane/ane_fw_platform.h +++ b/drivers/accel/ane/ane_fw_platform.h @@ -90,6 +90,7 @@ struct ane_fw_platform { */ const char *pwgate_window; u32 pwgate_offset; + u8 pwgate_domain; /* * The ANE DARTs lose SID0's translation registers when the engine * powers off, and their own runtime resume runs before the ANE domains @@ -104,6 +105,13 @@ struct ane_fw_platform { bool boot_qualified; bool firmware_preloaded; bool safe_reset; + /* + * Require /chosen/apple,ane-cold-boot raw-boot evidence in preflight + * before registering the driver or acquiring ANE power (T6030: an EL1 + * handoff can populate preload reservations and IOVAs without cold-boot + * ownership). + */ + bool require_cold_boot; /* * System sleep first takes the firmware out of Exclave mode * (EXCLAVE_MODE_STOP on the control ring) so that SUSPEND can run. diff --git a/drivers/accel/ane/ane_fw_platform_test.c b/drivers/accel/ane/ane_fw_platform_test.c index a0644c7b4b219..690e78e5f230e 100644 --- a/drivers/accel/ane/ane_fw_platform_test.c +++ b/drivers/accel/ane/ane_fw_platform_test.c @@ -118,6 +118,40 @@ static void ane_t8122_platform_test(struct kunit *test) platform_device_put(pdev); } +/* M3 Pro (T6030) H15: six reg windows, aux-0 PWGATE on domain 1, five DAPF records, cold sleep. */ +static void ane_t6030_platform_test(struct kunit *test) +{ + const struct ane_fw_platform *p = &ane_t6030_platform; + struct platform_device *pdev = platform_device_alloc("ane-t6030", -1); + u64 phys[] = { 0x100000000, 0x200000000 }; + + KUNIT_ASSERT_NOT_NULL(test, pdev); + KUNIT_EXPECT_EQ(test, p->soc, 0x6030U); + KUNIT_EXPECT_EQ(test, p->chip_family, 15U); + KUNIT_EXPECT_EQ(test, p->ane_type, 0xc0U); + KUNIT_EXPECT_EQ(test, p->hwx_subtype, 6U); + KUNIT_EXPECT_EQ(test, p->reg_count, 6U); + KUNIT_EXPECT_STREQ(test, p->reg_names[2], "aux-0"); + KUNIT_EXPECT_STREQ(test, p->reg_names[5], "aux-4"); + KUNIT_EXPECT_STREQ(test, p->pwgate_window, "aux-0"); + KUNIT_EXPECT_EQ(test, p->pwgate_offset, 0x2b6cU); + KUNIT_EXPECT_EQ(test, p->pwgate_domain, 1U); + KUNIT_EXPECT_FALSE(test, p->has_xl); + KUNIT_EXPECT_EQ(test, p->dapf_dart, 0U); + KUNIT_EXPECT_EQ(test, p->dapf_offset, 0x4000U); + KUNIT_EXPECT_EQ(test, p->dapf_count, 5); + KUNIT_EXPECT_EQ(test, p->power_words[0], 0x498U); + KUNIT_EXPECT_TRUE(test, p->sleep_cold); + KUNIT_ASSERT_EQ(test, p->h16_profile_count, 1U); + KUNIT_EXPECT_STREQ(test, p->h16_profiles[0].identity, "H15 T6030 27.2 26B123 J516s"); + KUNIT_EXPECT_TRUE(test, p->require_cold_boot); + KUNIT_EXPECT_TRUE(test, ane_fw_preload_ranges_valid(p, phys, + p->preload_size, + p->preload_dva)); + KUNIT_EXPECT_EQ(test, ane_fw_platform_preflight(pdev, p), -ENODEV); + platform_device_put(pdev); +} + /* * M2 (T8112) 27.2: the legacy H14 windows and seven domains under ANE_SYS, * the "set" power gate, four DAPF records, the mailbox-owned interrupt line, @@ -309,6 +343,7 @@ static void ane_t8142_bridge_ops_test(struct kunit *test) static struct kunit_case ane_fw_platform_cases[] = { #if IS_BUILTIN(CONFIG_DRM_ACCEL_ANE) && IS_BUILTIN(CONFIG_DRM_ACCEL_ANE_FW_KUNIT_TEST) KUNIT_CASE(ane_t8122_platform_test), + KUNIT_CASE(ane_t6030_platform_test), KUNIT_CASE(ane_t8112_platform_test), KUNIT_CASE(ane_t8132_platform_test), KUNIT_CASE(ane_t8132_builds_test), diff --git a/drivers/accel/ane/ane_h16_backend.c b/drivers/accel/ane/ane_h16_backend.c index 38499e94e018e..da7ddc1bb98f2 100644 --- a/drivers/accel/ane/ane_h16_backend.c +++ b/drivers/accel/ane/ane_h16_backend.c @@ -588,7 +588,7 @@ static int ane_h16_genpd_event(struct notifier_block *nb, unsigned long action, struct ane_h16_genpd *g = container_of(nb, struct ane_h16_genpd, nb); u64 now = ktime_get_boottime_ns(); - if (g == &g->h->genpd[0] && g->h->pwgate) { + if (g == &g->h->genpd[g->h->boot.soc->pwgate_domain] && g->h->pwgate) { int ret = ane_h16_pwgate_event(g->h, action); if (ret != NOTIFY_OK && ret != NOTIFY_DONE) @@ -2247,7 +2247,7 @@ static int ane_h16_acquire(struct platform_device *pdev, struct ane_h16_device * if (h->pwgate) { h->genpd[h->powered].added = !dev_pm_genpd_add_notifier(pd, &h->genpd[h->powered].nb); - if (!i && !h->genpd[h->powered].added) { + if (i == h->boot.soc->pwgate_domain && !h->genpd[h->powered].added) { dev_pm_domain_detach(pd, true); return -EBUSY; } diff --git a/drivers/accel/ane/ane_h16_boot_data.h b/drivers/accel/ane/ane_h16_boot_data.h index 76d65991f2403..6bed6899416c2 100644 --- a/drivers/accel/ane/ane_h16_boot_data.h +++ b/drivers/accel/ane/ane_h16_boot_data.h @@ -708,6 +708,42 @@ static const struct ane_h16_profile ane_t8122_profiles_26b123[] __maybe_unused = }, }; +/* + * M3 Pro (J516s) 27.2 (26B123) preload: TEXT 0xc8000, DATA 0x2a4000. + * Same patchbay cell shape as T8122 (GKTS, ECAP, ARcM mutable; ABOI, ZSOI + * fixed), shifted 0x260 bytes earlier in DATA. + */ +static const struct ane_h16_preload_cell ane_h15_patchbay_26b123_t6030[] = { + { "GKTS", 0x65f0, 8, true }, + { "ECAP", 0x66e3, 8, true }, + { "ARcM", 0x67b8, 4, true }, + { "ABOI", 0x6815, 8, false }, + { "ZSOI", 0x6825, 4, false }, +}; + +static const struct ane_h16_preload_rule ane_h15_preload_26b123_j516s = { + .cells = ane_h15_patchbay_26b123_t6030, + .cell_count = ARRAY_SIZE(ane_h15_patchbay_26b123_t6030), + .zero_start = 0x2a4000, + .zero_end = 0x2a4000, + .text_size = 0xc8000, + .data_size = 0x2a4000, + .digest = { + 0xd5, 0x0a, 0x4e, 0xc8, 0x46, 0xeb, 0xde, 0x7c, + 0xcd, 0x95, 0xbb, 0x51, 0x29, 0x6d, 0xa4, 0x1f, + 0x4d, 0x84, 0xaa, 0xdc, 0xce, 0xe1, 0xf8, 0x1b, + 0x01, 0xc4, 0x40, 0x95, 0x2d, 0x01, 0x28, 0xa4, + }, +}; + +static const struct ane_h16_profile ane_t6030_profiles_26b123[] __maybe_unused = { + { + .identity = "H15 T6030 27.2 26B123 J516s", + .preload = &ane_h15_preload_26b123_j516s, + .build = &ane_h15_build_t8122_26b123, + }, +}; + /* * T8112 (M2) ANE DARTs, revision 1.1 (PARAMS3 0x24240101 on all three, J473 * 27.2): the same fault, protect and lock words and DAPF record layout as the