From: Mikhail Malyshev <mike.malyshev@gmail.com>
To: alex.williamson@redhat.com, jgg@ziepe.ca, yi.l.liu@intel.com,
kevin.tian@intel.com, tglx@linutronix.de,
reinette.chatre@intel.com, stefanha@redhat.com
Cc: abhsahu@nvidia.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org,
Mikhail Malyshev <mike.malyshev@gmail.com>
Subject: [PATCH 1/1] vfio/pci: Reenable runtime PM for dynamically unbound devices
Date: Tue, 19 Mar 2024 12:04:10 +0000 [thread overview]
Message-ID: <20240319120410.1477713-2-mike.malyshev@gmail.com> (raw)
In-Reply-To: <20240319120410.1477713-1-mike.malyshev@gmail.com>
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@gmail.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
next prev parent reply other threads:[~2024-03-19 12:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-19 12:04 [PATCH 0/1] " Mikhail Malyshev
2024-03-19 12:04 ` Mikhail Malyshev [this message]
2024-03-19 14:50 ` Alex Williamson
2024-03-21 12:23 ` Mikhail Malyshev
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=20240319120410.1477713-2-mike.malyshev@gmail.com \
--to=mike.malyshev@gmail.com \
--cc=abhsahu@nvidia.com \
--cc=alex.williamson@redhat.com \
--cc=jgg@ziepe.ca \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=reinette.chatre@intel.com \
--cc=stefanha@redhat.com \
--cc=tglx@linutronix.de \
--cc=yi.l.liu@intel.com \
/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
all inboxes | Powered by JetHome®