Patchwork [08/14] UBUNTU: SAUCE: net: calxedaxgmac: add write barriers around setting owner bit

login
register
mail settings
Submitter Ike Panhc
Date Aug. 3, 2012, 1:24 a.m.
Message ID <1343957092-5528-1-git-send-email-ike.pan@canonical.com>
Download mbox | patch
Permalink /patch/174829/
State New
Headers show

Comments

Ike Panhc - Aug. 3, 2012, 1:24 a.m.
From: Rob Herring <rob.herring@calxeda.com>

BugLink: http://launchpad.net/bugs/1008345

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Ike Panhc <ike.pan@canonical.com>
---
 drivers/net/ethernet/calxeda/xgmac.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Patch

diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c
index cd64c6b..8f43dc4 100644
--- a/drivers/net/ethernet/calxeda/xgmac.c
+++ b/drivers/net/ethernet/calxeda/xgmac.c
@@ -332,7 +332,7 @@ 
 #define DESC_BUFFER2_SZ_OFFSET	16
 
 struct xgmac_dma_desc {
-	__le32 flags;
+	volatile __le32 flags;
 	__le32 buf_size;
 	__le32 buf1_addr;		/* Buffer 1 Address Pointer */
 	__le32 buf2_addr;		/* Buffer 2 Address Pointer */
@@ -451,15 +451,20 @@  static inline int desc_get_owner(struct xgmac_dma_desc *p)
 static inline void desc_set_rx_owner(struct xgmac_dma_desc *p)
 {
 	/* Clear all fields and set the owner */
+	wmb();
 	p->flags = cpu_to_le32(DESC_OWN);
+	wmb();
 }
 
 static inline void desc_set_tx_owner(struct xgmac_dma_desc *p, u32 flags)
 {
-	u32 tmpflags = le32_to_cpu(p->flags);
+	u32 tmpflags;
+	wmb();
+	tmpflags = le32_to_cpu(p->flags);
 	tmpflags &= TXDESC_END_RING;
 	tmpflags |= flags | DESC_OWN;
 	p->flags = cpu_to_le32(tmpflags);
+	wmb();
 }
 
 static inline int desc_get_tx_ls(struct xgmac_dma_desc *p)