]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/suse-2.6.27.31/patches.drivers/bnx2x-Barriers-for-the-compiler.patch
Merge branch 'master' into next
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.31 / patches.drivers / bnx2x-Barriers-for-the-compiler.patch
CommitLineData
2cb7cef9
BS
1From 237907c1ded8a1a447cea7c4f97ab853e8b46052 Mon Sep 17 00:00:00 2001
2From: Eilon Greenstein <eilong@broadcom.com>
3Date: Wed, 14 Jan 2009 06:42:44 +0000
4Subject: bnx2x: Barriers for the compiler
5Acked-by: Karsten Keil <kkeil@novell.com>
6Reference: bnc#472500
7
8To make sure no swapping are made by the compiler, changed HAS_WORK to inline
9functions and added all the necessary barriers
10
11Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
12Signed-off-by: David S. Miller <davem@davemloft.net>
13---
14 drivers/net/bnx2x.h | 9 +--------
15 drivers/net/bnx2x_main.c | 37 ++++++++++++++++++++++++++-----------
16 2 files changed, 27 insertions(+), 19 deletions(-)
17
18Index: 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 {
23
24 #define bnx2x_fp(bp, nr, var) (bp->fp[nr].var)
25
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))
29-
30-#define BNX2X_HAS_RX_WORK(fp) \
31- (fp->rx_comp_cons != rx_cons_sb)
32-
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))
35
36
37 /* MC hsi */
38Index: 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
44 */
45
46+static inline int bnx2x_has_tx_work(struct bnx2x_fastpath *fp)
47+{
48+ u16 tx_cons_sb;
49+
50+ /* Tell compiler that status block fields can change */
51+ barrier();
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));
55+}
56+
57 /* free skb in the packet ring at pos idx
58 * return idx of last bd freed
59 */
60@@ -6696,7 +6707,7 @@ static int bnx2x_nic_unload(struct bnx2x
61
62 cnt = 1000;
63 smp_rmb();
64- while (BNX2X_HAS_TX_WORK(fp)) {
65+ while (bnx2x_has_tx_work(fp)) {
66
67 bnx2x_tx_int(fp, 1000);
68 if (!cnt) {
69@@ -9285,6 +9296,18 @@ static int bnx2x_set_power_state(struct
70 return 0;
71 }
72
73+static inline int bnx2x_has_rx_work(struct bnx2x_fastpath *fp)
74+{
75+ u16 rx_cons_sb;
76+
77+ /* Tell compiler that status block fields can change */
78+ barrier();
79+ rx_cons_sb = le16_to_cpu(*fp->rx_cons_sb);
80+ if ((rx_cons_sb & MAX_RCQ_DESC_CNT) == MAX_RCQ_DESC_CNT)
81+ rx_cons_sb++;
82+ return (fp->rx_comp_cons != rx_cons_sb);
83+}
84+
85 /*
86 * net_device service functions
87 */
88@@ -9295,7 +9318,6 @@ static int bnx2x_poll(struct napi_struct
89 napi);
90 struct bnx2x *bp = fp->bp;
91 int work_done = 0;
92- u16 rx_cons_sb;
93
94 #ifdef BNX2X_STOP_ON_ERROR
95 if (unlikely(bp->panic))
96@@ -9308,19 +9330,12 @@ static int bnx2x_poll(struct napi_struct
97
98 bnx2x_update_fpsb_idx(fp);
99
100- if (BNX2X_HAS_TX_WORK(fp))
101+ if (bnx2x_has_tx_work(fp))
102 bnx2x_tx_int(fp, budget);
103
104- rx_cons_sb = le16_to_cpu(*fp->rx_cons_sb);
105- if ((rx_cons_sb & MAX_RCQ_DESC_CNT) == MAX_RCQ_DESC_CNT)
106- rx_cons_sb++;
107- if (BNX2X_HAS_RX_WORK(fp))
108+ if (bnx2x_has_rx_work(fp))
109 work_done = bnx2x_rx_int(fp, budget);
110-
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)
114- rx_cons_sb++;
115
116 /* must not complete if we consumed full budget */
117 if ((work_done < budget) && !BNX2X_HAS_WORK(fp)) {