]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[SCSI] qla4xxx: Fix underrun/overrun conditions
authorDavid C Somayajulu <david.somayajulu@qlogic.com>
Mon, 9 Jul 2007 19:44:36 +0000 (12:44 -0700)
committerJames Bottomley <jejb@mulgrave.localdomain>
Sun, 15 Jul 2007 00:11:38 +0000 (19:11 -0500)
On Wed, 2007-06-06 at 11:55 -0700, David C Somayajulu wrote:
This patch fixes the code handling underrun and overrun conditions.
Also fixed coding style as per Mike Christie's advice.

Signed-off-by: David Somayajulu <david.somayajulu@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/qla4xxx/ql4_isr.c
drivers/scsi/qla4xxx/ql4_version.h

index b47bd85f114d6ca02a9a49f3e3edb4fa6ea73dc9..4a154beb0d39ba90bf15e1b05b261fafe1bbec09 100644 (file)
@@ -93,9 +93,29 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha,
                        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 scsi_qla_host *ha,
 
        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 scsi_qla_host *ha,
                        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 scsi_qla_host *ha,
                                 * 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 {
index 2149069689bdc59d0f5d27b4ea177c8f9d824c42..ab984cb89cea53f14ee4c0cf6ab34dce1c48b82f 100644 (file)
@@ -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"