[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250728-luo-pci-v1-10-955b078dd653@kernel.org>
Date: Mon, 28 Jul 2025 01:24:40 -0700
From: Chris Li <chrisl@...nel.org>
To: Bjorn Helgaas <bhelgaas@...gle.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>, Danilo Krummrich <dakr@...nel.org>,
Len Brown <lenb@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-pci@...r.kernel.org,
linux-acpi@...r.kernel.org, David Matlack <dmatlack@...gle.com>,
Pasha Tatashin <tatashin@...gle.com>, Jason Miu <jasonmiu@...gle.com>,
Vipin Sharma <vipinsh@...gle.com>, Saeed Mahameed <saeedm@...dia.com>,
Adithya Jayachandran <ajayachandra@...dia.com>,
Parav Pandit <parav@...dia.com>, William Tu <witu@...dia.com>,
Mike Rapoport <rppt@...nel.org>, Chris Li <chrisl@...nel.org>,
Jason Gunthorpe <jgg@...pe.ca>, Leon Romanovsky <leon@...nel.org>
Subject: [PATCH RFC 10/25] PCI/LUO: Add pci_liveupdate_get_driver_data()
Similar to liveupdate_get_subsystem_data(), the PCI subsystem
provide pci_liveupdate_get_driver_data() for the driver to
receive the driver data during new kernel boot up, in the liveupdate
updated state.
This function will return an error on any other liveupdate state.
For example, vfio-pci will use this API in probe() to access the
liveupdate state from the previous kernel.
Signed-off-by: Chris Li <chrisl@...nel.org>
---
drivers/pci/liveupdate.c | 15 +++++++++++++++
include/linux/pci.h | 9 +++++++++
2 files changed, 24 insertions(+)
diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c
index 09faba99e9218b443f66060db5142208e22c7dd5..f84c0a455f7055b9b64051b125368fb0f9e6144f 100644
--- a/drivers/pci/liveupdate.c
+++ b/drivers/pci/liveupdate.c
@@ -406,6 +406,21 @@ void pci_liveupdate_restore(struct pci_dev *dev)
return pci_dev_do_restore(dev, s);
}
+int pci_liveupdate_get_driver_data(struct pci_dev *pdev, u64 *data)
+{
+ struct dev_liveupdate *lu = &pdev->dev.lu;
+ struct pci_dev_ser *s = lu->dev_state;
+
+ if (!liveupdate_state_updated())
+ return -EINVAL;
+
+ if (!lu->dev_state)
+ return -ENOENT;
+
+ *data = s->driver_data;
+ return 0;
+}
+
void pci_liveupdate_override_driver(struct pci_dev *dev)
{
struct pci_dev_ser *s = dev->dev.lu.dev_state;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 05e68f35f39238f8b9ce08df97b384d1c1e89bbe..50296bb04aaa7f2bbd2260f8ec4670533e019e38 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -2767,4 +2767,13 @@ void pci_uevent_ers(struct pci_dev *pdev, enum pci_ers_result err_type);
WARN_ONCE(condition, "%s %s: " fmt, \
dev_driver_string(&(pdev)->dev), pci_name(pdev), ##arg)
+#ifdef CONFIG_LIVEUPDATE
+int pci_liveupdate_get_driver_data(struct pci_dev *pdev, u64 *data);
+#else
+static inline int pci_liveupdate_get_driver_data(struct pci_dev *pdev,
+ u64 *data)
+{
+ return 0;
+}
+#endif
#endif /* LINUX_PCI_H */
--
2.50.1.487.gc89ff58d15-goog
Powered by blists - more mailing lists