diff options
author | Bharat Bhushan <Bharat.Bhushan@nxp.com> | 2016-10-18 09:40:10 (GMT) |
---|---|---|
committer | Xie Xiaobo <xiaobo.xie@nxp.com> | 2017-09-25 07:25:34 (GMT) |
commit | 7a66c154a8e16622f8e8f873220de85f6035c078 (patch) | |
tree | 60f164be20b60754d1bd7d42d82cda19a33a7885 /drivers/vfio | |
parent | dd2eb6c3f42d9f1cfb368a03828825bd8b3d4ff3 (diff) | |
download | linux-7a66c154a8e16622f8e8f873220de85f6035c078.tar.xz |
vfio/fsl-mc: Return fsl-mc device info
Allow userspace to get fsl-mc device info by making
VFIO_DEVICE_GET_INFO ioctl. With this usespace will get
basic device info such as number of regions and irqs.
Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
Diffstat (limited to 'drivers/vfio')
-rw-r--r-- | drivers/vfio/fsl-mc/vfio_fsl_mc.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c index eb40249..b01e9c0 100644 --- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c @@ -44,10 +44,31 @@ static void vfio_fsl_mc_release(void *device_data) static long vfio_fsl_mc_ioctl(void *device_data, unsigned int cmd, unsigned long arg) { + struct vfio_fsl_mc_device *vdev = device_data; + struct fsl_mc_device *mc_dev = vdev->mc_dev; + unsigned long minsz; + + if (WARN_ON(!mc_dev)) + return -ENODEV; + switch (cmd) { case VFIO_DEVICE_GET_INFO: { - return -EINVAL; + struct vfio_device_info info; + + minsz = offsetofend(struct vfio_device_info, num_irqs); + + if (copy_from_user(&info, (void __user *)arg, minsz)) + return -EFAULT; + + if (info.argsz < minsz) + return -EINVAL; + + info.flags = VFIO_DEVICE_FLAGS_FSL_MC; + info.num_regions = mc_dev->obj_desc.region_count; + info.num_irqs = mc_dev->obj_desc.irq_count; + + return copy_to_user((void __user *)arg, &info, minsz); } case VFIO_DEVICE_GET_REGION_INFO: { |