]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/lpfc/lpfc_scsi.c
Merge branch 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jikos/hid
[linux-2.6-omap-h63xx.git] / drivers / scsi / lpfc / lpfc_scsi.c
index a760a44173df6e8a8092f4963fcf3f2a235d6b02..c3e68e0d8f7445e426fa0ee28cc35ab5903c37cc 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <linux/pci.h>
 #include <linux/interrupt.h>
+#include <linux/delay.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_device.h>
@@ -296,8 +297,10 @@ lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd)
        uint32_t fcpi_parm = lpfc_cmd->cur_iocbq.iocb.un.fcpi.fcpi_parm;
        uint32_t resp_info = fcprsp->rspStatus2;
        uint32_t scsi_status = fcprsp->rspStatus3;
+       uint32_t *lp;
        uint32_t host_status = DID_OK;
        uint32_t rsplen = 0;
+       uint32_t logit = LOG_FCP | LOG_FCP_ERROR;
 
        /*
         *  If this is a task management command, there is no
@@ -309,10 +312,25 @@ lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd)
                goto out;
        }
 
-       lpfc_printf_log(phba, KERN_WARNING, LOG_FCP,
-                       "%d:0730 FCP command failed: RSP "
-                       "Data: x%x x%x x%x x%x x%x x%x\n",
-                       phba->brd_no, resp_info, scsi_status,
+       if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen) {
+               uint32_t snslen = be32_to_cpu(fcprsp->rspSnsLen);
+               if (snslen > SCSI_SENSE_BUFFERSIZE)
+                       snslen = SCSI_SENSE_BUFFERSIZE;
+
+               if (resp_info & RSP_LEN_VALID)
+                 rsplen = be32_to_cpu(fcprsp->rspRspLen);
+               memcpy(cmnd->sense_buffer, &fcprsp->rspInfo0 + rsplen, snslen);
+       }
+       lp = (uint32_t *)cmnd->sense_buffer;
+
+       if (!scsi_status && (resp_info & RESID_UNDER))
+               logit = LOG_FCP;
+
+       lpfc_printf_log(phba, KERN_WARNING, logit,
+                       "%d:0730 FCP command x%x failed: x%x SNS x%x x%x "
+                       "Data: x%x x%x x%x x%x x%x\n",
+                       phba->brd_no, cmnd->cmnd[0], scsi_status,
+                       be32_to_cpu(*lp), be32_to_cpu(*(lp + 3)), resp_info,
                        be32_to_cpu(fcprsp->rspResId),
                        be32_to_cpu(fcprsp->rspSnsLen),
                        be32_to_cpu(fcprsp->rspRspLen),
@@ -327,14 +345,6 @@ lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd)
                }
        }
 
-       if ((resp_info & SNS_LEN_VALID) && fcprsp->rspSnsLen) {
-               uint32_t snslen = be32_to_cpu(fcprsp->rspSnsLen);
-               if (snslen > SCSI_SENSE_BUFFERSIZE)
-                       snslen = SCSI_SENSE_BUFFERSIZE;
-
-               memcpy(cmnd->sense_buffer, &fcprsp->rspInfo0 + rsplen, snslen);
-       }
-
        cmnd->resid = 0;
        if (resp_info & RESID_UNDER) {
                cmnd->resid = be32_to_cpu(fcprsp->rspResId);
@@ -377,7 +387,7 @@ lpfc_handle_fcp_err(struct lpfc_scsi_buf *lpfc_cmd)
         */
        } else if ((scsi_status == SAM_STAT_GOOD) && fcpi_parm &&
                        (cmnd->sc_data_direction == DMA_FROM_DEVICE)) {
-               lpfc_printf_log(phba, KERN_WARNING, LOG_FCP,
+               lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_FCP_ERROR,
                        "%d:0734 FCP Read Check Error Data: "
                        "x%x x%x x%x x%x\n", phba->brd_no,
                        be32_to_cpu(fcpcmd->fcpDl),
@@ -669,6 +679,9 @@ lpfc_scsi_tgt_reset(struct lpfc_scsi_buf * lpfc_cmd, struct lpfc_hba * phba,
        struct lpfc_iocbq *iocbqrsp;
        int ret;
 
+       if (!rdata->pnode)
+               return FAILED;
+
        lpfc_cmd->rdata = rdata;
        ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, lun,
                                           FCP_TARGET_RESET);
@@ -841,6 +854,21 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
        return 0;
 }
 
+static void
+lpfc_block_error_handler(struct scsi_cmnd *cmnd)
+{
+       struct Scsi_Host *shost = cmnd->device->host;
+       struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
+
+       spin_lock_irq(shost->host_lock);
+       while (rport->port_state == FC_PORTSTATE_BLOCKED) {
+               spin_unlock_irq(shost->host_lock);
+               msleep(1000);
+               spin_lock_irq(shost->host_lock);
+       }
+       spin_unlock_irq(shost->host_lock);
+       return;
+}
 
 static int
 lpfc_abort_handler(struct scsi_cmnd *cmnd)
@@ -855,6 +883,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
        unsigned int loop_count = 0;
        int ret = SUCCESS;
 
+       lpfc_block_error_handler(cmnd);
        spin_lock_irq(shost->host_lock);
 
        lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble;
@@ -918,7 +947,7 @@ lpfc_abort_handler(struct scsi_cmnd *cmnd)
                        schedule_timeout_uninterruptible(LPFC_ABORT_WAIT*HZ);
                spin_lock_irq(phba->host->host_lock);
                if (++loop_count
-                   > (2 * phba->cfg_nodev_tmo)/LPFC_ABORT_WAIT)
+                   > (2 * phba->cfg_devloss_tmo)/LPFC_ABORT_WAIT)
                        break;
        }
 
@@ -957,21 +986,36 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
        int ret = FAILED;
        int cnt, loopcnt;
 
+       lpfc_block_error_handler(cmnd);
        spin_lock_irq(shost->host_lock);
+       loopcnt = 0;
        /*
         * If target is not in a MAPPED state, delay the reset until
-        * target is rediscovered or nodev timeout expires.
+        * target is rediscovered or devloss timeout expires.
         */
        while ( 1 ) {
                if (!pnode)
-                       break;
+                       return FAILED;
 
                if (pnode->nlp_state != NLP_STE_MAPPED_NODE) {
                        spin_unlock_irq(phba->host->host_lock);
                        schedule_timeout_uninterruptible(msecs_to_jiffies(500));
                        spin_lock_irq(phba->host->host_lock);
+                       loopcnt++;
+                       rdata = cmnd->device->hostdata;
+                       if (!rdata ||
+                               (loopcnt > ((phba->cfg_devloss_tmo * 2) + 1))) {
+                               lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
+                                       "%d:0721 LUN Reset rport failure:"
+                                       " cnt x%x rdata x%p\n",
+                                       phba->brd_no, loopcnt, rdata);
+                               goto out;
+                       }
+                       pnode = rdata->pnode;
+                       if (!pnode)
+                               return FAILED;
                }
-               if ((pnode) && (pnode->nlp_state == NLP_STE_MAPPED_NODE))
+               if (pnode->nlp_state == NLP_STE_MAPPED_NODE)
                        break;
        }
 
@@ -1032,7 +1076,7 @@ lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
                spin_lock_irq(phba->host->host_lock);
 
                if (++loopcnt
-                   > (2 * phba->cfg_nodev_tmo)/LPFC_RESET_WAIT)
+                   > (2 * phba->cfg_devloss_tmo)/LPFC_RESET_WAIT)
                        break;
 
                cnt = lpfc_sli_sum_iocb(phba,
@@ -1073,6 +1117,7 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
        int cnt, loopcnt;
        struct lpfc_scsi_buf * lpfc_cmd;
 
+       lpfc_block_error_handler(cmnd);
        spin_lock_irq(shost->host_lock);
 
        lpfc_cmd = lpfc_get_scsi_buf(phba);
@@ -1104,7 +1149,7 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
                                          ndlp->rport->dd_data);
                if (ret != SUCCESS) {
                        lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
-                               "%d:0713 Bus Reset on target %d failed\n",
+                               "%d:0700 Bus Reset on target %d failed\n",
                                phba->brd_no, i);
                        err_count++;
                }
@@ -1132,7 +1177,7 @@ lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
                spin_lock_irq(phba->host->host_lock);
 
                if (++loopcnt
-                   > (2 * phba->cfg_nodev_tmo)/LPFC_RESET_WAIT)
+                   > (2 * phba->cfg_devloss_tmo)/LPFC_RESET_WAIT)
                        break;
 
                cnt = lpfc_sli_sum_iocb(phba,
@@ -1230,7 +1275,7 @@ lpfc_slave_configure(struct scsi_device *sdev)
         * target pointer is stored in the starget_data for the
         * driver's sysfs entry point functions.
         */
-       rport->dev_loss_tmo = phba->cfg_nodev_tmo + 5;
+       rport->dev_loss_tmo = phba->cfg_devloss_tmo;
 
        if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
                lpfc_sli_poll_fcp_ring(phba);