From 7c4009192ea2276c1d7ed8ec0a18f3ecfca5cd2b Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Mon, 9 Jul 2012 14:16:08 +0000 Subject: [PATCH] net: calxedaxgmac: fix hang on rx refill Fix intermittent hangs in xgmac_rx_refill. If a ring buffer entry already had an skb allocated, then xgmac_rx_refill would get stuck in a loop. This can happen on a rx error when we just leave the skb allocated to the entry. [ 7884.510000] INFO: rcu_preempt detected stall on CPU 0 (t=727315 jiffies) [ 7884.510000] [] (unwind_backtrace+0x1/0x98) from [] (__rcu_pending+0x11b/0x2c4) [ 7884.510000] [] (__rcu_pending+0x11b/0x2c4) from [] (rcu_check_callbacks+0xed/0x1a8) [ 7884.510000] [] (rcu_check_callbacks+0xed/0x1a8) from [] (update_process_times+0x2b/0x48) [ 7884.510000] [] (update_process_times+0x2b/0x48) from [] (tick_sched_timer+0x51/0x94) [ 7884.510000] [] (tick_sched_timer+0x51/0x94) from [] (__run_hrtimer+0x4f/0x1e8) [ 7884.510000] [] (__run_hrtimer+0x4f/0x1e8) from [] (hrtimer_interrupt+0xd7/0x1e4) [ 7884.510000] [] (hrtimer_interrupt+0xd7/0x1e4) from [] (twd_handler+0x17/0x24) [ 7884.510000] [] (twd_handler+0x17/0x24) from [] (handle_percpu_devid_irq+0x59/0x114) [ 7884.510000] [] (handle_percpu_devid_irq+0x59/0x114) from [] (generic_handle_irq+0x17/0x2c) [ 7884.510000] [] (generic_handle_irq+0x17/0x2c) from [] (handle_IRQ+0x35/0x7c) [ 7884.510000] [] (handle_IRQ+0x35/0x7c) from [] (__irq_svc+0x33/0xb8) [ 7884.510000] [] (__irq_svc+0x33/0xb8) from [] (xgmac_rx_refill+0x3a/0x140) [ 7884.510000] [] (xgmac_rx_refill+0x3a/0x140) from [] (xgmac_poll+0x265/0x3bc) [ 7884.510000] [] (xgmac_poll+0x265/0x3bc) from [] (net_rx_action+0xc3/0x200) [ 7884.510000] [] (net_rx_action+0xc3/0x200) from [] (__do_softirq+0xa3/0x1bc) Signed-off-by: Rob Herring Signed-off-by: David S. Miller --- drivers/net/ethernet/calxeda/xgmac.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c index c4fd2e3600c7..3ca1d792f718 100644 --- a/drivers/net/ethernet/calxeda/xgmac.c +++ b/drivers/net/ethernet/calxeda/xgmac.c @@ -671,26 +671,23 @@ static void xgmac_rx_refill(struct xgmac_priv *priv) p = priv->dma_rx + entry; - if (priv->rx_skbuff[entry] != NULL) - continue; - - skb = __skb_dequeue(&priv->rx_recycle); - if (skb == NULL) - skb = netdev_alloc_skb(priv->dev, priv->dma_buf_sz); - if (unlikely(skb == NULL)) - break; - - priv->rx_skbuff[entry] = skb; - paddr = dma_map_single(priv->device, skb->data, - priv->dma_buf_sz, DMA_FROM_DEVICE); - desc_set_buf_addr(p, paddr, priv->dma_buf_sz); + if (priv->rx_skbuff[entry] == NULL) { + skb = __skb_dequeue(&priv->rx_recycle); + if (skb == NULL) + skb = netdev_alloc_skb(priv->dev, priv->dma_buf_sz); + if (unlikely(skb == NULL)) + break; + + priv->rx_skbuff[entry] = skb; + paddr = dma_map_single(priv->device, skb->data, + priv->dma_buf_sz, DMA_FROM_DEVICE); + desc_set_buf_addr(p, paddr, priv->dma_buf_sz); + } netdev_dbg(priv->dev, "rx ring: head %d, tail %d\n", priv->rx_head, priv->rx_tail); priv->rx_head = dma_ring_incr(priv->rx_head, DMA_RX_RING_SZ); - /* Ensure descriptor is in memory before handing to h/w */ - wmb(); desc_set_rx_owner(p); } } -- 2.30.2