lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240319120410.1477713-2-mike.malyshev@gmail.com>
Date: Tue, 19 Mar 2024 12:04:10 +0000
From: Mikhail Malyshev <mike.malyshev@...il.com>
To: alex.williamson@...hat.com,
	jgg@...pe.ca,
	yi.l.liu@...el.com,
	kevin.tian@...el.com,
	tglx@...utronix.de,
	reinette.chatre@...el.com,
	stefanha@...hat.com
Cc: abhsahu@...dia.com,
	kvm@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Mikhail Malyshev <mike.malyshev@...il.com>
Subject: [PATCH 1/1] vfio/pci: Reenable runtime PM for dynamically unbound devices

When a device is unbound from its driver it may call pm_runtime_disable()
in its ->remove() callback. When such device is bound to vfio-pci driver
VFIO framework should reenable runtime PM before calling pm_runtime_xxx
functions.

The problem was introduced by
commit 7ab5e10eda02 ("vfio/pci: Move the unused device into low power state
 with runtime PM")

Signed-off-by: Mikhail Malyshev <mike.malyshev@...il.com>
---
 drivers/vfio/pci/vfio_pci_core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
index 1cbc990d42e0..05c25ee66ee1 100644
--- a/drivers/vfio/pci/vfio_pci_core.c
+++ b/drivers/vfio/pci/vfio_pci_core.c
@@ -2258,6 +2258,16 @@ int vfio_pci_core_register_device(struct vfio_pci_core_device *vdev)
 	vfio_pci_set_power_state(vdev, PCI_D0);
 
 	dev->driver->pm = &vfio_pci_core_pm_ops;
+
+	/*
+	 * If the device was previously associated with a driver, the
+	 * driver might have invoked pm_runtime_disable in its remove()
+	 * callback. We must re-enable runtime PM here to ensure the
+	 * device can be managed.
+	 */
+	if (!pm_runtime_enabled(dev))
+		pm_runtime_enable(dev);
+
 	pm_runtime_allow(dev);
 	if (!disable_idle_d3)
 		pm_runtime_put(dev);
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ