mirror of https://github.com/torvalds/linux.git
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>
This commit is contained in:
parent
f3fddb71dd
commit
0787755271
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue