diff options
author | Eilon Greenstein <eilong@broadcom.com> | 2009-01-14 01:42:44 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-01-19 19:20:14 -0500 |
commit | 237907c1ded8a1a447cea7c4f97ab853e8b46052 (patch) | |
tree | abe06a24be466869f8252a3b8e80aa0bc9637ef6 /drivers/net/bnx2x_main.c | |
parent | e47d7e6eb841c1850f0e69b95ae6cf3c86881f53 (diff) |
bnx2x: Barriers for the compiler
To make sure no swapping are made by the compiler, changed HAS_WORK to inline
functions and added all the necessary barriers
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2x_main.c')
-rw-r--r-- | drivers/net/bnx2x_main.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c index dc05e37c581d..3236527477a3 100644 --- a/drivers/net/bnx2x_main.c +++ b/drivers/net/bnx2x_main.c | |||
@@ -733,6 +733,17 @@ static u16 bnx2x_ack_int(struct bnx2x *bp) | |||
733 | * fast path service functions | 733 | * fast path service functions |
734 | */ | 734 | */ |
735 | 735 | ||
736 | static inline int bnx2x_has_tx_work(struct bnx2x_fastpath *fp) | ||
737 | { | ||
738 | u16 tx_cons_sb; | ||
739 | |||
740 | /* Tell compiler that status block fields can change */ | ||
741 | barrier(); | ||
742 | tx_cons_sb = le16_to_cpu(*fp->tx_cons_sb); | ||
743 | return ((fp->tx_pkt_prod != tx_cons_sb) || | ||
744 | (fp->tx_pkt_prod != fp->tx_pkt_cons)); | ||
745 | } | ||
746 | |||
736 | /* free skb in the packet ring at pos idx | 747 | /* free skb in the packet ring at pos idx |
737 | * return idx of last bd freed | 748 | * return idx of last bd freed |
738 | */ | 749 | */ |
@@ -6693,7 +6704,7 @@ static int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode) | |||
6693 | 6704 | ||
6694 | cnt = 1000; | 6705 | cnt = 1000; |
6695 | smp_rmb(); | 6706 | smp_rmb(); |
6696 | while (BNX2X_HAS_TX_WORK(fp)) { | 6707 | while (bnx2x_has_tx_work(fp)) { |
6697 | 6708 | ||
6698 | bnx2x_tx_int(fp, 1000); | 6709 | bnx2x_tx_int(fp, 1000); |
6699 | if (!cnt) { | 6710 | if (!cnt) { |
@@ -9281,6 +9292,18 @@ static int bnx2x_set_power_state(struct bnx2x *bp, pci_power_t state) | |||
9281 | return 0; | 9292 | return 0; |
9282 | } | 9293 | } |
9283 | 9294 | ||
9295 | static inline int bnx2x_has_rx_work(struct bnx2x_fastpath *fp) | ||
9296 | { | ||
9297 | u16 rx_cons_sb; | ||
9298 | |||
9299 | /* Tell compiler that status block fields can change */ | ||
9300 | barrier(); | ||
9301 | rx_cons_sb = le16_to_cpu(*fp->rx_cons_sb); | ||
9302 | if ((rx_cons_sb & MAX_RCQ_DESC_CNT) == MAX_RCQ_DESC_CNT) | ||
9303 | rx_cons_sb++; | ||
9304 | return (fp->rx_comp_cons != rx_cons_sb); | ||
9305 | } | ||
9306 | |||
9284 | /* | 9307 | /* |
9285 | * net_device service functions | 9308 | * net_device service functions |
9286 | */ | 9309 | */ |
@@ -9291,7 +9314,6 @@ static int bnx2x_poll(struct napi_struct *napi, int budget) | |||
9291 | napi); | 9314 | napi); |
9292 | struct bnx2x *bp = fp->bp; | 9315 | struct bnx2x *bp = fp->bp; |
9293 | int work_done = 0; | 9316 | int work_done = 0; |
9294 | u16 rx_cons_sb; | ||
9295 | 9317 | ||
9296 | #ifdef BNX2X_STOP_ON_ERROR | 9318 | #ifdef BNX2X_STOP_ON_ERROR |
9297 | if (unlikely(bp->panic)) | 9319 | if (unlikely(bp->panic)) |
@@ -9304,19 +9326,12 @@ static int bnx2x_poll(struct napi_struct *napi, int budget) | |||
9304 | 9326 | ||
9305 | bnx2x_update_fpsb_idx(fp); | 9327 | bnx2x_update_fpsb_idx(fp); |
9306 | 9328 | ||
9307 | if (BNX2X_HAS_TX_WORK(fp)) | 9329 | if (bnx2x_has_tx_work(fp)) |
9308 | bnx2x_tx_int(fp, budget); | 9330 | bnx2x_tx_int(fp, budget); |
9309 | 9331 | ||
9310 | rx_cons_sb = le16_to_cpu(*fp->rx_cons_sb); | 9332 | if (bnx2x_has_rx_work(fp)) |
9311 | if ((rx_cons_sb & MAX_RCQ_DESC_CNT) == MAX_RCQ_DESC_CNT) | ||
9312 | rx_cons_sb++; | ||
9313 | if (BNX2X_HAS_RX_WORK(fp)) | ||
9314 | work_done = bnx2x_rx_int(fp, budget); | 9333 | work_done = bnx2x_rx_int(fp, budget); |
9315 | |||
9316 | rmb(); /* BNX2X_HAS_WORK() reads the status block */ | 9334 | rmb(); /* BNX2X_HAS_WORK() reads the status block */ |
9317 | rx_cons_sb = le16_to_cpu(*fp->rx_cons_sb); | ||
9318 | if ((rx_cons_sb & MAX_RCQ_DESC_CNT) == MAX_RCQ_DESC_CNT) | ||
9319 | rx_cons_sb++; | ||
9320 | 9335 | ||
9321 | /* must not complete if we consumed full budget */ | 9336 | /* must not complete if we consumed full budget */ |
9322 | if ((work_done < budget) && !BNX2X_HAS_WORK(fp)) { | 9337 | if ((work_done < budget) && !BNX2X_HAS_WORK(fp)) { |