Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Jason Gunthorpe and committed by
Alex Williamson
e238f147 113557b0

+21 -24
+21 -24
drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c
··· 1385 1385 return vfio_pci_core_read(core_vdev, buf, new_count, ppos); 1386 1386 } 1387 1387 1388 - static long hisi_acc_vfio_pci_ioctl(struct vfio_device *core_vdev, unsigned int cmd, 1389 - unsigned long arg) 1388 + static int hisi_acc_vfio_ioctl_get_region(struct vfio_device *core_vdev, 1389 + struct vfio_region_info __user *arg) 1390 1390 { 1391 - if (cmd == VFIO_DEVICE_GET_REGION_INFO) { 1392 - struct vfio_pci_core_device *vdev = 1393 - container_of(core_vdev, struct vfio_pci_core_device, vdev); 1394 - struct vfio_region_info info; 1395 - unsigned long minsz; 1391 + struct vfio_pci_core_device *vdev = 1392 + container_of(core_vdev, struct vfio_pci_core_device, vdev); 1393 + struct vfio_region_info info; 1394 + unsigned long minsz; 1396 1395 1397 - minsz = offsetofend(struct vfio_region_info, offset); 1396 + minsz = offsetofend(struct vfio_region_info, offset); 1398 1397 1399 - if (copy_from_user(&info, (void __user *)arg, minsz)) 1400 - return -EFAULT; 1398 + if (copy_from_user(&info, arg, minsz)) 1399 + return -EFAULT; 1401 1400 1402 - if (info.argsz < minsz) 1403 - return -EINVAL; 1401 + if (info.argsz < minsz) 1402 + return -EINVAL; 1404 1403 1405 - if (info.index == VFIO_PCI_BAR2_REGION_INDEX) { 1406 - info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index); 1404 + if (info.index != VFIO_PCI_BAR2_REGION_INDEX) 1405 + return vfio_pci_ioctl_get_region_info(core_vdev, arg); 1407 1406 1408 - info.size = hisi_acc_get_resource_len(vdev, info.index); 1407 + info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index); 1409 1408 1410 - info.flags = VFIO_REGION_INFO_FLAG_READ | 1411 - VFIO_REGION_INFO_FLAG_WRITE | 1412 - VFIO_REGION_INFO_FLAG_MMAP; 1409 + info.size = hisi_acc_get_resource_len(vdev, info.index); 1413 1410 1414 - return copy_to_user((void __user *)arg, &info, minsz) ? 1415 - -EFAULT : 0; 1416 - } 1417 - } 1418 - return vfio_pci_core_ioctl(core_vdev, cmd, arg); 1411 + info.flags = VFIO_REGION_INFO_FLAG_READ | VFIO_REGION_INFO_FLAG_WRITE | 1412 + VFIO_REGION_INFO_FLAG_MMAP; 1413 + 1414 + return copy_to_user(arg, &info, minsz) ? -EFAULT : 0; 1419 1415 } 1420 1416 1421 1417 static int hisi_acc_vf_debug_check(struct seq_file *seq, struct vfio_device *vdev) ··· 1609 1613 .release = vfio_pci_core_release_dev, 1610 1614 .open_device = hisi_acc_vfio_pci_open_device, 1611 1615 .close_device = hisi_acc_vfio_pci_close_device, 1612 - .ioctl = hisi_acc_vfio_pci_ioctl, 1616 + .ioctl = vfio_pci_core_ioctl, 1617 + .get_region_info = hisi_acc_vfio_ioctl_get_region, 1613 1618 .device_feature = vfio_pci_core_ioctl_feature, 1614 1619 .read = hisi_acc_vfio_pci_read, 1615 1620 .write = hisi_acc_vfio_pci_write,