PCI: PM: Avoid forcing PCI_D0 for wakeup reasons inconsistently
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 29 Jul 2021 15:54:28 +0000 (17:54 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 4 Aug 2021 17:26:23 +0000 (19:26 +0200)
commitda9f2150684ea684a7ddd6d7f0e38b2bdf43dcd8
treefffcf67e7220e24b767c14aa9e7e6d5d65041be2
parent14858dcc3b3587f4bb5c48e130ee7d68fc2b0a29
PCI: PM: Avoid forcing PCI_D0 for wakeup reasons inconsistently

It is inconsistent to return PCI_D0 from pci_target_state() instead
of the original target state if 'wakeup' is true and the device
cannot signal PME from D0.

This only happens when the device cannot signal PME from the original
target state and any shallower power states (including D0) and that
case is effectively equivalent to the one in which PME singaling is
not supported at all.  Since the original target state is returned in
the latter case, make the function do that in the former one too.

Link: https://lore.kernel.org/linux-pm/3149540.aeNJFYEL58@kreacher/
Fixes: 666ff6f83e1d ("PCI/PM: Avoid using device_may_wakeup() for runtime PM")
Reported-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reported-by: Utkarsh H Patel <utkarsh.h.patel@intel.com>
Reported-by: Koba Ko <koba.ko@canonical.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/pci/pci.c