]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
enic: move wmb closer to where needed: before writing posted_index to hw
authorScott Feldman <scofeldm@cisco.com>
Sat, 22 Nov 2008 05:29:01 +0000 (21:29 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 22 Nov 2008 05:29:01 +0000 (21:29 -0800)
Signed-off-by: Scott Feldman <scofeldm@cisco.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/enic/enic_res.h
drivers/net/enic/vnic_rq.h
drivers/net/enic/vnic_wq.h

index 68534a29b7ace04487be5e1608d24f8619771ac0..7bf272fa859b32ea530911573ce8450c8e7fc607 100644 (file)
@@ -58,8 +58,6 @@ static inline void enic_queue_wq_desc_ex(struct vnic_wq *wq,
                (u16)vlan_tag,
                0 /* loopback */);
 
-       wmb();
-
        vnic_wq_post(wq, os_buf, dma_addr, len, sop, eop);
 }
 
@@ -127,8 +125,6 @@ static inline void enic_queue_rq_desc(struct vnic_rq *rq,
                (u64)dma_addr | VNIC_PADDR_TARGET,
                type, (u16)len);
 
-       wmb();
-
        vnic_rq_post(rq, os_buf, os_buf_index, dma_addr, len);
 }
 
index 82bfca67cc4d18cac256fa61d01fe90b013f5d1b..fd0ef66d2e9f5cfb66d1fe9e0f15858b8da056c6 100644 (file)
@@ -132,8 +132,15 @@ static inline void vnic_rq_post(struct vnic_rq *rq,
 #define VNIC_RQ_RETURN_RATE            0xf     /* keep 2^n - 1 */
 #endif
 
-       if ((buf->index & VNIC_RQ_RETURN_RATE) == 0)
+       if ((buf->index & VNIC_RQ_RETURN_RATE) == 0) {
+               /* Adding write memory barrier prevents compiler and/or CPU
+                * reordering, thus avoiding descriptor posting before
+                * descriptor is initialized. Otherwise, hardware can read
+                * stale descriptor fields.
+                */
+               wmb();
                iowrite32(buf->index, &rq->ctrl->posted_index);
+       }
 }
 
 static inline void vnic_rq_return_descs(struct vnic_rq *rq, unsigned int count)
index 7081828d8a42bd98a8ed7bdacf1cc1254da63b9f..c826137dc6517c2d9d5c5bcef23c45b063659f37 100644 (file)
@@ -108,8 +108,15 @@ static inline void vnic_wq_post(struct vnic_wq *wq,
        buf->len = len;
 
        buf = buf->next;
-       if (eop)
+       if (eop) {
+               /* Adding write memory barrier prevents compiler and/or CPU
+                * reordering, thus avoiding descriptor posting before
+                * descriptor is initialized. Otherwise, hardware can read
+                * stale descriptor fields.
+                */
+               wmb();
                iowrite32(buf->index, &wq->ctrl->posted_index);
+       }
        wq->to_use = buf;
 
        wq->ring.desc_avail--;