win-pvdrivers

changeset 913:dae0e5c1f26c

Reorder initial ring bit width detection to fix the case where a bug check happens during hibernate
author James Harper <james.harper@bendigoit.com.au>
date Sat Apr 30 00:24:01 2011 +1000 (2011-04-30)
parents 1e795031439a
children 3c7778b9f877
files xenvbd/xenvbd_scsiport.c xenvbd/xenvbd_scsiport.h
line diff
     1.1 --- a/xenvbd/xenvbd_scsiport.c	Sat Apr 30 00:23:04 2011 +1000
     1.2 +++ b/xenvbd/xenvbd_scsiport.c	Sat Apr 30 00:24:01 2011 +1000
     1.3 @@ -158,9 +158,14 @@ XenVbd_InitFromConfig(PXENVBD_DEVICE_DAT
     1.4          xvdd->event_channel = PtrToUlong(value) & 0x3FFFFFFF;
     1.5          if (PtrToUlong(value) & 0x80000000)
     1.6          {
     1.7 +          xvdd->cached_use_other_valid = TRUE;
     1.8            xvdd->cached_use_other = (BOOLEAN)!!(PtrToUlong(value) & 0x40000000);
     1.9            KdPrint((__DRIVER_NAME "     cached_use_other = %d\n", xvdd->cached_use_other));
    1.10          }
    1.11 +        else
    1.12 +        {
    1.13 +          xvdd->cached_use_other_valid = FALSE;
    1.14 +        }
    1.15        }
    1.16        break;
    1.17      case XEN_INIT_TYPE_READ_STRING_BACK:
    1.18 @@ -345,9 +350,6 @@ decode_cdb_is_read(PSCSI_REQUEST_BLOCK s
    1.19    }
    1.20  }
    1.21  
    1.22 -ULONG max_dump_mode_blocks = 0;
    1.23 -ULONG max_dump_mode_length = 0;
    1.24 -
    1.25  static VOID
    1.26  XenVbd_PutSrbOnList(PXENVBD_DEVICE_DATA xvdd, PSCSI_REQUEST_BLOCK srb)
    1.27  {
    1.28 @@ -379,7 +381,11 @@ XenVbd_PutQueuedSrbsOnRing(PXENVBD_DEVIC
    1.29    ScsiPortQuerySystemTime(&current_time);
    1.30    #endif
    1.31    
    1.32 -  while(!xvdd->aligned_buffer_in_use && xvdd->shadow_free && (srb_entry = (srb_list_entry_t *)RemoveHeadList(&xvdd->srb_list)) != (srb_list_entry_t *)&xvdd->srb_list)
    1.33 +  while ((!dump_mode || xvdd->shadow_free == SHADOW_ENTRIES)
    1.34 +        && xvdd->ring_detect_state == RING_DETECT_STATE_COMPLETE
    1.35 +        && !xvdd->aligned_buffer_in_use
    1.36 +        && xvdd->shadow_free
    1.37 +        && (srb_entry = (srb_list_entry_t *)RemoveHeadList(&xvdd->srb_list)) != (srb_list_entry_t *)&xvdd->srb_list) /* RemoveHeadList must be last in the expression */
    1.38    {
    1.39      srb = srb_entry->srb;
    1.40      block_count = decode_cdb_length(srb);;
    1.41 @@ -466,17 +472,6 @@ XenVbd_PutQueuedSrbsOnRing(PXENVBD_DEVIC
    1.42        shadow->aligned_buffer_in_use = FALSE;
    1.43      }
    1.44  
    1.45 -    if (dump_mode && block_count > max_dump_mode_blocks)
    1.46 -    {
    1.47 -      max_dump_mode_blocks = block_count;
    1.48 -      KdPrint((__DRIVER_NAME "     max_dump_mode_blocks = %d\n", max_dump_mode_blocks));
    1.49 -    }
    1.50 -    if (dump_mode && srb->DataTransferLength > max_dump_mode_length)
    1.51 -    {
    1.52 -      max_dump_mode_length = srb->DataTransferLength;
    1.53 -      KdPrint((__DRIVER_NAME "     max_dump_mode_length = %d\n", max_dump_mode_length));
    1.54 -    }
    1.55 -
    1.56      //KdPrint((__DRIVER_NAME "     sector_number = %d, block_count = %d\n", (ULONG)shadow->req.sector_number, block_count));
    1.57      //KdPrint((__DRIVER_NAME "     SrbExtension = %p\n", srb->SrbExtension));
    1.58      //KdPrint((__DRIVER_NAME "     DataBuffer   = %p\n", srb->DataBuffer));
    1.59 @@ -553,7 +548,7 @@ XenVbd_PutQueuedSrbsOnRing(PXENVBD_DEVIC
    1.60    //FUNCTION_EXIT();
    1.61  }
    1.62  
    1.63 -static ULONG DDKAPI
    1.64 +static ULONG
    1.65  XenVbd_HwScsiFindAdapter(PVOID DeviceExtension, PVOID HwContext, PVOID BusInformation, PCHAR ArgumentString, PPORT_CONFIGURATION_INFORMATION ConfigInfo, PBOOLEAN Again)
    1.66  {
    1.67  //  PACCESS_RANGE AccessRange;
    1.68 @@ -686,11 +681,8 @@ XenVbd_HwScsiInitialize(PVOID DeviceExte
    1.69  
    1.70    if (!xvdd->inactive)
    1.71    {
    1.72 -    if (!dump_mode)
    1.73 -    {
    1.74 -      XenVbd_StartRingDetection(xvdd);
    1.75 -    }
    1.76 -    else
    1.77 +    xvdd->ring_detect_state = RING_DETECT_STATE_NOT_STARTED;
    1.78 +    if (xvdd->cached_use_other_valid)
    1.79      {
    1.80        if (xvdd->cached_use_other)
    1.81        {
    1.82 @@ -901,7 +893,7 @@ XenVbd_MakeAutoSense(PXENVBD_DEVICE_DATA
    1.83    srb->SrbStatus |= SRB_STATUS_AUTOSENSE_VALID;
    1.84  }
    1.85  
    1.86 -static BOOLEAN DDKAPI
    1.87 +static BOOLEAN
    1.88  XenVbd_HwScsiInterrupt(PVOID DeviceExtension)
    1.89  {
    1.90    PXENVBD_DEVICE_DATA xvdd = (PXENVBD_DEVICE_DATA)DeviceExtension;
    1.91 @@ -1136,7 +1128,7 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
    1.92    return last_interrupt;
    1.93  }
    1.94  
    1.95 -static BOOLEAN DDKAPI
    1.96 +static BOOLEAN
    1.97  XenVbd_HwScsiStartIo(PVOID DeviceExtension, PSCSI_REQUEST_BLOCK srb)
    1.98  {
    1.99    PUCHAR data_buffer;
   1.100 @@ -1157,10 +1149,8 @@ XenVbd_HwScsiStartIo(PVOID DeviceExtensi
   1.101    // If we haven't enumerated all the devices yet then just defer the request
   1.102    if (xvdd->ring_detect_state < RING_DETECT_STATE_COMPLETE)
   1.103    {
   1.104 -    srb->SrbStatus = SRB_STATUS_BUSY;
   1.105 -    ScsiPortNotification(RequestComplete, DeviceExtension, srb);
   1.106 -    KdPrint((__DRIVER_NAME " --- HwScsiStartIo (Still figuring out ring)\n"));
   1.107 -    return TRUE;
   1.108 +    if (xvdd->ring_detect_state == RING_DETECT_STATE_NOT_STARTED)
   1.109 +      XenVbd_StartRingDetection(xvdd);
   1.110    }
   1.111  
   1.112    if (xvdd->device_state->suspend_resume_state_pdo != SR_STATE_RUNNING)
   1.113 @@ -1615,7 +1605,7 @@ XenVbd_HwScsiAdapterState(PVOID DeviceEx
   1.114    return TRUE;
   1.115  }
   1.116  
   1.117 -static SCSI_ADAPTER_CONTROL_STATUS DDKAPI
   1.118 +static SCSI_ADAPTER_CONTROL_STATUS
   1.119  XenVbd_HwScsiAdapterControl(PVOID DeviceExtension, SCSI_ADAPTER_CONTROL_TYPE ControlType, PVOID Parameters)
   1.120  {
   1.121    PXENVBD_DEVICE_DATA xvdd = DeviceExtension;
   1.122 @@ -1646,7 +1636,7 @@ XenVbd_HwScsiAdapterControl(PVOID Device
   1.123      {
   1.124        if (XenVbd_InitFromConfig(xvdd) != SP_RETURN_FOUND)
   1.125          KeBugCheckEx(DATA_COHERENCY_EXCEPTION, 0, (ULONG_PTR) xvdd, 0, 0);
   1.126 -      XenVbd_StartRingDetection(xvdd);
   1.127 +      xvdd->ring_detect_state = RING_DETECT_STATE_NOT_STARTED;
   1.128      }
   1.129      break;
   1.130    case ScsiSetBootConfig:
     2.1 --- a/xenvbd/xenvbd_scsiport.h	Sat Apr 30 00:23:04 2011 +1000
     2.2 +++ b/xenvbd/xenvbd_scsiport.h	Sat Apr 30 00:24:01 2011 +1000
     2.3 @@ -139,6 +139,7 @@ struct
     2.4    int ring_detect_state;
     2.5    BOOLEAN use_other;
     2.6    BOOLEAN cached_use_other;
     2.7 +  BOOLEAN cached_use_other_valid;
     2.8    UCHAR last_sense_key;
     2.9    UCHAR last_additional_sense_code;
    2.10    blkif_response_t tmp_rep;