win-pvdrivers

changeset 927:ca7b237a61b1 0.11.0.295

hibernation fixes
author James Harper <james.harper@bendigoit.com.au>
date Sat Jun 04 16:46:44 2011 +1000 (2011-06-04)
parents d16dfda0ebce
children 047bcd81cdc0
files xenpci/xenpci.c xenpci/xenpci_pdo.c
line diff
     1.1 --- a/xenpci/xenpci.c	Sat Jun 04 16:44:36 2011 +1000
     1.2 +++ b/xenpci/xenpci.c	Sat Jun 04 16:46:44 2011 +1000
     1.3 @@ -709,7 +709,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
     1.4    ASSERT(!balloon_mdl_head);
     1.5    balloon_mdl_head = XenPci_InitialBalloonDown();
     1.6  
     1.7 -#if (NTDDI_VERSION >= NTDDI_WS03SP1)  
     1.8 +#if (NTDDI_VERSION >= NTDDI_WS03SP1)
     1.9    dump_page = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE, XENPCI_POOL_TAG);
    1.10    status = KeInitializeCrashDumpHeader(DUMP_TYPE_FULL, 0, dump_page, PAGE_SIZE, &dump_header_size);
    1.11    KdPrint((__DRIVER_NAME "     KeInitializeCrashDumpHeader status = %08x, size = %d\n", status, dump_header_size));
     2.1 --- a/xenpci/xenpci_pdo.c	Sat Jun 04 16:44:36 2011 +1000
     2.2 +++ b/xenpci/xenpci_pdo.c	Sat Jun 04 16:46:44 2011 +1000
     2.3 @@ -557,9 +557,8 @@ XenPci_XenShutdownDevice(PVOID context)
     2.4    {
     2.5      XenPci_ChangeFrontendStateMap(device, xppdd->xb_shutdown_map);
     2.6    }
     2.7 -  else
     2.8 +  else if (xppdd->backend_state == XenbusStateClosing)
     2.9    {
    2.10 -    if (xppdd->backend_state == XenbusStateClosing)
    2.11        XenPci_ChangeFrontendState(device, XenbusStateClosed, XenbusStateClosed, 30000);
    2.12    }
    2.13  
    2.14 @@ -903,7 +902,7 @@ XenPci_XenConfigDevice(WDFDEVICE device)
    2.15    PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
    2.16  
    2.17    src = ExAllocatePoolWithTag(NonPagedPool, xppdd->config_page_length, XENPCI_POOL_TAG);
    2.18 -  dst = MmMapIoSpace(xppdd->config_page_phys, xppdd->config_page_length, MmNonCached);
    2.19 +  dst = MmMapIoSpace(xppdd->config_page_phys, xppdd->config_page_length, MmCached);
    2.20    memcpy(src, dst, xppdd->config_page_length);
    2.21    
    2.22    status = XenPci_XenConfigDeviceSpecifyBuffers(device, src, dst);
    2.23 @@ -1088,6 +1087,11 @@ XenPciPdo_EvtDeviceD0Entry(WDFDEVICE dev
    2.24      break;
    2.25    case WdfPowerDeviceD3:
    2.26      KdPrint((__DRIVER_NAME "     WdfPowerDeviceD3\n"));
    2.27 +    if (xppdd->hiber_usage_kludge)
    2.28 +    {
    2.29 +      KdPrint((__DRIVER_NAME "     (but really WdfPowerDevicePrepareForHibernation)\n"));
    2.30 +      previous_state = WdfPowerDevicePrepareForHibernation;
    2.31 +    }
    2.32      break;
    2.33    case WdfPowerDeviceD3Final:
    2.34      KdPrint((__DRIVER_NAME "     WdfPowerDeviceD3Final\n"));
    2.35 @@ -1100,24 +1104,6 @@ XenPciPdo_EvtDeviceD0Entry(WDFDEVICE dev
    2.36      break;  
    2.37    }
    2.38  
    2.39 -  if (previous_state == WdfPowerDevicePrepareForHibernation
    2.40 -      || (previous_state == WdfPowerDeviceD3 && xppdd->hiber_usage_kludge))
    2.41 -  {
    2.42 -    KdPrint((__DRIVER_NAME "     starting up from hibernation\n"));
    2.43 -  }
    2.44 -  else
    2.45 -  {
    2.46 -  }
    2.47 -
    2.48 -#if 0
    2.49 -  if (previous_state == WdfPowerDevicePrepareForHibernation || previous_state == WdfPowerDeviceD3 || previous_state == WdfPowerDeviceD3Final)
    2.50 -  {
    2.51 -    xppdd->requested_resources_ptr = xppdd->requested_resources_start;
    2.52 -    xppdd->assigned_resources_start = xppdd->assigned_resources_ptr = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE, XENPCI_POOL_TAG);
    2.53 -  }
    2.54 -  XenConfig_InitConfigPage(device);
    2.55 -#endif
    2.56 -
    2.57    status = XenPci_GetBackendAndAddWatch(device);
    2.58    if (!NT_SUCCESS(status))
    2.59    {
    2.60 @@ -1139,10 +1125,10 @@ XenPciPdo_EvtDeviceD0Entry(WDFDEVICE dev
    2.61      
    2.62      ADD_XEN_INIT_REQ(&xppdd->requested_resources_ptr, XEN_INIT_TYPE_END, NULL, NULL, NULL);
    2.63      src = xppdd->requested_resources_start;
    2.64 -    xppdd->requested_resources_ptr = xppdd->requested_resources_start = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE, XENPCI_POOL_TAG);;
    2.65 +    xppdd->requested_resources_ptr = xppdd->requested_resources_start = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE, XENPCI_POOL_TAG);
    2.66      xppdd->assigned_resources_ptr = xppdd->assigned_resources_start;
    2.67  
    2.68 -    dst = MmMapIoSpace(xppdd->config_page_phys, xppdd->config_page_length, MmNonCached);
    2.69 +    dst = MmMapIoSpace(xppdd->config_page_phys, xppdd->config_page_length, MmCached);
    2.70  
    2.71      status = XenPci_XenConfigDeviceSpecifyBuffers(device, src, dst);
    2.72  
    2.73 @@ -1191,6 +1177,11 @@ XenPciPdo_EvtDeviceD0Exit(WDFDEVICE devi
    2.74      break;
    2.75    case WdfPowerDeviceD3:
    2.76      KdPrint((__DRIVER_NAME "     WdfPowerDeviceD3\n"));
    2.77 +    if (xppdd->hiber_usage_kludge)
    2.78 +    {
    2.79 +      KdPrint((__DRIVER_NAME "     (but really WdfPowerDevicePrepareForHibernation)\n"));
    2.80 +      target_state = WdfPowerDevicePrepareForHibernation;
    2.81 +    }
    2.82      break;
    2.83    case WdfPowerDeviceD3Final:
    2.84      KdPrint((__DRIVER_NAME "     WdfPowerDeviceD3Final\n"));
    2.85 @@ -1203,10 +1194,10 @@ XenPciPdo_EvtDeviceD0Exit(WDFDEVICE devi
    2.86      break;  
    2.87    }
    2.88    
    2.89 -  if (target_state == WdfPowerDevicePrepareForHibernation
    2.90 -      || (target_state == WdfPowerDeviceD3 && xppdd->hiber_usage_kludge))
    2.91 +  if (target_state == WdfPowerDevicePrepareForHibernation)
    2.92    {
    2.93      KdPrint((__DRIVER_NAME "     not powering down as we are hibernating\n"));
    2.94 +    // should we set the backend state here so it's correct on resume???
    2.95    }
    2.96    else
    2.97    {
    2.98 @@ -1317,8 +1308,6 @@ XenPci_EvtChildListCreateDevice(WDFCHILD
    2.99    DECLARE_CONST_UNICODE_STRING(location, L"Xen Bus");
   2.100    PXENPCI_PDO_DEVICE_DATA xppdd;
   2.101    PXENPCI_DEVICE_DATA xpdd = GetXpdd(WdfChildListGetDevice(child_list));
   2.102 -  WDF_QUERY_INTERFACE_CONFIG interface_config;
   2.103 -  BUS_INTERFACE_STANDARD bus_interface;
   2.104    WDF_PDO_EVENT_CALLBACKS pdo_callbacks;
   2.105    WDF_PNPPOWER_EVENT_CALLBACKS child_pnp_power_callbacks;
   2.106    UCHAR pnp_minor_functions[] = { IRP_MN_START_DEVICE };
   2.107 @@ -1403,7 +1392,7 @@ XenPci_EvtChildListCreateDevice(WDFCHILD
   2.108    xppdd->wdf_device = child_device;
   2.109    xppdd->wdf_device_bus_fdo = WdfChildListGetDevice(child_list);
   2.110  
   2.111 -  xppdd->config_page_mdl = AllocateUncachedPage();
   2.112 +  xppdd->config_page_mdl = AllocatePage();
   2.113  
   2.114    xppdd->device_state.magic = XEN_DEVICE_STATE_MAGIC;
   2.115    xppdd->device_state.length = sizeof(XENPCI_DEVICE_STATE);
   2.116 @@ -1437,21 +1426,6 @@ XenPci_EvtChildListCreateDevice(WDFCHILD
   2.117    child_power_capabilities.DeviceState[PowerSystemShutdown]  = PowerDeviceD3;
   2.118    WdfDeviceSetPowerCapabilities(child_device, &child_power_capabilities);  
   2.119  
   2.120 -  status = WdfFdoQueryForInterface(xpdd->wdf_device, &GUID_BUS_INTERFACE_STANDARD, (PINTERFACE)&bus_interface,
   2.121 -            sizeof(BUS_INTERFACE_STANDARD), 1, NULL);
   2.122 -  if (!NT_SUCCESS(status))
   2.123 -  {
   2.124 -    KdPrint((__DRIVER_NAME "     WdfFdoQueryForInterface failed - %08x\n", status));
   2.125 -    return status;
   2.126 -  }
   2.127 -  WDF_QUERY_INTERFACE_CONFIG_INIT(&interface_config, (PINTERFACE)&bus_interface, &GUID_BUS_INTERFACE_STANDARD, NULL);
   2.128 -  status = WdfDeviceAddQueryInterface(child_device, &interface_config);
   2.129 -  if (!NT_SUCCESS(status))
   2.130 -  {
   2.131 -    KdPrint((__DRIVER_NAME "     WdfDeviceAddQueryInterface failed - %08x\n", status));
   2.132 -    return status;
   2.133 -  }
   2.134 -
   2.135    RtlStringCbCopyA(xppdd->path, ARRAY_SIZE(xppdd->path), identification->path);
   2.136    RtlStringCbCopyA(xppdd->device, ARRAY_SIZE(xppdd->device), identification->device);
   2.137    xppdd->index = identification->index;
   2.138 @@ -1586,7 +1560,7 @@ XenPci_Pdo_Resume(WDFDEVICE device)
   2.139        xppdd->requested_resources_ptr = xppdd->requested_resources_start = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE, XENPCI_POOL_TAG);;
   2.140        xppdd->assigned_resources_ptr = xppdd->assigned_resources_start;
   2.141  
   2.142 -      dst = MmMapIoSpace(xppdd->config_page_phys, xppdd->config_page_length, MmNonCached);
   2.143 +      dst = MmMapIoSpace(xppdd->config_page_phys, xppdd->config_page_length, MmCached);
   2.144  
   2.145        status = XenPci_XenConfigDeviceSpecifyBuffers(device, src, dst);
   2.146