[openib-general] [PATCH] Being more anal about iospace accesses..

Roland Dreier roland at topspin.com
Mon Sep 20 19:50:31 PDT 2004


Thanks... I was meaning to do this once 2.6.9 comes out but it's great
to have it now.  I added a temporary #define to keep things building
against 2.6.8.1, like this:

 - R.

Index: infiniband/hw/mthca/mthca_dev.h
===================================================================
--- infiniband/hw/mthca/mthca_dev.h	(revision 862)
+++ infiniband/hw/mthca/mthca_dev.h	(working copy)
@@ -29,6 +29,14 @@
 #include <linux/pci.h>
 #include <asm/semaphore.h>
 
+/*
+ * Backwards compatibility for kernel 2.6.8.1.  Remove when 2.6.9 is
+ * officially released with support for __iomem annotations.
+ */
+#ifndef __iomem
+#define __iomem
+#endif
+
 #include "mthca_provider.h"
 #include "mthca_doorbell.h"
 
@@ -145,7 +153,7 @@
 
 struct mthca_eq_table {
 	struct mthca_alloc alloc;
-	unsigned long      clr_int;
+	void __iomem      *clr_int;
 	u32                clr_mask;
 	struct mthca_eq    eq[MTHCA_NUM_EQ];
 	int                have_irq;
@@ -169,7 +177,7 @@
 	struct pci_pool   *pool;
 	int                num_ddr_avs;
 	u64                ddr_av_base;
-	unsigned long      av_map;
+	void __iomem      *av_map;
 	struct mthca_alloc alloc;
 };
 
@@ -195,9 +203,9 @@
 
 	MTHCA_DECLARE_DOORBELL_LOCK(doorbell_lock)
 
-	unsigned long    hcr;
-	unsigned long    clr_base;
-	unsigned long    kar;
+	void __iomem    *hcr;
+	void __iomem    *clr_base;
+	void __iomem    *kar;
 
 	struct mthca_cmd    cmd;
 	struct mthca_limits limits;
Index: infiniband/hw/mthca/mthca_main.c
===================================================================
--- infiniband/hw/mthca/mthca_main.c	(revision 873)
+++ infiniband/hw/mthca/mthca_main.c	(working copy)
@@ -535,17 +535,15 @@
 	mdev->cmd.use_events = 0;
 
 	mthca_base = pci_resource_start(pdev, 0);
-	mdev->hcr = (unsigned long) ioremap(mthca_base + MTHCA_HCR_BASE,
-					    MTHCA_MAP_HCR_SIZE);
+	mdev->hcr = ioremap(mthca_base + MTHCA_HCR_BASE, MTHCA_MAP_HCR_SIZE);
 	if (!mdev->hcr) {
 		mthca_err(mdev, "Couldn't map command register, "
 			  "aborting.\n");
 		err = -ENOMEM;
 		goto err_out_free_dev;
 	}
-	mdev->clr_base =
-		(unsigned long) ioremap(mthca_base + MTHCA_CLR_INT_BASE,
-					MTHCA_CLR_INT_SIZE);
+	mdev->clr_base = ioremap(mthca_base + MTHCA_CLR_INT_BASE,
+				 MTHCA_CLR_INT_SIZE);
 	if (!mdev->clr_base) {
 		mthca_err(mdev, "Couldn't map command register, "
 			  "aborting.\n");
@@ -554,9 +552,7 @@
 	}
 
 	mthca_base = pci_resource_start(pdev, 2);
-	mdev->kar = (unsigned long) ioremap(mthca_base +
-					    PAGE_SIZE * MTHCA_KAR_PAGE,
-					    PAGE_SIZE);
+	mdev->kar = ioremap(mthca_base + PAGE_SIZE * MTHCA_KAR_PAGE, PAGE_SIZE);
 	if (!mdev->kar) {
 		mthca_err(mdev, "Couldn't map kernel access region, "
 			  "aborting.\n");
Index: infiniband/hw/mthca/mthca_av.c
===================================================================
--- infiniband/hw/mthca/mthca_av.c	(revision 824)
+++ infiniband/hw/mthca/mthca_av.c	(working copy)
@@ -175,12 +175,11 @@
 		goto out_free_alloc;
 
 	if (!(dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN)) {
-		dev->av_table.av_map =
-			(unsigned long) ioremap(pci_resource_start(dev->pdev, 4) +
-						dev->av_table.ddr_av_base -
-						dev->ddr_start,
-						dev->av_table.num_ddr_avs *
-						MTHCA_AV_SIZE);
+		dev->av_table.av_map = ioremap(pci_resource_start(dev->pdev, 4) +
+					       dev->av_table.ddr_av_base -
+					       dev->ddr_start,
+					       dev->av_table.num_ddr_avs *
+					       MTHCA_AV_SIZE);
 		if (!dev->av_table.av_map)
 			goto out_free_pool;
 	} else
Index: infiniband/hw/mthca/mthca_doorbell.h
===================================================================
--- infiniband/hw/mthca/mthca_doorbell.h	(revision 803)
+++ infiniband/hw/mthca/mthca_doorbell.h	(working copy)
@@ -42,7 +42,7 @@
 #define MTHCA_INIT_DOORBELL_LOCK(ptr)    do { } while (0)
 #define MTHCA_GET_DOORBELL_LOCK(ptr)      (0)
 
-static inline void mthca_write64(u32 val[2], unsigned long dest,
+static inline void mthca_write64(u32 val[2], void __iomem *dest,
 				 spinlock_t *doorbell_lock)
 {
 	writeq(cpu_to_le64p((u64 *) val), dest);
@@ -70,7 +70,7 @@
 	preempt_enable();
 }
 
-static inline void mthca_write64(u32 val[2], unsigned long dest,
+static inline void mthca_write64(u32 val[2], void __iomem *dest,
 				 spinlock_t *doorbell_lock)
 {
 	/* i386 stack is aligned to 8 bytes, so this should be OK: */
@@ -98,7 +98,7 @@
 #define MTHCA_INIT_DOORBELL_LOCK(ptr)     spin_lock_init(ptr)
 #define MTHCA_GET_DOORBELL_LOCK(ptr)      (ptr)
 
-static inline void mthca_write64(u32 val[2], unsigned long dest,
+static inline void mthca_write64(u32 val[2], void __iomem *dest,
 				 spinlock_t *doorbell_lock)
 {
 	unsigned long flags;



More information about the general mailing list