direct-io.hg

changeset 12262:ac2097d71e06

[NET] back: Fix wrap to zero in transmit credit scheduler.
This could happen when credit_bytes == ~0UL (i.e., scheduling is 'disabled').
Signed-off-by: Kirk Allan <kallan@novell.com>
author kfraser@localhost.localdomain
date Tue Nov 07 09:48:19 2006 +0000 (2006-11-07)
parents 9d981f3480b1
children d745f1420d5b
files linux-2.6-xen-sparse/drivers/xen/netback/netback.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Tue Nov 07 09:35:57 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Tue Nov 07 09:48:19 2006 +0000
     1.3 @@ -814,7 +814,7 @@ void netif_deschedule_work(netif_t *neti
     1.4  
     1.5  static void tx_add_credit(netif_t *netif)
     1.6  {
     1.7 -	unsigned long max_burst;
     1.8 +	unsigned long max_burst, max_credit;
     1.9  
    1.10  	/*
    1.11  	 * Allow a burst big enough to transmit a jumbo packet of up to 128kB.
    1.12 @@ -824,9 +824,10 @@ static void tx_add_credit(netif_t *netif
    1.13  	max_burst = min(max_burst, 131072UL);
    1.14  	max_burst = max(max_burst, netif->credit_bytes);
    1.15  
    1.16 -	netif->remaining_credit = min(netif->remaining_credit +
    1.17 -				      netif->credit_bytes,
    1.18 -				      max_burst);
    1.19 +	/* Take care that adding a new chunk of credit doesn't wrap to zero. */
    1.20 +	max_credit = max(netif->remaining_credit + netif->credit_bytes, ~0UL);
    1.21 +
    1.22 +	netif->remaining_credit = min(max_credit, max_burst);
    1.23  }
    1.24  
    1.25  static void tx_credit_callback(unsigned long data)