From 2eb9771ea2a24cb0fe06a29536f5094f6da22d4a Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 21 Nov 2026 22:29:39 +1100 Subject: [PATCH 1/2] arm64: dts: apple: t8132: keep the USB4 router DARTs out of the router's power state Since the USB4 NHI DARTs were given power-domains = <&ps_atcN_cio>, every deep sleep of an M4 MacBook Air with a USB4 partner attached hangs: the DART, a supplier of the NHI, suspends after the NHI's noirq suspend, so the native CIO sleep, which powers the router's states off from that noirq suspend, finds ATCN_CIO still held on, unwinds, and fails again in its recovery. The SoC watchdog then resets the machine. The DART does not need the state named: the router populates it only after powering its own states, and the native CIO sleep saves and restores it across their power cycle. Drop the property again on both routers and say why. Fixes: 202ede05e539 ("arm64: dts: apple: t8122/t8132/t603x: give the remaining DARTs their power domains") Signed-off-by: Ryan Murray --- arch/arm64/boot/dts/apple/t8132-usb4.dtsi | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8132-usb4.dtsi b/arch/arm64/boot/dts/apple/t8132-usb4.dtsi index be35c15c9e9ba..7a800738401f8 100644 --- a/arch/arm64/boot/dts/apple/t8132-usb4.dtsi +++ b/arch/arm64/boot/dts/apple/t8132-usb4.dtsi @@ -77,13 +77,18 @@ nonposted-mmio; status = "disabled"; + /* + * No power-domains: the router populates its DART after it has powered + * its own states, and the native CIO sleep powers them off with the DART + * saved. A DART in ps_atc0_cio would hold that state on through the + * NHI's noirq suspend (it suspends after the NHI), and the sleep fails. + */ usb4_0_dart: iommu@a80000 { compatible = "apple,t8132-dart", "apple,t8110-dart"; reg = <0xa80000 0x20000>; interrupt-parent = <&aic>; interrupts = ; #iommu-cells = <5>; - power-domains = <&ps_atc0_cio>; }; usb4_0_nhi: nhi@f00000 { @@ -194,13 +199,18 @@ nonposted-mmio; status = "disabled"; + /* + * No power-domains: the router populates its DART after it has powered + * its own states, and the native CIO sleep powers them off with the DART + * saved. A DART in ps_atc1_cio would hold that state on through the + * NHI's noirq suspend (it suspends after the NHI), and the sleep fails. + */ usb4_1_dart: iommu@a80000 { compatible = "apple,t8132-dart", "apple,t8110-dart"; reg = <0xa80000 0x20000>; interrupt-parent = <&aic>; interrupts = ; #iommu-cells = <5>; - power-domains = <&ps_atc1_cio>; }; usb4_1_nhi: nhi@f00000 { From 2fa243c99e6464e1aa70ea08f1e5a5374c445537 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 21 Nov 2026 23:01:44 +1100 Subject: [PATCH 2/2] scripts/dtc: apple-dart-pd-check: a DART its powered parent populates is covered A USB4 router's DARTs are children of the router node, which names the router's power states. The router driver populates them only after it has powered those states, so they are never probed while the block is off, and naming the same states on the DART holds them on through the native CIO sleep. The check counted such a DART as a new gap. Treat a DART without power-domains as covered when its parent is a device node (not a simple-bus or similar, which platform code populates) with power-domains of its own, and require the parent's domains to be enabled. This is read from the tree's structure, not from a list of boards. On today's integration DTBs it exempts nothing new; it accepts the four T8132 router DARTs once they drop their domains. Signed-off-by: Ryan Murray --- scripts/dtc/apple-dart-pd-check-test.py | 43 +++++++++++++++++++++++++ scripts/dtc/apple-dart-pd-check.py | 36 ++++++++++++++++++++- 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/scripts/dtc/apple-dart-pd-check-test.py b/scripts/dtc/apple-dart-pd-check-test.py index adab86a6e6657..00737ba3444cf 100755 --- a/scripts/dtc/apple-dart-pd-check-test.py +++ b/scripts/dtc/apple-dart-pd-check-test.py @@ -174,6 +174,49 @@ def test_disabled_dart_of_an_enabled_user_fails(self): self.assertIn("t8112-j413 /soc/iommu@5000 dart_x apple,t8110-dart disabled: " "power domain /soc/power-controller@3000 is disabled (new)", result.stdout) + ROUTER = ('acio@5000 { compatible = "apple,t8103-usb4-acio"; %s ' + '#address-cells = <1>; #size-cells = <0>; ' + 'dart_x: iommu@a00 { compatible = "apple,t8110-dart"; #iommu-cells = <1>; }; ' + 'nhi@b00 { iommus = <&dart_x 0>; }; };') + + def test_dart_inside_a_powered_device_is_exempt(self): + # A USB4 router's DART: its driver populates it after powering its domains. + router = self.ROUTER % "power-domains = <&ps_x>;" + self.dtb(self.head, "t8112-j413", dts("j413", "t8112", DOMAIN, GAP, router)) + result = self.check() + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertIn("new: 0", result.stderr) + report = self.check("--report") + self.assertIn("/soc/acio@5000/iommu@a00 dart_x apple,t8110-dart okay: " + "exempt (inside /soc/acio@5000)", report.stdout) + + def test_dart_inside_a_device_without_domains_fails(self): + router = self.ROUTER % "" + self.dtb(self.head, "t8112-j413", dts("j413", "t8112", DOMAIN, GAP, router)) + result = self.check() + self.assertEqual(result.returncode, 1, result.stdout + result.stderr) + self.assertIn("/soc/acio@5000/iommu@a00 dart_x apple,t8110-dart okay: " + "no power-domains (new)", result.stdout) + + def test_dart_inside_a_device_on_a_disabled_domain_fails(self): + disabled = DOMAIN.replace("{", '{ status = "disabled";') + router = self.ROUTER % "power-domains = <&ps_x>;" + self.dtb(self.head, "t8112-j413", dts("j413", "t8112", disabled, GAP, router)) + result = self.check() + self.assertEqual(result.returncode, 1, result.stdout + result.stderr) + self.assertIn("/soc/acio@5000/iommu@a00 dart_x apple,t8110-dart okay: " + "parent's power domain /soc/power-controller@3000 is disabled (new)", + result.stdout) + + def test_dart_inside_a_powered_bus_is_not_exempt(self): + # A simple-bus is populated by platform code, not by a driver. + bus = self.ROUTER.replace('"apple,t8103-usb4-acio"', '"simple-bus"') % \ + "power-domains = <&ps_x>;" + self.dtb(self.head, "t8112-j413", dts("j413", "t8112", DOMAIN, GAP, bus)) + result = self.check() + self.assertEqual(result.returncode, 1, result.stdout + result.stderr) + self.assertIn("no power-domains (new)", result.stdout) + def test_without_baseline_every_gap_fails(self): result = subprocess.run([sys.executable, str(CHECKER), "--dtb-dir", str(self.head)], text=True, capture_output=True) diff --git a/scripts/dtc/apple-dart-pd-check.py b/scripts/dtc/apple-dart-pd-check.py index 59aa7e64947a0..18d50c87985f1 100755 --- a/scripts/dtc/apple-dart-pd-check.py +++ b/scripts/dtc/apple-dart-pd-check.py @@ -14,7 +14,11 @@ block is off as a whole, which is consistent. Exempt: the DARTs of the SEP and of the AOP. Those coprocessors run from -before the handoff on states the AP never switches off. +before the handoff on states the AP never switches off. Also exempt: a DART +that is a child of a device node (not a bus) with power-domains of its own, +such as a USB4 router's. Its parent's driver populates it after powering the +parent's domains, so it is covered by them; the parent's domains must then be +enabled. Install python3-libfdt (or pylibfdt) to read DTBs. Labels are shown when the DTBs were built with DTC_FLAGS=-@. @@ -36,6 +40,7 @@ DART = re.compile(r"apple,.*dart") SOC = re.compile(r"apple,[st]\d{4}$") +BUSES = ("simple-bus", "simple-pm-bus", "simple-mfd", "isa") EXEMPT = ( (re.compile(r"apple,sep$"), "SEP"), (re.compile(r"apple,(t\d+-)?aop$"), "AOP"), @@ -115,6 +120,28 @@ def iommu_cells(offset): consumers.setdefault(phandles[spec[i + 1]], []).append(offset) i += 3 + iommu_cells(phandles[spec[i + 1]]) + def domain_providers(offset): + domains = cells(prop(offset, "power-domains")) + i = 0 + while i < len(domains): + provider = phandles.get(domains[i]) + if provider is None: + break + yield provider + n = cells(prop(provider, "#power-domain-cells")) + i += 1 + (n[0] if n else 0) + + def disabled_domains(offset): + return [nodes[p] for p in domain_providers(offset) if status(p) != "okay"] + + def powered_device(offset): + """A device node (not a bus) with power domains of its own: platform + code does not populate its children, its driver does.""" + compatible = strings(prop(offset, "compatible")) + return (offset != 0 and bool(compatible) and + not any(c in BUSES for c in compatible) and + bool(cells(prop(offset, "power-domains")))) + for offset, path in nodes.items(): compatible = strings(prop(offset, "compatible")) if not any(DART.match(c) for c in compatible): @@ -130,6 +157,13 @@ def iommu_cells(offset): for c in strings(prop(o, "compatible"))] why = [name for pattern, name in EXEMPT if any(pattern.match(c) for c in users)] problem = "exempt (%s)" % why[0] if why else "no power-domains" + parent = offsets[path.rsplit("/", 1)[0] or "/"] + if not why and powered_device(parent): + # The parent device's driver populates this DART once it has + # powered its own domains; it is never probed on its own. + bad = disabled_domains(parent) + problem = ("parent's power domain %s is disabled" % bad[0] if bad else + "exempt (inside %s)" % nodes[parent]) yield path, label, compatible[0], status(offset), problem continue i = 0