win-pvdrivers

changeset 418:bf3359218841 0.9.11-pre12

fixed multiple crashes in xennet
author James Harper <james.harper@bendigoit.com.au>
date Wed Aug 20 21:32:59 2008 +1000 (2008-08-20)
parents ef5345ea9984
children dcc440136d50
files common.inc installer.nsi xennet/xennet_common.c xennet/xennet_rx.c xenpci/evtchn.c xenvbd/scsiport.c
line diff
     1.1 --- a/common.inc	Mon Aug 18 23:14:40 2008 +1000
     1.2 +++ b/common.inc	Wed Aug 20 21:32:59 2008 +1000
     1.3 @@ -1,4 +1,4 @@
     1.4 -VERSION=0.9.10.12
     1.5 +VERSION=0.9.10.13
     1.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     1.7  MSC_WARNING_LEVEL=/W4
     1.8  INCLUDES = ..\common\include;..\common\include\public
     2.1 --- a/installer.nsi	Mon Aug 18 23:14:40 2008 +1000
     2.2 +++ b/installer.nsi	Wed Aug 20 21:32:59 2008 +1000
     2.3 @@ -3,7 +3,7 @@
     2.4  
     2.5  !define AppName "Xen PV Drivers"
     2.6  !define StartMenu "$SMPROGRAMS\${AppName}"
     2.7 -!define Version "0.9.11-pre11"
     2.8 +!define Version "0.9.11-pre12"
     2.9  #!define Version "$%VERSION%"
    2.10  Name "${AppName}"
    2.11  InstallDir "$PROGRAMFILES\${AppName}"
     3.1 --- a/xennet/xennet_common.c	Mon Aug 18 23:14:40 2008 +1000
     3.2 +++ b/xennet/xennet_common.c	Wed Aug 20 21:32:59 2008 +1000
     3.3 @@ -204,6 +204,9 @@ XenFreelist_GetPage(freelist_t *fl)
     3.4  {
     3.5    PMDL mdl;
     3.6    PFN_NUMBER pfn;
     3.7 +  grant_ref_t gref;
     3.8 +
     3.9 +  //ASSERT(!KeTestSpinLock(fl->lock));
    3.10  
    3.11    if (fl->page_free == 0)
    3.12    {
    3.13 @@ -211,9 +214,12 @@ XenFreelist_GetPage(freelist_t *fl)
    3.14      if (!mdl)
    3.15        return NULL;
    3.16      pfn = *MmGetMdlPfnArray(mdl);
    3.17 -    *(grant_ref_t *)(((UCHAR *)mdl) + MmSizeOfMdl(0, PAGE_SIZE)) = fl->xi->vectors.GntTbl_GrantAccess(
    3.18 +    gref = fl->xi->vectors.GntTbl_GrantAccess(
    3.19        fl->xi->vectors.context, 0,
    3.20        (uint32_t)pfn, FALSE, INVALID_GRANT_REF);
    3.21 +    if (gref == INVALID_GRANT_REF)
    3.22 +      KdPrint((__DRIVER_NAME "     No more grefs\n"));
    3.23 +    *(grant_ref_t *)(((UCHAR *)mdl) + MmSizeOfMdl(0, PAGE_SIZE)) = gref;
    3.24      /* we really should check if our grant was successful... */
    3.25    }
    3.26    else
    3.27 @@ -230,11 +236,15 @@ XenFreelist_GetPage(freelist_t *fl)
    3.28  VOID
    3.29  XenFreelist_PutPage(freelist_t *fl, PMDL mdl)
    3.30  {
    3.31 -  if (fl->page_free == PAGE_LIST_SIZE - 1)
    3.32 +  //ASSERT(!KeTestSpinLock(fl->lock));
    3.33 +
    3.34 +  ASSERT(NdisBufferLength(mdl) == PAGE_SIZE);
    3.35 +
    3.36 +  if (fl->page_free == PAGE_LIST_SIZE)
    3.37    {
    3.38      /* our page list is full. free the buffer instead. This will be a bit sucky performancewise... */
    3.39      fl->xi->vectors.GntTbl_EndAccess(fl->xi->vectors.context,
    3.40 -      *(grant_ref_t *)(((UCHAR *)mdl) + MmSizeOfMdl(0, PAGE_SIZE)), 0);
    3.41 +      *(grant_ref_t *)(((UCHAR *)mdl) + MmSizeOfMdl(0, PAGE_SIZE)), FALSE);
    3.42      FreePages(mdl);
    3.43    }
    3.44    else
     4.1 --- a/xennet/xennet_rx.c	Mon Aug 18 23:14:40 2008 +1000
     4.2 +++ b/xennet/xennet_rx.c	Wed Aug 20 21:32:59 2008 +1000
     4.3 @@ -33,6 +33,8 @@ XenNet_RxBufferAlloc(struct xennet_info 
     4.4  
     4.5  //KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
     4.6  
     4.7 +  //ASSERT(!KeTestSpinLock(&xi->rx_lock));
     4.8 +
     4.9    batch_target = xi->rx_target - (req_prod - xi->rx.rsp_cons);
    4.10  
    4.11    if (batch_target < (xi->rx_target >> 2))
    4.12 @@ -46,7 +48,7 @@ XenNet_RxBufferAlloc(struct xennet_info 
    4.13        break;
    4.14      }
    4.15      mdl = XenFreelist_GetPage(&xi->rx_freelist);
    4.16 -    if (mdl == NULL)
    4.17 +    if (!mdl)
    4.18      {
    4.19        KdPrint((__DRIVER_NAME "     Added %d out of %d buffers to rx ring (no free pages)\n", i, batch_target));
    4.20        break;
    4.21 @@ -59,6 +61,7 @@ XenNet_RxBufferAlloc(struct xennet_info 
    4.22      xi->rx_mdls[id] = mdl;
    4.23      req = RING_GET_REQUEST(&xi->rx, req_prod + i);
    4.24      req->gref = get_grant_ref(mdl);
    4.25 +    ASSERT(req->gref != INVALID_GRANT_REF);
    4.26      req->id = id;
    4.27    }
    4.28  
    4.29 @@ -80,6 +83,8 @@ get_packet_from_freelist(struct xennet_i
    4.30    NDIS_STATUS status;
    4.31    PNDIS_PACKET packet;
    4.32  
    4.33 +  //ASSERT(!KeTestSpinLock(&xi->rx_lock));
    4.34 +
    4.35    if (!xi->rx_packet_free)
    4.36    {
    4.37      NdisAllocatePacket(&status, &packet, xi->packet_pool);
    4.38 @@ -98,7 +103,9 @@ get_packet_from_freelist(struct xennet_i
    4.39  static VOID
    4.40  put_packet_on_freelist(struct xennet_info *xi, PNDIS_PACKET packet)
    4.41  {
    4.42 -  if (xi->rx_packet_free == NET_RX_RING_SIZE * 2 - 1)
    4.43 +  //ASSERT(!KeTestSpinLock(&xi->rx_lock));
    4.44 +
    4.45 +  if (xi->rx_packet_free == NET_RX_RING_SIZE * 2)
    4.46    {
    4.47      //KdPrint((__DRIVER_NAME "     packet free list full - releasing packet\n"));
    4.48      NdisFreePacket(packet);
    4.49 @@ -140,8 +147,7 @@ XenNet_MakePacket(struct xennet_info *xi
    4.50      packet = get_packet_from_freelist(xi);
    4.51      if (packet == NULL)
    4.52      {
    4.53 -      for (i = 0; i < xi->rxpi.mdl_count; i++)
    4.54 -        XenFreelist_PutPage(&xi->rx_freelist, xi->rxpi.mdls[i]);
    4.55 +      /* buffers will be freed in MakePackets */
    4.56        return NULL;
    4.57      }
    4.58      xi->rx_outstanding++;
    4.59 @@ -316,7 +322,8 @@ XenNet_MakePackets(
    4.60      if (packet == NULL)
    4.61      {
    4.62        xi->stat_rx_no_buffer++;
    4.63 -      return 0;
    4.64 +      packet_count = 0;
    4.65 +      goto done;
    4.66      }
    4.67      if (xi->rxpi.csum_calc_required)
    4.68        XenNet_SumPacketData(&xi->rxpi, packet);
    4.69 @@ -329,7 +336,8 @@ XenNet_MakePackets(
    4.70      if (packet == NULL)
    4.71      {
    4.72        xi->stat_rx_no_buffer++;
    4.73 -      return 0;
    4.74 +      packet_count = 0;
    4.75 +      goto done;
    4.76      }
    4.77      entry = (PLIST_ENTRY)&packet->MiniportReservedEx[sizeof(PVOID)];
    4.78      InsertTailList(rx_packet_list, entry);
    4.79 @@ -373,7 +381,8 @@ XenNet_MakePackets(
    4.80      packet_count++;
    4.81    }
    4.82  
    4.83 -  ASSERT(xi->rxpi.curr_mdl == xi->rxpi.mdl_count);
    4.84 +  // this won't be true if we had to abort due to a lack of resources... ASSERT(xi->rxpi.curr_mdl == xi->rxpi.mdl_count);
    4.85 +done:
    4.86    for (i = 0; i < xi->rxpi.mdl_count; i++)
    4.87    {
    4.88      NdisAdjustBufferLength(xi->rxpi.mdls[i], PAGE_SIZE);
     5.1 --- a/xenpci/evtchn.c	Mon Aug 18 23:14:40 2008 +1000
     5.2 +++ b/xenpci/evtchn.c	Wed Aug 20 21:32:59 2008 +1000
     5.3 @@ -47,20 +47,8 @@ EvtChn_DpcBounce(PRKDPC Dpc, PVOID Conte
     5.4  
     5.5    if (action->type == EVT_ACTION_TYPE_IRQ)
     5.6    {
     5.7 -    LARGE_INTEGER tstart = {0}, tend = {0};
     5.8      //KdPrint((__DRIVER_NAME "     Calling interrupt vector %02x\n", action->vector));
     5.9 -    if ((action->count & 0xFF) == 0)
    5.10 -    {
    5.11 -      tstart = KeQueryPerformanceCounter(NULL);
    5.12 -    }
    5.13      sw_interrupt((UCHAR)action->vector);
    5.14 -    if ((action->count & 0xFF) == 0)
    5.15 -    {
    5.16 -      LARGE_INTEGER tdiff;
    5.17 -      tend = KeQueryPerformanceCounter(NULL);
    5.18 -      tdiff.QuadPart = tend.QuadPart - tstart.QuadPart;
    5.19 -      KdPrint((__DRIVER_NAME "     EvtChn %s tdiff = %d\n", action->description, tdiff.LowPart));
    5.20 -    }
    5.21    }
    5.22    else
    5.23    {
     6.1 --- a/xenvbd/scsiport.c	Mon Aug 18 23:14:40 2008 +1000
     6.2 +++ b/xenvbd/scsiport.c	Wed Aug 20 21:32:59 2008 +1000
     6.3 @@ -667,8 +667,6 @@ XenVbd_MakeAutoSense(PXENVBD_DEVICE_DATA
     6.4    srb->SrbStatus |= SRB_STATUS_AUTOSENSE_VALID;
     6.5  }
     6.6  
     6.7 -static ULONG counter = 0;
     6.8 -
     6.9  static BOOLEAN DDKAPI
    6.10  XenVbd_HwScsiInterrupt(PVOID DeviceExtension)
    6.11  {
    6.12 @@ -681,16 +679,11 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
    6.13    int more_to_do = TRUE;
    6.14    blkif_shadow_t *shadow;
    6.15    ULONG offset;
    6.16 -  LARGE_INTEGER tstart = {0}, tend = {0};
    6.17  
    6.18    //KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    6.19  
    6.20    if (!xvdd->vectors.EvtChn_AckEvent(xvdd->vectors.context, xvdd->event_channel))
    6.21      return FALSE; /* interrupt was not for us */
    6.22 -  if ((counter & 0xFFF) == 0)
    6.23 -  {
    6.24 -    tstart = KeQueryPerformanceCounter(NULL);
    6.25 -  }
    6.26    if (xvdd->device_state->resume_state != RESUME_STATE_RUNNING)
    6.27    {
    6.28      //KdPrint((__DRIVER_NAME " --- " __FUNCTION__ " device_state event\n"));
    6.29 @@ -818,15 +811,6 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
    6.30  
    6.31    //KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    6.32  
    6.33 -  if ((counter & 0xFFF) == 0)
    6.34 -  {
    6.35 -    LARGE_INTEGER tdiff;
    6.36 -    tend = KeQueryPerformanceCounter(NULL);
    6.37 -    tdiff.QuadPart = tend.QuadPart - tstart.QuadPart;
    6.38 -    KdPrint((__DRIVER_NAME "     SCSI ISR IRQL = %d, tdiff = %d\n", KeGetCurrentIrql(), tdiff.LowPart));
    6.39 -  }
    6.40 -  counter++;
    6.41 -  
    6.42    return FALSE; /* we just don't know... */
    6.43  }
    6.44