[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250916-luo-pci-v2-8-c494053c3c08@kernel.org>
Date: Tue, 16 Sep 2025 00:45:16 -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>, Pasha Tatashin <pasha.tatashin@...een.com>
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 v2 08/10] 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 ae8f4dc5cf92577a4da83743c3b80bc72974a43e..1b12fc0649f479c6f45ffb26e6e3754f41054ea8 100644
--- a/drivers/pci/liveupdate.c
+++ b/drivers/pci/liveupdate.c
@@ -395,6 +395,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.51.0.384.g4c02a37b29-goog
Powered by blists - more mailing lists