win-pvdrivers

changeset 586:bdb2d6b163f3

More protection against the Dpcs running after shutdown
author James Harper <james.harper@bendigoit.com.au>
date Sun Jun 07 20:31:20 2009 +1000 (2009-06-07)
parents 19b4c4d2b621
children cfe35004c0f7
files xennet/xennet.c xennet/xennet_rx.c xennet/xennet_tx.c
line diff
     1.1 --- a/xennet/xennet.c	Sun Jun 07 20:22:05 2009 +1000
     1.2 +++ b/xennet/xennet.c	Sun Jun 07 20:31:20 2009 +1000
     1.3 @@ -280,14 +280,17 @@ XenNet_HandleEvent(PVOID context)
     1.4    KeMemoryBarrier();
     1.5  //  KdPrint((__DRIVER_NAME "     connected = %d, inactive = %d, suspend_resume_state_pdo = %d\n",
     1.6  //    xi->connected, xi->inactive, suspend_resume_state_pdo));
     1.7 -  if (suspend_resume_state_pdo != xi->device_state->suspend_resume_state_fdo)
     1.8 +  if (!xi->shutting_down)
     1.9    {
    1.10 -    KeInsertQueueDpc(&xi->suspend_dpc, NULL, NULL);
    1.11 -  }
    1.12 -  else if (xi->connected && !xi->inactive && suspend_resume_state_pdo != SR_STATE_RESUMING)
    1.13 -  {
    1.14 -    KeInsertQueueDpc(&xi->tx_dpc, NULL, NULL);
    1.15 -    KeInsertQueueDpc(&xi->rx_dpc, NULL, NULL);
    1.16 +    if (suspend_resume_state_pdo != xi->device_state->suspend_resume_state_fdo)
    1.17 +    {
    1.18 +      KeInsertQueueDpc(&xi->suspend_dpc, NULL, NULL);
    1.19 +    }
    1.20 +    else if (xi->connected && !xi->inactive && suspend_resume_state_pdo != SR_STATE_RESUMING)
    1.21 +    {
    1.22 +      KeInsertQueueDpc(&xi->tx_dpc, NULL, NULL);
    1.23 +      KeInsertQueueDpc(&xi->rx_dpc, NULL, NULL);
    1.24 +    }
    1.25    }
    1.26    //FUNCTION_EXIT();
    1.27    return TRUE;
     2.1 --- a/xennet/xennet_rx.c	Sun Jun 07 20:22:05 2009 +1000
     2.2 +++ b/xennet/xennet_rx.c	Sun Jun 07 20:31:20 2009 +1000
     2.3 @@ -996,6 +996,9 @@ XenNet_RxShutdown(xennet_info_t *xi)
     2.4      KeCancelTimer(&xi->rx_timer);
     2.5    }
     2.6  
     2.7 +  KeRemoveQueueDpc(&xi->rx_dpc);
     2.8 +  KeFlushQueuedDpcs();
     2.9 +
    2.10    while (xi->rx_outstanding)
    2.11    {
    2.12      KdPrint((__DRIVER_NAME "     Waiting for all packets to be returned\n"));
     3.1 --- a/xennet/xennet_tx.c	Sun Jun 07 20:22:05 2009 +1000
     3.2 +++ b/xennet/xennet_tx.c	Sun Jun 07 20:31:20 2009 +1000
     3.3 @@ -405,6 +405,13 @@ XenNet_TxBufferGC(PKDPC dpc, PVOID conte
     3.4  
     3.5    KeAcquireSpinLockAtDpcLevel(&xi->tx_lock);
     3.6  
     3.7 +  if (xi->shutting_down)
     3.8 +  {
     3.9 +    /* there is a chance that our Dpc had been queued just before the shutdown... */
    3.10 +    KeReleaseSpinLockFromDpcLevel(&xi->tx_lock);
    3.11 +    return;
    3.12 +  }
    3.13 +
    3.14    do {
    3.15      prod = xi->tx.sring->rsp_prod;
    3.16      KeMemoryBarrier(); /* Ensure we see responses up to 'rsp_prod'. */
    3.17 @@ -606,6 +613,9 @@ XenNet_TxShutdown(xennet_info_t *xi)
    3.18  
    3.19    FUNCTION_ENTER();
    3.20  
    3.21 +  KeRemoveQueueDpc(&xi->tx_dpc);
    3.22 +  KeFlushQueuedDpcs();
    3.23 +
    3.24    KeAcquireSpinLock(&xi->tx_lock, &OldIrql);
    3.25  
    3.26    /* Free packets in tx queue */