diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2026-04-16 08:01:16 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2026-04-16 08:01:16 -0700 |
| commit | f0bf3eac92b2be5f34b944cb82f1c23db642c7f5 (patch) | |
| tree | 6727ce3b61073f1341ece4f7326af0b1588120a0 /samples | |
| parent | 1d51b370a0f8f642f4fc84c795fbedac0fcdbbd2 (diff) | |
| parent | 493c7eff3c2ffa94ce3c5e62172948a1e38b491e (diff) | |
Merge tag 'vfio-v7.1-rc1' of https://github.com/awilliam/linux-vfio
Pull VFIO updates from Alex Williamson:
- Update QAT vfio-pci variant driver for Gen 5, 420xx devices (Vijay
Sundar Selvamani, Suman Kumar Chakraborty, Giovanni Cabiddu)
- Fix vfio selftest MMIO DMA mapping selftest (Alex Mastro)
- Conversions to const struct class in support of class_create()
deprecation (Jori Koolstra)
- Improve selftest compiler compatibility by avoiding initializer on
variable-length array (Manish Honap)
- Define new uAPI for drivers supporting migration to advise user-
space of new initial data for reducing target startup latency.
Implemented for mlx5 vfio-pci variant driver (Yishai Hadas)
- Enable vfio selftests on aarch64, not just cross-compiles reporting
arm64 (Ted Logan)
- Update vfio selftest driver support to include additional DSA devices
(Yi Lai)
- Unconditionally include debugfs root pointer in vfio device struct,
avoiding a build failure seen in hisi_acc variant driver without
debugfs otherwise (Arnd Bergmann)
- Add support for the s390 ISM (Internal Shared Memory) device via a
new variant driver. The device is unique in the size of its BAR space
(256TiB) and lack of mmap support (Julian Ruess)
- Enforce that vfio-pci drivers implement a name in their ops structure
for use in sequestering SR-IOV VFs (Alex Williamson)
- Prune leftover group notifier code (Paolo Bonzini)
- Fix Xe vfio-pci variant driver to avoid migration support as a
dependency in the reset path and missing release call (MichaĆ
Winiarski)
* tag 'vfio-v7.1-rc1' of https://github.com/awilliam/linux-vfio: (23 commits)
vfio/xe: Add a missing vfio_pci_core_release_dev()
vfio/xe: Reorganize the init to decouple migration from reset
vfio: remove dead notifier code
vfio/pci: Require vfio_device_ops.name
MAINTAINERS: add VFIO ISM PCI DRIVER section
vfio/ism: Implement vfio_pci driver for ISM devices
vfio/pci: Rename vfio_config_do_rw() to vfio_pci_config_rw_single() and export it
vfio: unhide vdev->debug_root
vfio/qat: add support for Intel QAT 420xx VFs
vfio: selftests: Support DMR and GNR-D DSA devices
vfio: selftests: Build tests on aarch64
vfio/mlx5: Add REINIT support to VFIO_MIG_GET_PRECOPY_INFO
vfio/mlx5: consider inflight SAVE during PRE_COPY
net/mlx5: Add IFC bits for migration state
vfio: Adapt drivers to use the core helper vfio_check_precopy_ioctl
vfio: Add support for VFIO_DEVICE_FEATURE_MIG_PRECOPY_INFOv2
vfio: Define uAPI for re-init initial bytes during the PRE_COPY phase
vfio: selftests: Fix VLA initialisation in vfio_pci_irq_set()
vfio: uapi: fix comment typo
vfio: mdev: replace mtty_dev->vd_class with a const struct class
...
Diffstat (limited to 'samples')
| -rw-r--r-- | samples/vfio-mdev/mtty.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c index bd92c38379b8..69b6d9defbce 100644 --- a/samples/vfio-mdev/mtty.c +++ b/samples/vfio-mdev/mtty.c @@ -68,9 +68,12 @@ * Global Structures */ +static const struct class mtty_class = { + .name = MTTY_CLASS_NAME +}; + static struct mtty_dev { dev_t vd_devt; - struct class *vd_class; struct cdev vd_cdev; struct idr vd_idr; struct device dev; @@ -837,18 +840,11 @@ static long mtty_precopy_ioctl(struct file *filp, unsigned int cmd, struct mdev_state *mdev_state = migf->mdev_state; loff_t *pos = &filp->f_pos; struct vfio_precopy_info info = {}; - unsigned long minsz; int ret; - if (cmd != VFIO_MIG_GET_PRECOPY_INFO) - return -ENOTTY; - - minsz = offsetofend(struct vfio_precopy_info, dirty_bytes); - - if (copy_from_user(&info, (void __user *)arg, minsz)) - return -EFAULT; - if (info.argsz < minsz) - return -EINVAL; + ret = vfio_check_precopy_ioctl(&mdev_state->vdev, cmd, arg, &info); + if (ret) + return ret; mutex_lock(&mdev_state->state_mutex); if (mdev_state->state != VFIO_DEVICE_STATE_PRE_COPY && @@ -875,7 +871,8 @@ static long mtty_precopy_ioctl(struct file *filp, unsigned int cmd, info.initial_bytes = migf->filled_size - *pos; mutex_unlock(&migf->lock); - ret = copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0; + ret = copy_to_user((void __user *)arg, &info, + offsetofend(struct vfio_precopy_info, dirty_bytes)) ? -EFAULT : 0; unlock: mtty_state_mutex_unlock(mdev_state); return ret; @@ -1980,15 +1977,14 @@ static int __init mtty_dev_init(void) if (ret) goto err_cdev; - mtty_dev.vd_class = class_create(MTTY_CLASS_NAME); + ret = class_register(&mtty_class); - if (IS_ERR(mtty_dev.vd_class)) { + if (ret) { pr_err("Error: failed to register mtty_dev class\n"); - ret = PTR_ERR(mtty_dev.vd_class); goto err_driver; } - mtty_dev.dev.class = mtty_dev.vd_class; + mtty_dev.dev.class = &mtty_class; mtty_dev.dev.release = mtty_device_release; dev_set_name(&mtty_dev.dev, "%s", MTTY_NAME); @@ -2007,7 +2003,7 @@ err_device: device_del(&mtty_dev.dev); err_put: put_device(&mtty_dev.dev); - class_destroy(mtty_dev.vd_class); + class_unregister(&mtty_class); err_driver: mdev_unregister_driver(&mtty_driver); err_cdev: @@ -2026,8 +2022,7 @@ static void __exit mtty_dev_exit(void) mdev_unregister_driver(&mtty_driver); cdev_del(&mtty_dev.vd_cdev); unregister_chrdev_region(mtty_dev.vd_devt, MINORMASK + 1); - class_destroy(mtty_dev.vd_class); - mtty_dev.vd_class = NULL; + class_unregister(&mtty_class); pr_info("mtty_dev: Unloaded!\n"); } |
