win-pvdrivers

changeset 68:7ae8e22810a3

move event processing to a DPC; random warning fixes

I turned on driver verifier for xenpci and xennet and it didn't like us executing the event handling code and calling KeSetEvent at interrupt level. I moved it all to a DPC and it all still seems to work fine.
I also fixed some trivial warnings in xenpci.
author Andy Grover <andy.grover@oracle.com>
date Wed Dec 19 11:23:47 2007 -0800 (2007-12-19)
parents 6de0f54b913c
children a41314faf255
files xenpci/evtchn.c xenpci/xenpci.c xenpci/xenpci.h
line diff
     1.1 --- a/xenpci/evtchn.c	Wed Dec 19 20:28:56 2007 +1100
     1.2 +++ b/xenpci/evtchn.c	Wed Dec 19 11:23:47 2007 -0800
     1.3 @@ -25,6 +25,25 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
     1.4  {
     1.5    int cpu = 0;
     1.6    vcpu_info_t *vcpu_info;
     1.7 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(WdfInterruptGetDevice(Interrupt));
     1.8 +  shared_info_t *shared_info_area = xpdd->shared_info_area;
     1.9 +
    1.10 +  UNREFERENCED_PARAMETER(MessageID);
    1.11 +
    1.12 +  vcpu_info = &shared_info_area->vcpu_info[cpu];
    1.13 +
    1.14 +  vcpu_info->evtchn_upcall_pending = 0;
    1.15 +
    1.16 +  WdfInterruptQueueDpcForIsr(Interrupt);
    1.17 +
    1.18 +  return TRUE;
    1.19 +}
    1.20 +
    1.21 +VOID
    1.22 +EvtChn_InterruptDpc(WDFINTERRUPT Interrupt, WDFOBJECT AssociatedObject)
    1.23 +{
    1.24 +  int cpu = 0;
    1.25 +  vcpu_info_t *vcpu_info;
    1.26    unsigned long evt_words, evt_word;
    1.27    unsigned long evt_bit;
    1.28    unsigned long port;
    1.29 @@ -33,15 +52,10 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
    1.30    shared_info_t *shared_info_area = xpdd->shared_info_area;
    1.31  
    1.32    UNREFERENCED_PARAMETER(Interrupt);
    1.33 -  UNREFERENCED_PARAMETER(MessageID);
    1.34 -
    1.35 -  //KdPrint((__DRIVER_NAME "     I+\n"));
    1.36 -  //KdPrint((__DRIVER_NAME " --> XenPCI_ISR\n"));
    1.37 +  UNREFERENCED_PARAMETER(AssociatedObject);
    1.38  
    1.39    vcpu_info = &shared_info_area->vcpu_info[cpu];
    1.40  
    1.41 -  vcpu_info->evtchn_upcall_pending = 0;
    1.42 -
    1.43    evt_words = _InterlockedExchange((volatile LONG *)&vcpu_info->evtchn_pending_sel, 0);
    1.44    
    1.45    while (_BitScanForward(&evt_word, evt_words))
    1.46 @@ -63,13 +77,6 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
    1.47        _interlockedbittestandreset((volatile LONG *)&shared_info_area->evtchn_pending[0], port);
    1.48      }
    1.49    }
    1.50 -
    1.51 -  //KdPrint((__DRIVER_NAME " <-- XenPCI_ISR\n"));
    1.52 -
    1.53 -  //KdPrint((__DRIVER_NAME "     I-\n"));
    1.54 -
    1.55 -//  return TRUE;
    1.56 -  return FALSE;
    1.57  }
    1.58  
    1.59  NTSTATUS
     2.1 --- a/xenpci/xenpci.c	Wed Dec 19 20:28:56 2007 +1100
     2.2 +++ b/xenpci/xenpci.c	Wed Dec 19 11:23:47 2007 -0800
     2.3 @@ -75,10 +75,10 @@ static BOOLEAN AutoEnumerate;
     2.4  static LIST_ENTRY ShutdownMsgList;
     2.5  
     2.6  typedef struct {
     2.7 -  LIST_ENTRY Entry;
     2.8 +  LIST_ENTRY ListEntry;
     2.9    ULONG Ptr;
    2.10  //  ULONG Len;
    2.11 -  UCHAR Buf[0];
    2.12 +  CHAR Buf[0];
    2.13  } SHUTDOWN_MSG_ENTRY, *PSHUTDOWN_MSG_ENTRY;
    2.14  
    2.15  static KSPIN_LOCK ShutdownMsgLock;
    2.16 @@ -374,7 +374,7 @@ XenPCI_AddDevice(
    2.17  
    2.18    WdfDeviceSetBusInformationForChildren(Device, &busInfo);
    2.19  
    2.20 -  WDF_INTERRUPT_CONFIG_INIT(&InterruptConfig, EvtChn_Interrupt, NULL);
    2.21 +  WDF_INTERRUPT_CONFIG_INIT(&InterruptConfig, EvtChn_Interrupt, EvtChn_InterruptDpc);
    2.22    InterruptConfig.EvtInterruptEnable = XenPCI_InterruptEnable;
    2.23    InterruptConfig.EvtInterruptDisable = XenPCI_InterruptDisable;
    2.24    Status = WdfInterruptCreate(Device, &InterruptConfig, WDF_NO_OBJECT_ATTRIBUTES, &xpdd->XenInterrupt);
    2.25 @@ -654,10 +654,11 @@ XenPCI_IoRead(WDFQUEUE Queue, WDFREQUEST
    2.26    ULONG Remaining;
    2.27    ULONG CopyLen;
    2.28    PCHAR Buffer;
    2.29 -  ULONG BufLen;
    2.30 +  size_t BufLen;
    2.31    KIRQL OldIrql;
    2.32  
    2.33    UNREFERENCED_PARAMETER(Queue);
    2.34 +  UNREFERENCED_PARAMETER(Length);
    2.35  
    2.36    KdPrint((__DRIVER_NAME " --> IoRead\n"));
    2.37  
    2.38 @@ -686,7 +687,7 @@ XenPCI_IoRead(WDFQUEUE Queue, WDFREQUEST
    2.39    else
    2.40    {    
    2.41      Entry->Ptr += CopyLen;
    2.42 -    InsertHeadList(&ShutdownMsgList, Entry);
    2.43 +    InsertHeadList(&ShutdownMsgList, &Entry->ListEntry);
    2.44    }
    2.45  
    2.46    KeReleaseSpinLock(&ShutdownMsgLock, OldIrql);
    2.47 @@ -941,10 +942,6 @@ XenBus_ShutdownHandler(char *Path, PVOID
    2.48    char *Value;
    2.49    xenbus_transaction_t xbt;
    2.50    int retry;
    2.51 -  WDFREQUEST Request;
    2.52 -  PCHAR Buffer;
    2.53 -  size_t BufLen;
    2.54 -  PCHAR Ptr;
    2.55    PSHUTDOWN_MSG_ENTRY Entry;
    2.56  
    2.57    UNREFERENCED_PARAMETER(Path);
    2.58 @@ -967,7 +964,7 @@ XenBus_ShutdownHandler(char *Path, PVOID
    2.59      Entry = (PSHUTDOWN_MSG_ENTRY)ExAllocatePoolWithTag(NonPagedPool, sizeof(SHUTDOWN_MSG_ENTRY) + strlen(Value) + 1 + 1, XENPCI_POOL_TAG);
    2.60      Entry->Ptr = 0;
    2.61      RtlStringCbPrintfA(Entry->Buf, sizeof(SHUTDOWN_MSG_ENTRY) + strlen(Value) + 1 + 1, "%s\n", Value);
    2.62 -    InsertTailList(&ShutdownMsgList, Entry);
    2.63 +    InsertTailList(&ShutdownMsgList, &Entry->ListEntry);
    2.64      WdfIoQueueStart(ReadQueue);
    2.65    }
    2.66    KdPrint((__DRIVER_NAME " <-- XenBus_ShutdownHandler\n"));
     3.1 --- a/xenpci/xenpci.h	Wed Dec 19 20:28:56 2007 +1100
     3.2 +++ b/xenpci/xenpci.h	Wed Dec 19 11:23:47 2007 -0800
     3.3 @@ -183,7 +183,7 @@ NTSTATUS
     3.4  EvtChn_Init(WDFDEVICE Device);
     3.5  BOOLEAN
     3.6  EvtChn_Interrupt(WDFINTERRUPT Interrupt, ULONG MessageID);
     3.7 -BOOLEAN
     3.8 +VOID
     3.9  EvtChn_InterruptDpc(WDFINTERRUPT Interrupt, WDFOBJECT AssociatedObject);
    3.10  NTSTATUS
    3.11  EvtChn_Mask(PVOID Context, evtchn_port_t Port);