[net-2.6 PATCH] mlx4_en: Fix a kernel panic when waking tx queue
From: Yevgeny Petrilin <hidden>
Date: 2009-05-25 08:31:49
Subsystem:
networking drivers, the rest · Maintainers:
Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds
This patch fixes a kernel panic when waking the TX queue from irq context. Signed-off-by: Yevgeny Petrilin <redacted> --- drivers/net/mlx4/en_tx.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/net/mlx4/en_tx.c b/drivers/net/mlx4/en_tx.c
index ac6fc49..bbb082b 100644
--- a/drivers/net/mlx4/en_tx.c
+++ b/drivers/net/mlx4/en_tx.c@@ -326,7 +326,8 @@ void mlx4_en_set_prio_map(struct mlx4_en_priv *priv, u16 *prio_map, u32 ring_num } } -static void mlx4_en_process_tx_cq(struct net_device *dev, struct mlx4_en_cq *cq) +static void mlx4_en_process_tx_cq(struct net_device *dev, + struct mlx4_en_cq *cq, int poll) { struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_cq *mcq = &cq->mcq;
@@ -383,7 +384,7 @@ static void mlx4_en_process_tx_cq(struct net_device *dev, struct mlx4_en_cq *cq) ring->cons += txbbs_skipped; /* Wakeup Tx queue if this ring stopped it */ - if (unlikely(ring->blocked)) { + if (unlikely(ring->blocked) && poll) { if ((u32) (ring->prod - ring->cons) <= ring->size - HEADROOM - MAX_DESC_TXBBS) {
@@ -411,7 +412,7 @@ void mlx4_en_tx_irq(struct mlx4_cq *mcq) if (!spin_trylock(&ring->comp_lock)) return; - mlx4_en_process_tx_cq(cq->dev, cq); + mlx4_en_process_tx_cq(cq->dev, cq, 0); mod_timer(&cq->timer, jiffies + 1); spin_unlock(&ring->comp_lock); }
@@ -430,7 +431,7 @@ void mlx4_en_poll_tx_cq(unsigned long data) mod_timer(&cq->timer, jiffies + MLX4_EN_TX_POLL_TIMEOUT); return; } - mlx4_en_process_tx_cq(cq->dev, cq); + mlx4_en_process_tx_cq(cq->dev, cq, 1); inflight = (u32) (ring->prod - ring->cons - ring->last_nr_txbb); /* If there are still packets in flight and the timer has not already
@@ -483,7 +484,7 @@ static inline void mlx4_en_xmit_poll(struct mlx4_en_priv *priv, int tx_ind) /* Poll the CQ every mlx4_en_TX_MODER_POLL packets */ if ((++ring->poll_cnt & (MLX4_EN_TX_POLL_MODER - 1)) == 0) if (spin_trylock(&ring->comp_lock)) { - mlx4_en_process_tx_cq(priv->dev, cq); + mlx4_en_process_tx_cq(priv->dev, cq, 1); spin_unlock(&ring->comp_lock); } }
--
1.6.0