linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] qla4xxx: Fix underrun/overrun conditions
@ 2007-06-06 18:55 David C Somayajulu
  2007-07-09 19:44 ` David C Somayajulu
  0 siblings, 1 reply; 3+ messages in thread
From: David C Somayajulu @ 2007-06-06 18:55 UTC (permalink / raw)
  To: linux-scsi; +Cc: David Somayajulu, David Wagner, Mike Christie

This patch fixes the code handling underrun and overrun conditions.

Signed-off-by: David Somayajulu <david.somayajulu@qlogic.com>

 drivers/scsi/qla4xxx/ql4_isr.c     |   57 ++++++++++++++++++++----------------
 drivers/scsi/qla4xxx/ql4_version.h |    2 +-
 2 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_isr.c b/drivers/scsi/qla4xxx/ql4_isr.c
index b47bd85..fa8a477 100644
--- a/drivers/scsi/qla4xxx/ql4_isr.c
+++ b/drivers/scsi/qla4xxx/ql4_isr.c
@@ -93,9 +93,29 @@ static void qla4xxx_status_entry(struct
 			break;
 		}
 
-		if (sts_entry->iscsiFlags &
-		    (ISCSI_FLAG_RESIDUAL_OVER|ISCSI_FLAG_RESIDUAL_UNDER))
+		if (sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) {
+			cmd->result = DID_ERROR << 16;
+			break;
+		}
+
+		if (sts_entry->iscsiFlags &ISCSI_FLAG_RESIDUAL_UNDER) {
 			scsi_set_resid(cmd, residual);
+			if (!scsi_status && ((scsi_bufflen(cmd) - residual)
+				< cmd->underflow)) {
+
+				cmd->result = DID_ERROR << 16;
+
+				DEBUG2(printk("scsi%ld:%d:%d:%d: %s: "
+					"Mid-layer Data underrun0, "
+					"xferlen = 0x%x, "
+					"residual = 0x%x\n", ha->host_no,
+					cmd->device->channel,
+					cmd->device->id,
+					cmd->device->lun, __func__,
+					scsi_bufflen(cmd), residual));
+				break;
+			}
+		}
 
 		cmd->result = DID_OK << 16 | scsi_status;
 
@@ -164,7 +184,8 @@ static void qla4xxx_status_entry(struct
 
 	case SCS_DATA_UNDERRUN:
 	case SCS_DATA_OVERRUN:
-		if (sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) {
+		if ((sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) ||
+			(sts_entry->completionStatus == SCS_DATA_OVERRUN)) {
 			DEBUG2(printk("scsi%ld:%d:%d:%d: %s: " "Data overrun, "
 				      "residual = 0x%x\n", ha->host_no,
 				      cmd->device->channel, cmd->device->id,
@@ -174,21 +195,7 @@ static void qla4xxx_status_entry(struct
 			break;
 		}
 
-		if ((sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_UNDER) == 0) {
-			/*
-			 * Firmware detected a SCSI transport underrun
-			 * condition
-			 */
-			scsi_set_resid(cmd, residual);
-			DEBUG2(printk("scsi%ld:%d:%d:%d: %s: UNDERRUN status "
-				      "detected, xferlen = 0x%x, residual = "
-				      "0x%x\n",
-				      ha->host_no, cmd->device->channel,
-				      cmd->device->id,
-				      cmd->device->lun, __func__,
-				      scsi_bufflen(cmd),
-				      residual));
-		}
+		scsi_set_resid(cmd, residual);
 
 		/*
 		 * If there is scsi_status, it takes precedense over
@@ -245,13 +252,13 @@ static void qla4xxx_status_entry(struct
 				 * will return DID_ERROR.
 				 */
 				DEBUG2(printk("scsi%ld:%d:%d:%d: %s: "
-					      "Mid-layer Data underrun, "
-					      "xferlen = 0x%x, "
-					      "residual = 0x%x\n", ha->host_no,
-					      cmd->device->channel,
-					      cmd->device->id,
-					      cmd->device->lun, __func__,
-					      scsi_bufflen(cmd), residual));
+					"Mid-layer Data underrun1, "
+					"xferlen = 0x%x, "
+					"residual = 0x%x\n", ha->host_no,
+					cmd->device->channel,
+					cmd->device->id,
+					cmd->device->lun, __func__,
+					scsi_bufflen(cmd), residual));
 
 				cmd->result = DID_ERROR << 16;
 			} else {
diff --git a/drivers/scsi/qla4xxx/ql4_version.h b/drivers/scsi/qla4xxx/ql4_version.h
index 2149069..ab984cb 100644
--- a/drivers/scsi/qla4xxx/ql4_version.h
+++ b/drivers/scsi/qla4xxx/ql4_version.h
@@ -5,5 +5,5 @@
  * See LICENSE.qla4xxx for copyright and licensing details.
  */
 
-#define QLA4XXX_DRIVER_VERSION	"5.01.00-k7"
+#define QLA4XXX_DRIVER_VERSION	"5.01.00-k8"
 


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] qla4xxx: Fix underrun/overrun conditions
  2007-06-06 18:55 [PATCH] qla4xxx: Fix underrun/overrun conditions David C Somayajulu
@ 2007-07-09 19:44 ` David C Somayajulu
  2007-07-12 18:47   ` Mike Christie
  0 siblings, 1 reply; 3+ messages in thread
From: David C Somayajulu @ 2007-07-09 19:44 UTC (permalink / raw)
  To: linux-scsi; +Cc: David Wagner, Mike Christie

On Wed, 2007-06-06 at 11:55 -0700, David C Somayajulu wrote:
> This patch fixes the code handling underrun and overrun conditions.
Fix coding style as per Mike Christie's advice.

Signed-off-by: David Somayajulu <david.somayajulu@qlogic.com>

 drivers/scsi/qla4xxx/ql4_isr.c     |   57 ++++++++++++++++++++----------------
 drivers/scsi/qla4xxx/ql4_version.h |    2 +-
 2 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_isr.c b/drivers/scsi/qla4xxx/ql4_isr.c
index b47bd85..fa8a477 100644
--- a/drivers/scsi/qla4xxx/ql4_isr.c
+++ b/drivers/scsi/qla4xxx/ql4_isr.c
@@ -93,9 +93,29 @@ static void qla4xxx_status_entry(struct
 			break;
 		}
 
-		if (sts_entry->iscsiFlags &
-		    (ISCSI_FLAG_RESIDUAL_OVER|ISCSI_FLAG_RESIDUAL_UNDER))
+		if (sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) {
+			cmd->result = DID_ERROR << 16;
+			break;
+		}
+
+		if (sts_entry->iscsiFlags &ISCSI_FLAG_RESIDUAL_UNDER) {
 			scsi_set_resid(cmd, residual);
+			if (!scsi_status && ((scsi_bufflen(cmd) - residual) <
+				cmd->underflow)) {
+
+				cmd->result = DID_ERROR << 16;
+
+				DEBUG2(printk("scsi%ld:%d:%d:%d: %s: "
+					"Mid-layer Data underrun0, "
+					"xferlen = 0x%x, "
+					"residual = 0x%x\n", ha->host_no,
+					cmd->device->channel,
+					cmd->device->id,
+					cmd->device->lun, __func__,
+					scsi_bufflen(cmd), residual));
+				break;
+			}
+		}
 
 		cmd->result = DID_OK << 16 | scsi_status;
 
@@ -164,7 +184,8 @@ static void qla4xxx_status_entry(struct
 
 	case SCS_DATA_UNDERRUN:
 	case SCS_DATA_OVERRUN:
-		if (sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) {
+		if ((sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) ||
+			(sts_entry->completionStatus == SCS_DATA_OVERRUN)) {
 			DEBUG2(printk("scsi%ld:%d:%d:%d: %s: " "Data overrun, "
 				      "residual = 0x%x\n", ha->host_no,
 				      cmd->device->channel, cmd->device->id,
@@ -174,21 +195,7 @@ static void qla4xxx_status_entry(struct
 			break;
 		}
 
-		if ((sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_UNDER) == 0) {
-			/*
-			 * Firmware detected a SCSI transport underrun
-			 * condition
-			 */
-			scsi_set_resid(cmd, residual);
-			DEBUG2(printk("scsi%ld:%d:%d:%d: %s: UNDERRUN status "
-				      "detected, xferlen = 0x%x, residual = "
-				      "0x%x\n",
-				      ha->host_no, cmd->device->channel,
-				      cmd->device->id,
-				      cmd->device->lun, __func__,
-				      scsi_bufflen(cmd),
-				      residual));
-		}
+		scsi_set_resid(cmd, residual);
 
 		/*
 		 * If there is scsi_status, it takes precedense over
@@ -245,13 +252,13 @@ static void qla4xxx_status_entry(struct
 				 * will return DID_ERROR.
 				 */
 				DEBUG2(printk("scsi%ld:%d:%d:%d: %s: "
-					      "Mid-layer Data underrun, "
-					      "xferlen = 0x%x, "
-					      "residual = 0x%x\n", ha->host_no,
-					      cmd->device->channel,
-					      cmd->device->id,
-					      cmd->device->lun, __func__,
-					      scsi_bufflen(cmd), residual));
+					"Mid-layer Data underrun1, "
+					"xferlen = 0x%x, "
+					"residual = 0x%x\n", ha->host_no,
+					cmd->device->channel,
+					cmd->device->id,
+					cmd->device->lun, __func__,
+					scsi_bufflen(cmd), residual));
 
 				cmd->result = DID_ERROR << 16;
 			} else {
diff --git a/drivers/scsi/qla4xxx/ql4_version.h b/drivers/scsi/qla4xxx/ql4_version.h
index 2149069..ab984cb 100644
--- a/drivers/scsi/qla4xxx/ql4_version.h
+++ b/drivers/scsi/qla4xxx/ql4_version.h
@@ -5,5 +5,5 @@
  * See LICENSE.qla4xxx for copyright and licensing details.
  */
 
-#define QLA4XXX_DRIVER_VERSION	"5.01.00-k7"
+#define QLA4XXX_DRIVER_VERSION	"5.01.00-k8"
 


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] qla4xxx: Fix underrun/overrun conditions
  2007-07-09 19:44 ` David C Somayajulu
@ 2007-07-12 18:47   ` Mike Christie
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Christie @ 2007-07-12 18:47 UTC (permalink / raw)
  To: David C Somayajulu; +Cc: linux-scsi, David Wagner

David C Somayajulu wrote:
> On Wed, 2007-06-06 at 11:55 -0700, David C Somayajulu wrote:
>> This patch fixes the code handling underrun and overrun conditions.
> Fix coding style as per Mike Christie's advice.
> 
> Signed-off-by: David Somayajulu <david.somayajulu@qlogic.com>
> 

You missed a space, but I do not think people care much about that. The 
patch looks ok from a technical standpoint compared to what other 
drivers are doing.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-07-12 18:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-06 18:55 [PATCH] qla4xxx: Fix underrun/overrun conditions David C Somayajulu
2007-07-09 19:44 ` David C Somayajulu
2007-07-12 18:47   ` Mike Christie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).