PCI: Fix runtime PM race with PME polling
authorAlex Williamson <alex.williamson@redhat.com>
Thu, 3 Aug 2023 17:12:33 +0000 (11:12 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 11 Aug 2023 19:25:58 +0000 (14:25 -0500)
commitd3fcd7360338358aa0036bec6d2cf0e37a0ca624
treee153238207984f3865efe343c4422beeb09408a9
parent5cd903bce9ddd234d76e67d0dfaf0aab0f11a2e0
PCI: Fix runtime PM race with PME polling

Testing that a device is not currently in a low power state provides no
guarantees that the device is not imminently transitioning to such a state.
Increment the PM usage counter before accessing the device.  Since we don't
wish to wake the device for PME polling, do so only if the device is
already active by using pm_runtime_get_if_active().

Link: https://lore.kernel.org/r/20230803171233.3810944-3-alex.williamson@redhat.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pci.c