From: kaf24@firebug.cl.cam.ac.uk Date: Mon, 5 Jun 2006 14:14:58 +0000 (+0100) Subject: [NET] back: fix synchronisation of access to deallocation buffer ring. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15972^2~49^2~10 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=08f2d66ff68e069cc7cc6f6ec3097aa545568527;p=xen.git [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 Signed-off-by: Keir Fraser --- diff --git a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c index fb6b88e5e2..238565f1bb 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c @@ -458,6 +458,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 */ @@ -695,7 +698,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);