From 333e55ce6ba54839b4f16ddec056f3a92f2a7100 Mon Sep 17 00:00:00 2001 From: Diljit Singh Date: Sun, 8 Nov 2026 19:53:13 -0500 Subject: [PATCH] soc: apple: t8140-sleep: wait for the PCIe block's domain before its AXI enables The commit clears the PCIe block's AXI enables, its link into the SoC fabric, between taking APCIE_SYS_GP off AUTO_ENABLE and lowering it. It cleared them only if the domain read on at once. After a sleep's wake the domain runs under AUTO_ENABLE, as on macOS, and once the radio's port and engine have stopped the hardware may have idled it. Clearing AUTO_ENABLE brings it back, but not by the next read, so the enables were skipped and the block went down with its link set up. SoC NI 1 then latched a PCIe receive link error (LINK_ERR PCIE_RXL) as the block's last domain, ANS, went off, on every sleep that kept DRAM up. The first sleep of a boot finds the enables clear as the loader left them. macOS's own sleep reads the word until it is on before it clears the enables and lowers it. Do the same. Signed-off-by: Diljit Singh --- drivers/soc/apple/t8140-sleep.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/soc/apple/t8140-sleep.c b/drivers/soc/apple/t8140-sleep.c index c18205d3243c9..d9e16f936593f 100644 --- a/drivers/soc/apple/t8140-sleep.c +++ b/drivers/soc/apple/t8140-sleep.c @@ -1029,6 +1029,16 @@ static int t8140_ps_raise(struct t8140_sleep *s, u32 offset) return ret; } +/* A domain the hardware idled under AUTO_ENABLE comes back once that's cleared. */ +static bool t8140_ps_wait_on(struct t8140_sleep *s, u32 offset, u32 val) +{ + if (!FIELD_GET(PS_TARGET, val)) + return false; + + return !readl_poll_timeout_atomic(s->ps + offset, val, FIELD_GET(PS_ACTUAL, val), 1, + PS_OFF_TIMEOUT_US); +} + static int t8140_ps_wait_off(struct t8140_sleep *s, u32 offset) { u32 val; @@ -1901,8 +1911,13 @@ static void t8140_sleep_lower_apcie(struct t8140_sleep *s) t8140_ps_lower(s, PS_APCIE_SYS_ST); t8140_ps_lower(s, PS_APCIE_ST); + /* + * The AXI enables are the block's link into the fabric. macOS reads the domain on + * before clearing them: powered off with them set, SoC NI 1 latches a PCIe receive + * link error once the block's last domain goes off. + */ val = t8140_ps_lower_start(s, PS_APCIE_SYS_GP); - if (s->apcie_axi && t8140_ps_on(s, PS_APCIE_SYS_GP)) { + if (s->apcie_axi && t8140_ps_wait_on(s, PS_APCIE_SYS_GP, val)) { writel(readl(s->apcie_axi + APCIE_AXI_EN0) & ~BIT(0), s->apcie_axi + APCIE_AXI_EN0); writel(readl(s->apcie_axi + APCIE_AXI_EN1) & ~BIT(0), s->apcie_axi + APCIE_AXI_EN1); }