From ccdd14ad5493ee3eb16c4b29c512b7728820b59e Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Wed, 11 Nov 2026 16:11:40 -0500 Subject: [PATCH] PCI: apple: keep Clock PM off on adopted T6050 links Restore the adopted-host Clock PM policy from candidate44. Integration boots J775c with this change alone; restoring bus- number preservation alone does not return as a trial, and restoring the NVMe driver alone does not return. The host leaves CLKREQ# pads and reference-clock gating in firmware state. Removing L0s/L1 capability bits does not mask PCIE_LINK_STATE_CLKPM. Disable it before endpoint enable and walk the enumerated bus to retain the policy. Adapted from Satya Benson candidate44 PCIe adoption changes. Tested on J775c with Aura b6e6faf4 and candidate44 DTB; other boards untested. Signed-off-by: Satya Benson Assisted-by: LLM --- drivers/pci/controller/pcie-apple.c | 45 ++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c index dec95de353ca..4af0bfc20e93 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -3542,6 +3542,38 @@ static int apple_pcie_radio_check_cold(struct apple_pcie_port *port) return ret; } +/* + * Adopted T6050 links have no kernel CLKREQ# pad or reference-clock gating + * setup. Disabling L0s/L1 capabilities alone does not disable Clock PM. + * Keep Clock PM off before enabling endpoints and after host enumeration; + * the policy mask also prevents a later ASPM policy change re-enabling it. + */ +static void apple_pcie_adopted_no_clkpm(struct pci_dev *pdev, bool locked) +{ + u32 lnkcap; + int ret; + + if (pci_is_root_bus(pdev->bus) || !pci_is_pcie(pdev)) + return; + if (pcie_capability_read_dword(pdev, PCI_EXP_LNKCAP, &lnkcap) || + !(lnkcap & PCI_EXP_LNKCAP_CLKPM)) + return; + ret = locked ? pci_disable_link_state_locked(pdev, PCIE_LINK_STATE_CLKPM) : + pci_disable_link_state(pdev, PCIE_LINK_STATE_CLKPM); + if (ret == -EINVAL) /* no ASPM link state: nothing turns Clock PM on */ + return; + if (ret) + pci_warn(pdev, "cannot turn Clock PM off: %d\n", ret); + else if (locked) + pci_info(pdev, "Clock PM off: the host does not handle CLKREQ#\n"); +} + +static int apple_pcie_adopted_no_clkpm_walk(struct pci_dev *pdev, void *data) +{ + apple_pcie_adopted_no_clkpm(pdev, true); + return 0; +} + static int apple_pcie_enable_device(struct pci_host_bridge *bridge, struct pci_dev *pdev) { struct apple_pcie *pcie = pci_host_bridge_priv(bridge); @@ -3592,6 +3624,7 @@ static int apple_pcie_enable_device(struct pci_host_bridge *bridge, struct pci_d if (pcie->hw->adopt_link) { if (READ_ONCE(port->link_failed)) return -ENODEV; + apple_pcie_adopted_no_clkpm(pdev, false); mutex_lock(&pcie->lock); err = apple_pcie_adopted_route(port, rid); mutex_unlock(&pcie->lock); @@ -4784,6 +4817,16 @@ static void apple_pcie_neo_sleep_probe(struct platform_device *pdev, struct appl dev_warn(dev, "no deep sleep: the loader didn't publish what this host needs\n"); } +static int apple_pcie_host_init(struct platform_device *pdev, struct pci_host_bridge *bridge) +{ + struct apple_pcie *pcie = pci_host_bridge_priv(bridge); + int ret = pci_host_common_init(pdev, bridge, &apple_pcie_cfg_ecam_ops); + + if (!ret && pcie->hw->adopt_link) + pci_walk_bus(bridge->bus, apple_pcie_adopted_no_clkpm_walk, NULL); + return ret; +} + static int apple_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -4951,7 +4994,7 @@ static int apple_pcie_probe(struct platform_device *pdev) if (hw->adopt_link) bridge->reset_root_port = apple_pcie_t6050_reset_root_port; - ret = pci_host_common_init(pdev, bridge, &apple_pcie_cfg_ecam_ops); + ret = apple_pcie_host_init(pdev, bridge); if (ret) { apple_pcie_cleanup(pcie); if (pcie->piodma_supplier) {