[openib-general] Re: [PATCH] roland-uverbs: possible race condition

Roland Dreier roland at topspin.com
Thu Feb 3 11:46:01 PST 2005


Does this look reasonable?

Index: infiniband/hw/mthca/mthca_dev.h
===================================================================
--- infiniband/hw/mthca/mthca_dev.h	(revision 1732)
+++ infiniband/hw/mthca/mthca_dev.h	(working copy)
@@ -171,6 +171,7 @@ struct mthca_eq_table {
 	struct mthca_alloc alloc;
 	void __iomem      *clr_int;
 	u32                clr_mask;
+	u32                arm_mask;
 	struct mthca_eq    eq[MTHCA_NUM_EQ];
 	u64                icm_virt;
 	struct page       *icm_page;
Index: infiniband/hw/mthca/mthca_eq.c
===================================================================
--- infiniband/hw/mthca/mthca_eq.c	(revision 1732)
+++ infiniband/hw/mthca/mthca_eq.c	(working copy)
@@ -430,6 +430,7 @@ static irqreturn_t mthca_arbel_interrupt
 {
 	struct mthca_dev *dev = dev_ptr;
 	u32 arm = 0;
+	int work = 0;
 	int i;
 
 	if (dev->eq_table.clr_mask)
@@ -437,14 +438,14 @@ static irqreturn_t mthca_arbel_interrupt
 
 	for (i = 0; i < MTHCA_NUM_EQ; ++i)
 		if (mthca_eq_int(dev, &dev->eq_table.eq[i])) {
+			work = 1;
 			arbel_set_eq_ci(dev, &dev->eq_table.eq[i],
 					dev->eq_table.eq[i].cons_index);
-			arm |= dev->eq_table.eq[i].eqn_mask;
 		}
 
-	arbel_eq_req_not(dev, arm);
+	arbel_eq_req_not(dev, dev->eq_table.arm_mask);
 
-	return IRQ_RETVAL(arm);
+	return IRQ_RETVAL(work);
 }
 
 static irqreturn_t mthca_arbel_msi_x_interrupt(int irq, void *eq_ptr,
@@ -568,6 +569,8 @@ static int __devinit mthca_create_eq(str
 	eq->eqn_mask   = swab32(1 << eq->eqn);
 	eq->cons_index = 0;
 
+	dev->eq_table.arm_mask |= eq->eqn_mask;
+
 	mthca_dbg(dev, "Allocated EQ %d with %d entries\n",
 		  eq->eqn, nent);
 
@@ -618,6 +621,8 @@ static void mthca_free_eq(struct mthca_d
 		mthca_warn(dev, "HW2SW_EQ returned status 0x%02x\n",
 			   status);
 
+	dev->eq_table.arm_mask &= ~eq->eqn_mask;
+
 	if (0) {
 		mthca_dbg(dev, "Dumping EQ context %02x:\n", eq->eqn);
 		for (i = 0; i < sizeof (struct mthca_eq_context) / 4; ++i) {
@@ -846,6 +851,8 @@ int __devinit mthca_init_eq_table(struct
 			(dev->eq_table.inta_pin < 31 ? 4 : 0);
 	}
 
+	dev->eq_table.arm_mask = 0;
+
 	intr = (dev->mthca_flags & MTHCA_FLAG_MSI) ?
 		128 : dev->eq_table.inta_pin;
 



More information about the general mailing list