From: Mario Limonciello <mario.limonciello@amd.com>
To: Hans de Goede <hdegoede@redhat.com>,
Bjorn Helgaas <bhelgaas@google.com>,
"Rafael J . Wysocki" <rjw@rjwysocki.net>
Cc: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>,
"open list:X86 PLATFORM DRIVERS"
<platform-driver-x86@vger.kernel.org>,
"open list:PCI SUBSYSTEM" <linux-pci@vger.kernel.org>,
<linux-pm@vger.kernel.org>,
Mario Limonciello <mario.limonciello@amd.com>
Subject: [PATCH v17 3/4] PCI: Check for changes in pci_bridge_d3_possible() when updating D3
Date: Wed, 6 Sep 2023 13:43:53 -0500 [thread overview]
Message-ID: <20230906184354.45846-4-mario.limonciello@amd.com> (raw)
In-Reply-To: <20230906184354.45846-1-mario.limonciello@amd.com>
As drivers can report an optin or veto for a given PCI device it's
possible that pci_bridge_d3_possible() reports different values while
calling pci_bridge_d3_update(). Take these values into account while
updating the ability for a bridge to go into D3.
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
drivers/pci/pci.c | 29 +++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 06ab73f58adf..9004d8ea460a 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3100,6 +3100,14 @@ static int pci_dev_check_d3cold(struct pci_dev *dev, void *data)
return !*d3cold_ok;
}
+static void pci_bridge_d3_propagate(struct pci_dev *bridge, bool d3_ok)
+{
+ if (bridge->bridge_d3 != d3_ok) {
+ bridge->bridge_d3 = d3_ok;
+ pci_bridge_d3_propagate(bridge, d3_ok);
+ }
+}
+
/*
* pci_bridge_d3_update - Update bridge D3 capabilities
* @dev: PCI device which is changed
@@ -3112,12 +3120,16 @@ void pci_bridge_d3_update(struct pci_dev *dev)
{
bool remove = !device_is_registered(&dev->dev);
struct pci_dev *bridge;
- bool d3cold_ok = true;
+ bool d3_ok = true;
bridge = pci_upstream_bridge(dev);
- if (!bridge || !pci_bridge_d3_possible(bridge))
+ if (!bridge)
return;
+ /* Propagate change to upstream bridges */
+ d3_ok = pci_bridge_d3_possible(bridge);
+ pci_bridge_d3_propagate(bridge, d3_ok);
+
/*
* If D3 is currently allowed for the bridge, removing one of its
* children won't change that.
@@ -3134,7 +3146,7 @@ void pci_bridge_d3_update(struct pci_dev *dev)
* first may allow us to skip checking its siblings.
*/
if (!remove)
- pci_dev_check_d3cold(dev, &d3cold_ok);
+ pci_dev_check_d3cold(dev, &d3_ok);
/*
* If D3 is currently not allowed for the bridge, this may be caused
@@ -3142,15 +3154,12 @@ void pci_bridge_d3_update(struct pci_dev *dev)
* so we need to go through all children to find out if one of them
* continues to block D3.
*/
- if (d3cold_ok && !bridge->bridge_d3)
+ if (d3_ok && !bridge->bridge_d3)
pci_walk_bus(bridge->subordinate, pci_dev_check_d3cold,
- &d3cold_ok);
+ &d3_ok);
- if (bridge->bridge_d3 != d3cold_ok) {
- bridge->bridge_d3 = d3cold_ok;
- /* Propagate change to upstream bridges */
- pci_bridge_d3_update(bridge);
- }
+ /* Propagate change to upstream bridges */
+ pci_bridge_d3_propagate(bridge, d3_ok);
}
/**
--
2.34.1
next prev parent reply other threads:[~2023-09-06 19:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-06 18:43 [PATCH v17 0/4] Allow drivers to influence D3 behavior for bridges Mario Limonciello
2023-09-06 18:43 ` [PATCH v17 1/4] ACPI: x86: s2idle: Export symbol for fetching constraints for module use Mario Limonciello
2023-09-06 18:43 ` [PATCH v17 2/4] PCI: Add support for drivers to register optin or veto of D3 Mario Limonciello
2023-09-11 18:34 ` Rafael J. Wysocki
2023-09-11 20:23 ` Mario Limonciello
2023-09-12 9:11 ` Rafael J. Wysocki
2023-09-06 18:43 ` Mario Limonciello [this message]
2023-09-06 18:43 ` [PATCH v17 4/4] platform/x86/amd: pmc: Report device constraints Mario Limonciello
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230906184354.45846-4-mario.limonciello@amd.com \
--to=mario.limonciello@amd.com \
--cc=Shyam-sundar.S-k@amd.com \
--cc=bhelgaas@google.com \
--cc=hdegoede@redhat.com \
--cc=linux-pci@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rjw@rjwysocki.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox