win-pvdrivers

changeset 888:33b9eccb6301

clean up scsiport vbd driver reset code
author James Harper <james.harper@bendigoit.com.au>
date Thu Mar 17 00:04:06 2011 +1100 (2011-03-17)
parents 9fb72b19a208
children 4b8b40cda748
files xenvbd/xenvbd_scsiport.c
line diff
     1.1 --- a/xenvbd/xenvbd_scsiport.c	Wed Mar 16 17:23:55 2011 +1100
     1.2 +++ b/xenvbd/xenvbd_scsiport.c	Thu Mar 17 00:04:06 2011 +1100
     1.3 @@ -281,12 +281,6 @@ XenVbd_InitFromConfig(PXENVBD_DEVICE_DAT
     1.4        if (dump_mode)
     1.5          xvdd->shadows[i].req.id |= SHADOW_ID_DUMP_FLAG;
     1.6        put_shadow_on_freelist(xvdd, &xvdd->shadows[i]);
     1.7 -      if (dump_mode)
     1.8 -      {
     1.9 -        /* set reset = TRUE to pick up in-flight requests when dump mode kicked in */
    1.10 -        /* do it after put_shadow_on_freelist because that resets the reset flag */
    1.11 -        xvdd->shadows[i].reset = TRUE;
    1.12 -      }
    1.13      }
    1.14    }
    1.15    
    1.16 @@ -1019,6 +1013,19 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
    1.17          if (shadow->reset)
    1.18          {
    1.19            KdPrint((__DRIVER_NAME "     discarding reset shadow\n"));
    1.20 +          for (j = 0; j < shadow->req.nr_segments; j++)
    1.21 +          {
    1.22 +            if (dump_mode)
    1.23 +            {
    1.24 +              xvdd->vectors.GntTbl_EndAccess(xvdd->vectors.context,
    1.25 +                shadow->req.seg[j].gref, TRUE, (ULONG)'SCSI');
    1.26 +            }
    1.27 +            else
    1.28 +            {
    1.29 +              xvdd->vectors.GntTbl_EndAccess(xvdd->vectors.context,
    1.30 +                shadow->req.seg[j].gref, FALSE, (ULONG)'SCSI');
    1.31 +            }
    1.32 +          }
    1.33          }
    1.34          else if (dump_mode && !(rep->id & SHADOW_ID_DUMP_FLAG))
    1.35          {
    1.36 @@ -1027,7 +1034,7 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
    1.37          else
    1.38          {
    1.39            srb = shadow->srb;
    1.40 -          ASSERT(srb != NULL);
    1.41 +          ASSERT(srb);
    1.42            block_count = decode_cdb_length(srb);
    1.43            block_count *= xvdd->bytes_per_sector / 512;
    1.44            #if DBG && NTDDI_VERSION >= NTDDI_WINXP
    1.45 @@ -1066,29 +1073,28 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
    1.46              xvdd->last_additional_sense_code = SCSI_ADSENSE_NO_SENSE;
    1.47              XenVbd_MakeAutoSense(xvdd, srb);
    1.48            }
    1.49 -          if (srb->SrbStatus == SRB_STATUS_SUCCESS && shadow->aligned_buffer_in_use)
    1.50 +          if (shadow->aligned_buffer_in_use)
    1.51            {
    1.52              ASSERT(xvdd->aligned_buffer_in_use);
    1.53              xvdd->aligned_buffer_in_use = FALSE;
    1.54 -            if (decode_cdb_is_read(srb))
    1.55 +            if (srb->SrbStatus == SRB_STATUS_SUCCESS && decode_cdb_is_read(srb))
    1.56                memcpy(srb->DataBuffer, xvdd->aligned_buffer, block_count * 512);
    1.57            }
    1.58 +          for (j = 0; j < shadow->req.nr_segments; j++)
    1.59 +          {
    1.60 +            if (dump_mode)
    1.61 +            {
    1.62 +              xvdd->vectors.GntTbl_EndAccess(xvdd->vectors.context,
    1.63 +                shadow->req.seg[j].gref, TRUE, (ULONG)'SCSI');
    1.64 +            }
    1.65 +            else
    1.66 +            {
    1.67 +              xvdd->vectors.GntTbl_EndAccess(xvdd->vectors.context,
    1.68 +                shadow->req.seg[j].gref, FALSE, (ULONG)'SCSI');
    1.69 +            }
    1.70 +          }
    1.71            ScsiPortNotification(RequestComplete, xvdd, srb);
    1.72          }
    1.73 -        
    1.74 -        for (j = 0; j < shadow->req.nr_segments; j++)
    1.75 -        {
    1.76 -          if (dump_mode)
    1.77 -          {
    1.78 -            xvdd->vectors.GntTbl_EndAccess(xvdd->vectors.context,
    1.79 -              shadow->req.seg[j].gref, TRUE, (ULONG)'SCSI');
    1.80 -          }
    1.81 -          else
    1.82 -          {
    1.83 -            xvdd->vectors.GntTbl_EndAccess(xvdd->vectors.context,
    1.84 -              shadow->req.seg[j].gref, FALSE, (ULONG)'SCSI');
    1.85 -          }
    1.86 -        }
    1.87          shadow->aligned_buffer_in_use = FALSE;
    1.88          shadow->reset = FALSE;
    1.89          shadow->srb = NULL;
    1.90 @@ -1556,6 +1562,7 @@ XenVbd_HwScsiResetBus(PVOID DeviceExtens
    1.91    FUNCTION_ENTER();
    1.92  
    1.93    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    1.94 +  xvdd->aligned_buffer_in_use = FALSE;
    1.95  
    1.96    if (xvdd->ring_detect_state == RING_DETECT_STATE_COMPLETE && xvdd->device_state->suspend_resume_state_pdo == SR_STATE_RUNNING)
    1.97    {
    1.98 @@ -1577,6 +1584,7 @@ XenVbd_HwScsiResetBus(PVOID DeviceExtens
    1.99          xvdd->shadows[i].srb->SrbStatus = SRB_STATUS_BUS_RESET;
   1.100          ScsiPortNotification(RequestComplete, xvdd, xvdd->shadows[i].srb);
   1.101          xvdd->shadows[i].srb = NULL;
   1.102 +        xvdd->shadows[i].aligned_buffer_in_use = FALSE;
   1.103        }
   1.104      }
   1.105