aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/isdn/i4l/Kconfig2
-rw-r--r--drivers/net/bonding/bond_alb.c112
-rw-r--r--drivers/net/ethernet/8390/ax88796.c3
-rw-r--r--drivers/net/ethernet/adi/bfin_mac.c3
-rw-r--r--drivers/net/ethernet/amd/au1000_eth.c3
-rw-r--r--drivers/net/ethernet/broadcom/bcm63xx_enet.c2
-rw-r--r--drivers/net/ethernet/broadcom/sb1250-mac.c3
-rw-r--r--drivers/net/ethernet/cadence/macb.c3
-rw-r--r--drivers/net/ethernet/dnet.c3
-rw-r--r--drivers/net/ethernet/freescale/fec.c12
-rw-r--r--drivers/net/ethernet/freescale/fec.h4
-rw-r--r--drivers/net/ethernet/freescale/gianfar.c34
-rw-r--r--drivers/net/ethernet/freescale/gianfar.h3
-rw-r--r--drivers/net/ethernet/lantiq_etop.c5
-rw-r--r--drivers/net/ethernet/marvell/mv643xx_eth.c3
-rw-r--r--drivers/net/ethernet/marvell/pxa168_eth.c3
-rw-r--r--drivers/net/ethernet/micrel/ksz884x.c2
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c3
-rw-r--r--drivers/net/ethernet/s6gmac.c2
-rw-r--r--drivers/net/ethernet/smsc/smsc911x.c3
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/mmc_core.c1
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c4
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c3
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c2
-rw-r--r--drivers/net/ethernet/ti/cpmac.c2
-rw-r--r--drivers/net/ethernet/ti/davinci_mdio.c3
-rw-r--r--drivers/net/ethernet/tundra/tsi108_eth.c6
-rw-r--r--drivers/net/ethernet/via/via-rhine.c668
-rw-r--r--drivers/net/ethernet/xscale/ixp4xx_eth.c2
-rw-r--r--drivers/net/phy/dp83640.c2
-rw-r--r--drivers/net/phy/fixed.c2
-rw-r--r--drivers/net/phy/mdio-gpio.c2
-rw-r--r--drivers/net/phy/mdio-octeon.c3
-rw-r--r--drivers/net/phy/mdio_bus.c24
-rw-r--r--drivers/net/ppp/pptp.c4
-rw-r--r--drivers/net/usb/asix.c15
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_phy.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.c1
-rw-r--r--drivers/net/wireless/ath/ath9k/calib.h1
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c8
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c4
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192se/fw.c4
-rw-r--r--include/linux/inet_diag.h14
-rw-r--r--include/linux/phy.h7
-rw-r--r--include/linux/pkt_sched.h20
-rw-r--r--include/net/bluetooth/hci_core.h4
-rw-r--r--include/net/red.h3
-rw-r--r--net/bluetooth/af_bluetooth.c8
-rw-r--r--net/bluetooth/hci_event.c22
-rw-r--r--net/bluetooth/hci_sock.c2
-rw-r--r--net/bluetooth/l2cap_core.c26
-rw-r--r--net/bluetooth/l2cap_sock.c2
-rw-r--r--net/bluetooth/mgmt.c4
-rw-r--r--net/bluetooth/rfcomm/sock.c12
-rw-r--r--net/bluetooth/rfcomm/tty.c22
-rw-r--r--net/bluetooth/sco.c8
-rw-r--r--net/core/net-sysfs.c6
-rw-r--r--net/core/netpoll.c2
-rw-r--r--net/dccp/diag.c4
-rw-r--r--net/decnet/dn_dev.c4
-rw-r--r--net/ipv4/devinet.c2
-rw-r--r--net/ipv4/fib_trie.c10
-rw-r--r--net/ipv4/igmp.c8
-rw-r--r--net/ipv4/inet_diag.c42
-rw-r--r--net/ipv4/ipip.c8
-rw-r--r--net/ipv4/ipmr.c2
-rw-r--r--net/ipv4/tcp_diag.c4
-rw-r--r--net/ipv4/tcp_memcontrol.c2
-rw-r--r--net/ipv4/udp_diag.c14
-rw-r--r--net/ipv6/addrconf.c2
-rw-r--r--net/ipv6/ip6_tunnel.c8
-rw-r--r--net/ipv6/raw.c2
-rw-r--r--net/ipv6/sit.c10
-rw-r--r--net/mac80211/agg-rx.c2
-rw-r--r--net/mac80211/cfg.c4
-rw-r--r--net/mac80211/ibss.c2
-rw-r--r--net/mac80211/sta_info.c6
-rw-r--r--net/mac80211/wpa.c2
-rw-r--r--net/netfilter/nf_conntrack_core.c2
-rw-r--r--net/netfilter/nf_conntrack_ecache.c4
-rw-r--r--net/netfilter/nf_conntrack_extend.c2
-rw-r--r--net/netfilter/nf_conntrack_helper.c2
-rw-r--r--net/netfilter/nf_conntrack_netlink.c2
-rw-r--r--net/netfilter/nf_log.c6
-rw-r--r--net/netfilter/nf_queue.c2
-rw-r--r--net/netfilter/nfnetlink.c4
-rw-r--r--net/netlabel/netlabel_domainhash.c4
-rw-r--r--net/netlabel/netlabel_unlabeled.c6
-rw-r--r--net/phonet/af_phonet.c2
-rw-r--r--net/phonet/pn_dev.c2
-rw-r--r--net/phonet/socket.c2
-rw-r--r--net/rds/iw_rdma.c15
-rw-r--r--net/sched/sch_sfq.c146
-rw-r--r--net/socket.c2
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c2
-rw-r--r--net/wireless/nl80211.c34
-rw-r--r--net/xfrm/xfrm_user.c2
98 files changed, 925 insertions, 588 deletions
diff --git a/drivers/isdn/i4l/Kconfig b/drivers/isdn/i4l/Kconfig
index 9c6650ea848e..2302fbe70ac6 100644
--- a/drivers/isdn/i4l/Kconfig
+++ b/drivers/isdn/i4l/Kconfig
@@ -6,7 +6,7 @@ if ISDN_I4L
6 6
7config ISDN_PPP 7config ISDN_PPP
8 bool "Support synchronous PPP" 8 bool "Support synchronous PPP"
9 depends on INET 9 depends on INET && NETDEVICES
10 select SLHC 10 select SLHC
11 help 11 help
12 Over digital connections such as ISDN, there is no need to 12 Over digital connections such as ISDN, there is no need to
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 106b88a04738..342626f4bc46 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -99,16 +99,26 @@ static inline u8 _simple_hash(const u8 *hash_start, int hash_size)
99 99
100/*********************** tlb specific functions ***************************/ 100/*********************** tlb specific functions ***************************/
101 101
102static inline void _lock_tx_hashtbl(struct bonding *bond) 102static inline void _lock_tx_hashtbl_bh(struct bonding *bond)
103{ 103{
104 spin_lock_bh(&(BOND_ALB_INFO(bond).tx_hashtbl_lock)); 104 spin_lock_bh(&(BOND_ALB_INFO(bond).tx_hashtbl_lock));
105} 105}
106 106
107static inline void _unlock_tx_hashtbl(struct bonding *bond) 107static inline void _unlock_tx_hashtbl_bh(struct bonding *bond)
108{ 108{
109 spin_unlock_bh(&(BOND_ALB_INFO(bond).tx_hashtbl_lock)); 109 spin_unlock_bh(&(BOND_ALB_INFO(bond).tx_hashtbl_lock));
110} 110}
111 111
112static inline void _lock_tx_hashtbl(struct bonding *bond)
113{
114 spin_lock(&(BOND_ALB_INFO(bond).tx_hashtbl_lock));
115}
116
117static inline void _unlock_tx_hashtbl(struct bonding *bond)
118{
119 spin_unlock(&(BOND_ALB_INFO(bond).tx_hashtbl_lock));
120}
121
112/* Caller must hold tx_hashtbl lock */ 122/* Caller must hold tx_hashtbl lock */
113static inline void tlb_init_table_entry(struct tlb_client_info *entry, int save_load) 123static inline void tlb_init_table_entry(struct tlb_client_info *entry, int save_load)
114{ 124{
@@ -129,14 +139,13 @@ static inline void tlb_init_slave(struct slave *slave)
129 SLAVE_TLB_INFO(slave).head = TLB_NULL_INDEX; 139 SLAVE_TLB_INFO(slave).head = TLB_NULL_INDEX;
130} 140}
131 141
132/* Caller must hold bond lock for read */ 142/* Caller must hold bond lock for read, BH disabled */
133static void tlb_clear_slave(struct bonding *bond, struct slave *slave, int save_load) 143static void __tlb_clear_slave(struct bonding *bond, struct slave *slave,
144 int save_load)
134{ 145{
135 struct tlb_client_info *tx_hash_table; 146 struct tlb_client_info *tx_hash_table;
136 u32 index; 147 u32 index;
137 148
138 _lock_tx_hashtbl(bond);
139
140 /* clear slave from tx_hashtbl */ 149 /* clear slave from tx_hashtbl */
141 tx_hash_table = BOND_ALB_INFO(bond).tx_hashtbl; 150 tx_hash_table = BOND_ALB_INFO(bond).tx_hashtbl;
142 151
@@ -151,8 +160,15 @@ static void tlb_clear_slave(struct bonding *bond, struct slave *slave, int save_
151 } 160 }
152 161
153 tlb_init_slave(slave); 162 tlb_init_slave(slave);
163}
154 164
155 _unlock_tx_hashtbl(bond); 165/* Caller must hold bond lock for read */
166static void tlb_clear_slave(struct bonding *bond, struct slave *slave,
167 int save_load)
168{
169 _lock_tx_hashtbl_bh(bond);
170 __tlb_clear_slave(bond, slave, save_load);
171 _unlock_tx_hashtbl_bh(bond);
156} 172}
157 173
158/* Must be called before starting the monitor timer */ 174/* Must be called before starting the monitor timer */
@@ -169,7 +185,7 @@ static int tlb_initialize(struct bonding *bond)
169 bond->dev->name); 185 bond->dev->name);
170 return -1; 186 return -1;
171 } 187 }
172 _lock_tx_hashtbl(bond); 188 _lock_tx_hashtbl_bh(bond);
173 189
174 bond_info->tx_hashtbl = new_hashtbl; 190 bond_info->tx_hashtbl = new_hashtbl;
175 191
@@ -177,7 +193,7 @@ static int tlb_initialize(struct bonding *bond)
177 tlb_init_table_entry(&bond_info->tx_hashtbl[i], 0); 193 tlb_init_table_entry(&bond_info->tx_hashtbl[i], 0);
178 } 194 }
179 195
180 _unlock_tx_hashtbl(bond); 196 _unlock_tx_hashtbl_bh(bond);
181 197
182 return 0; 198 return 0;
183} 199}
@@ -187,12 +203,12 @@ static void tlb_deinitialize(struct bonding *bond)
187{ 203{
188 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); 204 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
189 205
190 _lock_tx_hashtbl(bond); 206 _lock_tx_hashtbl_bh(bond);
191 207
192 kfree(bond_info->tx_hashtbl); 208 kfree(bond_info->tx_hashtbl);
193 bond_info->tx_hashtbl = NULL; 209 bond_info->tx_hashtbl = NULL;
194 210
195 _unlock_tx_hashtbl(bond); 211 _unlock_tx_hashtbl_bh(bond);
196} 212}
197 213
198static long long compute_gap(struct slave *slave) 214static long long compute_gap(struct slave *slave)
@@ -226,15 +242,13 @@ static struct slave *tlb_get_least_loaded_slave(struct bonding *bond)
226 return least_loaded; 242 return least_loaded;
227} 243}
228 244
229/* Caller must hold bond lock for read */ 245static struct slave *__tlb_choose_channel(struct bonding *bond, u32 hash_index,
230static struct slave *tlb_choose_channel(struct bonding *bond, u32 hash_index, u32 skb_len) 246 u32 skb_len)
231{ 247{
232 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); 248 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
233 struct tlb_client_info *hash_table; 249 struct tlb_client_info *hash_table;
234 struct slave *assigned_slave; 250 struct slave *assigned_slave;
235 251
236 _lock_tx_hashtbl(bond);
237
238 hash_table = bond_info->tx_hashtbl; 252 hash_table = bond_info->tx_hashtbl;
239 assigned_slave = hash_table[hash_index].tx_slave; 253 assigned_slave = hash_table[hash_index].tx_slave;
240 if (!assigned_slave) { 254 if (!assigned_slave) {
@@ -263,22 +277,46 @@ static struct slave *tlb_choose_channel(struct bonding *bond, u32 hash_index, u3
263 hash_table[hash_index].tx_bytes += skb_len; 277 hash_table[hash_index].tx_bytes += skb_len;
264 } 278 }
265 279
266 _unlock_tx_hashtbl(bond);
267
268 return assigned_slave; 280 return assigned_slave;
269} 281}
270 282
283/* Caller must hold bond lock for read */
284static struct slave *tlb_choose_channel(struct bonding *bond, u32 hash_index,
285 u32 skb_len)
286{
287 struct slave *tx_slave;
288 /*
289 * We don't need to disable softirq here, becase
290 * tlb_choose_channel() is only called by bond_alb_xmit()
291 * which already has softirq disabled.
292 */
293 _lock_tx_hashtbl(bond);
294 tx_slave = __tlb_choose_channel(bond, hash_index, skb_len);
295 _unlock_tx_hashtbl(bond);
296 return tx_slave;
297}
298
271/*********************** rlb specific functions ***************************/ 299/*********************** rlb specific functions ***************************/
272static inline void _lock_rx_hashtbl(struct bonding *bond) 300static inline void _lock_rx_hashtbl_bh(struct bonding *bond)
273{ 301{
274 spin_lock_bh(&(BOND_ALB_INFO(bond).rx_hashtbl_lock)); 302 spin_lock_bh(&(BOND_ALB_INFO(bond).rx_hashtbl_lock));
275} 303}
276 304
277static inline void _unlock_rx_hashtbl(struct bonding *bond) 305static inline void _unlock_rx_hashtbl_bh(struct bonding *bond)
278{ 306{
279 spin_unlock_bh(&(BOND_ALB_INFO(bond).rx_hashtbl_lock)); 307 spin_unlock_bh(&(BOND_ALB_INFO(bond).rx_hashtbl_lock));
280} 308}
281 309
310static inline void _lock_rx_hashtbl(struct bonding *bond)
311{
312 spin_lock(&(BOND_ALB_INFO(bond).rx_hashtbl_lock));
313}
314
315static inline void _unlock_rx_hashtbl(struct bonding *bond)
316{
317 spin_unlock(&(BOND_ALB_INFO(bond).rx_hashtbl_lock));
318}
319
282/* when an ARP REPLY is received from a client update its info 320/* when an ARP REPLY is received from a client update its info
283 * in the rx_hashtbl 321 * in the rx_hashtbl
284 */ 322 */
@@ -288,7 +326,7 @@ static void rlb_update_entry_from_arp(struct bonding *bond, struct arp_pkt *arp)
288 struct rlb_client_info *client_info; 326 struct rlb_client_info *client_info;
289 u32 hash_index; 327 u32 hash_index;
290 328
291 _lock_rx_hashtbl(bond); 329 _lock_rx_hashtbl_bh(bond);
292 330
293 hash_index = _simple_hash((u8*)&(arp->ip_src), sizeof(arp->ip_src)); 331 hash_index = _simple_hash((u8*)&(arp->ip_src), sizeof(arp->ip_src));
294 client_info = &(bond_info->rx_hashtbl[hash_index]); 332 client_info = &(bond_info->rx_hashtbl[hash_index]);
@@ -303,7 +341,7 @@ static void rlb_update_entry_from_arp(struct bonding *bond, struct arp_pkt *arp)
303 bond_info->rx_ntt = 1; 341 bond_info->rx_ntt = 1;
304 } 342 }
305 343
306 _unlock_rx_hashtbl(bond); 344 _unlock_rx_hashtbl_bh(bond);
307} 345}
308 346
309static void rlb_arp_recv(struct sk_buff *skb, struct bonding *bond, 347static void rlb_arp_recv(struct sk_buff *skb, struct bonding *bond,
@@ -401,7 +439,7 @@ static void rlb_clear_slave(struct bonding *bond, struct slave *slave)
401 u32 index, next_index; 439 u32 index, next_index;
402 440
403 /* clear slave from rx_hashtbl */ 441 /* clear slave from rx_hashtbl */
404 _lock_rx_hashtbl(bond); 442 _lock_rx_hashtbl_bh(bond);
405 443
406 rx_hash_table = bond_info->rx_hashtbl; 444 rx_hash_table = bond_info->rx_hashtbl;
407 index = bond_info->rx_hashtbl_head; 445 index = bond_info->rx_hashtbl_head;
@@ -432,7 +470,7 @@ static void rlb_clear_slave(struct bonding *bond, struct slave *slave)
432 } 470 }
433 } 471 }
434 472
435 _unlock_rx_hashtbl(bond); 473 _unlock_rx_hashtbl_bh(bond);
436 474
437 write_lock_bh(&bond->curr_slave_lock); 475 write_lock_bh(&bond->curr_slave_lock);
438 476
@@ -489,7 +527,7 @@ static void rlb_update_rx_clients(struct bonding *bond)
489 struct rlb_client_info *client_info; 527 struct rlb_client_info *client_info;
490 u32 hash_index; 528 u32 hash_index;
491 529
492 _lock_rx_hashtbl(bond); 530 _lock_rx_hashtbl_bh(bond);
493 531
494 hash_index = bond_info->rx_hashtbl_head; 532 hash_index = bond_info->rx_hashtbl_head;
495 for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) { 533 for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
@@ -507,7 +545,7 @@ static void rlb_update_rx_clients(struct bonding *bond)
507 */ 545 */
508 bond_info->rlb_update_delay_counter = RLB_UPDATE_DELAY; 546 bond_info->rlb_update_delay_counter = RLB_UPDATE_DELAY;
509 547
510 _unlock_rx_hashtbl(bond); 548 _unlock_rx_hashtbl_bh(bond);
511} 549}
512 550
513/* The slave was assigned a new mac address - update the clients */ 551/* The slave was assigned a new mac address - update the clients */
@@ -518,7 +556,7 @@ static void rlb_req_update_slave_clients(struct bonding *bond, struct slave *sla
518 int ntt = 0; 556 int ntt = 0;
519 u32 hash_index; 557 u32 hash_index;
520 558
521 _lock_rx_hashtbl(bond); 559 _lock_rx_hashtbl_bh(bond);
522 560
523 hash_index = bond_info->rx_hashtbl_head; 561 hash_index = bond_info->rx_hashtbl_head;
524 for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) { 562 for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
@@ -538,7 +576,7 @@ static void rlb_req_update_slave_clients(struct bonding *bond, struct slave *sla
538 bond_info->rlb_update_retry_counter = RLB_UPDATE_RETRY; 576 bond_info->rlb_update_retry_counter = RLB_UPDATE_RETRY;
539 } 577 }
540 578
541 _unlock_rx_hashtbl(bond); 579 _unlock_rx_hashtbl_bh(bond);
542} 580}
543 581
544/* mark all clients using src_ip to be updated */ 582/* mark all clients using src_ip to be updated */
@@ -709,7 +747,7 @@ static void rlb_rebalance(struct bonding *bond)
709 int ntt; 747 int ntt;
710 u32 hash_index; 748 u32 hash_index;
711 749
712 _lock_rx_hashtbl(bond); 750 _lock_rx_hashtbl_bh(bond);
713 751
714 ntt = 0; 752 ntt = 0;
715 hash_index = bond_info->rx_hashtbl_head; 753 hash_index = bond_info->rx_hashtbl_head;
@@ -727,7 +765,7 @@ static void rlb_rebalance(struct bonding *bond)
727 if (ntt) { 765 if (ntt) {
728 bond_info->rx_ntt = 1; 766 bond_info->rx_ntt = 1;
729 } 767 }
730 _unlock_rx_hashtbl(bond); 768 _unlock_rx_hashtbl_bh(bond);
731} 769}
732 770
733/* Caller must hold rx_hashtbl lock */ 771/* Caller must hold rx_hashtbl lock */
@@ -751,7 +789,7 @@ static int rlb_initialize(struct bonding *bond)
751 bond->dev->name); 789 bond->dev->name);
752 return -1; 790 return -1;
753 } 791 }
754 _lock_rx_hashtbl(bond); 792 _lock_rx_hashtbl_bh(bond);
755 793
756 bond_info->rx_hashtbl = new_hashtbl; 794 bond_info->rx_hashtbl = new_hashtbl;
757 795
@@ -761,7 +799,7 @@ static int rlb_initialize(struct bonding *bond)
761 rlb_init_table_entry(bond_info->rx_hashtbl + i); 799 rlb_init_table_entry(bond_info->rx_hashtbl + i);
762 } 800 }
763 801
764 _unlock_rx_hashtbl(bond); 802 _unlock_rx_hashtbl_bh(bond);
765 803
766 /* register to receive ARPs */ 804 /* register to receive ARPs */
767 bond->recv_probe = rlb_arp_recv; 805 bond->recv_probe = rlb_arp_recv;
@@ -773,13 +811,13 @@ static void rlb_deinitialize(struct bonding *bond)
773{ 811{
774 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); 812 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
775 813
776 _lock_rx_hashtbl(bond); 814 _lock_rx_hashtbl_bh(bond);
777 815
778 kfree(bond_info->rx_hashtbl); 816 kfree(bond_info->rx_hashtbl);
779 bond_info->rx_hashtbl = NULL; 817 bond_info->rx_hashtbl = NULL;
780 bond_info->rx_hashtbl_head = RLB_NULL_INDEX; 818 bond_info->rx_hashtbl_head = RLB_NULL_INDEX;
781 819
782 _unlock_rx_hashtbl(bond); 820 _unlock_rx_hashtbl_bh(bond);
783} 821}
784 822
785static void rlb_clear_vlan(struct bonding *bond, unsigned short vlan_id) 823static void rlb_clear_vlan(struct bonding *bond, unsigned short vlan_id)
@@ -787,7 +825,7 @@ static void rlb_clear_vlan(struct bonding *bond, unsigned short vlan_id)
787 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); 825 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
788 u32 curr_index; 826 u32 curr_index;
789 827
790 _lock_rx_hashtbl(bond); 828 _lock_rx_hashtbl_bh(bond);
791 829
792 curr_index = bond_info->rx_hashtbl_head; 830 curr_index = bond_info->rx_hashtbl_head;
793 while (curr_index != RLB_NULL_INDEX) { 831 while (curr_index != RLB_NULL_INDEX) {
@@ -812,7 +850,7 @@ static void rlb_clear_vlan(struct bonding *bond, unsigned short vlan_id)
812 curr_index = next_index; 850 curr_index = next_index;
813 } 851 }
814 852
815 _unlock_rx_hashtbl(bond); 853 _unlock_rx_hashtbl_bh(bond);
816} 854}
817 855
818/*********************** tlb/rlb shared functions *********************/ 856/*********************** tlb/rlb shared functions *********************/
@@ -1320,7 +1358,9 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev)
1320 res = bond_dev_queue_xmit(bond, skb, tx_slave->dev); 1358 res = bond_dev_queue_xmit(bond, skb, tx_slave->dev);
1321 } else { 1359 } else {
1322 if (tx_slave) { 1360 if (tx_slave) {
1323 tlb_clear_slave(bond, tx_slave, 0); 1361 _lock_tx_hashtbl(bond);
1362 __tlb_clear_slave(bond, tx_slave, 0);
1363 _unlock_tx_hashtbl(bond);
1324 } 1364 }
1325 } 1365 }
1326 1366
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index 9e8ba4f5636b..0f92e3567f68 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -623,7 +623,8 @@ static int ax_mii_init(struct net_device *dev)
623 623
624 ax->mii_bus->name = "ax88796_mii_bus"; 624 ax->mii_bus->name = "ax88796_mii_bus";
625 ax->mii_bus->parent = dev->dev.parent; 625 ax->mii_bus->parent = dev->dev.parent;
626 snprintf(ax->mii_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id); 626 snprintf(ax->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
627 pdev->name, pdev->id);
627 628
628 ax->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); 629 ax->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
629 if (!ax->mii_bus->irq) { 630 if (!ax->mii_bus->irq) {
diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c
index b6d69c91db96..d812a103e032 100644
--- a/drivers/net/ethernet/adi/bfin_mac.c
+++ b/drivers/net/ethernet/adi/bfin_mac.c
@@ -1670,7 +1670,8 @@ static int __devinit bfin_mii_bus_probe(struct platform_device *pdev)
1670 miibus->name = "bfin_mii_bus"; 1670 miibus->name = "bfin_mii_bus";
1671 miibus->phy_mask = mii_bus_pd->phy_mask; 1671 miibus->phy_mask = mii_bus_pd->phy_mask;
1672 1672
1673 snprintf(miibus->id, MII_BUS_ID_SIZE, "0"); 1673 snprintf(miibus->id, MII_BUS_ID_SIZE, "%s-%x",
1674 pdev->name, pdev->id);
1674 miibus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); 1675 miibus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
1675 if (!miibus->irq) 1676 if (!miibus->irq)
1676 goto out_err_irq_alloc; 1677 goto out_err_irq_alloc;
diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
index cc9262be69c8..8b95dd314253 100644
--- a/drivers/net/ethernet/amd/au1000_eth.c
+++ b/drivers/net/ethernet/amd/au1000_eth.c
@@ -1171,7 +1171,8 @@ static int __devinit au1000_probe(struct platform_device *pdev)
1171 aup->mii_bus->write = au1000_mdiobus_write; 1171 aup->mii_bus->write = au1000_mdiobus_write;
1172 aup->mii_bus->reset = au1000_mdiobus_reset; 1172 aup->mii_bus->reset = au1000_mdiobus_reset;
1173 aup->mii_bus->name = "au1000_eth_mii"; 1173 aup->mii_bus->name = "au1000_eth_mii";
1174 snprintf(aup->mii_bus->id, MII_BUS_ID_SIZE, "%x", aup->mac_id); 1174 snprintf(aup->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
1175 pdev->name, aup->mac_id);
1175 aup->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); 1176 aup->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
1176 if (aup->mii_bus->irq == NULL) 1177 if (aup->mii_bus->irq == NULL)
1177 goto err_out; 1178 goto err_out;
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index d44331eb07fe..986019b2c849 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -1727,7 +1727,7 @@ static int __devinit bcm_enet_probe(struct platform_device *pdev)
1727 bus->priv = priv; 1727 bus->priv = priv;
1728 bus->read = bcm_enet_mdio_read_phylib; 1728 bus->read = bcm_enet_mdio_read_phylib;
1729 bus->write = bcm_enet_mdio_write_phylib; 1729 bus->write = bcm_enet_mdio_write_phylib;
1730 sprintf(bus->id, "%d", priv->mac_id); 1730 sprintf(bus->id, "%s-%d", pdev->name, priv->mac_id);
1731 1731
1732 /* only probe bus where we think the PHY is, because 1732 /* only probe bus where we think the PHY is, because
1733 * the mdio read operation return 0 instead of 0xffff 1733 * the mdio read operation return 0 instead of 0xffff
diff --git a/drivers/net/ethernet/broadcom/sb1250-mac.c b/drivers/net/ethernet/broadcom/sb1250-mac.c
index 8fa7abc53ec6..084904ceaa30 100644
--- a/drivers/net/ethernet/broadcom/sb1250-mac.c
+++ b/drivers/net/ethernet/broadcom/sb1250-mac.c
@@ -2259,7 +2259,8 @@ static int sbmac_init(struct platform_device *pldev, long long base)
2259 } 2259 }
2260 2260
2261 sc->mii_bus->name = sbmac_mdio_string; 2261 sc->mii_bus->name = sbmac_mdio_string;
2262 snprintf(sc->mii_bus->id, MII_BUS_ID_SIZE, "%x", idx); 2262 snprintf(sc->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
2263 pldev->name, idx);
2263 sc->mii_bus->priv = sc; 2264 sc->mii_bus->priv = sc;
2264 sc->mii_bus->read = sbmac_mii_read; 2265 sc->mii_bus->read = sbmac_mii_read;
2265 sc->mii_bus->write = sbmac_mii_write; 2266 sc->mii_bus->write = sbmac_mii_write;
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index f3d5c65d99cf..23200680d4c1 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -243,7 +243,8 @@ static int macb_mii_init(struct macb *bp)
243 bp->mii_bus->read = &macb_mdio_read; 243 bp->mii_bus->read = &macb_mdio_read;
244 bp->mii_bus->write = &macb_mdio_write; 244 bp->mii_bus->write = &macb_mdio_write;
245 bp->mii_bus->reset = &macb_mdio_reset; 245 bp->mii_bus->reset = &macb_mdio_reset;
246 snprintf(bp->mii_bus->id, MII_BUS_ID_SIZE, "%x", bp->pdev->id); 246 snprintf(bp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
247 bp->pdev->name, bp->pdev->id);
247 bp->mii_bus->priv = bp; 248 bp->mii_bus->priv = bp;
248 bp->mii_bus->parent = &bp->dev->dev; 249 bp->mii_bus->parent = &bp->dev->dev;
249 pdata = bp->pdev->dev.platform_data; 250 pdata = bp->pdev->dev.platform_data;
diff --git a/drivers/net/ethernet/dnet.c b/drivers/net/ethernet/dnet.c
index ce88c0f399f6..925c9bafc9b9 100644
--- a/drivers/net/ethernet/dnet.c
+++ b/drivers/net/ethernet/dnet.c
@@ -325,7 +325,8 @@ static int dnet_mii_init(struct dnet *bp)
325 bp->mii_bus->write = &dnet_mdio_write; 325 bp->mii_bus->write = &dnet_mdio_write;
326 bp->mii_bus->reset = &dnet_mdio_reset; 326 bp->mii_bus->reset = &dnet_mdio_reset;
327 327
328 snprintf(bp->mii_bus->id, MII_BUS_ID_SIZE, "%x", 0); 328 snprintf(bp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
329 bp->pdev->name, bp->pdev->id);
329 330
330 bp->mii_bus->priv = bp; 331 bp->mii_bus->priv = bp;
331 332
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index ddcbbb34d1b9..7b25e9cf13f6 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -476,6 +476,7 @@ fec_restart(struct net_device *ndev, int duplex)
476 } else { 476 } else {
477#ifdef FEC_MIIGSK_ENR 477#ifdef FEC_MIIGSK_ENR
478 if (id_entry->driver_data & FEC_QUIRK_USE_GASKET) { 478 if (id_entry->driver_data & FEC_QUIRK_USE_GASKET) {
479 u32 cfgr;
479 /* disable the gasket and wait */ 480 /* disable the gasket and wait */
480 writel(0, fep->hwp + FEC_MIIGSK_ENR); 481 writel(0, fep->hwp + FEC_MIIGSK_ENR);
481 while (readl(fep->hwp + FEC_MIIGSK_ENR) & 4) 482 while (readl(fep->hwp + FEC_MIIGSK_ENR) & 4)
@@ -486,9 +487,11 @@ fec_restart(struct net_device *ndev, int duplex)
486 * RMII, 50 MHz, no loopback, no echo 487 * RMII, 50 MHz, no loopback, no echo
487 * MII, 25 MHz, no loopback, no echo 488 * MII, 25 MHz, no loopback, no echo
488 */ 489 */
489 writel((fep->phy_interface == PHY_INTERFACE_MODE_RMII) ? 490 cfgr = (fep->phy_interface == PHY_INTERFACE_MODE_RMII)
490 1 : 0, fep->hwp + FEC_MIIGSK_CFGR); 491 ? BM_MIIGSK_CFGR_RMII : BM_MIIGSK_CFGR_MII;
491 492 if (fep->phy_dev && fep->phy_dev->speed == SPEED_10)
493 cfgr |= BM_MIIGSK_CFGR_FRCONT_10M;
494 writel(cfgr, fep->hwp + FEC_MIIGSK_CFGR);
492 495
493 /* re-enable the gasket */ 496 /* re-enable the gasket */
494 writel(2, fep->hwp + FEC_MIIGSK_ENR); 497 writel(2, fep->hwp + FEC_MIIGSK_ENR);
@@ -1077,7 +1080,8 @@ static int fec_enet_mii_init(struct platform_device *pdev)
1077 fep->mii_bus->read = fec_enet_mdio_read; 1080 fep->mii_bus->read = fec_enet_mdio_read;
1078 fep->mii_bus->write = fec_enet_mdio_write; 1081 fep->mii_bus->write = fec_enet_mdio_write;
1079 fep->mii_bus->reset = fec_enet_mdio_reset; 1082 fep->mii_bus->reset = fec_enet_mdio_reset;
1080 snprintf(fep->mii_bus->id, MII_BUS_ID_SIZE, "%x", fep->dev_id + 1); 1083 snprintf(fep->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
1084 pdev->name, fep->dev_id + 1);
1081 fep->mii_bus->priv = fep; 1085 fep->mii_bus->priv = fep;
1082 fep->mii_bus->parent = &pdev->dev; 1086 fep->mii_bus->parent = &pdev->dev;
1083 1087
diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 8b2c6d797e6d..8408c627b195 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -47,6 +47,10 @@
47#define FEC_MIIGSK_CFGR 0x300 /* MIIGSK Configuration reg */ 47#define FEC_MIIGSK_CFGR 0x300 /* MIIGSK Configuration reg */
48#define FEC_MIIGSK_ENR 0x308 /* MIIGSK Enable reg */ 48#define FEC_MIIGSK_ENR 0x308 /* MIIGSK Enable reg */
49 49
50#define BM_MIIGSK_CFGR_MII 0x00
51#define BM_MIIGSK_CFGR_RMII 0x01
52#define BM_MIIGSK_CFGR_FRCONT_10M 0x40
53
50#else 54#else
51 55
52#define FEC_ECNTRL 0x000 /* Ethernet control reg */ 56#define FEC_ECNTRL 0x000 /* Ethernet control reg */
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index e01cdaa722a9..39d160d353a4 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -1984,7 +1984,8 @@ static inline struct txfcb *gfar_add_fcb(struct sk_buff *skb)
1984 return fcb; 1984 return fcb;
1985} 1985}
1986 1986
1987static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb) 1987static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb,
1988 int fcb_length)
1988{ 1989{
1989 u8 flags = 0; 1990 u8 flags = 0;
1990 1991
@@ -2006,7 +2007,7 @@ static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb)
2006 * frame (skb->data) and the start of the IP hdr. 2007 * frame (skb->data) and the start of the IP hdr.
2007 * l4os is the distance between the start of the 2008 * l4os is the distance between the start of the
2008 * l3 hdr and the l4 hdr */ 2009 * l3 hdr and the l4 hdr */
2009 fcb->l3os = (u16)(skb_network_offset(skb) - GMAC_FCB_LEN); 2010 fcb->l3os = (u16)(skb_network_offset(skb) - fcb_length);
2010 fcb->l4os = skb_network_header_len(skb); 2011 fcb->l4os = skb_network_header_len(skb);
2011 2012
2012 fcb->flags = flags; 2013 fcb->flags = flags;
@@ -2046,7 +2047,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2046 int i, rq = 0, do_tstamp = 0; 2047 int i, rq = 0, do_tstamp = 0;
2047 u32 bufaddr; 2048 u32 bufaddr;
2048 unsigned long flags; 2049 unsigned long flags;
2049 unsigned int nr_frags, nr_txbds, length; 2050 unsigned int nr_frags, nr_txbds, length, fcb_length = GMAC_FCB_LEN;
2050 2051
2051 /* 2052 /*
2052 * TOE=1 frames larger than 2500 bytes may see excess delays 2053 * TOE=1 frames larger than 2500 bytes may see excess delays
@@ -2070,22 +2071,28 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2070 2071
2071 /* check if time stamp should be generated */ 2072 /* check if time stamp should be generated */
2072 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP && 2073 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP &&
2073 priv->hwts_tx_en)) 2074 priv->hwts_tx_en)) {
2074 do_tstamp = 1; 2075 do_tstamp = 1;
2076 fcb_length = GMAC_FCB_LEN + GMAC_TXPAL_LEN;
2077 }
2075 2078
2076 /* make space for additional header when fcb is needed */ 2079 /* make space for additional header when fcb is needed */
2077 if (((skb->ip_summed == CHECKSUM_PARTIAL) || 2080 if (((skb->ip_summed == CHECKSUM_PARTIAL) ||
2078 vlan_tx_tag_present(skb) || 2081 vlan_tx_tag_present(skb) ||
2079 unlikely(do_tstamp)) && 2082 unlikely(do_tstamp)) &&
2080 (skb_headroom(skb) < GMAC_FCB_LEN)) { 2083 (skb_headroom(skb) < fcb_length)) {
2081 struct sk_buff *skb_new; 2084 struct sk_buff *skb_new;
2082 2085
2083 skb_new = skb_realloc_headroom(skb, GMAC_FCB_LEN); 2086 skb_new = skb_realloc_headroom(skb, fcb_length);
2084 if (!skb_new) { 2087 if (!skb_new) {
2085 dev->stats.tx_errors++; 2088 dev->stats.tx_errors++;
2086 kfree_skb(skb); 2089 kfree_skb(skb);
2087 return NETDEV_TX_OK; 2090 return NETDEV_TX_OK;
2088 } 2091 }
2092
2093 /* Steal sock reference for processing TX time stamps */
2094 swap(skb_new->sk, skb->sk);
2095 swap(skb_new->destructor, skb->destructor);
2089 kfree_skb(skb); 2096 kfree_skb(skb);
2090 skb = skb_new; 2097 skb = skb_new;
2091 } 2098 }
@@ -2154,6 +2161,12 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2154 lstatus = txbdp_start->lstatus; 2161 lstatus = txbdp_start->lstatus;
2155 } 2162 }
2156 2163
2164 /* Add TxPAL between FCB and frame if required */
2165 if (unlikely(do_tstamp)) {
2166 skb_push(skb, GMAC_TXPAL_LEN);
2167 memset(skb->data, 0, GMAC_TXPAL_LEN);
2168 }
2169
2157 /* Set up checksumming */ 2170 /* Set up checksumming */
2158 if (CHECKSUM_PARTIAL == skb->ip_summed) { 2171 if (CHECKSUM_PARTIAL == skb->ip_summed) {
2159 fcb = gfar_add_fcb(skb); 2172 fcb = gfar_add_fcb(skb);
@@ -2164,7 +2177,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2164 skb_checksum_help(skb); 2177 skb_checksum_help(skb);
2165 } else { 2178 } else {
2166 lstatus |= BD_LFLAG(TXBD_TOE); 2179 lstatus |= BD_LFLAG(TXBD_TOE);
2167 gfar_tx_checksum(skb, fcb); 2180 gfar_tx_checksum(skb, fcb, fcb_length);
2168 } 2181 }
2169 } 2182 }
2170 2183
@@ -2196,9 +2209,9 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
2196 * the full frame length. 2209 * the full frame length.
2197 */ 2210 */
2198 if (unlikely(do_tstamp)) { 2211 if (unlikely(do_tstamp)) {
2199 txbdp_tstamp->bufPtr = txbdp_start->bufPtr + GMAC_FCB_LEN; 2212 txbdp_tstamp->bufPtr = txbdp_start->bufPtr + fcb_length;
2200 txbdp_tstamp->lstatus |= BD_LFLAG(TXBD_READY) | 2213 txbdp_tstamp->lstatus |= BD_LFLAG(TXBD_READY) |
2201 (skb_headlen(skb) - GMAC_FCB_LEN); 2214 (skb_headlen(skb) - fcb_length);
2202 lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | GMAC_FCB_LEN; 2215 lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | GMAC_FCB_LEN;
2203 } else { 2216 } else {
2204 lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | skb_headlen(skb); 2217 lstatus |= BD_LFLAG(TXBD_CRC | TXBD_READY) | skb_headlen(skb);
@@ -2490,7 +2503,7 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
2490 2503
2491 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) { 2504 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS)) {
2492 next = next_txbd(bdp, base, tx_ring_size); 2505 next = next_txbd(bdp, base, tx_ring_size);
2493 buflen = next->length + GMAC_FCB_LEN; 2506 buflen = next->length + GMAC_FCB_LEN + GMAC_TXPAL_LEN;
2494 } else 2507 } else
2495 buflen = bdp->length; 2508 buflen = bdp->length;
2496 2509
@@ -2502,6 +2515,7 @@ static int gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
2502 u64 *ns = (u64*) (((u32)skb->data + 0x10) & ~0x7); 2515 u64 *ns = (u64*) (((u32)skb->data + 0x10) & ~0x7);
2503 memset(&shhwtstamps, 0, sizeof(shhwtstamps)); 2516 memset(&shhwtstamps, 0, sizeof(shhwtstamps));
2504 shhwtstamps.hwtstamp = ns_to_ktime(*ns); 2517 shhwtstamps.hwtstamp = ns_to_ktime(*ns);
2518 skb_pull(skb, GMAC_FCB_LEN + GMAC_TXPAL_LEN);
2505 skb_tstamp_tx(skb, &shhwtstamps); 2519 skb_tstamp_tx(skb, &shhwtstamps);
2506 bdp->lstatus &= BD_LFLAG(TXBD_WRAP); 2520 bdp->lstatus &= BD_LFLAG(TXBD_WRAP);
2507 bdp = next; 2521 bdp = next;
diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h
index fe7ac3a83194..40c33a7554c0 100644
--- a/drivers/net/ethernet/freescale/gianfar.h
+++ b/drivers/net/ethernet/freescale/gianfar.h
@@ -63,6 +63,9 @@ struct ethtool_rx_list {
63/* Length for FCB */ 63/* Length for FCB */
64#define GMAC_FCB_LEN 8 64#define GMAC_FCB_LEN 8
65 65
66/* Length for TxPAL */
67#define GMAC_TXPAL_LEN 16
68
66/* Default padding amount */ 69/* Default padding amount */
67#define DEFAULT_PADDING 2 70#define DEFAULT_PADDING 2
68 71
diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
index 0b3567ab8121..85e2c6cd9708 100644
--- a/drivers/net/ethernet/lantiq_etop.c
+++ b/drivers/net/ethernet/lantiq_etop.c
@@ -98,6 +98,7 @@ struct ltq_etop_chan {
98 98
99struct ltq_etop_priv { 99struct ltq_etop_priv {
100 struct net_device *netdev; 100 struct net_device *netdev;
101 struct platform_device *pdev;
101 struct ltq_eth_data *pldata; 102 struct ltq_eth_data *pldata;
102 struct resource *res; 103 struct resource *res;
103 104
@@ -436,7 +437,8 @@ ltq_etop_mdio_init(struct net_device *dev)
436 priv->mii_bus->read = ltq_etop_mdio_rd; 437 priv->mii_bus->read = ltq_etop_mdio_rd;
437 priv->mii_bus->write = ltq_etop_mdio_wr; 438 priv->mii_bus->write = ltq_etop_mdio_wr;
438 priv->mii_bus->name = "ltq_mii"; 439 priv->mii_bus->name = "ltq_mii";
439 snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%x", 0); 440 snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
441 priv->pdev->name, priv->pdev->id);
440 priv->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); 442 priv->mii_bus->irq = kmalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL);
441 if (!priv->mii_bus->irq) { 443 if (!priv->mii_bus->irq) {
442 err = -ENOMEM; 444 err = -ENOMEM;
@@ -734,6 +736,7 @@ ltq_etop_probe(struct platform_device *pdev)
734 dev->ethtool_ops = &ltq_etop_ethtool_ops; 736 dev->ethtool_ops = &ltq_etop_ethtool_ops;
735 priv = netdev_priv(dev); 737 priv = netdev_priv(dev);
736 priv->res = res; 738 priv->res = res;
739 priv->pdev = pdev;
737 priv->pldata = dev_get_platdata(&pdev->dev); 740 priv->pldata = dev_get_platdata(&pdev->dev);
738 priv->netdev = dev; 741 priv->netdev = dev;
739 spin_lock_init(&priv->lock); 742 spin_lock_init(&priv->lock);
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 80aab4e5d695..9c049d2cb97d 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -2613,7 +2613,8 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
2613 msp->smi_bus->name = "mv643xx_eth smi"; 2613 msp->smi_bus->name = "mv643xx_eth smi";
2614 msp->smi_bus->read = smi_bus_read; 2614 msp->smi_bus->read = smi_bus_read;
2615 msp->smi_bus->write = smi_bus_write, 2615 msp->smi_bus->write = smi_bus_write,
2616 snprintf(msp->smi_bus->id, MII_BUS_ID_SIZE, "%d", pdev->id); 2616 snprintf(msp->smi_bus->id, MII_BUS_ID_SIZE, "%s-%d",
2617 pdev->name, pdev->id);
2617 msp->smi_bus->parent = &pdev->dev; 2618 msp->smi_bus->parent = &pdev->dev;
2618 msp->smi_bus->phy_mask = 0xffffffff; 2619 msp->smi_bus->phy_mask = 0xffffffff;
2619 if (mdiobus_register(msp->smi_bus) < 0) 2620 if (mdiobus_register(msp->smi_bus) < 0)
diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c
index 5ec409e3da09..953ba5851f7b 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -1552,7 +1552,8 @@ static int pxa168_eth_probe(struct platform_device *pdev)
1552 pep->smi_bus->name = "pxa168_eth smi"; 1552 pep->smi_bus->name = "pxa168_eth smi";
1553 pep->smi_bus->read = pxa168_smi_read; 1553 pep->smi_bus->read = pxa168_smi_read;
1554 pep->smi_bus->write = pxa168_smi_write; 1554 pep->smi_bus->write = pxa168_smi_write;
1555 snprintf(pep->smi_bus->id, MII_BUS_ID_SIZE, "%d", pdev->id); 1555 snprintf(pep->smi_bus->id, MII_BUS_ID_SIZE, "%s-%d",
1556 pdev->name, pdev->id);
1556 pep->smi_bus->parent = &pdev->dev; 1557 pep->smi_bus->parent = &pdev->dev;
1557 pep->smi_bus->phy_mask = 0xffffffff; 1558 pep->smi_bus->phy_mask = 0xffffffff;
1558 err = mdiobus_register(pep->smi_bus); 1559 err = mdiobus_register(pep->smi_bus);
diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c
index 6ed09a85f035..e52cd310ae76 100644
--- a/drivers/net/ethernet/micrel/ksz884x.c
+++ b/drivers/net/ethernet/micrel/ksz884x.c
@@ -746,7 +746,7 @@
746#define MAC_ADDR_ORDER(i) (ETH_ALEN - 1 - (i)) 746#define MAC_ADDR_ORDER(i) (ETH_ALEN - 1 - (i))
747 747
748#define MAX_ETHERNET_BODY_SIZE 1500 748#define MAX_ETHERNET_BODY_SIZE 1500
749#define ETHERNET_HEADER_SIZE 14 749#define ETHERNET_HEADER_SIZE (14 + VLAN_HLEN)
750 750
751#define MAX_ETHERNET_PACKET_SIZE \ 751#define MAX_ETHERNET_PACKET_SIZE \
752 (MAX_ETHERNET_BODY_SIZE + ETHERNET_HEADER_SIZE) 752 (MAX_ETHERNET_BODY_SIZE + ETHERNET_HEADER_SIZE)
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index fc9bda9bc36c..6ece4295d78f 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1702,7 +1702,8 @@ static int sh_mdio_init(struct net_device *ndev, int id,
1702 /* Hook up MII support for ethtool */ 1702 /* Hook up MII support for ethtool */
1703 mdp->mii_bus->name = "sh_mii"; 1703 mdp->mii_bus->name = "sh_mii";
1704 mdp->mii_bus->parent = &ndev->dev; 1704 mdp->mii_bus->parent = &ndev->dev;
1705 snprintf(mdp->mii_bus->id, MII_BUS_ID_SIZE, "%x", id); 1705 snprintf(mdp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
1706 mdp->pdev->name, pdid);
1706 1707
1707 /* PHY IRQ */ 1708 /* PHY IRQ */
1708 mdp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); 1709 mdp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
diff --git a/drivers/net/ethernet/s6gmac.c b/drivers/net/ethernet/s6gmac.c
index a7ff8ea342b4..22e9c0181ce8 100644
--- a/drivers/net/ethernet/s6gmac.c
+++ b/drivers/net/ethernet/s6gmac.c
@@ -1004,7 +1004,7 @@ static int __devinit s6gmac_probe(struct platform_device *pdev)
1004 mb->write = s6mii_write; 1004 mb->write = s6mii_write;
1005 mb->reset = s6mii_reset; 1005 mb->reset = s6mii_reset;
1006 mb->priv = pd; 1006 mb->priv = pd;
1007 snprintf(mb->id, MII_BUS_ID_SIZE, "0"); 1007 snprintf(mb->id, MII_BUS_ID_SIZE, "%s-%x", pdev->name, pdev->id);
1008 mb->phy_mask = ~(1 << 0); 1008 mb->phy_mask = ~(1 << 0);
1009 mb->irq = &pd->mii.irq[0]; 1009 mb->irq = &pd->mii.irq[0];
1010 for (i = 0; i < PHY_MAX_ADDR; i++) { 1010 for (i = 0; i < PHY_MAX_ADDR; i++) {
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 9d0b8ced0234..24d2df068d71 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -1044,7 +1044,8 @@ static int __devinit smsc911x_mii_init(struct platform_device *pdev,
1044 } 1044 }
1045 1045
1046 pdata->mii_bus->name = SMSC_MDIONAME; 1046 pdata->mii_bus->name = SMSC_MDIONAME;
1047 snprintf(pdata->mii_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id); 1047 snprintf(pdata->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
1048 pdev->name, pdev->id);
1048 pdata->mii_bus->priv = pdata; 1049 pdata->mii_bus->priv = pdata;
1049 pdata->mii_bus->read = smsc911x_mii_read; 1050 pdata->mii_bus->read = smsc911x_mii_read;
1050 pdata->mii_bus->write = smsc911x_mii_write; 1051 pdata->mii_bus->write = smsc911x_mii_write;
diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
index 41e6b33e1b08..c07cfe989f6e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
@@ -22,6 +22,7 @@
22 Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> 22 Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
23*******************************************************************************/ 23*******************************************************************************/
24 24
25#include <linux/kernel.h>
25#include <linux/io.h> 26#include <linux/io.h>
26#include "mmc.h" 27#include "mmc.h"
27 28
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 3738b4700548..96fa2da30763 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -307,7 +307,7 @@ static int stmmac_init_phy(struct net_device *dev)
307 priv->speed = 0; 307 priv->speed = 0;
308 priv->oldduplex = -1; 308 priv->oldduplex = -1;
309 309
310 snprintf(bus_id, MII_BUS_ID_SIZE, "%x", priv->plat->bus_id); 310 snprintf(bus_id, MII_BUS_ID_SIZE, "stmmac-%x", priv->plat->bus_id);
311 snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, bus_id, 311 snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT, bus_id,
312 priv->plat->phy_addr); 312 priv->plat->phy_addr);
313 pr_debug("stmmac_init_phy: trying to attach to %s\n", phy_id); 313 pr_debug("stmmac_init_phy: trying to attach to %s\n", phy_id);
@@ -772,7 +772,7 @@ static void stmmac_mmc_setup(struct stmmac_priv *priv)
772 dwmac_mmc_ctrl(priv->ioaddr, mode); 772 dwmac_mmc_ctrl(priv->ioaddr, mode);
773 memset(&priv->mmc, 0, sizeof(struct stmmac_counters)); 773 memset(&priv->mmc, 0, sizeof(struct stmmac_counters));
774 } else 774 } else
775 pr_info(" No MAC Management Counters available"); 775 pr_info(" No MAC Management Counters available\n");
776} 776}
777 777
778static u32 stmmac_get_synopsys_id(struct stmmac_priv *priv) 778static u32 stmmac_get_synopsys_id(struct stmmac_priv *priv)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index 51f441233962..da4a1042523a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -158,7 +158,8 @@ int stmmac_mdio_register(struct net_device *ndev)
158 new_bus->read = &stmmac_mdio_read; 158 new_bus->read = &stmmac_mdio_read;
159 new_bus->write = &stmmac_mdio_write; 159 new_bus->write = &stmmac_mdio_write;
160 new_bus->reset = &stmmac_mdio_reset; 160 new_bus->reset = &stmmac_mdio_reset;
161 snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", mdio_bus_data->bus_id); 161 snprintf(new_bus->id, MII_BUS_ID_SIZE, "%s-%x",
162 new_bus->name, mdio_bus_data->bus_id);
162 new_bus->priv = ndev; 163 new_bus->priv = ndev;
163 new_bus->irq = irqlist; 164 new_bus->irq = irqlist;
164 new_bus->phy_mask = mdio_bus_data->phy_mask; 165 new_bus->phy_mask = mdio_bus_data->phy_mask;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 7b1594f4944e..1ac83243649a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -62,7 +62,7 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
62 priv = stmmac_dvr_probe(&(pdev->dev), plat_dat); 62 priv = stmmac_dvr_probe(&(pdev->dev), plat_dat);
63 if (!priv) { 63 if (!priv) {
64 pr_err("%s: main drivr probe failed", __func__); 64 pr_err("%s: main drivr probe failed", __func__);
65 goto out_release_region; 65 goto out_unmap;
66 } 66 }
67 67
68 priv->ioaddr = addr; 68 priv->ioaddr = addr;
diff --git a/drivers/net/ethernet/ti/cpmac.c b/drivers/net/ethernet/ti/cpmac.c
index aaac0c7ad111..4d9a28ffd3c3 100644
--- a/drivers/net/ethernet/ti/cpmac.c
+++ b/drivers/net/ethernet/ti/cpmac.c
@@ -1269,7 +1269,7 @@ int __devinit cpmac_init(void)
1269 } 1269 }
1270 1270
1271 cpmac_mii->phy_mask = ~(mask | 0x80000000); 1271 cpmac_mii->phy_mask = ~(mask | 0x80000000);
1272 snprintf(cpmac_mii->id, MII_BUS_ID_SIZE, "1"); 1272 snprintf(cpmac_mii->id, MII_BUS_ID_SIZE, "cpmac-1");
1273 1273
1274 res = mdiobus_register(cpmac_mii); 1274 res = mdiobus_register(cpmac_mii);
1275 if (res) 1275 if (res)
diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index 7615040df756..ef7c9c17bfff 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -313,7 +313,8 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev)
313 data->bus->reset = davinci_mdio_reset, 313 data->bus->reset = davinci_mdio_reset,
314 data->bus->parent = dev; 314 data->bus->parent = dev;
315 data->bus->priv = data; 315 data->bus->priv = data;
316 snprintf(data->bus->id, MII_BUS_ID_SIZE, "%x", pdev->id); 316 snprintf(data->bus->id, MII_BUS_ID_SIZE, "%s-%x",
317 pdev->name, pdev->id);
317 318
318 data->clk = clk_get(dev, NULL); 319 data->clk = clk_get(dev, NULL);
319 if (IS_ERR(data->clk)) { 320 if (IS_ERR(data->clk)) {
diff --git a/drivers/net/ethernet/tundra/tsi108_eth.c b/drivers/net/ethernet/tundra/tsi108_eth.c
index a9ce01bafd20..164fb775d7b3 100644
--- a/drivers/net/ethernet/tundra/tsi108_eth.c
+++ b/drivers/net/ethernet/tundra/tsi108_eth.c
@@ -1604,7 +1604,7 @@ tsi108_init_one(struct platform_device *pdev)
1604 data->phyregs = ioremap(einfo->phyregs, 0x400); 1604 data->phyregs = ioremap(einfo->phyregs, 0x400);
1605 if (NULL == data->phyregs) { 1605 if (NULL == data->phyregs) {
1606 err = -ENOMEM; 1606 err = -ENOMEM;
1607 goto regs_fail; 1607 goto phyregs_fail;
1608 } 1608 }
1609/* MII setup */ 1609/* MII setup */
1610 data->mii_if.dev = dev; 1610 data->mii_if.dev = dev;
@@ -1663,9 +1663,11 @@ tsi108_init_one(struct platform_device *pdev)
1663 return 0; 1663 return 0;
1664 1664
1665register_fail: 1665register_fail:
1666 iounmap(data->regs);
1667 iounmap(data->phyregs); 1666 iounmap(data->phyregs);
1668 1667
1668phyregs_fail:
1669 iounmap(data->regs);
1670
1669regs_fail: 1671regs_fail:
1670 free_netdev(dev); 1672 free_netdev(dev);
1671 return err; 1673 return err;
diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
index 5c4983b2870a..10b18eb63d25 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -39,10 +39,9 @@
39 39
40/* A few user-configurable values. 40/* A few user-configurable values.
41 These may be modified when a driver module is loaded. */ 41 These may be modified when a driver module is loaded. */
42 42static int debug = 0;
43#define DEBUG 43#define RHINE_MSG_DEFAULT \
44static int debug = 1; /* 1 normal messages, 0 quiet .. 7 verbose. */ 44 (0x0000)
45static int max_interrupt_work = 20;
46 45
47/* Set the copy breakpoint for the copy-only-tiny-frames scheme. 46/* Set the copy breakpoint for the copy-only-tiny-frames scheme.
48 Setting to > 1518 effectively disables this feature. */ 47 Setting to > 1518 effectively disables this feature. */
@@ -128,12 +127,10 @@ MODULE_AUTHOR("Donald Becker <becker@scyld.com>");
128MODULE_DESCRIPTION("VIA Rhine PCI Fast Ethernet driver"); 127MODULE_DESCRIPTION("VIA Rhine PCI Fast Ethernet driver");
129MODULE_LICENSE("GPL"); 128MODULE_LICENSE("GPL");
130 129
131module_param(max_interrupt_work, int, 0);
132module_param(debug, int, 0); 130module_param(debug, int, 0);
133module_param(rx_copybreak, int, 0); 131module_param(rx_copybreak, int, 0);
134module_param(avoid_D3, bool, 0); 132module_param(avoid_D3, bool, 0);
135MODULE_PARM_DESC(max_interrupt_work, "VIA Rhine maximum events handled per interrupt"); 133MODULE_PARM_DESC(debug, "VIA Rhine debug message flags");
136MODULE_PARM_DESC(debug, "VIA Rhine debug level (0-7)");
137MODULE_PARM_DESC(rx_copybreak, "VIA Rhine copy breakpoint for copy-only-tiny-frames"); 134MODULE_PARM_DESC(rx_copybreak, "VIA Rhine copy breakpoint for copy-only-tiny-frames");
138MODULE_PARM_DESC(avoid_D3, "Avoid power state D3 (work-around for broken BIOSes)"); 135MODULE_PARM_DESC(avoid_D3, "Avoid power state D3 (work-around for broken BIOSes)");
139 136
@@ -351,16 +348,25 @@ static const int mmio_verify_registers[] = {
351 348
352/* Bits in the interrupt status/mask registers. */ 349/* Bits in the interrupt status/mask registers. */
353enum intr_status_bits { 350enum intr_status_bits {
354 IntrRxDone=0x0001, IntrRxErr=0x0004, IntrRxEmpty=0x0020, 351 IntrRxDone = 0x0001,
355 IntrTxDone=0x0002, IntrTxError=0x0008, IntrTxUnderrun=0x0210, 352 IntrTxDone = 0x0002,
356 IntrPCIErr=0x0040, 353 IntrRxErr = 0x0004,
357 IntrStatsMax=0x0080, IntrRxEarly=0x0100, 354 IntrTxError = 0x0008,
358 IntrRxOverflow=0x0400, IntrRxDropped=0x0800, IntrRxNoBuf=0x1000, 355 IntrRxEmpty = 0x0020,
359 IntrTxAborted=0x2000, IntrLinkChange=0x4000, 356 IntrPCIErr = 0x0040,
360 IntrRxWakeUp=0x8000, 357 IntrStatsMax = 0x0080,
361 IntrNormalSummary=0x0003, IntrAbnormalSummary=0xC260, 358 IntrRxEarly = 0x0100,
362 IntrTxDescRace=0x080000, /* mapped from IntrStatus2 */ 359 IntrTxUnderrun = 0x0210,
363 IntrTxErrSummary=0x082218, 360 IntrRxOverflow = 0x0400,
361 IntrRxDropped = 0x0800,
362 IntrRxNoBuf = 0x1000,
363 IntrTxAborted = 0x2000,
364 IntrLinkChange = 0x4000,
365 IntrRxWakeUp = 0x8000,
366 IntrTxDescRace = 0x080000, /* mapped from IntrStatus2 */
367 IntrNormalSummary = IntrRxDone | IntrTxDone,
368 IntrTxErrSummary = IntrTxDescRace | IntrTxAborted | IntrTxError |
369 IntrTxUnderrun,
364}; 370};
365 371
366/* Bits in WOLcrSet/WOLcrClr and PwrcsrSet/PwrcsrClr */ 372/* Bits in WOLcrSet/WOLcrClr and PwrcsrSet/PwrcsrClr */
@@ -439,8 +445,13 @@ struct rhine_private {
439 struct net_device *dev; 445 struct net_device *dev;
440 struct napi_struct napi; 446 struct napi_struct napi;
441 spinlock_t lock; 447 spinlock_t lock;
448 struct mutex task_lock;
449 bool task_enable;
450 struct work_struct slow_event_task;
442 struct work_struct reset_task; 451 struct work_struct reset_task;
443 452
453 u32 msg_enable;
454
444 /* Frequently used values: keep some adjacent for cache effect. */ 455 /* Frequently used values: keep some adjacent for cache effect. */
445 u32 quirks; 456 u32 quirks;
446 struct rx_desc *rx_head_desc; 457 struct rx_desc *rx_head_desc;
@@ -476,41 +487,50 @@ static int mdio_read(struct net_device *dev, int phy_id, int location);
476static void mdio_write(struct net_device *dev, int phy_id, int location, int value); 487static void mdio_write(struct net_device *dev, int phy_id, int location, int value);
477static int rhine_open(struct net_device *dev); 488static int rhine_open(struct net_device *dev);
478static void rhine_reset_task(struct work_struct *work); 489static void rhine_reset_task(struct work_struct *work);
490static void rhine_slow_event_task(struct work_struct *work);
479static void rhine_tx_timeout(struct net_device *dev); 491static void rhine_tx_timeout(struct net_device *dev);
480static netdev_tx_t rhine_start_tx(struct sk_buff *skb, 492static netdev_tx_t rhine_start_tx(struct sk_buff *skb,
481 struct net_device *dev); 493 struct net_device *dev);
482static irqreturn_t rhine_interrupt(int irq, void *dev_instance); 494static irqreturn_t rhine_interrupt(int irq, void *dev_instance);
483static void rhine_tx(struct net_device *dev); 495static void rhine_tx(struct net_device *dev);
484static int rhine_rx(struct net_device *dev, int limit); 496static int rhine_rx(struct net_device *dev, int limit);
485static void rhine_error(struct net_device *dev, int intr_status);
486static void rhine_set_rx_mode(struct net_device *dev); 497static void rhine_set_rx_mode(struct net_device *dev);
487static struct net_device_stats *rhine_get_stats(struct net_device *dev); 498static struct net_device_stats *rhine_get_stats(struct net_device *dev);
488static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 499static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
489static const struct ethtool_ops netdev_ethtool_ops; 500static const struct ethtool_ops netdev_ethtool_ops;
490static int rhine_close(struct net_device *dev); 501static int rhine_close(struct net_device *dev);
491static void rhine_shutdown (struct pci_dev *pdev);
492static int rhine_vlan_rx_add_vid(struct net_device *dev, unsigned short vid); 502static int rhine_vlan_rx_add_vid(struct net_device *dev, unsigned short vid);
493static int rhine_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid); 503static int rhine_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid);
494static void rhine_set_cam(void __iomem *ioaddr, int idx, u8 *addr); 504static void rhine_restart_tx(struct net_device *dev);
495static void rhine_set_vlan_cam(void __iomem *ioaddr, int idx, u8 *addr); 505
496static void rhine_set_cam_mask(void __iomem *ioaddr, u32 mask); 506static void rhine_wait_bit(struct rhine_private *rp, u8 reg, u8 mask, bool high)
497static void rhine_set_vlan_cam_mask(void __iomem *ioaddr, u32 mask); 507{
498static void rhine_init_cam_filter(struct net_device *dev); 508 void __iomem *ioaddr = rp->base;
499static void rhine_update_vcam(struct net_device *dev); 509 int i;
500 510
501#define RHINE_WAIT_FOR(condition) \ 511 for (i = 0; i < 1024; i++) {
502do { \ 512 if (high ^ !!(ioread8(ioaddr + reg) & mask))
503 int i = 1024; \ 513 break;
504 while (!(condition) && --i) \ 514 udelay(10);
505 ; \ 515 }
506 if (debug > 1 && i < 512) \ 516 if (i > 64) {
507 pr_info("%4d cycles used @ %s:%d\n", \ 517 netif_dbg(rp, hw, rp->dev, "%s bit wait (%02x/%02x) cycle "
508 1024 - i, __func__, __LINE__); \ 518 "count: %04d\n", high ? "high" : "low", reg, mask, i);
509} while (0) 519 }
510 520}
511static inline u32 get_intr_status(struct net_device *dev) 521
522static void rhine_wait_bit_high(struct rhine_private *rp, u8 reg, u8 mask)
523{
524 rhine_wait_bit(rp, reg, mask, true);
525}
526
527static void rhine_wait_bit_low(struct rhine_private *rp, u8 reg, u8 mask)
528{
529 rhine_wait_bit(rp, reg, mask, false);
530}
531
532static u32 rhine_get_events(struct rhine_private *rp)
512{ 533{
513 struct rhine_private *rp = netdev_priv(dev);
514 void __iomem *ioaddr = rp->base; 534 void __iomem *ioaddr = rp->base;
515 u32 intr_status; 535 u32 intr_status;
516 536
@@ -521,6 +541,16 @@ static inline u32 get_intr_status(struct net_device *dev)
521 return intr_status; 541 return intr_status;
522} 542}
523 543
544static void rhine_ack_events(struct rhine_private *rp, u32 mask)
545{
546 void __iomem *ioaddr = rp->base;
547
548 if (rp->quirks & rqStatusWBRace)
549 iowrite8(mask >> 16, ioaddr + IntrStatus2);
550 iowrite16(mask, ioaddr + IntrStatus);
551 mmiowb();
552}
553
524/* 554/*
525 * Get power related registers into sane state. 555 * Get power related registers into sane state.
526 * Notify user about past WOL event. 556 * Notify user about past WOL event.
@@ -585,6 +615,7 @@ static void rhine_chip_reset(struct net_device *dev)
585{ 615{
586 struct rhine_private *rp = netdev_priv(dev); 616 struct rhine_private *rp = netdev_priv(dev);
587 void __iomem *ioaddr = rp->base; 617 void __iomem *ioaddr = rp->base;
618 u8 cmd1;
588 619
589 iowrite8(Cmd1Reset, ioaddr + ChipCmd1); 620 iowrite8(Cmd1Reset, ioaddr + ChipCmd1);
590 IOSYNC; 621 IOSYNC;
@@ -597,13 +628,12 @@ static void rhine_chip_reset(struct net_device *dev)
597 iowrite8(0x40, ioaddr + MiscCmd); 628 iowrite8(0x40, ioaddr + MiscCmd);
598 629
599 /* Reset can take somewhat longer (rare) */ 630 /* Reset can take somewhat longer (rare) */
600 RHINE_WAIT_FOR(!(ioread8(ioaddr + ChipCmd1) & Cmd1Reset)); 631 rhine_wait_bit_low(rp, ChipCmd1, Cmd1Reset);
601 } 632 }
602 633
603 if (debug > 1) 634 cmd1 = ioread8(ioaddr + ChipCmd1);
604 netdev_info(dev, "Reset %s\n", 635 netif_info(rp, hw, dev, "Reset %s\n", (cmd1 & Cmd1Reset) ?
605 (ioread8(ioaddr + ChipCmd1) & Cmd1Reset) ? 636 "failed" : "succeeded");
606 "failed" : "succeeded");
607} 637}
608 638
609#ifdef USE_MMIO 639#ifdef USE_MMIO
@@ -629,9 +659,15 @@ static void __devinit rhine_reload_eeprom(long pioaddr, struct net_device *dev)
629{ 659{
630 struct rhine_private *rp = netdev_priv(dev); 660 struct rhine_private *rp = netdev_priv(dev);
631 void __iomem *ioaddr = rp->base; 661 void __iomem *ioaddr = rp->base;
662 int i;
632 663
633 outb(0x20, pioaddr + MACRegEEcsr); 664 outb(0x20, pioaddr + MACRegEEcsr);
634 RHINE_WAIT_FOR(!(inb(pioaddr + MACRegEEcsr) & 0x20)); 665 for (i = 0; i < 1024; i++) {
666 if (!(inb(pioaddr + MACRegEEcsr) & 0x20))
667 break;
668 }
669 if (i > 512)
670 pr_info("%4d cycles used @ %s:%d\n", i, __func__, __LINE__);
635 671
636#ifdef USE_MMIO 672#ifdef USE_MMIO
637 /* 673 /*
@@ -657,23 +693,127 @@ static void rhine_poll(struct net_device *dev)
657} 693}
658#endif 694#endif
659 695
696static void rhine_kick_tx_threshold(struct rhine_private *rp)
697{
698 if (rp->tx_thresh < 0xe0) {
699 void __iomem *ioaddr = rp->base;
700
701 rp->tx_thresh += 0x20;
702 BYTE_REG_BITS_SET(rp->tx_thresh, 0x80, ioaddr + TxConfig);
703 }
704}
705
706static void rhine_tx_err(struct rhine_private *rp, u32 status)
707{
708 struct net_device *dev = rp->dev;
709
710 if (status & IntrTxAborted) {
711 netif_info(rp, tx_err, dev,
712 "Abort %08x, frame dropped\n", status);
713 }
714
715 if (status & IntrTxUnderrun) {
716 rhine_kick_tx_threshold(rp);
717 netif_info(rp, tx_err ,dev, "Transmitter underrun, "
718 "Tx threshold now %02x\n", rp->tx_thresh);
719 }
720
721 if (status & IntrTxDescRace)
722 netif_info(rp, tx_err, dev, "Tx descriptor write-back race\n");
723
724 if ((status & IntrTxError) &&
725 (status & (IntrTxAborted | IntrTxUnderrun | IntrTxDescRace)) == 0) {
726 rhine_kick_tx_threshold(rp);
727 netif_info(rp, tx_err, dev, "Unspecified error. "
728 "Tx threshold now %02x\n", rp->tx_thresh);
729 }
730
731 rhine_restart_tx(dev);
732}
733
734static void rhine_update_rx_crc_and_missed_errord(struct rhine_private *rp)
735{
736 void __iomem *ioaddr = rp->base;
737 struct net_device_stats *stats = &rp->dev->stats;
738
739 stats->rx_crc_errors += ioread16(ioaddr + RxCRCErrs);
740 stats->rx_missed_errors += ioread16(ioaddr + RxMissed);
741
742 /*
743 * Clears the "tally counters" for CRC errors and missed frames(?).
744 * It has been reported that some chips need a write of 0 to clear
745 * these, for others the counters are set to 1 when written to and
746 * instead cleared when read. So we clear them both ways ...
747 */
748 iowrite32(0, ioaddr + RxMissed);
749 ioread16(ioaddr + RxCRCErrs);
750 ioread16(ioaddr + RxMissed);
751}
752
753#define RHINE_EVENT_NAPI_RX (IntrRxDone | \
754 IntrRxErr | \
755 IntrRxEmpty | \
756 IntrRxOverflow | \
757 IntrRxDropped | \
758 IntrRxNoBuf | \
759 IntrRxWakeUp)
760
761#define RHINE_EVENT_NAPI_TX_ERR (IntrTxError | \
762 IntrTxAborted | \
763 IntrTxUnderrun | \
764 IntrTxDescRace)
765#define RHINE_EVENT_NAPI_TX (IntrTxDone | RHINE_EVENT_NAPI_TX_ERR)
766
767#define RHINE_EVENT_NAPI (RHINE_EVENT_NAPI_RX | \
768 RHINE_EVENT_NAPI_TX | \
769 IntrStatsMax)
770#define RHINE_EVENT_SLOW (IntrPCIErr | IntrLinkChange)
771#define RHINE_EVENT (RHINE_EVENT_NAPI | RHINE_EVENT_SLOW)
772
660static int rhine_napipoll(struct napi_struct *napi, int budget) 773static int rhine_napipoll(struct napi_struct *napi, int budget)
661{ 774{
662 struct rhine_private *rp = container_of(napi, struct rhine_private, napi); 775 struct rhine_private *rp = container_of(napi, struct rhine_private, napi);
663 struct net_device *dev = rp->dev; 776 struct net_device *dev = rp->dev;
664 void __iomem *ioaddr = rp->base; 777 void __iomem *ioaddr = rp->base;
665 int work_done; 778 u16 enable_mask = RHINE_EVENT & 0xffff;
779 int work_done = 0;
780 u32 status;
781
782 status = rhine_get_events(rp);
783 rhine_ack_events(rp, status & ~RHINE_EVENT_SLOW);
784
785 if (status & RHINE_EVENT_NAPI_RX)
786 work_done += rhine_rx(dev, budget);
787
788 if (status & RHINE_EVENT_NAPI_TX) {
789 if (status & RHINE_EVENT_NAPI_TX_ERR) {
790 /* Avoid scavenging before Tx engine turned off */
791 rhine_wait_bit_low(rp, ChipCmd, CmdTxOn);
792 if (ioread8(ioaddr + ChipCmd) & CmdTxOn)
793 netif_warn(rp, tx_err, dev, "Tx still on\n");
794 }
666 795
667 work_done = rhine_rx(dev, budget); 796 rhine_tx(dev);
797
798 if (status & RHINE_EVENT_NAPI_TX_ERR)
799 rhine_tx_err(rp, status);
800 }
801
802 if (status & IntrStatsMax) {
803 spin_lock(&rp->lock);
804 rhine_update_rx_crc_and_missed_errord(rp);
805 spin_unlock(&rp->lock);
806 }
807
808 if (status & RHINE_EVENT_SLOW) {
809 enable_mask &= ~RHINE_EVENT_SLOW;
810 schedule_work(&rp->slow_event_task);
811 }
668 812
669 if (work_done < budget) { 813 if (work_done < budget) {
670 napi_complete(napi); 814 napi_complete(napi);
671 815 iowrite16(enable_mask, ioaddr + IntrEnable);
672 iowrite16(IntrRxDone | IntrRxErr | IntrRxEmpty| IntrRxOverflow | 816 mmiowb();
673 IntrRxDropped | IntrRxNoBuf | IntrTxAborted |
674 IntrTxDone | IntrTxError | IntrTxUnderrun |
675 IntrPCIErr | IntrStatsMax | IntrLinkChange,
676 ioaddr + IntrEnable);
677 } 817 }
678 return work_done; 818 return work_done;
679} 819}
@@ -797,6 +937,7 @@ static int __devinit rhine_init_one(struct pci_dev *pdev,
797 rp->quirks = quirks; 937 rp->quirks = quirks;
798 rp->pioaddr = pioaddr; 938 rp->pioaddr = pioaddr;
799 rp->pdev = pdev; 939 rp->pdev = pdev;
940 rp->msg_enable = netif_msg_init(debug, RHINE_MSG_DEFAULT);
800 941
801 rc = pci_request_regions(pdev, DRV_NAME); 942 rc = pci_request_regions(pdev, DRV_NAME);
802 if (rc) 943 if (rc)
@@ -856,7 +997,9 @@ static int __devinit rhine_init_one(struct pci_dev *pdev,
856 dev->irq = pdev->irq; 997 dev->irq = pdev->irq;
857 998
858 spin_lock_init(&rp->lock); 999 spin_lock_init(&rp->lock);
1000 mutex_init(&rp->task_lock);
859 INIT_WORK(&rp->reset_task, rhine_reset_task); 1001 INIT_WORK(&rp->reset_task, rhine_reset_task);
1002 INIT_WORK(&rp->slow_event_task, rhine_slow_event_task);
860 1003
861 rp->mii_if.dev = dev; 1004 rp->mii_if.dev = dev;
862 rp->mii_if.mdio_read = mdio_read; 1005 rp->mii_if.mdio_read = mdio_read;
@@ -916,8 +1059,8 @@ static int __devinit rhine_init_one(struct pci_dev *pdev,
916 } 1059 }
917 } 1060 }
918 rp->mii_if.phy_id = phy_id; 1061 rp->mii_if.phy_id = phy_id;
919 if (debug > 1 && avoid_D3) 1062 if (avoid_D3)
920 netdev_info(dev, "No D3 power state at shutdown\n"); 1063 netif_info(rp, probe, dev, "No D3 power state at shutdown\n");
921 1064
922 return 0; 1065 return 0;
923 1066
@@ -1093,7 +1236,7 @@ static void rhine_check_media(struct net_device *dev, unsigned int init_media)
1093 struct rhine_private *rp = netdev_priv(dev); 1236 struct rhine_private *rp = netdev_priv(dev);
1094 void __iomem *ioaddr = rp->base; 1237 void __iomem *ioaddr = rp->base;
1095 1238
1096 mii_check_media(&rp->mii_if, debug, init_media); 1239 mii_check_media(&rp->mii_if, netif_msg_link(rp), init_media);
1097 1240
1098 if (rp->mii_if.full_duplex) 1241 if (rp->mii_if.full_duplex)
1099 iowrite8(ioread8(ioaddr + ChipCmd1) | Cmd1FDuplex, 1242 iowrite8(ioread8(ioaddr + ChipCmd1) | Cmd1FDuplex,
@@ -1101,24 +1244,26 @@ static void rhine_check_media(struct net_device *dev, unsigned int init_media)
1101 else 1244 else
1102 iowrite8(ioread8(ioaddr + ChipCmd1) & ~Cmd1FDuplex, 1245 iowrite8(ioread8(ioaddr + ChipCmd1) & ~Cmd1FDuplex,
1103 ioaddr + ChipCmd1); 1246 ioaddr + ChipCmd1);
1104 if (debug > 1) 1247
1105 netdev_info(dev, "force_media %d, carrier %d\n", 1248 netif_info(rp, link, dev, "force_media %d, carrier %d\n",
1106 rp->mii_if.force_media, netif_carrier_ok(dev)); 1249 rp->mii_if.force_media, netif_carrier_ok(dev));
1107} 1250}
1108 1251
1109/* Called after status of force_media possibly changed */ 1252/* Called after status of force_media possibly changed */
1110static void rhine_set_carrier(struct mii_if_info *mii) 1253static void rhine_set_carrier(struct mii_if_info *mii)
1111{ 1254{
1255 struct net_device *dev = mii->dev;
1256 struct rhine_private *rp = netdev_priv(dev);
1257
1112 if (mii->force_media) { 1258 if (mii->force_media) {
1113 /* autoneg is off: Link is always assumed to be up */ 1259 /* autoneg is off: Link is always assumed to be up */
1114 if (!netif_carrier_ok(mii->dev)) 1260 if (!netif_carrier_ok(dev))
1115 netif_carrier_on(mii->dev); 1261 netif_carrier_on(dev);
1116 } 1262 } else /* Let MMI library update carrier status */
1117 else /* Let MMI library update carrier status */ 1263 rhine_check_media(dev, 0);
1118 rhine_check_media(mii->dev, 0); 1264
1119 if (debug > 1) 1265 netif_info(rp, link, dev, "force_media %d, carrier %d\n",
1120 netdev_info(mii->dev, "force_media %d, carrier %d\n", 1266 mii->force_media, netif_carrier_ok(dev));
1121 mii->force_media, netif_carrier_ok(mii->dev));
1122} 1267}
1123 1268
1124/** 1269/**
@@ -1266,10 +1411,10 @@ static int rhine_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
1266{ 1411{
1267 struct rhine_private *rp = netdev_priv(dev); 1412 struct rhine_private *rp = netdev_priv(dev);
1268 1413
1269 spin_lock_irq(&rp->lock); 1414 spin_lock_bh(&rp->lock);
1270 set_bit(vid, rp->active_vlans); 1415 set_bit(vid, rp->active_vlans);
1271 rhine_update_vcam(dev); 1416 rhine_update_vcam(dev);
1272 spin_unlock_irq(&rp->lock); 1417 spin_unlock_bh(&rp->lock);
1273 return 0; 1418 return 0;
1274} 1419}
1275 1420
@@ -1277,10 +1422,10 @@ static int rhine_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
1277{ 1422{
1278 struct rhine_private *rp = netdev_priv(dev); 1423 struct rhine_private *rp = netdev_priv(dev);
1279 1424
1280 spin_lock_irq(&rp->lock); 1425 spin_lock_bh(&rp->lock);
1281 clear_bit(vid, rp->active_vlans); 1426 clear_bit(vid, rp->active_vlans);
1282 rhine_update_vcam(dev); 1427 rhine_update_vcam(dev);
1283 spin_unlock_irq(&rp->lock); 1428 spin_unlock_bh(&rp->lock);
1284 return 0; 1429 return 0;
1285} 1430}
1286 1431
@@ -1310,12 +1455,7 @@ static void init_registers(struct net_device *dev)
1310 1455
1311 napi_enable(&rp->napi); 1456 napi_enable(&rp->napi);
1312 1457
1313 /* Enable interrupts by setting the interrupt mask. */ 1458 iowrite16(RHINE_EVENT & 0xffff, ioaddr + IntrEnable);
1314 iowrite16(IntrRxDone | IntrRxErr | IntrRxEmpty| IntrRxOverflow |
1315 IntrRxDropped | IntrRxNoBuf | IntrTxAborted |
1316 IntrTxDone | IntrTxError | IntrTxUnderrun |
1317 IntrPCIErr | IntrStatsMax | IntrLinkChange,
1318 ioaddr + IntrEnable);
1319 1459
1320 iowrite16(CmdStart | CmdTxOn | CmdRxOn | (Cmd1NoTxPoll << 8), 1460 iowrite16(CmdStart | CmdTxOn | CmdRxOn | (Cmd1NoTxPoll << 8),
1321 ioaddr + ChipCmd); 1461 ioaddr + ChipCmd);
@@ -1323,23 +1463,27 @@ static void init_registers(struct net_device *dev)
1323} 1463}
1324 1464
1325/* Enable MII link status auto-polling (required for IntrLinkChange) */ 1465/* Enable MII link status auto-polling (required for IntrLinkChange) */
1326static void rhine_enable_linkmon(void __iomem *ioaddr) 1466static void rhine_enable_linkmon(struct rhine_private *rp)
1327{ 1467{
1468 void __iomem *ioaddr = rp->base;
1469
1328 iowrite8(0, ioaddr + MIICmd); 1470 iowrite8(0, ioaddr + MIICmd);
1329 iowrite8(MII_BMSR, ioaddr + MIIRegAddr); 1471 iowrite8(MII_BMSR, ioaddr + MIIRegAddr);
1330 iowrite8(0x80, ioaddr + MIICmd); 1472 iowrite8(0x80, ioaddr + MIICmd);
1331 1473
1332 RHINE_WAIT_FOR((ioread8(ioaddr + MIIRegAddr) & 0x20)); 1474 rhine_wait_bit_high(rp, MIIRegAddr, 0x20);
1333 1475
1334 iowrite8(MII_BMSR | 0x40, ioaddr + MIIRegAddr); 1476 iowrite8(MII_BMSR | 0x40, ioaddr + MIIRegAddr);
1335} 1477}
1336 1478
1337/* Disable MII link status auto-polling (required for MDIO access) */ 1479/* Disable MII link status auto-polling (required for MDIO access) */
1338static void rhine_disable_linkmon(void __iomem *ioaddr, u32 quirks) 1480static void rhine_disable_linkmon(struct rhine_private *rp)
1339{ 1481{
1482 void __iomem *ioaddr = rp->base;
1483
1340 iowrite8(0, ioaddr + MIICmd); 1484 iowrite8(0, ioaddr + MIICmd);
1341 1485
1342 if (quirks & rqRhineI) { 1486 if (rp->quirks & rqRhineI) {
1343 iowrite8(0x01, ioaddr + MIIRegAddr); // MII_BMSR 1487 iowrite8(0x01, ioaddr + MIIRegAddr); // MII_BMSR
1344 1488
1345 /* Can be called from ISR. Evil. */ 1489 /* Can be called from ISR. Evil. */
@@ -1348,13 +1492,13 @@ static void rhine_disable_linkmon(void __iomem *ioaddr, u32 quirks)
1348 /* 0x80 must be set immediately before turning it off */ 1492 /* 0x80 must be set immediately before turning it off */
1349 iowrite8(0x80, ioaddr + MIICmd); 1493 iowrite8(0x80, ioaddr + MIICmd);
1350 1494
1351 RHINE_WAIT_FOR(ioread8(ioaddr + MIIRegAddr) & 0x20); 1495 rhine_wait_bit_high(rp, MIIRegAddr, 0x20);
1352 1496
1353 /* Heh. Now clear 0x80 again. */ 1497 /* Heh. Now clear 0x80 again. */
1354 iowrite8(0, ioaddr + MIICmd); 1498 iowrite8(0, ioaddr + MIICmd);
1355 } 1499 }
1356 else 1500 else
1357 RHINE_WAIT_FOR(ioread8(ioaddr + MIIRegAddr) & 0x80); 1501 rhine_wait_bit_high(rp, MIIRegAddr, 0x80);
1358} 1502}
1359 1503
1360/* Read and write over the MII Management Data I/O (MDIO) interface. */ 1504/* Read and write over the MII Management Data I/O (MDIO) interface. */
@@ -1365,16 +1509,16 @@ static int mdio_read(struct net_device *dev, int phy_id, int regnum)
1365 void __iomem *ioaddr = rp->base; 1509 void __iomem *ioaddr = rp->base;
1366 int result; 1510 int result;
1367 1511
1368 rhine_disable_linkmon(ioaddr, rp->quirks); 1512 rhine_disable_linkmon(rp);
1369 1513
1370 /* rhine_disable_linkmon already cleared MIICmd */ 1514 /* rhine_disable_linkmon already cleared MIICmd */
1371 iowrite8(phy_id, ioaddr + MIIPhyAddr); 1515 iowrite8(phy_id, ioaddr + MIIPhyAddr);
1372 iowrite8(regnum, ioaddr + MIIRegAddr); 1516 iowrite8(regnum, ioaddr + MIIRegAddr);
1373 iowrite8(0x40, ioaddr + MIICmd); /* Trigger read */ 1517 iowrite8(0x40, ioaddr + MIICmd); /* Trigger read */
1374 RHINE_WAIT_FOR(!(ioread8(ioaddr + MIICmd) & 0x40)); 1518 rhine_wait_bit_low(rp, MIICmd, 0x40);
1375 result = ioread16(ioaddr + MIIData); 1519 result = ioread16(ioaddr + MIIData);
1376 1520
1377 rhine_enable_linkmon(ioaddr); 1521 rhine_enable_linkmon(rp);
1378 return result; 1522 return result;
1379} 1523}
1380 1524
@@ -1383,16 +1527,33 @@ static void mdio_write(struct net_device *dev, int phy_id, int regnum, int value
1383 struct rhine_private *rp = netdev_priv(dev); 1527 struct rhine_private *rp = netdev_priv(dev);
1384 void __iomem *ioaddr = rp->base; 1528 void __iomem *ioaddr = rp->base;
1385 1529
1386 rhine_disable_linkmon(ioaddr, rp->quirks); 1530 rhine_disable_linkmon(rp);
1387 1531
1388 /* rhine_disable_linkmon already cleared MIICmd */ 1532 /* rhine_disable_linkmon already cleared MIICmd */
1389 iowrite8(phy_id, ioaddr + MIIPhyAddr); 1533 iowrite8(phy_id, ioaddr + MIIPhyAddr);
1390 iowrite8(regnum, ioaddr + MIIRegAddr); 1534 iowrite8(regnum, ioaddr + MIIRegAddr);
1391 iowrite16(value, ioaddr + MIIData); 1535 iowrite16(value, ioaddr + MIIData);
1392 iowrite8(0x20, ioaddr + MIICmd); /* Trigger write */ 1536 iowrite8(0x20, ioaddr + MIICmd); /* Trigger write */
1393 RHINE_WAIT_FOR(!(ioread8(ioaddr + MIICmd) & 0x20)); 1537 rhine_wait_bit_low(rp, MIICmd, 0x20);
1394 1538
1395 rhine_enable_linkmon(ioaddr); 1539 rhine_enable_linkmon(rp);
1540}
1541
1542static void rhine_task_disable(struct rhine_private *rp)
1543{
1544 mutex_lock(&rp->task_lock);
1545 rp->task_enable = false;
1546 mutex_unlock(&rp->task_lock);
1547
1548 cancel_work_sync(&rp->slow_event_task);
1549 cancel_work_sync(&rp->reset_task);
1550}
1551
1552static void rhine_task_enable(struct rhine_private *rp)
1553{
1554 mutex_lock(&rp->task_lock);
1555 rp->task_enable = true;
1556 mutex_unlock(&rp->task_lock);
1396} 1557}
1397 1558
1398static int rhine_open(struct net_device *dev) 1559static int rhine_open(struct net_device *dev)
@@ -1406,8 +1567,7 @@ static int rhine_open(struct net_device *dev)
1406 if (rc) 1567 if (rc)
1407 return rc; 1568 return rc;
1408 1569
1409 if (debug > 1) 1570 netif_dbg(rp, ifup, dev, "%s() irq %d\n", __func__, rp->pdev->irq);
1410 netdev_dbg(dev, "%s() irq %d\n", __func__, rp->pdev->irq);
1411 1571
1412 rc = alloc_ring(dev); 1572 rc = alloc_ring(dev);
1413 if (rc) { 1573 if (rc) {
@@ -1417,11 +1577,12 @@ static int rhine_open(struct net_device *dev)
1417 alloc_rbufs(dev); 1577 alloc_rbufs(dev);
1418 alloc_tbufs(dev); 1578 alloc_tbufs(dev);
1419 rhine_chip_reset(dev); 1579 rhine_chip_reset(dev);
1580 rhine_task_enable(rp);
1420 init_registers(dev); 1581 init_registers(dev);
1421 if (debug > 2) 1582
1422 netdev_dbg(dev, "%s() Done - status %04x MII status: %04x\n", 1583 netif_dbg(rp, ifup, dev, "%s() Done - status %04x MII status: %04x\n",
1423 __func__, ioread16(ioaddr + ChipCmd), 1584 __func__, ioread16(ioaddr + ChipCmd),
1424 mdio_read(dev, rp->mii_if.phy_id, MII_BMSR)); 1585 mdio_read(dev, rp->mii_if.phy_id, MII_BMSR));
1425 1586
1426 netif_start_queue(dev); 1587 netif_start_queue(dev);
1427 1588
@@ -1434,11 +1595,12 @@ static void rhine_reset_task(struct work_struct *work)
1434 reset_task); 1595 reset_task);
1435 struct net_device *dev = rp->dev; 1596 struct net_device *dev = rp->dev;
1436 1597
1437 /* protect against concurrent rx interrupts */ 1598 mutex_lock(&rp->task_lock);
1438 disable_irq(rp->pdev->irq);
1439 1599
1440 napi_disable(&rp->napi); 1600 if (!rp->task_enable)
1601 goto out_unlock;
1441 1602
1603 napi_disable(&rp->napi);
1442 spin_lock_bh(&rp->lock); 1604 spin_lock_bh(&rp->lock);
1443 1605
1444 /* clear all descriptors */ 1606 /* clear all descriptors */
@@ -1452,11 +1614,13 @@ static void rhine_reset_task(struct work_struct *work)
1452 init_registers(dev); 1614 init_registers(dev);
1453 1615
1454 spin_unlock_bh(&rp->lock); 1616 spin_unlock_bh(&rp->lock);
1455 enable_irq(rp->pdev->irq);
1456 1617
1457 dev->trans_start = jiffies; /* prevent tx timeout */ 1618 dev->trans_start = jiffies; /* prevent tx timeout */
1458 dev->stats.tx_errors++; 1619 dev->stats.tx_errors++;
1459 netif_wake_queue(dev); 1620 netif_wake_queue(dev);
1621
1622out_unlock:
1623 mutex_unlock(&rp->task_lock);
1460} 1624}
1461 1625
1462static void rhine_tx_timeout(struct net_device *dev) 1626static void rhine_tx_timeout(struct net_device *dev)
@@ -1477,7 +1641,6 @@ static netdev_tx_t rhine_start_tx(struct sk_buff *skb,
1477 struct rhine_private *rp = netdev_priv(dev); 1641 struct rhine_private *rp = netdev_priv(dev);
1478 void __iomem *ioaddr = rp->base; 1642 void __iomem *ioaddr = rp->base;
1479 unsigned entry; 1643 unsigned entry;
1480 unsigned long flags;
1481 1644
1482 /* Caution: the write order is important here, set the field 1645 /* Caution: the write order is important here, set the field
1483 with the "ownership" bits last. */ 1646 with the "ownership" bits last. */
@@ -1529,7 +1692,6 @@ static netdev_tx_t rhine_start_tx(struct sk_buff *skb,
1529 rp->tx_ring[entry].tx_status = 0; 1692 rp->tx_ring[entry].tx_status = 0;
1530 1693
1531 /* lock eth irq */ 1694 /* lock eth irq */
1532 spin_lock_irqsave(&rp->lock, flags);
1533 wmb(); 1695 wmb();
1534 rp->tx_ring[entry].tx_status |= cpu_to_le32(DescOwn); 1696 rp->tx_ring[entry].tx_status |= cpu_to_le32(DescOwn);
1535 wmb(); 1697 wmb();
@@ -1550,78 +1712,43 @@ static netdev_tx_t rhine_start_tx(struct sk_buff *skb,
1550 if (rp->cur_tx == rp->dirty_tx + TX_QUEUE_LEN) 1712 if (rp->cur_tx == rp->dirty_tx + TX_QUEUE_LEN)
1551 netif_stop_queue(dev); 1713 netif_stop_queue(dev);
1552 1714
1553 spin_unlock_irqrestore(&rp->lock, flags); 1715 netif_dbg(rp, tx_queued, dev, "Transmit frame #%d queued in slot %d\n",
1716 rp->cur_tx - 1, entry);
1554 1717
1555 if (debug > 4) {
1556 netdev_dbg(dev, "Transmit frame #%d queued in slot %d\n",
1557 rp->cur_tx-1, entry);
1558 }
1559 return NETDEV_TX_OK; 1718 return NETDEV_TX_OK;
1560} 1719}
1561 1720
1721static void rhine_irq_disable(struct rhine_private *rp)
1722{
1723 iowrite16(0x0000, rp->base + IntrEnable);
1724 mmiowb();
1725}
1726
1562/* The interrupt handler does all of the Rx thread work and cleans up 1727/* The interrupt handler does all of the Rx thread work and cleans up
1563 after the Tx thread. */ 1728 after the Tx thread. */
1564static irqreturn_t rhine_interrupt(int irq, void *dev_instance) 1729static irqreturn_t rhine_interrupt(int irq, void *dev_instance)
1565{ 1730{
1566 struct net_device *dev = dev_instance; 1731 struct net_device *dev = dev_instance;
1567 struct rhine_private *rp = netdev_priv(dev); 1732 struct rhine_private *rp = netdev_priv(dev);
1568 void __iomem *ioaddr = rp->base; 1733 u32 status;
1569 u32 intr_status;
1570 int boguscnt = max_interrupt_work;
1571 int handled = 0; 1734 int handled = 0;
1572 1735
1573 while ((intr_status = get_intr_status(dev))) { 1736 status = rhine_get_events(rp);
1574 handled = 1;
1575
1576 /* Acknowledge all of the current interrupt sources ASAP. */
1577 if (intr_status & IntrTxDescRace)
1578 iowrite8(0x08, ioaddr + IntrStatus2);
1579 iowrite16(intr_status & 0xffff, ioaddr + IntrStatus);
1580 IOSYNC;
1581 1737
1582 if (debug > 4) 1738 netif_dbg(rp, intr, dev, "Interrupt, status %08x\n", status);
1583 netdev_dbg(dev, "Interrupt, status %08x\n",
1584 intr_status);
1585
1586 if (intr_status & (IntrRxDone | IntrRxErr | IntrRxDropped |
1587 IntrRxWakeUp | IntrRxEmpty | IntrRxNoBuf)) {
1588 iowrite16(IntrTxAborted |
1589 IntrTxDone | IntrTxError | IntrTxUnderrun |
1590 IntrPCIErr | IntrStatsMax | IntrLinkChange,
1591 ioaddr + IntrEnable);
1592
1593 napi_schedule(&rp->napi);
1594 }
1595 1739
1596 if (intr_status & (IntrTxErrSummary | IntrTxDone)) { 1740 if (status & RHINE_EVENT) {
1597 if (intr_status & IntrTxErrSummary) { 1741 handled = 1;
1598 /* Avoid scavenging before Tx engine turned off */
1599 RHINE_WAIT_FOR(!(ioread8(ioaddr+ChipCmd) & CmdTxOn));
1600 if (debug > 2 &&
1601 ioread8(ioaddr+ChipCmd) & CmdTxOn)
1602 netdev_warn(dev,
1603 "%s: Tx engine still on\n",
1604 __func__);
1605 }
1606 rhine_tx(dev);
1607 }
1608 1742
1609 /* Abnormal error summary/uncommon events handlers. */ 1743 rhine_irq_disable(rp);
1610 if (intr_status & (IntrPCIErr | IntrLinkChange | 1744 napi_schedule(&rp->napi);
1611 IntrStatsMax | IntrTxError | IntrTxAborted | 1745 }
1612 IntrTxUnderrun | IntrTxDescRace))
1613 rhine_error(dev, intr_status);
1614 1746
1615 if (--boguscnt < 0) { 1747 if (status & ~(IntrLinkChange | IntrStatsMax | RHINE_EVENT_NAPI)) {
1616 netdev_warn(dev, "Too much work at interrupt, status=%#08x\n", 1748 netif_err(rp, intr, dev, "Something Wicked happened! %08x\n",
1617 intr_status); 1749 status);
1618 break;
1619 }
1620 } 1750 }
1621 1751
1622 if (debug > 3)
1623 netdev_dbg(dev, "exiting interrupt, status=%08x\n",
1624 ioread16(ioaddr + IntrStatus));
1625 return IRQ_RETVAL(handled); 1752 return IRQ_RETVAL(handled);
1626} 1753}
1627 1754
@@ -1632,20 +1759,16 @@ static void rhine_tx(struct net_device *dev)
1632 struct rhine_private *rp = netdev_priv(dev); 1759 struct rhine_private *rp = netdev_priv(dev);
1633 int txstatus = 0, entry = rp->dirty_tx % TX_RING_SIZE; 1760 int txstatus = 0, entry = rp->dirty_tx % TX_RING_SIZE;
1634 1761
1635 spin_lock(&rp->lock);
1636
1637 /* find and cleanup dirty tx descriptors */ 1762 /* find and cleanup dirty tx descriptors */
1638 while (rp->dirty_tx != rp->cur_tx) { 1763 while (rp->dirty_tx != rp->cur_tx) {
1639 txstatus = le32_to_cpu(rp->tx_ring[entry].tx_status); 1764 txstatus = le32_to_cpu(rp->tx_ring[entry].tx_status);
1640 if (debug > 6) 1765 netif_dbg(rp, tx_done, dev, "Tx scavenge %d status %08x\n",
1641 netdev_dbg(dev, "Tx scavenge %d status %08x\n", 1766 entry, txstatus);
1642 entry, txstatus);
1643 if (txstatus & DescOwn) 1767 if (txstatus & DescOwn)
1644 break; 1768 break;
1645 if (txstatus & 0x8000) { 1769 if (txstatus & 0x8000) {
1646 if (debug > 1) 1770 netif_dbg(rp, tx_done, dev,
1647 netdev_dbg(dev, "Transmit error, Tx status %08x\n", 1771 "Transmit error, Tx status %08x\n", txstatus);
1648 txstatus);
1649 dev->stats.tx_errors++; 1772 dev->stats.tx_errors++;
1650 if (txstatus & 0x0400) 1773 if (txstatus & 0x0400)
1651 dev->stats.tx_carrier_errors++; 1774 dev->stats.tx_carrier_errors++;
@@ -1667,10 +1790,8 @@ static void rhine_tx(struct net_device *dev)
1667 dev->stats.collisions += (txstatus >> 3) & 0x0F; 1790 dev->stats.collisions += (txstatus >> 3) & 0x0F;
1668 else 1791 else
1669 dev->stats.collisions += txstatus & 0x0F; 1792 dev->stats.collisions += txstatus & 0x0F;
1670 if (debug > 6) 1793 netif_dbg(rp, tx_done, dev, "collisions: %1.1x:%1.1x\n",
1671 netdev_dbg(dev, "collisions: %1.1x:%1.1x\n", 1794 (txstatus >> 3) & 0xF, txstatus & 0xF);
1672 (txstatus >> 3) & 0xF,
1673 txstatus & 0xF);
1674 dev->stats.tx_bytes += rp->tx_skbuff[entry]->len; 1795 dev->stats.tx_bytes += rp->tx_skbuff[entry]->len;
1675 dev->stats.tx_packets++; 1796 dev->stats.tx_packets++;
1676 } 1797 }
@@ -1687,8 +1808,6 @@ static void rhine_tx(struct net_device *dev)
1687 } 1808 }
1688 if ((rp->cur_tx - rp->dirty_tx) < TX_QUEUE_LEN - 4) 1809 if ((rp->cur_tx - rp->dirty_tx) < TX_QUEUE_LEN - 4)
1689 netif_wake_queue(dev); 1810 netif_wake_queue(dev);
1690
1691 spin_unlock(&rp->lock);
1692} 1811}
1693 1812
1694/** 1813/**
@@ -1713,11 +1832,8 @@ static int rhine_rx(struct net_device *dev, int limit)
1713 int count; 1832 int count;
1714 int entry = rp->cur_rx % RX_RING_SIZE; 1833 int entry = rp->cur_rx % RX_RING_SIZE;
1715 1834
1716 if (debug > 4) { 1835 netif_dbg(rp, rx_status, dev, "%s(), entry %d status %08x\n", __func__,
1717 netdev_dbg(dev, "%s(), entry %d status %08x\n", 1836 entry, le32_to_cpu(rp->rx_head_desc->rx_status));
1718 __func__, entry,
1719 le32_to_cpu(rp->rx_head_desc->rx_status));
1720 }
1721 1837
1722 /* If EOP is set on the next entry, it's a new packet. Send it up. */ 1838 /* If EOP is set on the next entry, it's a new packet. Send it up. */
1723 for (count = 0; count < limit; ++count) { 1839 for (count = 0; count < limit; ++count) {
@@ -1729,9 +1845,8 @@ static int rhine_rx(struct net_device *dev, int limit)
1729 if (desc_status & DescOwn) 1845 if (desc_status & DescOwn)
1730 break; 1846 break;
1731 1847
1732 if (debug > 4) 1848 netif_dbg(rp, rx_status, dev, "%s() status %08x\n", __func__,
1733 netdev_dbg(dev, "%s() status is %08x\n", 1849 desc_status);
1734 __func__, desc_status);
1735 1850
1736 if ((desc_status & (RxWholePkt | RxErr)) != RxWholePkt) { 1851 if ((desc_status & (RxWholePkt | RxErr)) != RxWholePkt) {
1737 if ((desc_status & RxWholePkt) != RxWholePkt) { 1852 if ((desc_status & RxWholePkt) != RxWholePkt) {
@@ -1747,9 +1862,9 @@ static int rhine_rx(struct net_device *dev, int limit)
1747 dev->stats.rx_length_errors++; 1862 dev->stats.rx_length_errors++;
1748 } else if (desc_status & RxErr) { 1863 } else if (desc_status & RxErr) {
1749 /* There was a error. */ 1864 /* There was a error. */
1750 if (debug > 2) 1865 netif_dbg(rp, rx_err, dev,
1751 netdev_dbg(dev, "%s() Rx error was %08x\n", 1866 "%s() Rx error %08x\n", __func__,
1752 __func__, desc_status); 1867 desc_status);
1753 dev->stats.rx_errors++; 1868 dev->stats.rx_errors++;
1754 if (desc_status & 0x0030) 1869 if (desc_status & 0x0030)
1755 dev->stats.rx_length_errors++; 1870 dev->stats.rx_length_errors++;
@@ -1839,19 +1954,6 @@ static int rhine_rx(struct net_device *dev, int limit)
1839 return count; 1954 return count;
1840} 1955}
1841 1956
1842/*
1843 * Clears the "tally counters" for CRC errors and missed frames(?).
1844 * It has been reported that some chips need a write of 0 to clear
1845 * these, for others the counters are set to 1 when written to and
1846 * instead cleared when read. So we clear them both ways ...
1847 */
1848static inline void clear_tally_counters(void __iomem *ioaddr)
1849{
1850 iowrite32(0, ioaddr + RxMissed);
1851 ioread16(ioaddr + RxCRCErrs);
1852 ioread16(ioaddr + RxMissed);
1853}
1854
1855static void rhine_restart_tx(struct net_device *dev) { 1957static void rhine_restart_tx(struct net_device *dev) {
1856 struct rhine_private *rp = netdev_priv(dev); 1958 struct rhine_private *rp = netdev_priv(dev);
1857 void __iomem *ioaddr = rp->base; 1959 void __iomem *ioaddr = rp->base;
@@ -1862,7 +1964,7 @@ static void rhine_restart_tx(struct net_device *dev) {
1862 * If new errors occurred, we need to sort them out before doing Tx. 1964 * If new errors occurred, we need to sort them out before doing Tx.
1863 * In that case the ISR will be back here RSN anyway. 1965 * In that case the ISR will be back here RSN anyway.
1864 */ 1966 */
1865 intr_status = get_intr_status(dev); 1967 intr_status = rhine_get_events(rp);
1866 1968
1867 if ((intr_status & IntrTxErrSummary) == 0) { 1969 if ((intr_status & IntrTxErrSummary) == 0) {
1868 1970
@@ -1883,79 +1985,50 @@ static void rhine_restart_tx(struct net_device *dev) {
1883 } 1985 }
1884 else { 1986 else {
1885 /* This should never happen */ 1987 /* This should never happen */
1886 if (debug > 1) 1988 netif_warn(rp, tx_err, dev, "another error occurred %08x\n",
1887 netdev_warn(dev, "%s() Another error occurred %08x\n", 1989 intr_status);
1888 __func__, intr_status);
1889 } 1990 }
1890 1991
1891} 1992}
1892 1993
1893static void rhine_error(struct net_device *dev, int intr_status) 1994static void rhine_slow_event_task(struct work_struct *work)
1894{ 1995{
1895 struct rhine_private *rp = netdev_priv(dev); 1996 struct rhine_private *rp =
1896 void __iomem *ioaddr = rp->base; 1997 container_of(work, struct rhine_private, slow_event_task);
1998 struct net_device *dev = rp->dev;
1999 u32 intr_status;
1897 2000
1898 spin_lock(&rp->lock); 2001 mutex_lock(&rp->task_lock);
2002
2003 if (!rp->task_enable)
2004 goto out_unlock;
2005
2006 intr_status = rhine_get_events(rp);
2007 rhine_ack_events(rp, intr_status & RHINE_EVENT_SLOW);
1899 2008
1900 if (intr_status & IntrLinkChange) 2009 if (intr_status & IntrLinkChange)
1901 rhine_check_media(dev, 0); 2010 rhine_check_media(dev, 0);
1902 if (intr_status & IntrStatsMax) {
1903 dev->stats.rx_crc_errors += ioread16(ioaddr + RxCRCErrs);
1904 dev->stats.rx_missed_errors += ioread16(ioaddr + RxMissed);
1905 clear_tally_counters(ioaddr);
1906 }
1907 if (intr_status & IntrTxAborted) {
1908 if (debug > 1)
1909 netdev_info(dev, "Abort %08x, frame dropped\n",
1910 intr_status);
1911 }
1912 if (intr_status & IntrTxUnderrun) {
1913 if (rp->tx_thresh < 0xE0)
1914 BYTE_REG_BITS_SET((rp->tx_thresh += 0x20), 0x80, ioaddr + TxConfig);
1915 if (debug > 1)
1916 netdev_info(dev, "Transmitter underrun, Tx threshold now %02x\n",
1917 rp->tx_thresh);
1918 }
1919 if (intr_status & IntrTxDescRace) {
1920 if (debug > 2)
1921 netdev_info(dev, "Tx descriptor write-back race\n");
1922 }
1923 if ((intr_status & IntrTxError) &&
1924 (intr_status & (IntrTxAborted |
1925 IntrTxUnderrun | IntrTxDescRace)) == 0) {
1926 if (rp->tx_thresh < 0xE0) {
1927 BYTE_REG_BITS_SET((rp->tx_thresh += 0x20), 0x80, ioaddr + TxConfig);
1928 }
1929 if (debug > 1)
1930 netdev_info(dev, "Unspecified error. Tx threshold now %02x\n",
1931 rp->tx_thresh);
1932 }
1933 if (intr_status & (IntrTxAborted | IntrTxUnderrun | IntrTxDescRace |
1934 IntrTxError))
1935 rhine_restart_tx(dev);
1936
1937 if (intr_status & ~(IntrLinkChange | IntrStatsMax | IntrTxUnderrun |
1938 IntrTxError | IntrTxAborted | IntrNormalSummary |
1939 IntrTxDescRace)) {
1940 if (debug > 1)
1941 netdev_err(dev, "Something Wicked happened! %08x\n",
1942 intr_status);
1943 }
1944 2011
1945 spin_unlock(&rp->lock); 2012 if (intr_status & IntrPCIErr)
2013 netif_warn(rp, hw, dev, "PCI error\n");
2014
2015 napi_disable(&rp->napi);
2016 rhine_irq_disable(rp);
2017 /* Slow and safe. Consider __napi_schedule as a replacement ? */
2018 napi_enable(&rp->napi);
2019 napi_schedule(&rp->napi);
2020
2021out_unlock:
2022 mutex_unlock(&rp->task_lock);
1946} 2023}
1947 2024
1948static struct net_device_stats *rhine_get_stats(struct net_device *dev) 2025static struct net_device_stats *rhine_get_stats(struct net_device *dev)
1949{ 2026{
1950 struct rhine_private *rp = netdev_priv(dev); 2027 struct rhine_private *rp = netdev_priv(dev);
1951 void __iomem *ioaddr = rp->base;
1952 unsigned long flags;
1953 2028
1954 spin_lock_irqsave(&rp->lock, flags); 2029 spin_lock_bh(&rp->lock);
1955 dev->stats.rx_crc_errors += ioread16(ioaddr + RxCRCErrs); 2030 rhine_update_rx_crc_and_missed_errord(rp);
1956 dev->stats.rx_missed_errors += ioread16(ioaddr + RxMissed); 2031 spin_unlock_bh(&rp->lock);
1957 clear_tally_counters(ioaddr);
1958 spin_unlock_irqrestore(&rp->lock, flags);
1959 2032
1960 return &dev->stats; 2033 return &dev->stats;
1961} 2034}
@@ -2022,9 +2095,9 @@ static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2022 struct rhine_private *rp = netdev_priv(dev); 2095 struct rhine_private *rp = netdev_priv(dev);
2023 int rc; 2096 int rc;
2024 2097
2025 spin_lock_irq(&rp->lock); 2098 mutex_lock(&rp->task_lock);
2026 rc = mii_ethtool_gset(&rp->mii_if, cmd); 2099 rc = mii_ethtool_gset(&rp->mii_if, cmd);
2027 spin_unlock_irq(&rp->lock); 2100 mutex_unlock(&rp->task_lock);
2028 2101
2029 return rc; 2102 return rc;
2030} 2103}
@@ -2034,10 +2107,10 @@ static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2034 struct rhine_private *rp = netdev_priv(dev); 2107 struct rhine_private *rp = netdev_priv(dev);
2035 int rc; 2108 int rc;
2036 2109
2037 spin_lock_irq(&rp->lock); 2110 mutex_lock(&rp->task_lock);
2038 rc = mii_ethtool_sset(&rp->mii_if, cmd); 2111 rc = mii_ethtool_sset(&rp->mii_if, cmd);
2039 spin_unlock_irq(&rp->lock);
2040 rhine_set_carrier(&rp->mii_if); 2112 rhine_set_carrier(&rp->mii_if);
2113 mutex_unlock(&rp->task_lock);
2041 2114
2042 return rc; 2115 return rc;
2043} 2116}
@@ -2058,12 +2131,16 @@ static u32 netdev_get_link(struct net_device *dev)
2058 2131
2059static u32 netdev_get_msglevel(struct net_device *dev) 2132static u32 netdev_get_msglevel(struct net_device *dev)
2060{ 2133{
2061 return debug; 2134 struct rhine_private *rp = netdev_priv(dev);
2135
2136 return rp->msg_enable;
2062} 2137}
2063 2138
2064static void netdev_set_msglevel(struct net_device *dev, u32 value) 2139static void netdev_set_msglevel(struct net_device *dev, u32 value)
2065{ 2140{
2066 debug = value; 2141 struct rhine_private *rp = netdev_priv(dev);
2142
2143 rp->msg_enable = value;
2067} 2144}
2068 2145
2069static void rhine_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 2146static void rhine_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
@@ -2119,10 +2196,10 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2119 if (!netif_running(dev)) 2196 if (!netif_running(dev))
2120 return -EINVAL; 2197 return -EINVAL;
2121 2198
2122 spin_lock_irq(&rp->lock); 2199 mutex_lock(&rp->task_lock);
2123 rc = generic_mii_ioctl(&rp->mii_if, if_mii(rq), cmd, NULL); 2200 rc = generic_mii_ioctl(&rp->mii_if, if_mii(rq), cmd, NULL);
2124 spin_unlock_irq(&rp->lock);
2125 rhine_set_carrier(&rp->mii_if); 2201 rhine_set_carrier(&rp->mii_if);
2202 mutex_unlock(&rp->task_lock);
2126 2203
2127 return rc; 2204 return rc;
2128} 2205}
@@ -2132,27 +2209,21 @@ static int rhine_close(struct net_device *dev)
2132 struct rhine_private *rp = netdev_priv(dev); 2209 struct rhine_private *rp = netdev_priv(dev);
2133 void __iomem *ioaddr = rp->base; 2210 void __iomem *ioaddr = rp->base;
2134 2211
2212 rhine_task_disable(rp);
2135 napi_disable(&rp->napi); 2213 napi_disable(&rp->napi);
2136 cancel_work_sync(&rp->reset_task);
2137 netif_stop_queue(dev); 2214 netif_stop_queue(dev);
2138 2215
2139 spin_lock_irq(&rp->lock); 2216 netif_dbg(rp, ifdown, dev, "Shutting down ethercard, status was %04x\n",
2140 2217 ioread16(ioaddr + ChipCmd));
2141 if (debug > 1)
2142 netdev_dbg(dev, "Shutting down ethercard, status was %04x\n",
2143 ioread16(ioaddr + ChipCmd));
2144 2218
2145 /* Switch to loopback mode to avoid hardware races. */ 2219 /* Switch to loopback mode to avoid hardware races. */
2146 iowrite8(rp->tx_thresh | 0x02, ioaddr + TxConfig); 2220 iowrite8(rp->tx_thresh | 0x02, ioaddr + TxConfig);
2147 2221
2148 /* Disable interrupts by clearing the interrupt mask. */ 2222 rhine_irq_disable(rp);
2149 iowrite16(0x0000, ioaddr + IntrEnable);
2150 2223
2151 /* Stop the chip's Tx and Rx processes. */ 2224 /* Stop the chip's Tx and Rx processes. */
2152 iowrite16(CmdStop, ioaddr + ChipCmd); 2225 iowrite16(CmdStop, ioaddr + ChipCmd);
2153 2226
2154 spin_unlock_irq(&rp->lock);
2155
2156 free_irq(rp->pdev->irq, dev); 2227 free_irq(rp->pdev->irq, dev);
2157 free_rbufs(dev); 2228 free_rbufs(dev);
2158 free_tbufs(dev); 2229 free_tbufs(dev);
@@ -2192,6 +2263,8 @@ static void rhine_shutdown (struct pci_dev *pdev)
2192 if (rp->quirks & rq6patterns) 2263 if (rp->quirks & rq6patterns)
2193 iowrite8(0x04, ioaddr + WOLcgClr); 2264 iowrite8(0x04, ioaddr + WOLcgClr);
2194 2265
2266 spin_lock(&rp->lock);
2267
2195 if (rp->wolopts & WAKE_MAGIC) { 2268 if (rp->wolopts & WAKE_MAGIC) {
2196 iowrite8(WOLmagic, ioaddr + WOLcrSet); 2269 iowrite8(WOLmagic, ioaddr + WOLcrSet);
2197 /* 2270 /*
@@ -2216,58 +2289,46 @@ static void rhine_shutdown (struct pci_dev *pdev)
2216 iowrite8(ioread8(ioaddr + StickyHW) | 0x04, ioaddr + StickyHW); 2289 iowrite8(ioread8(ioaddr + StickyHW) | 0x04, ioaddr + StickyHW);
2217 } 2290 }
2218 2291
2219 /* Hit power state D3 (sleep) */ 2292 spin_unlock(&rp->lock);
2220 if (!avoid_D3)
2221 iowrite8(ioread8(ioaddr + StickyHW) | 0x03, ioaddr + StickyHW);
2222 2293
2223 /* TODO: Check use of pci_enable_wake() */ 2294 if (system_state == SYSTEM_POWER_OFF && !avoid_D3) {
2295 iowrite8(ioread8(ioaddr + StickyHW) | 0x03, ioaddr + StickyHW);
2224 2296
2297 pci_wake_from_d3(pdev, true);
2298 pci_set_power_state(pdev, PCI_D3hot);
2299 }
2225} 2300}
2226 2301
2227#ifdef CONFIG_PM 2302#ifdef CONFIG_PM_SLEEP
2228static int rhine_suspend(struct pci_dev *pdev, pm_message_t state) 2303static int rhine_suspend(struct device *device)
2229{ 2304{
2305 struct pci_dev *pdev = to_pci_dev(device);
2230 struct net_device *dev = pci_get_drvdata(pdev); 2306 struct net_device *dev = pci_get_drvdata(pdev);
2231 struct rhine_private *rp = netdev_priv(dev); 2307 struct rhine_private *rp = netdev_priv(dev);
2232 unsigned long flags;
2233 2308
2234 if (!netif_running(dev)) 2309 if (!netif_running(dev))
2235 return 0; 2310 return 0;
2236 2311
2312 rhine_task_disable(rp);
2313 rhine_irq_disable(rp);
2237 napi_disable(&rp->napi); 2314 napi_disable(&rp->napi);
2238 2315
2239 netif_device_detach(dev); 2316 netif_device_detach(dev);
2240 pci_save_state(pdev);
2241 2317
2242 spin_lock_irqsave(&rp->lock, flags);
2243 rhine_shutdown(pdev); 2318 rhine_shutdown(pdev);
2244 spin_unlock_irqrestore(&rp->lock, flags);
2245 2319
2246 free_irq(dev->irq, dev);
2247 return 0; 2320 return 0;
2248} 2321}
2249 2322
2250static int rhine_resume(struct pci_dev *pdev) 2323static int rhine_resume(struct device *device)
2251{ 2324{
2325 struct pci_dev *pdev = to_pci_dev(device);
2252 struct net_device *dev = pci_get_drvdata(pdev); 2326 struct net_device *dev = pci_get_drvdata(pdev);
2253 struct rhine_private *rp = netdev_priv(dev); 2327 struct rhine_private *rp = netdev_priv(dev);
2254 unsigned long flags;
2255 int ret;
2256 2328
2257 if (!netif_running(dev)) 2329 if (!netif_running(dev))
2258 return 0; 2330 return 0;
2259 2331
2260 if (request_irq(dev->irq, rhine_interrupt, IRQF_SHARED, dev->name, dev))
2261 netdev_err(dev, "request_irq failed\n");
2262
2263 ret = pci_set_power_state(pdev, PCI_D0);
2264 if (debug > 1)
2265 netdev_info(dev, "Entering power state D0 %s (%d)\n",
2266 ret ? "failed" : "succeeded", ret);
2267
2268 pci_restore_state(pdev);
2269
2270 spin_lock_irqsave(&rp->lock, flags);
2271#ifdef USE_MMIO 2332#ifdef USE_MMIO
2272 enable_mmio(rp->pioaddr, rp->quirks); 2333 enable_mmio(rp->pioaddr, rp->quirks);
2273#endif 2334#endif
@@ -2276,25 +2337,32 @@ static int rhine_resume(struct pci_dev *pdev)
2276 free_rbufs(dev); 2337 free_rbufs(dev);
2277 alloc_tbufs(dev); 2338 alloc_tbufs(dev);
2278 alloc_rbufs(dev); 2339 alloc_rbufs(dev);
2340 rhine_task_enable(rp);
2341 spin_lock_bh(&rp->lock);
2279 init_registers(dev); 2342 init_registers(dev);
2280 spin_unlock_irqrestore(&rp->lock, flags); 2343 spin_unlock_bh(&rp->lock);
2281 2344
2282 netif_device_attach(dev); 2345 netif_device_attach(dev);
2283 2346
2284 return 0; 2347 return 0;
2285} 2348}
2286#endif /* CONFIG_PM */ 2349
2350static SIMPLE_DEV_PM_OPS(rhine_pm_ops, rhine_suspend, rhine_resume);
2351#define RHINE_PM_OPS (&rhine_pm_ops)
2352
2353#else
2354
2355#define RHINE_PM_OPS NULL
2356
2357#endif /* !CONFIG_PM_SLEEP */
2287 2358
2288static struct pci_driver rhine_driver = { 2359static struct pci_driver rhine_driver = {
2289 .name = DRV_NAME, 2360 .name = DRV_NAME,
2290 .id_table = rhine_pci_tbl, 2361 .id_table = rhine_pci_tbl,
2291 .probe = rhine_init_one, 2362 .probe = rhine_init_one,
2292 .remove = __devexit_p(rhine_remove_one), 2363 .remove = __devexit_p(rhine_remove_one),
2293#ifdef CONFIG_PM 2364 .shutdown = rhine_shutdown,
2294 .suspend = rhine_suspend, 2365 .driver.pm = RHINE_PM_OPS,
2295 .resume = rhine_resume,
2296#endif /* CONFIG_PM */
2297 .shutdown = rhine_shutdown,
2298}; 2366};
2299 2367
2300static struct dmi_system_id __initdata rhine_dmi_table[] = { 2368static struct dmi_system_id __initdata rhine_dmi_table[] = {
diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index f45c85a84261..72a854f05bb8 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -529,7 +529,7 @@ static int ixp4xx_mdio_register(void)
529 mdio_bus->name = "IXP4xx MII Bus"; 529 mdio_bus->name = "IXP4xx MII Bus";
530 mdio_bus->read = &ixp4xx_mdio_read; 530 mdio_bus->read = &ixp4xx_mdio_read;
531 mdio_bus->write = &ixp4xx_mdio_write; 531 mdio_bus->write = &ixp4xx_mdio_write;
532 strcpy(mdio_bus->id, "0"); 532 snprintf(mdio_bus->id, MII_BUS_ID_SIZE, "ixp4xx-eth-0");
533 533
534 if ((err = mdiobus_register(mdio_bus))) 534 if ((err = mdiobus_register(mdio_bus)))
535 mdiobus_free(mdio_bus); 535 mdiobus_free(mdio_bus);
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 9663e0ba6003..ba3c59147aa7 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -1159,7 +1159,7 @@ static void rx_timestamp_work(struct work_struct *work)
1159 } 1159 }
1160 } 1160 }
1161 spin_unlock_irqrestore(&dp83640->rx_lock, flags); 1161 spin_unlock_irqrestore(&dp83640->rx_lock, flags);
1162 netif_rx(skb); 1162 netif_rx_ni(skb);
1163 } 1163 }
1164 1164
1165 /* Clear out expired time stamps. */ 1165 /* Clear out expired time stamps. */
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
index 1fa4d73c3cca..633680d0828e 100644
--- a/drivers/net/phy/fixed.c
+++ b/drivers/net/phy/fixed.c
@@ -220,7 +220,7 @@ static int __init fixed_mdio_bus_init(void)
220 goto err_mdiobus_reg; 220 goto err_mdiobus_reg;
221 } 221 }
222 222
223 snprintf(fmb->mii_bus->id, MII_BUS_ID_SIZE, "0"); 223 snprintf(fmb->mii_bus->id, MII_BUS_ID_SIZE, "fixed-0");
224 fmb->mii_bus->name = "Fixed MDIO Bus"; 224 fmb->mii_bus->name = "Fixed MDIO Bus";
225 fmb->mii_bus->priv = fmb; 225 fmb->mii_bus->priv = fmb;
226 fmb->mii_bus->parent = &pdev->dev; 226 fmb->mii_bus->parent = &pdev->dev;
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
index 89c5a3eccc12..50e8e5e74465 100644
--- a/drivers/net/phy/mdio-gpio.c
+++ b/drivers/net/phy/mdio-gpio.c
@@ -116,7 +116,7 @@ static struct mii_bus * __devinit mdio_gpio_bus_init(struct device *dev,
116 if (!new_bus->irq[i]) 116 if (!new_bus->irq[i])
117 new_bus->irq[i] = PHY_POLL; 117 new_bus->irq[i] = PHY_POLL;
118 118
119 snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", bus_id); 119 snprintf(new_bus->id, MII_BUS_ID_SIZE, "gpio-%x", bus_id);
120 120
121 if (gpio_request(bitbang->mdc, "mdc")) 121 if (gpio_request(bitbang->mdc, "mdc"))
122 goto out_free_bus; 122 goto out_free_bus;
diff --git a/drivers/net/phy/mdio-octeon.c b/drivers/net/phy/mdio-octeon.c
index bd12ba941be5..826d961f39f7 100644
--- a/drivers/net/phy/mdio-octeon.c
+++ b/drivers/net/phy/mdio-octeon.c
@@ -118,7 +118,8 @@ static int __devinit octeon_mdiobus_probe(struct platform_device *pdev)
118 bus->mii_bus->priv = bus; 118 bus->mii_bus->priv = bus;
119 bus->mii_bus->irq = bus->phy_irq; 119 bus->mii_bus->irq = bus->phy_irq;
120 bus->mii_bus->name = "mdio-octeon"; 120 bus->mii_bus->name = "mdio-octeon";
121 snprintf(bus->mii_bus->id, MII_BUS_ID_SIZE, "%x", bus->unit); 121 snprintf(bus->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
122 bus->mii_bus->name, bus->unit);
122 bus->mii_bus->parent = &pdev->dev; 123 bus->mii_bus->parent = &pdev->dev;
123 124
124 bus->mii_bus->read = octeon_mdiobus_read; 125 bus->mii_bus->read = octeon_mdiobus_read;
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 6c58da2b882c..88cc5db9affd 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -37,22 +37,36 @@
37#include <asm/uaccess.h> 37#include <asm/uaccess.h>
38 38
39/** 39/**
40 * mdiobus_alloc - allocate a mii_bus structure 40 * mdiobus_alloc_size - allocate a mii_bus structure
41 * 41 *
42 * Description: called by a bus driver to allocate an mii_bus 42 * Description: called by a bus driver to allocate an mii_bus
43 * structure to fill in. 43 * structure to fill in.
44 *
45 * 'size' is an an extra amount of memory to allocate for private storage.
46 * If non-zero, then bus->priv is points to that memory.
44 */ 47 */
45struct mii_bus *mdiobus_alloc(void) 48struct mii_bus *mdiobus_alloc_size(size_t size)
46{ 49{
47 struct mii_bus *bus; 50 struct mii_bus *bus;
51 size_t aligned_size = ALIGN(sizeof(*bus), NETDEV_ALIGN);
52 size_t alloc_size;
53
54 /* If we alloc extra space, it should be aligned */
55 if (size)
56 alloc_size = aligned_size + size;
57 else
58 alloc_size = sizeof(*bus);
48 59
49 bus = kzalloc(sizeof(*bus), GFP_KERNEL); 60 bus = kzalloc(alloc_size, GFP_KERNEL);
50 if (bus != NULL) 61 if (bus) {
51 bus->state = MDIOBUS_ALLOCATED; 62 bus->state = MDIOBUS_ALLOCATED;
63 if (size)
64 bus->priv = (void *)bus + aligned_size;
65 }
52 66
53 return bus; 67 return bus;
54} 68}
55EXPORT_SYMBOL(mdiobus_alloc); 69EXPORT_SYMBOL(mdiobus_alloc_size);
56 70
57/** 71/**
58 * mdiobus_release - mii_bus device release callback 72 * mdiobus_release - mii_bus device release callback
diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
index c1c9293c2bbf..df884dde2a51 100644
--- a/drivers/net/ppp/pptp.c
+++ b/drivers/net/ppp/pptp.c
@@ -585,8 +585,8 @@ static int pptp_create(struct net *net, struct socket *sock)
585 po = pppox_sk(sk); 585 po = pppox_sk(sk);
586 opt = &po->proto.pptp; 586 opt = &po->proto.pptp;
587 587
588 opt->seq_sent = 0; opt->seq_recv = 0; 588 opt->seq_sent = 0; opt->seq_recv = 0xffffffff;
589 opt->ack_recv = 0; opt->ack_sent = 0; 589 opt->ack_recv = 0; opt->ack_sent = 0xffffffff;
590 590
591 error = 0; 591 error = 0;
592out: 592out:
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index d0937c4634c9..8e84f5bdd6ca 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -978,6 +978,7 @@ static int ax88772_link_reset(struct usbnet *dev)
978 978
979static int ax88772_reset(struct usbnet *dev) 979static int ax88772_reset(struct usbnet *dev)
980{ 980{
981 struct asix_data *data = (struct asix_data *)&dev->data;
981 int ret, embd_phy; 982 int ret, embd_phy;
982 u16 rx_ctl; 983 u16 rx_ctl;
983 984
@@ -1055,6 +1056,13 @@ static int ax88772_reset(struct usbnet *dev)
1055 goto out; 1056 goto out;
1056 } 1057 }
1057 1058
1059 /* Rewrite MAC address */
1060 memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN);
1061 ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN,
1062 data->mac_addr);
1063 if (ret < 0)
1064 goto out;
1065
1058 /* Set RX_CTL to default values with 2k buffer, and enable cactus */ 1066 /* Set RX_CTL to default values with 2k buffer, and enable cactus */
1059 ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL); 1067 ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL);
1060 if (ret < 0) 1068 if (ret < 0)
@@ -1320,6 +1328,13 @@ static int ax88178_reset(struct usbnet *dev)
1320 if (ret < 0) 1328 if (ret < 0)
1321 return ret; 1329 return ret;
1322 1330
1331 /* Rewrite MAC address */
1332 memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN);
1333 ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN,
1334 data->mac_addr);
1335 if (ret < 0)
1336 return ret;
1337
1323 ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL); 1338 ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL);
1324 if (ret < 0) 1339 if (ret < 0)
1325 return ret; 1340 return ret;
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
index 2589b38b689a..2b0bfb8cca02 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
@@ -46,7 +46,7 @@ static const int m2ThreshExt_off = 127;
46 * @chan: 46 * @chan:
47 * 47 *
48 * This is the function to change channel on single-chip devices, that is 48 * This is the function to change channel on single-chip devices, that is
49 * all devices after ar9280. 49 * for AR9300 family of chipsets.
50 * 50 *
51 * This function takes the channel value in MHz and sets 51 * This function takes the channel value in MHz and sets
52 * hardware channel value. Assumes writes have been enabled to analog bus. 52 * hardware channel value. Assumes writes have been enabled to analog bus.
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index b30e9fc6433f..171ccf7c972f 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -679,7 +679,6 @@ void ath9k_deinit_device(struct ath_softc *sc);
679void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw); 679void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw);
680void ath9k_reload_chainmask_settings(struct ath_softc *sc); 680void ath9k_reload_chainmask_settings(struct ath_softc *sc);
681 681
682void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw);
683bool ath9k_uses_beacons(int type); 682bool ath9k_uses_beacons(int type);
684 683
685#ifdef CONFIG_ATH9K_PCI 684#ifdef CONFIG_ATH9K_PCI
diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c
index 172e33db7f4c..2f4b48e6fb03 100644
--- a/drivers/net/wireless/ath/ath9k/calib.c
+++ b/drivers/net/wireless/ath/ath9k/calib.c
@@ -400,6 +400,7 @@ bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan)
400 ah->noise = ath9k_hw_getchan_noise(ah, chan); 400 ah->noise = ath9k_hw_getchan_noise(ah, chan);
401 return true; 401 return true;
402} 402}
403EXPORT_SYMBOL(ath9k_hw_getnf);
403 404
404void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah, 405void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah,
405 struct ath9k_channel *chan) 406 struct ath9k_channel *chan)
diff --git a/drivers/net/wireless/ath/ath9k/calib.h b/drivers/net/wireless/ath/ath9k/calib.h
index 05b9dbf81850..3b33996d97df 100644
--- a/drivers/net/wireless/ath/ath9k/calib.h
+++ b/drivers/net/wireless/ath/ath9k/calib.h
@@ -19,7 +19,6 @@
19 19
20#include "hw.h" 20#include "hw.h"
21 21
22#define AR_PHY_CCA_FILTERWINDOW_LENGTH_INIT 3
23#define AR_PHY_CCA_FILTERWINDOW_LENGTH 5 22#define AR_PHY_CCA_FILTERWINDOW_LENGTH 5
24 23
25#define NUM_NF_READINGS 6 24#define NUM_NF_READINGS 6
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index e267c92dbfb8..4a00806e2852 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1629,7 +1629,6 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1629 1629
1630 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { 1630 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
1631 struct ieee80211_channel *curchan = hw->conf.channel; 1631 struct ieee80211_channel *curchan = hw->conf.channel;
1632 struct ath9k_channel old_chan;
1633 int pos = curchan->hw_value; 1632 int pos = curchan->hw_value;
1634 int old_pos = -1; 1633 int old_pos = -1;
1635 unsigned long flags; 1634 unsigned long flags;
@@ -1654,11 +1653,8 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
1654 * Preserve the current channel values, before updating 1653 * Preserve the current channel values, before updating
1655 * the same channel 1654 * the same channel
1656 */ 1655 */
1657 if (old_pos == pos) { 1656 if (ah->curchan && (old_pos == pos))
1658 memcpy(&old_chan, &sc->sc_ah->channels[pos], 1657 ath9k_hw_getnf(ah, ah->curchan);
1659 sizeof(struct ath9k_channel));
1660 ah->curchan = &old_chan;
1661 }
1662 1658
1663 ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos], 1659 ath9k_cmn_update_ichannel(&sc->sc_ah->channels[pos],
1664 curchan, conf->channel_type); 1660 curchan, conf->channel_type);
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index 5a002a21f108..f7eeee1dcdb6 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -3119,8 +3119,10 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_sdio *bus)
3119 /* Verify NVRAM bytes */ 3119 /* Verify NVRAM bytes */
3120 brcmf_dbg(INFO, "Compare NVRAM dl & ul; varsize=%d\n", varsize); 3120 brcmf_dbg(INFO, "Compare NVRAM dl & ul; varsize=%d\n", varsize);
3121 nvram_ularray = kmalloc(varsize, GFP_ATOMIC); 3121 nvram_ularray = kmalloc(varsize, GFP_ATOMIC);
3122 if (!nvram_ularray) 3122 if (!nvram_ularray) {
3123 kfree(vbuffer);
3123 return -ENOMEM; 3124 return -ENOMEM;
3125 }
3124 3126
3125 /* Upload image to verify downloaded contents. */ 3127 /* Upload image to verify downloaded contents. */
3126 memset(nvram_ularray, 0xaa, varsize); 3128 memset(nvram_ularray, 0xaa, varsize);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/fw.c b/drivers/net/wireless/rtlwifi/rtl8192se/fw.c
index 6f91a148c222..3fda6b1dcf46 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/fw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/fw.c
@@ -196,6 +196,8 @@ static bool _rtl92s_firmware_downloadcode(struct ieee80211_hw *hw,
196 /* Allocate skb buffer to contain firmware */ 196 /* Allocate skb buffer to contain firmware */
197 /* info and tx descriptor info. */ 197 /* info and tx descriptor info. */
198 skb = dev_alloc_skb(frag_length); 198 skb = dev_alloc_skb(frag_length);
199 if (!skb)
200 return false;
199 skb_reserve(skb, extra_descoffset); 201 skb_reserve(skb, extra_descoffset);
200 seg_ptr = (u8 *)skb_put(skb, (u32)(frag_length - 202 seg_ptr = (u8 *)skb_put(skb, (u32)(frag_length -
201 extra_descoffset)); 203 extra_descoffset));
@@ -573,6 +575,8 @@ static bool _rtl92s_firmware_set_h2c_cmd(struct ieee80211_hw *hw, u8 h2c_cmd,
573 575
574 len = _rtl92s_get_h2c_cmdlen(MAX_TRANSMIT_BUFFER_SIZE, 1, &cmd_len); 576 len = _rtl92s_get_h2c_cmdlen(MAX_TRANSMIT_BUFFER_SIZE, 1, &cmd_len);
575 skb = dev_alloc_skb(len); 577 skb = dev_alloc_skb(len);
578 if (!skb)
579 return false;
576 cb_desc = (struct rtl_tcb_desc *)(skb->cb); 580 cb_desc = (struct rtl_tcb_desc *)(skb->cb);
577 cb_desc->queue_index = TXCMD_QUEUE; 581 cb_desc->queue_index = TXCMD_QUEUE;
578 cb_desc->cmd_or_init = DESC_PACKET_TYPE_NORMAL; 582 cb_desc->cmd_or_init = DESC_PACKET_TYPE_NORMAL;
diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
index 34e8d52c1925..f1362b5447fc 100644
--- a/include/linux/inet_diag.h
+++ b/include/linux/inet_diag.h
@@ -22,7 +22,7 @@ struct inet_diag_sockid {
22 22
23/* Request structure */ 23/* Request structure */
24 24
25struct inet_diag_req_compat { 25struct inet_diag_req {
26 __u8 idiag_family; /* Family of addresses. */ 26 __u8 idiag_family; /* Family of addresses. */
27 __u8 idiag_src_len; 27 __u8 idiag_src_len;
28 __u8 idiag_dst_len; 28 __u8 idiag_dst_len;
@@ -34,7 +34,7 @@ struct inet_diag_req_compat {
34 __u32 idiag_dbs; /* Tables to dump (NI) */ 34 __u32 idiag_dbs; /* Tables to dump (NI) */
35}; 35};
36 36
37struct inet_diag_req { 37struct inet_diag_req_v2 {
38 __u8 sdiag_family; 38 __u8 sdiag_family;
39 __u8 sdiag_protocol; 39 __u8 sdiag_protocol;
40 __u8 idiag_ext; 40 __u8 idiag_ext;
@@ -143,12 +143,12 @@ struct netlink_callback;
143struct inet_diag_handler { 143struct inet_diag_handler {
144 void (*dump)(struct sk_buff *skb, 144 void (*dump)(struct sk_buff *skb,
145 struct netlink_callback *cb, 145 struct netlink_callback *cb,
146 struct inet_diag_req *r, 146 struct inet_diag_req_v2 *r,
147 struct nlattr *bc); 147 struct nlattr *bc);
148 148
149 int (*dump_one)(struct sk_buff *in_skb, 149 int (*dump_one)(struct sk_buff *in_skb,
150 const struct nlmsghdr *nlh, 150 const struct nlmsghdr *nlh,
151 struct inet_diag_req *req); 151 struct inet_diag_req_v2 *req);
152 152
153 void (*idiag_get_info)(struct sock *sk, 153 void (*idiag_get_info)(struct sock *sk,
154 struct inet_diag_msg *r, 154 struct inet_diag_msg *r,
@@ -158,15 +158,15 @@ struct inet_diag_handler {
158 158
159struct inet_connection_sock; 159struct inet_connection_sock;
160int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk, 160int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
161 struct sk_buff *skb, struct inet_diag_req *req, 161 struct sk_buff *skb, struct inet_diag_req_v2 *req,
162 u32 pid, u32 seq, u16 nlmsg_flags, 162 u32 pid, u32 seq, u16 nlmsg_flags,
163 const struct nlmsghdr *unlh); 163 const struct nlmsghdr *unlh);
164void inet_diag_dump_icsk(struct inet_hashinfo *h, struct sk_buff *skb, 164void inet_diag_dump_icsk(struct inet_hashinfo *h, struct sk_buff *skb,
165 struct netlink_callback *cb, struct inet_diag_req *r, 165 struct netlink_callback *cb, struct inet_diag_req_v2 *r,
166 struct nlattr *bc); 166 struct nlattr *bc);
167int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo, 167int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo,
168 struct sk_buff *in_skb, const struct nlmsghdr *nlh, 168 struct sk_buff *in_skb, const struct nlmsghdr *nlh,
169 struct inet_diag_req *req); 169 struct inet_diag_req_v2 *req);
170 170
171int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk); 171int inet_diag_bc_sk(const struct nlattr *_bc, struct sock *sk);
172 172
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 79f337c47388..c599f7eca1e7 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -129,7 +129,12 @@ struct mii_bus {
129}; 129};
130#define to_mii_bus(d) container_of(d, struct mii_bus, dev) 130#define to_mii_bus(d) container_of(d, struct mii_bus, dev)
131 131
132struct mii_bus *mdiobus_alloc(void); 132struct mii_bus *mdiobus_alloc_size(size_t);
133static inline struct mii_bus *mdiobus_alloc(void)
134{
135 return mdiobus_alloc_size(0);
136}
137
133int mdiobus_register(struct mii_bus *bus); 138int mdiobus_register(struct mii_bus *bus);
134void mdiobus_unregister(struct mii_bus *bus); 139void mdiobus_unregister(struct mii_bus *bus);
135void mdiobus_free(struct mii_bus *bus); 140void mdiobus_free(struct mii_bus *bus);
diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
index 8f1b928f777c..0d5b79365d03 100644
--- a/include/linux/pkt_sched.h
+++ b/include/linux/pkt_sched.h
@@ -162,10 +162,30 @@ struct tc_sfq_qopt {
162 unsigned flows; /* Maximal number of flows */ 162 unsigned flows; /* Maximal number of flows */
163}; 163};
164 164
165struct tc_sfqred_stats {
166 __u32 prob_drop; /* Early drops, below max threshold */
167 __u32 forced_drop; /* Early drops, after max threshold */
168 __u32 prob_mark; /* Marked packets, below max threshold */
169 __u32 forced_mark; /* Marked packets, after max threshold */
170 __u32 prob_mark_head; /* Marked packets, below max threshold */
171 __u32 forced_mark_head;/* Marked packets, after max threshold */
172};
173
165struct tc_sfq_qopt_v1 { 174struct tc_sfq_qopt_v1 {
166 struct tc_sfq_qopt v0; 175 struct tc_sfq_qopt v0;
167 unsigned int depth; /* max number of packets per flow */ 176 unsigned int depth; /* max number of packets per flow */
168 unsigned int headdrop; 177 unsigned int headdrop;
178/* SFQRED parameters */
179 __u32 limit; /* HARD maximal flow queue length (bytes) */
180 __u32 qth_min; /* Min average length threshold (bytes) */
181 __u32 qth_max; /* Max average length threshold (bytes) */
182 unsigned char Wlog; /* log(W) */
183 unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
184 unsigned char Scell_log; /* cell size for idle damping */
185 unsigned char flags;
186 __u32 max_P; /* probability, high resolution */
187/* SFQRED stats */
188 struct tc_sfqred_stats stats;
169}; 189};
170 190
171 191
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 5e2e98458496..ea9231f4935f 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -127,7 +127,7 @@ struct hci_dev {
127 __u8 major_class; 127 __u8 major_class;
128 __u8 minor_class; 128 __u8 minor_class;
129 __u8 features[8]; 129 __u8 features[8];
130 __u8 extfeatures[8]; 130 __u8 host_features[8];
131 __u8 commands[64]; 131 __u8 commands[64];
132 __u8 ssp_mode; 132 __u8 ssp_mode;
133 __u8 hci_ver; 133 __u8 hci_ver;
@@ -676,7 +676,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
676#define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE) 676#define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE)
677 677
678/* ----- Extended LMP capabilities ----- */ 678/* ----- Extended LMP capabilities ----- */
679#define lmp_host_le_capable(dev) ((dev)->extfeatures[0] & LMP_HOST_LE) 679#define lmp_host_le_capable(dev) ((dev)->host_features[0] & LMP_HOST_LE)
680 680
681/* ----- HCI protocols ----- */ 681/* ----- HCI protocols ----- */
682static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, 682static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr,
diff --git a/include/net/red.h b/include/net/red.h
index baab385a4736..28068ec614b2 100644
--- a/include/net/red.h
+++ b/include/net/red.h
@@ -199,7 +199,8 @@ static inline void red_set_parms(struct red_parms *p,
199 p->Scell_log = Scell_log; 199 p->Scell_log = Scell_log;
200 p->Scell_max = (255 << Scell_log); 200 p->Scell_max = (255 << Scell_log);
201 201
202 memcpy(p->Stab, stab, sizeof(p->Stab)); 202 if (stab)
203 memcpy(p->Stab, stab, sizeof(p->Stab));
203} 204}
204 205
205static inline int red_is_idling(const struct red_vars *v) 206static inline int red_is_idling(const struct red_vars *v)
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index cdcfcabb34ab..ef92864ac625 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -156,17 +156,17 @@ static int bt_sock_create(struct net *net, struct socket *sock, int proto,
156 156
157void bt_sock_link(struct bt_sock_list *l, struct sock *sk) 157void bt_sock_link(struct bt_sock_list *l, struct sock *sk)
158{ 158{
159 write_lock_bh(&l->lock); 159 write_lock(&l->lock);
160 sk_add_node(sk, &l->head); 160 sk_add_node(sk, &l->head);
161 write_unlock_bh(&l->lock); 161 write_unlock(&l->lock);
162} 162}
163EXPORT_SYMBOL(bt_sock_link); 163EXPORT_SYMBOL(bt_sock_link);
164 164
165void bt_sock_unlink(struct bt_sock_list *l, struct sock *sk) 165void bt_sock_unlink(struct bt_sock_list *l, struct sock *sk)
166{ 166{
167 write_lock_bh(&l->lock); 167 write_lock(&l->lock);
168 sk_del_node_init(sk); 168 sk_del_node_init(sk);
169 write_unlock_bh(&l->lock); 169 write_unlock(&l->lock);
170} 170}
171EXPORT_SYMBOL(bt_sock_unlink); 171EXPORT_SYMBOL(bt_sock_unlink);
172 172
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 4221bd256bdd..001307f81057 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -711,7 +711,14 @@ static void hci_cc_read_local_ext_features(struct hci_dev *hdev,
711 if (rp->status) 711 if (rp->status)
712 return; 712 return;
713 713
714 memcpy(hdev->extfeatures, rp->features, 8); 714 switch (rp->page) {
715 case 0:
716 memcpy(hdev->features, rp->features, 8);
717 break;
718 case 1:
719 memcpy(hdev->host_features, rp->features, 8);
720 break;
721 }
715 722
716 hci_req_complete(hdev, HCI_OP_READ_LOCAL_EXT_FEATURES, rp->status); 723 hci_req_complete(hdev, HCI_OP_READ_LOCAL_EXT_FEATURES, rp->status);
717} 724}
@@ -1047,9 +1054,7 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
1047 case LE_SCANNING_DISABLED: 1054 case LE_SCANNING_DISABLED:
1048 clear_bit(HCI_LE_SCAN, &hdev->dev_flags); 1055 clear_bit(HCI_LE_SCAN, &hdev->dev_flags);
1049 1056
1050 cancel_delayed_work_sync(&hdev->adv_work); 1057 schedule_delayed_work(&hdev->adv_work, ADV_CLEAR_TIMEOUT);
1051 queue_delayed_work(hdev->workqueue, &hdev->adv_work,
1052 jiffies + ADV_CLEAR_TIMEOUT);
1053 break; 1058 break;
1054 1059
1055 default: 1060 default:
@@ -2266,20 +2271,19 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s
2266 struct hci_ev_num_comp_pkts *ev = (void *) skb->data; 2271 struct hci_ev_num_comp_pkts *ev = (void *) skb->data;
2267 int i; 2272 int i;
2268 2273
2269 skb_pull(skb, sizeof(*ev));
2270
2271 BT_DBG("%s num_hndl %d", hdev->name, ev->num_hndl);
2272
2273 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) { 2274 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) {
2274 BT_ERR("Wrong event for mode %d", hdev->flow_ctl_mode); 2275 BT_ERR("Wrong event for mode %d", hdev->flow_ctl_mode);
2275 return; 2276 return;
2276 } 2277 }
2277 2278
2278 if (skb->len < ev->num_hndl * 4) { 2279 if (skb->len < sizeof(*ev) || skb->len < sizeof(*ev) +
2280 ev->num_hndl * sizeof(struct hci_comp_pkts_info)) {
2279 BT_DBG("%s bad parameters", hdev->name); 2281 BT_DBG("%s bad parameters", hdev->name);
2280 return; 2282 return;
2281 } 2283 }
2282 2284
2285 BT_DBG("%s num_hndl %d", hdev->name, ev->num_hndl);
2286
2283 for (i = 0; i < ev->num_hndl; i++) { 2287 for (i = 0; i < ev->num_hndl; i++) {
2284 struct hci_comp_pkts_info *info = &ev->handles[i]; 2288 struct hci_comp_pkts_info *info = &ev->handles[i];
2285 struct hci_conn *conn; 2289 struct hci_conn *conn;
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 6d94616af312..0dcc96266779 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -767,7 +767,6 @@ static int hci_sock_dev_event(struct notifier_block *this, unsigned long event,
767 /* Detach sockets from device */ 767 /* Detach sockets from device */
768 read_lock(&hci_sk_list.lock); 768 read_lock(&hci_sk_list.lock);
769 sk_for_each(sk, node, &hci_sk_list.head) { 769 sk_for_each(sk, node, &hci_sk_list.head) {
770 local_bh_disable();
771 bh_lock_sock_nested(sk); 770 bh_lock_sock_nested(sk);
772 if (hci_pi(sk)->hdev == hdev) { 771 if (hci_pi(sk)->hdev == hdev) {
773 hci_pi(sk)->hdev = NULL; 772 hci_pi(sk)->hdev = NULL;
@@ -778,7 +777,6 @@ static int hci_sock_dev_event(struct notifier_block *this, unsigned long event,
778 hci_dev_put(hdev); 777 hci_dev_put(hdev);
779 } 778 }
780 bh_unlock_sock(sk); 779 bh_unlock_sock(sk);
781 local_bh_enable();
782 } 780 }
783 read_unlock(&hci_sk_list.lock); 781 read_unlock(&hci_sk_list.lock);
784 } 782 }
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index aa78d8c4b93b..faf0b11ac1d3 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -165,7 +165,7 @@ int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm)
165{ 165{
166 int err; 166 int err;
167 167
168 write_lock_bh(&chan_list_lock); 168 write_lock(&chan_list_lock);
169 169
170 if (psm && __l2cap_global_chan_by_addr(psm, src)) { 170 if (psm && __l2cap_global_chan_by_addr(psm, src)) {
171 err = -EADDRINUSE; 171 err = -EADDRINUSE;
@@ -190,17 +190,17 @@ int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm)
190 } 190 }
191 191
192done: 192done:
193 write_unlock_bh(&chan_list_lock); 193 write_unlock(&chan_list_lock);
194 return err; 194 return err;
195} 195}
196 196
197int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid) 197int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid)
198{ 198{
199 write_lock_bh(&chan_list_lock); 199 write_lock(&chan_list_lock);
200 200
201 chan->scid = scid; 201 chan->scid = scid;
202 202
203 write_unlock_bh(&chan_list_lock); 203 write_unlock(&chan_list_lock);
204 204
205 return 0; 205 return 0;
206} 206}
@@ -289,9 +289,9 @@ struct l2cap_chan *l2cap_chan_create(struct sock *sk)
289 289
290 chan->sk = sk; 290 chan->sk = sk;
291 291
292 write_lock_bh(&chan_list_lock); 292 write_lock(&chan_list_lock);
293 list_add(&chan->global_l, &chan_list); 293 list_add(&chan->global_l, &chan_list);
294 write_unlock_bh(&chan_list_lock); 294 write_unlock(&chan_list_lock);
295 295
296 INIT_DELAYED_WORK(&chan->chan_timer, l2cap_chan_timeout); 296 INIT_DELAYED_WORK(&chan->chan_timer, l2cap_chan_timeout);
297 297
@@ -306,9 +306,9 @@ struct l2cap_chan *l2cap_chan_create(struct sock *sk)
306 306
307void l2cap_chan_destroy(struct l2cap_chan *chan) 307void l2cap_chan_destroy(struct l2cap_chan *chan)
308{ 308{
309 write_lock_bh(&chan_list_lock); 309 write_lock(&chan_list_lock);
310 list_del(&chan->global_l); 310 list_del(&chan->global_l);
311 write_unlock_bh(&chan_list_lock); 311 write_unlock(&chan_list_lock);
312 312
313 l2cap_chan_put(chan); 313 l2cap_chan_put(chan);
314} 314}
@@ -543,14 +543,14 @@ static u8 l2cap_get_ident(struct l2cap_conn *conn)
543 * 200 - 254 are used by utilities like l2ping, etc. 543 * 200 - 254 are used by utilities like l2ping, etc.
544 */ 544 */
545 545
546 spin_lock_bh(&conn->lock); 546 spin_lock(&conn->lock);
547 547
548 if (++conn->tx_ident > 128) 548 if (++conn->tx_ident > 128)
549 conn->tx_ident = 1; 549 conn->tx_ident = 1;
550 550
551 id = conn->tx_ident; 551 id = conn->tx_ident;
552 552
553 spin_unlock_bh(&conn->lock); 553 spin_unlock(&conn->lock);
554 554
555 return id; 555 return id;
556} 556}
@@ -1190,7 +1190,7 @@ inline int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdad
1190 } 1190 }
1191 1191
1192 /* Set destination address and psm */ 1192 /* Set destination address and psm */
1193 bacpy(&bt_sk(sk)->dst, src); 1193 bacpy(&bt_sk(sk)->dst, dst);
1194 chan->psm = psm; 1194 chan->psm = psm;
1195 chan->dcid = cid; 1195 chan->dcid = cid;
1196 1196
@@ -4702,7 +4702,7 @@ static int l2cap_debugfs_show(struct seq_file *f, void *p)
4702{ 4702{
4703 struct l2cap_chan *c; 4703 struct l2cap_chan *c;
4704 4704
4705 read_lock_bh(&chan_list_lock); 4705 read_lock(&chan_list_lock);
4706 4706
4707 list_for_each_entry(c, &chan_list, global_l) { 4707 list_for_each_entry(c, &chan_list, global_l) {
4708 struct sock *sk = c->sk; 4708 struct sock *sk = c->sk;
@@ -4715,7 +4715,7 @@ static int l2cap_debugfs_show(struct seq_file *f, void *p)
4715 c->sec_level, c->mode); 4715 c->sec_level, c->mode);
4716} 4716}
4717 4717
4718 read_unlock_bh(&chan_list_lock); 4718 read_unlock(&chan_list_lock);
4719 4719
4720 return 0; 4720 return 0;
4721} 4721}
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 9ca5616166f7..c61d967012b2 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -587,6 +587,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
587 if (smp_conn_security(conn, sec.level)) 587 if (smp_conn_security(conn, sec.level))
588 break; 588 break;
589 sk->sk_state = BT_CONFIG; 589 sk->sk_state = BT_CONFIG;
590 chan->state = BT_CONFIG;
590 591
591 /* or for ACL link, under defer_setup time */ 592 /* or for ACL link, under defer_setup time */
592 } else if (sk->sk_state == BT_CONNECT2 && 593 } else if (sk->sk_state == BT_CONNECT2 &&
@@ -731,6 +732,7 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct ms
731 732
732 if (sk->sk_state == BT_CONNECT2 && bt_sk(sk)->defer_setup) { 733 if (sk->sk_state == BT_CONNECT2 && bt_sk(sk)->defer_setup) {
733 sk->sk_state = BT_CONFIG; 734 sk->sk_state = BT_CONFIG;
735 pi->chan->state = BT_CONFIG;
734 736
735 __l2cap_connect_rsp_defer(pi->chan); 737 __l2cap_connect_rsp_defer(pi->chan);
736 release_sock(sk); 738 release_sock(sk);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 2540944d871f..bc8e59dda78e 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -291,7 +291,7 @@ static u32 get_current_settings(struct hci_dev *hdev)
291 if (!(hdev->features[4] & LMP_NO_BREDR)) 291 if (!(hdev->features[4] & LMP_NO_BREDR))
292 settings |= MGMT_SETTING_BREDR; 292 settings |= MGMT_SETTING_BREDR;
293 293
294 if (hdev->extfeatures[0] & LMP_HOST_LE) 294 if (hdev->host_features[0] & LMP_HOST_LE)
295 settings |= MGMT_SETTING_LE; 295 settings |= MGMT_SETTING_LE;
296 296
297 if (test_bit(HCI_AUTH, &hdev->flags)) 297 if (test_bit(HCI_AUTH, &hdev->flags))
@@ -2756,7 +2756,7 @@ int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status)
2756 if (!cmd) 2756 if (!cmd)
2757 return -ENOENT; 2757 return -ENOENT;
2758 2758
2759 err = cmd_status(cmd->sk, hdev->id, cmd->opcode, status); 2759 err = cmd_status(cmd->sk, hdev->id, cmd->opcode, mgmt_status(status));
2760 mgmt_pending_remove(cmd); 2760 mgmt_pending_remove(cmd);
2761 2761
2762 return err; 2762 return err;
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index aea2bdd1510f..f066678faeee 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -370,7 +370,7 @@ static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr
370 goto done; 370 goto done;
371 } 371 }
372 372
373 write_lock_bh(&rfcomm_sk_list.lock); 373 write_lock(&rfcomm_sk_list.lock);
374 374
375 if (sa->rc_channel && __rfcomm_get_sock_by_addr(sa->rc_channel, &sa->rc_bdaddr)) { 375 if (sa->rc_channel && __rfcomm_get_sock_by_addr(sa->rc_channel, &sa->rc_bdaddr)) {
376 err = -EADDRINUSE; 376 err = -EADDRINUSE;
@@ -381,7 +381,7 @@ static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr
381 sk->sk_state = BT_BOUND; 381 sk->sk_state = BT_BOUND;
382 } 382 }
383 383
384 write_unlock_bh(&rfcomm_sk_list.lock); 384 write_unlock(&rfcomm_sk_list.lock);
385 385
386done: 386done:
387 release_sock(sk); 387 release_sock(sk);
@@ -455,7 +455,7 @@ static int rfcomm_sock_listen(struct socket *sock, int backlog)
455 455
456 err = -EINVAL; 456 err = -EINVAL;
457 457
458 write_lock_bh(&rfcomm_sk_list.lock); 458 write_lock(&rfcomm_sk_list.lock);
459 459
460 for (channel = 1; channel < 31; channel++) 460 for (channel = 1; channel < 31; channel++)
461 if (!__rfcomm_get_sock_by_addr(channel, src)) { 461 if (!__rfcomm_get_sock_by_addr(channel, src)) {
@@ -464,7 +464,7 @@ static int rfcomm_sock_listen(struct socket *sock, int backlog)
464 break; 464 break;
465 } 465 }
466 466
467 write_unlock_bh(&rfcomm_sk_list.lock); 467 write_unlock(&rfcomm_sk_list.lock);
468 468
469 if (err < 0) 469 if (err < 0)
470 goto done; 470 goto done;
@@ -982,7 +982,7 @@ static int rfcomm_sock_debugfs_show(struct seq_file *f, void *p)
982 struct sock *sk; 982 struct sock *sk;
983 struct hlist_node *node; 983 struct hlist_node *node;
984 984
985 read_lock_bh(&rfcomm_sk_list.lock); 985 read_lock(&rfcomm_sk_list.lock);
986 986
987 sk_for_each(sk, node, &rfcomm_sk_list.head) { 987 sk_for_each(sk, node, &rfcomm_sk_list.head) {
988 seq_printf(f, "%s %s %d %d\n", 988 seq_printf(f, "%s %s %d %d\n",
@@ -991,7 +991,7 @@ static int rfcomm_sock_debugfs_show(struct seq_file *f, void *p)
991 sk->sk_state, rfcomm_pi(sk)->channel); 991 sk->sk_state, rfcomm_pi(sk)->channel);
992 } 992 }
993 993
994 read_unlock_bh(&rfcomm_sk_list.lock); 994 read_unlock(&rfcomm_sk_list.lock);
995 995
996 return 0; 996 return 0;
997} 997}
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index fa8f4de53b99..a2d4f5122a6a 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -76,7 +76,7 @@ struct rfcomm_dev {
76}; 76};
77 77
78static LIST_HEAD(rfcomm_dev_list); 78static LIST_HEAD(rfcomm_dev_list);
79static DEFINE_RWLOCK(rfcomm_dev_lock); 79static DEFINE_SPINLOCK(rfcomm_dev_lock);
80 80
81static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb); 81static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb);
82static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err); 82static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err);
@@ -146,7 +146,7 @@ static inline struct rfcomm_dev *rfcomm_dev_get(int id)
146{ 146{
147 struct rfcomm_dev *dev; 147 struct rfcomm_dev *dev;
148 148
149 read_lock(&rfcomm_dev_lock); 149 spin_lock(&rfcomm_dev_lock);
150 150
151 dev = __rfcomm_dev_get(id); 151 dev = __rfcomm_dev_get(id);
152 152
@@ -157,7 +157,7 @@ static inline struct rfcomm_dev *rfcomm_dev_get(int id)
157 rfcomm_dev_hold(dev); 157 rfcomm_dev_hold(dev);
158 } 158 }
159 159
160 read_unlock(&rfcomm_dev_lock); 160 spin_unlock(&rfcomm_dev_lock);
161 161
162 return dev; 162 return dev;
163} 163}
@@ -205,7 +205,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
205 if (!dev) 205 if (!dev)
206 return -ENOMEM; 206 return -ENOMEM;
207 207
208 write_lock_bh(&rfcomm_dev_lock); 208 spin_lock(&rfcomm_dev_lock);
209 209
210 if (req->dev_id < 0) { 210 if (req->dev_id < 0) {
211 dev->id = 0; 211 dev->id = 0;
@@ -290,7 +290,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
290 __module_get(THIS_MODULE); 290 __module_get(THIS_MODULE);
291 291
292out: 292out:
293 write_unlock_bh(&rfcomm_dev_lock); 293 spin_unlock(&rfcomm_dev_lock);
294 294
295 if (err < 0) 295 if (err < 0)
296 goto free; 296 goto free;
@@ -327,9 +327,9 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
327 if (atomic_read(&dev->opened) > 0) 327 if (atomic_read(&dev->opened) > 0)
328 return; 328 return;
329 329
330 write_lock_bh(&rfcomm_dev_lock); 330 spin_lock(&rfcomm_dev_lock);
331 list_del_init(&dev->list); 331 list_del_init(&dev->list);
332 write_unlock_bh(&rfcomm_dev_lock); 332 spin_unlock(&rfcomm_dev_lock);
333 333
334 rfcomm_dev_put(dev); 334 rfcomm_dev_put(dev);
335} 335}
@@ -473,7 +473,7 @@ static int rfcomm_get_dev_list(void __user *arg)
473 473
474 di = dl->dev_info; 474 di = dl->dev_info;
475 475
476 read_lock_bh(&rfcomm_dev_lock); 476 spin_lock(&rfcomm_dev_lock);
477 477
478 list_for_each_entry(dev, &rfcomm_dev_list, list) { 478 list_for_each_entry(dev, &rfcomm_dev_list, list) {
479 if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags)) 479 if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags))
@@ -488,7 +488,7 @@ static int rfcomm_get_dev_list(void __user *arg)
488 break; 488 break;
489 } 489 }
490 490
491 read_unlock_bh(&rfcomm_dev_lock); 491 spin_unlock(&rfcomm_dev_lock);
492 492
493 dl->dev_num = n; 493 dl->dev_num = n;
494 size = sizeof(*dl) + n * sizeof(*di); 494 size = sizeof(*dl) + n * sizeof(*di);
@@ -766,9 +766,9 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
766 rfcomm_dlc_unlock(dev->dlc); 766 rfcomm_dlc_unlock(dev->dlc);
767 767
768 if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags)) { 768 if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags)) {
769 write_lock_bh(&rfcomm_dev_lock); 769 spin_lock(&rfcomm_dev_lock);
770 list_del_init(&dev->list); 770 list_del_init(&dev->list);
771 write_unlock_bh(&rfcomm_dev_lock); 771 spin_unlock(&rfcomm_dev_lock);
772 772
773 rfcomm_dev_put(dev); 773 rfcomm_dev_put(dev);
774 } 774 }
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 5dc2f2126fac..8bf26d1bc5c1 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -482,7 +482,7 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le
482 goto done; 482 goto done;
483 } 483 }
484 484
485 write_lock_bh(&sco_sk_list.lock); 485 write_lock(&sco_sk_list.lock);
486 486
487 if (bacmp(src, BDADDR_ANY) && __sco_get_sock_by_addr(src)) { 487 if (bacmp(src, BDADDR_ANY) && __sco_get_sock_by_addr(src)) {
488 err = -EADDRINUSE; 488 err = -EADDRINUSE;
@@ -492,7 +492,7 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le
492 sk->sk_state = BT_BOUND; 492 sk->sk_state = BT_BOUND;
493 } 493 }
494 494
495 write_unlock_bh(&sco_sk_list.lock); 495 write_unlock(&sco_sk_list.lock);
496 496
497done: 497done:
498 release_sock(sk); 498 release_sock(sk);
@@ -965,14 +965,14 @@ static int sco_debugfs_show(struct seq_file *f, void *p)
965 struct sock *sk; 965 struct sock *sk;
966 struct hlist_node *node; 966 struct hlist_node *node;
967 967
968 read_lock_bh(&sco_sk_list.lock); 968 read_lock(&sco_sk_list.lock);
969 969
970 sk_for_each(sk, node, &sco_sk_list.head) { 970 sk_for_each(sk, node, &sco_sk_list.head) {
971 seq_printf(f, "%s %s %d\n", batostr(&bt_sk(sk)->src), 971 seq_printf(f, "%s %s %d\n", batostr(&bt_sk(sk)->src),
972 batostr(&bt_sk(sk)->dst), sk->sk_state); 972 batostr(&bt_sk(sk)->dst), sk->sk_state);
973 } 973 }
974 974
975 read_unlock_bh(&sco_sk_list.lock); 975 read_unlock(&sco_sk_list.lock);
976 976
977 return 0; 977 return 0;
978} 978}
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index abf4393a77b3..f3dbd4f596a4 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -1177,9 +1177,9 @@ static ssize_t store_xps_map(struct netdev_queue *queue,
1177 nonempty = 1; 1177 nonempty = 1;
1178 } 1178 }
1179 1179
1180 if (nonempty) 1180 if (nonempty) {
1181 RCU_INIT_POINTER(dev->xps_maps, new_dev_maps); 1181 rcu_assign_pointer(dev->xps_maps, new_dev_maps);
1182 else { 1182 } else {
1183 kfree(new_dev_maps); 1183 kfree(new_dev_maps);
1184 RCU_INIT_POINTER(dev->xps_maps, NULL); 1184 RCU_INIT_POINTER(dev->xps_maps, NULL);
1185 } 1185 }
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 0d38808a2305..556b08298669 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -765,7 +765,7 @@ int __netpoll_setup(struct netpoll *np)
765 } 765 }
766 766
767 /* last thing to do is link it to the net device structure */ 767 /* last thing to do is link it to the net device structure */
768 RCU_INIT_POINTER(ndev->npinfo, npinfo); 768 rcu_assign_pointer(ndev->npinfo, npinfo);
769 769
770 return 0; 770 return 0;
771 771
diff --git a/net/dccp/diag.c b/net/dccp/diag.c
index 8f1625753377..028fc43aacbd 100644
--- a/net/dccp/diag.c
+++ b/net/dccp/diag.c
@@ -49,13 +49,13 @@ static void dccp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
49} 49}
50 50
51static void dccp_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, 51static void dccp_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
52 struct inet_diag_req *r, struct nlattr *bc) 52 struct inet_diag_req_v2 *r, struct nlattr *bc)
53{ 53{
54 inet_diag_dump_icsk(&dccp_hashinfo, skb, cb, r, bc); 54 inet_diag_dump_icsk(&dccp_hashinfo, skb, cb, r, bc);
55} 55}
56 56
57static int dccp_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh, 57static int dccp_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh,
58 struct inet_diag_req *req) 58 struct inet_diag_req_v2 *req)
59{ 59{
60 return inet_diag_dump_one_icsk(&dccp_hashinfo, in_skb, nlh, req); 60 return inet_diag_dump_one_icsk(&dccp_hashinfo, in_skb, nlh, req);
61} 61}
diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c
index 2ab16e12520c..74d321a60e7b 100644
--- a/net/decnet/dn_dev.c
+++ b/net/decnet/dn_dev.c
@@ -388,7 +388,7 @@ static int dn_dev_insert_ifa(struct dn_dev *dn_db, struct dn_ifaddr *ifa)
388 } 388 }
389 389
390 ifa->ifa_next = dn_db->ifa_list; 390 ifa->ifa_next = dn_db->ifa_list;
391 RCU_INIT_POINTER(dn_db->ifa_list, ifa); 391 rcu_assign_pointer(dn_db->ifa_list, ifa);
392 392
393 dn_ifaddr_notify(RTM_NEWADDR, ifa); 393 dn_ifaddr_notify(RTM_NEWADDR, ifa);
394 blocking_notifier_call_chain(&dnaddr_chain, NETDEV_UP, ifa); 394 blocking_notifier_call_chain(&dnaddr_chain, NETDEV_UP, ifa);
@@ -1093,7 +1093,7 @@ static struct dn_dev *dn_dev_create(struct net_device *dev, int *err)
1093 1093
1094 memcpy(&dn_db->parms, p, sizeof(struct dn_dev_parms)); 1094 memcpy(&dn_db->parms, p, sizeof(struct dn_dev_parms));
1095 1095
1096 RCU_INIT_POINTER(dev->dn_ptr, dn_db); 1096 rcu_assign_pointer(dev->dn_ptr, dn_db);
1097 dn_db->dev = dev; 1097 dn_db->dev = dev;
1098 init_timer(&dn_db->timer); 1098 init_timer(&dn_db->timer);
1099 1099
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 65f01dc47565..e41c40f48cfe 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -258,7 +258,7 @@ static struct in_device *inetdev_init(struct net_device *dev)
258 ip_mc_up(in_dev); 258 ip_mc_up(in_dev);
259 259
260 /* we can receive as soon as ip_ptr is set -- do this last */ 260 /* we can receive as soon as ip_ptr is set -- do this last */
261 RCU_INIT_POINTER(dev->ip_ptr, in_dev); 261 rcu_assign_pointer(dev->ip_ptr, in_dev);
262out: 262out:
263 return in_dev; 263 return in_dev;
264out_kfree: 264out_kfree:
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index d04b13ae18fe..2b555a5521e0 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -205,7 +205,7 @@ static inline struct tnode *node_parent_rcu(const struct rt_trie_node *node)
205 return (struct tnode *)(parent & ~NODE_TYPE_MASK); 205 return (struct tnode *)(parent & ~NODE_TYPE_MASK);
206} 206}
207 207
208/* Same as RCU_INIT_POINTER 208/* Same as rcu_assign_pointer
209 * but that macro() assumes that value is a pointer. 209 * but that macro() assumes that value is a pointer.
210 */ 210 */
211static inline void node_set_parent(struct rt_trie_node *node, struct tnode *ptr) 211static inline void node_set_parent(struct rt_trie_node *node, struct tnode *ptr)
@@ -529,7 +529,7 @@ static void tnode_put_child_reorg(struct tnode *tn, int i, struct rt_trie_node *
529 if (n) 529 if (n)
530 node_set_parent(n, tn); 530 node_set_parent(n, tn);
531 531
532 RCU_INIT_POINTER(tn->child[i], n); 532 rcu_assign_pointer(tn->child[i], n);
533} 533}
534 534
535#define MAX_WORK 10 535#define MAX_WORK 10
@@ -1015,7 +1015,7 @@ static void trie_rebalance(struct trie *t, struct tnode *tn)
1015 1015
1016 tp = node_parent((struct rt_trie_node *) tn); 1016 tp = node_parent((struct rt_trie_node *) tn);
1017 if (!tp) 1017 if (!tp)
1018 RCU_INIT_POINTER(t->trie, (struct rt_trie_node *)tn); 1018 rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn);
1019 1019
1020 tnode_free_flush(); 1020 tnode_free_flush();
1021 if (!tp) 1021 if (!tp)
@@ -1027,7 +1027,7 @@ static void trie_rebalance(struct trie *t, struct tnode *tn)
1027 if (IS_TNODE(tn)) 1027 if (IS_TNODE(tn))
1028 tn = (struct tnode *)resize(t, (struct tnode *)tn); 1028 tn = (struct tnode *)resize(t, (struct tnode *)tn);
1029 1029
1030 RCU_INIT_POINTER(t->trie, (struct rt_trie_node *)tn); 1030 rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn);
1031 tnode_free_flush(); 1031 tnode_free_flush();
1032} 1032}
1033 1033
@@ -1164,7 +1164,7 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen)
1164 put_child(t, (struct tnode *)tp, cindex, 1164 put_child(t, (struct tnode *)tp, cindex,
1165 (struct rt_trie_node *)tn); 1165 (struct rt_trie_node *)tn);
1166 } else { 1166 } else {
1167 RCU_INIT_POINTER(t->trie, (struct rt_trie_node *)tn); 1167 rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn);
1168 tp = tn; 1168 tp = tn;
1169 } 1169 }
1170 } 1170 }
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 5104bc0bbdbe..450e5d21ed2a 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1249,7 +1249,7 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
1249 1249
1250 im->next_rcu = in_dev->mc_list; 1250 im->next_rcu = in_dev->mc_list;
1251 in_dev->mc_count++; 1251 in_dev->mc_count++;
1252 RCU_INIT_POINTER(in_dev->mc_list, im); 1252 rcu_assign_pointer(in_dev->mc_list, im);
1253 1253
1254#ifdef CONFIG_IP_MULTICAST 1254#ifdef CONFIG_IP_MULTICAST
1255 igmpv3_del_delrec(in_dev, im->multiaddr); 1255 igmpv3_del_delrec(in_dev, im->multiaddr);
@@ -1821,7 +1821,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
1821 iml->next_rcu = inet->mc_list; 1821 iml->next_rcu = inet->mc_list;
1822 iml->sflist = NULL; 1822 iml->sflist = NULL;
1823 iml->sfmode = MCAST_EXCLUDE; 1823 iml->sfmode = MCAST_EXCLUDE;
1824 RCU_INIT_POINTER(inet->mc_list, iml); 1824 rcu_assign_pointer(inet->mc_list, iml);
1825 ip_mc_inc_group(in_dev, addr); 1825 ip_mc_inc_group(in_dev, addr);
1826 err = 0; 1826 err = 0;
1827done: 1827done:
@@ -2008,7 +2008,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
2008 atomic_sub(IP_SFLSIZE(psl->sl_max), &sk->sk_omem_alloc); 2008 atomic_sub(IP_SFLSIZE(psl->sl_max), &sk->sk_omem_alloc);
2009 kfree_rcu(psl, rcu); 2009 kfree_rcu(psl, rcu);
2010 } 2010 }
2011 RCU_INIT_POINTER(pmc->sflist, newpsl); 2011 rcu_assign_pointer(pmc->sflist, newpsl);
2012 psl = newpsl; 2012 psl = newpsl;
2013 } 2013 }
2014 rv = 1; /* > 0 for insert logic below if sl_count is 0 */ 2014 rv = 1; /* > 0 for insert logic below if sl_count is 0 */
@@ -2111,7 +2111,7 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex)
2111 } else 2111 } else
2112 (void) ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode, 2112 (void) ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode,
2113 0, NULL, 0); 2113 0, NULL, 0);
2114 RCU_INIT_POINTER(pmc->sflist, newpsl); 2114 rcu_assign_pointer(pmc->sflist, newpsl);
2115 pmc->sfmode = msf->imsf_fmode; 2115 pmc->sfmode = msf->imsf_fmode;
2116 err = 0; 2116 err = 0;
2117done: 2117done:
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 2240a8e8c44d..fcf281819cd4 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -71,7 +71,7 @@ static inline void inet_diag_unlock_handler(
71} 71}
72 72
73int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk, 73int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
74 struct sk_buff *skb, struct inet_diag_req *req, 74 struct sk_buff *skb, struct inet_diag_req_v2 *req,
75 u32 pid, u32 seq, u16 nlmsg_flags, 75 u32 pid, u32 seq, u16 nlmsg_flags,
76 const struct nlmsghdr *unlh) 76 const struct nlmsghdr *unlh)
77{ 77{
@@ -193,7 +193,7 @@ nlmsg_failure:
193EXPORT_SYMBOL_GPL(inet_sk_diag_fill); 193EXPORT_SYMBOL_GPL(inet_sk_diag_fill);
194 194
195static int inet_csk_diag_fill(struct sock *sk, 195static int inet_csk_diag_fill(struct sock *sk,
196 struct sk_buff *skb, struct inet_diag_req *req, 196 struct sk_buff *skb, struct inet_diag_req_v2 *req,
197 u32 pid, u32 seq, u16 nlmsg_flags, 197 u32 pid, u32 seq, u16 nlmsg_flags,
198 const struct nlmsghdr *unlh) 198 const struct nlmsghdr *unlh)
199{ 199{
@@ -202,7 +202,7 @@ static int inet_csk_diag_fill(struct sock *sk,
202} 202}
203 203
204static int inet_twsk_diag_fill(struct inet_timewait_sock *tw, 204static int inet_twsk_diag_fill(struct inet_timewait_sock *tw,
205 struct sk_buff *skb, struct inet_diag_req *req, 205 struct sk_buff *skb, struct inet_diag_req_v2 *req,
206 u32 pid, u32 seq, u16 nlmsg_flags, 206 u32 pid, u32 seq, u16 nlmsg_flags,
207 const struct nlmsghdr *unlh) 207 const struct nlmsghdr *unlh)
208{ 208{
@@ -253,7 +253,7 @@ nlmsg_failure:
253} 253}
254 254
255static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, 255static int sk_diag_fill(struct sock *sk, struct sk_buff *skb,
256 struct inet_diag_req *r, u32 pid, u32 seq, u16 nlmsg_flags, 256 struct inet_diag_req_v2 *r, u32 pid, u32 seq, u16 nlmsg_flags,
257 const struct nlmsghdr *unlh) 257 const struct nlmsghdr *unlh)
258{ 258{
259 if (sk->sk_state == TCP_TIME_WAIT) 259 if (sk->sk_state == TCP_TIME_WAIT)
@@ -264,7 +264,7 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb,
264} 264}
265 265
266int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *in_skb, 266int inet_diag_dump_one_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *in_skb,
267 const struct nlmsghdr *nlh, struct inet_diag_req *req) 267 const struct nlmsghdr *nlh, struct inet_diag_req_v2 *req)
268{ 268{
269 int err; 269 int err;
270 struct sock *sk; 270 struct sock *sk;
@@ -333,7 +333,7 @@ EXPORT_SYMBOL_GPL(inet_diag_dump_one_icsk);
333 333
334static int inet_diag_get_exact(struct sk_buff *in_skb, 334static int inet_diag_get_exact(struct sk_buff *in_skb,
335 const struct nlmsghdr *nlh, 335 const struct nlmsghdr *nlh,
336 struct inet_diag_req *req) 336 struct inet_diag_req_v2 *req)
337{ 337{
338 const struct inet_diag_handler *handler; 338 const struct inet_diag_handler *handler;
339 int err; 339 int err;
@@ -540,7 +540,7 @@ static int inet_diag_bc_audit(const void *bytecode, int bytecode_len)
540static int inet_csk_diag_dump(struct sock *sk, 540static int inet_csk_diag_dump(struct sock *sk,
541 struct sk_buff *skb, 541 struct sk_buff *skb,
542 struct netlink_callback *cb, 542 struct netlink_callback *cb,
543 struct inet_diag_req *r, 543 struct inet_diag_req_v2 *r,
544 const struct nlattr *bc) 544 const struct nlattr *bc)
545{ 545{
546 if (!inet_diag_bc_sk(bc, sk)) 546 if (!inet_diag_bc_sk(bc, sk))
@@ -554,7 +554,7 @@ static int inet_csk_diag_dump(struct sock *sk,
554static int inet_twsk_diag_dump(struct inet_timewait_sock *tw, 554static int inet_twsk_diag_dump(struct inet_timewait_sock *tw,
555 struct sk_buff *skb, 555 struct sk_buff *skb,
556 struct netlink_callback *cb, 556 struct netlink_callback *cb,
557 struct inet_diag_req *r, 557 struct inet_diag_req_v2 *r,
558 const struct nlattr *bc) 558 const struct nlattr *bc)
559{ 559{
560 if (bc != NULL) { 560 if (bc != NULL) {
@@ -639,7 +639,7 @@ nlmsg_failure:
639 639
640static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk, 640static int inet_diag_dump_reqs(struct sk_buff *skb, struct sock *sk,
641 struct netlink_callback *cb, 641 struct netlink_callback *cb,
642 struct inet_diag_req *r, 642 struct inet_diag_req_v2 *r,
643 const struct nlattr *bc) 643 const struct nlattr *bc)
644{ 644{
645 struct inet_diag_entry entry; 645 struct inet_diag_entry entry;
@@ -721,7 +721,7 @@ out:
721} 721}
722 722
723void inet_diag_dump_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *skb, 723void inet_diag_dump_icsk(struct inet_hashinfo *hashinfo, struct sk_buff *skb,
724 struct netlink_callback *cb, struct inet_diag_req *r, struct nlattr *bc) 724 struct netlink_callback *cb, struct inet_diag_req_v2 *r, struct nlattr *bc)
725{ 725{
726 int i, num; 726 int i, num;
727 int s_i, s_num; 727 int s_i, s_num;
@@ -872,7 +872,7 @@ out:
872EXPORT_SYMBOL_GPL(inet_diag_dump_icsk); 872EXPORT_SYMBOL_GPL(inet_diag_dump_icsk);
873 873
874static int __inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, 874static int __inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
875 struct inet_diag_req *r, struct nlattr *bc) 875 struct inet_diag_req_v2 *r, struct nlattr *bc)
876{ 876{
877 const struct inet_diag_handler *handler; 877 const struct inet_diag_handler *handler;
878 878
@@ -887,12 +887,12 @@ static int __inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
887static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) 887static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
888{ 888{
889 struct nlattr *bc = NULL; 889 struct nlattr *bc = NULL;
890 int hdrlen = sizeof(struct inet_diag_req); 890 int hdrlen = sizeof(struct inet_diag_req_v2);
891 891
892 if (nlmsg_attrlen(cb->nlh, hdrlen)) 892 if (nlmsg_attrlen(cb->nlh, hdrlen))
893 bc = nlmsg_find_attr(cb->nlh, hdrlen, INET_DIAG_REQ_BYTECODE); 893 bc = nlmsg_find_attr(cb->nlh, hdrlen, INET_DIAG_REQ_BYTECODE);
894 894
895 return __inet_diag_dump(skb, cb, (struct inet_diag_req *)NLMSG_DATA(cb->nlh), bc); 895 return __inet_diag_dump(skb, cb, (struct inet_diag_req_v2 *)NLMSG_DATA(cb->nlh), bc);
896} 896}
897 897
898static inline int inet_diag_type2proto(int type) 898static inline int inet_diag_type2proto(int type)
@@ -909,10 +909,10 @@ static inline int inet_diag_type2proto(int type)
909 909
910static int inet_diag_dump_compat(struct sk_buff *skb, struct netlink_callback *cb) 910static int inet_diag_dump_compat(struct sk_buff *skb, struct netlink_callback *cb)
911{ 911{
912 struct inet_diag_req_compat *rc = NLMSG_DATA(cb->nlh); 912 struct inet_diag_req *rc = NLMSG_DATA(cb->nlh);
913 struct inet_diag_req req; 913 struct inet_diag_req_v2 req;
914 struct nlattr *bc = NULL; 914 struct nlattr *bc = NULL;
915 int hdrlen = sizeof(struct inet_diag_req_compat); 915 int hdrlen = sizeof(struct inet_diag_req);
916 916
917 req.sdiag_family = AF_UNSPEC; /* compatibility */ 917 req.sdiag_family = AF_UNSPEC; /* compatibility */
918 req.sdiag_protocol = inet_diag_type2proto(cb->nlh->nlmsg_type); 918 req.sdiag_protocol = inet_diag_type2proto(cb->nlh->nlmsg_type);
@@ -929,8 +929,8 @@ static int inet_diag_dump_compat(struct sk_buff *skb, struct netlink_callback *c
929static int inet_diag_get_exact_compat(struct sk_buff *in_skb, 929static int inet_diag_get_exact_compat(struct sk_buff *in_skb,
930 const struct nlmsghdr *nlh) 930 const struct nlmsghdr *nlh)
931{ 931{
932 struct inet_diag_req_compat *rc = NLMSG_DATA(nlh); 932 struct inet_diag_req *rc = NLMSG_DATA(nlh);
933 struct inet_diag_req req; 933 struct inet_diag_req_v2 req;
934 934
935 req.sdiag_family = rc->idiag_family; 935 req.sdiag_family = rc->idiag_family;
936 req.sdiag_protocol = inet_diag_type2proto(nlh->nlmsg_type); 936 req.sdiag_protocol = inet_diag_type2proto(nlh->nlmsg_type);
@@ -943,7 +943,7 @@ static int inet_diag_get_exact_compat(struct sk_buff *in_skb,
943 943
944static int inet_diag_rcv_msg_compat(struct sk_buff *skb, struct nlmsghdr *nlh) 944static int inet_diag_rcv_msg_compat(struct sk_buff *skb, struct nlmsghdr *nlh)
945{ 945{
946 int hdrlen = sizeof(struct inet_diag_req_compat); 946 int hdrlen = sizeof(struct inet_diag_req);
947 947
948 if (nlh->nlmsg_type >= INET_DIAG_GETSOCK_MAX || 948 if (nlh->nlmsg_type >= INET_DIAG_GETSOCK_MAX ||
949 nlmsg_len(nlh) < hdrlen) 949 nlmsg_len(nlh) < hdrlen)
@@ -970,7 +970,7 @@ static int inet_diag_rcv_msg_compat(struct sk_buff *skb, struct nlmsghdr *nlh)
970 970
971static int inet_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h) 971static int inet_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h)
972{ 972{
973 int hdrlen = sizeof(struct inet_diag_req); 973 int hdrlen = sizeof(struct inet_diag_req_v2);
974 974
975 if (nlmsg_len(h) < hdrlen) 975 if (nlmsg_len(h) < hdrlen)
976 return -EINVAL; 976 return -EINVAL;
@@ -990,7 +990,7 @@ static int inet_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h)
990 inet_diag_dump, NULL, 0); 990 inet_diag_dump, NULL, 0);
991 } 991 }
992 992
993 return inet_diag_get_exact(skb, h, (struct inet_diag_req *)NLMSG_DATA(h)); 993 return inet_diag_get_exact(skb, h, (struct inet_diag_req_v2 *)NLMSG_DATA(h));
994} 994}
995 995
996static struct sock_diag_handler inet_diag_handler = { 996static struct sock_diag_handler inet_diag_handler = {
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 413ed1ba7a5a..22a199315309 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -231,7 +231,7 @@ static void ipip_tunnel_unlink(struct ipip_net *ipn, struct ip_tunnel *t)
231 (iter = rtnl_dereference(*tp)) != NULL; 231 (iter = rtnl_dereference(*tp)) != NULL;
232 tp = &iter->next) { 232 tp = &iter->next) {
233 if (t == iter) { 233 if (t == iter) {
234 RCU_INIT_POINTER(*tp, t->next); 234 rcu_assign_pointer(*tp, t->next);
235 break; 235 break;
236 } 236 }
237 } 237 }
@@ -241,8 +241,8 @@ static void ipip_tunnel_link(struct ipip_net *ipn, struct ip_tunnel *t)
241{ 241{
242 struct ip_tunnel __rcu **tp = ipip_bucket(ipn, t); 242 struct ip_tunnel __rcu **tp = ipip_bucket(ipn, t);
243 243
244 RCU_INIT_POINTER(t->next, rtnl_dereference(*tp)); 244 rcu_assign_pointer(t->next, rtnl_dereference(*tp));
245 RCU_INIT_POINTER(*tp, t); 245 rcu_assign_pointer(*tp, t);
246} 246}
247 247
248static struct ip_tunnel * ipip_tunnel_locate(struct net *net, 248static struct ip_tunnel * ipip_tunnel_locate(struct net *net,
@@ -792,7 +792,7 @@ static int __net_init ipip_fb_tunnel_init(struct net_device *dev)
792 return -ENOMEM; 792 return -ENOMEM;
793 793
794 dev_hold(dev); 794 dev_hold(dev);
795 RCU_INIT_POINTER(ipn->tunnels_wc[0], tunnel); 795 rcu_assign_pointer(ipn->tunnels_wc[0], tunnel);
796 return 0; 796 return 0;
797} 797}
798 798
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 8e54490ee3f4..7bc2db6db8d4 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1225,7 +1225,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, unsi
1225 1225
1226 ret = ip_ra_control(sk, 1, mrtsock_destruct); 1226 ret = ip_ra_control(sk, 1, mrtsock_destruct);
1227 if (ret == 0) { 1227 if (ret == 0) {
1228 RCU_INIT_POINTER(mrt->mroute_sk, sk); 1228 rcu_assign_pointer(mrt->mroute_sk, sk);
1229 IPV4_DEVCONF_ALL(net, MC_FORWARDING)++; 1229 IPV4_DEVCONF_ALL(net, MC_FORWARDING)++;
1230 } 1230 }
1231 rtnl_unlock(); 1231 rtnl_unlock();
diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c
index 8cd357a8be79..ed3f2ad42e0f 100644
--- a/net/ipv4/tcp_diag.c
+++ b/net/ipv4/tcp_diag.c
@@ -35,13 +35,13 @@ static void tcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
35} 35}
36 36
37static void tcp_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, 37static void tcp_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
38 struct inet_diag_req *r, struct nlattr *bc) 38 struct inet_diag_req_v2 *r, struct nlattr *bc)
39{ 39{
40 inet_diag_dump_icsk(&tcp_hashinfo, skb, cb, r, bc); 40 inet_diag_dump_icsk(&tcp_hashinfo, skb, cb, r, bc);
41} 41}
42 42
43static int tcp_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh, 43static int tcp_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh,
44 struct inet_diag_req *req) 44 struct inet_diag_req_v2 *req)
45{ 45{
46 return inet_diag_dump_one_icsk(&tcp_hashinfo, in_skb, nlh, req); 46 return inet_diag_dump_one_icsk(&tcp_hashinfo, in_skb, nlh, req);
47} 47}
diff --git a/net/ipv4/tcp_memcontrol.c b/net/ipv4/tcp_memcontrol.c
index 7fed04f875c1..49978788a9dc 100644
--- a/net/ipv4/tcp_memcontrol.c
+++ b/net/ipv4/tcp_memcontrol.c
@@ -108,7 +108,7 @@ void tcp_destroy_cgroup(struct cgroup *cgrp, struct cgroup_subsys *ss)
108 tcp = tcp_from_cgproto(cg_proto); 108 tcp = tcp_from_cgproto(cg_proto);
109 percpu_counter_destroy(&tcp->tcp_sockets_allocated); 109 percpu_counter_destroy(&tcp->tcp_sockets_allocated);
110 110
111 val = res_counter_read_u64(&tcp->tcp_memory_allocated, RES_USAGE); 111 val = res_counter_read_u64(&tcp->tcp_memory_allocated, RES_LIMIT);
112 112
113 if (val != RESOURCE_MAX) 113 if (val != RESOURCE_MAX)
114 jump_label_dec(&memcg_socket_limit_enabled); 114 jump_label_dec(&memcg_socket_limit_enabled);
diff --git a/net/ipv4/udp_diag.c b/net/ipv4/udp_diag.c
index 69f8a7ca63dd..e5e18cb8a586 100644
--- a/net/ipv4/udp_diag.c
+++ b/net/ipv4/udp_diag.c
@@ -19,7 +19,7 @@
19#include <linux/sock_diag.h> 19#include <linux/sock_diag.h>
20 20
21static int sk_diag_dump(struct sock *sk, struct sk_buff *skb, 21static int sk_diag_dump(struct sock *sk, struct sk_buff *skb,
22 struct netlink_callback *cb, struct inet_diag_req *req, 22 struct netlink_callback *cb, struct inet_diag_req_v2 *req,
23 struct nlattr *bc) 23 struct nlattr *bc)
24{ 24{
25 if (!inet_diag_bc_sk(bc, sk)) 25 if (!inet_diag_bc_sk(bc, sk))
@@ -30,7 +30,7 @@ static int sk_diag_dump(struct sock *sk, struct sk_buff *skb,
30} 30}
31 31
32static int udp_dump_one(struct udp_table *tbl, struct sk_buff *in_skb, 32static int udp_dump_one(struct udp_table *tbl, struct sk_buff *in_skb,
33 const struct nlmsghdr *nlh, struct inet_diag_req *req) 33 const struct nlmsghdr *nlh, struct inet_diag_req_v2 *req)
34{ 34{
35 int err = -EINVAL; 35 int err = -EINVAL;
36 struct sock *sk; 36 struct sock *sk;
@@ -88,7 +88,7 @@ out_nosk:
88} 88}
89 89
90static void udp_dump(struct udp_table *table, struct sk_buff *skb, struct netlink_callback *cb, 90static void udp_dump(struct udp_table *table, struct sk_buff *skb, struct netlink_callback *cb,
91 struct inet_diag_req *r, struct nlattr *bc) 91 struct inet_diag_req_v2 *r, struct nlattr *bc)
92{ 92{
93 int num, s_num, slot, s_slot; 93 int num, s_num, slot, s_slot;
94 94
@@ -136,13 +136,13 @@ done:
136} 136}
137 137
138static void udp_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, 138static void udp_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
139 struct inet_diag_req *r, struct nlattr *bc) 139 struct inet_diag_req_v2 *r, struct nlattr *bc)
140{ 140{
141 udp_dump(&udp_table, skb, cb, r, bc); 141 udp_dump(&udp_table, skb, cb, r, bc);
142} 142}
143 143
144static int udp_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh, 144static int udp_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh,
145 struct inet_diag_req *req) 145 struct inet_diag_req_v2 *req)
146{ 146{
147 return udp_dump_one(&udp_table, in_skb, nlh, req); 147 return udp_dump_one(&udp_table, in_skb, nlh, req);
148} 148}
@@ -154,13 +154,13 @@ static const struct inet_diag_handler udp_diag_handler = {
154}; 154};
155 155
156static void udplite_diag_dump(struct sk_buff *skb, struct netlink_callback *cb, 156static void udplite_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
157 struct inet_diag_req *r, struct nlattr *bc) 157 struct inet_diag_req_v2 *r, struct nlattr *bc)
158{ 158{
159 udp_dump(&udplite_table, skb, cb, r, bc); 159 udp_dump(&udplite_table, skb, cb, r, bc);
160} 160}
161 161
162static int udplite_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh, 162static int udplite_diag_dump_one(struct sk_buff *in_skb, const struct nlmsghdr *nlh,
163 struct inet_diag_req *req) 163 struct inet_diag_req_v2 *req)
164{ 164{
165 return udp_dump_one(&udplite_table, in_skb, nlh, req); 165 return udp_dump_one(&udplite_table, in_skb, nlh, req);
166} 166}
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 0ba0866230c9..a225d5ee3c2f 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -429,7 +429,7 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
429 ndev->tstamp = jiffies; 429 ndev->tstamp = jiffies;
430 addrconf_sysctl_register(ndev); 430 addrconf_sysctl_register(ndev);
431 /* protected by rtnl_lock */ 431 /* protected by rtnl_lock */
432 RCU_INIT_POINTER(dev->ip6_ptr, ndev); 432 rcu_assign_pointer(dev->ip6_ptr, ndev);
433 433
434 /* Join all-node multicast group */ 434 /* Join all-node multicast group */
435 ipv6_dev_mc_inc(dev, &in6addr_linklocal_allnodes); 435 ipv6_dev_mc_inc(dev, &in6addr_linklocal_allnodes);
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index e1f7761815f3..aa21da6a09cd 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -218,8 +218,8 @@ ip6_tnl_link(struct ip6_tnl_net *ip6n, struct ip6_tnl *t)
218{ 218{
219 struct ip6_tnl __rcu **tp = ip6_tnl_bucket(ip6n, &t->parms); 219 struct ip6_tnl __rcu **tp = ip6_tnl_bucket(ip6n, &t->parms);
220 220
221 RCU_INIT_POINTER(t->next , rtnl_dereference(*tp)); 221 rcu_assign_pointer(t->next , rtnl_dereference(*tp));
222 RCU_INIT_POINTER(*tp, t); 222 rcu_assign_pointer(*tp, t);
223} 223}
224 224
225/** 225/**
@@ -237,7 +237,7 @@ ip6_tnl_unlink(struct ip6_tnl_net *ip6n, struct ip6_tnl *t)
237 (iter = rtnl_dereference(*tp)) != NULL; 237 (iter = rtnl_dereference(*tp)) != NULL;
238 tp = &iter->next) { 238 tp = &iter->next) {
239 if (t == iter) { 239 if (t == iter) {
240 RCU_INIT_POINTER(*tp, t->next); 240 rcu_assign_pointer(*tp, t->next);
241 break; 241 break;
242 } 242 }
243 } 243 }
@@ -1450,7 +1450,7 @@ static int __net_init ip6_fb_tnl_dev_init(struct net_device *dev)
1450 1450
1451 t->parms.proto = IPPROTO_IPV6; 1451 t->parms.proto = IPPROTO_IPV6;
1452 dev_hold(dev); 1452 dev_hold(dev);
1453 RCU_INIT_POINTER(ip6n->tnls_wc[0], t); 1453 rcu_assign_pointer(ip6n->tnls_wc[0], t);
1454 return 0; 1454 return 0;
1455} 1455}
1456 1456
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index a4894f4f1944..d02f7e4dd611 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -131,7 +131,7 @@ static mh_filter_t __rcu *mh_filter __read_mostly;
131 131
132int rawv6_mh_filter_register(mh_filter_t filter) 132int rawv6_mh_filter_register(mh_filter_t filter)
133{ 133{
134 RCU_INIT_POINTER(mh_filter, filter); 134 rcu_assign_pointer(mh_filter, filter);
135 return 0; 135 return 0;
136} 136}
137EXPORT_SYMBOL(rawv6_mh_filter_register); 137EXPORT_SYMBOL(rawv6_mh_filter_register);
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 3b6dac956bb0..133768e52912 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -182,7 +182,7 @@ static void ipip6_tunnel_unlink(struct sit_net *sitn, struct ip_tunnel *t)
182 (iter = rtnl_dereference(*tp)) != NULL; 182 (iter = rtnl_dereference(*tp)) != NULL;
183 tp = &iter->next) { 183 tp = &iter->next) {
184 if (t == iter) { 184 if (t == iter) {
185 RCU_INIT_POINTER(*tp, t->next); 185 rcu_assign_pointer(*tp, t->next);
186 break; 186 break;
187 } 187 }
188 } 188 }
@@ -192,8 +192,8 @@ static void ipip6_tunnel_link(struct sit_net *sitn, struct ip_tunnel *t)
192{ 192{
193 struct ip_tunnel __rcu **tp = ipip6_bucket(sitn, t); 193 struct ip_tunnel __rcu **tp = ipip6_bucket(sitn, t);
194 194
195 RCU_INIT_POINTER(t->next, rtnl_dereference(*tp)); 195 rcu_assign_pointer(t->next, rtnl_dereference(*tp));
196 RCU_INIT_POINTER(*tp, t); 196 rcu_assign_pointer(*tp, t);
197} 197}
198 198
199static void ipip6_tunnel_clone_6rd(struct net_device *dev, struct sit_net *sitn) 199static void ipip6_tunnel_clone_6rd(struct net_device *dev, struct sit_net *sitn)
@@ -393,7 +393,7 @@ ipip6_tunnel_add_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a, int chg)
393 p->addr = a->addr; 393 p->addr = a->addr;
394 p->flags = a->flags; 394 p->flags = a->flags;
395 t->prl_count++; 395 t->prl_count++;
396 RCU_INIT_POINTER(t->prl, p); 396 rcu_assign_pointer(t->prl, p);
397out: 397out:
398 return err; 398 return err;
399} 399}
@@ -1177,7 +1177,7 @@ static int __net_init ipip6_fb_tunnel_init(struct net_device *dev)
1177 if (!dev->tstats) 1177 if (!dev->tstats)
1178 return -ENOMEM; 1178 return -ENOMEM;
1179 dev_hold(dev); 1179 dev_hold(dev);
1180 RCU_INIT_POINTER(sitn->tunnels_wc[0], tunnel); 1180 rcu_assign_pointer(sitn->tunnels_wc[0], tunnel);
1181 return 0; 1181 return 0;
1182} 1182}
1183 1183
diff --git a/net/mac80211/agg-rx.c b/net/mac80211/agg-rx.c
index 96debba2c407..1068f668ac4e 100644
--- a/net/mac80211/agg-rx.c
+++ b/net/mac80211/agg-rx.c
@@ -332,7 +332,7 @@ void ieee80211_process_addba_request(struct ieee80211_local *local,
332 status = WLAN_STATUS_SUCCESS; 332 status = WLAN_STATUS_SUCCESS;
333 333
334 /* activate it for RX */ 334 /* activate it for RX */
335 RCU_INIT_POINTER(sta->ampdu_mlme.tid_rx[tid], tid_agg_rx); 335 rcu_assign_pointer(sta->ampdu_mlme.tid_rx[tid], tid_agg_rx);
336 336
337 if (timeout) 337 if (timeout)
338 mod_timer(&tid_agg_rx->session_timer, TU_TO_EXP_TIME(timeout)); 338 mod_timer(&tid_agg_rx->session_timer, TU_TO_EXP_TIME(timeout));
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 850bb96bd680..e60df48fa4d4 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -616,7 +616,7 @@ static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata,
616 616
617 sdata->vif.bss_conf.dtim_period = new->dtim_period; 617 sdata->vif.bss_conf.dtim_period = new->dtim_period;
618 618
619 RCU_INIT_POINTER(sdata->u.ap.beacon, new); 619 rcu_assign_pointer(sdata->u.ap.beacon, new);
620 620
621 synchronize_rcu(); 621 synchronize_rcu();
622 622
@@ -1033,7 +1033,7 @@ static int ieee80211_change_station(struct wiphy *wiphy,
1033 return -EBUSY; 1033 return -EBUSY;
1034 } 1034 }
1035 1035
1036 RCU_INIT_POINTER(vlansdata->u.vlan.sta, sta); 1036 rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
1037 } 1037 }
1038 1038
1039 sta->sdata = vlansdata; 1039 sta->sdata = vlansdata;
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index f8a32bf98216..b3d76b756cd5 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -207,7 +207,7 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
207 *pos++ = 0; /* U-APSD no in use */ 207 *pos++ = 0; /* U-APSD no in use */
208 } 208 }
209 209
210 RCU_INIT_POINTER(ifibss->presp, skb); 210 rcu_assign_pointer(ifibss->presp, skb);
211 211
212 sdata->vif.bss_conf.beacon_int = beacon_int; 212 sdata->vif.bss_conf.beacon_int = beacon_int;
213 sdata->vif.bss_conf.basic_rates = basic_rates; 213 sdata->vif.bss_conf.basic_rates = basic_rates;
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index b197136aea2c..3c428d4839c7 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -73,7 +73,7 @@ static int sta_info_hash_del(struct ieee80211_local *local,
73 if (!s) 73 if (!s)
74 return -ENOENT; 74 return -ENOENT;
75 if (s == sta) { 75 if (s == sta) {
76 RCU_INIT_POINTER(local->sta_hash[STA_HASH(sta->sta.addr)], 76 rcu_assign_pointer(local->sta_hash[STA_HASH(sta->sta.addr)],
77 s->hnext); 77 s->hnext);
78 return 0; 78 return 0;
79 } 79 }
@@ -83,7 +83,7 @@ static int sta_info_hash_del(struct ieee80211_local *local,
83 s = rcu_dereference_protected(s->hnext, 83 s = rcu_dereference_protected(s->hnext,
84 lockdep_is_held(&local->sta_mtx)); 84 lockdep_is_held(&local->sta_mtx));
85 if (rcu_access_pointer(s->hnext)) { 85 if (rcu_access_pointer(s->hnext)) {
86 RCU_INIT_POINTER(s->hnext, sta->hnext); 86 rcu_assign_pointer(s->hnext, sta->hnext);
87 return 0; 87 return 0;
88 } 88 }
89 89
@@ -226,7 +226,7 @@ static void sta_info_hash_add(struct ieee80211_local *local,
226{ 226{
227 lockdep_assert_held(&local->sta_mtx); 227 lockdep_assert_held(&local->sta_mtx);
228 sta->hnext = local->sta_hash[STA_HASH(sta->sta.addr)]; 228 sta->hnext = local->sta_hash[STA_HASH(sta->sta.addr)];
229 RCU_INIT_POINTER(local->sta_hash[STA_HASH(sta->sta.addr)], sta); 229 rcu_assign_pointer(local->sta_hash[STA_HASH(sta->sta.addr)], sta);
230} 230}
231 231
232static void sta_unblock(struct work_struct *wk) 232static void sta_unblock(struct work_struct *wk)
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index 93aab0715e8a..422b79851ec5 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -106,7 +106,7 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
106 if (status->flag & RX_FLAG_MMIC_ERROR) 106 if (status->flag & RX_FLAG_MMIC_ERROR)
107 goto mic_fail; 107 goto mic_fail;
108 108
109 if (!(status->flag & RX_FLAG_IV_STRIPPED)) 109 if (!(status->flag & RX_FLAG_IV_STRIPPED) && rx->key)
110 goto update_iv; 110 goto update_iv;
111 111
112 return RX_CONTINUE; 112 return RX_CONTINUE;
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index e875f8902db3..76613f5a55c0 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -777,7 +777,7 @@ init_conntrack(struct net *net, struct nf_conn *tmpl,
777 if (exp->helper) { 777 if (exp->helper) {
778 help = nf_ct_helper_ext_add(ct, GFP_ATOMIC); 778 help = nf_ct_helper_ext_add(ct, GFP_ATOMIC);
779 if (help) 779 if (help)
780 RCU_INIT_POINTER(help->helper, exp->helper); 780 rcu_assign_pointer(help->helper, exp->helper);
781 } 781 }
782 782
783#ifdef CONFIG_NF_CONNTRACK_MARK 783#ifdef CONFIG_NF_CONNTRACK_MARK
diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
index b62c4148b921..14af6329bdda 100644
--- a/net/netfilter/nf_conntrack_ecache.c
+++ b/net/netfilter/nf_conntrack_ecache.c
@@ -91,7 +91,7 @@ int nf_conntrack_register_notifier(struct net *net,
91 ret = -EBUSY; 91 ret = -EBUSY;
92 goto out_unlock; 92 goto out_unlock;
93 } 93 }
94 RCU_INIT_POINTER(net->ct.nf_conntrack_event_cb, new); 94 rcu_assign_pointer(net->ct.nf_conntrack_event_cb, new);
95 mutex_unlock(&nf_ct_ecache_mutex); 95 mutex_unlock(&nf_ct_ecache_mutex);
96 return ret; 96 return ret;
97 97
@@ -128,7 +128,7 @@ int nf_ct_expect_register_notifier(struct net *net,
128 ret = -EBUSY; 128 ret = -EBUSY;
129 goto out_unlock; 129 goto out_unlock;
130 } 130 }
131 RCU_INIT_POINTER(net->ct.nf_expect_event_cb, new); 131 rcu_assign_pointer(net->ct.nf_expect_event_cb, new);
132 mutex_unlock(&nf_ct_ecache_mutex); 132 mutex_unlock(&nf_ct_ecache_mutex);
133 return ret; 133 return ret;
134 134
diff --git a/net/netfilter/nf_conntrack_extend.c b/net/netfilter/nf_conntrack_extend.c
index 4605c947dcc4..641ff5f96718 100644
--- a/net/netfilter/nf_conntrack_extend.c
+++ b/net/netfilter/nf_conntrack_extend.c
@@ -169,7 +169,7 @@ int nf_ct_extend_register(struct nf_ct_ext_type *type)
169 before updating alloc_size */ 169 before updating alloc_size */
170 type->alloc_size = ALIGN(sizeof(struct nf_ct_ext), type->align) 170 type->alloc_size = ALIGN(sizeof(struct nf_ct_ext), type->align)
171 + type->len; 171 + type->len;
172 RCU_INIT_POINTER(nf_ct_ext_types[type->id], type); 172 rcu_assign_pointer(nf_ct_ext_types[type->id], type);
173 update_alloc_size(type); 173 update_alloc_size(type);
174out: 174out:
175 mutex_unlock(&nf_ct_ext_type_mutex); 175 mutex_unlock(&nf_ct_ext_type_mutex);
diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
index c9e0de08aa87..299fec91f741 100644
--- a/net/netfilter/nf_conntrack_helper.c
+++ b/net/netfilter/nf_conntrack_helper.c
@@ -157,7 +157,7 @@ int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl,
157 memset(&help->help, 0, sizeof(help->help)); 157 memset(&help->help, 0, sizeof(help->help));
158 } 158 }
159 159
160 RCU_INIT_POINTER(help->helper, helper); 160 rcu_assign_pointer(help->helper, helper);
161out: 161out:
162 return ret; 162 return ret;
163} 163}
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index e07dc3ae930e..2a4834b83332 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1172,7 +1172,7 @@ ctnetlink_change_helper(struct nf_conn *ct, const struct nlattr * const cda[])
1172 return -EOPNOTSUPP; 1172 return -EOPNOTSUPP;
1173 } 1173 }
1174 1174
1175 RCU_INIT_POINTER(help->helper, helper); 1175 rcu_assign_pointer(help->helper, helper);
1176 1176
1177 return 0; 1177 return 0;
1178} 1178}
diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
index ce0c406f58a8..957374a234d4 100644
--- a/net/netfilter/nf_log.c
+++ b/net/netfilter/nf_log.c
@@ -55,7 +55,7 @@ int nf_log_register(u_int8_t pf, struct nf_logger *logger)
55 llog = rcu_dereference_protected(nf_loggers[pf], 55 llog = rcu_dereference_protected(nf_loggers[pf],
56 lockdep_is_held(&nf_log_mutex)); 56 lockdep_is_held(&nf_log_mutex));
57 if (llog == NULL) 57 if (llog == NULL)
58 RCU_INIT_POINTER(nf_loggers[pf], logger); 58 rcu_assign_pointer(nf_loggers[pf], logger);
59 } 59 }
60 60
61 mutex_unlock(&nf_log_mutex); 61 mutex_unlock(&nf_log_mutex);
@@ -92,7 +92,7 @@ int nf_log_bind_pf(u_int8_t pf, const struct nf_logger *logger)
92 mutex_unlock(&nf_log_mutex); 92 mutex_unlock(&nf_log_mutex);
93 return -ENOENT; 93 return -ENOENT;
94 } 94 }
95 RCU_INIT_POINTER(nf_loggers[pf], logger); 95 rcu_assign_pointer(nf_loggers[pf], logger);
96 mutex_unlock(&nf_log_mutex); 96 mutex_unlock(&nf_log_mutex);
97 return 0; 97 return 0;
98} 98}
@@ -250,7 +250,7 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
250 mutex_unlock(&nf_log_mutex); 250 mutex_unlock(&nf_log_mutex);
251 return -ENOENT; 251 return -ENOENT;
252 } 252 }
253 RCU_INIT_POINTER(nf_loggers[tindex], logger); 253 rcu_assign_pointer(nf_loggers[tindex], logger);
254 mutex_unlock(&nf_log_mutex); 254 mutex_unlock(&nf_log_mutex);
255 } else { 255 } else {
256 mutex_lock(&nf_log_mutex); 256 mutex_lock(&nf_log_mutex);
diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
index 99ffd2885088..b3a7db678b8d 100644
--- a/net/netfilter/nf_queue.c
+++ b/net/netfilter/nf_queue.c
@@ -40,7 +40,7 @@ int nf_register_queue_handler(u_int8_t pf, const struct nf_queue_handler *qh)
40 else if (old) 40 else if (old)
41 ret = -EBUSY; 41 ret = -EBUSY;
42 else { 42 else {
43 RCU_INIT_POINTER(queue_handler[pf], qh); 43 rcu_assign_pointer(queue_handler[pf], qh);
44 ret = 0; 44 ret = 0;
45 } 45 }
46 mutex_unlock(&queue_handler_mutex); 46 mutex_unlock(&queue_handler_mutex);
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index c879c1a2370e..b4f8d849480c 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -59,7 +59,7 @@ int nfnetlink_subsys_register(const struct nfnetlink_subsystem *n)
59 nfnl_unlock(); 59 nfnl_unlock();
60 return -EBUSY; 60 return -EBUSY;
61 } 61 }
62 RCU_INIT_POINTER(subsys_table[n->subsys_id], n); 62 rcu_assign_pointer(subsys_table[n->subsys_id], n);
63 nfnl_unlock(); 63 nfnl_unlock();
64 64
65 return 0; 65 return 0;
@@ -210,7 +210,7 @@ static int __net_init nfnetlink_net_init(struct net *net)
210 if (!nfnl) 210 if (!nfnl)
211 return -ENOMEM; 211 return -ENOMEM;
212 net->nfnl_stash = nfnl; 212 net->nfnl_stash = nfnl;
213 RCU_INIT_POINTER(net->nfnl, nfnl); 213 rcu_assign_pointer(net->nfnl, nfnl);
214 return 0; 214 return 0;
215} 215}
216 216
diff --git a/net/netlabel/netlabel_domainhash.c b/net/netlabel/netlabel_domainhash.c
index 38204112b9f4..d8d424337550 100644
--- a/net/netlabel/netlabel_domainhash.c
+++ b/net/netlabel/netlabel_domainhash.c
@@ -282,7 +282,7 @@ int __init netlbl_domhsh_init(u32 size)
282 INIT_LIST_HEAD(&hsh_tbl->tbl[iter]); 282 INIT_LIST_HEAD(&hsh_tbl->tbl[iter]);
283 283
284 spin_lock(&netlbl_domhsh_lock); 284 spin_lock(&netlbl_domhsh_lock);
285 RCU_INIT_POINTER(netlbl_domhsh, hsh_tbl); 285 rcu_assign_pointer(netlbl_domhsh, hsh_tbl);
286 spin_unlock(&netlbl_domhsh_lock); 286 spin_unlock(&netlbl_domhsh_lock);
287 287
288 return 0; 288 return 0;
@@ -330,7 +330,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry,
330 &rcu_dereference(netlbl_domhsh)->tbl[bkt]); 330 &rcu_dereference(netlbl_domhsh)->tbl[bkt]);
331 } else { 331 } else {
332 INIT_LIST_HEAD(&entry->list); 332 INIT_LIST_HEAD(&entry->list);
333 RCU_INIT_POINTER(netlbl_domhsh_def, entry); 333 rcu_assign_pointer(netlbl_domhsh_def, entry);
334 } 334 }
335 335
336 if (entry->type == NETLBL_NLTYPE_ADDRSELECT) { 336 if (entry->type == NETLBL_NLTYPE_ADDRSELECT) {
diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c
index 4b5fa0fe78fd..e7ff694f1049 100644
--- a/net/netlabel/netlabel_unlabeled.c
+++ b/net/netlabel/netlabel_unlabeled.c
@@ -354,7 +354,7 @@ static struct netlbl_unlhsh_iface *netlbl_unlhsh_add_iface(int ifindex)
354 INIT_LIST_HEAD(&iface->list); 354 INIT_LIST_HEAD(&iface->list);
355 if (netlbl_unlhsh_rcu_deref(netlbl_unlhsh_def) != NULL) 355 if (netlbl_unlhsh_rcu_deref(netlbl_unlhsh_def) != NULL)
356 goto add_iface_failure; 356 goto add_iface_failure;
357 RCU_INIT_POINTER(netlbl_unlhsh_def, iface); 357 rcu_assign_pointer(netlbl_unlhsh_def, iface);
358 } 358 }
359 spin_unlock(&netlbl_unlhsh_lock); 359 spin_unlock(&netlbl_unlhsh_lock);
360 360
@@ -1447,11 +1447,9 @@ int __init netlbl_unlabel_init(u32 size)
1447 for (iter = 0; iter < hsh_tbl->size; iter++) 1447 for (iter = 0; iter < hsh_tbl->size; iter++)
1448 INIT_LIST_HEAD(&hsh_tbl->tbl[iter]); 1448 INIT_LIST_HEAD(&hsh_tbl->tbl[iter]);
1449 1449
1450 rcu_read_lock();
1451 spin_lock(&netlbl_unlhsh_lock); 1450 spin_lock(&netlbl_unlhsh_lock);
1452 RCU_INIT_POINTER(netlbl_unlhsh, hsh_tbl); 1451 rcu_assign_pointer(netlbl_unlhsh, hsh_tbl);
1453 spin_unlock(&netlbl_unlhsh_lock); 1452 spin_unlock(&netlbl_unlhsh_lock);
1454 rcu_read_unlock();
1455 1453
1456 register_netdevice_notifier(&netlbl_unlhsh_netdev_notifier); 1454 register_netdevice_notifier(&netlbl_unlhsh_netdev_notifier);
1457 1455
diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
index bf10ea8fbbf9..d65f699fbf34 100644
--- a/net/phonet/af_phonet.c
+++ b/net/phonet/af_phonet.c
@@ -480,7 +480,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
480 if (proto_tab[protocol]) 480 if (proto_tab[protocol])
481 err = -EBUSY; 481 err = -EBUSY;
482 else 482 else
483 RCU_INIT_POINTER(proto_tab[protocol], pp); 483 rcu_assign_pointer(proto_tab[protocol], pp);
484 mutex_unlock(&proto_tab_lock); 484 mutex_unlock(&proto_tab_lock);
485 485
486 return err; 486 return err;
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index c5827614376b..9b9a85ecc4c7 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -390,7 +390,7 @@ int phonet_route_add(struct net_device *dev, u8 daddr)
390 daddr = daddr >> 2; 390 daddr = daddr >> 2;
391 mutex_lock(&routes->lock); 391 mutex_lock(&routes->lock);
392 if (routes->table[daddr] == NULL) { 392 if (routes->table[daddr] == NULL) {
393 RCU_INIT_POINTER(routes->table[daddr], dev); 393 rcu_assign_pointer(routes->table[daddr], dev);
394 dev_hold(dev); 394 dev_hold(dev);
395 err = 0; 395 err = 0;
396 } 396 }
diff --git a/net/phonet/socket.c b/net/phonet/socket.c
index 3f8d0b1603b9..4c7eff30dfa9 100644
--- a/net/phonet/socket.c
+++ b/net/phonet/socket.c
@@ -680,7 +680,7 @@ int pn_sock_bind_res(struct sock *sk, u8 res)
680 mutex_lock(&resource_mutex); 680 mutex_lock(&resource_mutex);
681 if (pnres.sk[res] == NULL) { 681 if (pnres.sk[res] == NULL) {
682 sock_hold(sk); 682 sock_hold(sk);
683 RCU_INIT_POINTER(pnres.sk[res], sk); 683 rcu_assign_pointer(pnres.sk[res], sk);
684 ret = 0; 684 ret = 0;
685 } 685 }
686 mutex_unlock(&resource_mutex); 686 mutex_unlock(&resource_mutex);
diff --git a/net/rds/iw_rdma.c b/net/rds/iw_rdma.c
index 4e1de171866c..a817705ce2d0 100644
--- a/net/rds/iw_rdma.c
+++ b/net/rds/iw_rdma.c
@@ -477,17 +477,6 @@ void rds_iw_sync_mr(void *trans_private, int direction)
477 } 477 }
478} 478}
479 479
480static inline unsigned int rds_iw_flush_goal(struct rds_iw_mr_pool *pool, int free_all)
481{
482 unsigned int item_count;
483
484 item_count = atomic_read(&pool->item_count);
485 if (free_all)
486 return item_count;
487
488 return 0;
489}
490
491/* 480/*
492 * Flush our pool of MRs. 481 * Flush our pool of MRs.
493 * At a minimum, all currently unused MRs are unmapped. 482 * At a minimum, all currently unused MRs are unmapped.
@@ -500,7 +489,7 @@ static int rds_iw_flush_mr_pool(struct rds_iw_mr_pool *pool, int free_all)
500 LIST_HEAD(unmap_list); 489 LIST_HEAD(unmap_list);
501 LIST_HEAD(kill_list); 490 LIST_HEAD(kill_list);
502 unsigned long flags; 491 unsigned long flags;
503 unsigned int nfreed = 0, ncleaned = 0, unpinned = 0, free_goal; 492 unsigned int nfreed = 0, ncleaned = 0, unpinned = 0;
504 int ret = 0; 493 int ret = 0;
505 494
506 rds_iw_stats_inc(s_iw_rdma_mr_pool_flush); 495 rds_iw_stats_inc(s_iw_rdma_mr_pool_flush);
@@ -514,8 +503,6 @@ static int rds_iw_flush_mr_pool(struct rds_iw_mr_pool *pool, int free_all)
514 list_splice_init(&pool->clean_list, &kill_list); 503 list_splice_init(&pool->clean_list, &kill_list);
515 spin_unlock_irqrestore(&pool->list_lock, flags); 504 spin_unlock_irqrestore(&pool->list_lock, flags);
516 505
517 free_goal = rds_iw_flush_goal(pool, free_all);
518
519 /* Batched invalidate of dirty MRs. 506 /* Batched invalidate of dirty MRs.
520 * For FMR based MRs, the mappings on the unmap list are 507 * For FMR based MRs, the mappings on the unmap list are
521 * actually members of an ibmr (ibmr->mapping). They either 508 * actually members of an ibmr (ibmr->mapping). They either
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index 0a7964009e8c..67494aef9acf 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -24,6 +24,7 @@
24#include <net/netlink.h> 24#include <net/netlink.h>
25#include <net/pkt_sched.h> 25#include <net/pkt_sched.h>
26#include <net/flow_keys.h> 26#include <net/flow_keys.h>
27#include <net/red.h>
27 28
28 29
29/* Stochastic Fairness Queuing algorithm. 30/* Stochastic Fairness Queuing algorithm.
@@ -108,24 +109,30 @@ struct sfq_slot {
108 struct sfq_head dep; /* anchor in dep[] chains */ 109 struct sfq_head dep; /* anchor in dep[] chains */
109 unsigned short hash; /* hash value (index in ht[]) */ 110 unsigned short hash; /* hash value (index in ht[]) */
110 short allot; /* credit for this slot */ 111 short allot; /* credit for this slot */
112
113 unsigned int backlog;
114 struct red_vars vars;
111}; 115};
112 116
113struct sfq_sched_data { 117struct sfq_sched_data {
114/* frequently used fields */ 118/* frequently used fields */
115 int limit; /* limit of total number of packets in this qdisc */ 119 int limit; /* limit of total number of packets in this qdisc */
116 unsigned int divisor; /* number of slots in hash table */ 120 unsigned int divisor; /* number of slots in hash table */
117 unsigned int maxflows; /* number of flows in flows array */ 121 u8 headdrop;
118 int headdrop; 122 u8 maxdepth; /* limit of packets per flow */
119 int maxdepth; /* limit of packets per flow */
120 123
121 u32 perturbation; 124 u32 perturbation;
122 struct tcf_proto *filter_list; 125 u8 cur_depth; /* depth of longest slot */
123 sfq_index cur_depth; /* depth of longest slot */ 126 u8 flags;
124 unsigned short scaled_quantum; /* SFQ_ALLOT_SIZE(quantum) */ 127 unsigned short scaled_quantum; /* SFQ_ALLOT_SIZE(quantum) */
125 struct sfq_slot *tail; /* current slot in round */ 128 struct tcf_proto *filter_list;
126 sfq_index *ht; /* Hash table ('divisor' slots) */ 129 sfq_index *ht; /* Hash table ('divisor' slots) */
127 struct sfq_slot *slots; /* Flows table ('maxflows' entries) */ 130 struct sfq_slot *slots; /* Flows table ('maxflows' entries) */
128 131
132 struct red_parms *red_parms;
133 struct tc_sfqred_stats stats;
134 struct sfq_slot *tail; /* current slot in round */
135
129 struct sfq_head dep[SFQ_MAX_DEPTH + 1]; 136 struct sfq_head dep[SFQ_MAX_DEPTH + 1];
130 /* Linked lists of slots, indexed by depth 137 /* Linked lists of slots, indexed by depth
131 * dep[0] : list of unused flows 138 * dep[0] : list of unused flows
@@ -133,6 +140,7 @@ struct sfq_sched_data {
133 * dep[X] : list of flows with X packets 140 * dep[X] : list of flows with X packets
134 */ 141 */
135 142
143 unsigned int maxflows; /* number of flows in flows array */
136 int perturb_period; 144 int perturb_period;
137 unsigned int quantum; /* Allotment per round: MUST BE >= MTU */ 145 unsigned int quantum; /* Allotment per round: MUST BE >= MTU */
138 struct timer_list perturb_timer; 146 struct timer_list perturb_timer;
@@ -321,6 +329,7 @@ static unsigned int sfq_drop(struct Qdisc *sch)
321drop: 329drop:
322 skb = q->headdrop ? slot_dequeue_head(slot) : slot_dequeue_tail(slot); 330 skb = q->headdrop ? slot_dequeue_head(slot) : slot_dequeue_tail(slot);
323 len = qdisc_pkt_len(skb); 331 len = qdisc_pkt_len(skb);
332 slot->backlog -= len;
324 sfq_dec(q, x); 333 sfq_dec(q, x);
325 kfree_skb(skb); 334 kfree_skb(skb);
326 sch->q.qlen--; 335 sch->q.qlen--;
@@ -341,6 +350,23 @@ drop:
341 return 0; 350 return 0;
342} 351}
343 352
353/* Is ECN parameter configured */
354static int sfq_prob_mark(const struct sfq_sched_data *q)
355{
356 return q->flags & TC_RED_ECN;
357}
358
359/* Should packets over max threshold just be marked */
360static int sfq_hard_mark(const struct sfq_sched_data *q)
361{
362 return (q->flags & (TC_RED_ECN | TC_RED_HARDDROP)) == TC_RED_ECN;
363}
364
365static int sfq_headdrop(const struct sfq_sched_data *q)
366{
367 return q->headdrop;
368}
369
344static int 370static int
345sfq_enqueue(struct sk_buff *skb, struct Qdisc *sch) 371sfq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
346{ 372{
@@ -349,6 +375,8 @@ sfq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
349 sfq_index x, qlen; 375 sfq_index x, qlen;
350 struct sfq_slot *slot; 376 struct sfq_slot *slot;
351 int uninitialized_var(ret); 377 int uninitialized_var(ret);
378 struct sk_buff *head;
379 int delta;
352 380
353 hash = sfq_classify(skb, sch, &ret); 381 hash = sfq_classify(skb, sch, &ret);
354 if (hash == 0) { 382 if (hash == 0) {
@@ -368,24 +396,75 @@ sfq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
368 q->ht[hash] = x; 396 q->ht[hash] = x;
369 slot = &q->slots[x]; 397 slot = &q->slots[x];
370 slot->hash = hash; 398 slot->hash = hash;
399 slot->backlog = 0; /* should already be 0 anyway... */
400 red_set_vars(&slot->vars);
401 goto enqueue;
371 } 402 }
403 if (q->red_parms) {
404 slot->vars.qavg = red_calc_qavg_no_idle_time(q->red_parms,
405 &slot->vars,
406 slot->backlog);
407 switch (red_action(q->red_parms,
408 &slot->vars,
409 slot->vars.qavg)) {
410 case RED_DONT_MARK:
411 break;
372 412
373 if (slot->qlen >= q->maxdepth) { 413 case RED_PROB_MARK:
374 struct sk_buff *head; 414 sch->qstats.overlimits++;
415 if (sfq_prob_mark(q)) {
416 /* We know we have at least one packet in queue */
417 if (sfq_headdrop(q) &&
418 INET_ECN_set_ce(slot->skblist_next)) {
419 q->stats.prob_mark_head++;
420 break;
421 }
422 if (INET_ECN_set_ce(skb)) {
423 q->stats.prob_mark++;
424 break;
425 }
426 }
427 q->stats.prob_drop++;
428 goto congestion_drop;
429
430 case RED_HARD_MARK:
431 sch->qstats.overlimits++;
432 if (sfq_hard_mark(q)) {
433 /* We know we have at least one packet in queue */
434 if (sfq_headdrop(q) &&
435 INET_ECN_set_ce(slot->skblist_next)) {
436 q->stats.forced_mark_head++;
437 break;
438 }
439 if (INET_ECN_set_ce(skb)) {
440 q->stats.forced_mark++;
441 break;
442 }
443 }
444 q->stats.forced_drop++;
445 goto congestion_drop;
446 }
447 }
375 448
376 if (!q->headdrop) 449 if (slot->qlen >= q->maxdepth) {
450congestion_drop:
451 if (!sfq_headdrop(q))
377 return qdisc_drop(skb, sch); 452 return qdisc_drop(skb, sch);
378 453
454 /* We know we have at least one packet in queue */
379 head = slot_dequeue_head(slot); 455 head = slot_dequeue_head(slot);
380 sch->qstats.backlog -= qdisc_pkt_len(head); 456 delta = qdisc_pkt_len(head) - qdisc_pkt_len(skb);
457 sch->qstats.backlog -= delta;
458 slot->backlog -= delta;
381 qdisc_drop(head, sch); 459 qdisc_drop(head, sch);
382 460
383 sch->qstats.backlog += qdisc_pkt_len(skb);
384 slot_queue_add(slot, skb); 461 slot_queue_add(slot, skb);
385 return NET_XMIT_CN; 462 return NET_XMIT_CN;
386 } 463 }
387 464
465enqueue:
388 sch->qstats.backlog += qdisc_pkt_len(skb); 466 sch->qstats.backlog += qdisc_pkt_len(skb);
467 slot->backlog += qdisc_pkt_len(skb);
389 slot_queue_add(slot, skb); 468 slot_queue_add(slot, skb);
390 sfq_inc(q, x); 469 sfq_inc(q, x);
391 if (slot->qlen == 1) { /* The flow is new */ 470 if (slot->qlen == 1) { /* The flow is new */
@@ -396,6 +475,7 @@ sfq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
396 slot->next = q->tail->next; 475 slot->next = q->tail->next;
397 q->tail->next = x; 476 q->tail->next = x;
398 } 477 }
478 /* We could use a bigger initial quantum for new flows */
399 slot->allot = q->scaled_quantum; 479 slot->allot = q->scaled_quantum;
400 } 480 }
401 if (++sch->q.qlen <= q->limit) 481 if (++sch->q.qlen <= q->limit)
@@ -439,7 +519,7 @@ next_slot:
439 qdisc_bstats_update(sch, skb); 519 qdisc_bstats_update(sch, skb);
440 sch->q.qlen--; 520 sch->q.qlen--;
441 sch->qstats.backlog -= qdisc_pkt_len(skb); 521 sch->qstats.backlog -= qdisc_pkt_len(skb);
442 522 slot->backlog -= qdisc_pkt_len(skb);
443 /* Is the slot empty? */ 523 /* Is the slot empty? */
444 if (slot->qlen == 0) { 524 if (slot->qlen == 0) {
445 q->ht[slot->hash] = SFQ_EMPTY_SLOT; 525 q->ht[slot->hash] = SFQ_EMPTY_SLOT;
@@ -490,6 +570,8 @@ static void sfq_rehash(struct Qdisc *sch)
490 sfq_dec(q, i); 570 sfq_dec(q, i);
491 __skb_queue_tail(&list, skb); 571 __skb_queue_tail(&list, skb);
492 } 572 }
573 slot->backlog = 0;
574 red_set_vars(&slot->vars);
493 q->ht[slot->hash] = SFQ_EMPTY_SLOT; 575 q->ht[slot->hash] = SFQ_EMPTY_SLOT;
494 } 576 }
495 q->tail = NULL; 577 q->tail = NULL;
@@ -514,6 +596,11 @@ drop: sch->qstats.backlog -= qdisc_pkt_len(skb);
514 if (slot->qlen >= q->maxdepth) 596 if (slot->qlen >= q->maxdepth)
515 goto drop; 597 goto drop;
516 slot_queue_add(slot, skb); 598 slot_queue_add(slot, skb);
599 if (q->red_parms)
600 slot->vars.qavg = red_calc_qavg(q->red_parms,
601 &slot->vars,
602 slot->backlog);
603 slot->backlog += qdisc_pkt_len(skb);
517 sfq_inc(q, x); 604 sfq_inc(q, x);
518 if (slot->qlen == 1) { /* The flow is new */ 605 if (slot->qlen == 1) { /* The flow is new */
519 if (q->tail == NULL) { /* It is the first flow */ 606 if (q->tail == NULL) { /* It is the first flow */
@@ -552,6 +639,7 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt)
552 struct tc_sfq_qopt *ctl = nla_data(opt); 639 struct tc_sfq_qopt *ctl = nla_data(opt);
553 struct tc_sfq_qopt_v1 *ctl_v1 = NULL; 640 struct tc_sfq_qopt_v1 *ctl_v1 = NULL;
554 unsigned int qlen; 641 unsigned int qlen;
642 struct red_parms *p = NULL;
555 643
556 if (opt->nla_len < nla_attr_size(sizeof(*ctl))) 644 if (opt->nla_len < nla_attr_size(sizeof(*ctl)))
557 return -EINVAL; 645 return -EINVAL;
@@ -560,7 +648,11 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt)
560 if (ctl->divisor && 648 if (ctl->divisor &&
561 (!is_power_of_2(ctl->divisor) || ctl->divisor > 65536)) 649 (!is_power_of_2(ctl->divisor) || ctl->divisor > 65536))
562 return -EINVAL; 650 return -EINVAL;
563 651 if (ctl_v1 && ctl_v1->qth_min) {
652 p = kmalloc(sizeof(*p), GFP_KERNEL);
653 if (!p)
654 return -ENOMEM;
655 }
564 sch_tree_lock(sch); 656 sch_tree_lock(sch);
565 if (ctl->quantum) { 657 if (ctl->quantum) {
566 q->quantum = ctl->quantum; 658 q->quantum = ctl->quantum;
@@ -576,6 +668,16 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt)
576 if (ctl_v1) { 668 if (ctl_v1) {
577 if (ctl_v1->depth) 669 if (ctl_v1->depth)
578 q->maxdepth = min_t(u32, ctl_v1->depth, SFQ_MAX_DEPTH); 670 q->maxdepth = min_t(u32, ctl_v1->depth, SFQ_MAX_DEPTH);
671 if (p) {
672 swap(q->red_parms, p);
673 red_set_parms(q->red_parms,
674 ctl_v1->qth_min, ctl_v1->qth_max,
675 ctl_v1->Wlog,
676 ctl_v1->Plog, ctl_v1->Scell_log,
677 NULL,
678 ctl_v1->max_P);
679 }
680 q->flags = ctl_v1->flags;
579 q->headdrop = ctl_v1->headdrop; 681 q->headdrop = ctl_v1->headdrop;
580 } 682 }
581 if (ctl->limit) { 683 if (ctl->limit) {
@@ -594,6 +696,7 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt)
594 q->perturbation = net_random(); 696 q->perturbation = net_random();
595 } 697 }
596 sch_tree_unlock(sch); 698 sch_tree_unlock(sch);
699 kfree(p);
597 return 0; 700 return 0;
598} 701}
599 702
@@ -625,6 +728,7 @@ static void sfq_destroy(struct Qdisc *sch)
625 del_timer_sync(&q->perturb_timer); 728 del_timer_sync(&q->perturb_timer);
626 sfq_free(q->ht); 729 sfq_free(q->ht);
627 sfq_free(q->slots); 730 sfq_free(q->slots);
731 kfree(q->red_parms);
628} 732}
629 733
630static int sfq_init(struct Qdisc *sch, struct nlattr *opt) 734static int sfq_init(struct Qdisc *sch, struct nlattr *opt)
@@ -683,6 +787,7 @@ static int sfq_dump(struct Qdisc *sch, struct sk_buff *skb)
683 struct sfq_sched_data *q = qdisc_priv(sch); 787 struct sfq_sched_data *q = qdisc_priv(sch);
684 unsigned char *b = skb_tail_pointer(skb); 788 unsigned char *b = skb_tail_pointer(skb);
685 struct tc_sfq_qopt_v1 opt; 789 struct tc_sfq_qopt_v1 opt;
790 struct red_parms *p = q->red_parms;
686 791
687 memset(&opt, 0, sizeof(opt)); 792 memset(&opt, 0, sizeof(opt));
688 opt.v0.quantum = q->quantum; 793 opt.v0.quantum = q->quantum;
@@ -693,6 +798,17 @@ static int sfq_dump(struct Qdisc *sch, struct sk_buff *skb)
693 opt.depth = q->maxdepth; 798 opt.depth = q->maxdepth;
694 opt.headdrop = q->headdrop; 799 opt.headdrop = q->headdrop;
695 800
801 if (p) {
802 opt.qth_min = p->qth_min >> p->Wlog;
803 opt.qth_max = p->qth_max >> p->Wlog;
804 opt.Wlog = p->Wlog;
805 opt.Plog = p->Plog;
806 opt.Scell_log = p->Scell_log;
807 opt.max_P = p->max_P;
808 }
809 memcpy(&opt.stats, &q->stats, sizeof(opt.stats));
810 opt.flags = q->flags;
811
696 NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt); 812 NLA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
697 813
698 return skb->len; 814 return skb->len;
@@ -747,15 +863,13 @@ static int sfq_dump_class_stats(struct Qdisc *sch, unsigned long cl,
747 sfq_index idx = q->ht[cl - 1]; 863 sfq_index idx = q->ht[cl - 1];
748 struct gnet_stats_queue qs = { 0 }; 864 struct gnet_stats_queue qs = { 0 };
749 struct tc_sfq_xstats xstats = { 0 }; 865 struct tc_sfq_xstats xstats = { 0 };
750 struct sk_buff *skb;
751 866
752 if (idx != SFQ_EMPTY_SLOT) { 867 if (idx != SFQ_EMPTY_SLOT) {
753 const struct sfq_slot *slot = &q->slots[idx]; 868 const struct sfq_slot *slot = &q->slots[idx];
754 869
755 xstats.allot = slot->allot << SFQ_ALLOT_SHIFT; 870 xstats.allot = slot->allot << SFQ_ALLOT_SHIFT;
756 qs.qlen = slot->qlen; 871 qs.qlen = slot->qlen;
757 slot_queue_walk(slot, skb) 872 qs.backlog = slot->backlog;
758 qs.backlog += qdisc_pkt_len(skb);
759 } 873 }
760 if (gnet_stats_copy_queue(d, &qs) < 0) 874 if (gnet_stats_copy_queue(d, &qs) < 0)
761 return -1; 875 return -1;
diff --git a/net/socket.c b/net/socket.c
index e56162cd65b0..28a96af484b4 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2492,7 +2492,7 @@ int sock_register(const struct net_proto_family *ops)
2492 lockdep_is_held(&net_family_lock))) 2492 lockdep_is_held(&net_family_lock)))
2493 err = -EEXIST; 2493 err = -EEXIST;
2494 else { 2494 else {
2495 RCU_INIT_POINTER(net_families[ops->family], ops); 2495 rcu_assign_pointer(net_families[ops->family], ops);
2496 err = 0; 2496 err = 0;
2497 } 2497 }
2498 spin_unlock(&net_family_lock); 2498 spin_unlock(&net_family_lock);
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 28d72d298735..affa631ac1ab 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -122,7 +122,7 @@ gss_cred_set_ctx(struct rpc_cred *cred, struct gss_cl_ctx *ctx)
122 if (!test_bit(RPCAUTH_CRED_NEW, &cred->cr_flags)) 122 if (!test_bit(RPCAUTH_CRED_NEW, &cred->cr_flags))
123 return; 123 return;
124 gss_get_ctx(ctx); 124 gss_get_ctx(ctx);
125 RCU_INIT_POINTER(gss_cred->gc_ctx, ctx); 125 rcu_assign_pointer(gss_cred->gc_ctx, ctx);
126 set_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); 126 set_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags);
127 smp_mb__before_clear_bit(); 127 smp_mb__before_clear_bit();
128 clear_bit(RPCAUTH_CRED_NEW, &cred->cr_flags); 128 clear_bit(RPCAUTH_CRED_NEW, &cred->cr_flags);
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index b3d3cf8931cb..afeea32e04ad 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -2250,6 +2250,7 @@ static const struct nla_policy sta_flags_policy[NL80211_STA_FLAG_MAX + 1] = {
2250}; 2250};
2251 2251
2252static int parse_station_flags(struct genl_info *info, 2252static int parse_station_flags(struct genl_info *info,
2253 enum nl80211_iftype iftype,
2253 struct station_parameters *params) 2254 struct station_parameters *params)
2254{ 2255{
2255 struct nlattr *flags[NL80211_STA_FLAG_MAX + 1]; 2256 struct nlattr *flags[NL80211_STA_FLAG_MAX + 1];
@@ -2283,8 +2284,33 @@ static int parse_station_flags(struct genl_info *info,
2283 nla, sta_flags_policy)) 2284 nla, sta_flags_policy))
2284 return -EINVAL; 2285 return -EINVAL;
2285 2286
2286 params->sta_flags_mask = (1 << __NL80211_STA_FLAG_AFTER_LAST) - 1; 2287 /*
2287 params->sta_flags_mask &= ~1; 2288 * Only allow certain flags for interface types so that
2289 * other attributes are silently ignored. Remember that
2290 * this is backward compatibility code with old userspace
2291 * and shouldn't be hit in other cases anyway.
2292 */
2293 switch (iftype) {
2294 case NL80211_IFTYPE_AP:
2295 case NL80211_IFTYPE_AP_VLAN:
2296 case NL80211_IFTYPE_P2P_GO:
2297 params->sta_flags_mask = BIT(NL80211_STA_FLAG_AUTHORIZED) |
2298 BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) |
2299 BIT(NL80211_STA_FLAG_WME) |
2300 BIT(NL80211_STA_FLAG_MFP);
2301 break;
2302 case NL80211_IFTYPE_P2P_CLIENT:
2303 case NL80211_IFTYPE_STATION:
2304 params->sta_flags_mask = BIT(NL80211_STA_FLAG_AUTHORIZED) |
2305 BIT(NL80211_STA_FLAG_TDLS_PEER);
2306 break;
2307 case NL80211_IFTYPE_MESH_POINT:
2308 params->sta_flags_mask = BIT(NL80211_STA_FLAG_AUTHENTICATED) |
2309 BIT(NL80211_STA_FLAG_MFP) |
2310 BIT(NL80211_STA_FLAG_AUTHORIZED);
2311 default:
2312 return -EINVAL;
2313 }
2288 2314
2289 for (flag = 1; flag <= NL80211_STA_FLAG_MAX; flag++) 2315 for (flag = 1; flag <= NL80211_STA_FLAG_MAX; flag++)
2290 if (flags[flag]) 2316 if (flags[flag])
@@ -2585,7 +2611,7 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
2585 if (!rdev->ops->change_station) 2611 if (!rdev->ops->change_station)
2586 return -EOPNOTSUPP; 2612 return -EOPNOTSUPP;
2587 2613
2588 if (parse_station_flags(info, &params)) 2614 if (parse_station_flags(info, dev->ieee80211_ptr->iftype, &params))
2589 return -EINVAL; 2615 return -EINVAL;
2590 2616
2591 if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION]) 2617 if (info->attrs[NL80211_ATTR_STA_PLINK_ACTION])
@@ -2731,7 +2757,7 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
2731 if (!rdev->ops->add_station) 2757 if (!rdev->ops->add_station)
2732 return -EOPNOTSUPP; 2758 return -EOPNOTSUPP;
2733 2759
2734 if (parse_station_flags(info, &params)) 2760 if (parse_station_flags(info, dev->ieee80211_ptr->iftype, &params))
2735 return -EINVAL; 2761 return -EINVAL;
2736 2762
2737 switch (dev->ieee80211_ptr->iftype) { 2763 switch (dev->ieee80211_ptr->iftype) {
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index e0d747a2e803..637f11a1e4df 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -2927,7 +2927,7 @@ static int __net_init xfrm_user_net_init(struct net *net)
2927 if (nlsk == NULL) 2927 if (nlsk == NULL)
2928 return -ENOMEM; 2928 return -ENOMEM;
2929 net->xfrm.nlsk_stash = nlsk; /* Don't set to NULL */ 2929 net->xfrm.nlsk_stash = nlsk; /* Don't set to NULL */
2930 RCU_INIT_POINTER(net->xfrm.nlsk, nlsk); 2930 rcu_assign_pointer(net->xfrm.nlsk, nlsk);
2931 return 0; 2931 return 0;
2932} 2932}
2933 2933