enic: workaround A0 erratum
[pandora-kernel.git] / drivers / net / enic / vnic_rq.h
index 82bfca6..f7b5730 100644 (file)
@@ -132,8 +132,20 @@ 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 int vnic_rq_posting_soon(struct vnic_rq *rq)
+{
+       return ((rq->to_use->index & VNIC_RQ_RETURN_RATE) == 0);
 }
 
 static inline void vnic_rq_return_descs(struct vnic_rq *rq, unsigned int count)
@@ -179,7 +191,7 @@ static inline int vnic_rq_fill(struct vnic_rq *rq,
 {
        int err;
 
-       while (vnic_rq_desc_avail(rq) > 1) {
+       while (vnic_rq_desc_avail(rq) > 0) {
 
                err = (*buf_fill)(rq);
                if (err)