Re: [PATCH v8 3/3] PCI: Add support for PCIe WAKE# interrupt

From: Manivannan Sadhasivam

Date: Tue Mar 17 2026 - 03:28:21 EST


On Fri, Mar 13, 2026 at 12:38:42PM +0530, Krishna Chaitanya Chundru wrote:
> According to the PCI Express specification (PCIe r7.0, Section 5.3.3.2),
> two link wakeup mechanisms are defined: Beacon and WAKE#. Beacon is a
> hardware-only mechanism and is invisible to software (PCIe r7.0,
> Section 4.2.7.8.1). This change adds support for the WAKE# mechanism in
> the PCI core.
>
> According to the PCIe specification, multiple WAKE# signals can exist in
> a system or each component in the hierarchy could share a single WAKE#
> signal. In configurations involving a PCIe switch, each downstream port
> (DSP) of the switch may be connected to a separate WAKE# line, allowing
> each endpoint to signal WAKE# independently. From figure 5.4 in sec
> 5.3.3.2, WAKE# can also be terminated at the switch itself. To support
> this, the WAKE# should be described in the device tree node of the
> endpoint/bridge. If all endpoints share a single WAKE# line, then each
> endpoint node should describe the same WAKE# signal or a single WAKE# in
> the Root Port node.
>
> In pci_device_add(), PCI framework will search for the WAKE# in device
> node, If not found, it searches in its upstream port only if upstream port
> is Root Port. Once found, register for the wake IRQ in shared mode, as the
> WAKE# may be shared among multiple endpoints.
>
> dev_pm_set_dedicated_shared_wake_irq() associates a wakeup IRQ with a
> device and requests it, but the PM core keeps the IRQ disabled by default.
> The IRQ is enabled only when the device is permitted to wake the system,
> i.e. during system suspend and after runtime suspend, and only when device
> wakeup is enabled.
>
> When the wake IRQ fires, the wakeirq handler invokes pm_runtime_resume() to
> bring the device back to an active power state, such as transitioning from
> D3cold to D0. Once the device is active and the link is usable, the
> endpoint may generate a PME, which is then handled by the PCI core through
> PME polling or the PCIe PME service driver to complete the wakeup of the
> endpoint.
>
> WAKE# is added in dts schema and merged based on below links.
>
> Link: https://lore.kernel.org/all/20250515090517.3506772-1-krishna.chundru@xxxxxxxxxxxxxxxx/
> Link: https://github.com/devicetree-org/dt-schema/pull/170
> Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
> Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@xxxxxxxxxxxxxxxx>
> ---
> drivers/pci/of.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++
> drivers/pci/pci.c | 10 +++++++
> drivers/pci/pci.h | 2 ++
> drivers/pci/probe.c | 2 ++
> drivers/pci/remove.c | 1 +
> include/linux/of_pci.h | 4 +++
> include/linux/pci.h | 2 ++
> 7 files changed, 95 insertions(+)
>
> diff --git a/drivers/pci/of.c b/drivers/pci/of.c
> index 9f8eb5df279ed28db7a3b2fd29c65da9975c2efa..b7199d3598b31b62245716c178a5a73565efc89e 100644
> --- a/drivers/pci/of.c
> +++ b/drivers/pci/of.c
> @@ -7,6 +7,7 @@
> #define pr_fmt(fmt) "PCI: OF: " fmt
>
> #include <linux/cleanup.h>
> +#include <linux/gpio/consumer.h>
> #include <linux/irqdomain.h>
> #include <linux/kernel.h>
> #include <linux/pci.h>
> @@ -15,6 +16,7 @@
> #include <linux/of_address.h>
> #include <linux/of_pci.h>
> #include <linux/platform_device.h>
> +#include <linux/pm_wakeirq.h>
> #include "pci.h"
>
> #ifdef CONFIG_PCI
> @@ -586,6 +588,78 @@ int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin)
> return irq_create_of_mapping(&oirq);
> }
> EXPORT_SYMBOL_GPL(of_irq_parse_and_map_pci);
> +
> +static void pci_configure_wake_irq(struct pci_dev *pdev, struct gpio_desc *wake)
> +{
> + int ret, wake_irq;
> +
> + wake_irq = gpiod_to_irq(wake);
> + if (wake_irq < 0) {
> + pci_err(pdev, "Failed to get wake irq: %d\n", wake_irq);
> + return;
> + }
> +
> + device_init_wakeup(&pdev->dev, true);

Just set wakeup only if dev_pm_set_dedicated_shared_wake_irq() succeeds.

> +
> + /*
> + * dev_pm_set_dedicated_shared_wake_irq() associates a wakeup IRQ with the
> + * device and requests it, but the PM core keeps it disabled by default.
> + * The IRQ is enabled only when the device is allowed to wake the system
> + * (during system suspend and after runtime suspend), and only if device
> + * wakeup is enabled.
> + *
> + * When the wake IRQ fires, the wakeirq handler invokes pm_runtime_resume()
> + * to bring the device back to an active power state (e.g. from D3cold to D0).
> + * Once the device is active and the link is usable, the endpoint may signal
> + * a PME, which is then handled by the PCI core (either via PME polling or the
> + * PCIe PME service driver) to wakeup particular endpoint.
> + */
> + ret = dev_pm_set_dedicated_shared_wake_irq(&pdev->dev, wake_irq,
> + IRQ_TYPE_EDGE_FALLING);

Isn't WAKE# a level triggered signal?

> + if (ret < 0) {
> + pci_err(pdev, "Failed to set wake IRQ: %d\n", ret);

s/wake/WAKE#

- Mani

--
மணிவண்ணன் சதாசிவம்