Commit 286f600b authored by Laurent Pinchart's avatar Laurent Pinchart

iommu/omap: Fix map protection value handling

The prot flags passed to the IOMMU map handler are defined in
include/linux/iommu.h as IOMMU_(READ|WRITE|CACHE|EXEC). However, the
driver expects to receive MMU_RAM_* OMAP-specific flags. This causes
IOMMU flags being interpreted as page sizes, leading to failures.

Hardcode the OMAP mapping parameters to little-endian, 8-bits and
non-mixed page attributes. Furthermore, as the OMAP IOMMU doesn't
support read-only or write-only mappings, ignore the prot value.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarSakari Ailus <sakari.ailus@iki.fi>
Acked-by: default avatarSuman Anna <s-anna@ti.com>
parent 67b779d2
...@@ -1041,8 +1041,7 @@ static void iopte_cachep_ctor(void *iopte) ...@@ -1041,8 +1041,7 @@ static void iopte_cachep_ctor(void *iopte)
clean_dcache_area(iopte, IOPTE_TABLE_SIZE); clean_dcache_area(iopte, IOPTE_TABLE_SIZE);
} }
static u32 iotlb_init_entry(struct iotlb_entry *e, u32 da, u32 pa, static u32 iotlb_init_entry(struct iotlb_entry *e, u32 da, u32 pa, int pgsz)
u32 flags)
{ {
memset(e, 0, sizeof(*e)); memset(e, 0, sizeof(*e));
...@@ -1050,10 +1049,10 @@ static u32 iotlb_init_entry(struct iotlb_entry *e, u32 da, u32 pa, ...@@ -1050,10 +1049,10 @@ static u32 iotlb_init_entry(struct iotlb_entry *e, u32 da, u32 pa,
e->pa = pa; e->pa = pa;
e->valid = MMU_CAM_V; e->valid = MMU_CAM_V;
/* FIXME: add OMAP1 support */ /* FIXME: add OMAP1 support */
e->pgsz = flags & MMU_CAM_PGSZ_MASK; e->pgsz = pgsz;
e->endian = flags & MMU_RAM_ENDIAN_MASK; e->endian = MMU_RAM_ENDIAN_LITTLE;
e->elsz = flags & MMU_RAM_ELSZ_MASK; e->elsz = MMU_RAM_ELSZ_8;
e->mixed = flags & MMU_RAM_MIXED_MASK; e->mixed = 0;
return iopgsz_to_bytes(e->pgsz); return iopgsz_to_bytes(e->pgsz);
} }
...@@ -1066,7 +1065,7 @@ static int omap_iommu_map(struct iommu_domain *domain, unsigned long da, ...@@ -1066,7 +1065,7 @@ static int omap_iommu_map(struct iommu_domain *domain, unsigned long da,
struct device *dev = oiommu->dev; struct device *dev = oiommu->dev;
struct iotlb_entry e; struct iotlb_entry e;
int omap_pgsz; int omap_pgsz;
u32 ret, flags; u32 ret;
omap_pgsz = bytes_to_iopgsz(bytes); omap_pgsz = bytes_to_iopgsz(bytes);
if (omap_pgsz < 0) { if (omap_pgsz < 0) {
...@@ -1076,9 +1075,7 @@ static int omap_iommu_map(struct iommu_domain *domain, unsigned long da, ...@@ -1076,9 +1075,7 @@ static int omap_iommu_map(struct iommu_domain *domain, unsigned long da,
dev_dbg(dev, "mapping da 0x%lx to pa 0x%x size 0x%x\n", da, pa, bytes); dev_dbg(dev, "mapping da 0x%lx to pa 0x%x size 0x%x\n", da, pa, bytes);
flags = omap_pgsz | prot; iotlb_init_entry(&e, da, pa, omap_pgsz);
iotlb_init_entry(&e, da, pa, flags);
ret = omap_iopgtable_store_entry(oiommu, &e); ret = omap_iopgtable_store_entry(oiommu, &e);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment