Commit d713804c authored by Christian Lamparter's avatar Christian Lamparter Committed by John W. Linville

p54pci: move tx cleanup into tasklet

This patch moves the tx cleanup routines out of the critical
interrupt context and into the (previously known as rx) tasklet.

The main goal of this operation is to remove the extensive
usage of spin_lock_irqsaves in the generic p54common library.

The next step would be to modify p54usb to do the
rx processing inside a tasklet (just like usbnet).
Signed-off-by: default avatarChristian Lamparter <chunkeey@googlemail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 288c8ce8
...@@ -234,25 +234,26 @@ static void p54p_check_rx_ring(struct ieee80211_hw *dev, u32 *index, ...@@ -234,25 +234,26 @@ static void p54p_check_rx_ring(struct ieee80211_hw *dev, u32 *index,
p54p_refill_rx_ring(dev, ring_index, ring, ring_limit, rx_buf); p54p_refill_rx_ring(dev, ring_index, ring, ring_limit, rx_buf);
} }
/* caller must hold priv->lock */
static void p54p_check_tx_ring(struct ieee80211_hw *dev, u32 *index, static void p54p_check_tx_ring(struct ieee80211_hw *dev, u32 *index,
int ring_index, struct p54p_desc *ring, u32 ring_limit, int ring_index, struct p54p_desc *ring, u32 ring_limit,
void **tx_buf) struct sk_buff **tx_buf)
{ {
unsigned long flags;
struct p54p_priv *priv = dev->priv; struct p54p_priv *priv = dev->priv;
struct p54p_ring_control *ring_control = priv->ring_control; struct p54p_ring_control *ring_control = priv->ring_control;
struct p54p_desc *desc; struct p54p_desc *desc;
struct sk_buff *skb;
u32 idx, i; u32 idx, i;
i = (*index) % ring_limit; i = (*index) % ring_limit;
(*index) = idx = le32_to_cpu(ring_control->device_idx[1]); (*index) = idx = le32_to_cpu(ring_control->device_idx[1]);
idx %= ring_limit; idx %= ring_limit;
spin_lock_irqsave(&priv->lock, flags);
while (i != idx) { while (i != idx) {
desc = &ring[i]; desc = &ring[i];
if (tx_buf[i])
if (FREE_AFTER_TX((struct sk_buff *) tx_buf[i])) skb = tx_buf[i];
p54_free_skb(dev, tx_buf[i]);
tx_buf[i] = NULL; tx_buf[i] = NULL;
pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr), pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr),
...@@ -263,17 +264,32 @@ static void p54p_check_tx_ring(struct ieee80211_hw *dev, u32 *index, ...@@ -263,17 +264,32 @@ static void p54p_check_tx_ring(struct ieee80211_hw *dev, u32 *index,
desc->len = 0; desc->len = 0;
desc->flags = 0; desc->flags = 0;
if (skb && FREE_AFTER_TX(skb)) {
spin_unlock_irqrestore(&priv->lock, flags);
p54_free_skb(dev, skb);
spin_lock_irqsave(&priv->lock, flags);
}
i++; i++;
i %= ring_limit; i %= ring_limit;
} }
spin_unlock_irqrestore(&priv->lock, flags);
} }
static void p54p_rx_tasklet(unsigned long dev_id) static void p54p_tasklet(unsigned long dev_id)
{ {
struct ieee80211_hw *dev = (struct ieee80211_hw *)dev_id; struct ieee80211_hw *dev = (struct ieee80211_hw *)dev_id;
struct p54p_priv *priv = dev->priv; struct p54p_priv *priv = dev->priv;
struct p54p_ring_control *ring_control = priv->ring_control; struct p54p_ring_control *ring_control = priv->ring_control;
p54p_check_tx_ring(dev, &priv->tx_idx_mgmt, 3, ring_control->tx_mgmt,
ARRAY_SIZE(ring_control->tx_mgmt),
priv->tx_buf_mgmt);
p54p_check_tx_ring(dev, &priv->tx_idx_data, 1, ring_control->tx_data,
ARRAY_SIZE(ring_control->tx_data),
priv->tx_buf_data);
p54p_check_rx_ring(dev, &priv->rx_idx_mgmt, 2, ring_control->rx_mgmt, p54p_check_rx_ring(dev, &priv->rx_idx_mgmt, 2, ring_control->rx_mgmt,
ARRAY_SIZE(ring_control->rx_mgmt), priv->rx_buf_mgmt); ARRAY_SIZE(ring_control->rx_mgmt), priv->rx_buf_mgmt);
...@@ -288,38 +304,24 @@ static irqreturn_t p54p_interrupt(int irq, void *dev_id) ...@@ -288,38 +304,24 @@ static irqreturn_t p54p_interrupt(int irq, void *dev_id)
{ {
struct ieee80211_hw *dev = dev_id; struct ieee80211_hw *dev = dev_id;
struct p54p_priv *priv = dev->priv; struct p54p_priv *priv = dev->priv;
struct p54p_ring_control *ring_control = priv->ring_control;
__le32 reg; __le32 reg;
spin_lock(&priv->lock); spin_lock(&priv->lock);
reg = P54P_READ(int_ident); reg = P54P_READ(int_ident);
if (unlikely(reg == cpu_to_le32(0xFFFFFFFF))) { if (unlikely(reg == cpu_to_le32(0xFFFFFFFF))) {
spin_unlock(&priv->lock); goto out;
return IRQ_HANDLED;
} }
P54P_WRITE(int_ack, reg); P54P_WRITE(int_ack, reg);
reg &= P54P_READ(int_enable); reg &= P54P_READ(int_enable);
if (reg & cpu_to_le32(ISL38XX_INT_IDENT_UPDATE)) { if (reg & cpu_to_le32(ISL38XX_INT_IDENT_UPDATE))
p54p_check_tx_ring(dev, &priv->tx_idx_mgmt, tasklet_schedule(&priv->tasklet);
3, ring_control->tx_mgmt, else if (reg & cpu_to_le32(ISL38XX_INT_IDENT_INIT))
ARRAY_SIZE(ring_control->tx_mgmt),
priv->tx_buf_mgmt);
p54p_check_tx_ring(dev, &priv->tx_idx_data,
1, ring_control->tx_data,
ARRAY_SIZE(ring_control->tx_data),
priv->tx_buf_data);
tasklet_schedule(&priv->rx_tasklet);
} else if (reg & cpu_to_le32(ISL38XX_INT_IDENT_INIT))
complete(&priv->boot_comp); complete(&priv->boot_comp);
out:
spin_unlock(&priv->lock); spin_unlock(&priv->lock);
return reg ? IRQ_HANDLED : IRQ_NONE; return reg ? IRQ_HANDLED : IRQ_NONE;
} }
...@@ -368,7 +370,7 @@ static void p54p_stop(struct ieee80211_hw *dev) ...@@ -368,7 +370,7 @@ static void p54p_stop(struct ieee80211_hw *dev)
unsigned int i; unsigned int i;
struct p54p_desc *desc; struct p54p_desc *desc;
tasklet_kill(&priv->rx_tasklet); tasklet_kill(&priv->tasklet);
P54P_WRITE(int_enable, cpu_to_le32(0)); P54P_WRITE(int_enable, cpu_to_le32(0));
P54P_READ(int_enable); P54P_READ(int_enable);
...@@ -559,7 +561,7 @@ static int __devinit p54p_probe(struct pci_dev *pdev, ...@@ -559,7 +561,7 @@ static int __devinit p54p_probe(struct pci_dev *pdev,
priv->common.tx = p54p_tx; priv->common.tx = p54p_tx;
spin_lock_init(&priv->lock); spin_lock_init(&priv->lock);
tasklet_init(&priv->rx_tasklet, p54p_rx_tasklet, (unsigned long)dev); tasklet_init(&priv->tasklet, p54p_tasklet, (unsigned long)dev);
err = request_firmware(&priv->firmware, "isl3886pci", err = request_firmware(&priv->firmware, "isl3886pci",
&priv->pdev->dev); &priv->pdev->dev);
......
...@@ -92,7 +92,7 @@ struct p54p_priv { ...@@ -92,7 +92,7 @@ struct p54p_priv {
struct p54_common common; struct p54_common common;
struct pci_dev *pdev; struct pci_dev *pdev;
struct p54p_csr __iomem *map; struct p54p_csr __iomem *map;
struct tasklet_struct rx_tasklet; struct tasklet_struct tasklet;
const struct firmware *firmware; const struct firmware *firmware;
spinlock_t lock; spinlock_t lock;
struct p54p_ring_control *ring_control; struct p54p_ring_control *ring_control;
...@@ -101,8 +101,8 @@ struct p54p_priv { ...@@ -101,8 +101,8 @@ struct p54p_priv {
u32 rx_idx_mgmt, tx_idx_mgmt; u32 rx_idx_mgmt, tx_idx_mgmt;
struct sk_buff *rx_buf_data[8]; struct sk_buff *rx_buf_data[8];
struct sk_buff *rx_buf_mgmt[4]; struct sk_buff *rx_buf_mgmt[4];
void *tx_buf_data[32]; struct sk_buff *tx_buf_data[32];
void *tx_buf_mgmt[4]; struct sk_buff *tx_buf_mgmt[4];
struct completion boot_comp; struct completion boot_comp;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment