Thread (4 messages) flat view 4 messages, 3 authors, 2017-06-05
STALE3388d

[PATCH] PCI/PM: Set D3 power state only if the end device supports it.

From: Geetha sowjanya <hidden>
Date: 2017-05-31 11:53:04
Also in: linux-pci, lkml
Subsystem: pci subsystem, the rest · Maintainers: Bjorn Helgaas, Linus Torvalds

Pci driver doesn't check if the device supports D3hot/D3cold power states 
while setting these power states. The device that doesn't support these 
states will fail when a driver like vfio try to do D0->D3 power transition.

This patch adds a check that allows to set D3 power state only
for the supported devices.

Signed-off-by: Geetha sowjanya <redacted>
---
 drivers/pci/pci.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 563901c..cadd046 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -661,7 +661,8 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
 
 	/* check if this device supports the desired state */
 	if ((state == PCI_D1 && !dev->d1_support)
-	   || (state == PCI_D2 && !dev->d2_support))
+	   || (state == PCI_D2 && !dev->d2_support)
+	   || (state == PCI_D3hot && !pci_pme_capable(dev, state)))
 		return -EIO;
 
 	pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
-- 
1.7.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help