diff options
author | Diana Craciun <diana.craciun@nxp.com> | 2019-11-18 16:32:08 +0200 |
---|---|---|
committer | Dong Aisheng <aisheng.dong@nxp.com> | 2021-11-02 17:20:05 +0800 |
commit | 053c79cd5d897b39d3659d46370e3b8917f92806 (patch) | |
tree | ca927983a8b6a8057ec9462163384ec3c36f27cc /drivers/vfio/fsl-mc | |
parent | 8bb7eca972ad531c9b149c0a51ab43a417385813 (diff) |
vfio/fsl-mc: Map the VFIO region according to the flags received from the mc firmware
There are some VFIO regions which are cacheable, non-shareable(e.g.
QMAN CENA region). These regions should be mapped cacheable
non-shareable.
Signed-off-by: Diana Craciun <diana.craciun@oss.nxp.com>
Diffstat (limited to 'drivers/vfio/fsl-mc')
-rw-r--r-- | drivers/vfio/fsl-mc/vfio_fsl_mc.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c index 0ead91bfa838..b69d26b18d0f 100644 --- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c @@ -50,6 +50,7 @@ static int vfio_fsl_mc_open_device(struct vfio_device *core_vdev) vdev->regions[i].flags |= VFIO_REGION_INFO_FLAG_READ; if (!(mc_dev->regions[i].flags & IORESOURCE_READONLY)) vdev->regions[i].flags |= VFIO_REGION_INFO_FLAG_WRITE; + vdev->regions[i].type = mc_dev->regions[i].flags & IORESOURCE_BITS; } return 0; @@ -346,7 +347,6 @@ static int vfio_fsl_mc_mmap_mmio(struct vfio_fsl_mc_region region, { u64 size = vma->vm_end - vma->vm_start; u64 pgoff, base; - u8 region_cacheable; pgoff = vma->vm_pgoff & ((1U << (VFIO_FSL_MC_OFFSET_SHIFT - PAGE_SHIFT)) - 1); @@ -355,9 +355,10 @@ static int vfio_fsl_mc_mmap_mmio(struct vfio_fsl_mc_region region, if (region.size < PAGE_SIZE || base + size > region.size) return -EINVAL; - region_cacheable = (region.type & FSL_MC_REGION_CACHEABLE) && - (region.type & FSL_MC_REGION_SHAREABLE); - if (!region_cacheable) + if (region.type & FSL_MC_REGION_CACHEABLE) { + if (!(region.type & FSL_MC_REGION_SHAREABLE)) + vma->vm_page_prot = pgprot_cached_ns(vma->vm_page_prot); + } else vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); vma->vm_pgoff = (region.addr >> PAGE_SHIFT) + pgoff; |