From a313071a0aad3b9cf0cf31345f040c629ef620f3 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Thu, 3 Dec 2026 12:53:58 -0500 Subject: [PATCH] PCI: apple: link PWREN to the GPIO chip's device Since T6030 takes the noirq resume path (#3809), a J516s boot can lose the whole host, and with it Wi-Fi, Bluetooth and the SD reader: pcie-apple 580000000.pcie: error -EINVAL: no device link to gpiochip1 pcie-apple 580000000.pcie: probe with driver pcie-apple failed with error -22 PWREN on J514s/J516s is an SMC GPIO. gpio_device_find() returns a gpio_device as soon as device_add() has registered its kobject, but device_add() puts it on the PM list only later, and device_link_add() returns NULL for a supplier that is not on that list yet. The failing boot probed the host while macsmc-gpio was still adding its chip: the error falls between macsmc-gpio's "First GPIO key" line and macsmc-low-gpio's. Link the host to the device that registered the chip (the gpio_device's parent) instead. That device is on the PM list before its driver adds the chip, and resume order is unchanged, because a gpio_device resumes after its parent. If no link can be made, warn and keep the host: the link only orders deep-sleep resume, and failing the probe takes every port down. Fixes: 60d53dcf22c3 ("PCI: apple: Set T604x ports up in the noirq resume after a sleep") Signed-off-by: DjDeveloperr --- drivers/pci/controller/pcie-apple.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c index 88f464309cf27..84b06ded5acdd 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -3083,15 +3083,30 @@ static void apple_pcie_unlink_pwren(void *data) device_link_del(data); } -/* The PWREN GPIOs' provider resumes before this host, so its noirq resume can use them. */ +/* + * The PWREN GPIOs' provider resumes before this host, so its noirq resume can use them. + * + * Link to the device that registered the GPIO chip, not to its gpio_device: the + * gpio_device can be looked up as soon as device_add() has registered it, before + * device_pm_add(), and device_link_add() refuses a supplier that is not on the PM + * list yet. The chip's parent is on it before its driver adds the chip, and the + * gpio_device resumes after it in any case. + * + * The link only orders deep-sleep resume. If it can't be made, keep the host: the + * ports still work, only a deep-sleep resume may find PWREN not ready. + */ static int apple_pcie_link_pwren(struct apple_pcie *pcie, struct gpio_desc *pwren) { struct device *gpio = gpio_device_to_device(gpiod_to_gpio_device(pwren)); + struct device *provider = gpio->parent ?: gpio; struct device_link *link; - link = device_link_add(pcie->dev, gpio, DL_FLAG_STATELESS); - if (!link) - return dev_err_probe(pcie->dev, -EINVAL, "no device link to %s\n", dev_name(gpio)); + link = device_link_add(pcie->dev, provider, DL_FLAG_STATELESS); + if (!link) { + dev_warn(pcie->dev, "no device link to %s: PWREN may not be ready in noirq resume\n", + dev_name(provider)); + return 0; + } return devm_add_action_or_reset(pcie->dev, apple_pcie_unlink_pwren, link); }