1 From 237907c1ded8a1a447cea7c4f97ab853e8b46052 Mon Sep 17 00:00:00 2001
2 From: Eilon Greenstein <eilong@broadcom.com>
3 Date: Wed, 14 Jan 2009 06:42:44 +0000
4 Subject: bnx2x: Barriers for the compiler
5 Acked-by: Karsten Keil <kkeil@novell.com>
8 To make sure no swapping are made by the compiler, changed HAS_WORK to inline
9 functions and added all the necessary barriers
11 Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
12 Signed-off-by: David S. Miller <davem@davemloft.net>
14 drivers/net/bnx2x.h | 9 +--------
15 drivers/net/bnx2x_main.c | 37 ++++++++++++++++++++++++++-----------
16 2 files changed, 27 insertions(+), 19 deletions(-)
18 Index: linux-2.6.27-bnx2x_2/drivers/net/bnx2x.h
19 ===================================================================
20 --- linux-2.6.27-bnx2x_2.orig/drivers/net/bnx2x.h
21 +++ linux-2.6.27-bnx2x_2/drivers/net/bnx2x.h
22 @@ -271,14 +271,7 @@ struct bnx2x_fastpath {
24 #define bnx2x_fp(bp, nr, var) (bp->fp[nr].var)
26 -#define BNX2X_HAS_TX_WORK(fp) \
27 - ((fp->tx_pkt_prod != le16_to_cpu(*fp->tx_cons_sb)) || \
28 - (fp->tx_pkt_prod != fp->tx_pkt_cons))
30 -#define BNX2X_HAS_RX_WORK(fp) \
31 - (fp->rx_comp_cons != rx_cons_sb)
33 -#define BNX2X_HAS_WORK(fp) (BNX2X_HAS_RX_WORK(fp) || BNX2X_HAS_TX_WORK(fp))
34 +#define BNX2X_HAS_WORK(fp) (bnx2x_has_rx_work(fp) || bnx2x_has_tx_work(fp))
38 Index: linux-2.6.27-bnx2x_2/drivers/net/bnx2x_main.c
39 ===================================================================
40 --- linux-2.6.27-bnx2x_2.orig/drivers/net/bnx2x_main.c
41 +++ linux-2.6.27-bnx2x_2/drivers/net/bnx2x_main.c
42 @@ -733,6 +733,17 @@ static u16 bnx2x_ack_int(struct bnx2x *b
43 * fast path service functions
46 +static inline int bnx2x_has_tx_work(struct bnx2x_fastpath *fp)
50 + /* Tell compiler that status block fields can change */
52 + tx_cons_sb = le16_to_cpu(*fp->tx_cons_sb);
53 + return ((fp->tx_pkt_prod != tx_cons_sb) ||
54 + (fp->tx_pkt_prod != fp->tx_pkt_cons));
57 /* free skb in the packet ring at pos idx
58 * return idx of last bd freed
60 @@ -6696,7 +6707,7 @@ static int bnx2x_nic_unload(struct bnx2x
64 - while (BNX2X_HAS_TX_WORK(fp)) {
65 + while (bnx2x_has_tx_work(fp)) {
67 bnx2x_tx_int(fp, 1000);
69 @@ -9285,6 +9296,18 @@ static int bnx2x_set_power_state(struct
73 +static inline int bnx2x_has_rx_work(struct bnx2x_fastpath *fp)
77 + /* Tell compiler that status block fields can change */
79 + rx_cons_sb = le16_to_cpu(*fp->rx_cons_sb);
80 + if ((rx_cons_sb & MAX_RCQ_DESC_CNT) == MAX_RCQ_DESC_CNT)
82 + return (fp->rx_comp_cons != rx_cons_sb);
86 * net_device service functions
88 @@ -9295,7 +9318,6 @@ static int bnx2x_poll(struct napi_struct
90 struct bnx2x *bp = fp->bp;
94 #ifdef BNX2X_STOP_ON_ERROR
95 if (unlikely(bp->panic))
96 @@ -9308,19 +9330,12 @@ static int bnx2x_poll(struct napi_struct
98 bnx2x_update_fpsb_idx(fp);
100 - if (BNX2X_HAS_TX_WORK(fp))
101 + if (bnx2x_has_tx_work(fp))
102 bnx2x_tx_int(fp, budget);
104 - rx_cons_sb = le16_to_cpu(*fp->rx_cons_sb);
105 - if ((rx_cons_sb & MAX_RCQ_DESC_CNT) == MAX_RCQ_DESC_CNT)
107 - if (BNX2X_HAS_RX_WORK(fp))
108 + if (bnx2x_has_rx_work(fp))
109 work_done = bnx2x_rx_int(fp, budget);
111 rmb(); /* BNX2X_HAS_WORK() reads the status block */
112 - rx_cons_sb = le16_to_cpu(*fp->rx_cons_sb);
113 - if ((rx_cons_sb & MAX_RCQ_DESC_CNT) == MAX_RCQ_DESC_CNT)
116 /* must not complete if we consumed full budget */
117 if ((work_done < budget) && !BNX2X_HAS_WORK(fp)) {