diff mbox series

[v2,1/2] PCI/PM: Do not generate wakeup event when runtime resuming bus

Message ID 20201125090733.77782-1-mika.westerberg@linux.intel.com (mailing list archive)
State Accepted, archived
Delegated to: Bjorn Helgaas
Headers show
Series [v2,1/2] PCI/PM: Do not generate wakeup event when runtime resuming bus | expand

Commit Message

Mika Westerberg Nov. 25, 2020, 9:07 a.m. UTC
When a PCI bridge is runtime resumed from D3cold the underlying bus is
walked and the attached devices are runtime resumed as well. However, in
addition to that we also generate a wakeup event for these devices even
though this actually is not a real wakeup event coming from the
hardware.

Normally this does not cause problems but when combined with
/sys/power/wakeup_count like using the steps below:

  # count=$(cat /sys/power/wakeup_count)
  # echo $count > /sys/power/wakeup_count
  # echo mem > /sys/power/state

The system suspend cycle might fail at this point if a PCI bridge that
was runtime suspended (D3cold) was runtime resumed for any reason. The
runtime resume calls pci_wakeup_bus() and that generates wakeup event
increasing wakeup_count.

Since this is not a real wakeup event we can prevent the above from
happening by removing the call to pci_wakeup_event() in
pci_wakeup_bus().

Reported-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
Previous version can be found here:

  https://www.spinics.net/lists/linux-pci/msg101083.html

Changes from the previous version:

  - Split the patch in two. The second patch only does the rename.
  - Tried to improve the commit message a bit
  - Added Rafael's reviewed-by tag

 drivers/pci/pci.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Bjorn Helgaas Dec. 4, 2020, 11:18 p.m. UTC | #1
On Wed, Nov 25, 2020 at 12:07:32PM +0300, Mika Westerberg wrote:
> When a PCI bridge is runtime resumed from D3cold the underlying bus is
> walked and the attached devices are runtime resumed as well. However, in
> addition to that we also generate a wakeup event for these devices even
> though this actually is not a real wakeup event coming from the
> hardware.
> 
> Normally this does not cause problems but when combined with
> /sys/power/wakeup_count like using the steps below:
> 
>   # count=$(cat /sys/power/wakeup_count)
>   # echo $count > /sys/power/wakeup_count
>   # echo mem > /sys/power/state
> 
> The system suspend cycle might fail at this point if a PCI bridge that
> was runtime suspended (D3cold) was runtime resumed for any reason. The
> runtime resume calls pci_wakeup_bus() and that generates wakeup event
> increasing wakeup_count.
> 
> Since this is not a real wakeup event we can prevent the above from
> happening by removing the call to pci_wakeup_event() in
> pci_wakeup_bus().
> 
> Reported-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

I reversed the order of these since I think it's more obvious that
pci_wakeup_event() doesn't fit in pci_resume_one() and applied both to
pci/pm for v5.11, thanks!

> ---
> Previous version can be found here:
> 
>   https://www.spinics.net/lists/linux-pci/msg101083.html
> 
> Changes from the previous version:
> 
>   - Split the patch in two. The second patch only does the rename.
>   - Tried to improve the commit message a bit
>   - Added Rafael's reviewed-by tag
> 
>  drivers/pci/pci.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index e578d34095e9..6f7b33998fbe 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -1181,7 +1181,6 @@ EXPORT_SYMBOL_GPL(pci_platform_power_transition);
>   */
>  static int pci_wakeup(struct pci_dev *pci_dev, void *ign)
>  {
> -	pci_wakeup_event(pci_dev);
>  	pm_request_resume(&pci_dev->dev);
>  	return 0;
>  }
> -- 
> 2.29.2
>
diff mbox series

Patch

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index e578d34095e9..6f7b33998fbe 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1181,7 +1181,6 @@  EXPORT_SYMBOL_GPL(pci_platform_power_transition);
  */
 static int pci_wakeup(struct pci_dev *pci_dev, void *ign)
 {
-	pci_wakeup_event(pci_dev);
 	pm_request_resume(&pci_dev->dev);
 	return 0;
 }