[SCSI] allow sleeping in ->eh_host_reset_handler()
authorJeff Garzik <jgarzik@pobox.com>
Sat, 28 May 2005 11:57:14 +0000 (07:57 -0400)
committerJeff Garzik <jgarzik@pobox.com>
Fri, 17 Jun 2005 17:05:18 +0000 (12:05 -0500)
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
38 files changed:
Documentation/scsi/scsi_mid_low_api.txt
drivers/fc4/fc.c
drivers/fc4/fc_syms.c
drivers/fc4/fcp_impl.h
drivers/message/fusion/mptscsih.c
drivers/s390/scsi/zfcp_scsi.c
drivers/scsi/3w-9xxx.c
drivers/scsi/3w-xxxx.c
drivers/scsi/53c700.c
drivers/scsi/BusLogic.c
drivers/scsi/NCR53c406a.c
drivers/scsi/a2091.c
drivers/scsi/a3000.c
drivers/scsi/aacraid/linit.c
drivers/scsi/aha1542.c
drivers/scsi/aic7xxx_old.c
drivers/scsi/arm/fas216.c
drivers/scsi/dpt_i2o.c
drivers/scsi/eata.c
drivers/scsi/eata_pio.c
drivers/scsi/gvp11.c
drivers/scsi/ibmmca.c
drivers/scsi/ide-scsi.c
drivers/scsi/ipr.c
drivers/scsi/ips.c
drivers/scsi/mac53c94.c
drivers/scsi/mesh.c
drivers/scsi/mvme147.c
drivers/scsi/nsp32.c
drivers/scsi/pcmcia/sym53c500_cs.c
drivers/scsi/qla1280.c
drivers/scsi/qla2xxx/qla_os.c
drivers/scsi/scsi_error.c
drivers/scsi/sgiwd93.c
drivers/scsi/sym53c416.c
drivers/scsi/sym53c8xx_2/sym_glue.c
drivers/scsi/u14-34f.c
drivers/scsi/wd7000.c

index 5a066afcc672b8437c0406fae2cbf5ce7980a47d..da176c95d0fb62618ff5c3684f5768a935f9dd0f 100644 (file)
@@ -990,8 +990,7 @@ Details:
  *
  *      Returns SUCCESS if command aborted else FAILED
  *
- *      Locks: struct Scsi_Host::host_lock held (with irqsave) on entry
- *      and assumed to be held on return.
+ *      Locks: None held
  *
  *      Calling context: kernel thread
  *
index cdea598d0c1b9d12a9b00293bcbd2fcf8fe547d7..fbd9ff79b7b8cb98bdfa5b788033909e84b5b399 100644 (file)
@@ -1005,13 +1005,7 @@ int fcp_scsi_dev_reset(Scsi_Cmnd *SCpnt)
        return SUCCESS;
 }
 
-int fcp_scsi_bus_reset(Scsi_Cmnd *SCpnt)
-{
-       printk ("FC: bus reset!\n");
-       return FAILED;
-}
-
-int fcp_scsi_host_reset(Scsi_Cmnd *SCpnt)
+static int __fcp_scsi_host_reset(Scsi_Cmnd *SCpnt)
 {
        fc_channel *fc = FC_SCMND(SCpnt);
        fcp_cmnd *fcmd = FCP_CMND(SCpnt);
@@ -1032,6 +1026,17 @@ int fcp_scsi_host_reset(Scsi_Cmnd *SCpnt)
        else return FAILED;
 }
 
+int fcp_scsi_host_reset(Scsi_Cmnd *SCpnt)
+{
+       int rc;
+
+       spin_lock_irqsave(SCpnt->device->host->host_lock, flags);
+       rc = __fcp_scsi_host_reset(SCpnt);
+       spin_unlock_irqrestore(SCpnt->device->host->host_lock, flags);
+
+       return rc;
+}
+
 static int fcp_els_queue_it(fc_channel *fc, fcp_cmnd *fcmd)
 {
        long i;
index 8bac2c453027f836d951bcc70912b3a207b10dbf..ed85dfcef69a403ab84120824e248784a4acab3e 100644 (file)
@@ -27,7 +27,6 @@ EXPORT_SYMBOL(fc_do_prli);
 EXPORT_SYMBOL(fcp_scsi_queuecommand);
 EXPORT_SYMBOL(fcp_scsi_abort);
 EXPORT_SYMBOL(fcp_scsi_dev_reset);
-EXPORT_SYMBOL(fcp_scsi_bus_reset);
 EXPORT_SYMBOL(fcp_scsi_host_reset);
 
 #endif /* CONFIG_MODULES */
index e44d652a83dc055ba1a24118b26d78518bc99b33..c397c84bef635668f4e3e8c79e51de0695d43812 100644 (file)
@@ -158,7 +158,6 @@ int fc_do_prli(fc_channel *, unsigned char);
 int fcp_scsi_queuecommand(Scsi_Cmnd *, void (* done)(Scsi_Cmnd *));
 int fcp_scsi_abort(Scsi_Cmnd *);
 int fcp_scsi_dev_reset(Scsi_Cmnd *);
-int fcp_scsi_bus_reset(Scsi_Cmnd *);
 int fcp_scsi_host_reset(Scsi_Cmnd *);
 
 #endif /* !(_FCP_SCSI_H) */
index efae9be453706a4c53c0070f23ae9aa9bdc0eba8..48ff314cdfbf81e6264d9d1c2380bb2c69ad5fb8 100644 (file)
@@ -1899,7 +1899,6 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
 {
        MPT_SCSI_HOST *  hd;
        int              status = SUCCESS;
-       spinlock_t      *host_lock = SCpnt->device->host->host_lock;
 
        /*  If we can't locate the host to reset, then we failed. */
        if ((hd = (MPT_SCSI_HOST *) SCpnt->device->host->hostdata) == NULL){
@@ -1915,7 +1914,6 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
        /*  If our attempts to reset the host failed, then return a failed
         *  status.  The host will be taken off line by the SCSI mid-layer.
         */
-       spin_unlock_irq(host_lock);
        if (mpt_HardResetHandler(hd->ioc, CAN_SLEEP) < 0){
                status = FAILED;
        } else {
@@ -1925,8 +1923,6 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
                hd->tmPending = 0;
                hd->tmState = TM_STATE_NONE;
        }
-       spin_lock_irq(host_lock);
-
 
        dtmprintk( ( KERN_WARNING MYNAM ": mptscsih_host_reset: "
                     "Status = %s\n",
index ac5a5da434b342ff465343249eed7d95ba753b6d..6965992ddbbf73e7da5b0eeadc4509c0bc694822 100644 (file)
@@ -755,8 +755,6 @@ zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt)
        struct zfcp_unit *unit;
        struct Scsi_Host *scsi_host = scpnt->device->host;
 
-       spin_unlock_irq(scsi_host->host_lock);
-
        unit = (struct zfcp_unit *) scpnt->device->hostdata;
        ZFCP_LOG_NORMAL("host reset because of problems with "
                        "unit 0x%016Lx\n", unit->fcp_lun);
@@ -764,7 +762,6 @@ zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt)
        zfcp_erp_wait(unit->port->adapter);
        retval = SUCCESS;
 
-       spin_lock_irq(scsi_host->host_lock);
        return retval;
 }
 
index a2b18f5a4f9305af289e0eb750ad457f2152169f..34dbc37a79d4991f8b40d9e61ad01c32b07000a9 100644 (file)
@@ -1695,8 +1695,6 @@ static int twa_scsi_eh_reset(struct scsi_cmnd *SCpnt)
 
        tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
 
-       spin_unlock_irq(tw_dev->host->host_lock);
-
        tw_dev->num_resets++;
 
        printk(KERN_WARNING "3w-9xxx: scsi%d: WARNING: (0x%02X:0x%04X): Unit #%d: Command (0x%x) timed out, resetting card.\n", tw_dev->host->host_no, TW_DRIVER, 0x2c, SCpnt->device->id, SCpnt->cmnd[0]);
@@ -1709,7 +1707,6 @@ static int twa_scsi_eh_reset(struct scsi_cmnd *SCpnt)
 
        retval = SUCCESS;
 out:
-       spin_lock_irq(tw_dev->host->host_lock);
        return retval;
 } /* End twa_scsi_eh_reset() */
 
index 48f9ece1cbd0912237a3150c19410db31c6400a8..b6dc576da4306f28f861ffe853bb536444410627 100644 (file)
@@ -1430,8 +1430,6 @@ static int tw_scsi_eh_reset(struct scsi_cmnd *SCpnt)
 
        tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
 
-       spin_unlock_irq(tw_dev->host->host_lock);
-
        tw_dev->num_resets++;
 
        printk(KERN_WARNING "3w-xxxx: scsi%d: WARNING: Unit #%d: Command (0x%x) timed out, resetting card.\n", tw_dev->host->host_no, SCpnt->device->id, SCpnt->cmnd[0]);
@@ -1444,7 +1442,6 @@ static int tw_scsi_eh_reset(struct scsi_cmnd *SCpnt)
 
        retval = SUCCESS;
 out:
-       spin_lock_irq(tw_dev->host->host_lock);
        return retval;
 } /* End tw_scsi_eh_reset() */
 
index 47cf9bd55d90cf17bedcae92ae5dc944c5e1d26c..d151af9a6f15f4ee278aebcfeeb69f5589663ca7 100644 (file)
@@ -1991,8 +1991,13 @@ NCR_700_host_reset(struct scsi_cmnd * SCp)
               SCp->device->host->host_no, SCp->device->id, SCp->device->lun);
        scsi_print_command(SCp);
 
+       spin_lock_irq(SCp->device->host->host_lock);
+
        NCR_700_internal_bus_reset(SCp->device->host);
        NCR_700_chip_reset(SCp->device->host);
+
+       spin_unlock_irq(SCp->device->host->host_lock);
+
        return SUCCESS;
 }
 
index 15e4b122d56e93c4330fbbfd1871e6d2c164b7a0..9d6040bfa0646ae32283be9f1ffde0e974172594 100644 (file)
@@ -2746,9 +2746,15 @@ static int BusLogic_host_reset(struct scsi_cmnd * SCpnt)
 
        unsigned int id = SCpnt->device->id;
        struct BusLogic_TargetStatistics *stats = &HostAdapter->TargetStatistics[id];
+       int rc;
+
+       spin_lock_irq(SCpnt->device->host->host_lock);
+
        BusLogic_IncrementErrorCounter(&stats->HostAdapterResetsRequested);
 
-       return BusLogic_ResetHostAdapter(HostAdapter, false);
+       rc = BusLogic_ResetHostAdapter(HostAdapter, false);
+       spin_unlock_irq(SCpnt->device->host->host_lock);
+       return rc;
 }
 
 /*
index 7c025b6cdd7ccf167bf578198652dbe218fdb254..b2002ba6e2aa4ce928f85499db9a5ab7ee14d4ac 100644 (file)
@@ -725,6 +725,9 @@ static int NCR53c406a_queue(Scsi_Cmnd * SCpnt, void (*done) (Scsi_Cmnd *))
 static int NCR53c406a_host_reset(Scsi_Cmnd * SCpnt)
 {
        DEB(printk("NCR53c406a_reset called\n"));
+
+       spin_lock_irq(SCpnt->device->host->host_lock);
+
        outb(C4_IMG, CONFIG4);  /* Select reg set 0 */
        outb(CHIP_RESET, CMD_REG);
        outb(SCSI_NOP, CMD_REG);        /* required after reset */
@@ -732,6 +735,9 @@ static int NCR53c406a_host_reset(Scsi_Cmnd * SCpnt)
        chip_init();
 
        rtrc(2);
+
+       spin_unlock_irq(SCpnt->device->host->host_lock);
+
        return SUCCESS;
 }
 
index ce3c37610c5c26b7b582cc5402ce178e32432250..f7a1751e892dc34b18376313213f087e0a4998c4 100644 (file)
@@ -222,6 +222,9 @@ static int a2091_bus_reset(Scsi_Cmnd *cmd)
 {
        /* FIXME perform bus-specific reset */
 
+       /* FIXME 2: kill this function, and let midlayer fall back
+          to the same action, calling wd33c93_host_reset() */
+
        spin_lock_irq(cmd->device->host->host_lock);
        wd33c93_host_reset(cmd);
        spin_unlock_irq(cmd->device->host->host_lock);
index 92698f3355912501905607d7543c479d31cd2e7c..306caf56f3d9eaad59dea2916c42ca406abc5f67 100644 (file)
@@ -208,6 +208,9 @@ fail_register:
 static int a3000_bus_reset(Scsi_Cmnd *cmd)
 {
        /* FIXME perform bus-specific reset */
+       
+       /* FIXME 2: kill this entire function, which should
+          cause mid-layer to call wd33c93_host_reset anyway? */
 
        spin_lock_irq(cmd->device->host->host_lock);
        wd33c93_host_reset(cmd);
index b48843402cf423d01581764fe5219055db0f0af0..f7e9c89c491548ce40080d0c355f4b0f98492602 100644 (file)
@@ -384,10 +384,13 @@ static int aac_eh_reset(struct scsi_cmnd* cmd)
                                        AAC_DRIVERNAME);
 
 
+       spin_lock_irq(host->host_lock);
+
        aac = (struct aac_dev *)host->hostdata;
        if (aac_adapter_check_health(aac)) {
                printk(KERN_ERR "%s: Host adapter appears dead\n", 
                                AAC_DRIVERNAME);
+               spin_unlock_irq(host->host_lock);
                return -ENODEV;
        }
        /*
@@ -418,6 +421,7 @@ static int aac_eh_reset(struct scsi_cmnd* cmd)
                ssleep(1);
                spin_lock_irq(host->host_lock);
        }
+       spin_unlock_irq(host->host_lock);
        printk(KERN_ERR "%s: SCSI bus appears hung\n", AAC_DRIVERNAME);
        return -ETIMEDOUT;
 }
index f911b51e3042087561e6019053105e6892f05005..9ec4641a634899fe03089af6e88e6106863fa190 100644 (file)
@@ -1530,7 +1530,6 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt)
         * check for timeout, and if we are doing something like this
         * we are pretty desperate anyways.
         */
-       spin_unlock_irq(SCpnt->device->host->host_lock);
        ssleep(4);
        spin_lock_irq(SCpnt->device->host->host_lock);
 
@@ -1574,9 +1573,11 @@ static int aha1542_host_reset(Scsi_Cmnd * SCpnt)
                }
        }
 
+       spin_unlock_irq(SCpnt->device->host->host_lock);
        return SUCCESS;
 
 fail:
+       spin_unlock_irq(SCpnt->device->host->host_lock);
        return FAILED;
 }
 
index 1e83096bb9112ca26ff48015b8279383ebcfcdcf..fac091e7093c2e490d789704eaa9afdf6cf583ba 100644 (file)
@@ -10845,6 +10845,8 @@ aic7xxx_reset(Scsi_Cmnd *cmd)
   struct aic_dev_data *aic_dev;
 
   p = (struct aic7xxx_host *) cmd->device->host->hostdata;
+  spin_lock_irq(p->host->host_lock);
+
   aic_dev = AIC_DEV(cmd);
   if(aic7xxx_position(cmd) < p->scb_data->numscbs)
   {
@@ -10884,6 +10886,7 @@ aic7xxx_reset(Scsi_Cmnd *cmd)
      * longer have it.
      */
     unpause_sequencer(p, FALSE);
+    spin_unlock_irq(p->host->host_lock);
     return SUCCESS;
   }
     
@@ -10907,7 +10910,6 @@ aic7xxx_reset(Scsi_Cmnd *cmd)
   unpause_sequencer(p, FALSE);
   spin_unlock_irq(p->host->host_lock);
   ssleep(2);
-  spin_lock_irq(p->host->host_lock);
   return SUCCESS;
 }
 
index 3838f88e1fe01ee38166b9bba6093520d6cf0728..4772fb317f3e5d9aa5f603e7e30d98b09e64a33a 100644 (file)
@@ -2659,6 +2659,8 @@ int fas216_eh_host_reset(Scsi_Cmnd *SCpnt)
 {
        FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata;
 
+       spin_lock_irq(info->host->host_lock);
+
        fas216_checkmagic(info);
 
        printk("scsi%d.%c: %s: resetting host\n",
@@ -2686,6 +2688,7 @@ int fas216_eh_host_reset(Scsi_Cmnd *SCpnt)
 
        fas216_init_chip(info);
 
+       spin_unlock_irq(info->host->host_lock);
        return SUCCESS;
 }
 
index 2fd728731d5ed37cc519f154e419e4bfb366c052..9cc0015b717d7aa0c97c5ca054f959289e650c62 100644 (file)
@@ -746,7 +746,7 @@ static int adpt_bus_reset(struct scsi_cmnd* cmd)
 }
 
 // This version of reset is called by the eh_error_handler
-static int adpt_reset(struct scsi_cmnd* cmd)
+static int __adpt_reset(struct scsi_cmnd* cmd)
 {
        adpt_hba* pHba;
        int rcode;
@@ -762,6 +762,17 @@ static int adpt_reset(struct scsi_cmnd* cmd)
        }
 }
 
+static int adpt_reset(struct scsi_cmnd* cmd)
+{
+       int rc;
+
+       spin_lock_irq(cmd->device->host->host_lock);
+       rc = __adpt_reset(cmd);
+       spin_unlock_irq(cmd->device->host->host_lock);
+
+       return rc;
+}
+
 // This version of reset is called by the ioctls and indirectly from eh_error_handler via adpt_reset
 static int adpt_hba_reset(adpt_hba* pHba)
 {
index 8394529ba552f0e6ba5c831b730b78393250f73d..1bb8727eea3e5a2a2a7984bc7922451127c93426 100644 (file)
@@ -1948,16 +1948,20 @@ static int eata2x_eh_host_reset(struct scsi_cmnd *SCarg)
               ha->board_name, SCarg->device->channel, SCarg->device->id,
               SCarg->device->lun, SCarg->pid);
 
+       spin_lock_irq(shost->host_lock);
+
        if (SCarg->host_scribble == NULL)
                printk("%s: reset, pid %ld inactive.\n", ha->board_name, SCarg->pid);
 
        if (ha->in_reset) {
                printk("%s: reset, exit, already in reset.\n", ha->board_name);
+               spin_unlock_irq(shost->host_lock);
                return FAILED;
        }
 
        if (wait_on_busy(shost->io_port, MAXLOOP)) {
                printk("%s: reset, exit, timeout error.\n", ha->board_name);
+               spin_unlock_irq(shost->host_lock);
                return FAILED;
        }
 
@@ -2012,6 +2016,7 @@ static int eata2x_eh_host_reset(struct scsi_cmnd *SCarg)
 
        if (do_dma(shost->io_port, 0, RESET_PIO)) {
                printk("%s: reset, cannot reset, timeout error.\n", ha->board_name);
+               spin_unlock_irq(shost->host_lock);
                return FAILED;
        }
 
@@ -2024,9 +2029,12 @@ static int eata2x_eh_host_reset(struct scsi_cmnd *SCarg)
        ha->in_reset = 1;
 
        spin_unlock_irq(shost->host_lock);
+
+       /* FIXME: use a sleep instead */
        time = jiffies;
        while ((jiffies - time) < (10 * HZ) && limit++ < 200000)
                udelay(100L);
+
        spin_lock_irq(shost->host_lock);
 
        printk("%s: reset, interrupts disabled, loops %d.\n", ha->board_name, limit);
@@ -2076,6 +2084,7 @@ static int eata2x_eh_host_reset(struct scsi_cmnd *SCarg)
        else
                printk("%s: reset, exit.\n", ha->board_name);
 
+       spin_unlock_irq(shost->host_lock);
        return SUCCESS;
 }
 
index 0ee49dc50b85fd4dd6b32b5862e9edc44b5e2cde..04a06b71a5e23666956fd0bae203ada2ee959c7c 100644 (file)
@@ -486,8 +486,11 @@ static int eata_pio_host_reset(struct scsi_cmnd *cmd)
 
        DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset called pid:%ld target:" " %x lun: %x reason %x\n", cmd->pid, cmd->device->id, cmd->device->lun, cmd->abort_reason));
 
+       spin_lock_irq(host->host_lock);
+
        if (HD(cmd)->state == RESET) {
                printk(KERN_WARNING "eata_pio_reset: exit, already in reset.\n");
+               spin_unlock_irq(host->host_lock);
                return FAILED;
        }
 
@@ -536,6 +539,8 @@ static int eata_pio_host_reset(struct scsi_cmnd *cmd)
 
        HD(cmd)->state = 0;
 
+       spin_unlock_irq(host->host_lock);
+
        if (success) {          /* hmmm... */
                DBG(DBG_ABNORM, printk(KERN_WARNING "eata_pio_reset: exit, success.\n"));
                return SUCCESS;
index 66990af1dc9c0c0f0af446bd5380857a4b93560e..d12342fa81999e5938313cbb9f33734a63f44998 100644 (file)
@@ -346,6 +346,10 @@ static int gvp11_bus_reset(Scsi_Cmnd *cmd)
 {
        /* FIXME perform bus-specific reset */
 
+       /* FIXME 2: shouldn't we no-op this function (return
+          FAILED), and fall back to host reset function,
+          wd33c93_host_reset ? */
+
        spin_lock_irq(cmd->device->host->host_lock);
        wd33c93_host_reset(cmd);
        spin_unlock_irq(cmd->device->host->host_lock);
index 0018fb5c09a94ce9df57c0a4640a1d1f14f4d225..b5dc3535557079d368444aa136f1ff28fcdae3ca 100644 (file)
@@ -2237,7 +2237,7 @@ static int ibmmca_abort(Scsi_Cmnd * cmd)
        return rc;
 }
 
-static int ibmmca_host_reset(Scsi_Cmnd * cmd)
+static int __ibmmca_host_reset(Scsi_Cmnd * cmd)
 {
        struct Scsi_Host *shpnt;
        Scsi_Cmnd *cmd_aid;
@@ -2324,6 +2324,18 @@ static int ibmmca_host_reset(Scsi_Cmnd * cmd)
        return SUCCESS;
 }
 
+static int ibmmca_host_reset(Scsi_Cmnd * cmd)
+{
+       struct Scsi_Host *shpnt = cmd->device->host;
+       int rc;
+
+       spin_lock_irq(shpnt->host_lock);
+       rc = __ibmmca_host_reset(cmd);
+       spin_unlock_irq(shpnt->host_lock);
+
+       return rc;
+}
+
 static int ibmmca_biosparam(struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int *info)
 {
        int size = capacity;
index 83f062ed9082ac7e91e0dca720e3c57bd5a01ea7..3d62c9bcbff76931584364de2743060f9d398d68 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/slab.h>
 #include <linux/ide.h>
 #include <linux/scatterlist.h>
+#include <linux/delay.h>
 
 #include <asm/io.h>
 #include <asm/bitops.h>
@@ -1026,11 +1027,13 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd)
                return FAILED;
        }
 
-       spin_lock_irq(&ide_lock);
+       spin_lock_irq(cmd->device->host->host_lock);
+       spin_lock(&ide_lock);
 
        if (!scsi->pc || (req = scsi->pc->rq) != HWGROUP(drive)->rq || !HWGROUP(drive)->handler) {
                printk (KERN_WARNING "ide-scsi: No active request in idescsi_eh_reset\n");
                spin_unlock(&ide_lock);
+               spin_unlock_irq(cmd->device->host->host_lock);
                return FAILED;
        }
 
@@ -1052,16 +1055,15 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd)
        HWGROUP(drive)->rq = NULL;
        HWGROUP(drive)->handler = NULL;
        HWGROUP(drive)->busy = 1;               /* will set this to zero when ide reset finished */
-       spin_unlock_irq(&ide_lock);
+       spin_unlock(&ide_lock);
 
        ide_do_reset(drive);
 
        /* ide_do_reset starts a polling handler which restarts itself every 50ms until the reset finishes */
 
        do {
-               set_current_state(TASK_UNINTERRUPTIBLE);
                spin_unlock_irq(cmd->device->host->host_lock);
-               schedule_timeout(HZ/20);
+               msleep(50);
                spin_lock_irq(cmd->device->host->host_lock);
        } while ( HWGROUP(drive)->handler );
 
@@ -1072,6 +1074,7 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd)
                ret = FAILED;
        }
 
+       spin_unlock_irq(cmd->device->host->host_lock);
        return ret;
 }
 
index fd8af643feacdf2a85b34ca4d0a15bd2efeeeec9..17b106b79f721de523d1a1a6cca343761c3a0ae3 100644 (file)
@@ -2885,7 +2885,7 @@ static int ipr_slave_alloc(struct scsi_device *sdev)
  * Return value:
  *     SUCCESS / FAILED
  **/
-static int ipr_eh_host_reset(struct scsi_cmnd * scsi_cmd)
+static int __ipr_eh_host_reset(struct scsi_cmnd * scsi_cmd)
 {
        struct ipr_ioa_cfg *ioa_cfg;
        int rc;
@@ -2905,6 +2905,17 @@ static int ipr_eh_host_reset(struct scsi_cmnd * scsi_cmd)
        return rc;
 }
 
+static int ipr_eh_host_reset(struct scsi_cmnd * cmd)
+{
+       int rc;
+
+       spin_lock_irq(cmd->device->host->host_lock);
+       rc = __ipr_eh_host_reset(cmd);
+       spin_unlock_irq(cmd->device->host->host_lock);
+
+       return rc;
+}
+
 /**
  * ipr_eh_dev_reset - Reset the device
  * @scsi_cmd:  scsi command struct
index 6572e100f7b2a030bfb979dc7ef3cf83953e1c46..6dfcb4fbccdda1ed614b2833ea755ed81df7b9ea 100644 (file)
@@ -873,7 +873,7 @@ ips_eh_abort(Scsi_Cmnd * SC)
 /*                                                                          */
 /****************************************************************************/
 static int
-ips_eh_reset(Scsi_Cmnd * SC)
+__ips_eh_reset(Scsi_Cmnd * SC)
 {
        int ret;
        int i;
@@ -1060,6 +1060,18 @@ ips_eh_reset(Scsi_Cmnd * SC)
 
 }
 
+static int
+ips_eh_reset(Scsi_Cmnd * SC)
+{
+       int rc;
+
+       spin_lock_irq(SC->device->host->host_lock);
+       rc = __ips_eh_reset(SC);
+       spin_unlock_irq(SC->device->host->host_lock);
+
+       return rc;
+}
+
 /****************************************************************************/
 /*                                                                          */
 /* Routine Name: ips_queue                                                  */
index 9a792a5494b562ac86eaa1128e6ed217c5c79b37..edd47d1f0b17567047ee6d76029d9268380e4717 100644 (file)
@@ -103,6 +103,9 @@ static int mac53c94_host_reset(struct scsi_cmnd *cmd)
        struct fsc_state *state = (struct fsc_state *) cmd->device->host->hostdata;
        struct mac53c94_regs __iomem *regs = state->regs;
        struct dbdma_regs __iomem *dma = state->dma;
+       unsigned long flags;
+
+       spin_lock_irqsave(cmd->device->host->host_lock, flags);
 
        writel((RUN|PAUSE|FLUSH|WAKE) << 16, &dma->control);
        writeb(CMD_SCSI_RESET, &regs->command); /* assert RST */
@@ -111,6 +114,8 @@ static int mac53c94_host_reset(struct scsi_cmnd *cmd)
        udelay(20);
        mac53c94_init(state);
        writeb(CMD_NOP, &regs->command);
+
+       spin_unlock_irqrestore(cmd->device->host->host_lock, flags);
        return SUCCESS;
 }
 
index f6da46d672f18f063d4a64179b74105445e60e18..b05737ae5eff8f4c368d109f528ec1b684839ef3 100644 (file)
@@ -1715,9 +1715,12 @@ static int mesh_host_reset(struct scsi_cmnd *cmd)
        struct mesh_state *ms = (struct mesh_state *) cmd->device->host->hostdata;
        volatile struct mesh_regs __iomem *mr = ms->mesh;
        volatile struct dbdma_regs __iomem *md = ms->dma;
+       unsigned long flags;
 
        printk(KERN_DEBUG "mesh_host_reset\n");
 
+       spin_lock_irqsave(ms->host->host_lock, flags);
+
        /* Reset the controller & dbdma channel */
        out_le32(&md->control, (RUN|PAUSE|FLUSH|WAKE) << 16);   /* stop dma */
        out_8(&mr->exception, 0xff);    /* clear all exception bits */
@@ -1739,6 +1742,7 @@ static int mesh_host_reset(struct scsi_cmnd *cmd)
        /* Complete pending commands */
        handle_reset(ms);
        
+       spin_unlock_irqrestore(ms->host->host_lock, flags);
        return SUCCESS;
 }
 
index 5c42021189eb748c188ec072454bb50f3881da0c..2fb31ee6d9f52a83ceb4a214ca98e7101a960cc2 100644 (file)
@@ -117,6 +117,9 @@ static int mvme147_bus_reset(Scsi_Cmnd *cmd)
 {
        /* FIXME perform bus-specific reset */
 
+       /* FIXME 2: kill this function, and let midlayer fallback to 
+          the same result, calling wd33c93_host_reset() */
+
        spin_lock_irq(cmd->device->host->host_lock);
        wd33c93_host_reset(cmd);
        spin_unlock_irq(cmd->device->host->host_lock);
index 6f15e7adbc657bf8b242c21030cd93aa38303aec..5159ceea319eb99e34f8bb7fd10527562b179d5b 100644 (file)
@@ -3051,11 +3051,14 @@ static int nsp32_eh_host_reset(struct scsi_cmnd *SCpnt)
        nsp32_msg(KERN_INFO, "Host Reset");     
        nsp32_dbg(NSP32_DEBUG_BUSRESET, "SCpnt=0x%x", SCpnt);
 
+       spin_lock_irq(SCpnt->device->host->host_lock);
+
        nsp32hw_init(data);
        nsp32_write2(base, IRQ_CONTROL, IRQ_CONTROL_ALL_IRQ_MASK);
        nsp32_do_bus_reset(data);
        nsp32_write2(base, IRQ_CONTROL, 0);
 
+       spin_unlock_irq(SCpnt->device->host->host_lock);
        return SUCCESS; /* Host reset is succeeded at any time. */
 }
 
index 8457d0d7748a9bb15c1879cbba6d20dcd01ed7f7..1667da9508b4a2d34c667b5bb1d92a30ac3df240 100644 (file)
@@ -627,7 +627,9 @@ SYM53C500_host_reset(struct scsi_cmnd *SCpnt)
        int port_base = SCpnt->device->host->io_port;
 
        DEB(printk("SYM53C500_host_reset called\n"));
+       spin_lock_irq(SCpnt->device->host->host_lock);
        SYM53C500_int_host_reset(port_base);
+       spin_unlock_irq(SCpnt->device->host->host_lock);
 
        return SUCCESS;
 }
index d26dbe2a33fe38a86d2a5fa7cdb1fe7b93f35a97..1a4ce1c39478b02af8cb637a7531f4842d299f4e 100644 (file)
@@ -1146,7 +1146,13 @@ qla1280_eh_bus_reset(struct scsi_cmnd *cmd)
 static int
 qla1280_eh_adapter_reset(struct scsi_cmnd *cmd)
 {
-       return qla1280_error_action(cmd, ADAPTER_RESET);
+       int rc;
+
+       spin_lock_irq(cmd->device->host->host_lock);
+       rc = qla1280_error_action(cmd, ADAPTER_RESET);
+       spin_unlock_irq(cmd->device->host->host_lock);
+
+       return rc;
 }
 
 static int
index e9091f9fbf25c43c1c067ed826b35642c7615d44..f12a2b6fa7a06995de0a2a1dbeac71495981ed6d 100644 (file)
@@ -815,8 +815,6 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
        qla_printk(KERN_INFO, ha,
            "scsi(%ld:%d:%d): ADAPTER RESET ISSUED.\n", ha->host_no, id, lun);
 
-       spin_unlock_irq(ha->host->host_lock);
-
        if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS)
                goto eh_host_reset_lock;
 
@@ -845,8 +843,6 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
                ret = SUCCESS;
 
 eh_host_reset_lock:
-       spin_lock_irq(ha->host->host_lock);
-
        qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
            (ret == FAILED) ? "failed" : "succeded");
 
index be56ee67b7fe4cfe9d8a122f2526a9e5808ef408..ceb4e0c99b37eeac59e1f30a2316ad750f732e95 100644 (file)
@@ -1082,9 +1082,7 @@ static int scsi_try_host_reset(struct scsi_cmnd *scmd)
        if (!scmd->device->host->hostt->eh_host_reset_handler)
                return FAILED;
 
-       spin_lock_irqsave(scmd->device->host->host_lock, flags);
        rtn = scmd->device->host->hostt->eh_host_reset_handler(scmd);
-       spin_unlock_irqrestore(scmd->device->host->host_lock, flags);
 
        if (rtn == SUCCESS) {
                if (!scmd->device->host->hostt->skip_settle_delay)
index ed66828705e1e8e780c6ec9307732ec7b5cf4237..a5ba2c6927520daff832382a2ad82fb0f8bd2914 100644 (file)
@@ -311,6 +311,9 @@ static int sgiwd93_bus_reset(Scsi_Cmnd *cmd)
 {
        /* FIXME perform bus-specific reset */
 
+       /* FIXME 2: kill this function, and let midlayer fallback
+          to the same result, calling wd33c93_host_reset() */
+
        spin_lock_irq(cmd->device->host->host_lock);
        wd33c93_host_reset(cmd);
        spin_unlock_irq(cmd->device->host->host_lock);
index ca9a04cf4d3f055742a82cab85bfd94f5f3683f5..ef19adc67efff419565306323aa017500438bca4 100644 (file)
@@ -790,6 +790,9 @@ static int sym53c416_host_reset(Scsi_Cmnd *SCpnt)
        int base;
        int scsi_id = -1;       
        int i;
+       unsigned long flags;
+
+       spin_lock_irqsave(&sym53c416_lock, flags);
 
        /* printk("sym53c416_reset\n"); */
        base = SCpnt->device->host->io_port;
@@ -801,6 +804,8 @@ static int sym53c416_host_reset(Scsi_Cmnd *SCpnt)
        outb(NOOP | PIO_MODE, base + COMMAND_REG);
        outb(RESET_SCSI_BUS, base + COMMAND_REG);
        sym53c416_init(base, scsi_id);
+
+       spin_unlock_irqrestore(&sym53c416_lock, flags);
        return SUCCESS;
 }
 
index 6af9c18b3f97875af6f8db44de0c37c6afab7edc..d76766c3ce1643158ecc27a29dc157d0d36c9ea4 100644 (file)
@@ -889,7 +889,13 @@ static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd)
 
 static int sym53c8xx_eh_host_reset_handler(struct scsi_cmnd *cmd)
 {
-       return sym_eh_handler(SYM_EH_HOST_RESET, "HOST RESET", cmd);
+       int rc;
+
+       spin_lock_irq(cmd->device->host->host_lock);
+       rc = sym_eh_handler(SYM_EH_HOST_RESET, "HOST RESET", cmd);
+       spin_unlock_irq(cmd->device->host->host_lock);
+
+       return rc;
 }
 
 /*
index a6a441937acba3a58d895557ad575a919538852d..98369ce092836e4490ff9e6450fb1bdaa69a644c 100644 (file)
@@ -1417,16 +1417,20 @@ static int u14_34f_eh_host_reset(struct scsi_cmnd *SCarg) {
    printk("%s: reset, enter, target %d.%d:%d, pid %ld.\n",
           BN(j), SCarg->device->channel, SCarg->device->id, SCarg->device->lun, SCarg->pid);
 
+   spin_lock_irq(sh[j]->host_lock);
+
    if (SCarg->host_scribble == NULL)
       printk("%s: reset, pid %ld inactive.\n", BN(j), SCarg->pid);
 
    if (HD(j)->in_reset) {
       printk("%s: reset, exit, already in reset.\n", BN(j));
+      spin_unlock_irq(sh[j]->host_lock);
       return FAILED;
       }
 
    if (wait_on_busy(sh[j]->io_port, MAXLOOP)) {
       printk("%s: reset, exit, timeout error.\n", BN(j));
+      spin_unlock_irq(sh[j]->host_lock);
       return FAILED;
       }
 
@@ -1477,6 +1481,7 @@ static int u14_34f_eh_host_reset(struct scsi_cmnd *SCarg) {
 
    if (wait_on_busy(sh[j]->io_port, MAXLOOP)) {
       printk("%s: reset, cannot reset, timeout error.\n", BN(j));
+      spin_unlock_irq(sh[j]->host_lock);
       return FAILED;
       }
 
@@ -1538,6 +1543,7 @@ static int u14_34f_eh_host_reset(struct scsi_cmnd *SCarg) {
    if (arg_done) printk("%s: reset, exit, pid %ld done.\n", BN(j), SCarg->pid);
    else          printk("%s: reset, exit.\n", BN(j));
 
+   spin_unlock_irq(sh[j]->host_lock);
    return SUCCESS;
 }
 
index bf4a758e2801d4e541a473716b9b39d2662f99d2..fb54a87a80a3037cabdca8691b8d24113db3eaa1 100644 (file)
@@ -1586,9 +1586,16 @@ static int wd7000_host_reset(struct scsi_cmnd *SCpnt)
 {
        Adapter *host = (Adapter *) SCpnt->device->host->hostdata;
 
-       if (wd7000_adapter_reset(host) < 0)
+       spin_unlock_irq(SCpnt->device->host->host_lock);
+
+       if (wd7000_adapter_reset(host) < 0) {
+               spin_unlock_irq(SCpnt->device->host->host_lock);
                return FAILED;
+       }
+
        wd7000_enable_intr(host);
+
+       spin_unlock_irq(SCpnt->device->host->host_lock);
        return SUCCESS;
 }