msm: kgsl: use readonly mappings on the iommu

Userspace passes a flag KGSL_MEMFLAGS_GPUREADONLY when
the gpu should not write to a memory region. Use this
flag to control IOMMU_WRITE permissions on the buffer.

Change-Id: I5d3fc615dc36687252e2242f63fe74d6ce1c4fbc
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Sakshi Agrawal <sakshia@codeaurora.org>
This commit is contained in:
Sakshi Agrawal 2012-09-25 09:56:11 -06:00 committed by Iliyan Malchev
parent b7fbe70a95
commit e503522454

View file

@ -1138,19 +1138,22 @@ kgsl_iommu_map(void *mmu_specific_pt,
unsigned int iommu_virt_addr;
struct kgsl_iommu_pt *iommu_pt = mmu_specific_pt;
int size = kgsl_sg_size(memdesc->sg, memdesc->sglen);
unsigned int iommu_flags = IOMMU_READ;
BUG_ON(NULL == iommu_pt);
if (protflags & GSL_PT_PAGE_WV)
iommu_flags |= IOMMU_WRITE;
iommu_virt_addr = memdesc->gpuaddr;
ret = iommu_map_range(iommu_pt->domain, iommu_virt_addr, memdesc->sg,
size, (IOMMU_READ | IOMMU_WRITE));
size, iommu_flags);
if (ret) {
KGSL_CORE_ERR("iommu_map_range(%p, %x, %p, %d, %d) "
"failed with err: %d\n", iommu_pt->domain,
iommu_virt_addr, memdesc->sg, size,
(IOMMU_READ | IOMMU_WRITE), ret);
iommu_flags, ret);
return ret;
}