ia64/xen-unstable

changeset 10306:9f50b8c2de0a

[NET] back: fix synchronisation of access to deallocation buffer ring.
Must ensure ring is written to before producer index is incremented.
Bug diagnosed by Ky Srinivasan <ksrinivasan@novell.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Jun 05 15:14:58 2006 +0100 (2006-06-05)
parents 47412b44e35e
children 1dab198509a9
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	Mon Jun 05 14:35:22 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Mon Jun 05 15:14:58 2006 +0100
     1.3 @@ -458,6 +458,9 @@ inline static void net_tx_action_dealloc
     1.4  	dc = dealloc_cons;
     1.5  	dp = dealloc_prod;
     1.6  
     1.7 +	/* Ensure we see all indexes enqueued by netif_idx_release(). */
     1.8 +	smp_rmb();
     1.9 +
    1.10  	/*
    1.11  	 * Free up any grants we have finished using
    1.12  	 */
    1.13 @@ -695,7 +698,10 @@ static void netif_idx_release(u16 pendin
    1.14  	unsigned long flags;
    1.15  
    1.16  	spin_lock_irqsave(&_lock, flags);
    1.17 -	dealloc_ring[MASK_PEND_IDX(dealloc_prod++)] = pending_idx;
    1.18 +	dealloc_ring[MASK_PEND_IDX(dealloc_prod)] = pending_idx;
    1.19 +	/* Sync with net_tx_action_dealloc: insert idx /then/ incr producer. */
    1.20 +	smp_wmb();
    1.21 +	dealloc_prod++;
    1.22  	spin_unlock_irqrestore(&_lock, flags);
    1.23  
    1.24  	tasklet_schedule(&net_tx_tasklet);