Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions drivers/pci/controller/pcie-apple.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Loading