Re: [PATCH v3] net: add Faraday FTMAC100 10/100 Ethernet driver

From: Po-Yu Chuang
Date: Thu Jan 20 2011 - 10:55:01 EST


Dear Eric,

On Thu, Jan 20, 2011 at 11:41 PM, Eric Dumazet <eric.dumazet@xxxxxxxxx> wrote:
> Le jeudi 20 janvier 2011 Ã 23:30 +0800, Po-Yu Chuang a Ãcrit :
>
>> +static bool ftmac100_tx_complete_packet(struct ftmac100 *priv)
>> +{
>> + Â Â struct net_device *netdev = priv->netdev;
>> + Â Â struct ftmac100_txdes *txdes;
>> + Â Â struct sk_buff *skb;
>> + Â Â dma_addr_t map;
>> +
>> + Â Â if (priv->tx_pending == 0)
>> + Â Â Â Â Â Â return false;
>> +
>> + Â Â txdes = ftmac100_current_clean_txdes(priv);
>> +
>> + Â Â if (ftmac100_txdes_owned_by_dma(txdes))
>> + Â Â Â Â Â Â return false;
>> +
>> + Â Â skb = ftmac100_txdes_get_skb(txdes);
>> + Â Â map = ftmac100_txdes_get_dma_addr(txdes);
>> +
>> + Â Â if (unlikely(ftmac100_txdes_excessive_collision(txdes) ||
>> + Â Â Â Â Â Â Â Â Âftmac100_txdes_late_collision(txdes))) {
>> + Â Â Â Â Â Â /*
>> + Â Â Â Â Â Â Â* packet transmitted to ethernet lost due to late collision
>> + Â Â Â Â Â Â Â* or excessive collision
>> + Â Â Â Â Â Â Â*/
>> + Â Â Â Â Â Â netdev->stats.tx_aborted_errors++;
>> + Â Â } else {
>> + Â Â Â Â Â Â netdev->stats.tx_packets++;
>> + Â Â Â Â Â Â netdev->stats.tx_bytes += skb->len;
>> + Â Â }
>> +
>> + Â Â dma_unmap_single(priv->dev, map, skb_headlen(skb), DMA_TO_DEVICE);
>> +
>> + Â Â dev_kfree_skb_irq(skb);
>> +
>> + Â Â ftmac100_txdes_reset(txdes);
>> +
>> + Â Â ftmac100_tx_clean_pointer_advance(priv);
>> +
>> + Â Â priv->tx_pending--;
>> + Â Â netif_wake_queue(netdev);
>> +
>> + Â Â return true;
>> +}
>> +
>> +static void ftmac100_tx_complete(struct ftmac100 *priv)
>> +{
>> + Â Â unsigned long flags;
>> +
>> + Â Â spin_lock_irqsave(&priv->tx_lock, flags);
>> + Â Â while (ftmac100_tx_complete_packet(priv))
>> + Â Â Â Â Â Â ;
>> + Â Â spin_unlock_irqrestore(&priv->tx_lock, flags);
>> +}
>> +
>
> I dont understand why you still block hard IRQS, after full NAPI
> conversion.
>
> Now you run from NAPI, and softirq handler, are you sure you still need
> to block hard IRQ and tx_lock ?
>
> It seems to me ftmac100_xmit() could only block softirqs (but they
> already are blocked by caller), so you could use spin_lock() from
> ftmac100_xmit()

I was not quite clear about when to use what kinds of locking.
After your explanation, now I understand.
I will submit v4 tomorrow.

really appreciate,
Po-Yu Chuang
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/