From 631e8a1398ce4cfef8b30678d51daf0c64313a09 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 16 May 2005 01:59:55 +0100 Subject: [SCSI] TYPE_RBC cache fixes (sbp2.c affected) a) TYPE_SDAD renamed to TYPE_RBC and taken to scsi.h b) in sbp2.c remapping of TYPE_RPB to TYPE_DISK turned off c) relevant places in midlayer and sd.c taught to accept TYPE_RBC d) sd.c::sd_read_cache_type() looks into page 6 when dealing with TYPE_RBC - these guys have writeback cache flag there and are not guaranteed to have page 8 at all. e) sd_read_cache_type() got an extra sanity check - it checks that it got the page it asked for before using its contents. And screams if mismatch had happened. Rationale: there are broken devices out there that are "helpful" enough to go for "I don't have a page you've asked for, here, have another one". For example, PL3507 had been caught doing just that... f) sbp2 sets sdev->use_10_for_rw and sdev->use_10_for_ms instead of bothering to remap READ6/WRITE6/MOD_SENSE, so most of the conversions in there are gone now. Incidentally, I wonder if USB storage devices that have no mode page 8 are simply RBC ones. I haven't touched that, but it might be interesting to check... Signed-off-by: Al Viro Signed-off-by: James Bottomley --- drivers/ieee1394/sbp2.c | 130 ++---------------------------------------------- drivers/ieee1394/sbp2.h | 4 -- 2 files changed, 3 insertions(+), 131 deletions(-) (limited to 'drivers/ieee1394') diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 00c7b958361a..094e646ed4de 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -1070,7 +1070,7 @@ static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, quadlet_ static __inline__ int sbp2_command_conversion_device_type(u8 device_type) { return (((device_type == TYPE_DISK) || - (device_type == TYPE_SDAD) || + (device_type == TYPE_RBC) || (device_type == TYPE_ROM)) ? 1:0); } @@ -2111,102 +2111,6 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, */ static void sbp2_check_sbp2_command(struct scsi_id_instance_data *scsi_id, unchar *cmd) { - unchar new_cmd[16]; - u8 device_type = SBP2_DEVICE_TYPE (scsi_id->sbp2_device_type_and_lun); - - SBP2_DEBUG("sbp2_check_sbp2_command"); - - switch (*cmd) { - - case READ_6: - - if (sbp2_command_conversion_device_type(device_type)) { - - SBP2_DEBUG("Convert READ_6 to READ_10"); - - /* - * Need to turn read_6 into read_10 - */ - new_cmd[0] = 0x28; - new_cmd[1] = (cmd[1] & 0xe0); - new_cmd[2] = 0x0; - new_cmd[3] = (cmd[1] & 0x1f); - new_cmd[4] = cmd[2]; - new_cmd[5] = cmd[3]; - new_cmd[6] = 0x0; - new_cmd[7] = 0x0; - new_cmd[8] = cmd[4]; - new_cmd[9] = cmd[5]; - - memcpy(cmd, new_cmd, 10); - - } - - break; - - case WRITE_6: - - if (sbp2_command_conversion_device_type(device_type)) { - - SBP2_DEBUG("Convert WRITE_6 to WRITE_10"); - - /* - * Need to turn write_6 into write_10 - */ - new_cmd[0] = 0x2a; - new_cmd[1] = (cmd[1] & 0xe0); - new_cmd[2] = 0x0; - new_cmd[3] = (cmd[1] & 0x1f); - new_cmd[4] = cmd[2]; - new_cmd[5] = cmd[3]; - new_cmd[6] = 0x0; - new_cmd[7] = 0x0; - new_cmd[8] = cmd[4]; - new_cmd[9] = cmd[5]; - - memcpy(cmd, new_cmd, 10); - - } - - break; - - case MODE_SENSE: - - if (sbp2_command_conversion_device_type(device_type)) { - - SBP2_DEBUG("Convert MODE_SENSE_6 to MODE_SENSE_10"); - - /* - * Need to turn mode_sense_6 into mode_sense_10 - */ - new_cmd[0] = 0x5a; - new_cmd[1] = cmd[1]; - new_cmd[2] = cmd[2]; - new_cmd[3] = 0x0; - new_cmd[4] = 0x0; - new_cmd[5] = 0x0; - new_cmd[6] = 0x0; - new_cmd[7] = 0x0; - new_cmd[8] = cmd[4]; - new_cmd[9] = cmd[5]; - - memcpy(cmd, new_cmd, 10); - - } - - break; - - case MODE_SELECT: - - /* - * TODO. Probably need to change mode select to 10 byte version - */ - - default: - break; - } - - return; } /* @@ -2271,14 +2175,6 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, scsi_buf[4] = 36 - 5; } - /* - * Check for Simple Direct Access Device and change it to TYPE_DISK - */ - if ((scsi_buf[0] & 0x1f) == TYPE_SDAD) { - SBP2_DEBUG("Changing TYPE_SDAD to TYPE_DISK"); - scsi_buf[0] &= 0xe0; - } - /* * Fix ansi revision and response data format */ @@ -2287,27 +2183,6 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, break; - case MODE_SENSE: - - if (sbp2_command_conversion_device_type(device_type)) { - - SBP2_DEBUG("Modify mode sense response (10 byte version)"); - - scsi_buf[0] = scsi_buf[1]; /* Mode data length */ - scsi_buf[1] = scsi_buf[2]; /* Medium type */ - scsi_buf[2] = scsi_buf[3]; /* Device specific parameter */ - scsi_buf[3] = scsi_buf[7]; /* Block descriptor length */ - memcpy(scsi_buf + 4, scsi_buf + 8, scsi_buf[0]); - } - - break; - - case MODE_SELECT: - - /* - * TODO. Probably need to change mode select to 10 byte version - */ - default: break; } @@ -2690,7 +2565,8 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, static int sbp2scsi_slave_configure (struct scsi_device *sdev) { blk_queue_dma_alignment(sdev->request_queue, (512 - 1)); - + sdev->use_10_for_rw = 1; + sdev->use_10_for_ms = 1; return 0; } diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h index a84b039a05b9..cd425be74841 100644 --- a/drivers/ieee1394/sbp2.h +++ b/drivers/ieee1394/sbp2.h @@ -266,10 +266,6 @@ struct sbp2_status_block { #define SBP2_MAX_UDS_PER_NODE 16 /* Maximum scsi devices per node */ #define SBP2_MAX_SECTORS 255 /* Max sectors supported */ -#ifndef TYPE_SDAD -#define TYPE_SDAD 0x0e /* simplified direct access device */ -#endif - /* * SCSI direction table... * (now used as a back-up in case the direction passed down from above is "unknown") -- cgit v1.2.3 From 644e02ea147f8bea18800107f443ea5fa7f17f4f Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 24 May 2005 02:05:24 -0700 Subject: [SCSI] git-scsi-misc-sbp2-warning-fix drivers/ieee1394/sbp2.c: In function `sbp2_check_sbp2_response': drivers/ieee1394/sbp2.c:2154: warning: unused variable `device_type' Signed-off-by: Andrew Morton Signed-off-by: James Bottomley --- drivers/ieee1394/sbp2.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/ieee1394') diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 094e646ed4de..aa941025072e 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -2151,7 +2151,6 @@ static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, struct scsi_cmnd *SCpnt) { u8 *scsi_buf = SCpnt->request_buffer; - u8 device_type = SBP2_DEVICE_TYPE (scsi_id->sbp2_device_type_and_lun); SBP2_DEBUG("sbp2_check_sbp2_response"); -- cgit v1.2.3 From e3df715501be3329986e5d9dfa9a477f49e7996b Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Sat, 28 May 2005 07:47:39 -0400 Subject: [SCSI] Remove unnecessary locking around completion function calls The SCSI ->done() hook should not be called from inside a spinlock. Drivers that do this are mostly cut-n-paste from 2.2.x-era. Signed-off-by: James Bottomley --- drivers/fc4/fc.c | 4 ---- drivers/ieee1394/sbp2.c | 6 ------ drivers/scsi/ultrastor.c | 2 -- 3 files changed, 12 deletions(-) (limited to 'drivers/ieee1394') diff --git a/drivers/fc4/fc.c b/drivers/fc4/fc.c index 1fbb219aa9ba..d9e11b536659 100644 --- a/drivers/fc4/fc.c +++ b/drivers/fc4/fc.c @@ -767,10 +767,8 @@ static void fcp_scsi_done (Scsi_Cmnd *SCpnt) { unsigned long flags; - spin_lock_irqsave(SCpnt->device->host->host_lock, flags); if (FCP_CMND(SCpnt)->done) FCP_CMND(SCpnt)->done(SCpnt); - spin_unlock_irqrestore(SCpnt->device->host->host_lock, flags); } static int fcp_scsi_queue_it(fc_channel *fc, Scsi_Cmnd *SCpnt, fcp_cmnd *fcmd, int prepare) @@ -912,9 +910,7 @@ int fcp_scsi_abort(Scsi_Cmnd *SCpnt) unsigned long flags; SCpnt->result = DID_ABORT; - spin_lock_irqsave(SCpnt->device->host->host_lock, flags); fcmd->done(SCpnt); - spin_unlock_irqrestore(SCpnt->device->host->host_lock, flags); printk("FC: soft abort\n"); return SUCCESS; } else { diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index aa941025072e..de552486b1c9 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -2453,8 +2453,6 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, u32 scsi_status, struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)) { - unsigned long flags; - SBP2_DEBUG("sbp2scsi_complete_command"); /* @@ -2553,11 +2551,7 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, /* * Tell scsi stack that we're done with this command */ - spin_lock_irqsave(scsi_id->scsi_host->host_lock,flags); done (SCpnt); - spin_unlock_irqrestore(scsi_id->scsi_host->host_lock,flags); - - return; } diff --git a/drivers/scsi/ultrastor.c b/drivers/scsi/ultrastor.c index 97f4d9112b48..2c17470a229d 100644 --- a/drivers/scsi/ultrastor.c +++ b/drivers/scsi/ultrastor.c @@ -954,9 +954,7 @@ static int ultrastor_abort(Scsi_Cmnd *SCpnt) SCpnt->result = DID_ABORT << 16; /* Take the host lock to guard against scsi layer re-entry */ - spin_lock_irqsave(host->host_lock, flags); done(SCpnt); - spin_unlock_irqrestore(host->host_lock, flags); /* Need to set a timeout here in case command never completes. */ return SUCCESS; -- cgit v1.2.3 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 --- Documentation/scsi/scsi_mid_low_api.txt | 3 +-- drivers/ieee1394/sbp2.c | 14 +++++++++++++- drivers/message/fusion/mptscsih.c | 6 +----- drivers/s390/scsi/zfcp_scsi.c | 3 --- 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 +++++++- drivers/usb/storage/scsiglue.c | 4 ---- 17 files changed, 98 insertions(+), 42 deletions(-) (limited to 'drivers/ieee1394') diff --git a/Documentation/scsi/scsi_mid_low_api.txt b/Documentation/scsi/scsi_mid_low_api.txt index f4a37ee670f2..62f7f76f5de8 100644 --- a/Documentation/scsi/scsi_mid_low_api.txt +++ b/Documentation/scsi/scsi_mid_low_api.txt @@ -973,8 +973,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 * diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index de552486b1c9..fcfddcc8e7ba 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -2615,7 +2615,7 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt) /* * Called by scsi stack when something has really gone wrong. */ -static int sbp2scsi_reset(struct scsi_cmnd *SCpnt) +static int __sbp2scsi_reset(struct scsi_cmnd *SCpnt) { struct scsi_id_instance_data *scsi_id = (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0]; @@ -2630,6 +2630,18 @@ static int sbp2scsi_reset(struct scsi_cmnd *SCpnt) return(SUCCESS); } +static int sbp2scsi_reset(struct scsi_cmnd *SCpnt) +{ + unsigned long flags; + int rc; + + spin_lock_irqsave(SCpnt->device->host->host_lock, flags); + rc = __sbp2scsi_reset(SCpnt); + spin_unlock_irqrestore(SCpnt->device->host->host_lock, flags); + + return rc; +} + static const char *sbp2scsi_info (struct Scsi_Host *host) { return "SCSI emulation for IEEE-1394 SBP-2 Devices"; diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index 6a5851c51a21..82cd9bc3b024 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -1801,7 +1801,6 @@ int mptscsih_dev_reset(struct scsi_cmnd * SCpnt) { MPT_SCSI_HOST *hd; - spinlock_t *host_lock = SCpnt->device->host->host_lock; /* If we can't locate our host adapter structure, return FAILED status. */ @@ -1818,7 +1817,6 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt) printk(KERN_WARNING MYNAM ": %s: >> Attempting target reset! (sc=%p)\n", hd->ioc->name, SCpnt); - spin_unlock_irq(host_lock); if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, SCpnt->device->channel, SCpnt->device->id, 0, 0, 5 /* 5 second timeout */) @@ -1830,12 +1828,10 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt) hd->ioc->name, SCpnt); hd->tmPending = 0; hd->tmState = TM_STATE_NONE; - spin_lock_irq(host_lock); return FAILED; } - spin_lock_irq(host_lock); - return SUCCESS; + return SUCCESS; } /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index 6e4447598495..be7c91d4ae8c 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -636,8 +636,6 @@ zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt) struct zfcp_unit *unit = (struct zfcp_unit *) scpnt->device->hostdata; struct Scsi_Host *scsi_host = scpnt->device->host; - spin_unlock_irq(scsi_host->host_lock); - if (!unit) { ZFCP_LOG_NORMAL("bug: Tried reset for nonexistent unit\n"); retval = SUCCESS; @@ -680,7 +678,6 @@ zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt) retval = SUCCESS; } out: - spin_lock_irq(scsi_host->host_lock); return retval; } diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c index 88d119f4b970..630b11575230 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 7fc6c76e519b..31db0edc7cf9 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 ee127e8aea55..1e83096bb911 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 d857842bc45b..d89b8eb3cdf3 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 f9c01a13abef..fd8af643feac 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 e9b84f9d8e81..13da26883da3 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 8d707b29027d..80b0c40c522b 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 bec4406011aa..057ed45b54b2 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 638be81c4509..907a1e8cc880 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 1693998aa727..360974eb2b26 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 3877a78f5e50..87d925055b47 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 e2d055ed5b6f..5ea62552d47d 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) diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 7dce9c01c357..739a9143477d 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -253,8 +253,6 @@ static int device_reset(struct scsi_cmnd *srb) US_DEBUGP("%s called\n", __FUNCTION__); - scsi_unlock(us_to_host(us)); - /* lock the device pointers and do the reset */ down(&(us->dev_semaphore)); if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { @@ -264,8 +262,6 @@ static int device_reset(struct scsi_cmnd *srb) result = us->transport_reset(us); up(&(us->dev_semaphore)); - /* lock the host for the return */ - scsi_lock(us_to_host(us)); return result; } -- cgit v1.2.3