cxgb3: add memory barriers
authorDivy Le Ray <divy@chelsio.com>
Mon, 1 Feb 2010 10:29:29 +0000 (10:29 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 4 Feb 2010 02:37:10 +0000 (18:37 -0800)
Add memory barriers to fix crashes observed on newest PowerPC platforms.
The HW and driver state of the receive rings were getting out of sync.

Signed-off-by: Divy Le Ray <divy@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/cxgb3/sge.c

index bdbd14727e4b232987632fb19f114510e6068837..4cf9b7962afa99ccf70a4153f638f5dcdaf40779 100644 (file)
@@ -480,6 +480,7 @@ static inline void ring_fl_db(struct adapter *adap, struct sge_fl *q)
 {
        if (q->pend_cred >= q->credits / 4) {
                q->pend_cred = 0;
 {
        if (q->pend_cred >= q->credits / 4) {
                q->pend_cred = 0;
+               wmb();
                t3_write_reg(adap, A_SG_KDOORBELL, V_EGRCNTX(q->cntxt_id));
        }
 }
                t3_write_reg(adap, A_SG_KDOORBELL, V_EGRCNTX(q->cntxt_id));
        }
 }
@@ -2282,11 +2283,14 @@ static int process_responses(struct adapter *adap, struct sge_qset *qs,
        while (likely(budget_left && is_new_response(r, q))) {
                int packet_complete, eth, ethpad = 2, lro = qs->lro_enabled;
                struct sk_buff *skb = NULL;
        while (likely(budget_left && is_new_response(r, q))) {
                int packet_complete, eth, ethpad = 2, lro = qs->lro_enabled;
                struct sk_buff *skb = NULL;
-               u32 len, flags = ntohl(r->flags);
-               __be32 rss_hi = *(const __be32 *)r,
-                      rss_lo = r->rss_hdr.rss_hash_val;
+               u32 len, flags;
+               __be32 rss_hi, rss_lo;
 
 
+               rmb();
                eth = r->rss_hdr.opcode == CPL_RX_PKT;
                eth = r->rss_hdr.opcode == CPL_RX_PKT;
+               rss_hi = *(const __be32 *)r;
+               rss_lo = r->rss_hdr.rss_hash_val;
+               flags = ntohl(r->flags);
 
                if (unlikely(flags & F_RSPD_ASYNC_NOTIF)) {
                        skb = alloc_skb(AN_PKT_SIZE, GFP_ATOMIC);
 
                if (unlikely(flags & F_RSPD_ASYNC_NOTIF)) {
                        skb = alloc_skb(AN_PKT_SIZE, GFP_ATOMIC);
@@ -2497,7 +2501,10 @@ static int process_pure_responses(struct adapter *adap, struct sge_qset *qs,
                        refill_rspq(adap, q, q->credits);
                        q->credits = 0;
                }
                        refill_rspq(adap, q, q->credits);
                        q->credits = 0;
                }
-       } while (is_new_response(r, q) && is_pure_response(r));
+               if (!is_new_response(r, q))
+                       break;
+               rmb();
+       } while (is_pure_response(r));
 
        if (sleeping)
                check_ring_db(adap, qs, sleeping);
 
        if (sleeping)
                check_ring_db(adap, qs, sleeping);
@@ -2531,6 +2538,7 @@ static inline int handle_responses(struct adapter *adap, struct sge_rspq *q)
 
        if (!is_new_response(r, q))
                return -1;
 
        if (!is_new_response(r, q))
                return -1;
+       rmb();
        if (is_pure_response(r) && process_pure_responses(adap, qs, r) == 0) {
                t3_write_reg(adap, A_SG_GTS, V_RSPQ(q->cntxt_id) |
                             V_NEWTIMER(q->holdoff_tmr) | V_NEWINDEX(q->cidx));
        if (is_pure_response(r) && process_pure_responses(adap, qs, r) == 0) {
                t3_write_reg(adap, A_SG_GTS, V_RSPQ(q->cntxt_id) |
                             V_NEWTIMER(q->holdoff_tmr) | V_NEWINDEX(q->cidx));