[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230809185453.40916-9-mario.limonciello@amd.com>
Date: Wed, 9 Aug 2023 13:54:52 -0500
From: Mario Limonciello <mario.limonciello@....com>
To: "Rafael J . Wysocki" <rafael@...nel.org>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Bjorn Helgaas <helgaas@...nel.org>
CC: <linux-pci@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
"Andy Shevchenko" <andriy.shevchenko@...ux.intel.com>,
<linux-acpi@...r.kernel.org>,
Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@...ux.intel.com>,
"Iain Lane" <iain@...ngesquash.org.uk>,
Shyam-sundar S-k <Shyam-sundar.S-k@....com>,
Mario Limonciello <mario.limonciello@....com>
Subject: [PATCH v11 8/9] PCI: Split PME state selection into a local static function
When a device is not power manageable by the platform, and not already
in a low power state pci_target_state() will find the deepest state
that PME is supported and use this to select the wakeup state.
Simplify this logic and split it out to a local function. No intended
functional changes.
Signed-off-by: Mario Limonciello <mario.limonciello@....com>
---
v10->v11:
* New patch split from existing patch in v10
---
drivers/pci/pci.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 60230da957e0c..693f4ca90452b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2660,6 +2660,20 @@ int pci_wake_from_d3(struct pci_dev *dev, bool enable)
}
EXPORT_SYMBOL(pci_wake_from_d3);
+/*
+ * Find the deepest state from which the device can generate
+ * PME#.
+ */
+static inline pci_power_t pci_get_wake_pme_state(struct pci_dev *dev)
+{
+ pci_power_t state = PCI_D3hot;
+
+ while (state && !(dev->pme_support & (1 << state)))
+ state--;
+
+ return state;
+}
+
/**
* pci_target_state - find an appropriate low power state for a given PCI dev
* @dev: PCI device
@@ -2701,21 +2715,8 @@ static pci_power_t pci_target_state(struct pci_dev *dev, bool wakeup)
else if (!dev->pm_cap)
return PCI_D0;
- if (wakeup && dev->pme_support) {
- pci_power_t state = PCI_D3hot;
-
- /*
- * Find the deepest state from which the device can generate
- * PME#.
- */
- while (state && !(dev->pme_support & (1 << state)))
- state--;
-
- if (state)
- return state;
- else if (dev->pme_support & 1)
- return PCI_D0;
- }
+ if (wakeup && dev->pme_support)
+ return pci_get_wake_pme_state(dev);
return PCI_D3hot;
}
--
2.34.1
Powered by blists - more mailing lists