diff options
| author | Dmitry Osipenko <digetx@gmail.com> | 2019-03-06 17:50:09 -0500 |
|---|---|---|
| committer | Joerg Roedel <jroedel@suse.de> | 2019-04-11 08:51:37 -0400 |
| commit | 43d957b1334670a9b232f9a4a027d51e05155c83 (patch) | |
| tree | f68c419cc7ea3403100afe641bee0a3cab2afbfa | |
| parent | 4f97031ff8605c1e8388a650bc5708ceda4357d5 (diff) | |
iommu/tegra-smmu: Respect IOMMU API read-write protections
Set PTE read/write attributes accordingly to the the protections requested
by IOMMU API.
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
| -rw-r--r-- | drivers/iommu/tegra-smmu.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c index 27b1249f0773..463ee08f7d3a 100644 --- a/drivers/iommu/tegra-smmu.c +++ b/drivers/iommu/tegra-smmu.c | |||
| @@ -145,8 +145,6 @@ static inline u32 smmu_readl(struct tegra_smmu *smmu, unsigned long offset) | |||
| 145 | 145 | ||
| 146 | #define SMMU_PDE_ATTR (SMMU_PDE_READABLE | SMMU_PDE_WRITABLE | \ | 146 | #define SMMU_PDE_ATTR (SMMU_PDE_READABLE | SMMU_PDE_WRITABLE | \ |
| 147 | SMMU_PDE_NONSECURE) | 147 | SMMU_PDE_NONSECURE) |
| 148 | #define SMMU_PTE_ATTR (SMMU_PTE_READABLE | SMMU_PTE_WRITABLE | \ | ||
| 149 | SMMU_PTE_NONSECURE) | ||
| 150 | 148 | ||
| 151 | static unsigned int iova_pd_index(unsigned long iova) | 149 | static unsigned int iova_pd_index(unsigned long iova) |
| 152 | { | 150 | { |
| @@ -659,6 +657,7 @@ static int tegra_smmu_map(struct iommu_domain *domain, unsigned long iova, | |||
| 659 | { | 657 | { |
| 660 | struct tegra_smmu_as *as = to_smmu_as(domain); | 658 | struct tegra_smmu_as *as = to_smmu_as(domain); |
| 661 | dma_addr_t pte_dma; | 659 | dma_addr_t pte_dma; |
| 660 | u32 pte_attrs; | ||
| 662 | u32 *pte; | 661 | u32 *pte; |
| 663 | 662 | ||
| 664 | pte = as_get_pte(as, iova, &pte_dma); | 663 | pte = as_get_pte(as, iova, &pte_dma); |
| @@ -669,8 +668,16 @@ static int tegra_smmu_map(struct iommu_domain *domain, unsigned long iova, | |||
| 669 | if (*pte == 0) | 668 | if (*pte == 0) |
| 670 | tegra_smmu_pte_get_use(as, iova); | 669 | tegra_smmu_pte_get_use(as, iova); |
| 671 | 670 | ||
| 671 | pte_attrs = SMMU_PTE_NONSECURE; | ||
| 672 | |||
| 673 | if (prot & IOMMU_READ) | ||
| 674 | pte_attrs |= SMMU_PTE_READABLE; | ||
| 675 | |||
| 676 | if (prot & IOMMU_WRITE) | ||
| 677 | pte_attrs |= SMMU_PTE_WRITABLE; | ||
| 678 | |||
| 672 | tegra_smmu_set_pte(as, iova, pte, pte_dma, | 679 | tegra_smmu_set_pte(as, iova, pte, pte_dma, |
| 673 | __phys_to_pfn(paddr) | SMMU_PTE_ATTR); | 680 | __phys_to_pfn(paddr) | pte_attrs); |
| 674 | 681 | ||
| 675 | return 0; | 682 | return 0; |
| 676 | } | 683 | } |
