1 From a548dc00536e2cc6e7e7f95487f5261b3133a0d7 Mon Sep 17 00:00:00 2001
2 From: Diana Craciun <diana.craciun@nxp.com>
3 Date: Wed, 18 Sep 2019 18:26:14 +0300
4 Subject: [PATCH] vfio/fsl-mc: Implement VFIO_DEVICE_GET_INFO ioctl
6 Allow userspace to get fsl-mc device info (number of regions
9 Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
10 Signed-off-by: Diana Craciun <diana.craciun@nxp.com>
12 drivers/vfio/fsl-mc/vfio_fsl_mc.c | 22 +++++++++++++++++++++-
13 1 file changed, 21 insertions(+), 1 deletion(-)
15 --- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c
16 +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
17 @@ -32,10 +32,30 @@ static void vfio_fsl_mc_release(void *de
18 static long vfio_fsl_mc_ioctl(void *device_data, unsigned int cmd,
21 + unsigned long minsz;
22 + struct vfio_fsl_mc_device *vdev = device_data;
23 + struct fsl_mc_device *mc_dev = vdev->mc_dev;
26 case VFIO_DEVICE_GET_INFO:
29 + struct vfio_device_info info;
31 + minsz = offsetofend(struct vfio_device_info, num_irqs);
33 + if (copy_from_user(&info, (void __user *)arg, minsz))
36 + if (info.argsz < minsz)
39 + info.flags = VFIO_DEVICE_FLAGS_FSL_MC;
40 + info.num_regions = mc_dev->obj_desc.region_count;
41 + info.num_irqs = mc_dev->obj_desc.irq_count;
43 + return copy_to_user((void __user *)arg, &info, minsz) ?
47 case VFIO_DEVICE_GET_REGION_INFO: