From 6d6e598fac569f88b4348d1a8d8298c18641a204 Mon Sep 17 00:00:00 2001 From: Naman Padhiar Date: Sat, 30 Jan 2021 09:39:21 +0530 Subject: [PATCH] icnss2: Add support to enable IO Coherency Add support to enable IO Coherency based on DT property. Change-Id: I8de1b1cb6603c6852fe0f02b8b22806ad550bc48 Signed-off-by: Naman Padhiar --- drivers/soc/qcom/icnss2/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/soc/qcom/icnss2/main.c b/drivers/soc/qcom/icnss2/main.c index 816b2b8c9504..9897ad0f84a4 100644 --- a/drivers/soc/qcom/icnss2/main.c +++ b/drivers/soc/qcom/icnss2/main.c @@ -2859,6 +2859,8 @@ int icnss_smmu_map(struct device *dev, phys_addr_t paddr, uint32_t *iova_addr, size_t size) { struct icnss_priv *priv = dev_get_drvdata(dev); + int flag = IOMMU_READ | IOMMU_WRITE; + bool dma_coherent = false; unsigned long iova; int prop_len = 0; size_t len; @@ -2888,11 +2890,17 @@ int icnss_smmu_map(struct device *dev, return -ENOMEM; } + dma_coherent = of_property_read_bool(dev->of_node, "dma-coherent"); + icnss_pr_dbg("dma-coherent is %s\n", + dma_coherent ? "enabled" : "disabled"); + if (dma_coherent) + flag |= IOMMU_CACHE; + icnss_pr_dbg("IOMMU Map: iova %lx, len %zu\n", iova, len); ret = iommu_map(priv->iommu_domain, iova, rounddown(paddr, PAGE_SIZE), len, - IOMMU_READ | IOMMU_WRITE); + flag); if (ret) { icnss_pr_err("PA to IOVA mapping failed, ret %d\n", ret); return ret;