win-pvdrivers

changeset 869:34e72b071e51

Handle scsi resets properly
author James Harper <james.harper@bendigoit.com.au>
date Tue Mar 01 23:47:47 2011 +1100 (2011-03-01)
parents 9096c1757947
children bc0658d4bcee
files xenvbd/xenvbd_scsiport.c
line diff
     1.1 --- a/xenvbd/xenvbd_scsiport.c	Tue Mar 01 23:10:24 2011 +1100
     1.2 +++ b/xenvbd/xenvbd_scsiport.c	Tue Mar 01 23:47:47 2011 +1100
     1.3 @@ -989,7 +989,11 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
     1.4          block_count = decode_cdb_length(srb);
     1.5          block_count *= xvdd->bytes_per_sector / 512;
     1.6          /* a few errors occur in dump mode because Xen refuses to allow us to map pages we are using for other stuff. Just ignore them */
     1.7 -        if (rep->status == BLKIF_RSP_OKAY || (dump_mode &&  dump_mode_errors++ < DUMP_MODE_ERROR_LIMIT))
     1.8 +        if (srb->SrbStatus == SRB_STATUS_BUS_RESET)
     1.9 +        {
    1.10 +          KdPrint((__DRIVER_NAME "     completing SRB %p with status SRB_STATUS_BUS_RESET\n", srb));
    1.11 +        }
    1.12 +        else if (rep->status == BLKIF_RSP_OKAY || (dump_mode &&  dump_mode_errors++ < DUMP_MODE_ERROR_LIMIT))
    1.13            srb->SrbStatus = SRB_STATUS_SUCCESS;
    1.14          else
    1.15          {
    1.16 @@ -1018,7 +1022,7 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
    1.17            xvdd->last_additional_sense_code = SCSI_ADSENSE_NO_SENSE;
    1.18            XenVbd_MakeAutoSense(xvdd, srb);
    1.19          }
    1.20 -        if (shadow->aligned_buffer_in_use)
    1.21 +        if (srb->SrbStatus == SRB_STATUS_SUCCESS && shadow->aligned_buffer_in_use)
    1.22          {
    1.23            ASSERT(xvdd->aligned_buffer_in_use);
    1.24            xvdd->aligned_buffer_in_use = FALSE;
    1.25 @@ -1027,12 +1031,6 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
    1.26  //KdPrint((__DRIVER_NAME "     Completed use of buffer\n"));
    1.27          }
    1.28          
    1.29 -#if 0
    1.30 -if (xvdd->aligned_buffer_in_use)
    1.31 -{
    1.32 -KdPrint((__DRIVER_NAME "     Completed request while aligned buffer in use\n"));
    1.33 -}
    1.34 -#endif
    1.35          for (j = 0; j < shadow->req.nr_segments; j++)
    1.36          {
    1.37            if (dump_mode)
    1.38 @@ -1504,6 +1502,8 @@ static BOOLEAN
    1.39  XenVbd_HwScsiResetBus(PVOID DeviceExtension, ULONG PathId)
    1.40  {
    1.41    PXENVBD_DEVICE_DATA xvdd = DeviceExtension;
    1.42 +  srb_list_entry_t *srb_entry;
    1.43 +  PSCSI_REQUEST_BLOCK srb;
    1.44    int i;
    1.45  
    1.46    UNREFERENCED_PARAMETER(DeviceExtension);
    1.47 @@ -1512,19 +1512,34 @@ XenVbd_HwScsiResetBus(PVOID DeviceExtens
    1.48    FUNCTION_ENTER();
    1.49  
    1.50    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    1.51 +
    1.52 +  while((srb_entry = (srb_list_entry_t *)RemoveHeadList(&xvdd->srb_list)) != (srb_list_entry_t *)&xvdd->srb_list)
    1.53 +  {
    1.54 +    srb = srb_entry->srb;
    1.55 +    srb->SrbStatus = SRB_STATUS_BUS_RESET;
    1.56 +    KdPrint((__DRIVER_NAME "     completing queued SRB %p with status SRB_STATUS_BUS_RESET\n", srb));
    1.57 +    ScsiPortNotification(RequestComplete, xvdd, srb);
    1.58 +  }
    1.59    
    1.60    for (i = 0; i < MAX_SHADOW_ENTRIES; i++)
    1.61    {
    1.62      if (xvdd->shadows[i].srb)
    1.63      {
    1.64 -      KdPrint((__DRIVER_NAME "     shadow entry %d in use with srb %p\n", i, xvdd->shadows[i].srb));
    1.65 +      KdPrint((__DRIVER_NAME "     setting status SRB_STATUS_BUS_RESET for in-flight srb %p\n", xvdd->shadows[i].srb));
    1.66 +      xvdd->shadows[i].srb->SrbStatus = SRB_STATUS_BUS_RESET;
    1.67 +      /* can't complete now. It will have to be completed when it comes off the ring */
    1.68      }
    1.69    }
    1.70 +
    1.71 +  /* send a notify to Dom0 just in case it was missed for some reason (which should _never_ happen) */
    1.72 +  xvdd->vectors.EvtChn_Notify(xvdd->vectors.context, xvdd->event_channel);
    1.73    
    1.74 +/*
    1.75    if (xvdd->ring_detect_state == RING_DETECT_STATE_COMPLETE && xvdd->device_state->suspend_resume_state_pdo == SR_STATE_RUNNING)
    1.76    {
    1.77      ScsiPortNotification(NextRequest, DeviceExtension);
    1.78    }
    1.79 +*/
    1.80  
    1.81    FUNCTION_EXIT();
    1.82