From 9121dab2e7ee8ccb83161c75b531ca17fb00495a Mon Sep 17 00:00:00 2001 From: Grier Johnson Date: Fri, 4 Dec 2026 19:12:38 -0700 Subject: [PATCH 1/3] arm64: dts: apple: t8010: Disable PCIe L1 PM Substates on storage port Port 0 on T8010 keeps CLKREQ# configured as a software GPIO input (clkreq-gpios) rather than hardware PCIe CLKREQ# pinmux, so the storage link cannot enter PCIe L1 PM Substates (L1.1/L1.2) safely. Add aspm-no-l1ss to the shared T8010 storage root port node so the PCIe ASPM core enforces this restriction from enumeration onward (including under pcie_aspm.policy=powersupersave), while still allowing ASPM L1. Assisted-by: LLM Signed-off-by: Grier Johnson --- arch/arm64/boot/dts/apple/t8010.dtsi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t8010.dtsi b/arch/arm64/boot/dts/apple/t8010.dtsi index 0c1f9896ed40ce..05c270b1266f6e 100644 --- a/arch/arm64/boot/dts/apple/t8010.dtsi +++ b/arch/arm64/boot/dts/apple/t8010.dtsi @@ -783,6 +783,13 @@ reg = <0x0 0x0 0x0 0x0 0x0>; reset-gpios = <&pinctrl_ap 12 GPIO_ACTIVE_LOW>; clkreq-gpios = <&pinctrl_ap 16 GPIO_ACTIVE_LOW>; + /* + * Port 0 keeps CLKREQ# in software GPIO input + * mode rather than hardware PCIe pinmux, so + * block L1 PM Substates (L1.1/L1.2) while + * still allowing ASPM L1. + */ + aspm-no-l1ss; #address-cells = <3>; #size-cells = <2>; From 50c872912615623f9e68a8284cf34aacdf41aea1 Mon Sep 17 00:00:00 2001 From: Grier Johnson Date: Fri, 4 Dec 2026 19:12:38 -0700 Subject: [PATCH 2/3] PCI/ASPM: Override L1 acceptable latency for Apple S3E NVMe Apple S3E (ANS) NVMe controllers (106b:2002) advertise an L1 acceptable latency of <32us (0x5) in DevCap while pairing exclusively with Apple H8/H9 root ports that report <64us (0x6) L1 exit latency. Because 64us exceeds 32us, pcie_aspm_check_latency() strips PCIE_LINK_STATE_L1 and leaves the storage link stuck in L0 on Apple H8/H9 boards whose storage port allows ASPM L1 (T8010 and T8011; S800x boards explicitly opt out via aspm-no-l1 in devicetree). Override DevCap L1 acceptable latency via the existing aspm_l1_acceptable_latency() quirk, allowing ASPM L1 to be enabled. Assisted-by: LLM Signed-off-by: Grier Johnson --- drivers/pci/quirks.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index de9bbccda21fd1..8148a58f03df8e 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -6332,6 +6332,14 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x56b0, aspm_l1_acceptable_latency DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x56b1, aspm_l1_acceptable_latency); DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x56c0, aspm_l1_acceptable_latency); DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x56c1, aspm_l1_acceptable_latency); + +/* + * Apple S3E (ANS) NVMe controllers (106b:2002) advertise an L1 acceptable + * latency of <32us (0x5) in DevCap while pairing exclusively with Apple + * H8/H9 root ports that report <64us (0x6) L1 exit latency, preventing + * ASPM L1 from being enabled despite the controller supporting L1/L1SS. + */ +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_APPLE, 0x2002, aspm_l1_acceptable_latency); #endif #ifdef CONFIG_PCIE_DPC From 18727824f5a8dfb141769a36deebf7563fa54548 Mon Sep 17 00:00:00 2001 From: Grier Johnson Date: Fri, 4 Dec 2026 19:12:38 -0700 Subject: [PATCH 3/3] nvme-pci: apple-ans: Enable ASPM L1 PM Substates on T8011 On Apple T8011 (A10X), the storage root port pinmuxes CLKREQ# to the PCIe controller and permits REFCLK gating, so the Apple S3E NVMe link supports PCIe L1 PM Substates (L1.1 and L1.2). Previously, nvme_pci_apple_ans_config() overwrote PCI_L1SS_CTL2 with 0 and PCI_L1SS_CTL1 with the enable bits cleared, clobbering the L1.2 timing parameters computed by the PCIe ASPM core during enumeration, and devicetree ASPM defaults only enable L0s/L1. Add an l1ss_enable flag to struct apple_ans_host (enabled on T8011 and J120, kept off on S8000/S8001/S8003 where REFCLK gating is disabled and on T8010 where port 0 CLKREQ# stays in software GPIO mode). When set, leave the ASPM core's L1SS timing registers intact in nvme_pci_apple_ans_config() and request L1 + L1.1/L1.2 via pci_enable_link_state() in nvme_pci_apple_ans_init() (and explicitly disable L1SS when l1ss_enable is false). Doing this once synchronously during probe ensures it runs before pci_enable_device_mem() applies ASPM policy (protecting older T8010 DTBs without aspm-no-l1ss) and outside reset_work (avoiding pci_bus_sem recursion under AER recovery), while nvme_pci_enable() subsequently saves the resulting PCI config state for suspend/resume. Assisted-by: LLM Signed-off-by: Grier Johnson --- drivers/nvme/host/pci-apple-ans.c | 68 ++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a/drivers/nvme/host/pci-apple-ans.c b/drivers/nvme/host/pci-apple-ans.c index c75cfe58eff1bd..47f7e64f231f8a 100644 --- a/drivers/nvme/host/pci-apple-ans.c +++ b/drivers/nvme/host/pci-apple-ans.c @@ -58,6 +58,8 @@ struct apple_ans_nvme_req { * @sleep_stop: the controller's port loses power in system sleep: stop the * controller first, as iOS (AppleEmbeddedNVMeController) does, * and bring it up from reset on resume + * @l1ss_enable: allow PCIe L1 PM Substates (L1.1/L1.2) on links whose root + * port has hardware CLKREQ# pinmux and REFCLK gating * @read_only: diagnostic host rejects media changes and optional feature setup * @primary_ns_writes: diagnostic exception for namespace 1 Write and Flush */ @@ -67,10 +69,15 @@ struct apple_ans_host { unsigned int rdy_timeout_ms; bool late_bus_master; bool sleep_stop; + bool l1ss_enable; bool read_only; bool primary_ns_writes; }; +/* + * S8000/S8001/S8003 keep REFCLK ungated (S8003_RC_PORT_PWR_REFCLK_NOGATE), so + * leave l1ss_enable false. + */ static const struct apple_ans_host apple_ans_host_s8003 = { .l1ss_ctl1 = APPLE_ANS_L1SS_CTL1_S8003, /* @@ -93,15 +100,30 @@ static const struct apple_ans_host apple_ans_host_s8001 = { .read_only = true, }; +/* + * T8010 keeps port 0 CLKREQ# in software GPIO input mode (clkreq-gpios) + * rather than hardware PCIe pinmux, so leave l1ss_enable false. + */ static const struct apple_ans_host apple_ans_host_t8010 = { .l1ss_ctl1 = APPLE_ANS_L1SS_CTL1_T8010, .sleep_stop = true, }; -/* J120 uses the same L1SS control, verified against its native port data. */ +/* + * T8011 pinmuxes port 0 CLKREQ# to the PCIe controller and allows REFCLK + * gating, so ASPM L1.1/L1.2 work on the ANS link. + */ +static const struct apple_ans_host apple_ans_host_t8011 = { + .l1ss_ctl1 = APPLE_ANS_L1SS_CTL1_T8010, + .sleep_stop = true, + .l1ss_enable = true, +}; + +/* J120 is a T8011 board with the same hardware CLKREQ# pinmux and L1SS support. */ static const struct apple_ans_host apple_ans_host_j120 = { .l1ss_ctl1 = APPLE_ANS_L1SS_CTL1_T8010, .sleep_stop = true, + .l1ss_enable = true, /* Namespace writes and their recovery path are not yet qualified. */ .read_only = true, /* Isolated write-qualification candidate; never enable auxiliary writes. */ @@ -134,8 +156,7 @@ static const struct of_device_id nvme_pci_apple_ans_hosts[] = { { .compatible = "apple,s8001-pcie", .data = &apple_ans_host_s8001 }, { .compatible = "apple,s8003-pcie", .data = &apple_ans_host_s8003 }, { .compatible = "apple,t8010-pcie", .data = &apple_ans_host_t8010 }, - /* The A10X storage port carries the A10's ANS controller. */ - { .compatible = "apple,t8011-pcie", .data = &apple_ans_host_t8010 }, + { .compatible = "apple,t8011-pcie", .data = &apple_ans_host_t8011 }, { } }; @@ -182,10 +203,11 @@ unsigned long nvme_pci_apple_ans_quirks(struct pci_dev *pdev) static int nvme_pci_apple_ans_init(struct nvme_dev *dev, int node) { + struct pci_dev *pdev = to_pci_dev(dev->dev); const struct of_device_id *match; struct apple_ans_nvme *ans; - match = nvme_pci_apple_ans_host_match(to_pci_dev(dev->dev)); + match = nvme_pci_apple_ans_host_match(pdev); if (!match) return -ENODEV; @@ -198,6 +220,27 @@ static int nvme_pci_apple_ans_init(struct nvme_dev *dev, int node) dev->sleep_stop = ans->host->sleep_stop; spin_lock_init(&ans->req_lock); dev->dma_data = ans; + + /* + * Configure L1 PM Substates once during probe, before reset_work is + * queued (avoiding pci_bus_sem recursion under AER recovery) and + * before pci_enable_device_mem() applies ASPM policy. + */ + if (ans->host->l1ss_enable) { + pci_set_power_state(pdev, PCI_D0); + pci_enable_link_state(pdev, + PCIE_LINK_STATE_L1 | + PCIE_LINK_STATE_L1_1 | + PCIE_LINK_STATE_L1_2 | + PCIE_LINK_STATE_L1_1_PCIPM | + PCIE_LINK_STATE_L1_2_PCIPM); + } else { + pci_disable_link_state(pdev, + PCIE_LINK_STATE_L1_1 | + PCIE_LINK_STATE_L1_2 | + PCIE_LINK_STATE_L1_1_PCIPM | + PCIE_LINK_STATE_L1_2_PCIPM); + } return 0; } @@ -286,7 +329,7 @@ static int nvme_pci_apple_ans_config(struct nvme_dev *dev) { struct apple_ans_nvme *ans = nvme_pci_apple_ans(dev); struct pci_dev *pdev = to_pci_dev(dev->dev); - u16 ltr, l1ss; + u16 ltr; if (pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0x40)) return -EIO; @@ -296,12 +339,15 @@ static int nvme_pci_apple_ans_config(struct nvme_dev *dev) APPLE_ANS_LTR_MAX_LATENCY)) return -EIO; - l1ss = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_L1SS); - if (l1ss && - (pci_write_config_dword(pdev, l1ss + PCI_L1SS_CTL2, 0) || - pci_write_config_dword(pdev, l1ss + PCI_L1SS_CTL1, - ans->host->l1ss_ctl1))) - return -EIO; + if (!ans->host->l1ss_enable) { + u16 l1ss = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_L1SS); + + if (l1ss && + (pci_write_config_dword(pdev, l1ss + PCI_L1SS_CTL2, 0) || + pci_write_config_dword(pdev, l1ss + PCI_L1SS_CTL1, + ans->host->l1ss_ctl1))) + return -EIO; + } return 0; }