public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] PCI/PM: Only read PCI_PM_CTRL register when available
@ 2023-08-22 11:55 Feiyang Chen
  2023-08-22 13:06 ` Anders Roxell
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Feiyang Chen @ 2023-08-22 11:55 UTC (permalink / raw)
  To: bhelgaas, rafael.j.wysocki
  Cc: Feiyang Chen, mika.westerberg, helgaas, anders.roxell, linux-pci,
	linux-pm, guyinggang, siyanteng, chenhuacai, loongson-kernel,
	chris.chenfeiyang

When the current state is already PCI_D0, pci_power_up() will return
0 even though dev->pm_cap is not set. In that case, we should not
read the PCI_PM_CTRL register in pci_set_full_power_state().

Fixes: e200904b275c ("PCI/PM: Split pci_power_up()")
Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn>
---
 drivers/pci/pci.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 60230da957e0..7e90ab7b47a1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1242,9 +1242,6 @@ int pci_power_up(struct pci_dev *dev)
 		else
 			dev->current_state = state;
 
-		if (state == PCI_D0)
-			return 0;
-
 		return -EIO;
 	}
 
@@ -1302,8 +1299,12 @@ static int pci_set_full_power_state(struct pci_dev *dev)
 	int ret;
 
 	ret = pci_power_up(dev);
-	if (ret < 0)
+	if (ret < 0) {
+		if (dev->current_state == PCI_D0)
+			return 0;
+
 		return ret;
+	}
 
 	pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
 	dev->current_state = pmcsr & PCI_PM_CTRL_STATE_MASK;
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-08-24  1:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-22 11:55 [PATCH v2] PCI/PM: Only read PCI_PM_CTRL register when available Feiyang Chen
2023-08-22 13:06 ` Anders Roxell
2023-08-22 13:17   ` Ilpo Järvinen
2023-08-22 13:24 ` Ilpo Järvinen
2023-08-22 14:24   ` Rafael J. Wysocki
2023-08-23  7:28     ` Ilpo Järvinen
2023-08-23 12:46       ` Rafael J. Wysocki
2023-08-23 20:50         ` Bjorn Helgaas
2023-08-24  1:27           ` Feiyang Chen
2023-08-22 18:54 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox