Patchwork 8139too: move wmb before TX DMA start

login
register
mail settings
Submitter Andreas Oberritter
Date Oct. 8, 2008, 7:44 a.m.
Message ID <48EC64E1.5070806@linuxtv.org>
Download mbox | patch
Permalink /patch/3274/
State Superseded
Delegated to: Jeff Garzik
Headers show

Comments

Andreas Oberritter - Oct. 8, 2008, 7:44 a.m.
From: Andreas Oberritter <obi@linuxtv.org>

The write barrier should be used before starting a DMA transfer. This fixes
a problem, where almost all packets received on another machine had garbled
content. Tested with an RTL8100C on a MIPS machine.

Signed-off-by: Andreas Oberritter <obi@linuxtv.org>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ben Hutchings - Oct. 8, 2008, 10:16 a.m.
Andreas Oberritter wrote:
> From: Andreas Oberritter <obi@linuxtv.org>
> 
> The write barrier should be used before starting a DMA transfer. This fixes
> a problem, where almost all packets received on another machine had garbled
> content. Tested with an RTL8100C on a MIPS machine.
> 
> Signed-off-by: Andreas Oberritter <obi@linuxtv.org>
> 
> diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
> index 53bd903..44344af 100644
> --- a/drivers/net/8139too.c
> +++ b/drivers/net/8139too.c
> @@ -1716,13 +1716,13 @@ static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev)
>  	}
>  
>  	spin_lock_irqsave(&tp->lock, flags);
> +	wmb();
[...]

All memory barriers need a comment to explain why and what they're doing.

Ben.

Patch

diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index 53bd903..44344af 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -1716,13 +1716,13 @@  static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev)
 	}
 
 	spin_lock_irqsave(&tp->lock, flags);
+	wmb();
 	RTL_W32_F (TxStatus0 + (entry * sizeof (u32)),
 		   tp->tx_flag | max(len, (unsigned int)ETH_ZLEN));
 
 	dev->trans_start = jiffies;
 
 	tp->cur_tx++;
-	wmb();
 
 	if ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx)
 		netif_stop_queue (dev);