pci: prevent putting pcie devices into lower device states on certain intel bridges
RFC PATCH 1/1 pci: prevent putting pcie devices into lower device states on certain intel bridges
Fixes state transitions of Nvidia Pascal GPUs from D3cold into higher device states.
v2: convert to pci_dev quirk
put a proper technical explenation of the issue as a in-code comment
RFC comment (copied from last sent):
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
--- drivers/pci/pci.c | 11 ++++++++++ drivers/pci/quirks.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 1 + 3 files changed, 62 insertions(+)
drivers/pci/pci.c +11 -0
@@ -799,6 +799,13 @@ static inline bool platform_pci_bridge_d3(struct pci_dev *dev)return pci_platform_pm ? pci_platform_pm->bridge_d3 (dev) : false; } +static inline bool parent_broken_child_pm (struct pci_dev *dev) +{ +if (!dev->bus || !dev->bus->self) +return false; +return dev->bus->self->broken_child_pm; +} +/** * pci_raw_set_power_state - Use PCI PM registers to set the power state of * given PCI device
@@ -844,6 +851,10 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state) || (state == PCI_D2 && !dev->d2_support))return -EIO ; +/* check if the bus controller causes issues */ +if (state !=PCI_D0 &&parent_broken_child_pm (dev)) +return 0 ; +pci_read_config_word (dev, dev->pm_cap +PCI_PM_CTRL , &pmcsr);/*
drivers/pci/quirks.c +50 -0
53 lines not on this page · raw message
include/linux/pci.h +1 -0
@@ -413,6 +413,7 @@ struct pci_dev { unsigned int __aer_firmware_first_valid:1; unsigned int __aer_firmware_first:1; unsigned int broken_intx_masking:1; /* INTx masking can't be used */ + unsigned int broken_child_pm:1; /* children put into lower PCI PM states won't recover after D3cold transition */ unsigned int io_window_1k:1; /* Intel bridge 1K I/O windows */ unsigned int irq_managed:1; unsigned int has_secondary_link:1;
Signature · 6 lines
2.21.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau