]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/lpfc/lpfc_scsi.c
Merge master.kernel.org:/home/rmk/linux-2.6-arm
[linux-2.6-omap-h63xx.git] / drivers / scsi / lpfc / lpfc_scsi.c
index 094f18f1fa05c0ba6ba3aa580a151497d2804c08..aea1ee472f3d503d263684669bd4dd1374406883 100644 (file)
 #define LPFC_ABORT_WAIT  2
 
 
-static inline void
-lpfc_block_requests(struct lpfc_hba * phba)
-{
-       down(&phba->hba_can_block);
-       scsi_block_requests(phba->host);
-}
-
-static inline void
-lpfc_unblock_requests(struct lpfc_hba * phba)
-{
-       scsi_unblock_requests(phba->host);
-       up(&phba->hba_can_block);
-}
-
 /*
  * This routine allocates a scsi buffer, which contains all the necessary
  * information needed to initiate a SCSI I/O.  The non-DMAable buffer region
@@ -467,6 +453,11 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
        sdev = cmd->device;
        cmd->scsi_done(cmd);
 
+       if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
+               lpfc_release_scsi_buf(phba, lpfc_cmd);
+               return;
+       }
+
        if (!result && pnode != NULL &&
           ((jiffies - pnode->last_ramp_up_time) >
                LPFC_Q_RAMP_UP_INTERVAL * HZ) &&
@@ -624,8 +615,7 @@ lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_hba *phba,
        struct lpfc_iocbq *piocbq;
        IOCB_t *piocb;
        struct fcp_cmnd *fcp_cmnd;
-       struct scsi_device *scsi_dev = lpfc_cmd->pCmd->device;
-       struct lpfc_rport_data *rdata = scsi_dev->hostdata;
+       struct lpfc_rport_data *rdata = lpfc_cmd->rdata;
        struct lpfc_nodelist *ndlp = rdata->pnode;
 
        if ((ndlp == NULL) || (ndlp->nlp_state != NLP_STE_MAPPED_NODE)) {
@@ -660,56 +650,18 @@ lpfc_scsi_prep_task_mgmt_cmd(struct lpfc_hba *phba,
                piocb->ulpTimeout = lpfc_cmd->timeout;
        }
 
-       lpfc_cmd->rdata = rdata;
-
-       switch (task_mgmt_cmd) {
-       case FCP_LUN_RESET:
-               /* Issue LUN Reset to TGT <num> LUN <num> */
-               lpfc_printf_log(phba,
-                               KERN_INFO,
-                               LOG_FCP,
-                               "%d:0703 Issue LUN Reset to TGT %d LUN %d "
-                               "Data: x%x x%x\n",
-                               phba->brd_no,
-                               scsi_dev->id, scsi_dev->lun,
-                               ndlp->nlp_rpi, ndlp->nlp_flag);
-
-               break;
-       case FCP_ABORT_TASK_SET:
-               /* Issue Abort Task Set to TGT <num> LUN <num> */
-               lpfc_printf_log(phba,
-                               KERN_INFO,
-                               LOG_FCP,
-                               "%d:0701 Issue Abort Task Set to TGT %d LUN %d "
-                               "Data: x%x x%x\n",
-                               phba->brd_no,
-                               scsi_dev->id, scsi_dev->lun,
-                               ndlp->nlp_rpi, ndlp->nlp_flag);
-
-               break;
-       case FCP_TARGET_RESET:
-               /* Issue Target Reset to TGT <num> */
-               lpfc_printf_log(phba,
-                               KERN_INFO,
-                               LOG_FCP,
-                               "%d:0702 Issue Target Reset to TGT %d "
-                               "Data: x%x x%x\n",
-                               phba->brd_no,
-                               scsi_dev->id, ndlp->nlp_rpi,
-                               ndlp->nlp_flag);
-               break;
-       }
-
        return (1);
 }
 
 static int
-lpfc_scsi_tgt_reset(struct lpfc_scsi_buf * lpfc_cmd, struct lpfc_hba * phba)
+lpfc_scsi_tgt_reset(struct lpfc_scsi_buf * lpfc_cmd, struct lpfc_hba * phba,
+                   unsigned  tgt_id, struct lpfc_rport_data *rdata)
 {
        struct lpfc_iocbq *iocbq;
        struct lpfc_iocbq *iocbqrsp;
        int ret;
 
+       lpfc_cmd->rdata = rdata;
        ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, FCP_TARGET_RESET);
        if (!ret)
                return FAILED;
@@ -721,6 +673,13 @@ lpfc_scsi_tgt_reset(struct lpfc_scsi_buf * lpfc_cmd, struct lpfc_hba * phba)
        if (!iocbqrsp)
                return FAILED;
 
+       /* Issue Target Reset to TGT <num> */
+       lpfc_printf_log(phba, KERN_INFO, LOG_FCP,
+                       "%d:0702 Issue Target Reset to TGT %d "
+                       "Data: x%x x%x\n",
+                       phba->brd_no, tgt_id, rdata->pnode->nlp_rpi,
+                       rdata->pnode->nlp_flag);
+
        ret = lpfc_sli_issue_iocb_wait(phba,
                                       &phba->sli.ring[phba->sli.fcp_ring],
                                       iocbq, iocbqrsp, lpfc_cmd->timeout);
@@ -886,7 +845,6 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
        unsigned int loop_count = 0;
        int ret = SUCCESS;
 
-       lpfc_block_requests(phba);
        spin_lock_irq(shost->host_lock);
 
        lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble;
@@ -972,7 +930,6 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
                        cmnd->device->lun, cmnd->serial_number);
 
        spin_unlock_irq(shost->host_lock);
-       lpfc_unblock_requests(phba);
 
        return ret;
 }
@@ -990,7 +947,6 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
        int ret = FAILED;
        int cnt, loopcnt;
 
-       lpfc_block_requests(phba);
        spin_lock_irq(shost->host_lock);
        /*
         * If target is not in a MAPPED state, delay the reset until
@@ -1016,6 +972,7 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
        lpfc_cmd->pCmd = cmnd;
        lpfc_cmd->timeout = 60;
        lpfc_cmd->scsi_hba = phba;
+       lpfc_cmd->rdata = rdata;
 
        ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, FCP_LUN_RESET);
        if (!ret)
@@ -1028,6 +985,11 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
        if (iocbqrsp == NULL)
                goto out_free_scsi_buf;
 
+       lpfc_printf_log(phba, KERN_INFO, LOG_FCP,
+                       "%d:0703 Issue LUN Reset to TGT %d LUN %d "
+                       "Data: x%x x%x\n", phba->brd_no, cmnd->device->id,
+                       cmnd->device->lun, pnode->nlp_rpi, pnode->nlp_flag);
+
        ret = lpfc_sli_issue_iocb_wait(phba,
                                       &phba->sli.ring[phba->sli.fcp_ring],
                                       iocbq, iocbqrsp, lpfc_cmd->timeout);
@@ -1086,7 +1048,6 @@ out_free_scsi_buf:
 
 out:
        spin_unlock_irq(shost->host_lock);
-       lpfc_unblock_requests(phba);
        return ret;
 }
 
@@ -1099,10 +1060,8 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
        int match;
        int ret = FAILED, i, err_count = 0;
        int cnt, loopcnt;
-       unsigned int midlayer_id = 0;
        struct lpfc_scsi_buf * lpfc_cmd;
 
-       lpfc_block_requests(phba);
        spin_lock_irq(shost->host_lock);
 
        lpfc_cmd = lpfc_get_scsi_buf(phba);
@@ -1119,7 +1078,6 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
         * targets known to the driver.  Should any target reset
         * fail, this routine returns failure to the midlayer.
         */
-       midlayer_id = cmnd->device->id;
        for (i = 0; i < MAX_FCP_TARGET; i++) {
                /* Search the mapped list for this target ID */
                match = 0;
@@ -1132,9 +1090,8 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
                if (!match)
                        continue;
 
-               lpfc_cmd->pCmd->device->id = i;
-               lpfc_cmd->pCmd->device->hostdata = ndlp->rport->dd_data;
-               ret = lpfc_scsi_tgt_reset(lpfc_cmd, phba);
+               ret = lpfc_scsi_tgt_reset(lpfc_cmd, phba,
+                                         i, ndlp->rport->dd_data);
                if (ret != SUCCESS) {
                        lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
                                "%d:0713 Bus Reset on target %d failed\n",
@@ -1153,7 +1110,6 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
         * the targets.  Unfortunately, some targets do not abide by
         * this forcing the driver to double check.
         */
-       cmnd->device->id = midlayer_id;
        cnt = lpfc_sli_sum_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring],
                                0, 0, LPFC_CTX_HOST);
        if (cnt)
@@ -1188,7 +1144,6 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
                        phba->brd_no, ret);
 out:
        spin_unlock_irq(shost->host_lock);
-       lpfc_unblock_requests(phba);
        return ret;
 }