[U-Boot] [PATCH] arm: Kirkwood: Add memory barriers to kwgbe_send/recv

Simon Kagstrom simon.kagstrom at netinsight.net
Wed Jul 1 17:16:15 CEST 2009


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 at 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


More information about the U-Boot mailing list