diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2014-03-09 12:11:41 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2014-03-09 12:11:40 -0700 |
commit | 88322215dea618940facb12cc78669e625515b87 (patch) | |
tree | 4882a7515910479c9c13ee1e389c05de94eb9a9f /drivers/iommu | |
parent | 35016807aa24329266d8497911aec3ed80d0bb81 (diff) | |
parent | feedc93dc0728de6f6a85b69a099c9a3b7c6fcc7 (diff) |
Merge "iommu: msm: Use dma memory for secure pagetable"
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/msm_iommu_sec.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/iommu/msm_iommu_sec.c b/drivers/iommu/msm_iommu_sec.c index 5fca9e5eae5b..c6de1713bca7 100644 --- a/drivers/iommu/msm_iommu_sec.c +++ b/drivers/iommu/msm_iommu_sec.c @@ -26,6 +26,7 @@ #include <linux/of.h> #include <linux/of_device.h> #include <linux/kmemleak.h> +#include <linux/dma-mapping.h> #include <soc/qcom/scm.h> #include <asm/cacheflush.h> @@ -330,11 +331,15 @@ static int msm_iommu_sec_ptbl_init(void) unsigned int size; unsigned int spare; } pinit; - unsigned int *buf; int psize[2] = {0, 0}; unsigned int spare; int ret, ptbl_ret = 0; int version; + /* Use a dummy device for dma_alloc_coherent allocation */ + struct device dev = { 0 }; + void *cpu_addr; + dma_addr_t paddr; + DEFINE_DMA_ATTRS(attrs); for_each_matching_node(np, msm_smmu_list) if (of_find_property(np, "qcom,iommu-secure-id", NULL) && @@ -377,15 +382,17 @@ static int msm_iommu_sec_ptbl_init(void) goto fail; } - buf = kmalloc(psize[0], GFP_KERNEL); - if (!buf) { + dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &attrs); + dev.coherent_dma_mask = DMA_BIT_MASK(sizeof(dma_addr_t) * 8); + cpu_addr = dma_alloc_attrs(&dev, psize[0], &paddr, GFP_KERNEL, &attrs); + if (!cpu_addr) { pr_err("%s: Failed to allocate %d bytes for PTBL\n", __func__, psize[0]); ret = -ENOMEM; goto fail; } - pinit.paddr = virt_to_phys(buf); + pinit.paddr = (unsigned int)paddr; pinit.size = psize[0]; ret = scm_call(SCM_SVC_MP, IOMMU_SECURE_PTBL_INIT, &pinit, @@ -399,12 +406,10 @@ static int msm_iommu_sec_ptbl_init(void) goto fail_mem; } - kmemleak_not_leak(buf); - return 0; fail_mem: - kfree(buf); + dma_free_coherent(&dev, psize[0], cpu_addr, paddr); fail: return ret; } |