Commit c045ebb7 authored by James Bottomley's avatar James Bottomley Committed by James Bottomley

aic7xxx and aic79xx: fix sleeping while holding a lock

From: Luben Tuikov <luben_tuikov@adaptec.com>

Fix sleeping while holding a lock on host removal and on
killing the DV thread.
Signed-off-by: default avatarLuben Tuikov <luben_tuikov@adaptec.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 2207252b
...@@ -5270,7 +5270,6 @@ ahd_free(struct ahd_softc *ahd) ...@@ -5270,7 +5270,6 @@ ahd_free(struct ahd_softc *ahd)
default: default:
case 5: case 5:
ahd_shutdown(ahd); ahd_shutdown(ahd);
TAILQ_REMOVE(&ahd_tailq, ahd, links);
/* FALLTHROUGH */ /* FALLTHROUGH */
case 4: case 4:
ahd_dmamap_unload(ahd, ahd->shared_data_dmat, ahd_dmamap_unload(ahd, ahd->shared_data_dmat,
......
...@@ -5032,7 +5032,6 @@ static void __exit ...@@ -5032,7 +5032,6 @@ static void __exit
ahd_linux_exit(void) ahd_linux_exit(void)
{ {
struct ahd_softc *ahd; struct ahd_softc *ahd;
u_long l;
/* /*
* Shutdown DV threads before going into the SCSI mid-layer. * Shutdown DV threads before going into the SCSI mid-layer.
...@@ -5040,12 +5039,11 @@ ahd_linux_exit(void) ...@@ -5040,12 +5039,11 @@ ahd_linux_exit(void)
* kernel so that waiting for our DV threads to exit leads * kernel so that waiting for our DV threads to exit leads
* to deadlock. * to deadlock.
*/ */
ahd_list_lock(&l);
TAILQ_FOREACH(ahd, &ahd_tailq, links) { TAILQ_FOREACH(ahd, &ahd_tailq, links) {
ahd_linux_kill_dv_thread(ahd); ahd_linux_kill_dv_thread(ahd);
} }
ahd_list_unlock(&l);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
/* /*
* In 2.4 we have to unregister from the PCI core _after_ * In 2.4 we have to unregister from the PCI core _after_
......
...@@ -105,12 +105,14 @@ ahd_linux_pci_dev_remove(struct pci_dev *pdev) ...@@ -105,12 +105,14 @@ ahd_linux_pci_dev_remove(struct pci_dev *pdev)
if (ahd != NULL) { if (ahd != NULL) {
u_long s; u_long s;
TAILQ_REMOVE(&ahd_tailq, ahd, links);
ahd_list_unlock(&l);
ahd_lock(ahd, &s); ahd_lock(ahd, &s);
ahd_intr_enable(ahd, FALSE); ahd_intr_enable(ahd, FALSE);
ahd_unlock(ahd, &s); ahd_unlock(ahd, &s);
ahd_free(ahd); ahd_free(ahd);
} } else
ahd_list_unlock(&l); ahd_list_unlock(&l);
} }
static int static int
......
...@@ -3973,7 +3973,6 @@ ahc_free(struct ahc_softc *ahc) ...@@ -3973,7 +3973,6 @@ ahc_free(struct ahc_softc *ahc)
default: default:
case 5: case 5:
ahc_shutdown(ahc); ahc_shutdown(ahc);
TAILQ_REMOVE(&ahc_tailq, ahc, links);
/* FALLTHROUGH */ /* FALLTHROUGH */
case 4: case 4:
ahc_dmamap_unload(ahc, ahc->shared_data_dmat, ahc_dmamap_unload(ahc, ahc->shared_data_dmat,
......
...@@ -5033,7 +5033,6 @@ static void ...@@ -5033,7 +5033,6 @@ static void
ahc_linux_exit(void) ahc_linux_exit(void)
{ {
struct ahc_softc *ahc; struct ahc_softc *ahc;
u_long l;
/* /*
* Shutdown DV threads before going into the SCSI mid-layer. * Shutdown DV threads before going into the SCSI mid-layer.
...@@ -5041,12 +5040,10 @@ ahc_linux_exit(void) ...@@ -5041,12 +5040,10 @@ ahc_linux_exit(void)
* kernel so that waiting for our DV threads to exit leads * kernel so that waiting for our DV threads to exit leads
* to deadlock. * to deadlock.
*/ */
ahc_list_lock(&l);
TAILQ_FOREACH(ahc, &ahc_tailq, links) { TAILQ_FOREACH(ahc, &ahc_tailq, links) {
ahc_linux_kill_dv_thread(ahc); ahc_linux_kill_dv_thread(ahc);
} }
ahc_list_unlock(&l);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
/* /*
......
...@@ -160,12 +160,14 @@ ahc_linux_pci_dev_remove(struct pci_dev *pdev) ...@@ -160,12 +160,14 @@ ahc_linux_pci_dev_remove(struct pci_dev *pdev)
if (ahc != NULL) { if (ahc != NULL) {
u_long s; u_long s;
TAILQ_REMOVE(&ahc_tailq, ahc, links);
ahc_list_unlock(&l);
ahc_lock(ahc, &s); ahc_lock(ahc, &s);
ahc_intr_enable(ahc, FALSE); ahc_intr_enable(ahc, FALSE);
ahc_unlock(ahc, &s); ahc_unlock(ahc, &s);
ahc_free(ahc); ahc_free(ahc);
} } else
ahc_list_unlock(&l); ahc_list_unlock(&l);
} }
#endif /* !LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) */ #endif /* !LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment