linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] gianfar: Add I/O barriers when touching buffer descriptor ownership.
@ 2007-05-02 19:57 Scott Wood
  2007-05-02 20:09 ` Kumar Gala
  0 siblings, 1 reply; 14+ messages in thread
From: Scott Wood @ 2007-05-02 19:57 UTC (permalink / raw)
  To: jgarzik; +Cc: netdev, linuxppc-dev

The hardware must not see that is given ownership of a buffer until it is
completely written, and when the driver receives ownership of a buffer,
it must ensure that any other reads to the buffer reflect its final
state.  Thus, I/O barriers are added where required.

Without this patch, I have observed GCC reordering the setting of
bdp->length and bdp->status in gfar_new_skb.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
This is version 2 of this patch.  I was told that eieio doesn't order
loads from main memory, so a sync is used instead.  Also, due to
objectons that iobarrier_* shouldn't be used for main memory, I used
eieio() instead (a wmb() would be unnecessarily heavy).

 drivers/net/gianfar.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index b666a0c..b014d27 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -1025,6 +1025,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	dev->trans_start = jiffies;
 
+	eieio();
 	txbdp->status = status;
 
 	/* If this was the last BD in the ring, the next one */
@@ -1301,6 +1302,7 @@ struct sk_buff * gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp)
 	bdp->length = 0;
 
 	/* Mark the buffer empty */
+	eieio();
 	bdp->status |= (RXBD_EMPTY | RXBD_INTERRUPT);
 
 	return skb;
@@ -1484,6 +1486,7 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit)
 	bdp = priv->cur_rx;
 
 	while (!((bdp->status & RXBD_EMPTY) || (--rx_work_limit < 0))) {
+		rmb();
 		skb = priv->rx_skbuff[priv->skb_currx];
 
 		if (!(bdp->status &
-- 
1.5.0.3

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2007-05-05  0:41 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-02 19:57 [PATCH v2] gianfar: Add I/O barriers when touching buffer descriptor ownership Scott Wood
2007-05-02 20:09 ` Kumar Gala
2007-05-02 20:12   ` Scott Wood
2007-05-02 20:20     ` Kumar Gala
2007-05-02 20:40       ` Scott Wood
2007-05-02 21:23         ` Kumar Gala
2007-05-02 21:30           ` Scott Wood
2007-05-03  2:10             ` Kumar Gala
2007-05-03 16:00               ` Scott Wood
2007-05-03 16:38                 ` Segher Boessenkool
2007-05-02 23:42         ` Segher Boessenkool
2007-05-04 22:13         ` Linas Vepstas
2007-05-04 23:24           ` Olof Johansson
2007-05-05  0:41           ` Segher Boessenkool

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).