linux-stable/drivers/pci
Lukas Wunner 3ca7d87033 PCI/sysfs: Protect driver's D3cold preference from user space
commit 70b70a4307 upstream.

struct pci_dev contains two flags which govern whether the device may
suspend to D3cold:

* no_d3cold provides an opt-out for drivers (e.g. if a device is known
  to not wake from D3cold)

* d3cold_allowed provides an opt-out for user space (default is true,
  user space may set to false)

Since commit 9d26d3a8f1 ("PCI: Put PCIe ports into D3 during suspend"),
the user space setting overwrites the driver setting.  Essentially user
space is trusted to know better than the driver whether D3cold is
working.

That feels unsafe and wrong.  Assume that the change was introduced
inadvertently and do not overwrite no_d3cold when d3cold_allowed is
modified.  Instead, consider d3cold_allowed in addition to no_d3cold
when choosing a suspend state for the device.

That way, user space may opt out of D3cold if the driver hasn't, but it
may no longer force an opt in if the driver has opted out.

Fixes: 9d26d3a8f1 ("PCI: Put PCIe ports into D3 during suspend")
Link: https://lore.kernel.org/r/b8a7f4af2b73f6b506ad8ddee59d747cbf834606.1695025365.git.lukas@wunner.de
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Cc: stable@vger.kernel.org	# v4.8+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-11-28 16:45:44 +00:00
..
dwc PCI: qcom: Fix unbalanced PHY init on probe errors 2022-06-14 16:54:02 +02:00
endpoint
host PCI: hv: Fix interrupt mapping for multi-MSI 2022-07-29 17:06:53 +02:00
hotplug PCI: pciehp: Use RMW accessors for changing LNKCTL 2023-09-23 10:46:57 +02:00
pcie
switch
Kconfig
Makefile
access.c PCI: Reduce warnings on possible RW1C corruption 2022-04-20 09:08:18 +02:00
ats.c
bus.c
ecam.c
host-bridge.c
hotplug-pci.c
htirq.c
iov.c
irq.c PCI: Check for alloc failure in pci_request_irq() 2023-01-18 09:26:21 +01:00
mmap.c
msi.c PCI/MSI: Mask MSI-X vectors only on success 2021-12-22 09:18:00 +01:00
of.c
pci-acpi.c PCI/sysfs: Protect driver's D3cold preference from user space 2023-11-28 16:45:44 +00:00
pci-driver.c
pci-label.c PCI/sysfs: Fix dsm_label_utf16s_to_utf8s() buffer overrun 2021-07-20 16:17:53 +02:00
pci-mid.c
pci-stub.c
pci-sysfs.c PCI/sysfs: Protect driver's D3cold preference from user space 2023-11-28 16:45:44 +00:00
pci.c PCI: Fix pci_device_is_present() for VFs by checking PF 2023-01-18 09:26:38 +01:00
pci.h PCI: thunder: Fix compile testing 2021-05-22 10:57:42 +02:00
probe.c PCI: Release OF node in pci_scan_device()'s error path 2021-05-22 10:57:38 +02:00
proc.c
quirks.c PCI: Prevent xHCI driver from claiming AMD VanGogh USB3 DRD device 2023-11-08 11:21:10 +01:00
remove.c
rom.c
search.c
setup-bus.c
setup-irq.c
setup-res.c PCI: Sanitise firmware BAR assignments behind a PCI-PCI bridge 2022-10-26 13:16:56 +02:00
slot.c PCI: Fix pci_slot_release() NULL pointer dereference 2020-12-29 13:47:11 +01:00
syscall.c PCI: Return ~0 data on pciconfig_read() CAP_SYS_ADMIN failure 2021-09-22 11:45:25 +02:00
vc.c
vpd.c
xen-pcifront.c