[openib-general] [PATCH obvious] IB/verbs: fix 32-bit big endian platforms

Michael S. Tsirkin mst at mellanox.co.il
Tue Dec 19 00:20:35 PST 2006


ib_dma_alloc_coherent, introduced by 
commit 9b513090a3c5e4964f9ac09016c1586988abb3d5
is storing dma_handle through a pointer to u64.

This is broken on big-endian 32 bit platforms since the handle will land in
high-order bits of the qword.  And the compiler actually warns about passing
argument 3 of dma_alloc_coherent from incompatible pointer type.

Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 3c2e105..4214908 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1637,9 +1637,14 @@ static inline void *ib_dma_alloc_coherent(struct ib_device *dev,
 					   u64 *dma_handle,
 					   gfp_t flag)
 {
+	dma_addr_t a;
+	void *ptr;
 	if (dev->dma_ops)
 		return dev->dma_ops->alloc_coherent(dev, size, dma_handle, flag);
-	return dma_alloc_coherent(dev->dma_device, size, dma_handle, flag);
+	ptr = dma_alloc_coherent(dev->dma_device, size, &a, flag);
+	if (ptr)
+		*dma_handle = a;
+	return ptr;
 }
 
 /**

-- 
MST




More information about the general mailing list