[PATCH 6/9] powerpc/powernv: Pass CPU-endian argument to xchg() in pnv_tce_xchg()

Gavin Shan gwshan at linux.vnet.ibm.com
Tue Aug 2 14:10:34 AEST 2016


This fixes warning reported from sparse:

  gwshan at gwshan:~/sandbox/l$ make C=2 CF=-D__CHECK_ENDIAN__ \
                             arch/powerpc/platforms/powernv/pci.o
  arch/powerpc/platforms/powernv/pci.c:740:18: \
  warning: cast from restricted __be64
  arch/powerpc/platforms/powernv/pci.c:740:18: \
  warning: cast to restricted __be64
  arch/powerpc/platforms/powernv/pci.c:740:18: \
  warning: cast from restricted __be64
  arch/powerpc/platforms/powernv/pci.c:740:18: \
  warning: cast to restricted __be64

Cc: Alexey Kardashevskiy <aik at ozlabs.ru>
Fixes: 802a345183c0 ("powerpc/powernv/ioda: Fix endianness when reading TCEs")
Signed-off-by: Gavin Shan <gwshan at linux.vnet.ibm.com>
---
 arch/powerpc/platforms/powernv/pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c
index 9a26a57..4e385f9 100644
--- a/arch/powerpc/platforms/powernv/pci.c
+++ b/arch/powerpc/platforms/powernv/pci.c
@@ -737,7 +737,9 @@ int pnv_tce_xchg(struct iommu_table *tbl, long index,
 	if (newtce & TCE_PCI_WRITE)
 		newtce |= TCE_PCI_READ;
 
-	oldtce = be64_to_cpu(xchg(pnv_tce(tbl, idx), cpu_to_be64(newtce)));
+	oldtce = be64_to_cpu((__force __be64)xchg(
+			(unsigned long *)pnv_tce(tbl, idx),
+			(__force unsigned long)cpu_to_be64(newtce)));
 	*hpa = oldtce & ~(TCE_PCI_READ | TCE_PCI_WRITE);
 	*direction = iommu_tce_direction(oldtce);
 
-- 
2.1.0



More information about the Linuxppc-dev mailing list