mirror of https://github.com/torvalds/linux.git
vfio/hisi: Convert to the get_region_info op
Change the function signature of hisi_acc_vfio_pci_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/2-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
113557b040
commit
e238f147d5
|
|
@ -1385,37 +1385,33 @@ static ssize_t hisi_acc_vfio_pci_read(struct vfio_device *core_vdev,
|
||||||
return vfio_pci_core_read(core_vdev, buf, new_count, ppos);
|
return vfio_pci_core_read(core_vdev, buf, new_count, ppos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static long hisi_acc_vfio_pci_ioctl(struct vfio_device *core_vdev, unsigned int cmd,
|
static int hisi_acc_vfio_ioctl_get_region(struct vfio_device *core_vdev,
|
||||||
unsigned long arg)
|
struct vfio_region_info __user *arg)
|
||||||
{
|
{
|
||||||
if (cmd == VFIO_DEVICE_GET_REGION_INFO) {
|
struct vfio_pci_core_device *vdev =
|
||||||
struct vfio_pci_core_device *vdev =
|
container_of(core_vdev, struct vfio_pci_core_device, vdev);
|
||||||
container_of(core_vdev, struct vfio_pci_core_device, vdev);
|
struct vfio_region_info info;
|
||||||
struct vfio_region_info info;
|
unsigned long minsz;
|
||||||
unsigned long minsz;
|
|
||||||
|
|
||||||
minsz = offsetofend(struct vfio_region_info, offset);
|
minsz = offsetofend(struct vfio_region_info, offset);
|
||||||
|
|
||||||
if (copy_from_user(&info, (void __user *)arg, minsz))
|
if (copy_from_user(&info, arg, minsz))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
if (info.argsz < minsz)
|
if (info.argsz < minsz)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (info.index == VFIO_PCI_BAR2_REGION_INDEX) {
|
if (info.index != VFIO_PCI_BAR2_REGION_INDEX)
|
||||||
info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index);
|
return vfio_pci_ioctl_get_region_info(core_vdev, arg);
|
||||||
|
|
||||||
info.size = hisi_acc_get_resource_len(vdev, info.index);
|
info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index);
|
||||||
|
|
||||||
info.flags = VFIO_REGION_INFO_FLAG_READ |
|
info.size = hisi_acc_get_resource_len(vdev, info.index);
|
||||||
VFIO_REGION_INFO_FLAG_WRITE |
|
|
||||||
VFIO_REGION_INFO_FLAG_MMAP;
|
|
||||||
|
|
||||||
return copy_to_user((void __user *)arg, &info, minsz) ?
|
info.flags = VFIO_REGION_INFO_FLAG_READ | VFIO_REGION_INFO_FLAG_WRITE |
|
||||||
-EFAULT : 0;
|
VFIO_REGION_INFO_FLAG_MMAP;
|
||||||
}
|
|
||||||
}
|
return copy_to_user(arg, &info, minsz) ? -EFAULT : 0;
|
||||||
return vfio_pci_core_ioctl(core_vdev, cmd, arg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hisi_acc_vf_debug_check(struct seq_file *seq, struct vfio_device *vdev)
|
static int hisi_acc_vf_debug_check(struct seq_file *seq, struct vfio_device *vdev)
|
||||||
|
|
@ -1613,7 +1609,8 @@ static const struct vfio_device_ops hisi_acc_vfio_pci_migrn_ops = {
|
||||||
.release = vfio_pci_core_release_dev,
|
.release = vfio_pci_core_release_dev,
|
||||||
.open_device = hisi_acc_vfio_pci_open_device,
|
.open_device = hisi_acc_vfio_pci_open_device,
|
||||||
.close_device = hisi_acc_vfio_pci_close_device,
|
.close_device = hisi_acc_vfio_pci_close_device,
|
||||||
.ioctl = hisi_acc_vfio_pci_ioctl,
|
.ioctl = vfio_pci_core_ioctl,
|
||||||
|
.get_region_info = hisi_acc_vfio_ioctl_get_region,
|
||||||
.device_feature = vfio_pci_core_ioctl_feature,
|
.device_feature = vfio_pci_core_ioctl_feature,
|
||||||
.read = hisi_acc_vfio_pci_read,
|
.read = hisi_acc_vfio_pci_read,
|
||||||
.write = hisi_acc_vfio_pci_write,
|
.write = hisi_acc_vfio_pci_write,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue