* [PATCH] 8139too: move wmb before TX DMA start
@ 2008-10-08 7:44 Andreas Oberritter
2008-10-08 10:16 ` Ben Hutchings
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Oberritter @ 2008-10-08 7:44 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-kernel
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();
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);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] 8139too: move wmb before TX DMA start
2008-10-08 7:44 [PATCH] 8139too: move wmb before TX DMA start Andreas Oberritter
@ 2008-10-08 10:16 ` Ben Hutchings
2008-10-08 16:14 ` [PATCH v2] " Andreas Oberritter
0 siblings, 1 reply; 3+ messages in thread
From: Ben Hutchings @ 2008-10-08 10:16 UTC (permalink / raw)
To: Andreas Oberritter; +Cc: Jeff Garzik, netdev, linux-kernel
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.
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] 8139too: move wmb before TX DMA start
2008-10-08 10:16 ` Ben Hutchings
@ 2008-10-08 16:14 ` Andreas Oberritter
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Oberritter @ 2008-10-08 16:14 UTC (permalink / raw)
To: Ben Hutchings; +Cc: Jeff Garzik, netdev, linux-kernel
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>
---
Added a comment on Ben's request explaining the reason for the barrier.
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index 53bd903..3c5fac6 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -1716,13 +1716,18 @@ static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev)
}
spin_lock_irqsave(&tp->lock, flags);
+ /*
+ * Writing to TxStatus triggers a DMA transfer of the data
+ * copied to tp->tx_buf[entry] above. Use a memory barrier
+ * to make sure that the device sees the updated data.
+ */
+ 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);
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-10-08 16:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-08 7:44 [PATCH] 8139too: move wmb before TX DMA start Andreas Oberritter
2008-10-08 10:16 ` Ben Hutchings
2008-10-08 16:14 ` [PATCH v2] " Andreas Oberritter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).