public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] arm: Kirkwood: Add memory barriers to kwgbe_send/recv
@ 2009-07-01 15:16 Simon Kagstrom
  2009-07-01 16:56 ` Detlev Zundel
  2009-07-01 16:57 ` Prafulla Wadaskar
  0 siblings, 2 replies; 10+ messages in thread
From: Simon Kagstrom @ 2009-07-01 15:16 UTC (permalink / raw)
  To: u-boot

Add memory barriers to kwgbe_send/recv

kwgbe_send/recv both have loops waiting for the hardware to set  a bit.
GCC 4.3.3 cleverly optimizes this to ... a while(1); loop. This patch
introduces memory barriers to force re-loading of the transmit descriptor.

mb() wasn't defined for arm, but perhaps it should?

Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
---
 drivers/net/kirkwood_egiga.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/net/kirkwood_egiga.c b/drivers/net/kirkwood_egiga.c
index 3c5db19..abedf77 100644
--- a/drivers/net/kirkwood_egiga.c
+++ b/drivers/net/kirkwood_egiga.c
@@ -513,6 +513,8 @@ static int kwgbe_send(struct eth_device *dev, volatile void *dataptr,
 			printf("Err..(%s) in xmit packet\n", __FUNCTION__);
 			return -1;
 		}
+		/* Memory barrier to see to it that cmd_sts is re-read */
+		asm volatile("" : : : "memory");
 	};
 	return 0;
 }
@@ -531,6 +533,8 @@ static int kwgbe_recv(struct eth_device *dev)
 			debug("%s time out...\n", __FUNCTION__);
 			return -1;
 		}
+		/* Memory barrier to see to it that cmd_sts is re-read */
+		asm volatile("" : : : "memory");
 	} while (p_rxdesc_curr->cmd_sts & KWGBE_BUFFER_OWNED_BY_DMA);
 
 	if (p_rxdesc_curr->byte_cnt != 0) {
-- 
1.6.0.4

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

end of thread, other threads:[~2009-07-04 23:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-01 15:16 [U-Boot] [PATCH] arm: Kirkwood: Add memory barriers to kwgbe_send/recv Simon Kagstrom
2009-07-01 16:56 ` Detlev Zundel
2009-07-01 17:09   ` Stefan Roese
2009-07-01 17:14     ` Scott Wood
2009-07-03  9:15       ` Detlev Zundel
2009-07-01 16:57 ` Prafulla Wadaskar
2009-07-02  6:47   ` Simon Kagstrom
2009-07-02  8:12     ` Prafulla Wadaskar
2009-07-03  8:57       ` Detlev Zundel
2009-07-04 23:52     ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox