diff mbox series

[07/10] PCI: pciehp: Implement runtime PM callbacks

Message ID 20180906155020.51700-8-mika.westerberg@linux.intel.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show
Series PCI: Allow D3cold for PCIe hierarchies | expand

Commit Message

Mika Westerberg Sept. 6, 2018, 3:50 p.m. UTC
Basically we need to do the same thing when runtime suspending than with
system sleep so re-use those operations here. This makes sure hotplug
interrupt does not trigger immediately when the link goes down.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/pci/hotplug/pciehp_core.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Rafael J. Wysocki Sept. 11, 2018, 8:58 a.m. UTC | #1
On Thursday, September 6, 2018 5:50:17 PM CEST Mika Westerberg wrote:
> Basically we need to do the same thing when runtime suspending than with
> system sleep so re-use those operations here. This makes sure hotplug
> interrupt does not trigger immediately when the link goes down.
> 
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> ---
>  drivers/pci/hotplug/pciehp_core.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
> index c9cf9c3b5f7f..25b2ea9f9242 100644
> --- a/drivers/pci/hotplug/pciehp_core.c
> +++ b/drivers/pci/hotplug/pciehp_core.c
> @@ -349,6 +349,23 @@ static int pciehp_resume(struct pcie_device *dev)
>  
>  	return 0;
>  }
> +
> +static int pciehp_runtime_resume(struct pcie_device *dev)
> +{
> +	struct controller *ctrl = get_service_data(dev);
> +	struct slot *slot = ctrl->slot;
> +
> +	/* pci_restore_state() just wrote to the Slot Control register */
> +	ctrl->cmd_started = jiffies;
> +	ctrl->cmd_busy = true;
> +
> +	/* clear spurious events from rediscovery of inserted card */
> +	if ((slot->state == ON_STATE || slot->state == BLINKINGOFF_STATE) &&
> +	     pme_is_native(dev))
> +		pcie_clear_hotplug_events(ctrl);
> +
> +	return pciehp_resume(dev);
> +}
>  #endif /* PM */
>  
>  static struct pcie_port_service_driver hpdriver_portdrv = {
> @@ -363,6 +380,8 @@ static struct pcie_port_service_driver hpdriver_portdrv = {
>  	.suspend	= pciehp_suspend,
>  	.resume_noirq	= pciehp_resume_noirq,
>  	.resume		= pciehp_resume,
> +	.runtime_suspend = pciehp_suspend,
> +	.runtime_resume	= pciehp_runtime_resume,
>  #endif	/* PM */
>  };
>  
> 

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
diff mbox series

Patch

diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index c9cf9c3b5f7f..25b2ea9f9242 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -349,6 +349,23 @@  static int pciehp_resume(struct pcie_device *dev)
 
 	return 0;
 }
+
+static int pciehp_runtime_resume(struct pcie_device *dev)
+{
+	struct controller *ctrl = get_service_data(dev);
+	struct slot *slot = ctrl->slot;
+
+	/* pci_restore_state() just wrote to the Slot Control register */
+	ctrl->cmd_started = jiffies;
+	ctrl->cmd_busy = true;
+
+	/* clear spurious events from rediscovery of inserted card */
+	if ((slot->state == ON_STATE || slot->state == BLINKINGOFF_STATE) &&
+	     pme_is_native(dev))
+		pcie_clear_hotplug_events(ctrl);
+
+	return pciehp_resume(dev);
+}
 #endif /* PM */
 
 static struct pcie_port_service_driver hpdriver_portdrv = {
@@ -363,6 +380,8 @@  static struct pcie_port_service_driver hpdriver_portdrv = {
 	.suspend	= pciehp_suspend,
 	.resume_noirq	= pciehp_resume_noirq,
 	.resume		= pciehp_resume,
+	.runtime_suspend = pciehp_suspend,
+	.runtime_resume	= pciehp_runtime_resume,
 #endif	/* PM */
 };