From 94d0e7b805961c44e4dc486ffc21075084bb7175 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Sat, 28 May 2005 07:55:48 -0400 Subject: [SCSI] allow sleeping in ->eh_device_reset_handler() Signed-off-by: James Bottomley --- drivers/scsi/aha152x.c | 2 -- drivers/scsi/aic7xxx/aic79xx_osm.c | 8 ++++---- drivers/scsi/aic7xxx_old.c | 14 +++++++++++++- drivers/scsi/ibmvscsi/ibmvscsi.c | 2 -- drivers/scsi/ipr.c | 13 ++++++++++++- drivers/scsi/lpfc/lpfc_scsi.c | 12 +++++++++++- drivers/scsi/megaraid.c | 14 +++++++++++++- drivers/scsi/megaraid/megaraid_mbox.c | 14 +++++++++++++- drivers/scsi/qla1280.c | 8 +++++++- drivers/scsi/qla2xxx/qla_os.c | 8 +------- drivers/scsi/scsi_error.c | 7 ++----- drivers/scsi/sym53c8xx_2/sym_glue.c | 8 +++++++- 12 files changed, 83 insertions(+), 27 deletions(-) (limited to 'drivers/scsi') diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index 88d119f4b97..630b1157523 100644 --- a/drivers/scsi/aha152x.c +++ b/drivers/scsi/aha152x.c @@ -1225,8 +1225,6 @@ static int aha152x_device_reset(Scsi_Cmnd * SCpnt) } DO_UNLOCK(flags); - - spin_lock_irq(shpnt->host_lock); return ret; } diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c index 7fc6c76e519..31db0edc7cf 100644 --- a/drivers/scsi/aic7xxx/aic79xx_osm.c +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c @@ -1511,17 +1511,17 @@ ahd_linux_dev_reset(Scsi_Cmnd *cmd) ahd_name(ahd), cmd->device->channel, cmd->device->id, cmd->device->lun, cmd); #endif - ahd_midlayer_entrypoint_lock(ahd, &s); + ahd_lock(ahd, &s); dev = ahd_linux_get_device(ahd, cmd->device->channel, cmd->device->id, cmd->device->lun, /*alloc*/FALSE); if (dev == NULL) { - ahd_midlayer_entrypoint_unlock(ahd, &s); + ahd_unlock(ahd, &s); kfree(recovery_cmd); return (FAILED); } if ((scb = ahd_get_scb(ahd, AHD_NEVER_COL_IDX)) == NULL) { - ahd_midlayer_entrypoint_unlock(ahd, &s); + ahd_unlock(ahd, &s); kfree(recovery_cmd); return (FAILED); } @@ -1570,7 +1570,7 @@ ahd_linux_dev_reset(Scsi_Cmnd *cmd) spin_lock_irq(&ahd->platform_data->spin_lock); ahd_schedule_runq(ahd); ahd_linux_run_complete_queue(ahd); - ahd_midlayer_entrypoint_unlock(ahd, &s); + ahd_unlock(ahd, &s); printf("%s: Device reset returning 0x%x\n", ahd_name(ahd), retval); return (retval); } diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c index ee127e8aea5..1e83096bb91 100644 --- a/drivers/scsi/aic7xxx_old.c +++ b/drivers/scsi/aic7xxx_old.c @@ -10358,7 +10358,7 @@ aic7xxx_queue(Scsi_Cmnd *cmd, void (*fn)(Scsi_Cmnd *)) * Returns an enumerated type that indicates the status of the operation. *-F*************************************************************************/ static int -aic7xxx_bus_device_reset(Scsi_Cmnd *cmd) +__aic7xxx_bus_device_reset(Scsi_Cmnd *cmd) { struct aic7xxx_host *p; struct aic7xxx_scb *scb; @@ -10551,6 +10551,18 @@ aic7xxx_bus_device_reset(Scsi_Cmnd *cmd) return SUCCESS; } +static int +aic7xxx_bus_device_reset(Scsi_Cmnd *cmd) +{ + int rc; + + spin_lock_irq(cmd->device->host->host_lock); + rc = __aic7xxx_bus_device_reset(cmd); + spin_unlock_irq(cmd->device->host->host_lock); + + return rc; +} + /*+F************************************************************************* * Function: diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index d857842bc45..d89b8eb3cdf 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -976,9 +976,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd) return FAILED; } - spin_unlock_irq(hostdata->host->host_lock); wait_for_completion(&evt->comp); - spin_lock_irq(hostdata->host->host_lock); /* make sure we got a good response */ if (unlikely(srp_rsp.srp.generic.type != SRP_RSP_TYPE)) { diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index f9c01a13abe..fd8af643fea 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c @@ -2916,7 +2916,7 @@ static int ipr_eh_host_reset(struct scsi_cmnd * scsi_cmd) * Return value: * SUCCESS / FAILED **/ -static int ipr_eh_dev_reset(struct scsi_cmnd * scsi_cmd) +static int __ipr_eh_dev_reset(struct scsi_cmnd * scsi_cmd) { struct ipr_cmnd *ipr_cmd; struct ipr_ioa_cfg *ioa_cfg; @@ -2970,6 +2970,17 @@ static int ipr_eh_dev_reset(struct scsi_cmnd * scsi_cmd) return (IPR_IOASC_SENSE_KEY(ioasc) ? FAILED : SUCCESS); } +static int ipr_eh_dev_reset(struct scsi_cmnd * cmd) +{ + int rc; + + spin_lock_irq(cmd->device->host->host_lock); + rc = __ipr_eh_dev_reset(cmd); + spin_unlock_irq(cmd->device->host->host_lock); + + return rc; +} + /** * ipr_bus_reset_done - Op done function for bus reset. * @ipr_cmd: ipr command struct diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c index e9b84f9d8e8..13da26883da 100644 --- a/drivers/scsi/lpfc/lpfc_scsi.c +++ b/drivers/scsi/lpfc/lpfc_scsi.c @@ -928,7 +928,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd) } static int -lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) +__lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) { struct Scsi_Host *shost = cmnd->device->host; struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata[0]; @@ -1040,6 +1040,16 @@ out: return ret; } +static int +lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) +{ + int rc; + spin_lock_irq(cmnd->device->host->host_lock); + rc = __lpfc_reset_lun_handler(cmnd); + spin_unlock_irq(cmnd->device->host->host_lock); + return rc; +} + /* * Note: midlayer calls this function with the host_lock held */ diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 8d707b29027..80b0c40c522 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -1938,7 +1938,7 @@ megaraid_abort(Scsi_Cmnd *cmd) static int -megaraid_reset(Scsi_Cmnd *cmd) +__megaraid_reset(Scsi_Cmnd *cmd) { adapter_t *adapter; megacmd_t mc; @@ -1972,6 +1972,18 @@ megaraid_reset(Scsi_Cmnd *cmd) return rval; } +static int +megaraid_reset(Scsi_Cmnd *cmd) +{ + adapter = (adapter_t *)cmd->device->host->hostdata; + int rc; + + spin_lock_irq(&adapter->lock); + rc = __megaraid_reset(cmd); + spin_unlock_irq(&adapter->lock); + + return rc; +} /** diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c index bec4406011a..057ed45b54b 100644 --- a/drivers/scsi/megaraid/megaraid_mbox.c +++ b/drivers/scsi/megaraid/megaraid_mbox.c @@ -2726,7 +2726,7 @@ megaraid_abort_handler(struct scsi_cmnd *scp) * host **/ static int -megaraid_reset_handler(struct scsi_cmnd *scp) +__megaraid_reset_handler(struct scsi_cmnd *scp) { adapter_t *adapter; scb_t *scb; @@ -2847,6 +2847,18 @@ megaraid_reset_handler(struct scsi_cmnd *scp) return rval; } +static int +megaraid_reset_handler(struct scsi_cmnd *cmd) +{ + int rc; + + spin_lock_irq(cmd->device->host->host_lock); + rc = __megaraid_reset_handler(cmd); + spin_unlock_irq(cmd->device->host->host_lock); + + return rc; +} + /* * START: internal commands library diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 638be81c450..907a1e8cc88 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -1114,7 +1114,13 @@ qla1280_eh_abort(struct scsi_cmnd * cmd) static int qla1280_eh_device_reset(struct scsi_cmnd *cmd) { - return qla1280_error_action(cmd, DEVICE_RESET); + int rc; + + spin_lock_irq(cmd->device->host->host_lock); + rc = qla1280_error_action(cmd, DEVICE_RESET); + spin_unlock_irq(cmd->device->host->host_lock); + + return rc; } /************************************************************************** diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 1693998aa72..360974eb2b2 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -613,12 +613,8 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) qla_printk(KERN_INFO, ha, "scsi(%ld:%d:%d): DEVICE RESET ISSUED.\n", ha->host_no, id, lun); - spin_unlock_irq(ha->host->host_lock); - - if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) { - spin_lock_irq(ha->host->host_lock); + if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) goto eh_dev_reset_done; - } if (qla2x00_wait_for_loop_ready(ha) == QLA_SUCCESS) { if (qla2x00_device_reset(ha, fcport) == 0) @@ -669,8 +665,6 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) "scsi(%ld:%d:%d): DEVICE RESET SUCCEEDED.\n", ha->host_no, id, lun); eh_dev_reset_done: - spin_lock_irq(ha->host->host_lock); - return ret; } diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 3877a78f5e5..87d925055b4 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -857,17 +857,14 @@ static int scsi_eh_abort_cmds(struct list_head *work_q, **/ static int scsi_try_bus_device_reset(struct scsi_cmnd *scmd) { - unsigned long flags; - int rtn = FAILED; + int rtn; if (!scmd->device->host->hostt->eh_device_reset_handler) - return rtn; + return FAILED; scmd->owner = SCSI_OWNER_LOWLEVEL; - spin_lock_irqsave(scmd->device->host->host_lock, flags); rtn = scmd->device->host->hostt->eh_device_reset_handler(scmd); - spin_unlock_irqrestore(scmd->device->host->host_lock, flags); if (rtn == SUCCESS) { scmd->device->was_reset = 1; diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index e2d055ed5b6..5ea62552d47 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c @@ -867,7 +867,13 @@ static int sym53c8xx_eh_abort_handler(struct scsi_cmnd *cmd) static int sym53c8xx_eh_device_reset_handler(struct scsi_cmnd *cmd) { - return sym_eh_handler(SYM_EH_DEVICE_RESET, "DEVICE RESET", cmd); + int rc; + + spin_lock_irq(cmd->device->host->host_lock); + rc = sym_eh_handler(SYM_EH_DEVICE_RESET, "DEVICE RESET", cmd); + spin_unlock_irq(cmd->device->host->host_lock); + + return rc; } static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd) -- cgit v1.2.3-70-g09d2