]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
[NET] back: fix synchronisation of access to deallocation buffer ring.
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 5 Jun 2006 14:15:45 +0000 (15:15 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 5 Jun 2006 14:15:45 +0000 (15:15 +0100)
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>
xen-unstable changeset:   10268:9f50b8c2de0ad641d7795613edc35d78240dab8c
xen-unstable date:        Mon Jun  5 15:14:58 2006 +0100

linux-2.6-xen-sparse/drivers/xen/netback/netback.c

index dad463a1886e27ab3bcf32e794e92494de7642e9..c40c1c2707afffbfcec3b3dfda77774137b14ef5 100644 (file)
@@ -452,6 +452,9 @@ inline static void net_tx_action_dealloc(void)
        dc = dealloc_cons;
        dp = dealloc_prod;
 
+       /* Ensure we see all indexes enqueued by netif_idx_release(). */
+       smp_rmb();
+
        /*
         * Free up any grants we have finished using
         */
@@ -689,7 +692,10 @@ static void netif_idx_release(u16 pending_idx)
        unsigned long flags;
 
        spin_lock_irqsave(&_lock, flags);
-       dealloc_ring[MASK_PEND_IDX(dealloc_prod++)] = pending_idx;
+       dealloc_ring[MASK_PEND_IDX(dealloc_prod)] = pending_idx;
+       /* Sync with net_tx_action_dealloc: insert idx /then/ incr producer. */
+       smp_wmb();
+       dealloc_prod++;
        spin_unlock_irqrestore(&_lock, flags);
 
        tasklet_schedule(&net_tx_tasklet);