[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250728-luo-pci-v1-12-955b078dd653@kernel.org>
Date: Mon, 28 Jul 2025 01:24:42 -0700
From: 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 12/25] PCI/LUO: Save struct pci_dev info during prepare
phase
From: Jason Miu <jasonmiu@...gle.com>
Some fields in the struct pci_dev are mutable during kernel execution,
and the runtime values cannot be re-construct from reading the PCI
config space registers again. Therefore, for the next kernel, we need
to save those fields for liveupdate during the prepare phase. Those
values are expected to be restored in the boot up time of the next
kernel.
The struct pci_dev_ser is packed for making sure the field offsets are
consistent across the kernel images before and after liveupdate.
We would like to save one more field for PCI resources, which has type
struct resource. It contains pointers so needs extra handlings in the
coming patches.
Signed-off-by: Chris Li <chrisl@...nel.org>
---
drivers/pci/liveupdate.c | 22 ++++++++++++++--------
drivers/pci/pci.h | 22 ++++++++++++++++++++++
2 files changed, 36 insertions(+), 8 deletions(-)
diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c
index f84c0a455f7055b9b64051b125368fb0f9e6144f..6b1c14d70fd16b0919ca22faae788069f3743708 100644
--- a/drivers/pci/liveupdate.c
+++ b/drivers/pci/liveupdate.c
@@ -18,14 +18,6 @@
static LIST_HEAD(preserved_devices);
static LIST_HEAD(probe_devices);
-struct pci_dev_ser {
- u32 path; /* domain + bus + slot + fn */
- u8 requested;
- u16 num_vfs;
- char driver_name[63];
- u64 driver_data; /* driver data */
-};
-
struct pci_ser {
u32 count;
struct pci_dev_ser devs[];
@@ -156,6 +148,20 @@ static int pci_save_device_state(struct device *dev, struct pci_dev_ser *s)
s->requested = dev->lu.requested;
if (pdev->sriov && pdev->is_physfn)
s->num_vfs = pdev->sriov->num_VFs;
+
+ s->devfn = pdev->devfn;
+ s->current_state = pdev->current_state;
+ s->pm_cap = pdev->pm_cap;
+ s->broken_intx_masking = pdev->broken_intx_masking;
+ s->pme_poll = pdev->pme_poll;
+ s->no_d3cold = pdev->no_d3cold;
+ s->wakeup_prepared = pdev->wakeup_prepared;
+ s->skip_bus_pm = pdev->skip_bus_pm;
+ s->ignore_hotplug = pdev->ignore_hotplug;
+ s->hotplug_user_indicators = pdev->hotplug_user_indicators;
+ s->pref_window = pdev->pref_window;
+ s->pref_64_window = pdev->pref_64_window;
+
return 0;
}
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index b79a18c5e948980fe2ef3f0a10e0d795b1eee6d7..2ef12745ee05960878d8d3fe0cdf136f69c8d408 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -489,6 +489,28 @@ struct pci_sriov {
bool drivers_autoprobe; /* Auto probing of VFs by driver */
};
+struct pci_dev_ser {
+ u32 path; /* domain + bus + slot + fn */
+ u8 requested;
+ u16 num_vfs;
+ char driver_name[63];
+ u64 driver_data; /* driver data */
+
+ /* Saved fields from struct pci_dev */
+ u32 devfn;
+ u32 current_state;
+ u8 pm_cap;
+ u32 broken_intx_masking:1;
+ u32 pme_poll:1;
+ u32 no_d3cold:1;
+ u32 wakeup_prepared:1;
+ u32 skip_bus_pm:1;
+ u32 ignore_hotplug:1;
+ u32 hotplug_user_indicators:1;
+ u32 pref_window:1;
+ u32 pref_64_window:1;
+} __packed;
+
#ifdef CONFIG_PCI_DOE
void pci_doe_init(struct pci_dev *pdev);
void pci_doe_destroy(struct pci_dev *pdev);
--
2.50.1.487.gc89ff58d15-goog
Powered by blists - more mailing lists