diff options
author | Yangbo Lu <yangbo.lu@nxp.com> | 2020-04-10 10:47:05 +0800 |
---|---|---|
committer | Petr Štetiar <ynezz@true.cz> | 2020-05-07 12:53:06 +0200 |
commit | cddd4591404fb4c53dc0b3c0b15b942cdbed4356 (patch) | |
tree | 392c1179de46b0f804e3789edca19069b64e6b44 /target/linux/layerscape/patches-5.4/821-vfio-0004-vfio-fsl-mc-Implement-VFIO_DEVICE_GET_REGION_INFO-io.patch | |
parent | d1d2c0b5579ea4f69a42246c9318539d61ba1999 (diff) | |
download | upstream-cddd4591404fb4c53dc0b3c0b15b942cdbed4356.tar.gz upstream-cddd4591404fb4c53dc0b3c0b15b942cdbed4356.tar.bz2 upstream-cddd4591404fb4c53dc0b3c0b15b942cdbed4356.zip |
layerscape: add patches-5.4
Add patches for linux-5.4. The patches are from NXP LSDK-20.04 release
which was tagged LSDK-20.04-V5.4.
https://source.codeaurora.org/external/qoriq/qoriq-components/linux/
For boards LS1021A-IOT, and Traverse-LS1043 which are not involved in
LSDK, port the dts patches from 4.14.
The patches are sorted into the following categories:
301-arch-xxxx
302-dts-xxxx
303-core-xxxx
701-net-xxxx
801-audio-xxxx
802-can-xxxx
803-clock-xxxx
804-crypto-xxxx
805-display-xxxx
806-dma-xxxx
807-gpio-xxxx
808-i2c-xxxx
809-jailhouse-xxxx
810-keys-xxxx
811-kvm-xxxx
812-pcie-xxxx
813-pm-xxxx
814-qe-xxxx
815-sata-xxxx
816-sdhc-xxxx
817-spi-xxxx
818-thermal-xxxx
819-uart-xxxx
820-usb-xxxx
821-vfio-xxxx
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Diffstat (limited to 'target/linux/layerscape/patches-5.4/821-vfio-0004-vfio-fsl-mc-Implement-VFIO_DEVICE_GET_REGION_INFO-io.patch')
-rw-r--r-- | target/linux/layerscape/patches-5.4/821-vfio-0004-vfio-fsl-mc-Implement-VFIO_DEVICE_GET_REGION_INFO-io.patch | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/target/linux/layerscape/patches-5.4/821-vfio-0004-vfio-fsl-mc-Implement-VFIO_DEVICE_GET_REGION_INFO-io.patch b/target/linux/layerscape/patches-5.4/821-vfio-0004-vfio-fsl-mc-Implement-VFIO_DEVICE_GET_REGION_INFO-io.patch new file mode 100644 index 0000000000..c538ed0d5c --- /dev/null +++ b/target/linux/layerscape/patches-5.4/821-vfio-0004-vfio-fsl-mc-Implement-VFIO_DEVICE_GET_REGION_INFO-io.patch @@ -0,0 +1,153 @@ +From 10abb46294d1569826854f77bcdb5d38d8db8e79 Mon Sep 17 00:00:00 2001 +From: Diana Craciun <diana.craciun@nxp.com> +Date: Thu, 26 Sep 2019 15:13:24 +0300 +Subject: [PATCH] vfio/fsl-mc: Implement VFIO_DEVICE_GET_REGION_INFO ioctl call + +Expose to userspace information about the memory regions. + +Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com> +Signed-off-by: Diana Craciun <diana.craciun@nxp.com> +--- + drivers/vfio/fsl-mc/vfio_fsl_mc.c | 76 ++++++++++++++++++++++++++++++- + drivers/vfio/fsl-mc/vfio_fsl_mc_private.h | 19 ++++++++ + 2 files changed, 94 insertions(+), 1 deletion(-) + +--- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c ++++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c +@@ -16,16 +16,70 @@ + #include "vfio_fsl_mc_private.h" + + ++static int vfio_fsl_mc_regions_init(struct vfio_fsl_mc_device *vdev) ++{ ++ struct fsl_mc_device *mc_dev = vdev->mc_dev; ++ int count = mc_dev->obj_desc.region_count; ++ int i; ++ ++ vdev->regions = kcalloc(count, sizeof(struct vfio_fsl_mc_region), ++ GFP_KERNEL); ++ if (!vdev->regions) ++ return -ENOMEM; ++ ++ for (i = 0; i < count; i++) { ++ struct resource *res = &mc_dev->regions[i]; ++ ++ vdev->regions[i].addr = res->start; ++ vdev->regions[i].size = PAGE_ALIGN((resource_size(res))); ++ vdev->regions[i].flags = 0; ++ } ++ ++ vdev->num_regions = mc_dev->obj_desc.region_count; ++ return 0; ++} ++static void vfio_fsl_mc_regions_cleanup(struct vfio_fsl_mc_device *vdev) ++{ ++ vdev->num_regions = 0; ++ kfree(vdev->regions); ++} ++ + static int vfio_fsl_mc_open(void *device_data) + { ++ struct vfio_fsl_mc_device *vdev = device_data; ++ int ret; ++ + if (!try_module_get(THIS_MODULE)) + return -ENODEV; + ++ mutex_lock(&vdev->driver_lock); ++ if (!vdev->refcnt) { ++ ret = vfio_fsl_mc_regions_init(vdev); ++ if (ret) ++ goto err_reg_init; ++ } ++ vdev->refcnt++; ++ ++ mutex_unlock(&vdev->driver_lock); + return 0; ++ ++err_reg_init: ++ mutex_unlock(&vdev->driver_lock); ++ module_put(THIS_MODULE); ++ return ret; + } + + static void vfio_fsl_mc_release(void *device_data) + { ++ struct vfio_fsl_mc_device *vdev = device_data; ++ ++ mutex_lock(&vdev->driver_lock); ++ ++ if (!(--vdev->refcnt)) ++ vfio_fsl_mc_regions_cleanup(vdev); ++ ++ mutex_unlock(&vdev->driver_lock); ++ + module_put(THIS_MODULE); + } + +@@ -59,7 +113,26 @@ static long vfio_fsl_mc_ioctl(void *devi + } + case VFIO_DEVICE_GET_REGION_INFO: + { +- return -EINVAL; ++ struct vfio_region_info info; ++ ++ minsz = offsetofend(struct vfio_region_info, offset); ++ ++ if (copy_from_user(&info, (void __user *)arg, minsz)) ++ return -EFAULT; ++ ++ if (info.argsz < minsz) ++ return -EINVAL; ++ ++ if (info.index >= vdev->num_regions) ++ return -EINVAL; ++ ++ /* map offset to the physical address */ ++ info.offset = VFIO_FSL_MC_INDEX_TO_OFFSET(info.index); ++ info.size = vdev->regions[info.index].size; ++ info.flags = vdev->regions[info.index].flags; ++ ++ return copy_to_user((void __user *)arg, &info, minsz); ++ + } + case VFIO_DEVICE_GET_IRQ_INFO: + { +@@ -206,6 +279,7 @@ static int vfio_fsl_mc_probe(struct fsl_ + vfio_iommu_group_put(group, dev); + return ret; + } ++ mutex_init(&vdev->driver_lock); + + return ret; + } +--- a/drivers/vfio/fsl-mc/vfio_fsl_mc_private.h ++++ b/drivers/vfio/fsl-mc/vfio_fsl_mc_private.h +@@ -7,8 +7,27 @@ + #ifndef VFIO_FSL_MC_PRIVATE_H + #define VFIO_FSL_MC_PRIVATE_H + ++#define VFIO_FSL_MC_OFFSET_SHIFT 40 ++#define VFIO_FSL_MC_OFFSET_MASK (((u64)(1) << VFIO_FSL_MC_OFFSET_SHIFT) - 1) ++ ++#define VFIO_FSL_MC_OFFSET_TO_INDEX(off) (off >> VFIO_FSL_MC_OFFSET_SHIFT) ++ ++#define VFIO_FSL_MC_INDEX_TO_OFFSET(index) \ ++ ((u64)(index) << VFIO_FSL_MC_OFFSET_SHIFT) ++ ++struct vfio_fsl_mc_region { ++ u32 flags; ++ u32 type; ++ u64 addr; ++ resource_size_t size; ++}; ++ + struct vfio_fsl_mc_device { + struct fsl_mc_device *mc_dev; ++ int refcnt; ++ u32 num_regions; ++ struct vfio_fsl_mc_region *regions; ++ struct mutex driver_lock; + }; + + #endif /* VFIO_PCI_PRIVATE_H */ |