Skip to contentSkip to conversation

aic7xxx and aic79xx: fix sleeping while holding a lock and in DV thread

PATCH New Luben Tuikov 1 participant 1 message Oct 18, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aic7xxx and aic79xx: fix sleeping while holding a lock and in DV thread

Fix sleeping while holding a lock on host removal and on killing the DV thread.

(attached)

Thanks,
Luben

# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet

#   2004/10/13 15:55:49-04:00 [email protected] 
#   Fix sleeping while holding a lock on host removal and
#   on killing the DV thread.
# 
# drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
#   2004/10/13 15:55:36-04:00 [email protected] +4 -2
#   Fix sleeping while holding a lock on host removal.
# 
# drivers/scsi/aic7xxx/aic7xxx_osm.c
#   2004/10/13 15:55:35-04:00 [email protected] +0 -3
#   Fix sleeping while holding a lock on killing the DV thread.
# 
# drivers/scsi/aic7xxx/aic7xxx_core.c
#   2004/10/13 15:55:35-04:00 [email protected] +0 -1
#   Fix sleeping while holding a lock on host removal.
# 
# drivers/scsi/aic7xxx/aic79xx_osm_pci.c
#   2004/10/13 15:55:35-04:00 [email protected] +4 -2
#   Fix sleeping while holding a lock on host removal.
# 
# drivers/scsi/aic7xxx/aic79xx_osm.c
#   2004/10/13 15:55:35-04:00 [email protected] +1 -3
#   Fix sleeping while holding a lock on killing the DV thread.
# 
# drivers/scsi/aic7xxx/aic79xx_core.c
#   2004/10/13 15:55:35-04:00 [email protected] +0 -1
#   Fix sleeping while holding a lock on host removal.
# 
diff -Nru a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c
--- a/drivers/scsi/aic7xxx/aic79xx_core.c	2004-10-13 15:58:23 -04:00
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c	2004-10-13 15:58:23 -04:00
@@ -5270,7 +5270,6 @@
 	default:
 	case 5:
 		ahd_shutdown(ahd);
-		TAILQ_REMOVE(&ahd_tailq, ahd, links);
 		/* FALLTHROUGH */
 	case 4:
 		ahd_dmamap_unload(ahd, ahd->shared_data_dmat,
diff -Nru a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c	2004-10-13 15:58:23 -04:00
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c	2004-10-13 15:58:23 -04:00
@@ -5032,7 +5032,6 @@
 ahd_linux_exit(void)
 {
 	struct ahd_softc *ahd;
-	u_long l;

/*
* Shutdown DV threads before going into the SCSI mid-layer.
@@ -5040,12 +5039,11 @@
* kernel so that waiting for our DV threads to exit leads
* to deadlock.
*/
- ahd_list_lock(&l);
TAILQ_FOREACH(ahd, &ahd_tailq, links) {

ahd_linux_kill_dv_thread(ahd);
}
- ahd_list_unlock(&l);
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
/*
* In 2.4 we have to unregister from the PCI core _after_

drivers/scsi/aic7xxx/aic79xx_osm_pci.c +4 -2
diff -Nru a/drivers/scsi/aic7xxx/aic79xx_osm_pci.c b/drivers/scsi/aic7xxx/aic79xx_osm_pci.c
@@ -105,12 +105,14 @@
 	if (ahd != NULL) {
 		u_long s;
 
+		TAILQ_REMOVE(&ahd_tailq, ahd, links);
+		ahd_list_unlock(&l);
 		ahd_lock(ahd, &s);
 		ahd_intr_enable(ahd, FALSE);
 		ahd_unlock(ahd, &s);
 		ahd_free(ahd);
-	}
-	ahd_list_unlock(&l);
+	} else
+		ahd_list_unlock(&l);
 }
 
 static int
drivers/scsi/aic7xxx/aic7xxx_core.c +0 -1
diff -Nru a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -3973,7 +3973,6 @@
 	default:
 	case 5:
 		ahc_shutdown(ahc);
-		TAILQ_REMOVE(&ahc_tailq, ahc, links);
 		/* FALLTHROUGH */
 	case 4:
 		ahc_dmamap_unload(ahc, ahc->shared_data_dmat,
drivers/scsi/aic7xxx/aic7xxx_osm.c +0 -3
diff -Nru a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -5033,7 +5033,6 @@
 ahc_linux_exit(void)
 {
 	struct ahc_softc *ahc;
-	u_long l;
 
 	/*
 	 * Shutdown DV threads before going into the SCSI mid-layer.
@@ -5041,12 +5040,10 @@
 	 * kernel so that waiting for our DV threads to exit leads
 	 * to deadlock.
 	 */
-	ahc_list_lock(&l);
 	TAILQ_FOREACH(ahc, &ahc_tailq, links) {
 
 		ahc_linux_kill_dv_thread(ahc);
 	}
-	ahc_list_unlock(&l);
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 	/*
drivers/scsi/aic7xxx/aic7xxx_osm_pci.c +4 -2
diff -Nru a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
@@ -160,12 +160,14 @@
 	if (ahc != NULL) {
 		u_long s;
 
+		TAILQ_REMOVE(&ahc_tailq, ahc, links);
+		ahc_list_unlock(&l);
 		ahc_lock(ahc, &s);
 		ahc_intr_enable(ahc, FALSE);
 		ahc_unlock(ahc, &s);
 		ahc_free(ahc);
-	}
-	ahc_list_unlock(&l);
+	} else
+		ahc_list_unlock(&l);
 }
 #endif /* !LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) */