From: Karol Herbst <kherbst@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Karol Herbst <kherbst@redhat.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Lyude Paul <lyude@redhat.com>,
linux-pci@vger.kernel.org, dri-devel@lists.freedesktop.org,
nouveau@lists.freedesktop.org
Subject: [RFC PATCH] pci: prevent putting pcie devices into lower device states on certain intel bridges
Date: Fri, 27 Sep 2019 16:44:21 +0200 [thread overview]
Message-ID: <20190927144421.22608-1-kherbst@redhat.com> (raw)
Fixes runpm breakage mainly on Nvidia GPUs as they are not able to resume.
Works perfectly with this workaround applied.
RFC comment:
We are quite sure that there is a higher amount of bridges affected by this,
but I was only testing it on my own machine for now.
I've stresstested runpm by doing 5000 runpm cycles with that patch applied
and never saw it fail.
I mainly wanted to get a discussion going on if that's a feasable workaround
indeed or if we need something better.
I am also sure, that the nouveau driver itself isn't at fault as I am able
to reproduce the same issue by poking into some PCI registers on the PCIe
bridge to put the GPU into D3cold as it's done in ACPI code.
I've written a little python script to reproduce this issue without the need
of loading nouveau:
https://raw.githubusercontent.com/karolherbst/pci-stub-runpm/master/nv_runpm_bug_test.py
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Lyude Paul <lyude@redhat.com>
Cc: linux-pci@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
---
drivers/pci/pci.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 088fcdc8d2b4..9dbd29ced1ac 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -799,6 +799,42 @@ static inline bool platform_pci_bridge_d3(struct pci_dev *dev)
return pci_platform_pm ? pci_platform_pm->bridge_d3(dev) : false;
}
+/*
+ * some intel bridges cause serious issues with runpm if the client device
+ * is put into D1/D2/D3hot before putting the client into D3cold via
+ * platform means (generally ACPI).
+ *
+ * skipping this makes runpm work perfectly fine on such devices.
+ *
+ * As far as we know only skylake and kaby lake SoCs are affected.
+ */
+static unsigned short intel_broken_d3_bridges[] = {
+ /* kbl */
+ 0x1901,
+};
+
+static inline bool intel_broken_pci_pm(struct pci_bus *bus)
+{
+ struct pci_dev *bridge;
+ int i;
+
+ if (!bus || !bus->self)
+ return false;
+
+ bridge = bus->self;
+ if (bridge->vendor != PCI_VENDOR_ID_INTEL)
+ return false;
+
+ for (i = 0; i < ARRAY_SIZE(intel_broken_d3_bridges); i++) {
+ if (bridge->device == intel_broken_d3_bridges[i]) {
+ pci_err(bridge, "found broken intel bridge\n");
+ return true;
+ }
+ }
+
+ return false;
+}
+
/**
* pci_raw_set_power_state - Use PCI PM registers to set the power state of
* given PCI device
@@ -827,6 +863,9 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
if (state < PCI_D0 || state > PCI_D3hot)
return -EINVAL;
+ if (state != PCI_D0 && intel_broken_pci_pm(dev->bus))
+ return 0;
+
/*
* Validate current state:
* Can enter D0 from any state, but if we can only go deeper
--
2.21.0
next reply other threads:[~2019-09-27 14:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-27 14:44 Karol Herbst [this message]
2019-09-27 21:42 ` [RFC PATCH] pci: prevent putting pcie devices into lower device states on certain intel bridges Bjorn Helgaas
2019-09-27 21:53 ` Karol Herbst
2019-09-30 8:05 ` Mika Westerberg
2019-09-30 9:15 ` Karol Herbst
2019-09-30 9:29 ` Mika Westerberg
2019-09-30 16:05 ` Karol Herbst
2019-09-30 16:30 ` Mika Westerberg
2019-09-30 16:36 ` Karol Herbst
2019-10-01 8:46 ` Mika Westerberg
2019-10-01 8:56 ` Karol Herbst
2019-10-01 9:11 ` Mika Westerberg
2019-10-01 10:00 ` Karol Herbst
2019-10-03 9:47 ` Rafael J. Wysocki
2019-10-01 13:27 ` Bjorn Helgaas
2019-10-01 16:21 ` Karol Herbst
2019-10-01 19:34 ` Bjorn Helgaas
2019-10-02 7:51 ` Rafael J. Wysocki
-- strict thread matches above, loose matches on Subject: below --
2019-09-30 17:07 Karol Herbst
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=20190927144421.22608-1-kherbst@redhat.com \
--to=kherbst@redhat.com \
--cc=bhelgaas@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lyude@redhat.com \
--cc=nouveau@lists.freedesktop.org \
/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;
as well as URLs for NNTP newsgroup(s).