[PATCH] qla2xxx: remove internal queuing...

Remove internal command queuing from the driver.  As is, this
driver cannot tolerate cable-pulls as I/Os will begin to fail
by the upper layers.

     o Should be used in conjuction with the
       11-fc_rport_adds_2.diff patch.
     o Removes qla_listops.h file -- no longer needed.

Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 603d4c6..6e7eaaf 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -27,8 +27,6 @@
 static void qla2x00_error_entry(scsi_qla_host_t *, sts_entry_t *);
 static void qla2x00_ms_entry(scsi_qla_host_t *, ms_iocb_entry_t *);
 
-static int qla2x00_check_sense(struct scsi_cmnd *cp, os_lun_t *);
-
 /**
  * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200.
  * @irq:
@@ -93,7 +91,6 @@
 	}
 	spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
-	qla2x00_next(ha);
 	ha->last_irq_cpu = _smp_processor_id();
 	ha->total_isr_cnt++;
 
@@ -107,9 +104,6 @@
 		spin_unlock_irqrestore(&ha->mbx_reg_lock, flags);
 	}
 
-	if (!list_empty(&ha->done_queue))
-		qla2x00_done(ha);
-
 	return (IRQ_HANDLED);
 }
 
@@ -206,7 +200,6 @@
 	}
 	spin_unlock_irqrestore(&ha->hardware_lock, flags);
 
-	qla2x00_next(ha);
 	ha->last_irq_cpu = _smp_processor_id();
 	ha->total_isr_cnt++;
 
@@ -220,9 +213,6 @@
 		spin_unlock_irqrestore(&ha->mbx_reg_lock, flags);
 	}
 
-	if (!list_empty(&ha->done_queue))
-		qla2x00_done(ha);
-
 	return (IRQ_HANDLED);
 }
 
@@ -714,7 +704,7 @@
 		/* Save ISP completion status */
 		sp->cmd->result = DID_OK << 16;
 		sp->fo_retry_cnt = 0;
-		add_to_done_queue(ha, sp);
+		qla2x00_sp_compl(ha, sp);
 	} else {
 		DEBUG2(printk("scsi(%ld): Invalid ISP SCSI completion handle\n",
 		    ha->host_no));
@@ -914,24 +904,6 @@
 	tq = sp->tgt_queue;
 	lq = sp->lun_queue;
 
-	/*
-	 * If loop is in transient state Report DID_BUS_BUSY
-	 */
-	if ((comp_status != CS_COMPLETE || scsi_status != 0)) {
-		if (!(sp->flags & (SRB_IOCTL | SRB_TAPE)) &&
-		    (atomic_read(&ha->loop_down_timer) ||
-			atomic_read(&ha->loop_state) != LOOP_READY)) {
-
-			DEBUG2(printk("scsi(%ld:%d:%d:%d): Loop Not Ready - "
-			    "pid=%lx.\n",
-			    ha->host_no, b, t, l, cp->serial_number));
-
-			qla2x00_extend_timeout(cp, EXTEND_CMD_TIMEOUT);
-			add_to_retry_queue(ha, sp);
-			return;
-		}
-	}
-
 	/* Check for any FCP transport errors. */
 	if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) {
 		rsp_info_len = le16_to_cpu(pkt->rsp_info_len);
@@ -945,7 +917,7 @@
 			    pkt->rsp_info[6], pkt->rsp_info[7]));
 
 			cp->result = DID_BUS_BUSY << 16;
-			add_to_done_queue(ha, sp);
+			qla2x00_sp_compl(ha, sp);
 			return;
 		}
 	}
@@ -964,11 +936,6 @@
 			cp->resid = resid;
 			CMD_RESID_LEN(cp) = resid;
 		}
-		if (lscsi_status == SS_BUSY_CONDITION) {
-			cp->result = DID_BUS_BUSY << 16 | lscsi_status;
-			break;
-		}
-
 		cp->result = DID_OK << 16 | lscsi_status;
 
 		if (lscsi_status != SS_CHECK_CONDITION)
@@ -1002,14 +969,6 @@
 		if (sp->request_sense_length != 0)
 			ha->status_srb = sp;
 
-		if (!(sp->flags & (SRB_IOCTL | SRB_TAPE)) &&
-		    qla2x00_check_sense(cp, lq) == QLA_SUCCESS) {
-			/* Throw away status_cont if any */
-			ha->status_srb = NULL;
-			add_to_scsi_retry_queue(ha, sp);
-			return;
-		}
-
 		DEBUG5(printk("%s(): Check condition Sense data, "
 		    "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n",
 		    __func__, ha->host_no, b, t, l, cp,
@@ -1035,12 +994,6 @@
 		 * Status.
 		 */
 		if (lscsi_status != 0) {
-			if (lscsi_status == SS_BUSY_CONDITION) {
-				cp->result = DID_BUS_BUSY << 16 |
-				    lscsi_status;
-				break;
-			}
-
 			cp->result = DID_OK << 16 | lscsi_status;
 
 			if (lscsi_status != SS_CHECK_CONDITION)
@@ -1072,12 +1025,6 @@
 			if (sp->request_sense_length != 0)
 				ha->status_srb = sp;
 
-			if (!(sp->flags & (SRB_IOCTL | SRB_TAPE)) &&
-			    (qla2x00_check_sense(cp, lq) == QLA_SUCCESS)) {
-				ha->status_srb = NULL;
-				add_to_scsi_retry_queue(ha, sp);
-				return;
-			}
 			DEBUG5(printk("%s(): Check condition Sense data, "
 			    "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n",
 			    __func__, ha->host_no, b, t, l, cp,
@@ -1155,24 +1102,10 @@
 		    ha->host_no, t, l, cp->serial_number, comp_status,
 		    atomic_read(&fcport->state)));
 
-		if ((sp->flags & (SRB_IOCTL | SRB_TAPE)) ||
-		    atomic_read(&fcport->state) == FCS_DEVICE_DEAD) {
-			cp->result = DID_NO_CONNECT << 16;
-			if (atomic_read(&ha->loop_state) == LOOP_DOWN) 
-				sp->err_id = SRB_ERR_LOOP;
-			else
-				sp->err_id = SRB_ERR_PORT;
-			add_to_done_queue(ha, sp);
-		} else {
-			qla2x00_extend_timeout(cp, EXTEND_CMD_TIMEOUT);
-			add_to_retry_queue(ha, sp);
-		}
-
+		cp->result = DID_BUS_BUSY << 16;
 		if (atomic_read(&fcport->state) == FCS_ONLINE) {
 			qla2x00_mark_device_lost(ha, fcport, 1);
 		}
-
-		return;
 		break;
 
 	case CS_RESET:
@@ -1180,13 +1113,7 @@
 		    "scsi(%ld): RESET status detected 0x%x-0x%x.\n",
 		    ha->host_no, comp_status, scsi_status));
 
-		if (sp->flags & (SRB_IOCTL | SRB_TAPE)) {
-			cp->result = DID_RESET << 16;
-		} else {
-			qla2x00_extend_timeout(cp, EXTEND_CMD_TIMEOUT);
-			add_to_retry_queue(ha, sp);
-			return;
-		}
+		cp->result = DID_RESET << 16;
 		break;
 
 	case CS_ABORTED:
@@ -1253,7 +1180,7 @@
 
 	/* Place command on done queue. */
 	if (ha->status_srb == NULL)
-		add_to_done_queue(ha, sp);
+		qla2x00_sp_compl(ha, sp);
 }
 
 /**
@@ -1298,8 +1225,8 @@
 
 		/* Place command on done queue. */
 		if (sp->request_sense_length == 0) {
-			add_to_done_queue(ha, sp);
 			ha->status_srb = NULL;
+			qla2x00_sp_compl(ha, sp);
 		}
 	}
 }
@@ -1353,8 +1280,7 @@
 		} else {
 			sp->cmd->result = DID_ERROR << 16;
 		}
-		/* Place command on done queue. */
-		add_to_done_queue(ha, sp);
+		qla2x00_sp_compl(ha, sp);
 
 	} else if (pkt->entry_type == COMMAND_A64_TYPE ||
 	    pkt->entry_type == COMMAND_TYPE) {
@@ -1403,62 +1329,5 @@
 	/* Free outstanding command slot. */
 	ha->outstanding_cmds[pkt->handle1] = NULL;
 
-	add_to_done_queue(ha, sp);
-}
-
-/**
- * qla2x00_check_sense() - Perform any sense data interrogation.
- * @cp: SCSI Command
- * @lq: Lun queue
- *
- * Returns QLA_SUCCESS if the lun queue is suspended, else
- * QLA_FUNCTION_FAILED  (lun queue not suspended).
- */
-static int 
-qla2x00_check_sense(struct scsi_cmnd *cp, os_lun_t *lq)
-{
-	scsi_qla_host_t	*ha;
-	srb_t		*sp;
-	fc_port_t	*fcport;
-
-	ha = (scsi_qla_host_t *) cp->device->host->hostdata;
-	if ((cp->sense_buffer[0] & 0x70) != 0x70) {
-		return (QLA_FUNCTION_FAILED);
-	}
-
-	sp = (srb_t * )CMD_SP(cp);
-	sp->flags |= SRB_GOT_SENSE;
-
-	switch (cp->sense_buffer[2] & 0xf) {
-	case RECOVERED_ERROR:
-		cp->result = DID_OK << 16;
-		cp->sense_buffer[0] = 0;
-		break;
-
-	case NOT_READY:
-		fcport = lq->fclun->fcport;
-
-		/*
-		 * Suspend the lun only for hard disk device type.
-		 */
-		if ((fcport->flags & FCF_TAPE_PRESENT) == 0 &&
-		    lq->q_state != LUN_STATE_TIMEOUT) {
-			/*
-			 * If target is in process of being ready then suspend
-			 * lun for 6 secs and retry all the commands.
-			 */
-			if (cp->sense_buffer[12] == 0x4 &&
-			    cp->sense_buffer[13] == 0x1) {
-
-				/* Suspend the lun for 6 secs */
-				qla2x00_suspend_lun(ha, lq, 6,
-				    ql2xsuspendcount);
-
-				return (QLA_SUCCESS);
-			}
-		}
-		break;
-	}
-
-	return (QLA_FUNCTION_FAILED);
+	qla2x00_sp_compl(ha, sp);
 }