Commit e238f147 authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Alex Williamson
Browse files

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: default avatarKevin Tian <kevin.tian@intel.com>
Acked-by: default avatarPranjal Shrivastava <praan@google.com>
Signed-off-by: default avatarJason 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: default avatarAlex Williamson <alex@shazbot.org>
parent 113557b0
Loading
Loading
Loading
Loading
+21 −24
Original line number Diff line number Diff line
@@ -1385,10 +1385,9 @@ static ssize_t hisi_acc_vfio_pci_read(struct vfio_device *core_vdev,
	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,
				    unsigned long arg)
static int hisi_acc_vfio_ioctl_get_region(struct vfio_device *core_vdev,
					  struct vfio_region_info __user *arg)
{
	if (cmd == VFIO_DEVICE_GET_REGION_INFO) {
	struct vfio_pci_core_device *vdev =
		container_of(core_vdev, struct vfio_pci_core_device, vdev);
	struct vfio_region_info info;
@@ -1396,26 +1395,23 @@ static long hisi_acc_vfio_pci_ioctl(struct vfio_device *core_vdev, unsigned int

	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;

	if (info.argsz < minsz)
		return -EINVAL;

		if (info.index == VFIO_PCI_BAR2_REGION_INDEX) {
	if (info.index != VFIO_PCI_BAR2_REGION_INDEX)
		return vfio_pci_ioctl_get_region_info(core_vdev, arg);

	info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index);

	info.size = hisi_acc_get_resource_len(vdev, info.index);

			info.flags = VFIO_REGION_INFO_FLAG_READ |
					VFIO_REGION_INFO_FLAG_WRITE |
	info.flags = VFIO_REGION_INFO_FLAG_READ | VFIO_REGION_INFO_FLAG_WRITE |
		     VFIO_REGION_INFO_FLAG_MMAP;

			return copy_to_user((void __user *)arg, &info, minsz) ?
					    -EFAULT : 0;
		}
	}
	return vfio_pci_core_ioctl(core_vdev, cmd, arg);
	return copy_to_user(arg, &info, minsz) ? -EFAULT : 0;
}

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,
	.open_device = hisi_acc_vfio_pci_open_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,
	.read = hisi_acc_vfio_pci_read,
	.write = hisi_acc_vfio_pci_write,