ath79/mikrotik: use routerbootpart partitions
[oweals/openwrt.git] / target / linux / layerscape / patches-5.4 / 821-vfio-0010-vfio-fsl-mc-Map-the-VFIO-region-according-to-the-fla.patch
1 From 41a18521d40ed19c2e22d8e41cc427d18f082b71 Mon Sep 17 00:00:00 2001
2 From: Diana Craciun <diana.craciun@nxp.com>
3 Date: Mon, 18 Nov 2019 16:32:08 +0200
4 Subject: [PATCH] vfio/fsl-mc: Map the VFIO region according to the flags
5  received from mc firmware
6
7 There are some VFIO regions which are cacheable (QMAN CENA region).
8 These regions should be mapped cacheable.
9
10 Signed-off-by: Diana Craciun <diana.craciun@nxp.com>
11 ---
12  drivers/vfio/fsl-mc/vfio_fsl_mc.c | 8 +++++++-
13  1 file changed, 7 insertions(+), 1 deletion(-)
14
15 --- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c
16 +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
17 @@ -106,6 +106,7 @@ static int vfio_fsl_mc_regions_init(stru
18                 vdev->regions[i].flags |= VFIO_REGION_INFO_FLAG_READ;
19                 if (!(mc_dev->regions[i].flags & IORESOURCE_READONLY))
20                         vdev->regions[i].flags |= VFIO_REGION_INFO_FLAG_WRITE;
21 +               vdev->regions[i].type = mc_dev->regions[i].flags & IORESOURCE_BITS;
22         }
23  
24         vdev->num_regions = mc_dev->obj_desc.region_count;
25 @@ -451,7 +452,12 @@ static int vfio_fsl_mc_mmap_mmio(struct
26         if (region.size < PAGE_SIZE || base + size > region.size)
27                 return -EINVAL;
28  
29 -       vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
30 +       if (region.type & DPRC_REGION_CACHEABLE) {
31 +               if (!(region.type & DPRC_REGION_SHAREABLE))
32 +                       vma->vm_page_prot = pgprot_cached_ns(vma->vm_page_prot);
33 +       } else
34 +               vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
35 +
36         vma->vm_pgoff = (region.addr >> PAGE_SHIFT) + pgoff;
37  
38         return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,