diff --git a/Documentation/devicetree/bindings/iommu/apple,dart.yaml b/Documentation/devicetree/bindings/iommu/apple,dart.yaml index a462922f39c14..798a6e7f11e55 100644 --- a/Documentation/devicetree/bindings/iommu/apple,dart.yaml +++ b/Documentation/devicetree/bindings/iommu/apple,dart.yaml @@ -36,6 +36,10 @@ properties: - const: apple,t8140-ane-dart - const: apple,t8140-dart - const: apple,t8110-dart + - items: + - const: apple,t8142-ane-dart + - const: apple,t8142-dart + - const: apple,t8110-dart - items: - enum: - apple,t6000-dart diff --git a/Documentation/devicetree/bindings/npu/apple,ane.yaml b/Documentation/devicetree/bindings/npu/apple,ane.yaml index dded3c25fe216..1383ed8cdfe18 100644 --- a/Documentation/devicetree/bindings/npu/apple,ane.yaml +++ b/Documentation/devicetree/bindings/npu/apple,ane.yaml @@ -35,6 +35,7 @@ properties: - apple,t6050-ane - apple,t8112-ane - apple,t8140-ane + - apple,t8142-ane - items: - const: apple,t6001-ane - const: apple,ane @@ -226,12 +227,23 @@ allOf: const: 0x200 apple,dapf-ranges: maxItems: 4 + - if: + properties: + compatible: + const: apple,t8142-ane + then: + properties: + apple,ane-type: + const: 0x210 + apple,dapf-ranges: + maxItems: 4 - if: properties: compatible: enum: - apple,t6050-ane - apple,t8140-ane + - apple,t8142-ane then: properties: interrupts: @@ -266,6 +278,7 @@ allOf: - apple,t6041-ane - apple,t6050-ane - apple,t8140-ane + - apple,t8142-ane required: - memory-region then: @@ -339,6 +352,7 @@ allOf: - apple,t8140-ane - apple,t6041-ane - apple,t6050-ane + - apple,t8142-ane then: properties: interrupt-names: false @@ -440,6 +454,7 @@ allOf: - apple,t6041-ane - apple,t6050-ane - apple,t6001-ane + - apple,t8142-ane else: properties: power-domains: diff --git a/arch/arm64/boot/dts/apple/t8142-j815.dts b/arch/arm64/boot/dts/apple/t8142-j815.dts index 64edb6c4521f8..a11d808ff22a0 100644 --- a/arch/arm64/boot/dts/apple/t8142-j815.dts +++ b/arch/arm64/boot/dts/apple/t8142-j815.dts @@ -180,3 +180,27 @@ &ave { status = "okay"; }; + +/* + * The Neural Engine. It stays off until the first request: the firmware is + * started then, from the preload, and system sleep cycles it cold. + */ +&ps_ane_sys { + status = "okay"; +}; + +&ane_dart0 { + status = "okay"; +}; + +&ane_dart1 { + status = "okay"; +}; + +&ane_dart2 { + status = "okay"; +}; + +&ane { + status = "okay"; +}; diff --git a/arch/arm64/boot/dts/apple/t8142-peripherals.dtsi b/arch/arm64/boot/dts/apple/t8142-peripherals.dtsi index 350c7ab207a5f..caf5902393d51 100644 --- a/arch/arm64/boot/dts/apple/t8142-peripherals.dtsi +++ b/arch/arm64/boot/dts/apple/t8142-peripherals.dtsi @@ -149,6 +149,73 @@ status = "disabled"; }; + /* + * The Neural Engine's three DARTs (ADT dart-ane, one interrupt for all): + * revision 0x204, 16 streams; SIDs 1-7 are the exclave's and 10/13 + * bypass. The cold profile leaves every inherited stream alone and + * gives the kernel only SID0. + */ + ane_dart0: iommu@421800000 { + compatible = "apple,t8142-ane-dart", "apple,t8142-dart", + "apple,t8110-dart"; + reg = <0x4 0x21800000 0x0 0xc000>; + #iommu-cells = <1>; + interrupts = ; + power-domains = <&ps_ane_sys>; + /* The firmware DVAs reach 0x100_xxxx_xxxx. */ + apple,dma-range = <0x0 0x0 0x400 0x0>; + status = "disabled"; + }; + + ane_dart1: iommu@421820000 { + compatible = "apple,t8142-ane-dart", "apple,t8142-dart", + "apple,t8110-dart"; + reg = <0x4 0x21820000 0x0 0xc000>; + #iommu-cells = <1>; + interrupts = ; + power-domains = <&ps_ane_sys>; + apple,dma-range = <0x0 0x0 0x400 0x0>; + status = "disabled"; + }; + + ane_dart2: iommu@421840000 { + compatible = "apple,t8142-ane-dart", "apple,t8142-dart", + "apple,t8110-dart"; + reg = <0x4 0x21840000 0x0 0xc000>; + #iommu-cells = <1>; + interrupts = ; + power-domains = <&ps_ane_sys>; + apple,dma-range = <0x0 0x0 0x400 0x0>; + status = "disabled"; + }; + + /* + * The Neural Engine (ADT /arm-io/ane, "ane,t8132exclave", ane-type 0x210): + * the H17 engine, exclave-assigned, with firmware that iBoot preloads; the + * boot loader hands the preload over as firmware-text and firmware-data. + * PWGATE is the ADT's reg[2] (PMGR +0x24000) + 0x3640, measured under + * macOS 27.2.1. + */ + ane: ane@420000000 { + compatible = "apple,t8142-ane"; + reg = <0x4 0x20000000 0x0 0x2000000>, + <0x3 0x80700000 0x0 0x18000>, + <0x3 0x80727640 0x0 0x34>; + reg-names = "engine", "pmgr", "pwgate"; + interrupts = , + ; + iommus = <&ane_dart0 0>, <&ane_dart1 0>, <&ane_dart2 0>; + power-domains = <&ps_ane_sys>; + apple,firmware-preloaded; + apple,firmware-iovas = /bits/ 64 <0x10000000000 0x100000c0000>; + /* Inclusive SID0 identity windows from the ADT's dart-ane dapf-instance-0. */ + apple,dapf-ranges = /bits/ 64 <0x4a1668000 0x4a1668003 + 0x3807002e8 0x3807002eb + 0x38070c008 0x38070c00b + 0x582668000 0x582668003>; + status = "disabled"; + }; + scaler0_dart: iommu@305260000 { compatible = "apple,t8142-dart", "apple,t8110-dart"; reg = <0x3 0x5260000 0x0 0x20000>; @@ -462,6 +529,16 @@ }; &pmgr { + /* ADT pmgr device ANE_SYS (id 73), parent AFISOCNI3 (no power state). */ + ps_ane_sys: power-controller@2e8 { + compatible = "apple,t8142-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; + reg = <0x2e8 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "ane_sys"; + status = "disabled"; + }; + ps_msr: power-controller@2a8 { compatible = "apple,t8142-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; reg = <0x2a8 4>; diff --git a/drivers/accel/ane/ane_fw_cold.c b/drivers/accel/ane/ane_fw_cold.c index 6f447afa769e2..2dc8d2239b89c 100644 --- a/drivers/accel/ane/ane_fw_cold.c +++ b/drivers/accel/ane/ane_fw_cold.c @@ -2142,13 +2142,18 @@ static bool ane_fw_handoff_present(struct platform_device *pdev, !strcmp(name, i ? "firmware-data" : "firmware-text") && !ane_fw_preload_range(np, i, &h.phys[i], &h.size[i]); } - if (h.regions_ok && ane_fw_preload_ranges_valid(soc, h.phys, h.size, h.dva)) { + /* + * Hash what the loader handed over even when its layout is not this + * SoC's, so that one boot of a new firmware or SoC reports both. + */ + if (h.regions_ok) { void *text = memremap(h.phys[0], h.size[0], MEMREMAP_WB); if (text) { sha256(text, h.size[0], digest); memunmap(text); - h.text_ok = !memcmp(digest, soc->text_pin, sizeof(digest)); + h.text_ok = ane_fw_preload_ranges_valid(soc, h.phys, h.size, h.dva) && + !memcmp(digest, soc->text_pin, sizeof(digest)); } } *hp = h; @@ -2158,9 +2163,15 @@ static bool ane_fw_handoff_present(struct platform_device *pdev, !h.marker || strcmp(h.marker, ANE_FW_COLD_BOOT_EVIDENCE) ? "raw-boot marker" : !h.preloaded || !h.regions_ok ? "preload reservations" : !h.text_ok ? "firmware TEXT pin" : "preload layout"); - if (h.regions_ok && !h.text_ok) + if (h.regions_ok && !h.text_ok) { dev_info(&pdev->dev, "H17 ANE: preloaded TEXT sha256 %*phN\n", (int)sizeof(digest), digest); + dev_info(&pdev->dev, + "H17 ANE: preload TEXT %#llx+%#llx @%#llx, DATA %#llx+%#llx @%#llx (%s)\n", + h.phys[0], h.size[0], h.dva[0], h.phys[1], h.size[1], h.dva[1], + ane_fw_preload_ranges_valid(soc, h.phys, h.size, h.dva) ? + "layout as expected" : "layout differs"); + } return false; } diff --git a/drivers/accel/ane/ane_fw_platform.c b/drivers/accel/ane/ane_fw_platform.c index 5639f340d0a61..411b1732e41aa 100644 --- a/drivers/accel/ane/ane_fw_platform.c +++ b/drivers/accel/ane/ane_fw_platform.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "ane_fw_cold.h" #include "ane_fw_platform.h" @@ -177,6 +178,65 @@ const struct ane_fw_platform ane_t6050_platform = { .text_pin = ane_t6050_text_pin_27_0, }; +/* + * The M5 (T8142, J813/J815) ANE: "ane,t8132exclave", ane-type 0x210, + * exclave-assigned and preloaded by iBoot. From the T8142 ADT: ANE_SYS at + * PMGR +0x2e8 (pmgr device 73, parent AFISOCNI3), ANE_CPU +0xc000 and + * ANE_TDBASE +0xc008 as on T8140; four DAPF records. The macOS 27.0 (26A428) + * stub's iBoot preloads TEXT 0xc0000 and DATA 0x2ac000 at T8140's IOVAs, + * measured on a J815 under aura with TEXT sha256 1212c260...b6d4e3 (the 27.2 + * host's preload is 0xbc000/0x2b0000 at 0x100_000b_c000). + * + * Measured under aura's hypervisor on a J815 running macOS 27.2.1 (cold + * model load, power-up and power-down traced): the PWGATE window at PMGR + * +0x27640 (request +0xc, acknowledge +0x30, as on T8140), the scratch + * cells from +0x1880028 (as on T6050), DART revision 0x204 (PARAMS_8 + * 0x2a2a0204) and the four DAPF records. macOS powers the engine down in + * T8140's order: sub-block, PWGATE request 3, acknowledge 0, CPU, then + * ANE_SYS. So sleep and the parked start follow T8140. + */ +static const u8 ane_t8142_text_26a428[] = { + 0x12, 0x12, 0xc2, 0x60, 0x6e, 0xf8, 0xca, 0xce, + 0x51, 0xfd, 0x95, 0x1e, 0x60, 0xbc, 0xce, 0x75, + 0xbe, 0x8e, 0x65, 0xd5, 0xf0, 0xfe, 0x19, 0x37, + 0xac, 0x3b, 0x58, 0x07, 0x49, 0xd6, 0xb4, 0xe3, +}; + +const struct ane_fw_platform ane_t8142_platform = { + .soc = 0x8142, + .chip_family = 17, + .ane_type = 0x210, + .hwx_subtype = 9, + .task_generation = 19, + .interrupt_count = 2, + .owner = ANE_FW_OWNER_EXCLAVE, + .reg_names = ane_h17_reg_names, + .reg_sizes = ane_h17_reg_sizes, + .reg_count = ARRAY_SIZE(ane_h17_reg_names), + .wrapper = 0x1600000, + .mailbox = 0x1608000, + .scratch = 0x1880028, + .doorbell = 0x1884000, + .irq_status = 0x188c000, + .irq_ack = 0x1890000, + .preload_dva = { 0x10000000000, 0x100000c0000 }, + .preload_size = { 0xc0000, 0x2ac000 }, + .stream_mask = BIT(0), + .firmware_preloaded = true, + .safe_reset = false, + /* Exclave mode at boot, cold sleep cycle and parked start, as on T8140. */ + .exclave_mode_stop = true, + .macos_sleep = true, + .sleep_warm = false, + .pmgr_sys = 0x2e8, + .pmgr_cpu = 0xc000, + .pmgr_subblock = 0xc008, + .dart_compatible = "apple,t8142-ane-dart", + .dart_revision = 0x204, + .dapf_count = 4, + .text_pin = ane_t8142_text_26a428, +}; + /* * The iBoot preload is firmware memory. Accept it only as a no-map child of * /reserved-memory that Linux does not manage as System RAM, whether the diff --git a/drivers/accel/ane/ane_fw_platform.h b/drivers/accel/ane/ane_fw_platform.h index e4afe348b30c1..dd5e3278c423d 100644 --- a/drivers/accel/ane/ane_fw_platform.h +++ b/drivers/accel/ane/ane_fw_platform.h @@ -145,7 +145,8 @@ ane_fw_sleep_path(const struct ane_fw_platform *platform) return platform ? ANE_SLEEP_FW_BACKEND : ANE_SLEEP_RTCLIENT; } -extern const struct ane_fw_platform ane_h16_platform, ane_h17_platform, ane_t6050_platform; +extern const struct ane_fw_platform ane_h16_platform, ane_h17_platform, ane_t6050_platform, + ane_t8142_platform; int ane_fw_platform_preflight(struct platform_device *pdev, const struct ane_fw_platform *soc); diff --git a/drivers/accel/ane/ane_t6021_rtclient_main.c b/drivers/accel/ane/ane_t6021_rtclient_main.c index 6dc0458bcbbd3..a4f0d6fd7e872 100644 --- a/drivers/accel/ane/ane_t6021_rtclient_main.c +++ b/drivers/accel/ane/ane_t6021_rtclient_main.c @@ -4422,6 +4422,10 @@ static const struct ane_t602x_soc ane_t6050_soc = { .platform = &ane_t6050_platform, }; +static const struct ane_t602x_soc ane_t8142_soc = { + .platform = &ane_t8142_platform, +}; + static const struct of_device_id ane_rtclient_of_match[] = { { .compatible = "apple,t6020-ane", .data = &ane_t6020_soc }, { .compatible = "apple,t6021-ane", .data = &ane_t6021_soc }, @@ -4430,6 +4434,7 @@ static const struct of_device_id ane_rtclient_of_match[] = { { .compatible = "apple,t6041-ane", .data = &ane_h16_soc }, { .compatible = "apple,t8140-ane", .data = &ane_h17_soc }, { .compatible = "apple,t6050-ane", .data = &ane_t6050_soc }, + { .compatible = "apple,t8142-ane", .data = &ane_t8142_soc }, { } }; MODULE_DEVICE_TABLE(of, ane_rtclient_of_match); diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 7cf99361bf796..a8b91c7e63316 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -5172,7 +5172,8 @@ static int apple_dart_probe(struct platform_device *pdev) dart->dev = dev; dart->hw = of_device_get_match_data(dev); dart->tunneled = tunneled; - dart->cold_ane = of_device_is_compatible(dev->of_node, "apple,t8140-ane-dart"); + dart->cold_ane = of_device_is_compatible(dev->of_node, "apple,t8140-ane-dart") || + of_device_is_compatible(dev->of_node, "apple,t8142-ane-dart"); if (dart->cold_ane && !IS_BUILTIN(CONFIG_APPLE_DART)) return -EOPNOTSUPP; dart->isp_host = of_device_is_compatible(dev->of_node, "apple,t6050-isp-dart"); @@ -5643,8 +5644,12 @@ static int apple_dart_probe(struct platform_device *pdev) /* No reset, TCR/TTBR clear, global enable, remap or IRQ ACK. * Cold acquisition is checked by the staged ANE backend before * it attaches a private SID0 domain. Even bypass SIDs stay intact. + * T8140's ANE DARTs are revision 0x203, T8142's 0x204. */ - if (dart->locked || dart->version != 0x203 || dart->num_streams != 16 || + u32 cold_version = of_device_is_compatible(dev->of_node, "apple,t8142-ane-dart") ? + 0x204 : 0x203; + + if (dart->locked || dart->version != cold_version || dart->num_streams != 16 || !bitmap_empty(dart->remapped, DART_MAX_STREAMS)) { ret = -EPERM; goto err_clk_disable;