Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1715323

Re: [RFC PATCH v2 1/3] PCI: rockchip: Add support for pcie wake irq

From Brian Norris <briannorris@chromium.org>
Newsgroups linux.kernel
Subject Re: [RFC PATCH v2 1/3] PCI: rockchip: Add support for pcie wake irq
Date 2017-08-18 19:10 +0200
Message-ID <ufSWu-6HW-9@gated-at.bofh.it> (permalink)
References <ufrMC-4Ff-33@gated-at.bofh.it> <ufrMD-4Ff-63@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


+ Tony

On Thu, Aug 17, 2017 at 08:04:29PM +0800, Jeffy Chen wrote:
> Add support for PCIE_WAKE pin in rockchip pcie driver.
> 
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> ---
> 
> Changes in v2:
> Use dev_pm_set_dedicated_wake_irq
>         -- Suggested by Brian Norris <briannorris@chromium.com>
> 
>  drivers/pci/host/pcie-rockchip.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/host/pcie-rockchip.c b/drivers/pci/host/pcie-rockchip.c
> index 7bb9870f6d8c..c2b973c738fe 100644
> --- a/drivers/pci/host/pcie-rockchip.c
> +++ b/drivers/pci/host/pcie-rockchip.c
> @@ -36,6 +36,7 @@
>  #include <linux/pci_ids.h>
>  #include <linux/phy/phy.h>
>  #include <linux/platform_device.h>
> +#include <linux/pm_wakeirq.h>
>  #include <linux/reset.h>
>  #include <linux/regmap.h>
>  
> @@ -853,7 +854,6 @@ static void rockchip_pcie_legacy_int_handler(struct irq_desc *desc)
>  	chained_irq_exit(chip, desc);
>  }
>  
> -
>  /**
>   * rockchip_pcie_parse_dt - Parse Device Tree
>   * @rockchip: PCIe port information
> @@ -1018,6 +1018,14 @@ static int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip)
>  		return err;
>  	}
>  
> +	device_init_wakeup(dev, true);
> +	irq = platform_get_irq_byname(pdev, "wake");
> +	if (irq >= 0) {
> +		err = dev_pm_set_dedicated_wake_irq(dev, irq);

Did you test that this works out correctly as a level-triggered
interrupt? IIUC, the dummy handler won't mask the interrupt, so it might
keep firing. See:

static irqreturn_t handle_threaded_wake_irq(int irq, void *_wirq)
{
        struct wake_irq *wirq = _wirq;
        int res;

        /* Maybe abort suspend? */
        if (irqd_is_wakeup_set(irq_get_irq_data(irq))) {
                pm_wakeup_event(wirq->dev, 0);
        
                return IRQ_HANDLED; <--- We can return here, with the trigger still asserted
        }
...

This could cause some kind of an IRQ storm, including a lockup or
significant slowdown, I think.

BTW, in another context, Tony suggested we might need to fix up the IRQ flags
like this:

int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq)
{
...
        err = request_threaded_irq(irq, NULL, handle_threaded_wake_irq,
-                                  IRQF_ONESHOT, dev_name(dev), wirq);
+                                  IRQF_ONESHOT | irq_get_trigger_type(irq), dev_name(dev), wirq);

But IIUC, that's not actually necessary, because __setup_irq()
automatically configures the trigger type if the driver didn't request
one explicitly.

Brian

> +		if (err)
> +			dev_err(dev, "failed to setup PCIe wake IRQ\n");
> +	}
> +
>  	rockchip->vpcie3v3 = devm_regulator_get_optional(dev, "vpcie3v3");
>  	if (IS_ERR(rockchip->vpcie3v3)) {
>  		if (PTR_ERR(rockchip->vpcie3v3) == -EPROBE_DEFER)
> @@ -1524,6 +1532,9 @@ static int rockchip_pcie_remove(struct platform_device *pdev)
>  	struct device *dev = &pdev->dev;
>  	struct rockchip_pcie *rockchip = dev_get_drvdata(dev);
>  
> +	dev_pm_clear_wake_irq(dev);
> +	device_init_wakeup(dev, false);
> +
>  	pci_stop_root_bus(rockchip->root_bus);
>  	pci_remove_root_bus(rockchip->root_bus);
>  	pci_unmap_iospace(rockchip->io);
> -- 
> 2.11.0
> 
> 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC PATCH v2 0/3] PCI: rockchip: Move PCIE_WAKE handling into rockchip pcie driver Jeffy Chen <jeffy.chen@rock-chips.com> - 2017-08-17 14:10 +0200
  [RFC PATCH v2 3/3] arm64: dts: rockchip: Handle pcie wake in pcie driver for Gru Jeffy Chen <jeffy.chen@rock-chips.com> - 2017-08-17 14:10 +0200
  [RFC PATCH v2 1/3] PCI: rockchip: Add support for pcie wake irq Jeffy Chen <jeffy.chen@rock-chips.com> - 2017-08-17 14:10 +0200
    Re: [RFC PATCH v2 1/3] PCI: rockchip: Add support for pcie wake irq Shawn Lin <shawn.lin@rock-chips.com> - 2017-08-18 09:30 +0200
      Re: [RFC PATCH v2 1/3] PCI: rockchip: Add support for pcie wake irq jeffy <jeffy.chen@rock-chips.com> - 2017-08-18 10:40 +0200
    Re: [RFC PATCH v2 1/3] PCI: rockchip: Add support for pcie wake irq Brian Norris <briannorris@chromium.org> - 2017-08-18 19:10 +0200
      Re: [RFC PATCH v2 1/3] PCI: rockchip: Add support for pcie wake irq Brian Norris <briannorris@chromium.org> - 2017-08-18 19:10 +0200
      Re: [RFC PATCH v2 1/3] PCI: rockchip: Add support for pcie wake irq jeffy <jeffy.chen@rock-chips.com> - 2017-08-18 19:50 +0200
        Re: [RFC PATCH v2 1/3] PCI: rockchip: Add support for pcie wake irq Tony Lindgren <tony@atomide.com> - 2017-08-18 20:30 +0200
      Re: [RFC PATCH v2 1/3] PCI: rockchip: Add support for pcie wake irq Tony Lindgren <tony@atomide.com> - 2017-08-18 20:20 +0200
        Re: [RFC PATCH v2 1/3] PCI: rockchip: Add support for pcie wake irq jeffy <jeffy.chen@rock-chips.com> - 2017-08-18 22:10 +0200
          Re: [RFC PATCH v2 1/3] PCI: rockchip: Add support for pcie wake irq Tony Lindgren <tony@atomide.com> - 2017-08-22 19:30 +0200
            Re: [RFC PATCH v2 1/3] PCI: rockchip: Add support for pcie wake irq jeffy <jeffy.chen@rock-chips.com> - 2017-08-23 03:40 +0200
              Re: [RFC PATCH v2 1/3] PCI: rockchip: Add support for pcie wake irq Brian Norris <briannorris@chromium.org> - 2017-08-23 04:00 +0200
                Re: [RFC PATCH v2 1/3] PCI: rockchip: Add support for pcie wake irq jeffy <jeffy.chen@rock-chips.com> - 2017-08-23 04:20 +0200

csiph-web