public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] aic94xx: Hotplug ex_change_count race fix
@ 2006-09-26 22:05 Alexis Bruemmer
  2006-10-03 14:19 ` James Bottomley
  0 siblings, 1 reply; 8+ messages in thread
From: Alexis Bruemmer @ 2006-09-26 22:05 UTC (permalink / raw)
  To: linux-scsi

In some cases while hotplugging disks on a system with an expander the
broadcast primitive will be posted and begin processing before the
expander change count is updated.  This causes the device that triggered
the broadcast to not be found.

--Alexis   



Signed-off-by: Alexis Bruemmer <alexisb@us.ibm.com>

-------

diff -pNura linux-2.6.18-git4-orig/drivers/scsi/libsas/sas_expander.c linux-2.6.18-git4/drivers/scsi/libsas/sas_expander.c
--- linux-2.6.18-git4-orig/drivers/scsi/libsas/sas_expander.c	2006-09-26 07:42:43.000000000 -0700
+++ linux-2.6.18-git4/drivers/scsi/libsas/sas_expander.c	2006-09-26 08:28:50.000000000 -0700
@@ -24,6 +24,7 @@
 
 #include <linux/pci.h>
 #include <linux/scatterlist.h>
+#include <linux/delay.h>
 
 #include "sas_internal.h"
 
@@ -1760,23 +1761,34 @@ out:
 int sas_ex_revalidate_domain(struct domain_device *port_dev)
 {
 	int res;
+	int i;
 	struct domain_device *dev = NULL;
 
-	res = sas_find_bcast_dev(port_dev, &dev);
-	if (res)
-		goto out;
-	if (dev) {
-		struct expander_device *ex = &dev->ex_dev;
-		int i = 0, phy_id;
-
-		do {
-			phy_id = -1;
-			res = sas_find_bcast_phy(dev, &phy_id, i);
-			if (phy_id == -1)
-				break;
-			res = sas_rediscover(dev, phy_id);
-			i = phy_id + 1;
-		} while (i < ex->num_phys);
+	
+	/* Some expanders seem to generate a BROADCAST primitive before
+	 * they actually update their own "expander change count" field!
+	 * If we didn't find a device that caused the BROADCAST
+	 * primitive, let us wait and retry.
+	 */
+	for (i = 0; i < 2; i++) {
+		res = sas_find_bcast_dev(port_dev, &dev);
+		if (res)
+			goto out;
+		if (dev) {
+			struct expander_device *ex = &dev->ex_dev;
+			int i = 0, phy_id;
+
+			do {
+				phy_id = -1;
+				res = sas_find_bcast_phy(dev, &phy_id, i);
+				if (phy_id == -1)
+					break;
+				res = sas_rediscover(dev, phy_id);
+				i = phy_id + 1;
+			} while (i < ex->num_phys);
+			break;
+		}
+		ssleep(1);
 	}
 out:
 	return res;



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-10-04 23:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-26 22:05 [PATCH] aic94xx: Hotplug ex_change_count race fix Alexis Bruemmer
2006-10-03 14:19 ` James Bottomley
2006-10-03 15:30   ` Alexis Bruemmer
2006-10-04 23:52     ` malahal
2006-10-03 20:52   ` Luben Tuikov
2006-10-03 21:18     ` Jeff Garzik
2006-10-04  2:29       ` Douglas Gilbert
2006-10-04  7:39       ` Luben Tuikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox