win-pvdrivers

changeset 810:1293cb31aa0b

try and allocate less memory for dump mode.
This appears to break hibernation by corrupting memory - not sure why yet
author James Harper <james.harper@bendigoit.com.au>
date Wed Aug 11 09:10:15 2010 +1000 (2010-08-11)
parents ff77e2f26a3e
children bf1b18b4728b
files xenvbd/xenvbd.c xenvbd/xenvbd.h
line diff
     1.1 --- a/xenvbd/xenvbd.c	Tue Jul 27 11:37:50 2010 +1000
     1.2 +++ b/xenvbd/xenvbd.c	Wed Aug 11 09:10:15 2010 +1000
     1.3 @@ -548,17 +548,6 @@ XenVbd_HwScsiFindAdapter(PVOID DeviceExt
     1.4    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
     1.5    KdPrint((__DRIVER_NAME "     xvdd = %p\n", xvdd));
     1.6  
     1.7 -  {
     1.8 -  int i;
     1.9 -  for (i = 0; i < sizeof(XENVBD_DEVICE_DATA); i++)
    1.10 -  {
    1.11 -    if (((PUCHAR)xvdd)[i])
    1.12 -    {
    1.13 -      KdPrint((__DRIVER_NAME "     DeviceExtension is not zeroed!!!\n"));
    1.14 -      break;
    1.15 -    }
    1.16 -  }
    1.17 -  }
    1.18    RtlZeroMemory(xvdd, sizeof(XENVBD_DEVICE_DATA));
    1.19    *Again = FALSE;
    1.20  
    1.21 @@ -601,30 +590,25 @@ XenVbd_HwScsiFindAdapter(PVOID DeviceExt
    1.22    KdPrint((__DRIVER_NAME "     aligned_buffer_data = %p\n", xvdd->aligned_buffer_data));
    1.23    KdPrint((__DRIVER_NAME "     aligned_buffer = %p\n", xvdd->aligned_buffer));
    1.24  
    1.25 -  ConfigInfo->MaximumTransferLength = BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE;
    1.26 -  ConfigInfo->NumberOfPhysicalBreaks = BLKIF_MAX_SEGMENTS_PER_REQUEST - 1;
    1.27 -  ConfigInfo->ScatterGather = TRUE;
    1.28 -
    1.29 -#if 0
    1.30    if (!dump_mode)
    1.31    {
    1.32      ConfigInfo->MaximumTransferLength = BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE;
    1.33      ConfigInfo->NumberOfPhysicalBreaks = BLKIF_MAX_SEGMENTS_PER_REQUEST - 1;
    1.34 -    ConfigInfo->ScatterGather = TRUE;
    1.35 +    //ConfigInfo->ScatterGather = TRUE;
    1.36    }
    1.37    else
    1.38    {
    1.39 -    ConfigInfo->MaximumTransferLength = 4096;
    1.40 -    ConfigInfo->NumberOfPhysicalBreaks = 0;
    1.41 -    ConfigInfo->ScatterGather = FALSE;
    1.42 +    ConfigInfo->MaximumTransferLength = BLKIF_MAX_SEGMENTS_PER_REQUEST_DUMP_MODE * PAGE_SIZE;
    1.43 +    ConfigInfo->NumberOfPhysicalBreaks = BLKIF_MAX_SEGMENTS_PER_REQUEST_DUMP_MODE - 1;
    1.44 +    //ConfigInfo->ScatterGather = FALSE;
    1.45    }
    1.46 -#endif
    1.47 +  ConfigInfo->ScatterGather = FALSE;
    1.48    ConfigInfo->AlignmentMask = 0;
    1.49    ConfigInfo->NumberOfBuses = 1;
    1.50    ConfigInfo->InitiatorBusId[0] = 1;
    1.51    ConfigInfo->MaximumNumberOfLogicalUnits = 1;
    1.52    ConfigInfo->MaximumNumberOfTargets = 2;
    1.53 -  ConfigInfo->BufferAccessScsiPortControlled = TRUE;
    1.54 +  ConfigInfo->BufferAccessScsiPortControlled = FALSE;
    1.55    if (ConfigInfo->Dma64BitAddresses == SCSI_DMA64_SYSTEM_SUPPORTED)
    1.56    {
    1.57      ConfigInfo->Master = TRUE;
    1.58 @@ -1708,7 +1692,10 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
    1.59  
    1.60    HwInitializationData.HwInitializationDataSize = sizeof(HW_INITIALIZATION_DATA);
    1.61    HwInitializationData.AdapterInterfaceType = PNPBus;
    1.62 -  HwInitializationData.DeviceExtensionSize = sizeof(XENVBD_DEVICE_DATA);
    1.63 +  if (!dump_mode)
    1.64 +    HwInitializationData.DeviceExtensionSize = FIELD_OFFSET(XENVBD_DEVICE_DATA, aligned_buffer_data) + UNALIGNED_BUFFER_DATA_SIZE;
    1.65 +  else
    1.66 +    HwInitializationData.DeviceExtensionSize = FIELD_OFFSET(XENVBD_DEVICE_DATA, aligned_buffer_data) + UNALIGNED_BUFFER_DATA_SIZE_DUMP_MODE;
    1.67    HwInitializationData.SpecificLuExtensionSize = 0;
    1.68    HwInitializationData.SrbExtensionSize = sizeof(srb_list_entry_t);
    1.69    HwInitializationData.NumberOfAccessRanges = 1;
     2.1 --- a/xenvbd/xenvbd.h	Tue Jul 27 11:37:50 2010 +1000
     2.2 +++ b/xenvbd/xenvbd.h	Wed Aug 11 09:10:15 2010 +1000
     2.3 @@ -141,7 +141,6 @@ struct
     2.4    grant_ref_t dump_grant_refs[BLKIF_MAX_SEGMENTS_PER_REQUEST];
     2.5    BOOLEAN aligned_buffer_in_use;
     2.6    PVOID aligned_buffer;
     2.7 -  UCHAR aligned_buffer_data[(BLKIF_MAX_SEGMENTS_PER_REQUEST + 1) * PAGE_SIZE - 1];
     2.8  /*  
     2.9    ULONGLONG interrupts;
    2.10    ULONGLONG aligned_requests;
    2.11 @@ -149,6 +148,12 @@ struct
    2.12    ULONGLONG unaligned_requests;
    2.13    ULONGLONG unaligned_bytes;
    2.14  */
    2.15 +  #define BLKIF_MAX_SEGMENTS_PER_REQUEST_DUMP_MODE 1
    2.16 +  #define UNALIGNED_BUFFER_DATA_SIZE ((BLKIF_MAX_SEGMENTS_PER_REQUEST + 1) * PAGE_SIZE - 1)
    2.17 +  #define UNALIGNED_BUFFER_DATA_SIZE_DUMP_MODE ((BLKIF_MAX_SEGMENTS_PER_REQUEST_DUMP_MODE + 1) * PAGE_SIZE - 1)
    2.18 +  /* this has to be right at the end of DeviceExtension */
    2.19 +  /* can't allocate too much data in dump mode so size DeviceExtensionSize accordingly */
    2.20 +  UCHAR aligned_buffer_data[1];
    2.21  } typedef XENVBD_DEVICE_DATA, *PXENVBD_DEVICE_DATA;
    2.22  
    2.23  #endif