data_type large_stringclasses 3
values | source large_stringclasses 29
values | code large_stringlengths 98 49.4M | filepath large_stringlengths 5 161 ⌀ | message large_stringclasses 234
values | commit large_stringclasses 234
values | subject large_stringclasses 418
values | critique large_stringlengths 101 1.26M ⌀ | metadata dict |
|---|---|---|---|---|---|---|---|---|
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | Expose a few low-level helper routings for setting up vfio_pci_device
structs. These routines will be used in a subsequent commit to assert
that VFIO_GROUP_GET_DEVICE_FD fails under certain conditions.
Signed-off-by: David Matlack <dmatlack@google.com>
---
.../lib/include/libvfio/vfio_pci_device.h | 5 +++
.../selftests/vfio/lib/vfio_pci_device.c | 33 +++++++++++++------
2 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h b/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h
index 896dfde88118..2389c7698335 100644
--- a/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h
+++ b/tools/testing/selftests/vfio/lib/include/libvfio/vfio_pci_device.h
@@ -125,4 +125,9 @@ static inline bool vfio_pci_device_match(struct vfio_pci_device *device,
const char *vfio_pci_get_cdev_path(const char *bdf);
+/* Low-level routines for setting up a struct vfio_pci_device */
+struct vfio_pci_device *vfio_pci_device_alloc(const char *bdf, struct iommu *iommu);
+void vfio_pci_group_setup(struct vfio_pci_device *device);
+void vfio_pci_iommu_setup(struct vfio_pci_device *device);
+
#endif /* SELFTESTS_VFIO_LIB_INCLUDE_LIBVFIO_VFIO_PCI_DEVICE_H */
diff --git a/tools/testing/selftests/vfio/lib/vfio_pci_device.c b/tools/testing/selftests/vfio/lib/vfio_pci_device.c
index 08bb582eaa8f..76597c84e956 100644
--- a/tools/testing/selftests/vfio/lib/vfio_pci_device.c
+++ b/tools/testing/selftests/vfio/lib/vfio_pci_device.c
@@ -198,7 +198,7 @@ static unsigned int vfio_pci_get_group_from_dev(const char *bdf)
return group;
}
-static void vfio_pci_group_setup(struct vfio_pci_device *device, const char *bdf)
+void vfio_pci_group_setup(struct vfio_pci_device *device)
{
struct vfio_group_status group_status = {
.argsz = sizeof(group_status),
@@ -206,7 +206,7 @@ static void vfio_pci_group_setup(struct vfio_pci_device *device, const char *bdf
char group_path[32];
int group;
- group = vfio_pci_get_group_from_dev(bdf);
+ group = vfio_pci_get_group_from_dev(device->bdf);
snprintf(group_path, sizeof(group_path), "/dev/vfio/%d", group);
device->group_fd = open(group_path, O_RDWR);
@@ -218,14 +218,12 @@ static void vfio_pci_group_setup(struct vfio_pci_device *device, const char *bdf
ioctl_assert(device->group_fd, VFIO_GROUP_SET_CONTAINER, &device->iommu->container_fd);
}
-static void vfio_pci_container_setup(struct vfio_pci_device *device, const char *bdf)
+void vfio_pci_iommu_setup(struct vfio_pci_device *device)
{
struct iommu *iommu = device->iommu;
unsigned long iommu_type = iommu->mode->iommu_type;
int ret;
- vfio_pci_group_setup(device, bdf);
-
ret = ioctl(iommu->container_fd, VFIO_CHECK_EXTENSION, iommu_type);
VFIO_ASSERT_GT(ret, 0, "VFIO IOMMU type %lu not supported\n", iommu_type);
@@ -235,8 +233,14 @@ static void vfio_pci_container_setup(struct vfio_pci_device *device, const char
* because the IOMMU type is already set.
*/
(void)ioctl(iommu->container_fd, VFIO_SET_IOMMU, (void *)iommu_type);
+}
- device->fd = ioctl(device->group_fd, VFIO_GROUP_GET_DEVICE_FD, bdf);
+static void vfio_pci_container_setup(struct vfio_pci_device *device)
+{
+ vfio_pci_group_setup(device);
+ vfio_pci_iommu_setup(device);
+
+ device->fd = ioctl(device->group_fd, VFIO_GROUP_GET_DEVICE_FD, device->bdf);
VFIO_ASSERT_GE(device->fd, 0);
}
@@ -336,9 +340,7 @@ static void vfio_pci_iommufd_setup(struct vfio_pci_device *device,
vfio_device_attach_iommufd_pt(device->fd, device->iommu->ioas_id);
}
-struct vfio_pci_device *__vfio_pci_device_init(const char *bdf,
- struct iommu *iommu,
- int device_fd)
+struct vfio_pci_device *vfio_pci_device_alloc(const char *bdf, struct iommu *iommu)
{
struct vfio_pci_device *device;
@@ -349,9 +351,20 @@ struct vfio_pci_device *__vfio_pci_device_init(const char *bdf,
device->iommu = iommu;
device->bdf = bdf;
+ return device;
+}
+
+struct vfio_pci_device *__vfio_pci_device_init(const char *bdf,
+ struct iommu *iommu,
+ int device_fd)
+{
+ struct vfio_pci_device *device;
+
+ device = vfio_pci_device_alloc(bdf, iommu);
+
if (iommu->mode->container_path) {
VFIO_ASSERT_EQ(device_fd, -1);
- vfio_pci_container_setup(device, bdf);
+ vfio_pci_container_setup(device);
} else {
vfio_pci_iommufd_setup(device, bdf, device_fd);
}
--
2.53.0.rc1.225.gd81095ad13-goog | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Thu, 29 Jan 2026 21:25:07 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | Verify that opening a VFIO device through its cdev file and via
VFIO_GROUP_GET_DEVICE_FD both fail with -EBUSY if the device was
preserved across a Live Update. When a device file is preserve across a
Live Update, the file must be retrieved from /dev/liveupdate, not from
VFIO directly.
Signed-off-by: David Matlack <dmatlack@google.com>
---
.../vfio/vfio_pci_liveupdate_kexec_test.c | 38 +++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c b/tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
index 15b3e3af91d1..65c48196e44e 100644
--- a/tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
+++ b/tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
@@ -36,6 +36,42 @@ static void before_kexec(int luo_fd)
daemonize_and_wait();
}
+static void check_open_vfio_device_fails(void)
+{
+ const char *cdev_path = vfio_pci_get_cdev_path(device_bdf);
+ struct vfio_pci_device *device;
+ struct iommu *iommu;
+ int ret, i;
+
+ printf("Checking open(%s) fails\n", cdev_path);
+ ret = open(cdev_path, O_RDWR);
+ VFIO_ASSERT_EQ(ret, -1);
+ VFIO_ASSERT_EQ(errno, EBUSY);
+ free((void *)cdev_path);
+
+ for (i = 0; i < nr_iommu_modes; i++) {
+ if (!iommu_modes[i].container_path)
+ continue;
+
+ iommu = iommu_init(iommu_modes[i].name);
+
+ device = vfio_pci_device_alloc(device_bdf, iommu);
+ vfio_pci_group_setup(device);
+ vfio_pci_iommu_setup(device);
+
+ printf("Checking ioctl(group_fd, VFIO_GROUP_GET_DEVICE_FD, \"%s\") fails (%s)\n",
+ device_bdf, iommu_modes[i].name);
+
+ ret = ioctl(device->group_fd, VFIO_GROUP_GET_DEVICE_FD, device->bdf);
+ VFIO_ASSERT_EQ(ret, -1);
+ VFIO_ASSERT_EQ(errno, EBUSY);
+
+ close(device->group_fd);
+ free(device);
+ iommu_cleanup(iommu);
+ }
+}
+
static void after_kexec(int luo_fd, int state_session_fd)
{
struct vfio_pci_device *device;
@@ -44,6 +80,8 @@ static void after_kexec(int luo_fd, int state_session_fd)
int device_fd;
int stage;
+ check_open_vfio_device_fails();
+
restore_and_read_stage(state_session_fd, STATE_TOKEN, &stage);
VFIO_ASSERT_EQ(stage, 2);
--
2.53.0.rc1.225.gd81095ad13-goog | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Thu, 29 Jan 2026 21:25:08 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | Add a long-running DMA memcpy operation to
vfio_pci_liveupdate_kexec_test so that the device attempts to perform
DMAs continuously during the Live Update.
At this point iommufd preservation is not supported and bus mastering is
not kept enabled on the device during across the kexec, so most of these
DMAs will be dropped. However this test ensures that the current device
preservation support does not lead to system instability or crashes if
the device is active. And once iommufd and bus mastering are preserved,
this test can be relaxed to check that the DMA operations completed
successfully.
Signed-off-by: David Matlack <dmatlack@google.com>
---
.../vfio/vfio_pci_liveupdate_kexec_test.c | 129 ++++++++++++++++++
1 file changed, 129 insertions(+)
diff --git a/tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c b/tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
index 65c48196e44e..36bddfbb88ed 100644
--- a/tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
+++ b/tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
@@ -1,8 +1,16 @@
// SPDX-License-Identifier: GPL-2.0-only
+#include <linux/sizes.h>
+#include <sys/mman.h>
+
#include <libliveupdate.h>
#include <libvfio.h>
+#define MEMCPY_SIZE SZ_1G
+#define DRIVER_SIZE SZ_1M
+#define MEMFD_SIZE (MEMCPY_SIZE + DRIVER_SIZE)
+
+static struct dma_region memcpy_region;
static const char *device_bdf;
static char state_session[LIVEUPDATE_SESSION_NAME_LENGTH];
@@ -11,8 +19,89 @@ static char device_session[LIVEUPDATE_SESSION_NAME_LENGTH];
enum {
STATE_TOKEN,
DEVICE_TOKEN,
+ MEMFD_TOKEN,
};
+static void dma_memcpy_one(struct vfio_pci_device *device)
+{
+ void *src = memcpy_region.vaddr, *dst;
+ u64 size;
+
+ size = min_t(u64, memcpy_region.size / 2, device->driver.max_memcpy_size);
+ dst = src + size;
+
+ memset(src, 1, size);
+ memset(dst, 0, size);
+
+ printf("Kicking off 1 DMA memcpy operations of size 0x%lx...\n", size);
+ vfio_pci_driver_memcpy(device,
+ to_iova(device, src),
+ to_iova(device, dst),
+ size);
+
+ VFIO_ASSERT_EQ(memcmp(src, dst, size), 0);
+}
+
+static void dma_memcpy_start(struct vfio_pci_device *device)
+{
+ void *src = memcpy_region.vaddr, *dst;
+ u64 count, size;
+
+ size = min_t(u64, memcpy_region.size / 2, device->driver.max_memcpy_size);
+ dst = src + size;
+
+ /*
+ * Rough Math: If we assume the device will perform memcpy at a rate of
+ * 30GB/s then 7200GB of transfers will run for about 4 minutes.
+ */
+ count = (u64)7200 * SZ_1G / size;
+ count = min_t(u64, count, device->driver.max_memcpy_count);
+
+ memset(src, 1, size / 2);
+ memset(dst, 0, size / 2);
+
+ printf("Kicking off %lu DMA memcpy operations of size 0x%lx...\n", count, size);
+ vfio_pci_driver_memcpy_start(device,
+ to_iova(device, src),
+ to_iova(device, dst),
+ size, count);
+}
+
+static void dma_memfd_map(struct vfio_pci_device *device, int fd)
+{
+ void *vaddr;
+
+ vaddr = mmap(NULL, MEMFD_SIZE, PROT_WRITE, MAP_SHARED, fd, 0);
+ VFIO_ASSERT_NE(vaddr, MAP_FAILED);
+
+ memcpy_region.iova = SZ_4G;
+ memcpy_region.size = MEMCPY_SIZE;
+ memcpy_region.vaddr = vaddr;
+ iommu_map(device->iommu, &memcpy_region);
+
+ device->driver.region.iova = memcpy_region.iova + memcpy_region.size;
+ device->driver.region.size = DRIVER_SIZE;
+ device->driver.region.vaddr = vaddr + memcpy_region.size;
+ iommu_map(device->iommu, &device->driver.region);
+}
+
+static void dma_memfd_setup(struct vfio_pci_device *device, int session_fd)
+{
+ int fd, ret;
+
+ fd = memfd_create("dma-buffer", 0);
+ VFIO_ASSERT_GE(fd, 0);
+
+ ret = fallocate(fd, 0, 0, MEMFD_SIZE);
+ VFIO_ASSERT_EQ(ret, 0);
+
+ printf("Preserving memfd of size 0x%x in session\n", MEMFD_SIZE);
+ ret = luo_session_preserve_fd(session_fd, fd, MEMFD_TOKEN);
+ VFIO_ASSERT_EQ(ret, 0);
+
+ dma_memfd_map(device, fd);
+}
+
static void before_kexec(int luo_fd)
{
struct vfio_pci_device *device;
@@ -32,6 +121,27 @@ static void before_kexec(int luo_fd)
ret = luo_session_preserve_fd(session_fd, device->fd, DEVICE_TOKEN);
VFIO_ASSERT_EQ(ret, 0);
+ dma_memfd_setup(device, session_fd);
+
+ /*
+ * If the device has a selftests driver, kick off a long-running DMA
+ * operation to exercise the device trying to DMA during a Live Update.
+ * Since iommufd preservation is not supported yet, these DMAs should be
+ * dropped. So this is just looking to verify that the system does not
+ * fall over and crash as a result of a busy device being preserved.
+ */
+ if (device->driver.ops) {
+ vfio_pci_driver_init(device);
+ dma_memcpy_start(device);
+
+ /*
+ * Disable interrupts on the device or freeze() will fail.
+ * Unfortunately there isn't a way to easily have a test for
+ * that here since the check happens during shutdown.
+ */
+ vfio_pci_msix_disable(device);
+ }
+
close(luo_fd);
daemonize_and_wait();
}
@@ -78,6 +188,7 @@ static void after_kexec(int luo_fd, int state_session_fd)
struct iommu *iommu;
int session_fd;
int device_fd;
+ int memfd;
int stage;
check_open_vfio_device_fails();
@@ -88,6 +199,10 @@ static void after_kexec(int luo_fd, int state_session_fd)
session_fd = luo_retrieve_session(luo_fd, device_session);
VFIO_ASSERT_GE(session_fd, 0);
+ printf("Retrieving memfd from LUO\n");
+ memfd = luo_session_retrieve_fd(session_fd, MEMFD_TOKEN);
+ VFIO_ASSERT_GE(memfd, 0);
+
printf("Finishing the session before retrieving the device (should fail)\n");
VFIO_ASSERT_NE(luo_session_finish(session_fd), 0);
@@ -109,9 +224,23 @@ static void after_kexec(int luo_fd, int state_session_fd)
*/
device = __vfio_pci_device_init(device_bdf, iommu, device_fd);
+ dma_memfd_map(device, memfd);
+
printf("Finishing the session\n");
VFIO_ASSERT_EQ(luo_session_finish(session_fd), 0);
+ /*
+ * Once iommufd preservation is supported and the device is kept fully
+ * running across the Live Update, this should wait for the long-
+ * running DMA memcpy operation kicked off in before_kexec() to
+ * complete. But for now we expect the device to be reset so just
+ * trigger a single memcpy to make sure it's still functional.
+ */
+ if (device->driver.ops) {
+ vfio_pci_driver_init(device);
+ dma_memcpy_one(device);
+ }
+
vfio_pci_device_cleanup(device);
iommu_cleanup(iommu);
}
--
2.53.0.rc1.225.gd81095ad13-goog | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Thu, 29 Jan 2026 21:25:09 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | From: Vipin Sharma <vipinsh@google.com>
Add a selftest to exercise preserving a vfio-pci device across a Live
Update. For now the test is extremely simple and just verifies that the
device file can be preserved and retrieved. In the future this test will
be extended to verify more parts about device preservation as they are
implemented.
This test is added to TEST_GEN_PROGS_EXTENDED since it must be run
manually along with a kexec.
To run this test manually:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ... # NOTE: Exact method will be distro-dependent
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
The second call to setup.sh is necessary because preserved devices are
not bound to a driver after Live Update. Such devices must be manually
bound by userspace after Live Update via driver_override.
This test is considered passing if all commands exit with 0.
Signed-off-by: Vipin Sharma <vipinsh@google.com>
Co-developed-by: David Matlack <dmatlack@google.com>
Signed-off-by: David Matlack <dmatlack@google.com>
---
tools/testing/selftests/vfio/Makefile | 4 +
.../vfio/vfio_pci_liveupdate_kexec_test.c | 89 +++++++++++++++++++
2 files changed, 93 insertions(+)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
diff --git a/tools/testing/selftests/vfio/Makefile b/tools/testing/selftests/vfio/Makefile
index 666310872217..55d685f6e540 100644
--- a/tools/testing/selftests/vfio/Makefile
+++ b/tools/testing/selftests/vfio/Makefile
@@ -6,6 +6,10 @@ TEST_GEN_PROGS += vfio_pci_device_init_perf_test
TEST_GEN_PROGS += vfio_pci_driver_test
TEST_GEN_PROGS += vfio_pci_liveupdate_uapi_test
+# This test must be run manually since it requires the user/automation to
+# perform a kexec during the test.
+TEST_GEN_PROGS_EXTENDED += vfio_pci_liveupdate_kexec_test
+
TEST_FILES += scripts/cleanup.sh
TEST_FILES += scripts/lib.sh
TEST_FILES += scripts/run.sh
diff --git a/tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c b/tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
new file mode 100644
index 000000000000..15b3e3af91d1
--- /dev/null
+++ b/tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <libliveupdate.h>
+#include <libvfio.h>
+
+static const char *device_bdf;
+
+static char state_session[LIVEUPDATE_SESSION_NAME_LENGTH];
+static char device_session[LIVEUPDATE_SESSION_NAME_LENGTH];
+
+enum {
+ STATE_TOKEN,
+ DEVICE_TOKEN,
+};
+
+static void before_kexec(int luo_fd)
+{
+ struct vfio_pci_device *device;
+ struct iommu *iommu;
+ int session_fd;
+ int ret;
+
+ iommu = iommu_init("iommufd");
+ device = vfio_pci_device_init(device_bdf, iommu);
+
+ create_state_file(luo_fd, state_session, STATE_TOKEN, /*next_stage=*/2);
+
+ session_fd = luo_create_session(luo_fd, device_session);
+ VFIO_ASSERT_GE(session_fd, 0);
+
+ printf("Preserving device in session\n");
+ ret = luo_session_preserve_fd(session_fd, device->fd, DEVICE_TOKEN);
+ VFIO_ASSERT_EQ(ret, 0);
+
+ close(luo_fd);
+ daemonize_and_wait();
+}
+
+static void after_kexec(int luo_fd, int state_session_fd)
+{
+ struct vfio_pci_device *device;
+ struct iommu *iommu;
+ int session_fd;
+ int device_fd;
+ int stage;
+
+ restore_and_read_stage(state_session_fd, STATE_TOKEN, &stage);
+ VFIO_ASSERT_EQ(stage, 2);
+
+ session_fd = luo_retrieve_session(luo_fd, device_session);
+ VFIO_ASSERT_GE(session_fd, 0);
+
+ printf("Finishing the session before retrieving the device (should fail)\n");
+ VFIO_ASSERT_NE(luo_session_finish(session_fd), 0);
+
+ printf("Retrieving the device FD from LUO\n");
+ device_fd = luo_session_retrieve_fd(session_fd, DEVICE_TOKEN);
+ VFIO_ASSERT_GE(device_fd, 0);
+
+ printf("Finishing the session before binding to iommufd (should fail)\n");
+ VFIO_ASSERT_NE(luo_session_finish(session_fd), 0);
+
+ printf("Binding the device to an iommufd and setting it up\n");
+ iommu = iommu_init("iommufd");
+
+ /*
+ * This will invoke various ioctls on device_fd such as
+ * VFIO_DEVICE_GET_INFO. So this is a decent sanity test
+ * that LUO actually handed us back a valid VFIO device
+ * file and not something else.
+ */
+ device = __vfio_pci_device_init(device_bdf, iommu, device_fd);
+
+ printf("Finishing the session\n");
+ VFIO_ASSERT_EQ(luo_session_finish(session_fd), 0);
+
+ vfio_pci_device_cleanup(device);
+ iommu_cleanup(iommu);
+}
+
+int main(int argc, char *argv[])
+{
+ device_bdf = vfio_selftests_get_bdf(&argc, argv);
+
+ sprintf(device_session, "device-%s", device_bdf);
+ sprintf(state_session, "state-%s", device_bdf);
+
+ return luo_test(argc, argv, state_session, before_kexec, after_kexec);
+}
--
2.53.0.rc1.225.gd81095ad13-goog | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Thu, 29 Jan 2026 21:25:05 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | Hi David,
On Thu, 29 Jan 2026 21:24:57 +0000
David Matlack <dmatlack@google.com> wrote:
Just wondering what happened to skipping the bus master clearing. I
understand this version does not preserve the device itself yet; I’m
just curious whether there were specific difficulties that led to
dropping the earlier patch which skipped clearing bus master. | {
"author": "Jacob Pan <jacob.pan@linux.microsoft.com>",
"date": "Thu, 29 Jan 2026 14:21:58 -0800",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On 2026-01-29 02:21 PM, Jacob Pan wrote:
Hi Jacob,
There's several places where bus master gets cleared that we need to
eventually eliminate to fully preserve the device.
1. vfio_pci_liveupdate_freeze() clears it during shutdown when it
restores vdev->pci_saved_state.
2. pci_device_shutdown() clears it during shutdown.
3. vfio_pci_core_enable() clears it when the preserved device file
is bound to an iommufd after the Live Update (in
vfio_pci_core_enable()).
I think it would be safe to skip (3) in this series, since that's very
similar to how this series skips resets during vfio_pci_core_enable()
for preserved devices.
But I don't think it would be safe to skip (1) or (2) until the attached
iommufd is fully preserved.
If you are just asking about (3) then I agree it could be skipped and I
can include that in the next version. | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Thu, 29 Jan 2026 22:33:13 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | Hi David,
On Thu, 29 Jan 2026 22:33:13 +0000
David Matlack <dmatlack@google.com> wrote:
I was just asking about (3) and trying to understand the asymmetric
handling compared to reset. I don’t have a strong preference since this
is temporary—thanks for the explanation.
I’ve been testing my noiommu cdev patches on top of yours, and so far
they behave the same as with a real IOMMU. As you noted, however, final
device preservation still depends on iommufd. | {
"author": "Jacob Pan <jacob.pan@linux.microsoft.com>",
"date": "Thu, 29 Jan 2026 16:31:50 -0800",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | 在 2026/1/29 13:24, David Matlack 写道:
Can the above 2 functions support the virtual devices? For example,
bonding, veth, iSWAP and RXE.
These virtual devices do not have BDF. As such, I am not sure if your
patches take these virtual devices in to account.
Thanks a lot.
Zhu Yanjun
--
Best Regards,
Yanjun.Zhu | {
"author": "Zhu Yanjun <yanjun.zhu@linux.dev>",
"date": "Sat, 31 Jan 2026 22:38:18 -0800",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Sat, Jan 31, 2026 at 10:38 PM Zhu Yanjun <yanjun.zhu@linux.dev> wrote:
No this patch series only supports PCI devices, since those are the
only devices so far we've needed to support.
I am not familiar with any of the devices that you mentioned. If they
are virtual then does that mean it's all just software? In that case I
would be curious to know what problem is solved by preserving them in
the kernel, vs. tearing them down and rebuilding them across a Live
Udpate. | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Mon, 2 Feb 2026 10:14:56 -0800",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On 2/2/26 10:14 AM, David Matlack wrote:
Bonding, veth, rxe, and siw can be used in KVM environments.
Although these are software-only virtual devices with no associated
hardware,
they may maintain state that is observable by userspace.
As a result, Live Update should preserve their state across the update.
Zhu Yanjun | {
"author": "\"Yanjun.Zhu\" <yanjun.zhu@linux.dev>",
"date": "Tue, 3 Feb 2026 16:10:04 -0800",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On 1/29/26 1:24 PM, David Matlack wrote:
813 int liveupdate_register_file_handler(struct liveupdate_file_handler *fh)
814 {
815 struct liveupdate_file_handler *fh_iter;
816 int err;
817
818 if (!liveupdate_enabled())
819 return -EOPNOTSUPP;
In the function liveupdate_register_file_handler, liveupdate_enabled is also checked.
as such, it is not necessary to check here?
+
+ return liveupdate_register_file_handler(&vfio_pci_liveupdate_fh);
+}
+
+void vfio_pci_liveupdate_cleanup(void)
+{
+ if (!liveupdate_enabled())
+ return;
+
ditto
Zhu Yanjun | {
"author": "\"Yanjun.Zhu\" <yanjun.zhu@linux.dev>",
"date": "Fri, 6 Feb 2026 14:37:45 -0800",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On 2026-02-06 02:37 PM, Yanjun.Zhu wrote:
Yeah that is a bit odd. I see that memfd_luo_init() just checks for
-EOPNOTSUPP. We can do the same thing here. | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Fri, 6 Feb 2026 23:14:46 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Tue, Feb 3, 2026 at 4:10 PM Yanjun.Zhu <yanjun.zhu@linux.dev> wrote:
Sorry for taking so long to get back to you.
Userspace should serialize the state of those devices out of the
kernel, persist it in memory or on disk across Live Update, and then
recreate it after Live Update.
This is why, for example, KVM does not need to direclty participate in
Live Update. The VMM serializes all KVM state from the kernel, saves
it, and then constructs a completely new KVM VM after the Live Update
using that state. KVM will only need to participate in Live Update
once there is hardware requirement. For example, I believe some of the
Confidential Computing hardware virtualization extensions require
certain memory structures used by hardware remain in place and cannot
be reallocated after Live Update. KVM would have to participate to
preserve those and reassociate them with the right VM after Live
Update. | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Fri, 20 Feb 2026 11:03:18 -0800",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, Jan 29, 2026 at 09:24:49PM +0000, David Matlack wrote:
nit: Preserve and Unpreserve can only be done from outgoing kernel, maybe
remove the "outgoing" from the function name.
This will not work for SRIOV as new devices will be registered when
sriov is enabled and the max will increase. As we are not handling VFs
with this patch series, this can be fine? | {
"author": "Samiullah Khawaja <skhawaja@google.com>",
"date": "Mon, 23 Feb 2026 22:04:51 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, Jan 29, 2026 at 09:24:52PM +0000, David Matlack wrote:
Reviewed-by: Samiullah Khawaja <skhawaja@google.com> | {
"author": "Samiullah Khawaja <skhawaja@google.com>",
"date": "Mon, 23 Feb 2026 22:29:03 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Mon, Feb 23, 2026 at 2:04 PM Samiullah Khawaja <skhawaja@google.com> wrote:
That's reasonable, I can make that change in v3.
That's right. Since this series does not support VFs
(pci_liveupdate_outgoing_preserve(VF) will return -EINVAL), I dropped
the logic from v1 that included the maximum possible number of VFs in
max_nr_devices.
Once we add support for preserving VFs, we can update this logic.
Another way that pci_liveupdate_outgoing_preserve() could fail due to
running out of room is if hot-plugged devices are preserved. But I
don't think that's an important problem to solve right now. | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Mon, 23 Feb 2026 15:08:19 -0800",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, Jan 29, 2026 at 09:24:53PM +0000, David Matlack wrote:
Reviewed-by: Samiullah Khawaja <skhawaja@google.com> | {
"author": "Samiullah Khawaja <skhawaja@google.com>",
"date": "Mon, 23 Feb 2026 23:27:35 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Mon, Feb 23, 2026 at 03:08:19PM -0800, David Matlack wrote:
I should have added it earlier, but the same applies to the
pci_liveupdate_incoming_finish() as it can only be done with incoming
kernel. Maybe we can remove incoming from it also for consistency? | {
"author": "Samiullah Khawaja <skhawaja@google.com>",
"date": "Mon, 23 Feb 2026 23:43:42 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Mon, Feb 23, 2026 at 3:43 PM Samiullah Khawaja <skhawaja@google.com> wrote:
Yeah I can make that change as well.
I was erring on the side of being overly explicity with the
incoming/outgoing terminology, but I agree it's unnecessary in these
APIs. | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Mon, 23 Feb 2026 16:00:56 -0800",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, Jan 29, 2026 at 09:24:48PM +0000, David Matlack wrote:
Reviewed-by: Pranjal Shrivastava <praan@google.com> | {
"author": "Pranjal Shrivastava <praan@google.com>",
"date": "Tue, 24 Feb 2026 08:26:08 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, Jan 29, 2026 at 09:24:49PM +0000, David Matlack wrote:
Nit: Should these be 2026 now?
I'm wondering how (or if) this handles hot-plugged devices?
max_nr_devices is calculated based on for_each_pci_dev at the time of
the first preservation.. what happens if a device is hotplugged after
the first device is preserved but before the second one is, does
max_nr_devices become stale? Since ser->max_nr_devices will not reflect
the actual possible device count, potentially leading to an unnecessary
-E2BIG failure?
Masking this error looks troubled, in the following patch, I see that
the retval 0 is treated as a fresh boot, but the IOMMU mappings for that
BDF might still be preserved? Which could lead to DMA aliasing issues,
without a hint of what happened since we don't even log anything.
Maybe we could have something like the following:
int pci_liveupdate_incoming_nr_devices(void)
{
struct pci_ser *ser;
int ret;
ret = liveupdate_flb_get_incoming(&pci_liveupdate_flb, (void **)&ser);
if (ret) {
if (ret != -ENOENT)
pr_warn("PCI: Failed to retrieve preservation list: %d\n", ret);
return ret;
}
return ser->nr_devices;
}
We should log something here either at info / debug level since the
error isn't bubbled up and the luo_core doesn't scream about it either.
This feels a little hacky, shall we go for something like:
dev->liveupdate_incoming = (pci_ser_find(ser, dev) != NULL); ?
This would start another anon bitfield container, should we move this
above within the existing bitfield? If we've run pahole and found this
to be better, then this should be fine.
[ ---->8------]
Thanks,
Praan | {
"author": "Pranjal Shrivastava <praan@google.com>",
"date": "Tue, 24 Feb 2026 09:17:48 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, Jan 29, 2026 at 09:24:50PM +0000, David Matlack wrote:
Following the comment on Patch 2 regarding propagating errors, the check
if (pci_liveupdate_incoming_nr_devices()) should be made explicit to
distinguish between "Preservation Active" and "Retrieval Failed".
Looks like we over-ride the pci=assign-busses boot param here.
We should document how this change affects the pci=assign-busses kernel
command line. If both are present, the inheritance required by LUO would
likely take precedence to prevent DMA corruption, but a doc update & a
warning to the user would be nice.
Thanks,
Praan | {
"author": "Pranjal Shrivastava <praan@google.com>",
"date": "Tue, 24 Feb 2026 09:36:03 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Fri, Feb 06, 2026 at 11:14:46PM +0000, David Matlack wrote:
If we move to checking the return value for -EOPNOTSUPP, we should
ensure the pattern is consistent for the upcoming PCI registration in
Patch 7 as well. With this addressed:
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Thanks,
Praan | {
"author": "Pranjal Shrivastava <praan@google.com>",
"date": "Tue, 24 Feb 2026 09:58:55 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, Jan 29, 2026 at 09:24:48PM +0000, David Matlack wrote:
Reviewed-by: Samiullah Khawaja <skhawaja@google.com> | {
"author": "Samiullah Khawaja <skhawaja@google.com>",
"date": "Tue, 24 Feb 2026 17:08:11 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Tue, Feb 24, 2026 at 1:18 AM Pranjal Shrivastava <praan@google.com> wrote:
Yes! Thanks for catching that.
Yes, it's possible to run out space to preserve devices if devices are
hot-plugged and then preserved. But I think it's better to defer
handling such a use-case exists (unless you see an obvious simple
solution). So far I am not seeing preserving hot-plugged devices
across Live Update as a high priority use-case to support.
All fo the non-0 errors indicate there are 0 incoming devices at the
time of the call, so I think returning 0 is appropriate.
- EOPNOTSUPP: Live Update is not enabled.
- ENODATA: Live Update is finished (all incoming devices have been restored).
- ENOTENT: No PCI data was preserved across the Live Update.
None of these cover the case where an IOMMU mapping for BDF X is
preserved, but device X is not preserved. This is a case we should
handle in some way... but here is not that place.
This would cause this warning to get printed if Live Update was
disabled, or if no PCI devices were preserved. But both of those are
not error scenarios.
Any error from liveupdate_flb_get_incoming() simply means there are no
incoming devices. So I don't think there's any error to report in
dmesg.
In my experience in the kernel (mostly from KVM), explicity comparison
to NULL is less preferred to treating a pointer as a boolean. But I'm
ok with following whatever is the locally preferred style for this
kind of check.
Yeah I simply appended these new fields to the very end of the struct.
If we care about optimizing the packing of struct pci_dev I can find a
better place to put it. | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Tue, 24 Feb 2026 09:33:28 -0800",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Tue, Feb 24, 2026 at 1:36 AM Pranjal Shrivastava <praan@google.com> wrote:
As mentioned in the previous patch, the errors mean "no incoming
devices" rather than "retrieval failed".
Good call, I'll add a log message and update kernel-parameters.txt in v3. | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Tue, 24 Feb 2026 09:36:50 -0800",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, Jan 29, 2026 at 09:24:52PM +0000, David Matlack wrote:
I see the 'Eventually both of these should be dropped' comment,
which acknowledges that a reset is a v1 crutch. However, I wanted to
clarify the fallback strategy here.
If vdev->reset_works is false, we skip the reset but still jump into the
new kernel. For devices that don't support FLR, are we comfortable jumping
with the device potentially still hot?
There seem to be two extern declarations for vfio_device_fops in both
vfio_pci_priv.h and include/linux/vfio.h. Could we consolidate these?
I'm a little uncomfortable with this part. Why is it necessary to expose
the internal vfio_device_file structure to drivers? If this is only to
support vfio_device_from_file(), could we not keep the structure private
and just export the helper function instead?
Exposing internal state into the public API introduces some maintenance
constraints for e.g. if vfio_main.c ever changes how it tracks
file-to-device mappings or its internal security state (like
access_granted), it now has to worry about breaking external drivers.
I believe we expose the struct just to power these static inline helper
(mainly vfio_device_from_file) ? Instead, could we treat
`vfio_device_file` as an opaque type in the public header (like struct
iommu_group) and move the implementation of vfio_device_from_file() into
vfio_main.c as an exported symbol? This gives drivers the vfio_device
pointer they need without leaking the core's private internals. Maybe
something like the following (untested):
diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c
index f7df90c423b4..71e3dda53187 100644
--- a/drivers/vfio/vfio_main.c
+++ b/drivers/vfio/vfio_main.c
@@ -1446,6 +1446,18 @@ static struct vfio_device *vfio_device_from_file(struct file *file)
return df->device;
}
+struct vfio_device *vfio_device_from_file(struct file *file)
+{
+ struct vfio_device_file *df;
+
+ if (file->f_op != &vfio_device_fops)
+ return NULL;
+
+ df = file->private_data;
+ return df->device;
+}
+EXPORT_SYMBOL_GPL(vfio_device_from_file);
+
/**
* vfio_file_is_valid - True if the file is valid vfio file
* @file: VFIO group file or VFIO device file
diff --git a/include/linux/vfio.h b/include/linux/vfio.h
index e90859956514..182f192c5641 100644
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -81,6 +81,15 @@ struct vfio_device {
#endif
};
+
+struct vfio_device_file;
+
+extern const struct file_operations vfio_device_fops;
+
+/* Public API for drivers */
+struct vfio_device *vfio_device_from_file(struct file *file);
+ [...]
+
Thanks,
Praan | {
"author": "Pranjal Shrivastava <praan@google.com>",
"date": "Tue, 24 Feb 2026 18:37:58 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Tue, Feb 24, 2026 at 09:33:28AM -0800, David Matlack wrote:
Ack. If we aren't supporting preservation for hot-plug at this point.
Let's mention that somewhere? Maybe just a little comment or the kdoc?
I agree, the snippet was just an example. What I'm trying to say here
is, what if the retval is -ENOMEM / -ENODATA, the existing code will
treat it as a fresh boot because it believes there are no incoming
devices. However, since this was an incoming device which failed to be
retrieved, there's a chance that it's IOMMU mapping was preserved too.
By returning 0, the PCI core will feel free to rebalance bus numbers or
reassign BARs. For instance, if the IOMMU already inherited mappings for
BDF 02:00.0, but the PCI core (due to this masked error) reassigns a
different device to that BDF, we face DMA aliasing or IOMMU faults.
Am I missing some context here?
No strong feelings there, I see both being used in drivers/pci.
If you have pahole handy, it would be great to see if these can slide
into an existing hole. If not, no big deal for v3.. we can keep it as is
Thanks,
Praan | {
"author": "Pranjal Shrivastava <praan@google.com>",
"date": "Tue, 24 Feb 2026 19:02:56 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Tue, Feb 24, 2026 at 07:02:56PM +0000, Pranjal Shrivastava wrote:
The flb_retrive_one seems to call:
err = flb->ops->retrieve(&args);
which could be anything honestly.. since the luo_core doesn't scream
about it, maybe the caller should?
Thanks,
Praan | {
"author": "Pranjal Shrivastava <praan@google.com>",
"date": "Tue, 24 Feb 2026 19:05:41 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Tue, Feb 24, 2026 at 10:38 AM Pranjal Shrivastava <praan@google.com> wrote:
That situation is already possible today. Simply use a VFIO device
that does not support reset, close it, and then kexec into a new
kernel. vfio_pci_core_disable() (which runs when the last reference to
the VFIO device file is dropped) also skips the reset, and kexec does
not reset devices.
Note that we still restore the state, which at least will reset the
device's configuration back to a sane default, including disabling bus
mastering.
Sure I can clean those up.
Yeah, no problem.
Good points. | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Tue, 24 Feb 2026 11:16:55 -0800",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, Jan 29, 2026 at 09:24:53PM +0000, David Matlack wrote:
The use of anon_inode_getfile_fmode() is clever! The abstraction is
clean as well.
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Thanks!
Praan | {
"author": "Pranjal Shrivastava <praan@google.com>",
"date": "Tue, 24 Feb 2026 19:19:30 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, Jan 29, 2026 at 09:24:54PM +0000, David Matlack wrote:
Nit: We might need to handle the retval here if we remove the
liveupdate_enabled() check above (as discussed in patch 2).
same here.
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Thanks,
Praan | {
"author": "Pranjal Shrivastava <praan@google.com>",
"date": "Wed, 25 Feb 2026 07:55:51 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, Jan 29, 2026 at 09:24:55PM +0000, David Matlack wrote:
Reviewed-by: Pranjal Shrivastava <praan@google.com>
Thanks,
Praan | {
"author": "Pranjal Shrivastava <praan@google.com>",
"date": "Wed, 25 Feb 2026 08:03:18 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, Jan 29, 2026 at 09:24:56PM +0000, David Matlack wrote:
Since we set this to NULL in the success path of vfio_pci_core_enable()
I'm wondering if a failure in vfio_pci_core_enable could cause a
resource leak? Because vfio_pci_liveupdate_can_finish() returns false
as long as that pointer is valid, a single device failure will
perpetually block the LIVEUPDATE_SESSION_FINISH IOCTL for the entire
session preventing the LUO from reclaiming KHO memory.
Shall we also set vdev->liveupdate_incoming_state = NULL on the error
paths of vfio_pci_core_enable() ?
Thanks,
Praan | {
"author": "Pranjal Shrivastava <praan@google.com>",
"date": "Wed, 25 Feb 2026 08:38:02 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, 29 Jan 2026 21:24:51 +0000
David Matlack <dmatlack@google.com> wrote:
...
liveupdate_register_file_handler() "pins" vfio-pci with a
try_module_get(). Since this is done in our module_init function and
unregister occurs in our module_exit function, rather than relative
to any actual device binding or usage, this means vfio-pci CANNOT be
unloaded. That seems bad. Thanks,
Alex | {
"author": "Alex Williamson <alex@shazbot.org>",
"date": "Wed, 25 Feb 2026 14:33:28 -0700",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Wed, Feb 25, 2026 at 02:33:28PM -0700, Alex Williamson wrote:
Hmm... IIUC the concern here is about liveupdate policy if the user
wants to unload a module which was previously marked for preservation?
AFAICT, In such a case, the user is expected to close the LUO session FD,
which "unpreserves" the FD. Finally, when rmmod is executed, the __exit
(vfio_pci_cleanup) calls vfio_pci_liveupdate_cleanup() which ends up
calling liveupdate_unregister_file_handler(), thereby dropping the ref
held by the liveupdate orchestrator which allows the module to be
unloaded.
I think we should document this policy somewhere or have a dev_warn to
scream at the users when they try unloading the module without closing
the session FD.
Thanks,
Praan | {
"author": "Pranjal Shrivastava <praan@google.com>",
"date": "Wed, 25 Feb 2026 22:06:18 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Wed, Feb 25, 2026 at 10:06:18PM +0000, Pranjal Shrivastava wrote:
Ohh wait, You're right, Alex. I just realized the __exit won't even be
reached because of the internal pin. The current implementation creates
a catch-22 where the module pins itself during init and can't reach the
unregister call in exit. I believe we should drop the ref when the user
closes the session FD? Additionally, should we move try_module_get out of
the global liveupdate_register_file_handler() and instead take the ref
only when a file is actually marked for preservation?
Thanks,
Praan | {
"author": "Pranjal Shrivastava <praan@google.com>",
"date": "Wed, 25 Feb 2026 22:29:41 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, 29 Jan 2026 21:24:52 +0000
David Matlack <dmatlack@google.com> wrote:
Why can't we use vfio_device_cdev_opened() here and avoid all the new
exposure in public headers?
struct vfio_device *device = vfio_device_from_file(file);
if (!device)
return false;
if (!vfio_device_cdev_opened(device))
return false;
return device->ops == &vfio_pci_ops;
Some comments describing what's missing, if these are TODO or DONTCARE
would be useful.
device_lock() is a dangerous source of deadlocks, for instance how can
we know the freeze isn't occurring with an outstanding driver unbind?
Seems we just need to export vfio_device_from_file(). Thanks,
Alex | {
"author": "Alex Williamson <alex@shazbot.org>",
"date": "Wed, 25 Feb 2026 15:41:24 -0700",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, Jan 29, 2026 at 09:24:49PM +0000, David Matlack wrote:
I'd probably describe this in the "outgoing ... incoming" order since
that's the order of operation.
In what sense is this "global"? I assume it doesn't mean global
scope; does it mean something that persists across the kexec?
IIUC this is basically asking the PCI core to preserve the generic PCI
parts of a device, i.e., the PCI core and the driver collaborate to
preserve it?
I know what "preserve" means: "please maintain the original state."
The sort of made-up "unpreserve" sounds nicely symmetric, but I don't
think it means "destroy the original state." It feels like more of a
"cancel" of the original request to preserve something. Maybe not
worth any change, but I suspect this operation is going to be part of
the user interface for the administrator, and the description of
"unpreserve" will probably include something like "cancel."
I see how drivers need to know whether their device has been preserved
and needs to be adopted, but what does userspace have to do with this?
I don't know what the file is, but it doesn't sound related to the PCI
core, so maybe it should be mentioned elsewhere?
I assume the PCI core preserves a device based only on the indication
from the previous kernel.
2026
How is this protected against hotplug?
What is this warning telling the user? Is there something wrong?
What would I do to fix things if I saw this, and how would I know what
to do?
Is this telling us that we're undoing a "preserve" operation, which is
supposed to involve "unpreserve" on each device that has previously
been marked for preservation, but something (what?) forgot to
unpreserve one of the devices?
Seems like maybe a debugging aid, but probably not something an
indication that the administrator did something wrong?
I don't see anything in this series that checks this. Maybe omit it
until it's used?
Is there a real need to keep "dev->liveupdate_outgoing", as opposed to
just searching ser->devices[]? It looks like the only use is to keep
from adding a device to ser->devices[] twice.
I guess this "get" must correspond with the kho_alloc_preserve() in
pci_flb_preserve()? It's sort of annoying that there's nothing in the
function names to connect them because it's hard to find the source.
I'm a little dubious about all the WARN_ON_ONCE() calls here. They
seem like debugging aids that we would want to remove eventually, so
maybe they should just be out-of-tree to begin with.
I don't like putting code with side effects inside WARN_ON() because
the important code gets hidden.
Currently only called from drivers/pci/probe.c; does this really need
to be declared in include/linux/pci.h and exported? We can do that
later if/when needed. Put in drivers/pci/pci.h if only needed in
drivers/pci/.
I think this would be easier to read as:
if (pci_ser_find(ser, dev))
dev->liveupdate_incoming = true;
Currently only called from pci_setup_device(); does this really need
to be declared in include/linux/pci.h and exported? We can do that
later if/when needed.
What is this useful for? Does the PCI core need to *do* anything
after a driver finishes its own adoption of a preserved device? I
assume everything the PCI core does, i.e., rebuilding its pci_dev and
related things based on KHO data, must be done before the driver sees
the device.
Seems unusual to make an abi/ subdirectory when that's the only thing
in kho/, but I assume you have plans for more.
There are several *-abi.h files in include/uapi/, but this abi/
directory is the ABI-ish name in include/linux (except for the
include/soc/tegra/bpmp-abi.h oddity).
ACPI _SEG is limited to 16 bits, but I think all the Linux interfaces
use "int" and VMD creates domains starting with 0x10000 to avoid
colliding with ACPI segment numbers. I think we should probably use
u32 here (and for the Linux interfaces, but that's another patch). | {
"author": "Bjorn Helgaas <helgaas@kernel.org>",
"date": "Wed, 25 Feb 2026 16:46:51 -0600",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, Jan 29, 2026 at 09:24:50PM +0000, David Matlack wrote:
I think changing bus numbers would break DMA regardless of whether an
IOMMU is involved. Completions carrying the data for DMA reads are
routed back to the Requester ID of the read. | {
"author": "Bjorn Helgaas <helgaas@kernel.org>",
"date": "Wed, 25 Feb 2026 16:47:46 -0600",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Wed, Feb 25, 2026 at 2:29 PM Pranjal Shrivastava <praan@google.com> wrote:
If we don't do try_module_get during registration, the registered file
handler can go away on module unload while LUO is using the handler
during FD preservation. This makes it racy. Maybe register/unregister
need to move outside the module_init/exit. | {
"author": "Samiullah Khawaja <skhawaja@google.com>",
"date": "Wed, 25 Feb 2026 14:50:47 -0800",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On 2026-02-25 02:33 PM, Alex Williamson wrote:
Good point. So a better approach that would allow vfio-pci to be
unloaded would be to register the file handler when the number of
devices bound to vfio-pci goes from 0->1 and then unregister on 1->0. | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Wed, 25 Feb 2026 23:15:43 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On 2026-02-25 04:47 PM, Bjorn Helgaas wrote:
Ahh, makes sense. I'll clarify the commit message in the next version. | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Wed, 25 Feb 2026 23:20:10 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On 2026-02-25 03:41 PM, Alex Williamson wrote:
I thought I explored using vfio_device_cdev_opened() but I can't
remember now why I went with df->group. Maybe there wasn't a good
reason. I'll switch to vfio_device_cdev_opened() in the next version.
Will do.
I can change this to a try-lock and return an error if taking the lock
fails. The freeze() callbacks are triggered by liveupdate_reboot() which
is called from kernel_kexec(). So returning an error to userspace is
possible.
My only concern is whether using try-lock would make kexec flaky, or if
it would only fail if userspace is misbehavior (e.g. unbinding drivers
while kexecing).
Will do. | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Wed, 25 Feb 2026 23:41:04 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Wed, Feb 25, 2026 at 3:15 PM David Matlack <dmatlack@google.com> wrote:
Yeah maybe a kref that gets inc/dec in probe/remove. I have a similar
problem with iommufd preservation, but I think I can handle it based
on the number of iommufd open.
I am wondering whether this file handler registration kref stuff can
be moved into LUO by adding it to LUO file_handler and the modules
only call get/put? | {
"author": "Samiullah Khawaja <skhawaja@google.com>",
"date": "Wed, 25 Feb 2026 15:54:47 -0800",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On 2026-02-25 04:46 PM, Bjorn Helgaas wrote:
Will do.
Global in the sense that there is only one struct pci_ser in the system.
There is no global variable for it though. It is created
pci_flb_preserve() when the first device is preserved (and destroyed
after the last device is unpreserved/cancelled).
So it's lifecycle is bound to the number of devices. It is maintained by
LUO (which does not know about devices, it just knows about files being
preserved). For the PCI FLB, each file happens to correspond to a device
(these are vfio-pci device files), but LUO doesn't need to know or care.
Yeah it is a cancel of the original request. I chose the name to match
the callback op that this function implements
(liveupdate_flb_ops.unpreserve).
At the Live Update Orchestrator level the PCI device preservation is
driven by userspace preserving files via ioctls. So that framing leaked
into this commit message. I will rephrase this to be more in the context
of devices that the PCI code actually cares about.
Will do.
Pranjal raised this as well. Here was my reply:
. Yes, it's possible to run out space to preserve devices if devices are
. hot-plugged and then preserved. But I think it's better to defer
. handling such a use-case exists (unless you see an obvious simple
. solution). So far I am not seeing preserving hot-plugged devices
. across Live Update as a high priority use-case to support.
I am going to add a comment here in the next revision to clarify that.
I will also add a comment clarifying why this code doesn't bother to
account for VFs created after this call (preserving VFs are explicitly
disallowed to be preserved in this patch since they require additional
support).
This WARN_ON (and the others you flagged) are all "this should never
happen" scenarios. For example if this triggers it means a bug somewhere
in the kernel (likely in LUO), or some sort of corruption.
Would you prefer I omit such WARNs or should I just a better
accompanying log message or comment?
LUO checks this when it receives preserved data from the previous kernel
and needs to hand it back to the users of that data. This prevents
passing binary data between 2 kernels that don't speak the same ABI.
Yes that's the only use-case in this series. I think there will be more
usecases in the future for checking if a device is outgoing (for example
in pci_device_shutdown() to avoid pci_clear_master()). I can defer
adding this bit for now if you prefer.
Yeah, the LUO FLB flow took me a little while to wrap my head around.
liveupdate_flb_get_outgoing() actually just returns the data
pci_flb_preserve() already allocated. It does not trigger
pci_flb_preserve().
pci_flb_preserve() is triggered when the first file is preserved, for
files that have registered their file handler with PCI
(pci_liveupdate_register_fh()).
So what happens in practice is:
0. VFIO calls pci_liveupdate_register_fh(). This is what connects VFIO
files with pci_liveupdate_flb.
1. Userpace preserves a vfio-pci file using
LIVEUPDATE_SESSION_PRESERVE_FD.
a. If this is the first file to be preserved associated with
pci_liveupdate_flb, then LUO will call pci_flb_preserve(). This
allocates struct pci_ser.
b. LUO calls VFIO preserve callback to preserve the VFIO device
file.
c. VFIO's preserve callback calls pci_liveupdate_outgoing_preserve()
to notify PCI of which PCI device is getting preserved.
c. pci_liveupdate_outgoing_preserve() calls
liveupdate_flb_get_outgoing() to get the data allocated in (a).
Note that this data may have been allocated a long time ago since
(a) only happens when the first device is preserved.
(And note I am saying "first" but I really mean when the count goes from
0 to 1.)
It's kind of convoluted but it has some properties that I think make it
worth it:
- It works for any kind of file (not just devices).
- It allows other drivers to participate in PCI preservation by
registering thier own file handler via pci_liveupdate_register_fh()
(so it's not VFIO-specific).
- The lifecycle is managed by LUO (create on first file preserve,
destroy on last file unpreserve/cancel). So it avoids PCI subsystem
having to maintain any global variables for struct pci_ser.
This is another "should never happen" guard.
Ack, I'll separate out the WARN.
Will do.
Will do.
Ack, I'll take this out of include/.
VFIO needs to know this before userspace retrieves the file associated
the preserved device from LUO. See patch 08:
https://lore.kernel.org/kvm/20260129212510.967611-9-dmatlack@google.com/
This directory hosts all the ABI structures that are passed from
kernel-to-kernel across a Live Update.
$ ls include/linux/kho/abi
kexec_handover.h luo.h memblock.h memfd.h pci.h vfio_pci.h
I agree the directory structure doesn't need to be quite so deep though.
Will do.
Thank you for the review! | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Thu, 26 Feb 2026 00:28:28 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Tue, Feb 24, 2026 at 11:56 PM Pranjal Shrivastava <praan@google.com> wrote:
I think you mean for the below call to pci_liveupdate_register_fh(),
but yes agreed :). | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Wed, 25 Feb 2026 16:45:52 -0800",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Wed, Feb 25, 2026 at 12:38 AM Pranjal Shrivastava <praan@google.com> wrote:
LIVEUPDATE_SESSION_FINISH will also perpetually fail if userspace
never calls ioctl(VFIO_DEVICE_BIND_IOMMUFD) (which is what triggers
vfio_pci_core_enable()). Or if that ioctl fails before it gets to
vfio_pci_core_enable().
It's not a great situation to be in, but this is why can_finish()
exists as a callback. Userspace must properly and correctly restore
all of the state in the session before the session can be cleaned up.
And the kernel is not going to handle every possible edge case (some
files in a session are restored but some are not), at least not
initially. If userspace gets stuck and cannot recover a resource then
userspace will have to reboot the host to get back to a healthy state. | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Wed, 25 Feb 2026 16:51:47 -0800",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Wed, Feb 25, 2026 at 11:20:10PM +0000, David Matlack wrote:
More broadly you can't shouldn't the fabric topology while Memory
Enable is active.
Renumbering or readdressing the fabric requires disabling and flushing
any memory transactions.
is expected to hitlesslly continue performing memory operations.
That may be a clearer long term basis for describing the requirements
here.
Jason | {
"author": "Jason Gunthorpe <jgg@nvidia.com>",
"date": "Thu, 26 Feb 2026 10:40:57 -0400",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, 29 Jan 2026 21:24:53 +0000
David Matlack <dmatlack@google.com> wrote:
I really dislike that we're exporting the underscore variant, which
implies it's an internal function that the caller should understand the
constraints, without outlining any constraints.
I'm not sure what a good alternative is. We can drop fops since this
isn't called from file_operations. Maybe vfio_device_cdev_open_file().
Don't we end up calling vfio_device_fops.release with NULL
file->private_data here with inevitable segfaults? Thanks,
Alex | {
"author": "Alex Williamson <alex@shazbot.org>",
"date": "Thu, 26 Feb 2026 15:52:22 -0700",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, 29 Jan 2026 21:24:54 +0000
David Matlack <dmatlack@google.com> wrote:
Why do we get to ignore the return value here?
This is propagation of a poor API choice in liveupdate, the unregister
should return void, it shouldn't be allowed to fail, IMO. Thanks,
Alex | {
"author": "Alex Williamson <alex@shazbot.org>",
"date": "Thu, 26 Feb 2026 16:03:53 -0700",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, 29 Jan 2026 21:24:55 +0000
David Matlack <dmatlack@google.com> wrote:
Is this an EPERM issue then?
Why does this need to be in the public header versus
drivers/vfio/vfio.h? | {
"author": "Alex Williamson <alex@shazbot.org>",
"date": "Thu, 26 Feb 2026 16:15:12 -0700",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On 2026-02-26 04:15 PM, Alex Williamson wrote:
I was thinking EBUSY in the sense that the device is only temporarily
inaccesible through this interface due it being in a preserved state as
part of a Live Update. Once the preserved device file is retreived and
closed, the device can be accessed again through
VFIO_GROUP_GET_DEVICE_FD.
EPERM might lead to confusion that there is a filesystem permission
issue?
No good reason. I'll make it private. | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Thu, 26 Feb 2026 23:27:47 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On 2026-02-26 04:03 PM, Alex Williamson wrote:
Ugh, we do not. This is a bug, thanks for catching.
Ack. I'll make pci_liveupdate_unregister_fh() unable to fail and follow
up with the maintainers of LUO about liveupdate_unregister_flb(). | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Thu, 26 Feb 2026 23:31:43 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On 2026-02-26 03:52 PM, Alex Williamson wrote:
Ack. Due to the bug you pointed out below, I think the changes in this
file will look fairly different in the next version. But no matter what
I'll avoid exporting a underscore variant without outlining the
constraints.
Yes indeed. In that case I think we need to call
vfio_device_try_get_registration() and vfio_allocate_device_file()
before anon_inode_getfile_fmode(). We could play games with file->fops
to avoid it calling vfio_device_fops.release here instead, but that
feels hacky. | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Thu, 26 Feb 2026 23:40:41 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, 26 Feb 2026 23:27:47 +0000
David Matlack <dmatlack@google.com> wrote:
Ok, fair explanation. Thanks,
Alex | {
"author": "Alex Williamson <alex@shazbot.org>",
"date": "Thu, 26 Feb 2026 16:42:36 -0700",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Thu, 29 Jan 2026 21:24:57 +0000
David Matlack <dmatlack@google.com> wrote:
This could maybe be incrementally cleaner in a
int vfio_pci_core_probe_reset(struct vfio_pci_core_device *vdev)
helper.
Isn't this a problem too? In the first kernel we store the initial,
post reset state of the device, now we're storing some arbitrary state.
This is the state we're restore when the device is closed.
Wouldn't a forward declaration do, and the kho/abi include can be kept
out of the public header? Also should be in the previous patch?
Thanks,
Alex | {
"author": "Alex Williamson <alex@shazbot.org>",
"date": "Thu, 26 Feb 2026 17:00:30 -0700",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On 2026-02-26 05:00 PM, Alex Williamson wrote:
Will do.
The previous kernel resets the device and restores it back to its
post reset state in vfio_pci_liveupdate_freeze() before handing off
control to the next kernel. So my intention here is that VFIO will
receive the device in that state, allowing it to call
pci_store_saved_state() here to capture the post reset state of the
device again.
Eventually we want to drop the reset in vfio_pci_liveupdate_freeze() and
preserve vdev->pci_saved_state across the Live Update. But I was hoping
to add that in a follow up series to avoid this one getting too long.
Will do. | {
"author": "David Matlack <dmatlack@google.com>",
"date": "Fri, 27 Feb 2026 00:51:18 +0000",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | This series can be found on GitHub:
https://github.com/dmatlack/linux/tree/liveupdate/vfio/cdev/v2
This series adds the base support to preserve a VFIO device file across
a Live Update. "Base support" means that this allows userspace to
safely preserve a VFIO device file with LIVEUPDATE_SESSION_PRESERVE_FD
and retrieve it with LIVEUPDATE_SESSION_RETRIEVE_FD, but the device
itself is not preserved in a fully running state across Live Update.
This series aims to provide a foundation on which to build the rest of
the device preservation infrastructure, including:
- Preservation of iommufd files [1]
- Preservation of IOMMU driver state
- Preservation of PCI state (BAR resources, device state, bridge state, ...)
- Preservation of vfio-pci driver state
Testing
-------
The patches at the end of this series provide comprehensive selftests
for the new code added by this series. The selftests have been validated
in both a VM environment using a virtio-net PCIe device, and in a
baremetal environment on an Intel EMR server with an Intel DSA PCIe
device.
Here is an example of how to run the new selftests:
vfio_pci_liveupdate_uapi_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
vfio_pci_liveupdate_kexec_test:
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 1 0000:00:04.0
$ kexec ...
$ tools/testing/selftests/vfio/scripts/setup.sh 0000:00:04.0
$ tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test --stage 2 0000:00:04.0
$ tools/testing/selftests/vfio/scripts/cleanup.sh
It is also possible to run vfio_pci_liveupdate_kexec_test multiple times
to preserve multiple devices simultaneously across a Live Update. This
series has been tested with up to 8 devices concurrently preserved.
Changelog
---------
v2:
- Rebase on top of linux-next (tag: next-20260115)
- Add missing EXPORT_SYMBOL_GPLs in LUO (Zhu)
- Add Missing EXPORT_SYMBOL_GPLs for vfio_device_fops (Zhu)
- Fix circular dependency between vfio-pci-core and vfio-pci (Zhu)
- Handle pci=assign-busses (Lukas)
- Drop driver_override patch (Jason)
- Use kho_alloc_preserve(), kho_unpreserve_free(), kho_restore_free() (Pasha)
- Don't access PCI FLB after device initialization (Jason)
- Fix folio leak in vfio_pci_liveupdate_retrieve() (Alex)
- Add Documentation (Pasha)
v1: https://lore.kernel.org/kvm/20251126193608.2678510-1-dmatlack@google.com/
rfc: https://lore.kernel.org/kvm/20251018000713.677779-1-vipinsh@google.com/
Cc: Saeed Mahameed <saeedm@nvidia.com>
Cc: Adithya Jayachandran <ajayachandra@nvidia.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Parav Pandit <parav@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>
Cc: William Tu <witu@nvidia.com>
Cc: Jacob Pan <jacob.pan@linux.microsoft.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>
Cc: Samiullah Khawaja <skhawaja@google.com>
Cc: Chris Li <chrisl@kernel.org>
Cc: Josh Hilke <jrhilke@google.com>
Cc: David Rientjes <rientjes@google.com>
[1] https://lore.kernel.org/linux-iommu/20251202230303.1017519-1-skhawaja@google.com/
David Matlack (13):
liveupdate: Export symbols needed by modules
PCI: Add API to track PCI devices preserved across Live Update
PCI: Inherit bus numbers from previous kernel during Live Update
vfio/pci: Notify PCI subsystem about devices preserved across Live
Update
vfio: Enforce preserved devices are retrieved via
LIVEUPDATE_SESSION_RETRIEVE_FD
vfio/pci: Store incoming Live Update state in struct
vfio_pci_core_device
docs: liveupdate: Document VFIO device file preservation
vfio: selftests: Add Makefile support for TEST_GEN_PROGS_EXTENDED
vfio: selftests: Add vfio_pci_liveupdate_uapi_test
vfio: selftests: Expose iommu_modes to tests
vfio: selftests: Expose low-level helper routines for setting up
struct vfio_pci_device
vfio: selftests: Verify that opening VFIO device fails during Live
Update
vfio: selftests: Add continuous DMA to vfio_pci_liveupdate_kexec_test
Vipin Sharma (9):
vfio/pci: Register a file handler with Live Update Orchestrator
vfio/pci: Preserve vfio-pci device files across Live Update
vfio/pci: Retrieve preserved device files after Live Update
vfio/pci: Skip reset of preserved device after Live Update
selftests/liveupdate: Move luo_test_utils.* into a reusable library
selftests/liveupdate: Add helpers to preserve/retrieve FDs
vfio: selftests: Build liveupdate library in VFIO selftests
vfio: selftests: Initialize vfio_pci_device using a VFIO cdev FD
vfio: selftests: Add vfio_pci_liveupdate_kexec_test
Documentation/userspace-api/liveupdate.rst | 144 ++++++++++
MAINTAINERS | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/liveupdate.c | 212 +++++++++++++++
drivers/pci/probe.c | 23 +-
drivers/vfio/device_cdev.c | 25 +-
drivers/vfio/group.c | 9 +
drivers/vfio/pci/Makefile | 1 +
drivers/vfio/pci/vfio_pci.c | 11 +-
drivers/vfio/pci/vfio_pci_core.c | 24 +-
drivers/vfio/pci/vfio_pci_liveupdate.c | 246 +++++++++++++++++
drivers/vfio/pci/vfio_pci_priv.h | 16 ++
drivers/vfio/vfio.h | 13 -
drivers/vfio/vfio_main.c | 23 +-
include/linux/kho/abi/pci.h | 55 ++++
include/linux/kho/abi/vfio_pci.h | 45 +++
include/linux/pci.h | 47 ++++
include/linux/vfio.h | 58 ++++
include/linux/vfio_pci_core.h | 2 +
kernel/liveupdate/luo_core.c | 1 +
kernel/liveupdate/luo_file.c | 2 +
tools/testing/selftests/liveupdate/.gitignore | 1 +
tools/testing/selftests/liveupdate/Makefile | 14 +-
.../include/libliveupdate.h} | 11 +-
.../selftests/liveupdate/lib/libliveupdate.mk | 20 ++
.../{luo_test_utils.c => lib/liveupdate.c} | 43 ++-
.../selftests/liveupdate/luo_kexec_simple.c | 2 +-
.../selftests/liveupdate/luo_multi_session.c | 2 +-
tools/testing/selftests/vfio/Makefile | 23 +-
.../vfio/lib/include/libvfio/iommu.h | 2 +
.../lib/include/libvfio/vfio_pci_device.h | 8 +
tools/testing/selftests/vfio/lib/iommu.c | 4 +-
.../selftests/vfio/lib/vfio_pci_device.c | 60 ++--
.../vfio/vfio_pci_liveupdate_kexec_test.c | 256 ++++++++++++++++++
.../vfio/vfio_pci_liveupdate_uapi_test.c | 93 +++++++
35 files changed, 1410 insertions(+), 88 deletions(-)
create mode 100644 drivers/pci/liveupdate.c
create mode 100644 drivers/vfio/pci/vfio_pci_liveupdate.c
create mode 100644 include/linux/kho/abi/pci.h
create mode 100644 include/linux/kho/abi/vfio_pci.h
rename tools/testing/selftests/liveupdate/{luo_test_utils.h => lib/include/libliveupdate.h} (80%)
create mode 100644 tools/testing/selftests/liveupdate/lib/libliveupdate.mk
rename tools/testing/selftests/liveupdate/{luo_test_utils.c => lib/liveupdate.c} (89%)
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_kexec_test.c
create mode 100644 tools/testing/selftests/vfio/vfio_pci_liveupdate_uapi_test.c
base-commit: 9b7977f9e39b7768c70c2aa497f04e7569fd3e00
--
2.53.0.rc1.225.gd81095ad13-goog
| null | null | null | [PATCH v2 00/22] vfio/pci: Base Live Update support for VFIO device files | On Fri, 27 Feb 2026 00:51:18 +0000
David Matlack <dmatlack@google.com> wrote:
I appreciate reviewing this in smaller chunks, but how does userspace
know whether the kernel contains a stub implementation of liveupdate or
behaves according to the end goal?
Also, didn't we violate our own contract in this patch by adding the
reset_works field to the serialization data without updating the
compatibility string? Thanks,
Alex | {
"author": "Alex Williamson <alex@shazbot.org>",
"date": "Fri, 27 Feb 2026 08:46:58 -0700",
"is_openbsd": false,
"thread_id": "20260227084658.3767d801@shazbot.org.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | Ahead of introducing I2C-adapter-specific printk() helpers, preemptively
avoid a conflict with the upcoming i2c_dbg() and rename the local macro
in the saa7134 driver to saa7134_i2c_dbg().
Suggested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/media/pci/saa7134/saa7134-i2c.c b/drivers/media/pci/saa7134/saa7134-i2c.c
index 04e85765373ecc0f0759eba539c20bcdc9716ca8..1164e91cbb7b7f5250dc02bc086f5cc06ea8f5a5 100644
--- a/drivers/media/pci/saa7134/saa7134-i2c.c
+++ b/drivers/media/pci/saa7134/saa7134-i2c.c
@@ -28,7 +28,7 @@ static unsigned int i2c_scan;
module_param(i2c_scan, int, 0444);
MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time");
-#define i2c_dbg(level, fmt, arg...) do { \
+#define saa7134_i2c_dbg(level, fmt, arg...) do { \
if (i2c_debug == level) \
printk(KERN_DEBUG pr_fmt("i2c: " fmt), ## arg); \
} while (0)
@@ -84,20 +84,20 @@ static inline enum i2c_status i2c_get_status(struct saa7134_dev *dev)
enum i2c_status status;
status = saa_readb(SAA7134_I2C_ATTR_STATUS) & 0x0f;
- i2c_dbg(2, "i2c stat <= %s\n", str_i2c_status[status]);
+ saa7134_i2c_dbg(2, "i2c stat <= %s\n", str_i2c_status[status]);
return status;
}
static inline void i2c_set_status(struct saa7134_dev *dev,
enum i2c_status status)
{
- i2c_dbg(2, "i2c stat => %s\n", str_i2c_status[status]);
+ saa7134_i2c_dbg(2, "i2c stat => %s\n", str_i2c_status[status]);
saa_andorb(SAA7134_I2C_ATTR_STATUS,0x0f,status);
}
static inline void i2c_set_attr(struct saa7134_dev *dev, enum i2c_attr attr)
{
- i2c_dbg(2, "i2c attr => %s\n", str_i2c_attr[attr]);
+ saa7134_i2c_dbg(2, "i2c attr => %s\n", str_i2c_attr[attr]);
saa_andorb(SAA7134_I2C_ATTR_STATUS,0xc0,attr << 6);
}
@@ -160,7 +160,7 @@ static int i2c_reset(struct saa7134_dev *dev)
enum i2c_status status;
int count;
- i2c_dbg(2, "i2c reset\n");
+ saa7134_i2c_dbg(2, "i2c reset\n");
status = i2c_get_status(dev);
if (!i2c_is_error(status))
return true;
@@ -198,7 +198,7 @@ static inline int i2c_send_byte(struct saa7134_dev *dev,
// dword |= 0x40 << 16; /* 400 kHz */
dword |= 0xf0 << 24;
saa_writel(SAA7134_I2C_ATTR_STATUS >> 2, dword);
- i2c_dbg(2, "i2c data => 0x%x\n", data);
+ saa7134_i2c_dbg(2, "i2c data => 0x%x\n", data);
if (!i2c_is_busy_wait(dev))
return -EIO;
@@ -220,7 +220,7 @@ static inline int i2c_recv_byte(struct saa7134_dev *dev)
if (i2c_is_error(status))
return -EIO;
data = saa_readb(SAA7134_I2C_DATA);
- i2c_dbg(2, "i2c data <= 0x%x\n", data);
+ saa7134_i2c_dbg(2, "i2c data <= 0x%x\n", data);
return data;
}
@@ -237,12 +237,12 @@ static int saa7134_i2c_xfer(struct i2c_adapter *i2c_adap,
if (!i2c_reset(dev))
return -EIO;
- i2c_dbg(2, "start xfer\n");
- i2c_dbg(1, "i2c xfer:");
+ saa7134_i2c_dbg(2, "start xfer\n");
+ saa7134_i2c_dbg(1, "i2c xfer:");
for (i = 0; i < num; i++) {
if (!(msgs[i].flags & I2C_M_NOSTART) || 0 == i) {
/* send address */
- i2c_dbg(2, "send address\n");
+ saa7134_i2c_dbg(2, "send address\n");
addr = msgs[i].addr << 1;
if (msgs[i].flags & I2C_M_RD)
addr |= 1;
@@ -265,7 +265,7 @@ static int saa7134_i2c_xfer(struct i2c_adapter *i2c_adap,
}
if (msgs[i].flags & I2C_M_RD) {
/* read bytes */
- i2c_dbg(2, "read bytes\n");
+ saa7134_i2c_dbg(2, "read bytes\n");
for (byte = 0; byte < msgs[i].len; byte++) {
i2c_cont(1, " =");
rc = i2c_recv_byte(dev);
@@ -286,7 +286,7 @@ static int saa7134_i2c_xfer(struct i2c_adapter *i2c_adap,
}
} else {
/* write bytes */
- i2c_dbg(2, "write bytes\n");
+ saa7134_i2c_dbg(2, "write bytes\n");
for (byte = 0; byte < msgs[i].len; byte++) {
data = msgs[i].buf[byte];
i2c_cont(1, " %02x", data);
@@ -296,7 +296,7 @@ static int saa7134_i2c_xfer(struct i2c_adapter *i2c_adap,
}
}
}
- i2c_dbg(2, "xfer done\n");
+ saa7134_i2c_dbg(2, "xfer done\n");
i2c_cont(1, " >");
i2c_set_attr(dev,STOP);
rc = -EIO;
--
2.47.3 | {
"author": "Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>",
"date": "Mon, 23 Feb 2026 09:59:30 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | Add a set of i2c-specific printk helpers that wrap their device-level
counterparts and hide the dereferencing of struct device embedded in
struct i2c_adapter. This is done in order to allow moving this struct
device out of struct i2c_adapter into memory managed by i2c core.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
include/linux/i2c.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 20fd41b51d5c85ee1665395c07345faafd8e2fca..2225696c859f617479be4d5c9d304bb32cbf5e9d 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -768,6 +768,12 @@ struct i2c_adapter {
};
#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
+#define i2c_err(adap, fmt, ...) dev_err(&(adap)->dev, fmt, ##__VA_ARGS__)
+#define i2c_warn(adap, fmt, ...) dev_warn(&(adap)->dev, fmt, ##__VA_ARGS__)
+#define i2c_notice(adap, fmt, ...) dev_notice(&(adap)->dev, fmt, ##__VA_ARGS__)
+#define i2c_info(adap, fmt, ...) dev_info(&(adap)->dev, fmt, ##__VA_ARGS__)
+#define i2c_dbg(adap, fmt, ...) dev_dbg(&(adap)->dev, fmt, ##__VA_ARGS__)
+
static inline void *i2c_get_adapdata(const struct i2c_adapter *adap)
{
return dev_get_drvdata(&adap->dev);
--
2.47.3 | {
"author": "Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>",
"date": "Mon, 23 Feb 2026 09:59:31 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | Convert all instances of using device printk helpers with struct device
embedded in struct i2c_adapter to the new i2c-specific macros that hide
that dereference.
Acked-by: Chen-Yu Tsai <wens@kernel.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c
index fb5280b8cf7fc0e3cba8ea6a318172ea2b011a02..845ca56cdae2d056c122eb648c082f319d955b5e 100644
--- a/drivers/i2c/busses/i2c-sun6i-p2wi.c
+++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c
@@ -122,7 +122,7 @@ static int p2wi_smbus_xfer(struct i2c_adapter *adap, u16 addr,
unsigned long dlen = P2WI_DLEN_DATA_LENGTH(1);
if (p2wi->target_addr >= 0 && addr != p2wi->target_addr) {
- dev_err(&adap->dev, "invalid P2WI address\n");
+ i2c_err(adap, "invalid P2WI address\n");
return -EINVAL;
}
@@ -139,7 +139,7 @@ static int p2wi_smbus_xfer(struct i2c_adapter *adap, u16 addr,
writel(dlen, p2wi->regs + P2WI_DLEN);
if (readl(p2wi->regs + P2WI_CTRL) & P2WI_CTRL_START_TRANS) {
- dev_err(&adap->dev, "P2WI bus busy\n");
+ i2c_err(adap, "P2WI bus busy\n");
return -EBUSY;
}
@@ -154,12 +154,12 @@ static int p2wi_smbus_xfer(struct i2c_adapter *adap, u16 addr,
wait_for_completion(&p2wi->complete);
if (p2wi->status & P2WI_INTS_LOAD_BSY) {
- dev_err(&adap->dev, "P2WI bus busy\n");
+ i2c_err(adap, "P2WI bus busy\n");
return -EBUSY;
}
if (p2wi->status & P2WI_INTS_TRANS_ERR) {
- dev_err(&adap->dev, "P2WI bus xfer error\n");
+ i2c_err(adap, "P2WI bus xfer error\n");
return -ENXIO;
}
--
2.47.3 | {
"author": "Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>",
"date": "Mon, 23 Feb 2026 09:59:32 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | Convert all instances of using device printk helpers with struct device
embedded in struct i2c_adapter to the new i2c-specific macros that hide
that dereference.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/i2c/busses/i2c-mlxbf.c b/drivers/i2c/busses/i2c-mlxbf.c
index 6c1cfe9ec8accefaa3f95424393953ff3b869ff6..1dac73002220920ab8f954b29fcc809c6451daa0 100644
--- a/drivers/i2c/busses/i2c-mlxbf.c
+++ b/drivers/i2c/busses/i2c-mlxbf.c
@@ -2038,28 +2038,28 @@ static s32 mlxbf_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr,
switch (size) {
case I2C_SMBUS_QUICK:
mlxbf_i2c_smbus_quick_command(&request, read);
- dev_dbg(&adap->dev, "smbus quick, slave 0x%02x\n", addr);
+ i2c_dbg(adap, "smbus quick, slave 0x%02x\n", addr);
break;
case I2C_SMBUS_BYTE:
mlxbf_i2c_smbus_byte_func(&request,
read ? &data->byte : &command, read,
pec);
- dev_dbg(&adap->dev, "smbus %s byte, slave 0x%02x.\n",
+ i2c_dbg(adap, "smbus %s byte, slave 0x%02x.\n",
str_read_write(read), addr);
break;
case I2C_SMBUS_BYTE_DATA:
mlxbf_i2c_smbus_data_byte_func(&request, &command, &data->byte,
read, pec);
- dev_dbg(&adap->dev, "smbus %s byte data at 0x%02x, slave 0x%02x.\n",
+ i2c_dbg(adap, "smbus %s byte data at 0x%02x, slave 0x%02x.\n",
str_read_write(read), command, addr);
break;
case I2C_SMBUS_WORD_DATA:
mlxbf_i2c_smbus_data_word_func(&request, &command,
(u8 *)&data->word, read, pec);
- dev_dbg(&adap->dev, "smbus %s word data at 0x%02x, slave 0x%02x.\n",
+ i2c_dbg(adap, "smbus %s word data at 0x%02x, slave 0x%02x.\n",
str_read_write(read), command, addr);
break;
@@ -2067,7 +2067,7 @@ static s32 mlxbf_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr,
byte_cnt = data->block[0];
mlxbf_i2c_smbus_i2c_block_func(&request, &command, data->block,
&byte_cnt, read, pec);
- dev_dbg(&adap->dev, "i2c %s block data, %d bytes at 0x%02x, slave 0x%02x.\n",
+ i2c_dbg(adap, "i2c %s block data, %d bytes at 0x%02x, slave 0x%02x.\n",
str_read_write(read), byte_cnt, command, addr);
break;
@@ -2075,14 +2075,14 @@ static s32 mlxbf_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr,
byte_cnt = read ? I2C_SMBUS_BLOCK_MAX : data->block[0];
mlxbf_i2c_smbus_block_func(&request, &command, data->block,
&byte_cnt, read, pec);
- dev_dbg(&adap->dev, "smbus %s block data, %d bytes at 0x%02x, slave 0x%02x.\n",
+ i2c_dbg(adap, "smbus %s block data, %d bytes at 0x%02x, slave 0x%02x.\n",
str_read_write(read), byte_cnt, command, addr);
break;
case I2C_FUNC_SMBUS_PROC_CALL:
mlxbf_i2c_smbus_process_call_func(&request, &command,
(u8 *)&data->word, pec);
- dev_dbg(&adap->dev, "process call, wr/rd at 0x%02x, slave 0x%02x.\n",
+ i2c_dbg(adap, "process call, wr/rd at 0x%02x, slave 0x%02x.\n",
command, addr);
break;
@@ -2091,13 +2091,12 @@ static s32 mlxbf_i2c_smbus_xfer(struct i2c_adapter *adap, u16 addr,
mlxbf_i2c_smbus_blk_process_call_func(&request, &command,
data->block, &byte_cnt,
pec);
- dev_dbg(&adap->dev, "block process call, wr/rd %d bytes, slave 0x%02x.\n",
+ i2c_dbg(adap, "block process call, wr/rd %d bytes, slave 0x%02x.\n",
byte_cnt, addr);
break;
default:
- dev_dbg(&adap->dev, "Unsupported I2C/SMBus command %d\n",
- size);
+ i2c_dbg(adap, "Unsupported I2C/SMBus command %d\n", size);
return -EOPNOTSUPP;
}
--
2.47.3 | {
"author": "Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>",
"date": "Mon, 23 Feb 2026 09:59:33 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | Convert all instances of using device printk helpers with struct device
embedded in struct i2c_adapter to the new i2c-specific macros that hide
that dereference.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/drivers/i2c/busses/i2c-isch.c b/drivers/i2c/busses/i2c-isch.c
index a2ac992f9cb0d2accfaa979b802b98c3b7fbe3af..6ff07ab12e30db6821cadea4de3a588b9023ea20 100644
--- a/drivers/i2c/busses/i2c-isch.c
+++ b/drivers/i2c/busses/i2c-isch.c
@@ -86,7 +86,7 @@ static int sch_transaction(struct i2c_adapter *adap)
int temp;
int rc;
- dev_dbg(&adap->dev,
+ i2c_dbg(adap,
"Transaction (pre): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
sch_io_rd8(priv, SMBHSTCNT), sch_io_rd8(priv, SMBHSTCMD),
sch_io_rd8(priv, SMBHSTADD),
@@ -97,13 +97,13 @@ static int sch_transaction(struct i2c_adapter *adap)
if (temp) {
/* Can not be busy since we checked it in sch_access */
if (temp & 0x01)
- dev_dbg(&adap->dev, "Completion (%02x). Clear...\n", temp);
+ i2c_dbg(adap, "Completion (%02x). Clear...\n", temp);
if (temp & 0x06)
- dev_dbg(&adap->dev, "SMBus error (%02x). Resetting...\n", temp);
+ i2c_dbg(adap, "SMBus error (%02x). Resetting...\n", temp);
sch_io_wr8(priv, SMBHSTSTS, temp);
temp = sch_io_rd8(priv, SMBHSTSTS) & 0x0f;
if (temp) {
- dev_err(&adap->dev, "SMBus is not ready: (%02x)\n", temp);
+ i2c_err(adap, "SMBus is not ready: (%02x)\n", temp);
return -EAGAIN;
}
}
@@ -116,28 +116,28 @@ static int sch_transaction(struct i2c_adapter *adap)
rc = read_poll_timeout(sch_io_rd8, temp, !(temp & 0x08), 200, 500000, true, priv, SMBHSTSTS);
/* If the SMBus is still busy, we give up */
if (rc) {
- dev_err(&adap->dev, "SMBus Timeout!\n");
+ i2c_err(adap, "SMBus Timeout!\n");
} else if (temp & 0x04) {
rc = -EIO;
- dev_dbg(&adap->dev, "Bus collision! SMBus may be locked until next hard reset. (sorry!)\n");
+ i2c_dbg(adap, "Bus collision! SMBus may be locked until next hard reset. (sorry!)\n");
/* Clock stops and target is stuck in mid-transmission */
} else if (temp & 0x02) {
rc = -EIO;
- dev_err(&adap->dev, "Error: no response!\n");
+ i2c_err(adap, "Error: no response!\n");
} else if (temp & 0x01) {
- dev_dbg(&adap->dev, "Post complete!\n");
+ i2c_dbg(adap, "Post complete!\n");
sch_io_wr8(priv, SMBHSTSTS, temp & 0x0f);
temp = sch_io_rd8(priv, SMBHSTSTS) & 0x07;
if (temp & 0x06) {
/* Completion clear failed */
- dev_dbg(&adap->dev,
+ i2c_dbg(adap,
"Failed reset at end of transaction (%02x), Bus error!\n", temp);
}
} else {
rc = -ENXIO;
- dev_dbg(&adap->dev, "No such address.\n");
+ i2c_dbg(adap, "No such address.\n");
}
- dev_dbg(&adap->dev, "Transaction (post): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
+ i2c_dbg(adap, "Transaction (post): CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
sch_io_rd8(priv, SMBHSTCNT), sch_io_rd8(priv, SMBHSTCMD),
sch_io_rd8(priv, SMBHSTADD),
sch_io_rd8(priv, SMBHSTDAT0), sch_io_rd8(priv, SMBHSTDAT1));
@@ -166,7 +166,7 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr,
/* Make sure the SMBus host is not busy */
temp = sch_io_rd8(priv, SMBHSTSTS) & 0x0f;
if (temp & 0x08) {
- dev_dbg(&adap->dev, "SMBus busy (%02x)\n", temp);
+ i2c_dbg(adap, "SMBus busy (%02x)\n", temp);
return -EAGAIN;
}
temp = sch_io_rd16(priv, SMBHSTCLK);
@@ -177,11 +177,11 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr,
* 100 kHz. If we actually run at 25 MHz the bus will be
* run ~75 kHz instead which should do no harm.
*/
- dev_notice(&adap->dev, "Clock divider uninitialized. Setting defaults\n");
+ i2c_notice(adap, "Clock divider uninitialized. Setting defaults\n");
sch_io_wr16(priv, SMBHSTCLK, backbone_speed / (4 * 100));
}
- dev_dbg(&adap->dev, "access size: %d %s\n", size, str_read_write(read_write));
+ i2c_dbg(adap, "access size: %d %s\n", size, str_read_write(read_write));
switch (size) {
case I2C_SMBUS_QUICK:
sch_io_wr8(priv, SMBHSTADD, (addr << 1) | read_write);
@@ -223,10 +223,10 @@ static s32 sch_access(struct i2c_adapter *adap, u16 addr,
size = SCH_BLOCK_DATA;
break;
default:
- dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
+ i2c_warn(adap, "Unsupported transaction %d\n", size);
return -EOPNOTSUPP;
}
- dev_dbg(&adap->dev, "write size %d to 0x%04x\n", size, SMBHSTCNT);
+ i2c_dbg(adap, "write size %d to 0x%04x\n", size, SMBHSTCNT);
temp = sch_io_rd8(priv, SMBHSTCNT);
temp = (temp & 0xb0) | (size & 0x7);
--
2.47.3 | {
"author": "Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>",
"date": "Mon, 23 Feb 2026 09:59:34 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | Convert all instances of using device printk helpers with struct device
embedded in struct i2c_adapter to the new i2c-specific macros that hide
that dereference.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/i2c/busses/i2c-scmi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-scmi.c b/drivers/i2c/busses/i2c-scmi.c
index 324a63efa1ab90027854646f84142f052a966537..57b8175f0fa8da52dd74c5bf8e3059358c033a37 100644
--- a/drivers/i2c/busses/i2c-scmi.c
+++ b/drivers/i2c/busses/i2c-scmi.c
@@ -87,7 +87,7 @@ acpi_smbus_cmi_access(struct i2c_adapter *adap, u16 addr, unsigned short flags,
char *method;
int len = 0;
- dev_dbg(&adap->dev, "access size: %d %s\n", size,
+ i2c_dbg(adap, "access size: %d %s\n", size,
(read_write) ? "READ" : "WRITE");
switch (size) {
case I2C_SMBUS_QUICK:
@@ -148,7 +148,7 @@ acpi_smbus_cmi_access(struct i2c_adapter *adap, u16 addr, unsigned short flags,
break;
default:
- dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
+ i2c_warn(adap, "Unsupported transaction %d\n", size);
return -EOPNOTSUPP;
}
@@ -257,7 +257,7 @@ acpi_smbus_cmi_access(struct i2c_adapter *adap, u16 addr, unsigned short flags,
out:
kfree(buffer.pointer);
- dev_dbg(&adap->dev, "Transaction status: %i\n", result);
+ i2c_dbg(adap, "Transaction status: %i\n", result);
return result;
}
--
2.47.3 | {
"author": "Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>",
"date": "Mon, 23 Feb 2026 09:59:36 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | Convert all instances of using device printk helpers with struct device
embedded in struct i2c_adapter to the new i2c-specific macros that hide
that dereference.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index 1eac358380405838d15551e353605cab0a7e5e65..bf0f36450c5930f86b122618d17eecf1782dd776 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -215,7 +215,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
int result = 0;
int timeout = 0;
- dev_dbg(&adap->dev, "Transaction (pre): STS=%02x, TYP=%02x, "
+ i2c_dbg(adap, "Transaction (pre): STS=%02x, TYP=%02x, "
"CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
inb_p(SMBHSTSTS), inb_p(SMBHSTTYP), inb_p(SMBHSTCMD),
inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1));
@@ -245,7 +245,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
* BUSY bit may come back on when you try and use the chip
* again. If that's the case you are stuck.
*/
- dev_info(&adap->dev,
+ i2c_info(adap,
"Resetting entire SMB Bus to clear busy condition (%02x)\n",
temp);
outb_p(ALI1535_T_OUT, SMBHSTTYP);
@@ -262,7 +262,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
* power reset as one of the bits now appears to be
* stuck */
/* This may be a bus or device with electrical problems. */
- dev_err(&adap->dev,
+ i2c_err(adap,
"SMBus reset failed! (0x%02x) - controller or "
"device on bus is probably hung\n", temp);
return -EBUSY;
@@ -290,7 +290,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
if (temp & ALI1535_STS_FAIL) {
result = -EIO;
- dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
+ i2c_dbg(adap, "Error: Failed bus transaction\n");
}
/* Unfortunately the ALI SMB controller maps "no response" and "bus
@@ -299,7 +299,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
*/
if (temp & ALI1535_STS_BUSERR) {
result = -ENXIO;
- dev_dbg(&adap->dev,
+ i2c_dbg(adap,
"Error: no response or bus collision ADD=%02x\n",
inb_p(SMBHSTADD));
}
@@ -307,14 +307,14 @@ static int ali1535_transaction(struct i2c_adapter *adap)
/* haven't ever seen this */
if (temp & ALI1535_STS_DEV) {
result = -EIO;
- dev_err(&adap->dev, "Error: device error\n");
+ i2c_err(adap, "Error: device error\n");
}
/* check to see if the "command complete" indication is set */
if (!(temp & ALI1535_STS_DONE))
result = -ETIMEDOUT;
- dev_dbg(&adap->dev, "Transaction (post): STS=%02x, TYP=%02x, "
+ i2c_dbg(adap, "Transaction (post): STS=%02x, TYP=%02x, "
"CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
inb_p(SMBHSTSTS), inb_p(SMBHSTTYP), inb_p(SMBHSTCMD),
inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1));
@@ -352,7 +352,7 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
temp = inb_p(SMBHSTSTS);
}
if (timeout >= MAX_TIMEOUT)
- dev_warn(&adap->dev, "Idle wait Timeout! STS=0x%02x\n", temp);
+ i2c_warn(adap, "Idle wait Timeout! STS=0x%02x\n", temp);
/* clear status register (clear-on-write) */
outb_p(0xFF, SMBHSTSTS);
@@ -416,7 +416,7 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
}
break;
default:
- dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
+ i2c_warn(adap, "Unsupported transaction %d\n", size);
result = -EOPNOTSUPP;
goto EXIT;
}
@@ -449,7 +449,7 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
outb_p(inb_p(SMBHSTTYP) | ALI1535_BLOCK_CLR, SMBHSTTYP);
for (i = 1; i <= data->block[0]; i++) {
data->block[i] = inb_p(SMBBLKDAT);
- dev_dbg(&adap->dev, "Blk: len=%d, i=%d, data=%02x\n",
+ i2c_dbg(adap, "Blk: len=%d, i=%d, data=%02x\n",
len, i, data->block[i]);
}
break;
--
2.47.3 | {
"author": "Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>",
"date": "Mon, 23 Feb 2026 09:59:35 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | Convert all instances of using device printk helpers with struct device
embedded in struct i2c_adapter to the new i2c-specific macros that hide
that dereference.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
index 418d11266671e314aa2fb882ece025dc0ae998da..bd62aa8d645004bef121fa46efc1d7afc473332a 100644
--- a/drivers/i2c/busses/i2c-ali15x3.c
+++ b/drivers/i2c/busses/i2c-ali15x3.c
@@ -223,7 +223,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
int result = 0;
int timeout = 0;
- dev_dbg(&adap->dev, "Transaction (pre): STS=%02x, CNT=%02x, CMD=%02x, "
+ i2c_dbg(adap, "Transaction (pre): STS=%02x, CNT=%02x, CMD=%02x, "
"ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTSTS),
inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD),
inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1));
@@ -255,7 +255,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
then the BUSY bit may come back on when you try and use the chip again.
If that's the case you are stuck.
*/
- dev_info(&adap->dev, "Resetting entire SMB Bus to "
+ i2c_info(adap, "Resetting entire SMB Bus to "
"clear busy condition (%02x)\n", temp);
outb_p(ALI15X3_T_OUT, SMBHSTCNT);
temp = inb_p(SMBHSTSTS);
@@ -270,7 +270,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
/* this is probably going to be correctable only by a power reset
as one of the bits now appears to be stuck */
/* This may be a bus or device with electrical problems. */
- dev_err(&adap->dev, "SMBus reset failed! (0x%02x) - "
+ i2c_err(adap, "SMBus reset failed! (0x%02x) - "
"controller or device on bus is probably hung\n",
temp);
return -EBUSY;
@@ -299,7 +299,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
if (temp & ALI15X3_STS_TERM) {
result = -EIO;
- dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
+ i2c_dbg(adap, "Error: Failed bus transaction\n");
}
/*
@@ -310,7 +310,7 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
*/
if (temp & ALI15X3_STS_COLL) {
result = -ENXIO;
- dev_dbg(&adap->dev,
+ i2c_dbg(adap,
"Error: no response or bus collision ADD=%02x\n",
inb_p(SMBHSTADD));
}
@@ -318,9 +318,9 @@ static int ali15x3_transaction(struct i2c_adapter *adap)
/* haven't ever seen this */
if (temp & ALI15X3_STS_DEV) {
result = -EIO;
- dev_err(&adap->dev, "Error: device error\n");
+ i2c_err(adap, "Error: device error\n");
}
- dev_dbg(&adap->dev, "Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, "
+ i2c_dbg(adap, "Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, "
"ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTSTS),
inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD),
inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1));
@@ -347,7 +347,7 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
temp = inb_p(SMBHSTSTS);
}
if (timeout >= MAX_TIMEOUT) {
- dev_err(&adap->dev, "Idle wait Timeout! STS=0x%02x\n", temp);
+ i2c_err(adap, "Idle wait Timeout! STS=0x%02x\n", temp);
}
switch (size) {
@@ -404,7 +404,7 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
size = ALI15X3_BLOCK_DATA;
break;
default:
- dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
+ i2c_warn(adap, "Unsupported transaction %d\n", size);
return -EOPNOTSUPP;
}
@@ -437,7 +437,7 @@ static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr,
outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT);
for (i = 1; i <= data->block[0]; i++) {
data->block[i] = inb_p(SMBBLKDAT);
- dev_dbg(&adap->dev, "Blk: len=%d, i=%d, data=%02x\n",
+ i2c_dbg(adap, "Blk: len=%d, i=%d, data=%02x\n",
len, i, data->block[i]);
}
break;
--
2.47.3 | {
"author": "Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>",
"date": "Mon, 23 Feb 2026 09:59:37 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | Convert all instances of using device printk helpers with struct device
embedded in struct i2c_adapter to the new i2c-specific macros that hide
that dereference.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c
index f99a2cc721a81dc328bc03ea88ff959cafe0f05a..fb5482655d6c5c617392e9ccd745433d5d828335 100644
--- a/drivers/i2c/busses/i2c-powermac.c
+++ b/drivers/i2c/busses/i2c-powermac.c
@@ -92,13 +92,13 @@ static s32 i2c_powermac_smbus_xfer( struct i2c_adapter* adap,
rc = pmac_i2c_open(bus, 0);
if (rc) {
- dev_err(&adap->dev, "Failed to open I2C, err %d\n", rc);
+ i2c_err(adap, "Failed to open I2C, err %d\n", rc);
return rc;
}
rc = pmac_i2c_setmode(bus, mode);
if (rc) {
- dev_err(&adap->dev, "Failed to set I2C mode %d, err %d\n",
+ i2c_err(adap, "Failed to set I2C mode %d, err %d\n",
mode, rc);
goto bail;
}
@@ -106,11 +106,11 @@ static s32 i2c_powermac_smbus_xfer( struct i2c_adapter* adap,
rc = pmac_i2c_xfer(bus, addrdir, subsize, subaddr, buf, len);
if (rc) {
if (rc == -ENXIO)
- dev_dbg(&adap->dev,
+ i2c_dbg(adap,
"I2C transfer at 0x%02x failed, size %d, "
"err %d\n", addrdir >> 1, size, rc);
else
- dev_err(&adap->dev,
+ i2c_err(adap,
"I2C transfer at 0x%02x failed, size %d, "
"err %d\n", addrdir >> 1, size, rc);
goto bail;
@@ -145,23 +145,23 @@ static int i2c_powermac_xfer(struct i2c_adapter *adap,
rc = pmac_i2c_open(bus, 0);
if (rc) {
- dev_err(&adap->dev, "Failed to open I2C, err %d\n", rc);
+ i2c_err(adap, "Failed to open I2C, err %d\n", rc);
return rc;
}
rc = pmac_i2c_setmode(bus, pmac_i2c_mode_std);
if (rc) {
- dev_err(&adap->dev, "Failed to set I2C mode %d, err %d\n",
+ i2c_err(adap, "Failed to set I2C mode %d, err %d\n",
pmac_i2c_mode_std, rc);
goto bail;
}
rc = pmac_i2c_xfer(bus, addrdir, 0, 0, msgs->buf, msgs->len);
if (rc < 0) {
if (rc == -ENXIO)
- dev_dbg(&adap->dev, "I2C %s 0x%02x failed, err %d\n",
+ i2c_dbg(adap, "I2C %s 0x%02x failed, err %d\n",
addrdir & 1 ? "read from" : "write to",
addrdir >> 1, rc);
else
- dev_err(&adap->dev, "I2C %s 0x%02x failed, err %d\n",
+ i2c_err(adap, "I2C %s 0x%02x failed, err %d\n",
addrdir & 1 ? "read from" : "write to",
addrdir >> 1, rc);
}
@@ -219,7 +219,7 @@ static u32 i2c_powermac_get_addr(struct i2c_adapter *adap,
else if (of_node_name_eq(node, "deq"))
return 0x34;
- dev_warn(&adap->dev, "No i2c address for %pOF\n", node);
+ i2c_warn(adap, "No i2c address for %pOF\n", node);
return 0xffffffff;
}
@@ -235,7 +235,7 @@ static void i2c_powermac_create_one(struct i2c_adapter *adap,
info.addr = addr;
newdev = i2c_new_client_device(adap, &info);
if (IS_ERR(newdev))
- dev_err(&adap->dev,
+ i2c_err(adap,
"i2c-powermac: Failure to register missing %s\n",
type);
}
@@ -299,7 +299,7 @@ static bool i2c_powermac_get_type(struct i2c_adapter *adap,
}
}
- dev_err(&adap->dev, "i2c-powermac: modalias failure on %pOF\n", node);
+ i2c_err(adap, "i2c-powermac: modalias failure on %pOF\n", node);
return false;
}
@@ -331,7 +331,7 @@ static void i2c_powermac_register_devices(struct i2c_adapter *adap,
if (!pmac_i2c_match_adapter(node, adap))
continue;
- dev_dbg(&adap->dev, "i2c-powermac: register %pOF\n", node);
+ i2c_dbg(adap, "i2c-powermac: register %pOF\n", node);
/*
* Keep track of some device existence to handle
@@ -353,7 +353,7 @@ static void i2c_powermac_register_devices(struct i2c_adapter *adap,
newdev = i2c_new_client_device(adap, &info);
if (IS_ERR(newdev)) {
- dev_err(&adap->dev, "i2c-powermac: Failure to register"
+ i2c_err(adap, "i2c-powermac: Failure to register"
" %pOF\n", node);
of_node_put(node);
/* We do not dispose of the interrupt mapping on
--
2.47.3 | {
"author": "Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>",
"date": "Mon, 23 Feb 2026 09:59:38 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | Convert all instances of using device printk helpers with struct device
embedded in struct i2c_adapter to the new i2c-specific macros that hide
that dereference.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/i2c/busses/i2c-owl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-owl.c b/drivers/i2c/busses/i2c-owl.c
index 84a195e358866d693fb6d435a5beaaee640fd2e2..17718f15a0f1fd238bb4a6f23dbb4f9696969ed5 100644
--- a/drivers/i2c/busses/i2c-owl.c
+++ b/drivers/i2c/busses/i2c-owl.c
@@ -241,7 +241,7 @@ static int owl_i2c_check_bus_busy(struct i2c_adapter *adap)
timeout = jiffies + OWL_I2C_TIMEOUT;
while (readl(i2c_dev->base + OWL_I2C_REG_STAT) & OWL_I2C_STAT_BBB) {
if (time_after(jiffies, timeout)) {
- dev_err(&adap->dev, "Bus busy timeout\n");
+ i2c_err(adap, "Bus busy timeout\n");
return -ETIMEDOUT;
}
}
@@ -383,7 +383,7 @@ static int owl_i2c_xfer_common(struct i2c_adapter *adap, struct i2c_msg *msgs,
spin_lock_irqsave(&i2c_dev->lock, flags);
if (ret) {
- dev_err(&adap->dev, "Transaction timed out\n");
+ i2c_err(adap, "Transaction timed out\n");
/* Send stop condition and release the bus */
owl_i2c_update_reg(i2c_dev->base + OWL_I2C_REG_CTL,
OWL_I2C_CTL_GBCC_STOP | OWL_I2C_CTL_RB,
--
2.47.3 | {
"author": "Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>",
"date": "Mon, 23 Feb 2026 09:59:39 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | Convert all instances of using device printk helpers with struct device
embedded in struct i2c_adapter to the new i2c-specific macros that hide
that dereference.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index 7064fab81eacd416756906cc2ff0567ac44a3465..0cc2cfe8f3c788d84374d40ae8b43cabc467fdd4 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -123,7 +123,7 @@ static void nforce2_abort(struct i2c_adapter *adap)
int timeout = 0;
unsigned char temp;
- dev_dbg(&adap->dev, "Aborting current transaction\n");
+ i2c_dbg(adap, "Aborting current transaction\n");
outb_p(NVIDIA_SMB_CTRL_ABORT, NVIDIA_SMB_CTRL);
do {
@@ -132,7 +132,7 @@ static void nforce2_abort(struct i2c_adapter *adap)
} while (!(temp & NVIDIA_SMB_STATUS_ABRT_STS) &&
(timeout++ < MAX_TIMEOUT));
if (!(temp & NVIDIA_SMB_STATUS_ABRT_STS))
- dev_err(&adap->dev, "Can't reset the smbus\n");
+ i2c_err(adap, "Can't reset the smbus\n");
outb_p(NVIDIA_SMB_STATUS_ABRT_STS, NVIDIA_SMB_STATUS_ABRT);
}
@@ -148,13 +148,13 @@ static int nforce2_check_status(struct i2c_adapter *adap)
} while ((!temp) && (timeout++ < MAX_TIMEOUT));
if (timeout > MAX_TIMEOUT) {
- dev_dbg(&adap->dev, "SMBus Timeout!\n");
+ i2c_dbg(adap, "SMBus Timeout!\n");
if (smbus->can_abort)
nforce2_abort(adap);
return -ETIMEDOUT;
}
if (!(temp & NVIDIA_SMB_STS_DONE) || (temp & NVIDIA_SMB_STS_STATUS)) {
- dev_dbg(&adap->dev, "Transaction failed (0x%02x)!\n", temp);
+ i2c_dbg(adap, "Transaction failed (0x%02x)!\n", temp);
return -EIO;
}
return 0;
@@ -207,7 +207,7 @@ static s32 nforce2_access(struct i2c_adapter *adap, u16 addr,
if (read_write == I2C_SMBUS_WRITE) {
len = data->block[0];
if ((len == 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
- dev_err(&adap->dev,
+ i2c_err(adap,
"Transaction failed (requested block size: %d)\n",
len);
return -EINVAL;
@@ -221,7 +221,7 @@ static s32 nforce2_access(struct i2c_adapter *adap, u16 addr,
break;
default:
- dev_err(&adap->dev, "Unsupported transaction %d\n", size);
+ i2c_err(adap, "Unsupported transaction %d\n", size);
return -EOPNOTSUPP;
}
@@ -249,7 +249,7 @@ static s32 nforce2_access(struct i2c_adapter *adap, u16 addr,
case I2C_SMBUS_BLOCK_DATA:
len = inb_p(NVIDIA_SMB_BCNT);
if ((len <= 0) || (len > I2C_SMBUS_BLOCK_MAX)) {
- dev_err(&adap->dev,
+ i2c_err(adap,
"Transaction failed (received block size: 0x%02x)\n",
len);
return -EPROTO;
--
2.47.3 | {
"author": "Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>",
"date": "Mon, 23 Feb 2026 09:59:40 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | Convert all instances of using device printk helpers with struct device
embedded in struct i2c_adapter to the new i2c-specific macros that hide
that dereference.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
index 3621c02f1cbabd8c5e9d8a4ae1494ada78726b15..629da0b8024b88cc4d51ea5e785147b462a1281c 100644
--- a/drivers/i2c/busses/i2c-amd756.c
+++ b/drivers/i2c/busses/i2c-amd756.c
@@ -99,14 +99,14 @@ static int amd756_transaction(struct i2c_adapter *adap)
int result = 0;
int timeout = 0;
- dev_dbg(&adap->dev, "Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, "
+ i2c_dbg(adap, "Transaction (pre): GS=%04x, GE=%04x, ADD=%04x, "
"DAT=%04x\n", inw_p(SMB_GLOBAL_STATUS),
inw_p(SMB_GLOBAL_ENABLE), inw_p(SMB_HOST_ADDRESS),
inb_p(SMB_HOST_DATA));
/* Make sure the SMBus host is ready to start transmitting */
if ((temp = inw_p(SMB_GLOBAL_STATUS)) & (GS_HST_STS | GS_SMB_STS)) {
- dev_dbg(&adap->dev, "SMBus busy (%04x). Waiting...\n", temp);
+ i2c_dbg(adap, "SMBus busy (%04x). Waiting...\n", temp);
do {
msleep(1);
temp = inw_p(SMB_GLOBAL_STATUS);
@@ -114,7 +114,7 @@ static int amd756_transaction(struct i2c_adapter *adap)
(timeout++ < MAX_TIMEOUT));
/* If the SMBus is still busy, we give up */
if (timeout > MAX_TIMEOUT) {
- dev_dbg(&adap->dev, "Busy wait timeout (%04x)\n", temp);
+ i2c_dbg(adap, "Busy wait timeout (%04x)\n", temp);
goto abort;
}
timeout = 0;
@@ -131,38 +131,38 @@ static int amd756_transaction(struct i2c_adapter *adap)
/* If the SMBus is still busy, we give up */
if (timeout > MAX_TIMEOUT) {
- dev_dbg(&adap->dev, "Completion timeout!\n");
+ i2c_dbg(adap, "Completion timeout!\n");
goto abort;
}
if (temp & GS_PRERR_STS) {
result = -ENXIO;
- dev_dbg(&adap->dev, "SMBus Protocol error (no response)!\n");
+ i2c_dbg(adap, "SMBus Protocol error (no response)!\n");
}
if (temp & GS_COL_STS) {
result = -EIO;
- dev_warn(&adap->dev, "SMBus collision!\n");
+ i2c_warn(adap, "SMBus collision!\n");
}
if (temp & GS_TO_STS) {
result = -ETIMEDOUT;
- dev_dbg(&adap->dev, "SMBus protocol timeout!\n");
+ i2c_dbg(adap, "SMBus protocol timeout!\n");
}
if (temp & GS_HCYC_STS)
- dev_dbg(&adap->dev, "SMBus protocol success!\n");
+ i2c_dbg(adap, "SMBus protocol success!\n");
outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS);
#ifdef DEBUG
if (((temp = inw_p(SMB_GLOBAL_STATUS)) & GS_CLEAR_STS) != 0x00) {
- dev_dbg(&adap->dev,
+ i2c_dbg(adap,
"Failed reset at end of transaction (%04x)\n", temp);
}
#endif
- dev_dbg(&adap->dev,
+ i2c_dbg(adap,
"Transaction (post): GS=%04x, GE=%04x, ADD=%04x, DAT=%04x\n",
inw_p(SMB_GLOBAL_STATUS), inw_p(SMB_GLOBAL_ENABLE),
inw_p(SMB_HOST_ADDRESS), inb_p(SMB_HOST_DATA));
@@ -170,7 +170,7 @@ static int amd756_transaction(struct i2c_adapter *adap)
return result;
abort:
- dev_warn(&adap->dev, "Sending abort\n");
+ i2c_warn(adap, "Sending abort\n");
outw_p(inw(SMB_GLOBAL_ENABLE) | GE_ABORT, SMB_GLOBAL_ENABLE);
msleep(100);
outw_p(GS_CLEAR_STS, SMB_GLOBAL_STATUS);
@@ -233,7 +233,7 @@ static s32 amd756_access(struct i2c_adapter * adap, u16 addr,
size = AMD756_BLOCK_DATA;
break;
default:
- dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
+ i2c_warn(adap, "Unsupported transaction %d\n", size);
return -EOPNOTSUPP;
}
--
2.47.3 | {
"author": "Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>",
"date": "Mon, 23 Feb 2026 09:59:41 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | Convert all instances of using device printk helpers with struct device
embedded in struct i2c_adapter to the new i2c-specific macros that hide
that dereference.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 7b6a4e201be4a211c3b84e57fb7d8e0adc9895b7..d7fa2fbace908d1c2de66aae152e848bd1678fb9 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -650,7 +650,7 @@ static s32 piix4_access(struct i2c_adapter * adap, u16 addr,
size = PIIX4_BLOCK_DATA;
break;
default:
- dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
+ i2c_warn(adap, "Unsupported transaction %d\n", size);
return -EOPNOTSUPP;
}
@@ -825,12 +825,12 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
ret = piix4_imc_sleep();
switch (ret) {
case -EBUSY:
- dev_warn(&adap->dev,
+ i2c_warn(adap,
"IMC base address index region 0x%x already in use.\n",
KERNCZ_IMC_IDX);
break;
case -ETIMEDOUT:
- dev_warn(&adap->dev,
+ i2c_warn(adap,
"Failed to communicate with the IMC.\n");
break;
default:
@@ -839,7 +839,7 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr,
/* If IMC communication fails do not retry */
if (ret) {
- dev_warn(&adap->dev,
+ i2c_warn(adap,
"Continuing without IMC notification.\n");
adapdata->notify_imc = false;
}
--
2.47.3 | {
"author": "Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>",
"date": "Mon, 23 Feb 2026 09:59:42 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | On Mon, Feb 23, 2026 at 09:59:29AM +0100, Bartosz Golaszewski wrote:
I applied the series to for-current but squashed the user conversions
into patch 1. Changes are trivial enough and I don't want the pull
request to look excessive, so it can go in smoothly. Hope you are fine
with it. | {
"author": "Wolfram Sang <wsa+renesas@sang-engineering.com>",
"date": "Thu, 26 Feb 2026 21:21:35 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | On Thu, 26 Feb 2026 21:21:35 +0100, Wolfram Sang
<wsa+renesas@sang-engineering.com> said:
Sure, do you still want me to send these changes in separate patches for
review?
Bart | {
"author": "Bartosz Golaszewski <brgl@kernel.org>",
"date": "Fri, 27 Feb 2026 00:38:23 -0800",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | On Mon, Feb 23, 2026 at 09:59:29AM +0100, Bartosz Golaszewski wrote:
Again, this is not the way to do this. You don't need to wrap every
access to struct device in random subsystem specific helpers to address
the lifetime issues. You're just creating a big mess here for no good
reason.
I asked you to show where you think you're going with this because none
of this looks right. Same comment applies to your other series.
Wolfram, I noticed you merged these last night. Please think again and
let's discuss the end result here. There's no question that there are
lifetime issues in i2c, but this is not the way to solve it.
Johan | {
"author": "Johan Hovold <johan@kernel.org>",
"date": "Fri, 27 Feb 2026 09:58:27 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | Johan,
I did think again and do not see a way how the life cycle problems can
be solved while drivers happily access the device struct of the adapter.
Whatever the solution to the core problem is (revocable, custom SRCU,
something else), I still think this step is needed in any case. If I am
wrong with this opinion, please enlighten me. Pointer to some existing
thread is OK, too. I didn't have the bandwidth to read the revocable
mail threads.
Happy hacking,
Wolfram | {
"author": "Wolfram Sang <wsa+renesas@sang-engineering.com>",
"date": "Fri, 27 Feb 2026 10:08:34 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | On Fri, Feb 27, 2026 at 10:08:34AM +0100, Wolfram Sang wrote:
There's nothing special about the struct device. What matters is that
drivers don't free memory that's still in use by the core.
It's not even about revocable or SRCU, that's just an implementation
detail.
It seems all that is needed is to decouple the struct i2c_adapter from
the driver data and have core manage the lifetime of the former using
the reference count of the embedded struct device.
Then you can use an rwsem, SRCU, revocable or something else to handle
devices going away while they are in use.
Johan | {
"author": "Johan Hovold <johan@kernel.org>",
"date": "Fri, 27 Feb 2026 11:05:25 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | It's been another year of discussing the object life-time problems at
conferences. I2C is one of the offenders and its problems are more
complex than those of some other subsystems. It seems the revocable[1]
API may make its way into the kernel this year but even with it in
place, I2C won't be able to use it as there's currently nothing to
*revoke*. The struct device is embedded within the i2c_adapter struct
whose lifetime is tied to the provider device being bound to its driver.
Fixing this won't be fast and easy but nothing's going to happen if we
don't start chipping away at it. The ultimate goal in order to be able
to use an SRCU-based solution (revocable or otherwise) is to convert the
embedded struct device in struct i2c_adapter into an __rcu pointer that
can be *revoked*. To that end we need to hide all dereferences of
adap->dev in drivers.
This series addresses the usage of adap->dev in device printk() helpers
(dev_err() et al). It introduces a set of i2c-specific helpers and
starts using them across bus drivers. For now just 12 patches but I'll
keep on doing it if these get accepted. Once these get upstream for
v6.20/7.0, we'll be able to also start converting i2c drivers outside of
drivers/i2c/.
Link: [1] https://lore.kernel.org/all/20251106152330.11733-1-tzungbi@kernel.org/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- Add a patch renaming an existing i2c_dbg() macro in a media driver
- Link to v1: https://lore.kernel.org/r/20251223-i2c-printk-helpers-v1-0-46a08306afdb@oss.qualcomm.com
---
Bartosz Golaszewski (13):
media: saa7134: rename i2c_dbg() to saa7134_i2c_dbg()
i2c: add i2c_adapter-specific printk helpers
i2c: sun6i-p2wi: use i2c_adapter-specific printk helpers
i2c: mlxbf: use i2c_adapter-specific printk helpers
i2c: isch: use i2c_adapter-specific printk helpers
i2c: ali1535: use i2c_adapter-specific printk helpers
i2c: scmi: use i2c_adapter-specific printk helpers
i2c: ali15x3: use i2c_adapter-specific printk helpers
i2c: powermac: use i2c_adapter-specific printk helpers
i2c: owl: use i2c_adapter-specific printk helpers
i2c: nforce2: use i2c_adapter-specific printk helpers
i2c: amd756: use i2c_adapter-specific printk helpers
i2c: piix4: use i2c_adapter-specific printk helpers
drivers/i2c/busses/i2c-ali1535.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-ali15x3.c | 20 ++++++++++----------
drivers/i2c/busses/i2c-amd756.c | 24 ++++++++++++------------
drivers/i2c/busses/i2c-isch.c | 32 ++++++++++++++++----------------
drivers/i2c/busses/i2c-mlxbf.c | 19 +++++++++----------
drivers/i2c/busses/i2c-nforce2.c | 14 +++++++-------
drivers/i2c/busses/i2c-owl.c | 4 ++--
drivers/i2c/busses/i2c-piix4.c | 8 ++++----
drivers/i2c/busses/i2c-powermac.c | 26 +++++++++++++-------------
drivers/i2c/busses/i2c-scmi.c | 6 +++---
drivers/i2c/busses/i2c-sun6i-p2wi.c | 8 ++++----
drivers/media/pci/saa7134/saa7134-i2c.c | 26 +++++++++++++-------------
include/linux/i2c.h | 6 ++++++
13 files changed, 109 insertions(+), 104 deletions(-)
---
base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
change-id: 20251222-i2c-printk-helpers-a69f4403ca70
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
| null | null | null | [PATCH v2 00/13] i2c: add and start using i2c_adapter-specific
printk helpers | On Fri, Feb 27, 2026 at 11:06 AM Johan Hovold <johan@kernel.org> wrote:
I feel like we've discussed it already under v1 or elsewhere.
This is a weird pattern you sometimes see where a driver allocates
something and passes the ownership to the subsystem. This often
causes confusion among driver authors, who logically assume that if
you allocate something, you are responsible for freeing it. Since this
is C and not Rust (where such things are tracked by the compiler), I
strongly believe we should strive to keep ownership consistent: the
driver should free resources it allocated within the bounds of the
lifetime of the device it controls. The subsystem should manage the
data it allocated - in this case the i2c adapter struct device.
I know there are a lot of places where this is done in the kernel but
let's not introduce new ones. This is a bad pattern.
But even if you decided this is the way to go, I fail to see how it
would be easier than what I'm trying to do. You would have to modify
*all* I2C bus drivers as opposed to only modifying those that access
the underlying struct device. Or am I missing something?
Bartosz | {
"author": "Bartosz Golaszewski <brgl@kernel.org>",
"date": "Fri, 27 Feb 2026 16:42:09 +0100",
"is_openbsd": false,
"thread_id": "CAMRc=MfcvD1nJy=zpoCkSkJq6WjyXQxFUZ4QE6vyCS+XFCn5AA@mail.gmail.com.mbox.gz"
} |
lkml_critique | lkml | This reverts commit 1366cd228b0c67b60a2c0c26ef37fe9f7cfedb7f.
The fwnode_usb_role_switch_get() returns NULL only if no connection is
found, returns ERR_PTR(-EPROBE_DEFER) if connection is found but deferred
probe is needed, or a valid pointer of usb_role_switch.
When switching from NULL check to IS_ERR_OR_NULL(), usb_role_switch_get()
will return NULL pointer which will override ERR_PTR(-EPROBE_DEFER) which
is returned by fwnode_usb_role_switch_get(). Then usb role switch can't be
obtained because the defer probe info is lost. So the unique error should
not be regarded the same as NULL.
Fixes: 1366cd228b0c ("tcpm: allow looking for role_sw device in the main node")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
Also correct a description in 1366cd228b0c ("tcpm: allow looking for
role_sw device in the main node"), if the ports are defined in the tcpc
main node, NULL pointer is returned by fwnode_usb_role_switch_get()
instead of an error.
---
drivers/usb/typec/tcpm/tcpm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 1d2f3af034c5..8e0e14a2704e 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -7890,7 +7890,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
port->partner_desc.identity = &port->partner_ident;
port->role_sw = fwnode_usb_role_switch_get(tcpc->fwnode);
- if (IS_ERR_OR_NULL(port->role_sw))
+ if (!port->role_sw)
port->role_sw = usb_role_switch_get(port->dev);
if (IS_ERR(port->role_sw)) {
err = PTR_ERR(port->role_sw);
--
2.34.1
| null | null | null | [PATCH] Revert "tcpm: allow looking for role_sw device in the main node" | Hi,
Le 24/02/2026 à 12:01, Xu Yang a écrit :
I believe a plain revert isn't the right solution here, as we'll get to
the same point as we were before 1366cd228b0c, where some devices
stopped working properly with newer kernels.
It might be worth saving the error and restoring it after the call to
usb_role_switch_get() instead, something like:
if (IS_ERR_OR_NULL(port->role_sw)) {
err = PTR_ERR(port->role_sw);
port->role_sw = usb_role_switch_get(port->dev);
if (!port->role_sw)
port->role_sw = ERR_PTR(err);
}
Best regards,
Arnaud | {
"author": "Arnaud Ferraris <arnaud.ferraris@collabora.com>",
"date": "Tue, 24 Feb 2026 12:33:33 +0100",
"is_openbsd": false,
"thread_id": "073cbeb3-04a8-4b26-a7b6-ef0b7654c34c@collabora.com.mbox.gz"
} |
lkml_critique | lkml | This reverts commit 1366cd228b0c67b60a2c0c26ef37fe9f7cfedb7f.
The fwnode_usb_role_switch_get() returns NULL only if no connection is
found, returns ERR_PTR(-EPROBE_DEFER) if connection is found but deferred
probe is needed, or a valid pointer of usb_role_switch.
When switching from NULL check to IS_ERR_OR_NULL(), usb_role_switch_get()
will return NULL pointer which will override ERR_PTR(-EPROBE_DEFER) which
is returned by fwnode_usb_role_switch_get(). Then usb role switch can't be
obtained because the defer probe info is lost. So the unique error should
not be regarded the same as NULL.
Fixes: 1366cd228b0c ("tcpm: allow looking for role_sw device in the main node")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
Also correct a description in 1366cd228b0c ("tcpm: allow looking for
role_sw device in the main node"), if the ports are defined in the tcpc
main node, NULL pointer is returned by fwnode_usb_role_switch_get()
instead of an error.
---
drivers/usb/typec/tcpm/tcpm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 1d2f3af034c5..8e0e14a2704e 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -7890,7 +7890,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
port->partner_desc.identity = &port->partner_ident;
port->role_sw = fwnode_usb_role_switch_get(tcpc->fwnode);
- if (IS_ERR_OR_NULL(port->role_sw))
+ if (!port->role_sw)
port->role_sw = usb_role_switch_get(port->dev);
if (IS_ERR(port->role_sw)) {
err = PTR_ERR(port->role_sw);
--
2.34.1
| null | null | null | [PATCH] Revert "tcpm: allow looking for role_sw device in the main node" | Hi Arnaud,
On Tue, Feb 24, 2026 at 12:33:33PM +0100, Arnaud Ferraris wrote:
I don't think 1366cd228b0c fix the real root problem because the description
should be wrong in the commit message. If -EPROBE_DEFER is returned by
fwnode_usb_role_switch_get(), the ports node should be in connector node
instead of tcpc node. However, you get the error when ports in tcpc node.
Could you double check the issue, so we can find a proper solution and avoid
the further regression?
It works but we'd better to get the thing clear firstly.
Thanks,
Xu Yang | {
"author": "Xu Yang <xu.yang_2@nxp.com>",
"date": "Wed, 25 Feb 2026 10:57:47 +0800",
"is_openbsd": false,
"thread_id": "073cbeb3-04a8-4b26-a7b6-ef0b7654c34c@collabora.com.mbox.gz"
} |
lkml_critique | lkml | This reverts commit 1366cd228b0c67b60a2c0c26ef37fe9f7cfedb7f.
The fwnode_usb_role_switch_get() returns NULL only if no connection is
found, returns ERR_PTR(-EPROBE_DEFER) if connection is found but deferred
probe is needed, or a valid pointer of usb_role_switch.
When switching from NULL check to IS_ERR_OR_NULL(), usb_role_switch_get()
will return NULL pointer which will override ERR_PTR(-EPROBE_DEFER) which
is returned by fwnode_usb_role_switch_get(). Then usb role switch can't be
obtained because the defer probe info is lost. So the unique error should
not be regarded the same as NULL.
Fixes: 1366cd228b0c ("tcpm: allow looking for role_sw device in the main node")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
Also correct a description in 1366cd228b0c ("tcpm: allow looking for
role_sw device in the main node"), if the ports are defined in the tcpc
main node, NULL pointer is returned by fwnode_usb_role_switch_get()
instead of an error.
---
drivers/usb/typec/tcpm/tcpm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 1d2f3af034c5..8e0e14a2704e 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -7890,7 +7890,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc)
port->partner_desc.identity = &port->partner_ident;
port->role_sw = fwnode_usb_role_switch_get(tcpc->fwnode);
- if (IS_ERR_OR_NULL(port->role_sw))
+ if (!port->role_sw)
port->role_sw = usb_role_switch_get(port->dev);
if (IS_ERR(port->role_sw)) {
err = PTR_ERR(port->role_sw);
--
2.34.1
| null | null | null | [PATCH] Revert "tcpm: allow looking for role_sw device in the main node" | Hi Xu,
Le 25/02/2026 à 03:57, Xu Yang a écrit :
Sure, I'll come up with more details asap, either tomorrow or early next
week.
Best regards,
Arnaud | {
"author": "Arnaud Ferraris <arnaud.ferraris@collabora.com>",
"date": "Fri, 27 Feb 2026 16:45:30 +0100",
"is_openbsd": false,
"thread_id": "073cbeb3-04a8-4b26-a7b6-ef0b7654c34c@collabora.com.mbox.gz"
} |
lkml_critique | lkml | There are some clocks where the rounding is managed by the hardware, and
the determine_rate() clk ops is just a noop that simply returns 0. Based
on discussions with Stephen at Linux Plumbers Conference, he suggested
adding a flag for this particular case. So let's add a new flag, and
update the clk core so that the determine_rate() clk op is not required
when this flag is set.
This series adds the flag, some kunit tests, and updates all of the
relevant drivers under drivers/clk to use the new flag.
Once this is merged, and in Linus's tree, I can update the few remaining
clk drivers that are outside of drivers/clk via those subsystems at a
later time.
Merge Strategy
--------------
All of this needs to be directly merged by Stephen as one series into
his tree. Subsystem maintainers: please leave a Reviewed-by or Acked-by.
To reduce the noise, I am only CCing people on their respective drivers.
Note this series depends on 3 previously-posted patches in this git pull
to Stephen for v7.1.
https://lore.kernel.org/linux-clk/aZuK4-QJCXUeSxtL@redhat.com/
Hopefully I set the depeendencies up correctly in b4.
Signed-off-by: Brian Masney <bmasney@redhat.com>
---
Brian Masney (13):
clk: add new flag CLK_ROUNDING_FW_MANAGED
clk: test: add test suite for CLK_ROUNDING_FW_MANAGED flag
clk: rp1: drop determine_rate op and use CLK_ROUNDING_FW_MANAGED flag
clk: scpi: drop determine_rate op and use CLK_ROUNDING_FW_MANAGED flag
clk: hisilicon: hi3660-stub: drop determine_rate op and use CLK_ROUNDING_FW_MANAGED flag
clk: imx: scu: drop redundant init.ops variable assignment
clk: imx: scu: drop determine_rate op and use CLK_ROUNDING_FW_MANAGED flag
clk: qcom: rpm: drop determine_rate op and use CLK_ROUNDING_FW_MANAGED flag
clk: qcom: rpmh: drop determine_rate op and use CLK_ROUNDING_FW_MANAGED flag
clk: qcom: smd-rpm: drop determine_rate op and use CLK_ROUNDING_FW_MANAGED flag
clk: renesas: rzg2l-cpg: drop determine_rate op and use CLK_ROUNDING_FW_MANAGED flag
clk: samsung: acpm: drop determine_rate op and use CLK_ROUNDING_FW_MANAGED flag
clk: sprd: drop determine_rate op and use CLK_ROUNDING_FW_MANAGED flag
drivers/clk/clk-rp1.c | 11 +----
drivers/clk/clk-scpi.c | 14 +-----
drivers/clk/clk.c | 24 ++++++++--
drivers/clk/clk_test.c | 85 +++++++++++++++++++++++++++++++++
drivers/clk/hisilicon/clk-hi3660-stub.c | 14 +-----
drivers/clk/imx/clk-scu.c | 23 +--------
drivers/clk/qcom/clk-rpm.c | 16 ++-----
drivers/clk/qcom/clk-rpmh.c | 8 +---
drivers/clk/qcom/clk-smd-rpm.c | 15 +-----
drivers/clk/renesas/rzg2l-cpg.c | 9 +---
drivers/clk/samsung/clk-acpm.c | 14 +-----
drivers/clk/sprd/pll.c | 7 ---
drivers/clk/sprd/pll.h | 2 +-
include/linux/clk-provider.h | 2 +
14 files changed, 123 insertions(+), 121 deletions(-)
---
base-commit: 7d6661873f6b54c75195780a40d66bad3d482d8f
change-id: 20260226-clk-det-rate-fw-managed-4b8d061f31be
prerequisite-patch-id: 59198edc95aca82a29327137ad2af82ec13295b6
prerequisite-patch-id: 8932e170649711d7a80c57784033a37faadd519b
prerequisite-patch-id: 91c7b1851c5d77e504c49ce6bf14b3f8b84e826a
Best regards,
--
Brian Masney <bmasney@redhat.com>
| null | null | null | [PATCH 00/13] clk: add new flag CLK_ROUNDING_FW_MANAGED | Hi Biju,
On Fri, Feb 27, 2026 at 03:23:19PM +0000, Biju Das wrote:
OK. So how do you all want to proceed here?
Do you want to fill out the determine rate in this driver? If so, we can
just drop this particular patch from this series.
Since the PLL is capable of any frequency, do you want to keep the empty
determine rate functionality? If so, we could use a different name for
this flag. Maybe CLK_ROUNDING_NOOP?
Brian | {
"author": "Brian Masney <bmasney@redhat.com>",
"date": "Fri, 27 Feb 2026 10:48:15 -0500",
"is_openbsd": false,
"thread_id": "aaG8v-y9UqsgOZxy@redhat.com.mbox.gz"
} |
lkml_critique | lkml | Qualcomm kaanapali platform have a newer generation of video IP iris4.
The hardware have evolved mostly with respect to higher number of power
domains as well as multiple clock sources.
Considering iris as a client driver, it adds the handling for multiple
stream ids from VPU via iommu-map.
This series is depend on the below series:
https://lore.kernel.org/all/20260226074245.3098486-1-vijayanand.jitta@oss.qualcomm.com/
Following patches were dropped in v2, as per the comments, and would
be posted separately. This series depends on these patches for
functionality.
- https://lore.kernel.org/all/20260126-kaanapali-iris-v1-2-e2646246bfc1@oss.qualcomm.com/
- https://lore.kernel.org/all/20260126-kaanapali-iris-v1-3-e2646246bfc1@oss.qualcomm.com/
Patch #4 is also posted alongwith below series. If the other series is
picked earlier, then this patch can be dropped from this series.
https://lore.kernel.org/all/20260227-iris_sc7280_gen2_support-v2-1-7e5b13d26542@oss.qualcomm.com/
Following are the compliance and functional validation reports.
v4l2-compliance report for decoder including streaming tests:
v4l2-compliance 1.33.0-5441, 64 bits, 64-bit time_t
v4l2-compliance SHA: 4310f15610f4 2026-01-18 22:09:17
Compliance test for iris_driver device /dev/video0:
Driver Info:
Driver name : iris_driver
Card type : Iris Decoder
Bus info : platform:2000000.video-codec
Driver version : 6.19.0
Capabilities : 0x84204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Detected Stateful Decoder
Required ioctls:
test VIDIOC_QUERYCAP: OK
test invalid ioctls: OK
Allow for multiple opens:
test second /dev/video0 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 12 Private Controls: 0
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK
test Composing: OK
test Scaling: OK (Not Supported)
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test CREATE_BUFS maximum buffers: OK
test VIDIOC_REMOVE_BUFS: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)
test blocking wait: OK
Test input 0:
Streaming ioctls:
test read/write: OK (Not Supported)
the input file is smaller than 7077888 bytes
Video Capture Multiplanar: Captured 465 buffers
test MMAP (select, REQBUFS): OK
the input file is smaller than 7077888 bytes
Video Capture Multiplanar: Captured 465 buffers
test MMAP (epoll, REQBUFS): OK
the input file is smaller than 7077888 bytes
Video Capture Multiplanar: Captured 465 buffers
test MMAP (select, CREATE_BUFS): OK
the input file is smaller than 7077888 bytes
Video Capture Multiplanar: Captured 465 buffers
test MMAP (epoll, CREATE_BUFS): OK
test USERPTR (select): OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device
Total for iris_driver device /dev/video0: 54, Succeeded: 54, Failed: 0,
Warnings: 0
v4l2-compliance report for encoder including streaming tests:
v4l2-compliance 1.33.0-5441, 64 bits, 64-bit time_t
v4l2-compliance SHA: 4310f15610f4 2026-01-18 22:09:17
Compliance test for iris_driver device /dev/video1:
Driver Info:
Driver name : iris_driver
Card type : Iris Encoder
Bus info : platform:2000000.video-codec
Driver version : 6.19.0
Capabilities : 0x84204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Detected Stateful Encoder
Required ioctls:
test VIDIOC_QUERYCAP: OK
test invalid ioctls: OK
Allow for multiple opens:
test second /dev/video1 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 38 Private Controls: 0
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test CREATE_BUFS maximum buffers: OK
test VIDIOC_REMOVE_BUFS: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)
test blocking wait: OK
Test input 0:
Streaming ioctls:
test read/write: OK (Not Supported)
Video Capture Multiplanar: Captured 61 buffers
test MMAP (select, REQBUFS): OK
Video Capture Multiplanar: Captured 61 buffers
test MMAP (epoll, REQBUFS): OK
Video Capture Multiplanar: Captured 61 buffers
test MMAP (select, CREATE_BUFS): OK
Video Capture Multiplanar: Captured 61 buffers
test MMAP (epoll, CREATE_BUFS): OK
test USERPTR (select): OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device
Total for iris_driver device /dev/video1: 54, Succeeded: 54, Failed: 0,
Warnings: 0
Fluster test report:
77/135 while testing JVT-AVC_V1 with
GStreamer-H.264-V4L2-Gst1.0.JVT-AVC_V1
The failing tests are:
- 52 test vectors failed due to interlaced clips: Interlaced decoding is
not supported.
- cabac_mot_fld0_full
- cabac_mot_mbaff0_full
- cabac_mot_picaff0_full
- CABREF3_Sand_D
- CAFI1_SVA_C
- CAMA1_Sony_C
- CAMA1_TOSHIBA_B
- cama1_vtc_c
- cama2_vtc_b
- CAMA3_Sand_E
- cama3_vtc_b
- CAMACI3_Sony_C
- CAMANL1_TOSHIBA_B
- CAMANL2_TOSHIBA_B
- CAMANL3_Sand_E
- CAMASL3_Sony_B
- CAMP_MOT_MBAFF_L30
- CAMP_MOT_MBAFF_L31
- CANLMA2_Sony_C
- CANLMA3_Sony_C
- CAPA1_TOSHIBA_B
- CAPAMA3_Sand_F
- cavlc_mot_fld0_full_B
- cavlc_mot_mbaff0_full_B
- cavlc_mot_picaff0_full_B
- CVCANLMA2_Sony_C
- CVFI1_Sony_D
- CVFI1_SVA_C
- CVFI2_Sony_H
- CVFI2_SVA_C
- CVMA1_Sony_D
- CVMA1_TOSHIBA_B
- CVMANL1_TOSHIBA_B
- CVMANL2_TOSHIBA_B
- CVMAPAQP3_Sony_E
- CVMAQP2_Sony_G
- CVMAQP3_Sony_D
- CVMP_MOT_FLD_L30_B
- CVNLFI1_Sony_C
- CVNLFI2_Sony_H
- CVPA1_TOSHIBA_B
- FI1_Sony_E
- MR6_BT_B
- MR7_BT_B
- MR8_BT_B
- MR9_BT_B
- Sharp_MP_Field_1_B
- Sharp_MP_Field_2_B
- Sharp_MP_Field_3_B
- Sharp_MP_PAFF_1r2
- Sharp_MP_PAFF_2r
- CVMP_MOT_FRM_L31_B
3 test case failed due to unsupported bitstream.
num_slice_groups_minus1 greater than zero is not supported.
- FM1_BT_B
- FM1_FT_E
- FM2_SVA_C
2 test case failed because SP_SLICE type is not supported.
- SP1_BT_A
- sp2_bt_b
1 test case failed due to unsupported profile.
- BA3_SVA_C
131/147 testcases passed while testing JCT-VC-HEVC_V1 with
GStreamer-H.265-V4L2-Gst1.0
10 testcases failed due to unsupported 10 bit format.
- DBLK_A_MAIN10_VIXS_4
- INITQP_B_Main10_Sony_1
- TSUNEQBD_A_MAIN10_Technicolor_2
- WP_A_MAIN10_Toshiba_3
- WP_MAIN10_B_Toshiba_3
- WPP_A_ericsson_MAIN10_2
- WPP_B_ericsson_MAIN10_2
- WPP_C_ericsson_MAIN10_2
- WPP_E_ericsson_MAIN10_2
- WPP_F_ericsson_MAIN10_2
4 testcase failed due to unsupported resolution.
- PICSIZE_A_Bossen_1
- PICSIZE_B_Bossen_1
- WPP_D_ericsson_MAIN10_2
- WPP_D_ericsson_MAIN_2
2 testcase failed due to CRC mismatch.
- VPSSPSPPS_A_MainConcept_1
This fails with software decoder as well. Earlier discussion on this
here https://lore.kernel.org/all/63ca375440c4ff2f55ea0aa4e19458f775552d88.camel@ndufresne.ca/
- RAP_A_docomo_6
This was discussed on bug
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4392
Based on above discussion, the initial error frames need to be safely
dropped in the firmware or driver side. Client does not have the
required logic to drop them even if marked as error.
Discussion ongoing with video firmware team on a way to handle such
case. Note that the issue is not specific to kaanapali, and its there on
all platforms.
235/305 testcases passed while testing VP9-TEST-VECTORS with GStreamer-VP9-V4L2-Gst1.0
64 testcases failed due to unsupported resolution
- vp90-2-02-size-08x08.webm
- vp90-2-02-size-08x10.webm
- vp90-2-02-size-08x16.webm
- vp90-2-02-size-08x18.webm
- vp90-2-02-size-08x32.webm
- vp90-2-02-size-08x34.webm
- vp90-2-02-size-08x64.webm
- vp90-2-02-size-08x66.webm
- vp90-2-02-size-10x08.webm
- vp90-2-02-size-10x10.webm
- vp90-2-02-size-10x16.webm
- vp90-2-02-size-10x18.webm
- vp90-2-02-size-10x32.webm
- vp90-2-02-size-10x34.webm
- vp90-2-02-size-10x64.webm
- vp90-2-02-size-10x66.webm
- vp90-2-02-size-16x08.webm
- vp90-2-02-size-16x10.webm
- vp90-2-02-size-16x16.webm
- vp90-2-02-size-16x18.webm
- vp90-2-02-size-16x32.webm
- vp90-2-02-size-16x34.webm
- vp90-2-02-size-16x64.webm
- vp90-2-02-size-16x66.webm
- vp90-2-02-size-18x08.webm
- vp90-2-02-size-18x10.webm
- vp90-2-02-size-18x16.webm
- vp90-2-02-size-18x18.webm
- vp90-2-02-size-18x32.webm
- vp90-2-02-size-18x34.webm
- vp90-2-02-size-18x64.webm
- vp90-2-02-size-18x66.webm
- vp90-2-02-size-32x08.webm
- vp90-2-02-size-32x10.webm
- vp90-2-02-size-32x16.webm
- vp90-2-02-size-32x18.webm
- vp90-2-02-size-32x32.webm
- vp90-2-02-size-32x34.webm
- vp90-2-02-size-32x64.webm
- vp90-2-02-size-32x66.webm
- vp90-2-02-size-34x08.webm
- vp90-2-02-size-34x10.webm
- vp90-2-02-size-34x16.webm
- vp90-2-02-size-34x18.webm
- vp90-2-02-size-34x32.webm
- vp90-2-02-size-34x34.webm
- vp90-2-02-size-34x64.webm
- vp90-2-02-size-34x66.webm
- vp90-2-02-size-64x08.webm
- vp90-2-02-size-64x10.webm
- vp90-2-02-size-64x16.webm
- vp90-2-02-size-64x18.webm
- vp90-2-02-size-64x32.webm
- vp90-2-02-size-64x34.webm
- vp90-2-02-size-64x64.webm
- vp90-2-02-size-64x66.webm
- vp90-2-02-size-66x08.webm
- vp90-2-02-size-66x10.webm
- vp90-2-02-size-66x16.webm
- vp90-2-02-size-66x18.webm
- vp90-2-02-size-66x32.webm
- vp90-2-02-size-66x34.webm
- vp90-2-02-size-66x64.webm
- vp90-2-02-size-66x66.webm
2 testcases failed due to unsupported format.
- vp91-2-04-yuv422.webm
- vp91-2-04-yuv444.webm
2 testcase failed due to unsupported resolution after DRC.
- vp90-2-21-resize_inter_320x180_5_1-2.webm
- vp90-2-21-resize_inter_320x180_7_1-2.webm
1 testcase failed with CRC mismatch.
- vp90-2-22-svc_1280x720_3.ivf
Discussion ongoing with firmware team on how to handle this case. This
is not specific to kaanapali, and its there on all platforms.
1 testcase failed due to unsupported stream.
- vp90-2-16-intra-only.webm
Signed-off-by: Vikash Garodia <vikash.garodia@oss.qualcomm.com>
---
Changes in v2:
- Described iommu map in a better way in binding (Dmitry, Krzysztof)
- Defined the function IDs as ABI instead of hardcode numbers (Dmitry)
- Added iris vpu bus and configured callback for dma_configure (Robin)
- Remove parsing of iommu-map from driver (Robin)
- Fixed fluster issues by adding H265 line buffer calculation for vpu4
- Dropped iommu patches #2 and #3 from this series. Those would be
posted separately (Bryan)
- Link to v1: https://lore.kernel.org/r/20260126-kaanapali-iris-v1-0-e2646246bfc1@oss.qualcomm.com
---
Vikash Garodia (7):
media: dt-bindings: qcom-kaanapali-iris: Add kaanapali video codec binding
media: iris: switch to hardware mode after firmware boot
media: iris: add iris vpu bus support and register it with iommu_buses
media: iris: add context bank devices using iommu-map
media: iris: add helper to select context bank device
media: iris: add iris4 specific H265 line buffer calculation
media: iris: add platform data for kaanapali
.../bindings/media/qcom,kaanapali-iris.yaml | 261 +++++++++++++++++++++
drivers/iommu/iommu.c | 4 +
drivers/media/platform/qcom/iris/Makefile | 4 +
drivers/media/platform/qcom/iris/iris_buffer.c | 7 +-
drivers/media/platform/qcom/iris/iris_buffer.h | 2 +
drivers/media/platform/qcom/iris/iris_core.c | 4 +
drivers/media/platform/qcom/iris/iris_hfi_common.c | 4 +
drivers/media/platform/qcom/iris/iris_hfi_queue.c | 16 +-
.../platform/qcom/iris/iris_platform_common.h | 19 ++
.../media/platform/qcom/iris/iris_platform_gen2.c | 90 +++++++
.../platform/qcom/iris/iris_platform_kaanapali.h | 86 +++++++
drivers/media/platform/qcom/iris/iris_probe.c | 64 ++++-
drivers/media/platform/qcom/iris/iris_resources.c | 96 ++++++++
drivers/media/platform/qcom/iris/iris_resources.h | 3 +
drivers/media/platform/qcom/iris/iris_vidc.c | 4 +-
drivers/media/platform/qcom/iris/iris_vpu2.c | 1 +
drivers/media/platform/qcom/iris/iris_vpu3x.c | 9 +-
drivers/media/platform/qcom/iris/iris_vpu4x.c | 24 +-
drivers/media/platform/qcom/iris/iris_vpu_buffer.c | 51 +++-
drivers/media/platform/qcom/iris/iris_vpu_bus.c | 32 +++
drivers/media/platform/qcom/iris/iris_vpu_common.c | 16 +-
drivers/media/platform/qcom/iris/iris_vpu_common.h | 3 +
include/dt-bindings/media/qcom,iris.h | 18 ++
include/linux/iris_vpu_bus.h | 13 +
24 files changed, 791 insertions(+), 40 deletions(-)
---
base-commit: 7d6661873f6b54c75195780a40d66bad3d482d8f
change-id: 20260126-kaanapali-iris-29fd184e2fe4
prerequisite-message-id: <20260226074245.3098486-1-vijayanand.jitta@oss.qualcomm.com>
prerequisite-patch-id: 421e3bb43ae0dbd6a1ba02acd02592d260456eb1
prerequisite-patch-id: f4b9b5e59b3d37407941f7fee05ca4996ad3d9ba
prerequisite-patch-id: 4556a2b44275b120be0faa86bde0b55593065476
Best regards,
--
Vikash Garodia <vikash.garodia@oss.qualcomm.com>
| null | null | null | [PATCH v2 0/7] media: iris: add support for kaanapali platform | On 27/02/2026 15:11, Vikash Garodia wrote:
How many copies do you want of this? Data definition never goes to
headers. That's standard C rules.
Best regards,
Krzysztof | {
"author": "Krzysztof Kozlowski <krzk@kernel.org>",
"date": "Fri, 27 Feb 2026 16:48:31 +0100",
"is_openbsd": false,
"thread_id": "20257f68-04cf-40fa-9f0b-bd798e62b7eb@kernel.org.mbox.gz"
} |
lkml_critique | lkml | Qualcomm kaanapali platform have a newer generation of video IP iris4.
The hardware have evolved mostly with respect to higher number of power
domains as well as multiple clock sources.
Considering iris as a client driver, it adds the handling for multiple
stream ids from VPU via iommu-map.
This series is depend on the below series:
https://lore.kernel.org/all/20260226074245.3098486-1-vijayanand.jitta@oss.qualcomm.com/
Following patches were dropped in v2, as per the comments, and would
be posted separately. This series depends on these patches for
functionality.
- https://lore.kernel.org/all/20260126-kaanapali-iris-v1-2-e2646246bfc1@oss.qualcomm.com/
- https://lore.kernel.org/all/20260126-kaanapali-iris-v1-3-e2646246bfc1@oss.qualcomm.com/
Patch #4 is also posted alongwith below series. If the other series is
picked earlier, then this patch can be dropped from this series.
https://lore.kernel.org/all/20260227-iris_sc7280_gen2_support-v2-1-7e5b13d26542@oss.qualcomm.com/
Following are the compliance and functional validation reports.
v4l2-compliance report for decoder including streaming tests:
v4l2-compliance 1.33.0-5441, 64 bits, 64-bit time_t
v4l2-compliance SHA: 4310f15610f4 2026-01-18 22:09:17
Compliance test for iris_driver device /dev/video0:
Driver Info:
Driver name : iris_driver
Card type : Iris Decoder
Bus info : platform:2000000.video-codec
Driver version : 6.19.0
Capabilities : 0x84204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Detected Stateful Decoder
Required ioctls:
test VIDIOC_QUERYCAP: OK
test invalid ioctls: OK
Allow for multiple opens:
test second /dev/video0 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 12 Private Controls: 0
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK
test Composing: OK
test Scaling: OK (Not Supported)
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test CREATE_BUFS maximum buffers: OK
test VIDIOC_REMOVE_BUFS: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)
test blocking wait: OK
Test input 0:
Streaming ioctls:
test read/write: OK (Not Supported)
the input file is smaller than 7077888 bytes
Video Capture Multiplanar: Captured 465 buffers
test MMAP (select, REQBUFS): OK
the input file is smaller than 7077888 bytes
Video Capture Multiplanar: Captured 465 buffers
test MMAP (epoll, REQBUFS): OK
the input file is smaller than 7077888 bytes
Video Capture Multiplanar: Captured 465 buffers
test MMAP (select, CREATE_BUFS): OK
the input file is smaller than 7077888 bytes
Video Capture Multiplanar: Captured 465 buffers
test MMAP (epoll, CREATE_BUFS): OK
test USERPTR (select): OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device
Total for iris_driver device /dev/video0: 54, Succeeded: 54, Failed: 0,
Warnings: 0
v4l2-compliance report for encoder including streaming tests:
v4l2-compliance 1.33.0-5441, 64 bits, 64-bit time_t
v4l2-compliance SHA: 4310f15610f4 2026-01-18 22:09:17
Compliance test for iris_driver device /dev/video1:
Driver Info:
Driver name : iris_driver
Card type : Iris Encoder
Bus info : platform:2000000.video-codec
Driver version : 6.19.0
Capabilities : 0x84204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Detected Stateful Encoder
Required ioctls:
test VIDIOC_QUERYCAP: OK
test invalid ioctls: OK
Allow for multiple opens:
test second /dev/video1 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 38 Private Controls: 0
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test CREATE_BUFS maximum buffers: OK
test VIDIOC_REMOVE_BUFS: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)
test blocking wait: OK
Test input 0:
Streaming ioctls:
test read/write: OK (Not Supported)
Video Capture Multiplanar: Captured 61 buffers
test MMAP (select, REQBUFS): OK
Video Capture Multiplanar: Captured 61 buffers
test MMAP (epoll, REQBUFS): OK
Video Capture Multiplanar: Captured 61 buffers
test MMAP (select, CREATE_BUFS): OK
Video Capture Multiplanar: Captured 61 buffers
test MMAP (epoll, CREATE_BUFS): OK
test USERPTR (select): OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device
Total for iris_driver device /dev/video1: 54, Succeeded: 54, Failed: 0,
Warnings: 0
Fluster test report:
77/135 while testing JVT-AVC_V1 with
GStreamer-H.264-V4L2-Gst1.0.JVT-AVC_V1
The failing tests are:
- 52 test vectors failed due to interlaced clips: Interlaced decoding is
not supported.
- cabac_mot_fld0_full
- cabac_mot_mbaff0_full
- cabac_mot_picaff0_full
- CABREF3_Sand_D
- CAFI1_SVA_C
- CAMA1_Sony_C
- CAMA1_TOSHIBA_B
- cama1_vtc_c
- cama2_vtc_b
- CAMA3_Sand_E
- cama3_vtc_b
- CAMACI3_Sony_C
- CAMANL1_TOSHIBA_B
- CAMANL2_TOSHIBA_B
- CAMANL3_Sand_E
- CAMASL3_Sony_B
- CAMP_MOT_MBAFF_L30
- CAMP_MOT_MBAFF_L31
- CANLMA2_Sony_C
- CANLMA3_Sony_C
- CAPA1_TOSHIBA_B
- CAPAMA3_Sand_F
- cavlc_mot_fld0_full_B
- cavlc_mot_mbaff0_full_B
- cavlc_mot_picaff0_full_B
- CVCANLMA2_Sony_C
- CVFI1_Sony_D
- CVFI1_SVA_C
- CVFI2_Sony_H
- CVFI2_SVA_C
- CVMA1_Sony_D
- CVMA1_TOSHIBA_B
- CVMANL1_TOSHIBA_B
- CVMANL2_TOSHIBA_B
- CVMAPAQP3_Sony_E
- CVMAQP2_Sony_G
- CVMAQP3_Sony_D
- CVMP_MOT_FLD_L30_B
- CVNLFI1_Sony_C
- CVNLFI2_Sony_H
- CVPA1_TOSHIBA_B
- FI1_Sony_E
- MR6_BT_B
- MR7_BT_B
- MR8_BT_B
- MR9_BT_B
- Sharp_MP_Field_1_B
- Sharp_MP_Field_2_B
- Sharp_MP_Field_3_B
- Sharp_MP_PAFF_1r2
- Sharp_MP_PAFF_2r
- CVMP_MOT_FRM_L31_B
3 test case failed due to unsupported bitstream.
num_slice_groups_minus1 greater than zero is not supported.
- FM1_BT_B
- FM1_FT_E
- FM2_SVA_C
2 test case failed because SP_SLICE type is not supported.
- SP1_BT_A
- sp2_bt_b
1 test case failed due to unsupported profile.
- BA3_SVA_C
131/147 testcases passed while testing JCT-VC-HEVC_V1 with
GStreamer-H.265-V4L2-Gst1.0
10 testcases failed due to unsupported 10 bit format.
- DBLK_A_MAIN10_VIXS_4
- INITQP_B_Main10_Sony_1
- TSUNEQBD_A_MAIN10_Technicolor_2
- WP_A_MAIN10_Toshiba_3
- WP_MAIN10_B_Toshiba_3
- WPP_A_ericsson_MAIN10_2
- WPP_B_ericsson_MAIN10_2
- WPP_C_ericsson_MAIN10_2
- WPP_E_ericsson_MAIN10_2
- WPP_F_ericsson_MAIN10_2
4 testcase failed due to unsupported resolution.
- PICSIZE_A_Bossen_1
- PICSIZE_B_Bossen_1
- WPP_D_ericsson_MAIN10_2
- WPP_D_ericsson_MAIN_2
2 testcase failed due to CRC mismatch.
- VPSSPSPPS_A_MainConcept_1
This fails with software decoder as well. Earlier discussion on this
here https://lore.kernel.org/all/63ca375440c4ff2f55ea0aa4e19458f775552d88.camel@ndufresne.ca/
- RAP_A_docomo_6
This was discussed on bug
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4392
Based on above discussion, the initial error frames need to be safely
dropped in the firmware or driver side. Client does not have the
required logic to drop them even if marked as error.
Discussion ongoing with video firmware team on a way to handle such
case. Note that the issue is not specific to kaanapali, and its there on
all platforms.
235/305 testcases passed while testing VP9-TEST-VECTORS with GStreamer-VP9-V4L2-Gst1.0
64 testcases failed due to unsupported resolution
- vp90-2-02-size-08x08.webm
- vp90-2-02-size-08x10.webm
- vp90-2-02-size-08x16.webm
- vp90-2-02-size-08x18.webm
- vp90-2-02-size-08x32.webm
- vp90-2-02-size-08x34.webm
- vp90-2-02-size-08x64.webm
- vp90-2-02-size-08x66.webm
- vp90-2-02-size-10x08.webm
- vp90-2-02-size-10x10.webm
- vp90-2-02-size-10x16.webm
- vp90-2-02-size-10x18.webm
- vp90-2-02-size-10x32.webm
- vp90-2-02-size-10x34.webm
- vp90-2-02-size-10x64.webm
- vp90-2-02-size-10x66.webm
- vp90-2-02-size-16x08.webm
- vp90-2-02-size-16x10.webm
- vp90-2-02-size-16x16.webm
- vp90-2-02-size-16x18.webm
- vp90-2-02-size-16x32.webm
- vp90-2-02-size-16x34.webm
- vp90-2-02-size-16x64.webm
- vp90-2-02-size-16x66.webm
- vp90-2-02-size-18x08.webm
- vp90-2-02-size-18x10.webm
- vp90-2-02-size-18x16.webm
- vp90-2-02-size-18x18.webm
- vp90-2-02-size-18x32.webm
- vp90-2-02-size-18x34.webm
- vp90-2-02-size-18x64.webm
- vp90-2-02-size-18x66.webm
- vp90-2-02-size-32x08.webm
- vp90-2-02-size-32x10.webm
- vp90-2-02-size-32x16.webm
- vp90-2-02-size-32x18.webm
- vp90-2-02-size-32x32.webm
- vp90-2-02-size-32x34.webm
- vp90-2-02-size-32x64.webm
- vp90-2-02-size-32x66.webm
- vp90-2-02-size-34x08.webm
- vp90-2-02-size-34x10.webm
- vp90-2-02-size-34x16.webm
- vp90-2-02-size-34x18.webm
- vp90-2-02-size-34x32.webm
- vp90-2-02-size-34x34.webm
- vp90-2-02-size-34x64.webm
- vp90-2-02-size-34x66.webm
- vp90-2-02-size-64x08.webm
- vp90-2-02-size-64x10.webm
- vp90-2-02-size-64x16.webm
- vp90-2-02-size-64x18.webm
- vp90-2-02-size-64x32.webm
- vp90-2-02-size-64x34.webm
- vp90-2-02-size-64x64.webm
- vp90-2-02-size-64x66.webm
- vp90-2-02-size-66x08.webm
- vp90-2-02-size-66x10.webm
- vp90-2-02-size-66x16.webm
- vp90-2-02-size-66x18.webm
- vp90-2-02-size-66x32.webm
- vp90-2-02-size-66x34.webm
- vp90-2-02-size-66x64.webm
- vp90-2-02-size-66x66.webm
2 testcases failed due to unsupported format.
- vp91-2-04-yuv422.webm
- vp91-2-04-yuv444.webm
2 testcase failed due to unsupported resolution after DRC.
- vp90-2-21-resize_inter_320x180_5_1-2.webm
- vp90-2-21-resize_inter_320x180_7_1-2.webm
1 testcase failed with CRC mismatch.
- vp90-2-22-svc_1280x720_3.ivf
Discussion ongoing with firmware team on how to handle this case. This
is not specific to kaanapali, and its there on all platforms.
1 testcase failed due to unsupported stream.
- vp90-2-16-intra-only.webm
Signed-off-by: Vikash Garodia <vikash.garodia@oss.qualcomm.com>
---
Changes in v2:
- Described iommu map in a better way in binding (Dmitry, Krzysztof)
- Defined the function IDs as ABI instead of hardcode numbers (Dmitry)
- Added iris vpu bus and configured callback for dma_configure (Robin)
- Remove parsing of iommu-map from driver (Robin)
- Fixed fluster issues by adding H265 line buffer calculation for vpu4
- Dropped iommu patches #2 and #3 from this series. Those would be
posted separately (Bryan)
- Link to v1: https://lore.kernel.org/r/20260126-kaanapali-iris-v1-0-e2646246bfc1@oss.qualcomm.com
---
Vikash Garodia (7):
media: dt-bindings: qcom-kaanapali-iris: Add kaanapali video codec binding
media: iris: switch to hardware mode after firmware boot
media: iris: add iris vpu bus support and register it with iommu_buses
media: iris: add context bank devices using iommu-map
media: iris: add helper to select context bank device
media: iris: add iris4 specific H265 line buffer calculation
media: iris: add platform data for kaanapali
.../bindings/media/qcom,kaanapali-iris.yaml | 261 +++++++++++++++++++++
drivers/iommu/iommu.c | 4 +
drivers/media/platform/qcom/iris/Makefile | 4 +
drivers/media/platform/qcom/iris/iris_buffer.c | 7 +-
drivers/media/platform/qcom/iris/iris_buffer.h | 2 +
drivers/media/platform/qcom/iris/iris_core.c | 4 +
drivers/media/platform/qcom/iris/iris_hfi_common.c | 4 +
drivers/media/platform/qcom/iris/iris_hfi_queue.c | 16 +-
.../platform/qcom/iris/iris_platform_common.h | 19 ++
.../media/platform/qcom/iris/iris_platform_gen2.c | 90 +++++++
.../platform/qcom/iris/iris_platform_kaanapali.h | 86 +++++++
drivers/media/platform/qcom/iris/iris_probe.c | 64 ++++-
drivers/media/platform/qcom/iris/iris_resources.c | 96 ++++++++
drivers/media/platform/qcom/iris/iris_resources.h | 3 +
drivers/media/platform/qcom/iris/iris_vidc.c | 4 +-
drivers/media/platform/qcom/iris/iris_vpu2.c | 1 +
drivers/media/platform/qcom/iris/iris_vpu3x.c | 9 +-
drivers/media/platform/qcom/iris/iris_vpu4x.c | 24 +-
drivers/media/platform/qcom/iris/iris_vpu_buffer.c | 51 +++-
drivers/media/platform/qcom/iris/iris_vpu_bus.c | 32 +++
drivers/media/platform/qcom/iris/iris_vpu_common.c | 16 +-
drivers/media/platform/qcom/iris/iris_vpu_common.h | 3 +
include/dt-bindings/media/qcom,iris.h | 18 ++
include/linux/iris_vpu_bus.h | 13 +
24 files changed, 791 insertions(+), 40 deletions(-)
---
base-commit: 7d6661873f6b54c75195780a40d66bad3d482d8f
change-id: 20260126-kaanapali-iris-29fd184e2fe4
prerequisite-message-id: <20260226074245.3098486-1-vijayanand.jitta@oss.qualcomm.com>
prerequisite-patch-id: 421e3bb43ae0dbd6a1ba02acd02592d260456eb1
prerequisite-patch-id: f4b9b5e59b3d37407941f7fee05ca4996ad3d9ba
prerequisite-patch-id: 4556a2b44275b120be0faa86bde0b55593065476
Best regards,
--
Vikash Garodia <vikash.garodia@oss.qualcomm.com>
| null | null | null | [PATCH v2 0/7] media: iris: add support for kaanapali platform | On 27/02/2026 15:11, Vikash Garodia wrote:
Apply this patch and build it. Does it build?
Best regards,
Krzysztof | {
"author": "Krzysztof Kozlowski <krzk@kernel.org>",
"date": "Fri, 27 Feb 2026 16:49:52 +0100",
"is_openbsd": false,
"thread_id": "20257f68-04cf-40fa-9f0b-bd798e62b7eb@kernel.org.mbox.gz"
} |
lkml_critique | lkml | Qualcomm kaanapali platform have a newer generation of video IP iris4.
The hardware have evolved mostly with respect to higher number of power
domains as well as multiple clock sources.
Considering iris as a client driver, it adds the handling for multiple
stream ids from VPU via iommu-map.
This series is depend on the below series:
https://lore.kernel.org/all/20260226074245.3098486-1-vijayanand.jitta@oss.qualcomm.com/
Following patches were dropped in v2, as per the comments, and would
be posted separately. This series depends on these patches for
functionality.
- https://lore.kernel.org/all/20260126-kaanapali-iris-v1-2-e2646246bfc1@oss.qualcomm.com/
- https://lore.kernel.org/all/20260126-kaanapali-iris-v1-3-e2646246bfc1@oss.qualcomm.com/
Patch #4 is also posted alongwith below series. If the other series is
picked earlier, then this patch can be dropped from this series.
https://lore.kernel.org/all/20260227-iris_sc7280_gen2_support-v2-1-7e5b13d26542@oss.qualcomm.com/
Following are the compliance and functional validation reports.
v4l2-compliance report for decoder including streaming tests:
v4l2-compliance 1.33.0-5441, 64 bits, 64-bit time_t
v4l2-compliance SHA: 4310f15610f4 2026-01-18 22:09:17
Compliance test for iris_driver device /dev/video0:
Driver Info:
Driver name : iris_driver
Card type : Iris Decoder
Bus info : platform:2000000.video-codec
Driver version : 6.19.0
Capabilities : 0x84204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Detected Stateful Decoder
Required ioctls:
test VIDIOC_QUERYCAP: OK
test invalid ioctls: OK
Allow for multiple opens:
test second /dev/video0 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 12 Private Controls: 0
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK
test Composing: OK
test Scaling: OK (Not Supported)
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test CREATE_BUFS maximum buffers: OK
test VIDIOC_REMOVE_BUFS: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)
test blocking wait: OK
Test input 0:
Streaming ioctls:
test read/write: OK (Not Supported)
the input file is smaller than 7077888 bytes
Video Capture Multiplanar: Captured 465 buffers
test MMAP (select, REQBUFS): OK
the input file is smaller than 7077888 bytes
Video Capture Multiplanar: Captured 465 buffers
test MMAP (epoll, REQBUFS): OK
the input file is smaller than 7077888 bytes
Video Capture Multiplanar: Captured 465 buffers
test MMAP (select, CREATE_BUFS): OK
the input file is smaller than 7077888 bytes
Video Capture Multiplanar: Captured 465 buffers
test MMAP (epoll, CREATE_BUFS): OK
test USERPTR (select): OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device
Total for iris_driver device /dev/video0: 54, Succeeded: 54, Failed: 0,
Warnings: 0
v4l2-compliance report for encoder including streaming tests:
v4l2-compliance 1.33.0-5441, 64 bits, 64-bit time_t
v4l2-compliance SHA: 4310f15610f4 2026-01-18 22:09:17
Compliance test for iris_driver device /dev/video1:
Driver Info:
Driver name : iris_driver
Card type : Iris Encoder
Bus info : platform:2000000.video-codec
Driver version : 6.19.0
Capabilities : 0x84204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Detected Stateful Encoder
Required ioctls:
test VIDIOC_QUERYCAP: OK
test invalid ioctls: OK
Allow for multiple opens:
test second /dev/video1 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported)
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 38 Private Controls: 0
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test CREATE_BUFS maximum buffers: OK
test VIDIOC_REMOVE_BUFS: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)
test blocking wait: OK
Test input 0:
Streaming ioctls:
test read/write: OK (Not Supported)
Video Capture Multiplanar: Captured 61 buffers
test MMAP (select, REQBUFS): OK
Video Capture Multiplanar: Captured 61 buffers
test MMAP (epoll, REQBUFS): OK
Video Capture Multiplanar: Captured 61 buffers
test MMAP (select, CREATE_BUFS): OK
Video Capture Multiplanar: Captured 61 buffers
test MMAP (epoll, CREATE_BUFS): OK
test USERPTR (select): OK (Not Supported)
test DMABUF: Cannot test, specify --expbuf-device
Total for iris_driver device /dev/video1: 54, Succeeded: 54, Failed: 0,
Warnings: 0
Fluster test report:
77/135 while testing JVT-AVC_V1 with
GStreamer-H.264-V4L2-Gst1.0.JVT-AVC_V1
The failing tests are:
- 52 test vectors failed due to interlaced clips: Interlaced decoding is
not supported.
- cabac_mot_fld0_full
- cabac_mot_mbaff0_full
- cabac_mot_picaff0_full
- CABREF3_Sand_D
- CAFI1_SVA_C
- CAMA1_Sony_C
- CAMA1_TOSHIBA_B
- cama1_vtc_c
- cama2_vtc_b
- CAMA3_Sand_E
- cama3_vtc_b
- CAMACI3_Sony_C
- CAMANL1_TOSHIBA_B
- CAMANL2_TOSHIBA_B
- CAMANL3_Sand_E
- CAMASL3_Sony_B
- CAMP_MOT_MBAFF_L30
- CAMP_MOT_MBAFF_L31
- CANLMA2_Sony_C
- CANLMA3_Sony_C
- CAPA1_TOSHIBA_B
- CAPAMA3_Sand_F
- cavlc_mot_fld0_full_B
- cavlc_mot_mbaff0_full_B
- cavlc_mot_picaff0_full_B
- CVCANLMA2_Sony_C
- CVFI1_Sony_D
- CVFI1_SVA_C
- CVFI2_Sony_H
- CVFI2_SVA_C
- CVMA1_Sony_D
- CVMA1_TOSHIBA_B
- CVMANL1_TOSHIBA_B
- CVMANL2_TOSHIBA_B
- CVMAPAQP3_Sony_E
- CVMAQP2_Sony_G
- CVMAQP3_Sony_D
- CVMP_MOT_FLD_L30_B
- CVNLFI1_Sony_C
- CVNLFI2_Sony_H
- CVPA1_TOSHIBA_B
- FI1_Sony_E
- MR6_BT_B
- MR7_BT_B
- MR8_BT_B
- MR9_BT_B
- Sharp_MP_Field_1_B
- Sharp_MP_Field_2_B
- Sharp_MP_Field_3_B
- Sharp_MP_PAFF_1r2
- Sharp_MP_PAFF_2r
- CVMP_MOT_FRM_L31_B
3 test case failed due to unsupported bitstream.
num_slice_groups_minus1 greater than zero is not supported.
- FM1_BT_B
- FM1_FT_E
- FM2_SVA_C
2 test case failed because SP_SLICE type is not supported.
- SP1_BT_A
- sp2_bt_b
1 test case failed due to unsupported profile.
- BA3_SVA_C
131/147 testcases passed while testing JCT-VC-HEVC_V1 with
GStreamer-H.265-V4L2-Gst1.0
10 testcases failed due to unsupported 10 bit format.
- DBLK_A_MAIN10_VIXS_4
- INITQP_B_Main10_Sony_1
- TSUNEQBD_A_MAIN10_Technicolor_2
- WP_A_MAIN10_Toshiba_3
- WP_MAIN10_B_Toshiba_3
- WPP_A_ericsson_MAIN10_2
- WPP_B_ericsson_MAIN10_2
- WPP_C_ericsson_MAIN10_2
- WPP_E_ericsson_MAIN10_2
- WPP_F_ericsson_MAIN10_2
4 testcase failed due to unsupported resolution.
- PICSIZE_A_Bossen_1
- PICSIZE_B_Bossen_1
- WPP_D_ericsson_MAIN10_2
- WPP_D_ericsson_MAIN_2
2 testcase failed due to CRC mismatch.
- VPSSPSPPS_A_MainConcept_1
This fails with software decoder as well. Earlier discussion on this
here https://lore.kernel.org/all/63ca375440c4ff2f55ea0aa4e19458f775552d88.camel@ndufresne.ca/
- RAP_A_docomo_6
This was discussed on bug
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4392
Based on above discussion, the initial error frames need to be safely
dropped in the firmware or driver side. Client does not have the
required logic to drop them even if marked as error.
Discussion ongoing with video firmware team on a way to handle such
case. Note that the issue is not specific to kaanapali, and its there on
all platforms.
235/305 testcases passed while testing VP9-TEST-VECTORS with GStreamer-VP9-V4L2-Gst1.0
64 testcases failed due to unsupported resolution
- vp90-2-02-size-08x08.webm
- vp90-2-02-size-08x10.webm
- vp90-2-02-size-08x16.webm
- vp90-2-02-size-08x18.webm
- vp90-2-02-size-08x32.webm
- vp90-2-02-size-08x34.webm
- vp90-2-02-size-08x64.webm
- vp90-2-02-size-08x66.webm
- vp90-2-02-size-10x08.webm
- vp90-2-02-size-10x10.webm
- vp90-2-02-size-10x16.webm
- vp90-2-02-size-10x18.webm
- vp90-2-02-size-10x32.webm
- vp90-2-02-size-10x34.webm
- vp90-2-02-size-10x64.webm
- vp90-2-02-size-10x66.webm
- vp90-2-02-size-16x08.webm
- vp90-2-02-size-16x10.webm
- vp90-2-02-size-16x16.webm
- vp90-2-02-size-16x18.webm
- vp90-2-02-size-16x32.webm
- vp90-2-02-size-16x34.webm
- vp90-2-02-size-16x64.webm
- vp90-2-02-size-16x66.webm
- vp90-2-02-size-18x08.webm
- vp90-2-02-size-18x10.webm
- vp90-2-02-size-18x16.webm
- vp90-2-02-size-18x18.webm
- vp90-2-02-size-18x32.webm
- vp90-2-02-size-18x34.webm
- vp90-2-02-size-18x64.webm
- vp90-2-02-size-18x66.webm
- vp90-2-02-size-32x08.webm
- vp90-2-02-size-32x10.webm
- vp90-2-02-size-32x16.webm
- vp90-2-02-size-32x18.webm
- vp90-2-02-size-32x32.webm
- vp90-2-02-size-32x34.webm
- vp90-2-02-size-32x64.webm
- vp90-2-02-size-32x66.webm
- vp90-2-02-size-34x08.webm
- vp90-2-02-size-34x10.webm
- vp90-2-02-size-34x16.webm
- vp90-2-02-size-34x18.webm
- vp90-2-02-size-34x32.webm
- vp90-2-02-size-34x34.webm
- vp90-2-02-size-34x64.webm
- vp90-2-02-size-34x66.webm
- vp90-2-02-size-64x08.webm
- vp90-2-02-size-64x10.webm
- vp90-2-02-size-64x16.webm
- vp90-2-02-size-64x18.webm
- vp90-2-02-size-64x32.webm
- vp90-2-02-size-64x34.webm
- vp90-2-02-size-64x64.webm
- vp90-2-02-size-64x66.webm
- vp90-2-02-size-66x08.webm
- vp90-2-02-size-66x10.webm
- vp90-2-02-size-66x16.webm
- vp90-2-02-size-66x18.webm
- vp90-2-02-size-66x32.webm
- vp90-2-02-size-66x34.webm
- vp90-2-02-size-66x64.webm
- vp90-2-02-size-66x66.webm
2 testcases failed due to unsupported format.
- vp91-2-04-yuv422.webm
- vp91-2-04-yuv444.webm
2 testcase failed due to unsupported resolution after DRC.
- vp90-2-21-resize_inter_320x180_5_1-2.webm
- vp90-2-21-resize_inter_320x180_7_1-2.webm
1 testcase failed with CRC mismatch.
- vp90-2-22-svc_1280x720_3.ivf
Discussion ongoing with firmware team on how to handle this case. This
is not specific to kaanapali, and its there on all platforms.
1 testcase failed due to unsupported stream.
- vp90-2-16-intra-only.webm
Signed-off-by: Vikash Garodia <vikash.garodia@oss.qualcomm.com>
---
Changes in v2:
- Described iommu map in a better way in binding (Dmitry, Krzysztof)
- Defined the function IDs as ABI instead of hardcode numbers (Dmitry)
- Added iris vpu bus and configured callback for dma_configure (Robin)
- Remove parsing of iommu-map from driver (Robin)
- Fixed fluster issues by adding H265 line buffer calculation for vpu4
- Dropped iommu patches #2 and #3 from this series. Those would be
posted separately (Bryan)
- Link to v1: https://lore.kernel.org/r/20260126-kaanapali-iris-v1-0-e2646246bfc1@oss.qualcomm.com
---
Vikash Garodia (7):
media: dt-bindings: qcom-kaanapali-iris: Add kaanapali video codec binding
media: iris: switch to hardware mode after firmware boot
media: iris: add iris vpu bus support and register it with iommu_buses
media: iris: add context bank devices using iommu-map
media: iris: add helper to select context bank device
media: iris: add iris4 specific H265 line buffer calculation
media: iris: add platform data for kaanapali
.../bindings/media/qcom,kaanapali-iris.yaml | 261 +++++++++++++++++++++
drivers/iommu/iommu.c | 4 +
drivers/media/platform/qcom/iris/Makefile | 4 +
drivers/media/platform/qcom/iris/iris_buffer.c | 7 +-
drivers/media/platform/qcom/iris/iris_buffer.h | 2 +
drivers/media/platform/qcom/iris/iris_core.c | 4 +
drivers/media/platform/qcom/iris/iris_hfi_common.c | 4 +
drivers/media/platform/qcom/iris/iris_hfi_queue.c | 16 +-
.../platform/qcom/iris/iris_platform_common.h | 19 ++
.../media/platform/qcom/iris/iris_platform_gen2.c | 90 +++++++
.../platform/qcom/iris/iris_platform_kaanapali.h | 86 +++++++
drivers/media/platform/qcom/iris/iris_probe.c | 64 ++++-
drivers/media/platform/qcom/iris/iris_resources.c | 96 ++++++++
drivers/media/platform/qcom/iris/iris_resources.h | 3 +
drivers/media/platform/qcom/iris/iris_vidc.c | 4 +-
drivers/media/platform/qcom/iris/iris_vpu2.c | 1 +
drivers/media/platform/qcom/iris/iris_vpu3x.c | 9 +-
drivers/media/platform/qcom/iris/iris_vpu4x.c | 24 +-
drivers/media/platform/qcom/iris/iris_vpu_buffer.c | 51 +++-
drivers/media/platform/qcom/iris/iris_vpu_bus.c | 32 +++
drivers/media/platform/qcom/iris/iris_vpu_common.c | 16 +-
drivers/media/platform/qcom/iris/iris_vpu_common.h | 3 +
include/dt-bindings/media/qcom,iris.h | 18 ++
include/linux/iris_vpu_bus.h | 13 +
24 files changed, 791 insertions(+), 40 deletions(-)
---
base-commit: 7d6661873f6b54c75195780a40d66bad3d482d8f
change-id: 20260126-kaanapali-iris-29fd184e2fe4
prerequisite-message-id: <20260226074245.3098486-1-vijayanand.jitta@oss.qualcomm.com>
prerequisite-patch-id: 421e3bb43ae0dbd6a1ba02acd02592d260456eb1
prerequisite-patch-id: f4b9b5e59b3d37407941f7fee05ca4996ad3d9ba
prerequisite-patch-id: 4556a2b44275b120be0faa86bde0b55593065476
Best regards,
--
Vikash Garodia <vikash.garodia@oss.qualcomm.com>
| null | null | null | [PATCH v2 0/7] media: iris: add support for kaanapali platform | On 27/02/2026 15:11, Vikash Garodia wrote:
I cannot really parse above.
You don't need definitions.
Drop description, pointless. How does it help anyhow in writing DTS?
This solves nothing from the discussions we had. I re-iterated multiple
times, plus there were internal threads doing the same, that you need to
define the items to have strict order.
I assume you checked and used last SoC order of all the entries here.
additionalprops, see writing schema for explanation.
...
Filename must match binding/compatible. I asked for this multiple times.
Abstract identifiers for ABI start with 0 or 1 and are incremented by 1,
not 0x100. There are also decimal, not hex.
Best regards,
Krzysztof | {
"author": "Krzysztof Kozlowski <krzk@kernel.org>",
"date": "Fri, 27 Feb 2026 16:50:30 +0100",
"is_openbsd": false,
"thread_id": "20257f68-04cf-40fa-9f0b-bd798e62b7eb@kernel.org.mbox.gz"
} |
lkml_critique | lkml | Fix checkpatch.pl warnings by adding comments to mutex and spinlocks,
and fixing alignment to match open parenthesis.
Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
drivers/staging/greybus/uart.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 7d060b4cd33d..1d2c4ef70865 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -50,12 +50,12 @@ struct gb_tty {
unsigned int minor;
unsigned char clocal;
bool disconnected;
- spinlock_t read_lock;
- spinlock_t write_lock;
+ spinlock_t read_lock; /* protects read operations */
+ spinlock_t write_lock; /* protects write operations */
struct async_icount iocount;
struct async_icount oldcount;
wait_queue_head_t wioctl;
- struct mutex mutex;
+ struct mutex mutex; /* serializes port operations */
u8 ctrlin; /* input control lines */
u8 ctrlout; /* output control lines */
struct gb_uart_set_line_coding_request line_coding;
@@ -318,7 +318,7 @@ static int gb_uart_wait_for_all_credits(struct gb_tty *gb_tty)
return 0;
ret = wait_for_completion_timeout(&gb_tty->credits_complete,
- msecs_to_jiffies(GB_UART_CREDIT_WAIT_TIMEOUT_MSEC));
+ msecs_to_jiffies(GB_UART_CREDIT_WAIT_TIMEOUT_MSEC));
if (!ret) {
dev_err(&gb_tty->gbphy_dev->dev,
"time out waiting for credits\n");
--
2.53.0
| null | null | null | [PATCH 1/2] staging: greybus: uart: fix style issues | Replace the deprecated IDR API with the more modern XArray API.
This simplifies the code and improves efficiency.
Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
drivers/staging/greybus/uart.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 1d2c4ef70865..fe554eba555a 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -67,7 +67,7 @@ struct gb_tty {
};
static struct tty_driver *gb_tty_driver;
-static DEFINE_IDR(tty_minors);
+static DEFINE_XARRAY(tty_minors);
static DEFINE_MUTEX(table_lock);
static int gb_uart_receive_data_handler(struct gb_operation *op)
@@ -342,7 +342,7 @@ static struct gb_tty *get_gb_by_minor(unsigned int minor)
struct gb_tty *gb_tty;
mutex_lock(&table_lock);
- gb_tty = idr_find(&tty_minors, minor);
+ gb_tty = xa_load(&tty_minors, minor);
if (gb_tty) {
mutex_lock(&gb_tty->mutex);
if (gb_tty->disconnected) {
@@ -359,14 +359,18 @@ static struct gb_tty *get_gb_by_minor(unsigned int minor)
static int alloc_minor(struct gb_tty *gb_tty)
{
- int minor;
+ u32 minor;
+ int ret;
mutex_lock(&table_lock);
- minor = idr_alloc(&tty_minors, gb_tty, 0, GB_NUM_MINORS, GFP_KERNEL);
+ ret = xa_alloc(&tty_minors, &minor, gb_tty,
+ XA_LIMIT(0, GB_NUM_MINORS - 1), GFP_KERNEL);
mutex_unlock(&table_lock);
- if (minor >= 0)
+ if (ret >= 0) {
gb_tty->minor = minor;
- return minor;
+ return minor;
+ }
+ return ret;
}
static void release_minor(struct gb_tty *gb_tty)
@@ -375,7 +379,7 @@ static void release_minor(struct gb_tty *gb_tty)
gb_tty->minor = 0; /* Maybe should use an invalid value instead */
mutex_lock(&table_lock);
- idr_remove(&tty_minors, minor);
+ xa_erase(&tty_minors, minor);
mutex_unlock(&table_lock);
}
@@ -984,7 +988,7 @@ static void gb_tty_exit(void)
{
tty_unregister_driver(gb_tty_driver);
tty_driver_kref_put(gb_tty_driver);
- idr_destroy(&tty_minors);
+ xa_destroy(&tty_minors);
}
static const struct gbphy_device_id gb_uart_id_table[] = {
--
2.53.0 | {
"author": "Shubham Chakraborty <chakrabortyshubham66@gmail.com>",
"date": "Thu, 26 Feb 2026 00:08:36 +0530",
"is_openbsd": false,
"thread_id": "20260227154839.7866-1-chakrabortyshubham66@gmail.com.mbox.gz"
} |
lkml_critique | lkml | Fix checkpatch.pl warnings by adding comments to mutex and spinlocks,
and fixing alignment to match open parenthesis.
Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
drivers/staging/greybus/uart.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 7d060b4cd33d..1d2c4ef70865 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -50,12 +50,12 @@ struct gb_tty {
unsigned int minor;
unsigned char clocal;
bool disconnected;
- spinlock_t read_lock;
- spinlock_t write_lock;
+ spinlock_t read_lock; /* protects read operations */
+ spinlock_t write_lock; /* protects write operations */
struct async_icount iocount;
struct async_icount oldcount;
wait_queue_head_t wioctl;
- struct mutex mutex;
+ struct mutex mutex; /* serializes port operations */
u8 ctrlin; /* input control lines */
u8 ctrlout; /* output control lines */
struct gb_uart_set_line_coding_request line_coding;
@@ -318,7 +318,7 @@ static int gb_uart_wait_for_all_credits(struct gb_tty *gb_tty)
return 0;
ret = wait_for_completion_timeout(&gb_tty->credits_complete,
- msecs_to_jiffies(GB_UART_CREDIT_WAIT_TIMEOUT_MSEC));
+ msecs_to_jiffies(GB_UART_CREDIT_WAIT_TIMEOUT_MSEC));
if (!ret) {
dev_err(&gb_tty->gbphy_dev->dev,
"time out waiting for credits\n");
--
2.53.0
| null | null | null | [PATCH 1/2] staging: greybus: uart: fix style issues | On Thu, Feb 26, 2026 at 12:08:35AM +0530, Shubham Chakraborty wrote:
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- Your patch did many different things all at once, making it difficult
to review. All Linux kernel patches need to only do one thing at a
time. If you need to do multiple things (such as clean up all coding
style issues in a file/driver), do it in a sequence of patches, each
one doing only one thing. This will make it easier to review the
patches to ensure that they are correct, and to help alleviate any
merge issues that larger patches can cause.
- You sent a patch that has been sent multiple times in the past few
days, and is identical to ones that has been recently rejected.
Please always look at the mailing list traffic to determine if you are
duplicating other people's work.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot | {
"author": "Greg Kroah-Hartman <gregkh@linuxfoundation.org>",
"date": "Wed, 25 Feb 2026 10:43:12 -0800",
"is_openbsd": false,
"thread_id": "20260227154839.7866-1-chakrabortyshubham66@gmail.com.mbox.gz"
} |
lkml_critique | lkml | Fix checkpatch.pl warnings by adding comments to mutex and spinlocks,
and fixing alignment to match open parenthesis.
Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
drivers/staging/greybus/uart.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 7d060b4cd33d..1d2c4ef70865 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -50,12 +50,12 @@ struct gb_tty {
unsigned int minor;
unsigned char clocal;
bool disconnected;
- spinlock_t read_lock;
- spinlock_t write_lock;
+ spinlock_t read_lock; /* protects read operations */
+ spinlock_t write_lock; /* protects write operations */
struct async_icount iocount;
struct async_icount oldcount;
wait_queue_head_t wioctl;
- struct mutex mutex;
+ struct mutex mutex; /* serializes port operations */
u8 ctrlin; /* input control lines */
u8 ctrlout; /* output control lines */
struct gb_uart_set_line_coding_request line_coding;
@@ -318,7 +318,7 @@ static int gb_uart_wait_for_all_credits(struct gb_tty *gb_tty)
return 0;
ret = wait_for_completion_timeout(&gb_tty->credits_complete,
- msecs_to_jiffies(GB_UART_CREDIT_WAIT_TIMEOUT_MSEC));
+ msecs_to_jiffies(GB_UART_CREDIT_WAIT_TIMEOUT_MSEC));
if (!ret) {
dev_err(&gb_tty->gbphy_dev->dev,
"time out waiting for credits\n");
--
2.53.0
| null | null | null | [PATCH 1/2] staging: greybus: uart: fix style issues | On Thu, Feb 26, 2026 at 12:08:36AM +0530, Shubham Chakraborty wrote:
This really isn't needed, sorry, it doesn't improve any "efficiency" and
I think I've rejected this change in the past as well.
It's just a simple minor number, an idr is just fine for it.
thanks,
greg k-h | {
"author": "Greg Kroah-Hartman <gregkh@linuxfoundation.org>",
"date": "Wed, 25 Feb 2026 10:47:42 -0800",
"is_openbsd": false,
"thread_id": "20260227154839.7866-1-chakrabortyshubham66@gmail.com.mbox.gz"
} |
lkml_critique | lkml | Fix checkpatch.pl warnings by adding comments to mutex and spinlocks,
and fixing alignment to match open parenthesis.
Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
drivers/staging/greybus/uart.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 7d060b4cd33d..1d2c4ef70865 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -50,12 +50,12 @@ struct gb_tty {
unsigned int minor;
unsigned char clocal;
bool disconnected;
- spinlock_t read_lock;
- spinlock_t write_lock;
+ spinlock_t read_lock; /* protects read operations */
+ spinlock_t write_lock; /* protects write operations */
struct async_icount iocount;
struct async_icount oldcount;
wait_queue_head_t wioctl;
- struct mutex mutex;
+ struct mutex mutex; /* serializes port operations */
u8 ctrlin; /* input control lines */
u8 ctrlout; /* output control lines */
struct gb_uart_set_line_coding_request line_coding;
@@ -318,7 +318,7 @@ static int gb_uart_wait_for_all_credits(struct gb_tty *gb_tty)
return 0;
ret = wait_for_completion_timeout(&gb_tty->credits_complete,
- msecs_to_jiffies(GB_UART_CREDIT_WAIT_TIMEOUT_MSEC));
+ msecs_to_jiffies(GB_UART_CREDIT_WAIT_TIMEOUT_MSEC));
if (!ret) {
dev_err(&gb_tty->gbphy_dev->dev,
"time out waiting for credits\n");
--
2.53.0
| null | null | null | [PATCH 1/2] staging: greybus: uart: fix style issues | On Thu, Feb 26, 2026 at 12:08:35AM +0530, Shubham Chakraborty wrote:
This is really vague, but I wouldn't say it was accurate.
Also really vague. What does "operations" mean in this context?
But word "write" is correct at least.
This comment is doesn't really add any value.
regards,
dan carpenter | {
"author": "Dan Carpenter <dan.carpenter@linaro.org>",
"date": "Thu, 26 Feb 2026 10:59:19 +0300",
"is_openbsd": false,
"thread_id": "20260227154839.7866-1-chakrabortyshubham66@gmail.com.mbox.gz"
} |
lkml_critique | lkml | Fix checkpatch.pl warnings by adding comments to mutex and spinlocks,
and fixing alignment to match open parenthesis.
Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
drivers/staging/greybus/uart.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 7d060b4cd33d..1d2c4ef70865 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -50,12 +50,12 @@ struct gb_tty {
unsigned int minor;
unsigned char clocal;
bool disconnected;
- spinlock_t read_lock;
- spinlock_t write_lock;
+ spinlock_t read_lock; /* protects read operations */
+ spinlock_t write_lock; /* protects write operations */
struct async_icount iocount;
struct async_icount oldcount;
wait_queue_head_t wioctl;
- struct mutex mutex;
+ struct mutex mutex; /* serializes port operations */
u8 ctrlin; /* input control lines */
u8 ctrlout; /* output control lines */
struct gb_uart_set_line_coding_request line_coding;
@@ -318,7 +318,7 @@ static int gb_uart_wait_for_all_credits(struct gb_tty *gb_tty)
return 0;
ret = wait_for_completion_timeout(&gb_tty->credits_complete,
- msecs_to_jiffies(GB_UART_CREDIT_WAIT_TIMEOUT_MSEC));
+ msecs_to_jiffies(GB_UART_CREDIT_WAIT_TIMEOUT_MSEC));
if (!ret) {
dev_err(&gb_tty->gbphy_dev->dev,
"time out waiting for credits\n");
--
2.53.0
| null | null | null | [PATCH 1/2] staging: greybus: uart: fix style issues | Hi Dan,
Thanks for the review.
You're right, the comments are too vague and don't add much value.
I'll review what the locks actually protect and resend with more
specific documentation, or drop the patch if it doesn't improve clarity.
Thanks,
Shubham | {
"author": "Shubham Chakraborty <chakrabortyshubham66@gmail.com>",
"date": "Thu, 26 Feb 2026 23:28:11 +0530",
"is_openbsd": false,
"thread_id": "20260227154839.7866-1-chakrabortyshubham66@gmail.com.mbox.gz"
} |
lkml_critique | lkml | Fix checkpatch.pl warnings by adding comments to mutex and spinlocks,
and fixing alignment to match open parenthesis.
Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
drivers/staging/greybus/uart.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 7d060b4cd33d..1d2c4ef70865 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -50,12 +50,12 @@ struct gb_tty {
unsigned int minor;
unsigned char clocal;
bool disconnected;
- spinlock_t read_lock;
- spinlock_t write_lock;
+ spinlock_t read_lock; /* protects read operations */
+ spinlock_t write_lock; /* protects write operations */
struct async_icount iocount;
struct async_icount oldcount;
wait_queue_head_t wioctl;
- struct mutex mutex;
+ struct mutex mutex; /* serializes port operations */
u8 ctrlin; /* input control lines */
u8 ctrlout; /* output control lines */
struct gb_uart_set_line_coding_request line_coding;
@@ -318,7 +318,7 @@ static int gb_uart_wait_for_all_credits(struct gb_tty *gb_tty)
return 0;
ret = wait_for_completion_timeout(&gb_tty->credits_complete,
- msecs_to_jiffies(GB_UART_CREDIT_WAIT_TIMEOUT_MSEC));
+ msecs_to_jiffies(GB_UART_CREDIT_WAIT_TIMEOUT_MSEC));
if (!ret) {
dev_err(&gb_tty->gbphy_dev->dev,
"time out waiting for credits\n");
--
2.53.0
| null | null | null | [PATCH 1/2] staging: greybus: uart: fix style issues | Replace vague lock comments with specific descriptions of
what data each lock protects:
- read_lock: protects iocount and oldcount
- write_lock: protects write_fifo and credits
- mutex: protects disconnected state
Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
drivers/staging/greybus/uart.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index fe554eba555a..1e51818e34a8 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -50,12 +50,12 @@ struct gb_tty {
unsigned int minor;
unsigned char clocal;
bool disconnected;
- spinlock_t read_lock; /* protects read operations */
- spinlock_t write_lock; /* protects write operations */
+ spinlock_t read_lock; /* protects iocount and oldcount */
+ spinlock_t write_lock; /* protects write_fifo and credits */
struct async_icount iocount;
struct async_icount oldcount;
wait_queue_head_t wioctl;
- struct mutex mutex; /* serializes port operations */
+ struct mutex mutex; /* protects disconnected state */
u8 ctrlin; /* input control lines */
u8 ctrlout; /* output control lines */
struct gb_uart_set_line_coding_request line_coding;
--
2.53.0 | {
"author": "Shubham Chakraborty <chakrabortyshubham66@gmail.com>",
"date": "Fri, 27 Feb 2026 12:22:20 +0530",
"is_openbsd": false,
"thread_id": "20260227154839.7866-1-chakrabortyshubham66@gmail.com.mbox.gz"
} |
lkml_critique | lkml | Fix checkpatch.pl warnings by adding comments to mutex and spinlocks,
and fixing alignment to match open parenthesis.
Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
drivers/staging/greybus/uart.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 7d060b4cd33d..1d2c4ef70865 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -50,12 +50,12 @@ struct gb_tty {
unsigned int minor;
unsigned char clocal;
bool disconnected;
- spinlock_t read_lock;
- spinlock_t write_lock;
+ spinlock_t read_lock; /* protects read operations */
+ spinlock_t write_lock; /* protects write operations */
struct async_icount iocount;
struct async_icount oldcount;
wait_queue_head_t wioctl;
- struct mutex mutex;
+ struct mutex mutex; /* serializes port operations */
u8 ctrlin; /* input control lines */
u8 ctrlout; /* output control lines */
struct gb_uart_set_line_coding_request line_coding;
@@ -318,7 +318,7 @@ static int gb_uart_wait_for_all_credits(struct gb_tty *gb_tty)
return 0;
ret = wait_for_completion_timeout(&gb_tty->credits_complete,
- msecs_to_jiffies(GB_UART_CREDIT_WAIT_TIMEOUT_MSEC));
+ msecs_to_jiffies(GB_UART_CREDIT_WAIT_TIMEOUT_MSEC));
if (!ret) {
dev_err(&gb_tty->gbphy_dev->dev,
"time out waiting for credits\n");
--
2.53.0
| null | null | null | [PATCH 1/2] staging: greybus: uart: fix style issues | On Fri, Feb 27, 2026 at 12:22:20PM +0530, Shubham Chakraborty wrote:
When you're writing a v2 patch, you should first start from a fresh
kernel tree. This v2 assumes that we applied the v1 patch.
https://staticthinking.wordpress.com/2022/07/27/how-to-send-a-v2-patch/
To be honest, I'm likely never going to be happy with a four word
explanation of what these locks do... Probably a paragraph would be
better.
Don't just think about it so narrowly... For example, does the name
read_lock make sense? What does the word "read" have anything to do
with "iocount and oldcount"?
Why do we need two separate locks for read and write? I understand
how write means write_fifo but why do "write_fifo and credits" go
together? If write_lock protects credits, then why are there several
places where we access gb_tty->credits without taking the lock?
Then as you go along, you're going to notice weird things. For
example, in set_serial_info() it allows non-admin uses to set the
close_delay and closing_wait to the existing values. What is the
point of that? Do other .set_serial() functions allow that? I
haven't looked, so maybe there is a good reason! But when you
look at this code with an open mind then you'll find all kinds of
questions like that.
What does protect really mean? What would happen if we removed
the locking? Is the locking even correct? If read_lock "protects
iocount" then why do we not take it in gb_tty_get_icount()?
The locking around disconnect probably is meant to prevent a use after
free. What are all the variables we allocate and how do we free them?
Does the disconnect process work? Go through the probe make a list
of allocations. When is the earliest we can call disconnect? What
if we set ->disconnected = true but we haven't called
gb_connection_disable_rx() so we're still receiving packets? I haven't
looked at it so I don't know!
regards,
dan carpenter | {
"author": "Dan Carpenter <dan.carpenter@linaro.org>",
"date": "Fri, 27 Feb 2026 12:03:02 +0300",
"is_openbsd": false,
"thread_id": "20260227154839.7866-1-chakrabortyshubham66@gmail.com.mbox.gz"
} |
lkml_critique | lkml | Fix checkpatch.pl warnings by adding comments to mutex and spinlocks,
and fixing alignment to match open parenthesis.
Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
drivers/staging/greybus/uart.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
index 7d060b4cd33d..1d2c4ef70865 100644
--- a/drivers/staging/greybus/uart.c
+++ b/drivers/staging/greybus/uart.c
@@ -50,12 +50,12 @@ struct gb_tty {
unsigned int minor;
unsigned char clocal;
bool disconnected;
- spinlock_t read_lock;
- spinlock_t write_lock;
+ spinlock_t read_lock; /* protects read operations */
+ spinlock_t write_lock; /* protects write operations */
struct async_icount iocount;
struct async_icount oldcount;
wait_queue_head_t wioctl;
- struct mutex mutex;
+ struct mutex mutex; /* serializes port operations */
u8 ctrlin; /* input control lines */
u8 ctrlout; /* output control lines */
struct gb_uart_set_line_coding_request line_coding;
@@ -318,7 +318,7 @@ static int gb_uart_wait_for_all_credits(struct gb_tty *gb_tty)
return 0;
ret = wait_for_completion_timeout(&gb_tty->credits_complete,
- msecs_to_jiffies(GB_UART_CREDIT_WAIT_TIMEOUT_MSEC));
+ msecs_to_jiffies(GB_UART_CREDIT_WAIT_TIMEOUT_MSEC));
if (!ret) {
dev_err(&gb_tty->gbphy_dev->dev,
"time out waiting for credits\n");
--
2.53.0
| null | null | null | [PATCH 1/2] staging: greybus: uart: fix style issues | Thanks for the detailed feedback. I'll do a proper audit of the
locking and the disconnect sequence before sending v3 from a fresh tree.
Regards,
Shubham Chakraborty | {
"author": "Shubham Chakraborty <chakrabortyshubham66@gmail.com>",
"date": "Fri, 27 Feb 2026 21:18:39 +0530",
"is_openbsd": false,
"thread_id": "20260227154839.7866-1-chakrabortyshubham66@gmail.com.mbox.gz"
} |
lkml_critique | lkml | This series fixes doorbell bit/vector handling for the EPF-based NTB
pair (ntb_hw_epf <-> pci-epf-*ntb). Its primary goal is to enable safe
per-db-vector handling in the NTB core and clients (e.g. ntb_transport),
without changing the on-the-wire doorbell mapping.
Background / problem
====================
ntb_hw_epf historically applies an extra offset when ringing peer
doorbells: the link event uses the first interrupt slot, and doorbells
start from the third slot (i.e. a second slot is effectively unused).
pci-epf-vntb carries the matching offset on the EP side as well.
As long as db_vector_count()/db_vector_mask() are not implemented, this
mismatch is mostly masked. Doorbell events are effectively treated as
"can hit any QP" and the off-by-one vector numbering does not surface
clearly.
However, once per-vector handling is enabled, the current state becomes
problematic:
- db_valid_mask exposes bits that do not correspond to real doorbells
(link/unused slots leak into the mask).
- ntb_db_event() is fed with 1-based/shifted vectors, while NTB core
expects a 0-based db_vector for doorbells.
- On pci-epf-vntb, .peer_db_set() may be called in atomic context, but
it directly calls pci_epc_raise_irq(), which can sleep.
Why NOT fix the root offset?
============================
The natural "root" fix would be to remove the historical extra offset in
the peer_db_set() doorbell paths for ntb_hw_epf and pci-epf-vntb.
Unfortunately this would lead to interoperability issues when mixing old
and new kernel versions (old/new peers). A new side would ring a
different interrupt slot than what an old peer expects, leading to
missed or misrouted doorbells, once db_vector_count()/db_vector_mask()
are implemented.
Therefore this series intentionally keeps the legacy offset, and instead
fixes the surrounding pieces so the mapping is documented and handled
consistently in masks, vector numbering, and per-vector reporting.
What this series does
=====================
- pci-epf-vntb:
- Document the legacy offset.
- Defer MSI doorbell raises to process context to avoid sleeping in
atomic context. This becomes relevant once multiple doorbells are
raised concurrently at a high rate.
- Report doorbell vectors as 0-based to ntb_db_event().
- Fix db_valid_mask and implement db_vector_count()/db_vector_mask().
- ntb_hw_epf:
- Document the legacy offset in ntb_epf_peer_db_set().
- Fix db_valid_mask to cover only real doorbell bits.
- Report 0-based db_vector to ntb_db_event() (accounting for the
unused slot).
- Keep db_val as a bitmask and fix db_read/db_clear semantics
accordingly.
- Implement db_vector_count()/db_vector_mask().
Compatibility
=============
By keeping the legacy offset intact, this series aims to remain
compatible across mixed kernel versions. The observable changes are
limited to correct mask/vector reporting and safer execution context
handling.
Patches 1-5 (PCI Endpoint) and 6-10 (NTB) are independent and can be
applied separately for each tree. I am sending them together in this
series to provide the full context and to make the cross-subsystem
compatibility constraints explicit. Ideally the whole series would be
applied in a single tree, but each subset is safe to merge on its own.
- Patch 1-5 can apply cleanly onto pci/endpoint latest:
f6797680fe31 ("PCI: epf-mhi: Return 0 on success instead of positive
jiffies from pci_epf_mhi_edma_{read/write}")
- Patch 6-10 can apply cleanly onto ntb-next latest:
7b3302c687ca ("ntb_hw_amd: Fix incorrect debug message in link disable
path")
Note: I don't have a suitable hardware to test ntb_hw_epf + pci-epf-ntb
(not vNTB) bridge scenario, but I believe no changes are needed in
pci-epf-ntb.c.
Changelog
=========
Changes since v1:
- Addressed feedback from Dave (add a source code comment, introduce
enum to eliminate magic numbers)
- Updated source code comment in Patch 2.
- No functional changes, so retained Reviewed-by tags by Frank and Dave.
Thank you both for the review.
Best regards,
Koichiro Den (10):
PCI: endpoint: pci-epf-vntb: Document legacy MSI doorbell offset
PCI: endpoint: pci-epf-vntb: Defer pci_epc_raise_irq() out of atomic
context
PCI: endpoint: pci-epf-vntb: Report 0-based doorbell vector via
ntb_db_event()
PCI: endpoint: pci-epf-vntb: Exclude reserved slots from db_valid_mask
PCI: endpoint: pci-epf-vntb: Implement db_vector_count/mask for
doorbells
NTB: epf: Document legacy doorbell slot offset in
ntb_epf_peer_db_set()
NTB: epf: Make db_valid_mask cover only real doorbell bits
NTB: epf: Report 0-based doorbell vector via ntb_db_event()
NTB: epf: Fix doorbell bitmask handling in db_read/db_clear
NTB: epf: Implement db_vector_count/mask for doorbells
drivers/ntb/hw/epf/ntb_hw_epf.c | 89 ++++++++++-
drivers/pci/endpoint/functions/pci-epf-vntb.c | 147 +++++++++++++++---
2 files changed, 210 insertions(+), 26 deletions(-)
--
2.51.0
| null | null | null | [PATCH v2 00/10] PCI: endpoint: pci-epf-vntb: Document legacy MSI doorbell offset | vntb_epf_peer_db_set() raises an MSI interrupt to notify the RC side of
a doorbell event. pci_epc_raise_irq(..., PCI_IRQ_MSI, interrupt_num)
takes a 1-based MSI interrupt number.
The ntb_hw_epf driver reserves MSI #1 for link events, so doorbells
would naturally start at MSI #2 (doorbell bit 0 -> MSI #2). However,
pci-epf-vntb has historically applied an extra offset and maps doorbell
bit 0 to MSI #3. This matches the legacy behavior of ntb_hw_epf and has
been preserved since commit e35f56bb0330 ("PCI: endpoint: Support NTB
transfer between RC and EP").
This offset has not surfaced as a functional issue because:
- ntb_hw_epf typically allocates enough MSI vectors, so the off-by-one
still hits a valid MSI vector, and
- ntb_hw_epf does not implement .db_vector_count()/.db_vector_mask(), so
client drivers such as ntb_transport effectively ignore the vector
number and schedule all QPs.
Correcting the MSI number would break interoperability with peers
running older kernels.
Document the legacy offset to avoid confusion when enabling
per-db-vector handling.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Koichiro Den <den@valinux.co.jp>
---
drivers/pci/endpoint/functions/pci-epf-vntb.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
index 148a3b160812..83372aba5106 100644
--- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
+++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
@@ -1379,6 +1379,25 @@ static int vntb_epf_peer_db_set(struct ntb_dev *ndev, u64 db_bits)
func_no = ntb->epf->func_no;
vfunc_no = ntb->epf->vfunc_no;
+ /*
+ * pci_epc_raise_irq() for MSI expects a 1-based interrupt number.
+ * ffs() returns a 1-based index (bit 0 -> 1). interrupt_num has already
+ * been computed as ffs(db_bits) + 1 above. Adding one more +1 when
+ * calling pci_epc_raise_irq() therefore results in:
+ *
+ * doorbell bit 0 -> MSI #3
+ *
+ * Legacy mapping (kept for compatibility):
+ *
+ * MSI #1 : link event (reserved)
+ * MSI #2 : unused (historical offset)
+ * MSI #3 : doorbell bit 0 (DB#0)
+ * MSI #4 : doorbell bit 1 (DB#1)
+ * ...
+ *
+ * Do not change this mapping to avoid breaking interoperability with
+ * older peers.
+ */
ret = pci_epc_raise_irq(ntb->epf->epc, func_no, vfunc_no,
PCI_IRQ_MSI, interrupt_num + 1);
if (ret)
--
2.51.0 | {
"author": "Koichiro Den <den@valinux.co.jp>",
"date": "Fri, 27 Feb 2026 17:49:46 +0900",
"is_openbsd": false,
"thread_id": "aaG9COYXPJamIvTx@lizhi-Precision-Tower-5810.mbox.gz"
} |
lkml_critique | lkml | This series fixes doorbell bit/vector handling for the EPF-based NTB
pair (ntb_hw_epf <-> pci-epf-*ntb). Its primary goal is to enable safe
per-db-vector handling in the NTB core and clients (e.g. ntb_transport),
without changing the on-the-wire doorbell mapping.
Background / problem
====================
ntb_hw_epf historically applies an extra offset when ringing peer
doorbells: the link event uses the first interrupt slot, and doorbells
start from the third slot (i.e. a second slot is effectively unused).
pci-epf-vntb carries the matching offset on the EP side as well.
As long as db_vector_count()/db_vector_mask() are not implemented, this
mismatch is mostly masked. Doorbell events are effectively treated as
"can hit any QP" and the off-by-one vector numbering does not surface
clearly.
However, once per-vector handling is enabled, the current state becomes
problematic:
- db_valid_mask exposes bits that do not correspond to real doorbells
(link/unused slots leak into the mask).
- ntb_db_event() is fed with 1-based/shifted vectors, while NTB core
expects a 0-based db_vector for doorbells.
- On pci-epf-vntb, .peer_db_set() may be called in atomic context, but
it directly calls pci_epc_raise_irq(), which can sleep.
Why NOT fix the root offset?
============================
The natural "root" fix would be to remove the historical extra offset in
the peer_db_set() doorbell paths for ntb_hw_epf and pci-epf-vntb.
Unfortunately this would lead to interoperability issues when mixing old
and new kernel versions (old/new peers). A new side would ring a
different interrupt slot than what an old peer expects, leading to
missed or misrouted doorbells, once db_vector_count()/db_vector_mask()
are implemented.
Therefore this series intentionally keeps the legacy offset, and instead
fixes the surrounding pieces so the mapping is documented and handled
consistently in masks, vector numbering, and per-vector reporting.
What this series does
=====================
- pci-epf-vntb:
- Document the legacy offset.
- Defer MSI doorbell raises to process context to avoid sleeping in
atomic context. This becomes relevant once multiple doorbells are
raised concurrently at a high rate.
- Report doorbell vectors as 0-based to ntb_db_event().
- Fix db_valid_mask and implement db_vector_count()/db_vector_mask().
- ntb_hw_epf:
- Document the legacy offset in ntb_epf_peer_db_set().
- Fix db_valid_mask to cover only real doorbell bits.
- Report 0-based db_vector to ntb_db_event() (accounting for the
unused slot).
- Keep db_val as a bitmask and fix db_read/db_clear semantics
accordingly.
- Implement db_vector_count()/db_vector_mask().
Compatibility
=============
By keeping the legacy offset intact, this series aims to remain
compatible across mixed kernel versions. The observable changes are
limited to correct mask/vector reporting and safer execution context
handling.
Patches 1-5 (PCI Endpoint) and 6-10 (NTB) are independent and can be
applied separately for each tree. I am sending them together in this
series to provide the full context and to make the cross-subsystem
compatibility constraints explicit. Ideally the whole series would be
applied in a single tree, but each subset is safe to merge on its own.
- Patch 1-5 can apply cleanly onto pci/endpoint latest:
f6797680fe31 ("PCI: epf-mhi: Return 0 on success instead of positive
jiffies from pci_epf_mhi_edma_{read/write}")
- Patch 6-10 can apply cleanly onto ntb-next latest:
7b3302c687ca ("ntb_hw_amd: Fix incorrect debug message in link disable
path")
Note: I don't have a suitable hardware to test ntb_hw_epf + pci-epf-ntb
(not vNTB) bridge scenario, but I believe no changes are needed in
pci-epf-ntb.c.
Changelog
=========
Changes since v1:
- Addressed feedback from Dave (add a source code comment, introduce
enum to eliminate magic numbers)
- Updated source code comment in Patch 2.
- No functional changes, so retained Reviewed-by tags by Frank and Dave.
Thank you both for the review.
Best regards,
Koichiro Den (10):
PCI: endpoint: pci-epf-vntb: Document legacy MSI doorbell offset
PCI: endpoint: pci-epf-vntb: Defer pci_epc_raise_irq() out of atomic
context
PCI: endpoint: pci-epf-vntb: Report 0-based doorbell vector via
ntb_db_event()
PCI: endpoint: pci-epf-vntb: Exclude reserved slots from db_valid_mask
PCI: endpoint: pci-epf-vntb: Implement db_vector_count/mask for
doorbells
NTB: epf: Document legacy doorbell slot offset in
ntb_epf_peer_db_set()
NTB: epf: Make db_valid_mask cover only real doorbell bits
NTB: epf: Report 0-based doorbell vector via ntb_db_event()
NTB: epf: Fix doorbell bitmask handling in db_read/db_clear
NTB: epf: Implement db_vector_count/mask for doorbells
drivers/ntb/hw/epf/ntb_hw_epf.c | 89 ++++++++++-
drivers/pci/endpoint/functions/pci-epf-vntb.c | 147 +++++++++++++++---
2 files changed, 210 insertions(+), 26 deletions(-)
--
2.51.0
| null | null | null | [PATCH v2 00/10] PCI: endpoint: pci-epf-vntb: Document legacy MSI doorbell offset | ndev->db_count includes an unused doorbell slot due to the legacy extra
offset in the peer doorbell path. db_valid_mask must cover only the real
doorbell bits and exclude the unused slot.
Set db_valid_mask to BIT_ULL(db_count - 1) - 1.
Fixes: 812ce2f8d14e ("NTB: Add support for EPF PCI Non-Transparent Bridge")
Signed-off-by: Koichiro Den <den@valinux.co.jp>
---
Changes since v1:
- No functional changes.
- Addressed review comments (documentation).
drivers/ntb/hw/epf/ntb_hw_epf.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/ntb/hw/epf/ntb_hw_epf.c b/drivers/ntb/hw/epf/ntb_hw_epf.c
index bce7130fec39..07dc97d3270b 100644
--- a/drivers/ntb/hw/epf/ntb_hw_epf.c
+++ b/drivers/ntb/hw/epf/ntb_hw_epf.c
@@ -580,7 +580,17 @@ static int ntb_epf_init_dev(struct ntb_epf_dev *ndev)
return ret;
}
- ndev->db_valid_mask = BIT_ULL(ndev->db_count) - 1;
+ if (ndev->db_count < NTB_EPF_MIN_DB_COUNT) {
+ dev_err(dev, "db_count %u is less than %u\n", ndev->db_count,
+ NTB_EPF_MIN_DB_COUNT);
+ return -EINVAL;
+ }
+
+ /*
+ * ndev->db_count includes an extra skipped slot due to the legacy
+ * doorbell layout, hence -1.
+ */
+ ndev->db_valid_mask = BIT_ULL(ndev->db_count - 1) - 1;
ndev->mw_count = readl(ndev->ctrl_reg + NTB_EPF_MW_COUNT);
ndev->spad_count = readl(ndev->ctrl_reg + NTB_EPF_SPAD_COUNT);
--
2.51.0 | {
"author": "Koichiro Den <den@valinux.co.jp>",
"date": "Fri, 27 Feb 2026 17:49:52 +0900",
"is_openbsd": false,
"thread_id": "aaG9COYXPJamIvTx@lizhi-Precision-Tower-5810.mbox.gz"
} |
lkml_critique | lkml | This series fixes doorbell bit/vector handling for the EPF-based NTB
pair (ntb_hw_epf <-> pci-epf-*ntb). Its primary goal is to enable safe
per-db-vector handling in the NTB core and clients (e.g. ntb_transport),
without changing the on-the-wire doorbell mapping.
Background / problem
====================
ntb_hw_epf historically applies an extra offset when ringing peer
doorbells: the link event uses the first interrupt slot, and doorbells
start from the third slot (i.e. a second slot is effectively unused).
pci-epf-vntb carries the matching offset on the EP side as well.
As long as db_vector_count()/db_vector_mask() are not implemented, this
mismatch is mostly masked. Doorbell events are effectively treated as
"can hit any QP" and the off-by-one vector numbering does not surface
clearly.
However, once per-vector handling is enabled, the current state becomes
problematic:
- db_valid_mask exposes bits that do not correspond to real doorbells
(link/unused slots leak into the mask).
- ntb_db_event() is fed with 1-based/shifted vectors, while NTB core
expects a 0-based db_vector for doorbells.
- On pci-epf-vntb, .peer_db_set() may be called in atomic context, but
it directly calls pci_epc_raise_irq(), which can sleep.
Why NOT fix the root offset?
============================
The natural "root" fix would be to remove the historical extra offset in
the peer_db_set() doorbell paths for ntb_hw_epf and pci-epf-vntb.
Unfortunately this would lead to interoperability issues when mixing old
and new kernel versions (old/new peers). A new side would ring a
different interrupt slot than what an old peer expects, leading to
missed or misrouted doorbells, once db_vector_count()/db_vector_mask()
are implemented.
Therefore this series intentionally keeps the legacy offset, and instead
fixes the surrounding pieces so the mapping is documented and handled
consistently in masks, vector numbering, and per-vector reporting.
What this series does
=====================
- pci-epf-vntb:
- Document the legacy offset.
- Defer MSI doorbell raises to process context to avoid sleeping in
atomic context. This becomes relevant once multiple doorbells are
raised concurrently at a high rate.
- Report doorbell vectors as 0-based to ntb_db_event().
- Fix db_valid_mask and implement db_vector_count()/db_vector_mask().
- ntb_hw_epf:
- Document the legacy offset in ntb_epf_peer_db_set().
- Fix db_valid_mask to cover only real doorbell bits.
- Report 0-based db_vector to ntb_db_event() (accounting for the
unused slot).
- Keep db_val as a bitmask and fix db_read/db_clear semantics
accordingly.
- Implement db_vector_count()/db_vector_mask().
Compatibility
=============
By keeping the legacy offset intact, this series aims to remain
compatible across mixed kernel versions. The observable changes are
limited to correct mask/vector reporting and safer execution context
handling.
Patches 1-5 (PCI Endpoint) and 6-10 (NTB) are independent and can be
applied separately for each tree. I am sending them together in this
series to provide the full context and to make the cross-subsystem
compatibility constraints explicit. Ideally the whole series would be
applied in a single tree, but each subset is safe to merge on its own.
- Patch 1-5 can apply cleanly onto pci/endpoint latest:
f6797680fe31 ("PCI: epf-mhi: Return 0 on success instead of positive
jiffies from pci_epf_mhi_edma_{read/write}")
- Patch 6-10 can apply cleanly onto ntb-next latest:
7b3302c687ca ("ntb_hw_amd: Fix incorrect debug message in link disable
path")
Note: I don't have a suitable hardware to test ntb_hw_epf + pci-epf-ntb
(not vNTB) bridge scenario, but I believe no changes are needed in
pci-epf-ntb.c.
Changelog
=========
Changes since v1:
- Addressed feedback from Dave (add a source code comment, introduce
enum to eliminate magic numbers)
- Updated source code comment in Patch 2.
- No functional changes, so retained Reviewed-by tags by Frank and Dave.
Thank you both for the review.
Best regards,
Koichiro Den (10):
PCI: endpoint: pci-epf-vntb: Document legacy MSI doorbell offset
PCI: endpoint: pci-epf-vntb: Defer pci_epc_raise_irq() out of atomic
context
PCI: endpoint: pci-epf-vntb: Report 0-based doorbell vector via
ntb_db_event()
PCI: endpoint: pci-epf-vntb: Exclude reserved slots from db_valid_mask
PCI: endpoint: pci-epf-vntb: Implement db_vector_count/mask for
doorbells
NTB: epf: Document legacy doorbell slot offset in
ntb_epf_peer_db_set()
NTB: epf: Make db_valid_mask cover only real doorbell bits
NTB: epf: Report 0-based doorbell vector via ntb_db_event()
NTB: epf: Fix doorbell bitmask handling in db_read/db_clear
NTB: epf: Implement db_vector_count/mask for doorbells
drivers/ntb/hw/epf/ntb_hw_epf.c | 89 ++++++++++-
drivers/pci/endpoint/functions/pci-epf-vntb.c | 147 +++++++++++++++---
2 files changed, 210 insertions(+), 26 deletions(-)
--
2.51.0
| null | null | null | [PATCH v2 00/10] PCI: endpoint: pci-epf-vntb: Document legacy MSI doorbell offset | The NTB .peer_db_set() callback may be invoked from atomic context.
pci-epf-vntb currently calls pci_epc_raise_irq() directly, but
pci_epc_raise_irq() may sleep (it takes epc->lock).
Avoid sleeping in atomic context by coalescing doorbell bits into an
atomic64 pending mask and raising MSIs from a work item. Limit the
amount of work per run to avoid monopolizing the workqueue under a
doorbell storm.
Fixes: e35f56bb0330 ("PCI: endpoint: Support NTB transfer between RC and EP")
Signed-off-by: Koichiro Den <den@valinux.co.jp>
---
Changes since v1:
- No functional changes.
- Updated comment in vntb_epf_peer_db_work().
drivers/pci/endpoint/functions/pci-epf-vntb.c | 106 +++++++++++++-----
1 file changed, 78 insertions(+), 28 deletions(-)
diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
index 83372aba5106..e2c0b6dba793 100644
--- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
+++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
@@ -69,6 +69,9 @@ static struct workqueue_struct *kpcintb_workqueue;
#define MAX_DB_COUNT 32
#define MAX_MW 4
+/* Limit per-work execution to avoid monopolizing kworker on doorbell storms. */
+#define VNTB_PEER_DB_WORK_BUDGET 5
+
enum epf_ntb_bar {
BAR_CONFIG,
BAR_DB,
@@ -129,6 +132,8 @@ struct epf_ntb {
u32 spad_count;
u64 mws_size[MAX_MW];
atomic64_t db;
+ atomic64_t peer_db_pending;
+ struct work_struct peer_db_work;
u32 vbus_number;
u16 vntb_pid;
u16 vntb_vid;
@@ -933,6 +938,8 @@ static int epf_ntb_epc_init(struct epf_ntb *ntb)
INIT_DELAYED_WORK(&ntb->cmd_handler, epf_ntb_cmd_handler);
queue_work(kpcintb_workqueue, &ntb->cmd_handler.work);
+ enable_work(&ntb->peer_db_work);
+
return 0;
err_write_header:
@@ -955,6 +962,7 @@ static int epf_ntb_epc_init(struct epf_ntb *ntb)
*/
static void epf_ntb_epc_cleanup(struct epf_ntb *ntb)
{
+ disable_work_sync(&ntb->peer_db_work);
epf_ntb_mw_bar_clear(ntb, ntb->num_mws);
epf_ntb_db_bar_clear(ntb);
epf_ntb_config_sspad_bar_clear(ntb);
@@ -1369,41 +1377,79 @@ static int vntb_epf_peer_spad_write(struct ntb_dev *ndev, int pidx, int idx, u32
return 0;
}
+static void vntb_epf_peer_db_work(struct work_struct *work)
+{
+ struct epf_ntb *ntb = container_of(work, struct epf_ntb, peer_db_work);
+ struct pci_epf *epf = ntb->epf;
+ unsigned int budget = VNTB_PEER_DB_WORK_BUDGET;
+ u8 func_no, vfunc_no;
+ u32 interrupt_num;
+ u64 db_bits;
+ int ret;
+
+ if (!epf || !epf->epc)
+ return;
+
+ func_no = epf->func_no;
+ vfunc_no = epf->vfunc_no;
+
+ /*
+ * Drain doorbells from peer_db_pending in snapshots (atomic64_xchg()).
+ * Limit the number of snapshots handled per run so we don't monopolize
+ * the workqueue under a doorbell storm.
+ */
+ while (budget--) {
+ db_bits = atomic64_xchg(&ntb->peer_db_pending, 0);
+ if (!db_bits)
+ return;
+
+ while (db_bits) {
+ /*
+ * pci_epc_raise_irq() for MSI expects a 1-based
+ * interrupt number. ffs() returns a 1-based index (bit
+ * 0 -> 1). We historically add +2 to compute
+ * interrupt_num.
+ *
+ * Legacy mapping (kept for compatibility):
+ *
+ * MSI #1 : link event (reserved)
+ * MSI #2 : unused (historical offset)
+ * MSI #3 : doorbell bit 0 (DB#0)
+ * MSI #4 : doorbell bit 1 (DB#1)
+ * ...
+ *
+ * Do not change this mapping to avoid breaking
+ * interoperability with older peers.
+ */
+ interrupt_num = ffs(db_bits) + 2;
+ db_bits &= db_bits - 1;
+
+ ret = pci_epc_raise_irq(epf->epc, func_no, vfunc_no,
+ PCI_IRQ_MSI, interrupt_num);
+ if (ret)
+ dev_err(&ntb->ntb.dev,
+ "Failed to raise IRQ for interrupt_num %u: %d\n",
+ interrupt_num, ret);
+ }
+ }
+
+ if (atomic64_read(&ntb->peer_db_pending))
+ queue_work(kpcintb_workqueue, &ntb->peer_db_work);
+}
+
static int vntb_epf_peer_db_set(struct ntb_dev *ndev, u64 db_bits)
{
- u32 interrupt_num = ffs(db_bits) + 1;
struct epf_ntb *ntb = ntb_ndev(ndev);
- u8 func_no, vfunc_no;
- int ret;
-
- func_no = ntb->epf->func_no;
- vfunc_no = ntb->epf->vfunc_no;
/*
- * pci_epc_raise_irq() for MSI expects a 1-based interrupt number.
- * ffs() returns a 1-based index (bit 0 -> 1). interrupt_num has already
- * been computed as ffs(db_bits) + 1 above. Adding one more +1 when
- * calling pci_epc_raise_irq() therefore results in:
- *
- * doorbell bit 0 -> MSI #3
- *
- * Legacy mapping (kept for compatibility):
- *
- * MSI #1 : link event (reserved)
- * MSI #2 : unused (historical offset)
- * MSI #3 : doorbell bit 0 (DB#0)
- * MSI #4 : doorbell bit 1 (DB#1)
- * ...
- *
- * Do not change this mapping to avoid breaking interoperability with
- * older peers.
+ * .peer_db_set() may be called from atomic context. pci_epc_raise_irq()
+ * can sleep (it takes epc->lock), so defer MSI raising to process
+ * context. Doorbell requests are coalesced in peer_db_pending.
*/
- ret = pci_epc_raise_irq(ntb->epf->epc, func_no, vfunc_no,
- PCI_IRQ_MSI, interrupt_num + 1);
- if (ret)
- dev_err(&ntb->ntb.dev, "Failed to raise IRQ\n");
+ atomic64_or(db_bits, &ntb->peer_db_pending);
+ queue_work(kpcintb_workqueue, &ntb->peer_db_work);
- return ret;
+ return 0;
}
static u64 vntb_epf_db_read(struct ntb_dev *ndev)
@@ -1645,6 +1691,10 @@ static int epf_ntb_probe(struct pci_epf *epf,
ntb->epf = epf;
ntb->vbus_number = 0xff;
+ INIT_WORK(&ntb->peer_db_work, vntb_epf_peer_db_work);
+ disable_work(&ntb->peer_db_work);
+ atomic64_set(&ntb->peer_db_pending, 0);
+
/* Initially, no bar is assigned */
for (i = 0; i < VNTB_BAR_NUM; i++)
ntb->epf_ntb_bar[i] = NO_BAR;
--
2.51.0 | {
"author": "Koichiro Den <den@valinux.co.jp>",
"date": "Fri, 27 Feb 2026 17:49:47 +0900",
"is_openbsd": false,
"thread_id": "aaG9COYXPJamIvTx@lizhi-Precision-Tower-5810.mbox.gz"
} |
lkml_critique | lkml | This series fixes doorbell bit/vector handling for the EPF-based NTB
pair (ntb_hw_epf <-> pci-epf-*ntb). Its primary goal is to enable safe
per-db-vector handling in the NTB core and clients (e.g. ntb_transport),
without changing the on-the-wire doorbell mapping.
Background / problem
====================
ntb_hw_epf historically applies an extra offset when ringing peer
doorbells: the link event uses the first interrupt slot, and doorbells
start from the third slot (i.e. a second slot is effectively unused).
pci-epf-vntb carries the matching offset on the EP side as well.
As long as db_vector_count()/db_vector_mask() are not implemented, this
mismatch is mostly masked. Doorbell events are effectively treated as
"can hit any QP" and the off-by-one vector numbering does not surface
clearly.
However, once per-vector handling is enabled, the current state becomes
problematic:
- db_valid_mask exposes bits that do not correspond to real doorbells
(link/unused slots leak into the mask).
- ntb_db_event() is fed with 1-based/shifted vectors, while NTB core
expects a 0-based db_vector for doorbells.
- On pci-epf-vntb, .peer_db_set() may be called in atomic context, but
it directly calls pci_epc_raise_irq(), which can sleep.
Why NOT fix the root offset?
============================
The natural "root" fix would be to remove the historical extra offset in
the peer_db_set() doorbell paths for ntb_hw_epf and pci-epf-vntb.
Unfortunately this would lead to interoperability issues when mixing old
and new kernel versions (old/new peers). A new side would ring a
different interrupt slot than what an old peer expects, leading to
missed or misrouted doorbells, once db_vector_count()/db_vector_mask()
are implemented.
Therefore this series intentionally keeps the legacy offset, and instead
fixes the surrounding pieces so the mapping is documented and handled
consistently in masks, vector numbering, and per-vector reporting.
What this series does
=====================
- pci-epf-vntb:
- Document the legacy offset.
- Defer MSI doorbell raises to process context to avoid sleeping in
atomic context. This becomes relevant once multiple doorbells are
raised concurrently at a high rate.
- Report doorbell vectors as 0-based to ntb_db_event().
- Fix db_valid_mask and implement db_vector_count()/db_vector_mask().
- ntb_hw_epf:
- Document the legacy offset in ntb_epf_peer_db_set().
- Fix db_valid_mask to cover only real doorbell bits.
- Report 0-based db_vector to ntb_db_event() (accounting for the
unused slot).
- Keep db_val as a bitmask and fix db_read/db_clear semantics
accordingly.
- Implement db_vector_count()/db_vector_mask().
Compatibility
=============
By keeping the legacy offset intact, this series aims to remain
compatible across mixed kernel versions. The observable changes are
limited to correct mask/vector reporting and safer execution context
handling.
Patches 1-5 (PCI Endpoint) and 6-10 (NTB) are independent and can be
applied separately for each tree. I am sending them together in this
series to provide the full context and to make the cross-subsystem
compatibility constraints explicit. Ideally the whole series would be
applied in a single tree, but each subset is safe to merge on its own.
- Patch 1-5 can apply cleanly onto pci/endpoint latest:
f6797680fe31 ("PCI: epf-mhi: Return 0 on success instead of positive
jiffies from pci_epf_mhi_edma_{read/write}")
- Patch 6-10 can apply cleanly onto ntb-next latest:
7b3302c687ca ("ntb_hw_amd: Fix incorrect debug message in link disable
path")
Note: I don't have a suitable hardware to test ntb_hw_epf + pci-epf-ntb
(not vNTB) bridge scenario, but I believe no changes are needed in
pci-epf-ntb.c.
Changelog
=========
Changes since v1:
- Addressed feedback from Dave (add a source code comment, introduce
enum to eliminate magic numbers)
- Updated source code comment in Patch 2.
- No functional changes, so retained Reviewed-by tags by Frank and Dave.
Thank you both for the review.
Best regards,
Koichiro Den (10):
PCI: endpoint: pci-epf-vntb: Document legacy MSI doorbell offset
PCI: endpoint: pci-epf-vntb: Defer pci_epc_raise_irq() out of atomic
context
PCI: endpoint: pci-epf-vntb: Report 0-based doorbell vector via
ntb_db_event()
PCI: endpoint: pci-epf-vntb: Exclude reserved slots from db_valid_mask
PCI: endpoint: pci-epf-vntb: Implement db_vector_count/mask for
doorbells
NTB: epf: Document legacy doorbell slot offset in
ntb_epf_peer_db_set()
NTB: epf: Make db_valid_mask cover only real doorbell bits
NTB: epf: Report 0-based doorbell vector via ntb_db_event()
NTB: epf: Fix doorbell bitmask handling in db_read/db_clear
NTB: epf: Implement db_vector_count/mask for doorbells
drivers/ntb/hw/epf/ntb_hw_epf.c | 89 ++++++++++-
drivers/pci/endpoint/functions/pci-epf-vntb.c | 147 +++++++++++++++---
2 files changed, 210 insertions(+), 26 deletions(-)
--
2.51.0
| null | null | null | [PATCH v2 00/10] PCI: endpoint: pci-epf-vntb: Document legacy MSI doorbell offset | ntb_epf_peer_db_set() uses ffs(db_bits) to select a doorbell to ring.
ffs() returns a 1-based bit index (bit 0 -> 1).
Entry 0 is reserved for link events, so doorbell bit 0 must map to entry
1. However, since the initial commit 812ce2f8d14e ("NTB: Add support for
EPF PCI Non-Transparent Bridge"), the implementation has been adding an
extra +1, ending up using entry 2 for bit 0. Fixing the extra increment
would break interoperability with peers running older kernels.
Keep the legacy behavior and document the offset and the resulting slot
layout to avoid confusion when enabling per-db-vector handling.
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Koichiro Den <den@valinux.co.jp>
---
drivers/ntb/hw/epf/ntb_hw_epf.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/ntb/hw/epf/ntb_hw_epf.c b/drivers/ntb/hw/epf/ntb_hw_epf.c
index d3ecf25a5162..bce7130fec39 100644
--- a/drivers/ntb/hw/epf/ntb_hw_epf.c
+++ b/drivers/ntb/hw/epf/ntb_hw_epf.c
@@ -43,6 +43,18 @@
#define NTB_EPF_DB_DATA(n) (0x34 + (n) * 4)
#define NTB_EPF_DB_OFFSET(n) (0xB4 + (n) * 4)
+/*
+ * Legacy doorbell slot layout when paired with pci-epf-*ntb:
+ *
+ * slot 0 : reserved for link events
+ * slot 1 : unused (historical extra offset)
+ * slot 2 : DB#0
+ * slot 3 : DB#1
+ * ...
+ *
+ * Thus, NTB_EPF_MIN_DB_COUNT=3 means that we at least create vectors for
+ * doorbells DB#0 and DB#1.
+ */
#define NTB_EPF_MIN_DB_COUNT 3
#define NTB_EPF_MAX_DB_COUNT 31
@@ -473,6 +485,14 @@ static int ntb_epf_peer_mw_get_addr(struct ntb_dev *ntb, int idx,
static int ntb_epf_peer_db_set(struct ntb_dev *ntb, u64 db_bits)
{
struct ntb_epf_dev *ndev = ntb_ndev(ntb);
+ /*
+ * ffs() returns a 1-based bit index (bit 0 -> 1).
+ *
+ * With slot 0 reserved for link events, DB#0 would naturally map to
+ * slot 1. Historically an extra +1 offset was added, so DB#0 maps to
+ * slot 2 and slot 1 remains unused. Keep this mapping for
+ * backward-compatibility.
+ */
u32 interrupt_num = ffs(db_bits) + 1;
struct device *dev = ndev->dev;
u32 db_entry_size;
--
2.51.0 | {
"author": "Koichiro Den <den@valinux.co.jp>",
"date": "Fri, 27 Feb 2026 17:49:51 +0900",
"is_openbsd": false,
"thread_id": "aaG9COYXPJamIvTx@lizhi-Precision-Tower-5810.mbox.gz"
} |
lkml_critique | lkml | This series fixes doorbell bit/vector handling for the EPF-based NTB
pair (ntb_hw_epf <-> pci-epf-*ntb). Its primary goal is to enable safe
per-db-vector handling in the NTB core and clients (e.g. ntb_transport),
without changing the on-the-wire doorbell mapping.
Background / problem
====================
ntb_hw_epf historically applies an extra offset when ringing peer
doorbells: the link event uses the first interrupt slot, and doorbells
start from the third slot (i.e. a second slot is effectively unused).
pci-epf-vntb carries the matching offset on the EP side as well.
As long as db_vector_count()/db_vector_mask() are not implemented, this
mismatch is mostly masked. Doorbell events are effectively treated as
"can hit any QP" and the off-by-one vector numbering does not surface
clearly.
However, once per-vector handling is enabled, the current state becomes
problematic:
- db_valid_mask exposes bits that do not correspond to real doorbells
(link/unused slots leak into the mask).
- ntb_db_event() is fed with 1-based/shifted vectors, while NTB core
expects a 0-based db_vector for doorbells.
- On pci-epf-vntb, .peer_db_set() may be called in atomic context, but
it directly calls pci_epc_raise_irq(), which can sleep.
Why NOT fix the root offset?
============================
The natural "root" fix would be to remove the historical extra offset in
the peer_db_set() doorbell paths for ntb_hw_epf and pci-epf-vntb.
Unfortunately this would lead to interoperability issues when mixing old
and new kernel versions (old/new peers). A new side would ring a
different interrupt slot than what an old peer expects, leading to
missed or misrouted doorbells, once db_vector_count()/db_vector_mask()
are implemented.
Therefore this series intentionally keeps the legacy offset, and instead
fixes the surrounding pieces so the mapping is documented and handled
consistently in masks, vector numbering, and per-vector reporting.
What this series does
=====================
- pci-epf-vntb:
- Document the legacy offset.
- Defer MSI doorbell raises to process context to avoid sleeping in
atomic context. This becomes relevant once multiple doorbells are
raised concurrently at a high rate.
- Report doorbell vectors as 0-based to ntb_db_event().
- Fix db_valid_mask and implement db_vector_count()/db_vector_mask().
- ntb_hw_epf:
- Document the legacy offset in ntb_epf_peer_db_set().
- Fix db_valid_mask to cover only real doorbell bits.
- Report 0-based db_vector to ntb_db_event() (accounting for the
unused slot).
- Keep db_val as a bitmask and fix db_read/db_clear semantics
accordingly.
- Implement db_vector_count()/db_vector_mask().
Compatibility
=============
By keeping the legacy offset intact, this series aims to remain
compatible across mixed kernel versions. The observable changes are
limited to correct mask/vector reporting and safer execution context
handling.
Patches 1-5 (PCI Endpoint) and 6-10 (NTB) are independent and can be
applied separately for each tree. I am sending them together in this
series to provide the full context and to make the cross-subsystem
compatibility constraints explicit. Ideally the whole series would be
applied in a single tree, but each subset is safe to merge on its own.
- Patch 1-5 can apply cleanly onto pci/endpoint latest:
f6797680fe31 ("PCI: epf-mhi: Return 0 on success instead of positive
jiffies from pci_epf_mhi_edma_{read/write}")
- Patch 6-10 can apply cleanly onto ntb-next latest:
7b3302c687ca ("ntb_hw_amd: Fix incorrect debug message in link disable
path")
Note: I don't have a suitable hardware to test ntb_hw_epf + pci-epf-ntb
(not vNTB) bridge scenario, but I believe no changes are needed in
pci-epf-ntb.c.
Changelog
=========
Changes since v1:
- Addressed feedback from Dave (add a source code comment, introduce
enum to eliminate magic numbers)
- Updated source code comment in Patch 2.
- No functional changes, so retained Reviewed-by tags by Frank and Dave.
Thank you both for the review.
Best regards,
Koichiro Den (10):
PCI: endpoint: pci-epf-vntb: Document legacy MSI doorbell offset
PCI: endpoint: pci-epf-vntb: Defer pci_epc_raise_irq() out of atomic
context
PCI: endpoint: pci-epf-vntb: Report 0-based doorbell vector via
ntb_db_event()
PCI: endpoint: pci-epf-vntb: Exclude reserved slots from db_valid_mask
PCI: endpoint: pci-epf-vntb: Implement db_vector_count/mask for
doorbells
NTB: epf: Document legacy doorbell slot offset in
ntb_epf_peer_db_set()
NTB: epf: Make db_valid_mask cover only real doorbell bits
NTB: epf: Report 0-based doorbell vector via ntb_db_event()
NTB: epf: Fix doorbell bitmask handling in db_read/db_clear
NTB: epf: Implement db_vector_count/mask for doorbells
drivers/ntb/hw/epf/ntb_hw_epf.c | 89 ++++++++++-
drivers/pci/endpoint/functions/pci-epf-vntb.c | 147 +++++++++++++++---
2 files changed, 210 insertions(+), 26 deletions(-)
--
2.51.0
| null | null | null | [PATCH v2 00/10] PCI: endpoint: pci-epf-vntb: Document legacy MSI doorbell offset | ntb_db_event() expects the vector number to be relative to the first
doorbell vector starting at 0.
pci-epf-vntb reserves vector 0 for link events and uses higher vector
indices for doorbells. By passing the raw slot index to ntb_db_event(),
it effectively assumes that doorbell 0 maps to vector 1.
However, because the host uses a legacy slot layout and writes doorbell
0 into the third slot, doorbell 0 ultimately appears as vector 2 from
the NTB core perspective.
Adjust pci-epf-vntb to:
- skip the unused second slot, and
- report doorbells as 0-based vectors (DB#0 -> vector 0).
This change does not introduce a behavioral difference until
.db_vector_count()/.db_vector_mask() are implemented, because without
those callbacks NTB clients effectively ignore the vector number.
Fixes: e35f56bb0330 ("PCI: endpoint: Support NTB transfer between RC and EP")
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Koichiro Den <den@valinux.co.jp>
---
Changes since v1:
- No functional changes.
- Introduced enum epf_irq_slot and replaced hard-coded magic numbers,
to be consistent with the change on Patch 8.
drivers/pci/endpoint/functions/pci-epf-vntb.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
index e2c0b6dba793..b13e0d2db6cd 100644
--- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
+++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
@@ -82,6 +82,12 @@ enum epf_ntb_bar {
VNTB_BAR_NUM,
};
+enum epf_irq_slot {
+ EPF_IRQ_LINK = 0,
+ EPF_IRQ_RESERVED_DB, /* Historically skipped slot */
+ EPF_IRQ_DB_START,
+};
+
/*
* +--------------------------------------------------+ Base
* | |
@@ -266,10 +272,11 @@ static void epf_ntb_cmd_handler(struct work_struct *work)
ntb = container_of(work, struct epf_ntb, cmd_handler.work);
- for (i = 1; i < ntb->db_count && !ntb->msi_doorbell; i++) {
+ for (i = EPF_IRQ_DB_START; i < ntb->db_count && !ntb->msi_doorbell;
+ i++) {
if (ntb->epf_db[i]) {
- atomic64_or(1 << (i - 1), &ntb->db);
- ntb_db_event(&ntb->ntb, i);
+ atomic64_or(1 << (i - EPF_IRQ_DB_START), &ntb->db);
+ ntb_db_event(&ntb->ntb, i - EPF_IRQ_DB_START);
ntb->epf_db[i] = 0;
}
}
@@ -335,10 +342,10 @@ static irqreturn_t epf_ntb_doorbell_handler(int irq, void *data)
struct epf_ntb *ntb = data;
int i;
- for (i = 1; i < ntb->db_count; i++)
+ for (i = EPF_IRQ_DB_START; i < ntb->db_count; i++)
if (irq == ntb->epf->db_msg[i].virq) {
- atomic64_or(1 << (i - 1), &ntb->db);
- ntb_db_event(&ntb->ntb, i);
+ atomic64_or(1 << (i - EPF_IRQ_DB_START), &ntb->db);
+ ntb_db_event(&ntb->ntb, i - EPF_IRQ_DB_START);
}
return IRQ_HANDLED;
--
2.51.0 | {
"author": "Koichiro Den <den@valinux.co.jp>",
"date": "Fri, 27 Feb 2026 17:49:48 +0900",
"is_openbsd": false,
"thread_id": "aaG9COYXPJamIvTx@lizhi-Precision-Tower-5810.mbox.gz"
} |
lkml_critique | lkml | This series fixes doorbell bit/vector handling for the EPF-based NTB
pair (ntb_hw_epf <-> pci-epf-*ntb). Its primary goal is to enable safe
per-db-vector handling in the NTB core and clients (e.g. ntb_transport),
without changing the on-the-wire doorbell mapping.
Background / problem
====================
ntb_hw_epf historically applies an extra offset when ringing peer
doorbells: the link event uses the first interrupt slot, and doorbells
start from the third slot (i.e. a second slot is effectively unused).
pci-epf-vntb carries the matching offset on the EP side as well.
As long as db_vector_count()/db_vector_mask() are not implemented, this
mismatch is mostly masked. Doorbell events are effectively treated as
"can hit any QP" and the off-by-one vector numbering does not surface
clearly.
However, once per-vector handling is enabled, the current state becomes
problematic:
- db_valid_mask exposes bits that do not correspond to real doorbells
(link/unused slots leak into the mask).
- ntb_db_event() is fed with 1-based/shifted vectors, while NTB core
expects a 0-based db_vector for doorbells.
- On pci-epf-vntb, .peer_db_set() may be called in atomic context, but
it directly calls pci_epc_raise_irq(), which can sleep.
Why NOT fix the root offset?
============================
The natural "root" fix would be to remove the historical extra offset in
the peer_db_set() doorbell paths for ntb_hw_epf and pci-epf-vntb.
Unfortunately this would lead to interoperability issues when mixing old
and new kernel versions (old/new peers). A new side would ring a
different interrupt slot than what an old peer expects, leading to
missed or misrouted doorbells, once db_vector_count()/db_vector_mask()
are implemented.
Therefore this series intentionally keeps the legacy offset, and instead
fixes the surrounding pieces so the mapping is documented and handled
consistently in masks, vector numbering, and per-vector reporting.
What this series does
=====================
- pci-epf-vntb:
- Document the legacy offset.
- Defer MSI doorbell raises to process context to avoid sleeping in
atomic context. This becomes relevant once multiple doorbells are
raised concurrently at a high rate.
- Report doorbell vectors as 0-based to ntb_db_event().
- Fix db_valid_mask and implement db_vector_count()/db_vector_mask().
- ntb_hw_epf:
- Document the legacy offset in ntb_epf_peer_db_set().
- Fix db_valid_mask to cover only real doorbell bits.
- Report 0-based db_vector to ntb_db_event() (accounting for the
unused slot).
- Keep db_val as a bitmask and fix db_read/db_clear semantics
accordingly.
- Implement db_vector_count()/db_vector_mask().
Compatibility
=============
By keeping the legacy offset intact, this series aims to remain
compatible across mixed kernel versions. The observable changes are
limited to correct mask/vector reporting and safer execution context
handling.
Patches 1-5 (PCI Endpoint) and 6-10 (NTB) are independent and can be
applied separately for each tree. I am sending them together in this
series to provide the full context and to make the cross-subsystem
compatibility constraints explicit. Ideally the whole series would be
applied in a single tree, but each subset is safe to merge on its own.
- Patch 1-5 can apply cleanly onto pci/endpoint latest:
f6797680fe31 ("PCI: epf-mhi: Return 0 on success instead of positive
jiffies from pci_epf_mhi_edma_{read/write}")
- Patch 6-10 can apply cleanly onto ntb-next latest:
7b3302c687ca ("ntb_hw_amd: Fix incorrect debug message in link disable
path")
Note: I don't have a suitable hardware to test ntb_hw_epf + pci-epf-ntb
(not vNTB) bridge scenario, but I believe no changes are needed in
pci-epf-ntb.c.
Changelog
=========
Changes since v1:
- Addressed feedback from Dave (add a source code comment, introduce
enum to eliminate magic numbers)
- Updated source code comment in Patch 2.
- No functional changes, so retained Reviewed-by tags by Frank and Dave.
Thank you both for the review.
Best regards,
Koichiro Den (10):
PCI: endpoint: pci-epf-vntb: Document legacy MSI doorbell offset
PCI: endpoint: pci-epf-vntb: Defer pci_epc_raise_irq() out of atomic
context
PCI: endpoint: pci-epf-vntb: Report 0-based doorbell vector via
ntb_db_event()
PCI: endpoint: pci-epf-vntb: Exclude reserved slots from db_valid_mask
PCI: endpoint: pci-epf-vntb: Implement db_vector_count/mask for
doorbells
NTB: epf: Document legacy doorbell slot offset in
ntb_epf_peer_db_set()
NTB: epf: Make db_valid_mask cover only real doorbell bits
NTB: epf: Report 0-based doorbell vector via ntb_db_event()
NTB: epf: Fix doorbell bitmask handling in db_read/db_clear
NTB: epf: Implement db_vector_count/mask for doorbells
drivers/ntb/hw/epf/ntb_hw_epf.c | 89 ++++++++++-
drivers/pci/endpoint/functions/pci-epf-vntb.c | 147 +++++++++++++++---
2 files changed, 210 insertions(+), 26 deletions(-)
--
2.51.0
| null | null | null | [PATCH v2 00/10] PCI: endpoint: pci-epf-vntb: Document legacy MSI doorbell offset | ntb_db_event() expects the vector number to be relative to the first
doorbell vector starting at 0.
Vector 0 is reserved for link events in the EPF driver, so doorbells
start at vector 1. However, both supported peers (ntb_hw_epf with
pci-epf-ntb, and pci-epf-vntb) have historically skipped vector 1 and
started doorbells at vector 2.
Pass (irq_no - 2) to ntb_db_event() so doorbells are reported as 0..N-1.
If irq_no == 1 is ever observed, treat it as DB#0 and emit a warning, as
this would indicate an unexpected change in the slot layout.
Fixes: 812ce2f8d14e ("NTB: Add support for EPF PCI Non-Transparent Bridge")
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Suggested-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Koichiro Den <den@valinux.co.jp>
---
Changes since v1:
- No functional changes.
- Addressed review comments (enum epf_irq_slot introduced).
drivers/ntb/hw/epf/ntb_hw_epf.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/ntb/hw/epf/ntb_hw_epf.c b/drivers/ntb/hw/epf/ntb_hw_epf.c
index 07dc97d3270b..67cdc5d729d5 100644
--- a/drivers/ntb/hw/epf/ntb_hw_epf.c
+++ b/drivers/ntb/hw/epf/ntb_hw_epf.c
@@ -81,6 +81,12 @@ enum epf_ntb_bar {
NTB_BAR_NUM,
};
+enum epf_irq_slot {
+ EPF_IRQ_LINK = 0,
+ EPF_IRQ_RESERVED_DB, /* Historically skipped slot */
+ EPF_IRQ_DB_START,
+};
+
#define NTB_EPF_MAX_MW_COUNT (NTB_BAR_NUM - BAR_MW1)
struct ntb_epf_dev {
@@ -333,10 +339,15 @@ static irqreturn_t ntb_epf_vec_isr(int irq, void *dev)
irq_no = irq - pci_irq_vector(ndev->ntb.pdev, 0);
ndev->db_val = irq_no + 1;
- if (irq_no == 0)
+ if (irq_no == EPF_IRQ_LINK) {
ntb_link_event(&ndev->ntb);
- else
- ntb_db_event(&ndev->ntb, irq_no);
+ } else if (irq_no == EPF_IRQ_RESERVED_DB) {
+ dev_warn_ratelimited(ndev->dev,
+ "Unexpected irq_no 1 received. Treat it as DB#0.\n");
+ ntb_db_event(&ndev->ntb, 0);
+ } else {
+ ntb_db_event(&ndev->ntb, irq_no - EPF_IRQ_DB_START);
+ }
return IRQ_HANDLED;
}
--
2.51.0 | {
"author": "Koichiro Den <den@valinux.co.jp>",
"date": "Fri, 27 Feb 2026 17:49:53 +0900",
"is_openbsd": false,
"thread_id": "aaG9COYXPJamIvTx@lizhi-Precision-Tower-5810.mbox.gz"
} |
lkml_critique | lkml | This series fixes doorbell bit/vector handling for the EPF-based NTB
pair (ntb_hw_epf <-> pci-epf-*ntb). Its primary goal is to enable safe
per-db-vector handling in the NTB core and clients (e.g. ntb_transport),
without changing the on-the-wire doorbell mapping.
Background / problem
====================
ntb_hw_epf historically applies an extra offset when ringing peer
doorbells: the link event uses the first interrupt slot, and doorbells
start from the third slot (i.e. a second slot is effectively unused).
pci-epf-vntb carries the matching offset on the EP side as well.
As long as db_vector_count()/db_vector_mask() are not implemented, this
mismatch is mostly masked. Doorbell events are effectively treated as
"can hit any QP" and the off-by-one vector numbering does not surface
clearly.
However, once per-vector handling is enabled, the current state becomes
problematic:
- db_valid_mask exposes bits that do not correspond to real doorbells
(link/unused slots leak into the mask).
- ntb_db_event() is fed with 1-based/shifted vectors, while NTB core
expects a 0-based db_vector for doorbells.
- On pci-epf-vntb, .peer_db_set() may be called in atomic context, but
it directly calls pci_epc_raise_irq(), which can sleep.
Why NOT fix the root offset?
============================
The natural "root" fix would be to remove the historical extra offset in
the peer_db_set() doorbell paths for ntb_hw_epf and pci-epf-vntb.
Unfortunately this would lead to interoperability issues when mixing old
and new kernel versions (old/new peers). A new side would ring a
different interrupt slot than what an old peer expects, leading to
missed or misrouted doorbells, once db_vector_count()/db_vector_mask()
are implemented.
Therefore this series intentionally keeps the legacy offset, and instead
fixes the surrounding pieces so the mapping is documented and handled
consistently in masks, vector numbering, and per-vector reporting.
What this series does
=====================
- pci-epf-vntb:
- Document the legacy offset.
- Defer MSI doorbell raises to process context to avoid sleeping in
atomic context. This becomes relevant once multiple doorbells are
raised concurrently at a high rate.
- Report doorbell vectors as 0-based to ntb_db_event().
- Fix db_valid_mask and implement db_vector_count()/db_vector_mask().
- ntb_hw_epf:
- Document the legacy offset in ntb_epf_peer_db_set().
- Fix db_valid_mask to cover only real doorbell bits.
- Report 0-based db_vector to ntb_db_event() (accounting for the
unused slot).
- Keep db_val as a bitmask and fix db_read/db_clear semantics
accordingly.
- Implement db_vector_count()/db_vector_mask().
Compatibility
=============
By keeping the legacy offset intact, this series aims to remain
compatible across mixed kernel versions. The observable changes are
limited to correct mask/vector reporting and safer execution context
handling.
Patches 1-5 (PCI Endpoint) and 6-10 (NTB) are independent and can be
applied separately for each tree. I am sending them together in this
series to provide the full context and to make the cross-subsystem
compatibility constraints explicit. Ideally the whole series would be
applied in a single tree, but each subset is safe to merge on its own.
- Patch 1-5 can apply cleanly onto pci/endpoint latest:
f6797680fe31 ("PCI: epf-mhi: Return 0 on success instead of positive
jiffies from pci_epf_mhi_edma_{read/write}")
- Patch 6-10 can apply cleanly onto ntb-next latest:
7b3302c687ca ("ntb_hw_amd: Fix incorrect debug message in link disable
path")
Note: I don't have a suitable hardware to test ntb_hw_epf + pci-epf-ntb
(not vNTB) bridge scenario, but I believe no changes are needed in
pci-epf-ntb.c.
Changelog
=========
Changes since v1:
- Addressed feedback from Dave (add a source code comment, introduce
enum to eliminate magic numbers)
- Updated source code comment in Patch 2.
- No functional changes, so retained Reviewed-by tags by Frank and Dave.
Thank you both for the review.
Best regards,
Koichiro Den (10):
PCI: endpoint: pci-epf-vntb: Document legacy MSI doorbell offset
PCI: endpoint: pci-epf-vntb: Defer pci_epc_raise_irq() out of atomic
context
PCI: endpoint: pci-epf-vntb: Report 0-based doorbell vector via
ntb_db_event()
PCI: endpoint: pci-epf-vntb: Exclude reserved slots from db_valid_mask
PCI: endpoint: pci-epf-vntb: Implement db_vector_count/mask for
doorbells
NTB: epf: Document legacy doorbell slot offset in
ntb_epf_peer_db_set()
NTB: epf: Make db_valid_mask cover only real doorbell bits
NTB: epf: Report 0-based doorbell vector via ntb_db_event()
NTB: epf: Fix doorbell bitmask handling in db_read/db_clear
NTB: epf: Implement db_vector_count/mask for doorbells
drivers/ntb/hw/epf/ntb_hw_epf.c | 89 ++++++++++-
drivers/pci/endpoint/functions/pci-epf-vntb.c | 147 +++++++++++++++---
2 files changed, 210 insertions(+), 26 deletions(-)
--
2.51.0
| null | null | null | [PATCH v2 00/10] PCI: endpoint: pci-epf-vntb: Document legacy MSI doorbell offset | In pci-epf-vntb, db_count represents the total number of doorbell slots
exposed to the peer, including:
- slot #0 reserved for link events, and
- slot #1 historically unused (kept for compatibility).
Only the remaining slots correspond to actual doorbell bits. The current
db_valid_mask() exposes all slots as valid doorbells.
Limit db_valid_mask() to the real doorbell bits by returning
BIT_ULL(db_count - 2) - 1, and guard against db_count < 2.
Fixes: e35f56bb0330 ("PCI: endpoint: Support NTB transfer between RC and EP")
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Koichiro Den <den@valinux.co.jp>
---
Changes since v1:
- No functional changes.
- Use EPF_IRQ_DB_START instead of magic number 2, to be consistent
with the change on Patch 8.
drivers/pci/endpoint/functions/pci-epf-vntb.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
index b13e0d2db6cd..b94e2e1d3421 100644
--- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
+++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
@@ -1280,7 +1280,10 @@ static int vntb_epf_peer_mw_count(struct ntb_dev *ntb)
static u64 vntb_epf_db_valid_mask(struct ntb_dev *ntb)
{
- return BIT_ULL(ntb_ndev(ntb)->db_count) - 1;
+ if (ntb_ndev(ntb)->db_count < EPF_IRQ_DB_START)
+ return 0;
+
+ return BIT_ULL(ntb_ndev(ntb)->db_count - EPF_IRQ_DB_START) - 1;
}
static int vntb_epf_db_set_mask(struct ntb_dev *ntb, u64 db_bits)
--
2.51.0 | {
"author": "Koichiro Den <den@valinux.co.jp>",
"date": "Fri, 27 Feb 2026 17:49:49 +0900",
"is_openbsd": false,
"thread_id": "aaG9COYXPJamIvTx@lizhi-Precision-Tower-5810.mbox.gz"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.