Skip to contentSkip to conversation

iommu: arm-smmu: avoid build warning

PATCH In review Arnd Bergmann 3 participants 3 messages Jan 30, 2015 – Feb 3, 2015 IOMMU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu: arm-smmu: avoid build warning

ARM allmodconfig gained a new warning when dma_addr_t is 32-bit wide:

drivers/iommu/arm-smmu.c: In function 'arm_smmu_iova_to_phys_hard':
drivers/iommu/arm-smmu.c:1255:3: warning: right shift count >= width of type

This changes the calculation so that the effective type is always 64-bit.

Fixes 859a732e4f713 ("iommu/arm-smmu: add support for iova_to_phys through ATS1PR")
drivers/iommu/arm-smmu.c +1 -1
index 1d6d43bb3395..fc13dd56953e 100644
@@ -1252,7 +1252,7 @@ static phys_addr_t arm_smmu_iova_to_phys_hard(struct iommu_domain *domain,
 	} else {
 		u32 reg = iova & ~0xfff;
 		writel_relaxed(reg, cb_base + ARM_SMMU_CB_ATS1PR_LO);
-		reg = (iova & ~0xfff) >> 32;
+		reg = ((u64)iova & ~0xfff) >> 32;
 		writel_relaxed(reg, cb_base + ARM_SMMU_CB_ATS1PR_HI);
 	}
 
Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines · Arnd Bergmann

ARM allmodconfig gained a new warning when dma_addr_t is 32-bit wide:

drivers/iommu/arm-smmu.c: In function 'arm_smmu_iova_to_phys_hard':
drivers/iommu/arm-smmu.c:1255:3: warning: right shift count >= width of type

This changes the calculation so that the effective type is always 64-bit.

Fixes 859a732e4f713 ("iommu/arm-smmu: add support for iova_to_phys through ATS1PR")
drivers/iommu/arm-smmu.c +0 -0
index 1d6d43bb3395..fc13dd56953e 100644

drivers/iommu/arm-smmu.c static phys_addr_t arm_smmu_iova_to_phys_hard(struct iommu_domain *domain, · line 1257

Quoted 7 lines
drivers/iommu/arm-smmu.c +1 -1
@@ -1252,7 +1252,7 @@ static phys_addr_t arm_smmu_iova_to_phys_hard(struct iommu_domain *domain,
 	} else {
 		u32 reg = iova & ~0xfff;
 		writel_relaxed(reg, cb_base + ARM_SMMU_CB_ATS1PR_LO);
-		reg = (iova & ~0xfff) >> 32;
+		reg = ((u64)iova & ~0xfff) >> 32;
 		writel_relaxed(reg, cb_base + ARM_SMMU_CB_ATS1PR_HI);
 	}

Thanks, Arnd.

Joerg, could you pick this one up directly please? I don't have any other ARM SMMU fixes queued at the moment.

Will

#2 lore raw
Quoted 8 lines · Will Deacon

drivers/iommu/arm-smmu.c static phys_addr_t arm_smmu_iova_to_phys_hard(struct iommu_domain *domain, · line 1257

Quoted 4 lines · Arnd Bergmann
drivers/iommu/arm-smmu.c +1 -1
-		reg = (iova & ~0xfff) >> 32;
+		reg = ((u64)iova & ~0xfff) >> 32;
 		writel_relaxed(reg, cb_base + ARM_SMMU_CB_ATS1PR_HI);
 	}

Thanks, Arnd.

Quoted 4 lines

Joerg, could you pick this one up directly please? I don't have any other ARM SMMU fixes queued at the moment.

Done, thanks.