Skip to contentSkip to conversation

PATCH [2/18] qla2xxx: Correct residual counts

PATCH Andrew Vasquez 2 participants 2 messages Jun 22, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

ChangeSet
1.1838 04/06/03 15:24:43 [email protected] +2 -0 Problem reported/corrected by Tony Battersby [[email protected]]:

o The qla2xxx driver calculates data transfer residuals for some but not all circumstances. The patch below adds data transfer residual calculations for the remaining cases.

o Interrogate the proper cmnd[] array when determining the transfer direction.

 drivers/scsi/qla2xxx/qla_iocb.c |    2 +-
 drivers/scsi/qla2xxx/qla_isr.c  |   13 ++++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/scsi/qla2xxx/qla_iocb.c +1 -1
diff -Nru a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -43,7 +43,7 @@
 	else if (cmd->sc_data_direction == DMA_FROM_DEVICE)
 		cflags = CF_READ;
 	else {
-		switch (cmd->data_cmnd[0]) {
+		switch (cmd->cmnd[0]) {
 		case WRITE_6:
 		case WRITE_10:
 		case WRITE_12:
drivers/scsi/qla2xxx/qla_isr.c +10 -3
diff -Nru a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
@@ -827,7 +827,7 @@
 	uint16_t	comp_status;
 	uint16_t	scsi_status;
 	uint8_t		lscsi_status;
-	uint32_t	resid;
+	int32_t		resid;
 	uint8_t		sense_sz = 0;
 	uint16_t	rsp_info_len;
 
@@ -948,6 +948,11 @@
 			cp->result = DID_OK << 16;
 			break;
 		}
+		if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER)) {
+			resid = le32_to_cpu(pkt->residual_length);
+			cp->resid = resid;
+			CMD_RESID_LEN(cp) = resid;
+		}
 		if (lscsi_status == SS_BUSY_CONDITION) {
 			cp->result = DID_BUS_BUSY << 16 | lscsi_status;
 			break;
@@ -1009,7 +1014,10 @@
 		    ha->host_no, t, l, comp_status, scsi_status));
 
 		resid = le32_to_cpu(pkt->residual_length);
-		CMD_RESID_LEN(cp) = resid;
+		if (scsi_status & SS_RESIDUAL_UNDER) {
+			cp->resid = resid;
+			CMD_RESID_LEN(cp) = resid;
+		}
 
 		/*
 		 * Check to see if SCSI Status is non zero. If so report SCSI 
@@ -1085,7 +1093,6 @@
 			}
 
 			/* Handle mid-layer underflow */
-			cp->resid = resid;
 			if ((unsigned)(cp->request_bufflen - resid) <
 			    cp->underflow) {
 				qla_printk(KERN_INFO, ha,
#1 lore raw

drivers/scsi/qla2xxx/qla_iocb.c line 49

Quoted 12 lines · Andrew Vasquez

diff -Nru a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c

drivers/scsi/qla2xxx/qla_iocb.c +1 -1
@@ -43,7 +43,7 @@
 	else if (cmd->sc_data_direction == DMA_FROM_DEVICE)
 		cflags = CF_READ;
 	else {
-		switch (cmd->data_cmnd[0]) {
+		switch (cmd->cmnd[0]) {
 		case WRITE_6:
 		case WRITE_10:
 		case WRITE_12:

this sounds wrong. Is there any reason qlogic drivers can't use/trust the midlayer instead of doing qla2x00_get_cmd_direction() to reverse engineer to direction ??