win-pvdrivers

changeset 389:3ffdcb607981

More changes to support save/restore. Mostly around making sure things are called at the correct IRQL
author James Harper <james.harper@bendigoit.com.au>
date Mon Jul 14 20:03:18 2008 +1000 (2008-07-14)
parents 81b5f730455b
children 46b6fa5bb7ad
files xenpci/evtchn.c xenpci/xenpci.h xenpci/xenpci_fdo.c
line diff
     1.1 --- a/xenpci/evtchn.c	Fri Jul 11 20:41:07 2008 +1000
     1.2 +++ b/xenpci/evtchn.c	Mon Jul 14 20:03:18 2008 +1000
     1.3 @@ -251,8 +251,8 @@ EvtChn_AllocUnbound(PVOID Context, domid
     1.4    return op.port;
     1.5  }
     1.6  
     1.7 -static VOID
     1.8 -EvtChn_Connect(PXENPCI_DEVICE_DATA xpdd)
     1.9 +NTSTATUS
    1.10 +EvtChn_Init(PXENPCI_DEVICE_DATA xpdd)
    1.11  {
    1.12    int i;
    1.13  
    1.14 @@ -285,15 +285,17 @@ EvtChn_Connect(PXENPCI_DEVICE_DATA xpdd)
    1.15    }
    1.16    
    1.17    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    1.18 +  
    1.19 +  return STATUS_SUCCESS;
    1.20  }
    1.21  
    1.22  NTSTATUS
    1.23 -EvtChn_Init(PXENPCI_DEVICE_DATA xpdd)
    1.24 +EvtChn_ConnectInterrupt(PXENPCI_DEVICE_DATA xpdd)
    1.25  {
    1.26    NTSTATUS status;
    1.27    
    1.28 -  EvtChn_Connect(xpdd);
    1.29 -  
    1.30 +  ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
    1.31 +
    1.32    status = IoConnectInterrupt(
    1.33      &xpdd->interrupt,
    1.34    	EvtChn_Interrupt,
     2.1 --- a/xenpci/xenpci.h	Fri Jul 11 20:41:07 2008 +1000
     2.2 +++ b/xenpci/xenpci.h	Mon Jul 14 20:03:18 2008 +1000
     2.3 @@ -402,8 +402,12 @@ XenPci_AllocMMIO(PXENPCI_DEVICE_DATA xpd
     2.4  
     2.5  NTSTATUS
     2.6  EvtChn_Init(PXENPCI_DEVICE_DATA xpdd);
     2.7 +NTSTATUS
     2.8 +EvtChn_ConnectInterrupt(PXENPCI_DEVICE_DATA xpdd);
     2.9 +/*
    2.10  VOID
    2.11  EvtChn_Resume(PXENPCI_DEVICE_DATA xpdd);
    2.12 +*/
    2.13  NTSTATUS
    2.14  EvtChn_Shutdown(PXENPCI_DEVICE_DATA xpdd);
    2.15  
     3.1 --- a/xenpci/xenpci_fdo.c	Fri Jul 11 20:41:07 2008 +1000
     3.2 +++ b/xenpci/xenpci_fdo.c	Mon Jul 14 20:03:18 2008 +1000
     3.3 @@ -311,6 +311,7 @@ struct {
     3.4    KEVENT stopped_spinning_event;
     3.5  } typedef SUSPEND_INFO, *PSUSPEND_INFO;
     3.6  
     3.7 +/* runs at PASSIVE_LEVEL */
     3.8  static DDKAPI VOID
     3.9  XenPci_CompleteResume(PDEVICE_OBJECT device_object, PVOID context)
    3.10  {
    3.11 @@ -330,6 +331,9 @@ XenPci_CompleteResume(PDEVICE_OBJECT dev
    3.12    }
    3.13    KdPrint((__DRIVER_NAME "     all other processors have stopped spinning\n"));
    3.14  
    3.15 +  /* this has to be done at PASSIVE_LEVEL */
    3.16 +  EvtChn_ConnectInterrupt(xpdd);
    3.17 +
    3.18    XenBus_Resume(xpdd);
    3.19  
    3.20    for (child = (PXEN_CHILD)xpdd->child_list.Flink; child != (PXEN_CHILD)&xpdd->child_list; child = (PXEN_CHILD)child->entry.Flink)
    3.21 @@ -400,6 +404,7 @@ XenPci_Suspend(
    3.22    KdPrint((__DRIVER_NAME "     all other processors are spinning\n"));
    3.23  
    3.24    xpdd->suspend_state = SUSPEND_STATE_HIGH_IRQL;
    3.25 +  KeMemoryBarrier();
    3.26    
    3.27    KdPrint((__DRIVER_NAME "     calling suspend\n"));
    3.28    cancelled = hvm_shutdown(Context, SHUTDOWN_suspend);
    3.29 @@ -417,8 +422,9 @@ XenPci_Suspend(
    3.30      child->context->device_state.resume_state = RESUME_STATE_BACKEND_RESUME;
    3.31    }
    3.32  
    3.33 +  KeLowerIrql(old_irql);
    3.34    xpdd->suspend_state = SUSPEND_STATE_RESUMING;
    3.35 -  KeLowerIrql(old_irql);
    3.36 +  KeMemoryBarrier();
    3.37    
    3.38    KdPrint((__DRIVER_NAME "     waiting for all other processors to stop spinning\n"));
    3.39    suspend_info->do_spin = 0;
    3.40 @@ -451,9 +457,7 @@ XenPci_BeginSuspend(PXENPCI_DEVICE_DATA 
    3.41      KeInitializeEvent(&suspend_info->stopped_spinning_event, SynchronizationEvent, FALSE);
    3.42      suspend_info->do_spin = 1;
    3.43  
    3.44 -    // I think we need to synchronise with the interrupt here...
    3.45 -
    3.46 -    for (i = 0; i < MAX_VIRT_CPUS; i++)
    3.47 +     for (i = 0; i < MAX_VIRT_CPUS; i++)
    3.48      {
    3.49        xpdd->shared_info_area->vcpu_info[i].evtchn_upcall_mask = 1;
    3.50      }
    3.51 @@ -626,6 +630,7 @@ XenPci_Pnp_StartDeviceCallback(PDEVICE_O
    3.52    GntTbl_Init(xpdd);
    3.53  
    3.54    EvtChn_Init(xpdd);
    3.55 +  EvtChn_ConnectInterrupt(xpdd);
    3.56  
    3.57    XenBus_Init(xpdd);
    3.58