Skip to contentSkip to conversation

iommu: arm-smmu: Fix Tegra workaround for PAGE_SIZE mappings

PATCH Superseded Ashish Mhetre 2 participants 3 messages Jul 17, 2024 – Jul 24, 2024

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu: arm-smmu: Fix Tegra workaround for PAGE_SIZE mappings

PAGE_SIZE can be 16KB for Tegra which is not supported by MMU-500 on both Tegra194 and Tegra234. So, use 4KB mappings when PAGE_SIZE is 16KB.

---
 drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c +3 -2
index 4b2994b6126d..bb621a94f6fe 100644
@@ -273,11 +273,12 @@ static int nvidia_smmu_init_context(struct arm_smmu_domain *smmu_domain,
 	 * release of PMD entry and avoid translations seeing stale PMD entry in
 	 * walk cache.
 	 * Fix this by limiting the page mappings to PAGE_SIZE on Tegra194 and
-	 * Tegra234.
+	 * Tegra234. Use 4K page mappings if PAGE_SIZE is 16K as MMU500 doesn't
+	 * support it.
 	 */
 	if (of_device_is_compatible(np, "nvidia,tegra234-smmu") ||
 	    of_device_is_compatible(np, "nvidia,tegra194-smmu")) {
-		smmu->pgsize_bitmap = PAGE_SIZE;
+		smmu->pgsize_bitmap = (PAGE_SIZE == SZ_16K) ? SZ_4K : PAGE_SIZE;
 		pgtbl_cfg->pgsize_bitmap = smmu->pgsize_bitmap;
 	}
 
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 14 lines · Ashish Mhetre

PAGE_SIZE can be 16KB for Tegra which is not supported by MMU-500 on both Tegra194 and Tegra234. So, use 4KB mappings when PAGE_SIZE is 16KB.

---
 drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c +0 -0
index 4b2994b6126d..bb621a94f6fe 100644
@@ -273,11 +273,12 @@ static int nvidia_smmu_init_context(struct arm_smmu_domain *smmu_domain,
 	 * release of PMD entry and avoid translations seeing stale PMD entry in

drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c static int nvidia_smmu_init_context(struct arm_smmu_domain *smmu_domain, · line 281

Quoted 10 lines
drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c +3 -2
 	 * walk cache.
 	 * Fix this by limiting the page mappings to PAGE_SIZE on Tegra194 and
-	 * Tegra234.
+	 * Tegra234. Use 4K page mappings if PAGE_SIZE is 16K as MMU500 doesn't
+	 * support it.
 	 */
 	if (of_device_is_compatible(np, "nvidia,tegra234-smmu") ||
 	    of_device_is_compatible(np, "nvidia,tegra194-smmu")) {
-		smmu->pgsize_bitmap = PAGE_SIZE;
+		smmu->pgsize_bitmap = (PAGE_SIZE == SZ_16K) ? SZ_4K : PAGE_SIZE;

Perhaps it would be more robust to do a read-modify-write of the pgsize_bitmap, preserving all the page-sizes that are <= PAGE_SIZE (i.e. and it with something like GENMASK(PAGE_SHIFT, 0)?

Will

#2 lore raw
Quoted 32 lines · Will Deacon

External email: Use caution opening links or attachments

Quoted 14 lines · Ashish Mhetre

PAGE_SIZE can be 16KB for Tegra which is not supported by MMU-500 on both Tegra194 and Tegra234. So, use 4KB mappings when PAGE_SIZE is 16KB.

---
  drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c +0 -0
index 4b2994b6126d..bb621a94f6fe 100644
@@ -273,11 +273,12 @@ static int nvidia_smmu_init_context(struct arm_smmu_domain *smmu_domain,
        * release of PMD entry and avoid translations seeing stale PMD entry in

drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c static int nvidia_smmu_init_context(struct arm_smmu_domain *smmu_domain, · line 281

Quoted 10 lines
drivers/iommu/arm/arm-smmu/arm-smmu-nvidia.c +3 -2
        * walk cache.
        * Fix this by limiting the page mappings to PAGE_SIZE on Tegra194 and
-      * Tegra234.
+      * Tegra234. Use 4K page mappings if PAGE_SIZE is 16K as MMU500 doesn't
+      * support it.
        */
       if (of_device_is_compatible(np, "nvidia,tegra234-smmu") ||
           of_device_is_compatible(np, "nvidia,tegra194-smmu")) {
-             smmu->pgsize_bitmap = PAGE_SIZE;
+             smmu->pgsize_bitmap = (PAGE_SIZE == SZ_16K) ? SZ_4K : PAGE_SIZE;

Perhaps it would be more robust to do a read-modify-write of the pgsize_bitmap, preserving all the page-sizes that are <= PAGE_SIZE (i.e. and it with something like GENMASK(PAGE_SHIFT, 0)?

Quoted 1 line

Will

Thanks for the review Will. Yes, that will be a better approach as pgsize_bitmap will never be with 16K granularity for Tegra. I will send new version with this update.