diff options
| author | Jason Gunthorpe <jgg@nvidia.com> | 2025-11-07 13:41:22 -0400 |
|---|---|---|
| committer | Alex Williamson <alex@shazbot.org> | 2025-11-12 15:05:02 -0700 |
| commit | 0787755271096e6c48019f44aea6ccc33f93bf41 (patch) | |
| tree | ac851410684ef116b6dd1cb68d1d6a8a59c32695 /samples | |
| parent | f3fddb71dd50ed31ae474238551e8623a1bc16db (diff) | |
vfio/mtty: Provide a get_region_info op
Move it out of mtty_ioctl() and re-indent it.
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Pranjal Shrivastava <praan@google.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/6-v2-2a9e24d62f1b+e10a-vfio_get_region_info_op_jgg@nvidia.com
Signed-off-by: Alex Williamson <alex@shazbot.org>
Diffstat (limited to 'samples')
| -rw-r--r-- | samples/vfio-mdev/mtty.c | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c index 6cb3e5974990..05a65e627679 100644 --- a/samples/vfio-mdev/mtty.c +++ b/samples/vfio-mdev/mtty.c @@ -1785,6 +1785,34 @@ static int mtty_get_device_info(struct vfio_device_info *dev_info) return 0; } +static int mtty_ioctl_get_region_info(struct vfio_device *vdev, + struct vfio_region_info __user *arg) +{ + struct mdev_state *mdev_state = + container_of(vdev, struct mdev_state, vdev); + struct vfio_region_info info; + void *cap_type = NULL; + u16 cap_type_id = 0; + unsigned long minsz; + int ret; + + minsz = offsetofend(struct vfio_region_info, offset); + + if (copy_from_user(&info, arg, minsz)) + return -EFAULT; + + if (info.argsz < minsz) + return -EINVAL; + + ret = mtty_get_region_info(mdev_state, &info, &cap_type_id, &cap_type); + if (ret) + return ret; + + if (copy_to_user(arg, &info, minsz)) + return -EFAULT; + return 0; +} + static long mtty_ioctl(struct vfio_device *vdev, unsigned int cmd, unsigned long arg) { @@ -1817,30 +1845,6 @@ static long mtty_ioctl(struct vfio_device *vdev, unsigned int cmd, return 0; } - case VFIO_DEVICE_GET_REGION_INFO: - { - struct vfio_region_info info; - u16 cap_type_id = 0; - void *cap_type = NULL; - - minsz = offsetofend(struct vfio_region_info, offset); - - if (copy_from_user(&info, (void __user *)arg, minsz)) - return -EFAULT; - - if (info.argsz < minsz) - return -EINVAL; - - ret = mtty_get_region_info(mdev_state, &info, &cap_type_id, - &cap_type); - if (ret) - return ret; - - if (copy_to_user((void __user *)arg, &info, minsz)) - return -EFAULT; - - return 0; - } case VFIO_DEVICE_GET_IRQ_INFO: { @@ -1949,6 +1953,7 @@ static const struct vfio_device_ops mtty_dev_ops = { .read = mtty_read, .write = mtty_write, .ioctl = mtty_ioctl, + .get_region_info = mtty_ioctl_get_region_info, .bind_iommufd = vfio_iommufd_emulated_bind, .unbind_iommufd = vfio_iommufd_emulated_unbind, .attach_ioas = vfio_iommufd_emulated_attach_ioas, |
