Commit 94d0e7b805961c44e4dc486ffc21075084bb7175

Authored by Jeff Garzik
1 parent 8fa728a268

[SCSI] allow sleeping in ->eh_device_reset_handler()

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

Showing 17 changed files with 98 additions and 42 deletions Side-by-side Diff

Documentation/scsi/scsi_mid_low_api.txt
... ... @@ -973,8 +973,7 @@
973 973 *
974 974 * Returns SUCCESS if command aborted else FAILED
975 975 *
976   - * Locks: struct Scsi_Host::host_lock held (with irqsave) on entry
977   - * and assumed to be held on return.
  976 + * Locks: None held
978 977 *
979 978 * Calling context: kernel thread
980 979 *
drivers/ieee1394/sbp2.c
... ... @@ -2615,7 +2615,7 @@
2615 2615 /*
2616 2616 * Called by scsi stack when something has really gone wrong.
2617 2617 */
2618   -static int sbp2scsi_reset(struct scsi_cmnd *SCpnt)
  2618 +static int __sbp2scsi_reset(struct scsi_cmnd *SCpnt)
2619 2619 {
2620 2620 struct scsi_id_instance_data *scsi_id =
2621 2621 (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0];
... ... @@ -2628,6 +2628,18 @@
2628 2628 }
2629 2629  
2630 2630 return(SUCCESS);
  2631 +}
  2632 +
  2633 +static int sbp2scsi_reset(struct scsi_cmnd *SCpnt)
  2634 +{
  2635 + unsigned long flags;
  2636 + int rc;
  2637 +
  2638 + spin_lock_irqsave(SCpnt->device->host->host_lock, flags);
  2639 + rc = __sbp2scsi_reset(SCpnt);
  2640 + spin_unlock_irqrestore(SCpnt->device->host->host_lock, flags);
  2641 +
  2642 + return rc;
2631 2643 }
2632 2644  
2633 2645 static const char *sbp2scsi_info (struct Scsi_Host *host)
drivers/message/fusion/mptscsih.c
... ... @@ -1801,7 +1801,6 @@
1801 1801 mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
1802 1802 {
1803 1803 MPT_SCSI_HOST *hd;
1804   - spinlock_t *host_lock = SCpnt->device->host->host_lock;
1805 1804  
1806 1805 /* If we can't locate our host adapter structure, return FAILED status.
1807 1806 */
... ... @@ -1818,7 +1817,6 @@
1818 1817 printk(KERN_WARNING MYNAM ": %s: >> Attempting target reset! (sc=%p)\n",
1819 1818 hd->ioc->name, SCpnt);
1820 1819  
1821   - spin_unlock_irq(host_lock);
1822 1820 if (mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
1823 1821 SCpnt->device->channel, SCpnt->device->id,
1824 1822 0, 0, 5 /* 5 second timeout */)
1825 1823  
1826 1824  
... ... @@ -1830,12 +1828,10 @@
1830 1828 hd->ioc->name, SCpnt);
1831 1829 hd->tmPending = 0;
1832 1830 hd->tmState = TM_STATE_NONE;
1833   - spin_lock_irq(host_lock);
1834 1831 return FAILED;
1835 1832 }
1836   - spin_lock_irq(host_lock);
1837   - return SUCCESS;
1838 1833  
  1834 + return SUCCESS;
1839 1835 }
1840 1836  
1841 1837 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
drivers/s390/scsi/zfcp_scsi.c
... ... @@ -636,8 +636,6 @@
636 636 struct zfcp_unit *unit = (struct zfcp_unit *) scpnt->device->hostdata;
637 637 struct Scsi_Host *scsi_host = scpnt->device->host;
638 638  
639   - spin_unlock_irq(scsi_host->host_lock);
640   -
641 639 if (!unit) {
642 640 ZFCP_LOG_NORMAL("bug: Tried reset for nonexistent unit\n");
643 641 retval = SUCCESS;
... ... @@ -680,7 +678,6 @@
680 678 retval = SUCCESS;
681 679 }
682 680 out:
683   - spin_lock_irq(scsi_host->host_lock);
684 681 return retval;
685 682 }
686 683  
drivers/scsi/aha152x.c
... ... @@ -1225,8 +1225,6 @@
1225 1225 }
1226 1226  
1227 1227 DO_UNLOCK(flags);
1228   -
1229   - spin_lock_irq(shpnt->host_lock);
1230 1228 return ret;
1231 1229 }
1232 1230  
drivers/scsi/aic7xxx/aic79xx_osm.c
... ... @@ -1511,17 +1511,17 @@
1511 1511 ahd_name(ahd), cmd->device->channel, cmd->device->id,
1512 1512 cmd->device->lun, cmd);
1513 1513 #endif
1514   - ahd_midlayer_entrypoint_lock(ahd, &s);
  1514 + ahd_lock(ahd, &s);
1515 1515  
1516 1516 dev = ahd_linux_get_device(ahd, cmd->device->channel, cmd->device->id,
1517 1517 cmd->device->lun, /*alloc*/FALSE);
1518 1518 if (dev == NULL) {
1519   - ahd_midlayer_entrypoint_unlock(ahd, &s);
  1519 + ahd_unlock(ahd, &s);
1520 1520 kfree(recovery_cmd);
1521 1521 return (FAILED);
1522 1522 }
1523 1523 if ((scb = ahd_get_scb(ahd, AHD_NEVER_COL_IDX)) == NULL) {
1524   - ahd_midlayer_entrypoint_unlock(ahd, &s);
  1524 + ahd_unlock(ahd, &s);
1525 1525 kfree(recovery_cmd);
1526 1526 return (FAILED);
1527 1527 }
... ... @@ -1570,7 +1570,7 @@
1570 1570 spin_lock_irq(&ahd->platform_data->spin_lock);
1571 1571 ahd_schedule_runq(ahd);
1572 1572 ahd_linux_run_complete_queue(ahd);
1573   - ahd_midlayer_entrypoint_unlock(ahd, &s);
  1573 + ahd_unlock(ahd, &s);
1574 1574 printf("%s: Device reset returning 0x%x\n", ahd_name(ahd), retval);
1575 1575 return (retval);
1576 1576 }
drivers/scsi/aic7xxx_old.c
... ... @@ -10358,7 +10358,7 @@
10358 10358 * Returns an enumerated type that indicates the status of the operation.
10359 10359 *-F*************************************************************************/
10360 10360 static int
10361   -aic7xxx_bus_device_reset(Scsi_Cmnd *cmd)
  10361 +__aic7xxx_bus_device_reset(Scsi_Cmnd *cmd)
10362 10362 {
10363 10363 struct aic7xxx_host *p;
10364 10364 struct aic7xxx_scb *scb;
... ... @@ -10549,6 +10549,18 @@
10549 10549 return FAILED;
10550 10550 else
10551 10551 return SUCCESS;
  10552 +}
  10553 +
  10554 +static int
  10555 +aic7xxx_bus_device_reset(Scsi_Cmnd *cmd)
  10556 +{
  10557 + int rc;
  10558 +
  10559 + spin_lock_irq(cmd->device->host->host_lock);
  10560 + rc = __aic7xxx_bus_device_reset(cmd);
  10561 + spin_unlock_irq(cmd->device->host->host_lock);
  10562 +
  10563 + return rc;
10552 10564 }
10553 10565  
10554 10566  
drivers/scsi/ibmvscsi/ibmvscsi.c
... ... @@ -976,9 +976,7 @@
976 976 return FAILED;
977 977 }
978 978  
979   - spin_unlock_irq(hostdata->host->host_lock);
980 979 wait_for_completion(&evt->comp);
981   - spin_lock_irq(hostdata->host->host_lock);
982 980  
983 981 /* make sure we got a good response */
984 982 if (unlikely(srp_rsp.srp.generic.type != SRP_RSP_TYPE)) {
... ... @@ -2916,7 +2916,7 @@
2916 2916 * Return value:
2917 2917 * SUCCESS / FAILED
2918 2918 **/
2919   -static int ipr_eh_dev_reset(struct scsi_cmnd * scsi_cmd)
  2919 +static int __ipr_eh_dev_reset(struct scsi_cmnd * scsi_cmd)
2920 2920 {
2921 2921 struct ipr_cmnd *ipr_cmd;
2922 2922 struct ipr_ioa_cfg *ioa_cfg;
... ... @@ -2968,6 +2968,17 @@
2968 2968  
2969 2969 LEAVE;
2970 2970 return (IPR_IOASC_SENSE_KEY(ioasc) ? FAILED : SUCCESS);
  2971 +}
  2972 +
  2973 +static int ipr_eh_dev_reset(struct scsi_cmnd * cmd)
  2974 +{
  2975 + int rc;
  2976 +
  2977 + spin_lock_irq(cmd->device->host->host_lock);
  2978 + rc = __ipr_eh_dev_reset(cmd);
  2979 + spin_unlock_irq(cmd->device->host->host_lock);
  2980 +
  2981 + return rc;
2971 2982 }
2972 2983  
2973 2984 /**
drivers/scsi/lpfc/lpfc_scsi.c
... ... @@ -928,7 +928,7 @@
928 928 }
929 929  
930 930 static int
931   -lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
  931 +__lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
932 932 {
933 933 struct Scsi_Host *shost = cmnd->device->host;
934 934 struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata[0];
... ... @@ -1038,6 +1038,16 @@
1038 1038 lpfc_free_scsi_buf(lpfc_cmd);
1039 1039 out:
1040 1040 return ret;
  1041 +}
  1042 +
  1043 +static int
  1044 +lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
  1045 +{
  1046 + int rc;
  1047 + spin_lock_irq(cmnd->device->host->host_lock);
  1048 + rc = __lpfc_reset_lun_handler(cmnd);
  1049 + spin_unlock_irq(cmnd->device->host->host_lock);
  1050 + return rc;
1041 1051 }
1042 1052  
1043 1053 /*
drivers/scsi/megaraid.c
... ... @@ -1938,7 +1938,7 @@
1938 1938  
1939 1939  
1940 1940 static int
1941   -megaraid_reset(Scsi_Cmnd *cmd)
  1941 +__megaraid_reset(Scsi_Cmnd *cmd)
1942 1942 {
1943 1943 adapter_t *adapter;
1944 1944 megacmd_t mc;
... ... @@ -1972,6 +1972,18 @@
1972 1972 return rval;
1973 1973 }
1974 1974  
  1975 +static int
  1976 +megaraid_reset(Scsi_Cmnd *cmd)
  1977 +{
  1978 + adapter = (adapter_t *)cmd->device->host->hostdata;
  1979 + int rc;
  1980 +
  1981 + spin_lock_irq(&adapter->lock);
  1982 + rc = __megaraid_reset(cmd);
  1983 + spin_unlock_irq(&adapter->lock);
  1984 +
  1985 + return rc;
  1986 +}
1975 1987  
1976 1988  
1977 1989 /**
drivers/scsi/megaraid/megaraid_mbox.c
... ... @@ -2726,7 +2726,7 @@
2726 2726 * host
2727 2727 **/
2728 2728 static int
2729   -megaraid_reset_handler(struct scsi_cmnd *scp)
  2729 +__megaraid_reset_handler(struct scsi_cmnd *scp)
2730 2730 {
2731 2731 adapter_t *adapter;
2732 2732 scb_t *scb;
... ... @@ -2845,6 +2845,18 @@
2845 2845 }
2846 2846  
2847 2847 return rval;
  2848 +}
  2849 +
  2850 +static int
  2851 +megaraid_reset_handler(struct scsi_cmnd *cmd)
  2852 +{
  2853 + int rc;
  2854 +
  2855 + spin_lock_irq(cmd->device->host->host_lock);
  2856 + rc = __megaraid_reset_handler(cmd);
  2857 + spin_unlock_irq(cmd->device->host->host_lock);
  2858 +
  2859 + return rc;
2848 2860 }
2849 2861  
2850 2862  
drivers/scsi/qla1280.c
... ... @@ -1114,7 +1114,13 @@
1114 1114 static int
1115 1115 qla1280_eh_device_reset(struct scsi_cmnd *cmd)
1116 1116 {
1117   - return qla1280_error_action(cmd, DEVICE_RESET);
  1117 + int rc;
  1118 +
  1119 + spin_lock_irq(cmd->device->host->host_lock);
  1120 + rc = qla1280_error_action(cmd, DEVICE_RESET);
  1121 + spin_unlock_irq(cmd->device->host->host_lock);
  1122 +
  1123 + return rc;
1118 1124 }
1119 1125  
1120 1126 /**************************************************************************
drivers/scsi/qla2xxx/qla_os.c
... ... @@ -613,12 +613,8 @@
613 613 qla_printk(KERN_INFO, ha,
614 614 "scsi(%ld:%d:%d): DEVICE RESET ISSUED.\n", ha->host_no, id, lun);
615 615  
616   - spin_unlock_irq(ha->host->host_lock);
617   -
618   - if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS) {
619   - spin_lock_irq(ha->host->host_lock);
  616 + if (qla2x00_wait_for_hba_online(ha) != QLA_SUCCESS)
620 617 goto eh_dev_reset_done;
621   - }
622 618  
623 619 if (qla2x00_wait_for_loop_ready(ha) == QLA_SUCCESS) {
624 620 if (qla2x00_device_reset(ha, fcport) == 0)
... ... @@ -669,8 +665,6 @@
669 665 "scsi(%ld:%d:%d): DEVICE RESET SUCCEEDED.\n", ha->host_no, id, lun);
670 666  
671 667 eh_dev_reset_done:
672   - spin_lock_irq(ha->host->host_lock);
673   -
674 668 return ret;
675 669 }
676 670  
drivers/scsi/scsi_error.c
... ... @@ -857,17 +857,14 @@
857 857 **/
858 858 static int scsi_try_bus_device_reset(struct scsi_cmnd *scmd)
859 859 {
860   - unsigned long flags;
861   - int rtn = FAILED;
  860 + int rtn;
862 861  
863 862 if (!scmd->device->host->hostt->eh_device_reset_handler)
864   - return rtn;
  863 + return FAILED;
865 864  
866 865 scmd->owner = SCSI_OWNER_LOWLEVEL;
867 866  
868   - spin_lock_irqsave(scmd->device->host->host_lock, flags);
869 867 rtn = scmd->device->host->hostt->eh_device_reset_handler(scmd);
870   - spin_unlock_irqrestore(scmd->device->host->host_lock, flags);
871 868  
872 869 if (rtn == SUCCESS) {
873 870 scmd->device->was_reset = 1;
drivers/scsi/sym53c8xx_2/sym_glue.c
... ... @@ -867,7 +867,13 @@
867 867  
868 868 static int sym53c8xx_eh_device_reset_handler(struct scsi_cmnd *cmd)
869 869 {
870   - return sym_eh_handler(SYM_EH_DEVICE_RESET, "DEVICE RESET", cmd);
  870 + int rc;
  871 +
  872 + spin_lock_irq(cmd->device->host->host_lock);
  873 + rc = sym_eh_handler(SYM_EH_DEVICE_RESET, "DEVICE RESET", cmd);
  874 + spin_unlock_irq(cmd->device->host->host_lock);
  875 +
  876 + return rc;
871 877 }
872 878  
873 879 static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd)
drivers/usb/storage/scsiglue.c
... ... @@ -253,8 +253,6 @@
253 253  
254 254 US_DEBUGP("%s called\n", __FUNCTION__);
255 255  
256   - scsi_unlock(us_to_host(us));
257   -
258 256 /* lock the device pointers and do the reset */
259 257 down(&(us->dev_semaphore));
260 258 if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
... ... @@ -264,8 +262,6 @@
264 262 result = us->transport_reset(us);
265 263 up(&(us->dev_semaphore));
266 264  
267   - /* lock the host for the return */
268   - scsi_lock(us_to_host(us));
269 265 return result;
270 266 }
271 267