win-pvdrivers

changeset 576:dc0a293c870c

Fixed a problem where shutdown was hanging if there were packets in the tx ring
author James Harper <james.harper@bendigoit.com.au>
date Thu May 21 00:04:46 2009 +1000 (2009-05-21)
parents b162a1156e3f
children 17e6a7e1d3df
files xennet/xennet.c xennet/xennet.h xennet/xennet_rx.c xennet/xennet_tx.c
line diff
     1.1 --- a/xennet/xennet.c	Wed May 20 21:41:21 2009 +1000
     1.2 +++ b/xennet/xennet.c	Thu May 21 00:04:46 2009 +1000
     1.3 @@ -694,12 +694,15 @@ XenNet_Halt(
     1.4    FUNCTION_ENTER();
     1.5    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
     1.6  
     1.7 -  xi->connected = FALSE;
     1.8 -  KeMemoryBarrier(); /* make sure everyone sees that we are now shut down */
     1.9 +  xi->shutting_down = TRUE;
    1.10 +  KeMemoryBarrier(); /* make sure everyone sees that we are now shutting down */
    1.11  
    1.12    XenNet_TxShutdown(xi);
    1.13    XenNet_RxShutdown(xi);
    1.14  
    1.15 +  xi->connected = FALSE;
    1.16 +  KeMemoryBarrier(); /* make sure everyone sees that we are now disconnected */
    1.17 +
    1.18    xi->vectors.XenPci_XenShutdownDevice(xi->vectors.context);
    1.19  
    1.20    // TODO: remove event channel xenbus entry (how?)
     2.1 --- a/xennet/xennet.h	Wed May 20 21:41:21 2009 +1000
     2.2 +++ b/xennet/xennet.h	Thu May 21 00:04:46 2009 +1000
     2.3 @@ -244,7 +244,8 @@ struct xennet_info
     2.4    NDIS_HANDLE adapter_handle;
     2.5    NDIS_MINIPORT_INTERRUPT interrupt;
     2.6    ULONG packet_filter;
     2.7 -  int connected;
     2.8 +  BOOLEAN connected;
     2.9 +  BOOLEAN shutting_down;
    2.10    uint8_t perm_mac_addr[ETH_ALEN];
    2.11    uint8_t curr_mac_addr[ETH_ALEN];
    2.12  
    2.13 @@ -271,7 +272,6 @@ struct xennet_info
    2.14  #define TX_HEADER_BUFFER_SIZE 512
    2.15  //#define TX_HEADER_BUFFERS (NET_TX_RING_SIZE >> 2)
    2.16  #define TX_HEADER_BUFFERS (NET_TX_RING_SIZE)
    2.17 -  BOOLEAN tx_shutting_down;
    2.18    KEVENT tx_idle_event;
    2.19    ULONG tx_outstanding;
    2.20    ULONG tx_id_free;
    2.21 @@ -288,7 +288,6 @@ struct xennet_info
    2.22    packet_info_t rxpi;
    2.23    PNDIS_PACKET rx_packet_list[NET_RX_RING_SIZE * 2];
    2.24    ULONG rx_packet_free;
    2.25 -  BOOLEAN rx_shutting_down;
    2.26    KEVENT packet_returned_event;
    2.27    //NDIS_MINIPORT_TIMER rx_timer;
    2.28    KDPC rx_dpc;
     3.1 --- a/xennet/xennet_rx.c	Wed May 20 21:41:21 2009 +1000
     3.2 +++ b/xennet/xennet_rx.c	Thu May 21 00:04:46 2009 +1000
     3.3 @@ -856,7 +856,7 @@ XenNet_ReturnPacket(
     3.4    put_packet_on_freelist(xi, Packet);
     3.5    xi->rx_outstanding--;
     3.6    
     3.7 -  if (!xi->rx_outstanding && xi->rx_shutting_down)
     3.8 +  if (!xi->rx_outstanding && xi->shutting_down)
     3.9      KeSetEvent(&xi->packet_returned_event, IO_NO_INCREMENT, FALSE);
    3.10  
    3.11    XenNet_FillRing(xi);
    3.12 @@ -971,7 +971,6 @@ XenNet_RxInit(xennet_info_t *xi)
    3.13    KeSetTargetProcessorDpc(&xi->rx_dpc, 0);
    3.14    //KeSetImportanceDpc(&xi->rx_dpc, HighImportance);
    3.15    //KeInitializeDpc(&xi->rx_timer_dpc, XenNet_RxTimerDpc, xi);
    3.16 -  xi->rx_shutting_down = FALSE;
    3.17  
    3.18    XenNet_BufferAlloc(xi);
    3.19    
    3.20 @@ -999,10 +998,6 @@ XenNet_RxShutdown(xennet_info_t *xi)
    3.21  
    3.22    FUNCTION_ENTER();
    3.23  
    3.24 -  KeAcquireSpinLock(&xi->rx_lock, &OldIrql);
    3.25 -  xi->rx_shutting_down = TRUE;
    3.26 -  KeReleaseSpinLock(&xi->rx_lock, OldIrql);
    3.27 -
    3.28    if (xi->config_rx_interrupt_moderation)
    3.29    {
    3.30      KeCancelTimer(&xi->rx_timer);
     4.1 --- a/xennet/xennet_tx.c	Wed May 20 21:41:21 2009 +1000
     4.2 +++ b/xennet/xennet_tx.c	Thu May 21 00:04:46 2009 +1000
     4.3 @@ -446,7 +446,8 @@ XenNet_TxBufferGC(PKDPC dpc, PVOID conte
     4.4    } while (prod != xi->tx.sring->rsp_prod);
     4.5  
     4.6    /* if queued packets, send them now */
     4.7 -  XenNet_SendQueuedPackets(xi);
     4.8 +  if (!xi->shutting_down)
     4.9 +    XenNet_SendQueuedPackets(xi);
    4.10  
    4.11    KeReleaseSpinLockFromDpcLevel(&xi->tx_lock);
    4.12  
    4.13 @@ -456,7 +457,7 @@ XenNet_TxBufferGC(PKDPC dpc, PVOID conte
    4.14      head = *(PNDIS_PACKET *)&packet->MiniportReservedEx[0];
    4.15      NdisMSendComplete(xi->adapter_handle, packet, NDIS_STATUS_SUCCESS);
    4.16      xi->tx_outstanding--;
    4.17 -    if (!xi->tx_outstanding && xi->tx_shutting_down)
    4.18 +    if (!xi->tx_outstanding && xi->shutting_down)
    4.19        KeSetEvent(&xi->tx_idle_event, IO_NO_INCREMENT, FALSE);
    4.20    }
    4.21  
    4.22 @@ -556,7 +557,6 @@ XenNet_TxInit(xennet_info_t *xi)
    4.23    InitializeListHead(&xi->tx_waiting_pkt_list);
    4.24  
    4.25    KeInitializeEvent(&xi->tx_idle_event, SynchronizationEvent, FALSE);
    4.26 -  xi->tx_shutting_down = FALSE;
    4.27    xi->tx_outstanding = 0;
    4.28    xi->tx_ring_free = NET_TX_RING_SIZE;
    4.29  
    4.30 @@ -606,12 +606,8 @@ XenNet_TxShutdown(xennet_info_t *xi)
    4.31  
    4.32    FUNCTION_ENTER();
    4.33  
    4.34 -  ASSERT(!xi->connected);
    4.35 -
    4.36    KeAcquireSpinLock(&xi->tx_lock, &OldIrql);
    4.37  
    4.38 -  xi->tx_shutting_down = TRUE;
    4.39 -
    4.40    /* Free packets in tx queue */
    4.41    entry = RemoveHeadList(&xi->tx_waiting_pkt_list);
    4.42    while (entry != &xi->tx_waiting_pkt_list)