aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-01-20 01:19:31 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-01-20 01:19:31 -0500
commiteef8f4c2acac6fae84f2d959a145fa3cad4d00c9 (patch)
tree75bae5d1b2dbf7bd3f631f9e423a35f391163e1a
parent2262889091c15ef0c790be0b99ea6dae73c86a0b (diff)
parenta8c1d28ac3925b99b5a939617d3fef1644298ee8 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Socket addresses returned in the error queue need to be fully initialized before being passed on to userspace, fix from Willem de Bruijn. 2) Interrupt handling fixes to davinci_emac driver from Tony Lindgren. 3) Fix races between receive packet steering and cpu hotplug, from Eric Dumazet. 4) Allowing netlink sockets to subscribe to unknown multicast groups leads to crashes, don't allow it. From Johannes Berg. 5) One to many socket races in SCTP fixed by Daniel Borkmann. 6) Put in a guard against the mis-use of ipv6 atomic fragments, from Hagen Paul Pfeifer. 7) Fix promisc mode and ethtool crashes in sh_eth driver, from Ben Hutchings. 8) NULL deref and double kfree fix in sxgbe driver from Girish K.S and Byungho An. 9) cfg80211 deadlock fix from Arik Nemtsov. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (36 commits) s2io: use snprintf() as a safety feature r8152: remove sram_read r8152: remove generic_ocp_read before writing bgmac: activate irqs only if there is nothing to poll bgmac: register napi before the device sh_eth: Fix ethtool operation crash when net device is down sh_eth: Fix promiscuous mode on chips without TSU ipv6: stop sending PTB packets for MTU < 1280 net: sctp: fix race for one-to-many sockets in sendmsg's auto associate genetlink: synchronize socket closing and family removal genetlink: disallow subscribing to unknown mcast groups genetlink: document parallel_ops net: rps: fix cpu unplug net: davinci_emac: Add support for emac on dm816x net: davinci_emac: Fix ioremap for devices with MDIO within the EMAC address space net: davinci_emac: Fix incomplete code for getting the phy from device tree net: davinci_emac: Free clock after checking the frequency net: davinci_emac: Fix runtime pm calls for davinci_emac net: davinci_emac: Fix hangs with interrupts ip: zero sockaddr returned on error queue ...
-rw-r--r--Documentation/devicetree/bindings/net/davinci_emac.txt3
-rw-r--r--MAINTAINERS6
-rw-r--r--drivers/infiniband/hw/mlx4/main.c3
-rw-r--r--drivers/net/can/c_can/c_can_platform.c29
-rw-r--r--drivers/net/can/dev.c8
-rw-r--r--drivers/net/can/m_can/m_can.c5
-rw-r--r--drivers/net/can/usb/kvaser_usb.c31
-rw-r--r--drivers/net/ethernet/broadcom/bgmac.c12
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c41
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c3
-rw-r--r--drivers/net/ethernet/neterion/s2io.c11
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c32
-rw-r--r--drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c21
-rw-r--r--drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c8
-rw-r--r--drivers/net/ethernet/ti/cpsw.c27
-rw-r--r--drivers/net/ethernet/ti/davinci_emac.c96
-rw-r--r--drivers/net/usb/r8152.c30
-rw-r--r--include/linux/genetlink.h4
-rw-r--r--include/net/genetlink.h7
-rw-r--r--include/uapi/linux/can/netlink.h1
-rw-r--r--net/core/dev.c20
-rw-r--r--net/ipv4/ip_sockglue.c8
-rw-r--r--net/ipv6/datagram.c10
-rw-r--r--net/ipv6/route.c7
-rw-r--r--net/mac80211/mlme.c2
-rw-r--r--net/netlink/af_netlink.c24
-rw-r--r--net/netlink/af_netlink.h1
-rw-r--r--net/netlink/genetlink.c18
-rw-r--r--net/sctp/socket.c8
-rw-r--r--net/wireless/reg.c56
31 files changed, 343 insertions, 192 deletions
diff --git a/Documentation/devicetree/bindings/net/davinci_emac.txt b/Documentation/devicetree/bindings/net/davinci_emac.txt
index 032808843f90..24c5cdaba8d2 100644
--- a/Documentation/devicetree/bindings/net/davinci_emac.txt
+++ b/Documentation/devicetree/bindings/net/davinci_emac.txt
@@ -4,7 +4,8 @@ This file provides information, what the device node
4for the davinci_emac interface contains. 4for the davinci_emac interface contains.
5 5
6Required properties: 6Required properties:
7- compatible: "ti,davinci-dm6467-emac" or "ti,am3517-emac" 7- compatible: "ti,davinci-dm6467-emac", "ti,am3517-emac" or
8 "ti,dm816-emac"
8- reg: Offset and length of the register set for the device 9- reg: Offset and length of the register set for the device
9- ti,davinci-ctrl-reg-offset: offset to control register 10- ti,davinci-ctrl-reg-offset: offset to control register
10- ti,davinci-ctrl-mod-reg-offset: offset to control module register 11- ti,davinci-ctrl-mod-reg-offset: offset to control module register
diff --git a/MAINTAINERS b/MAINTAINERS
index 2e99241d148d..56de2e34c9f3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2346,7 +2346,8 @@ CAN NETWORK LAYER
2346M: Oliver Hartkopp <socketcan@hartkopp.net> 2346M: Oliver Hartkopp <socketcan@hartkopp.net>
2347L: linux-can@vger.kernel.org 2347L: linux-can@vger.kernel.org
2348W: http://gitorious.org/linux-can 2348W: http://gitorious.org/linux-can
2349T: git git://gitorious.org/linux-can/linux-can-next.git 2349T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git
2350T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git
2350S: Maintained 2351S: Maintained
2351F: Documentation/networking/can.txt 2352F: Documentation/networking/can.txt
2352F: net/can/ 2353F: net/can/
@@ -2361,7 +2362,8 @@ M: Wolfgang Grandegger <wg@grandegger.com>
2361M: Marc Kleine-Budde <mkl@pengutronix.de> 2362M: Marc Kleine-Budde <mkl@pengutronix.de>
2362L: linux-can@vger.kernel.org 2363L: linux-can@vger.kernel.org
2363W: http://gitorious.org/linux-can 2364W: http://gitorious.org/linux-can
2364T: git git://gitorious.org/linux-can/linux-can-next.git 2365T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git
2366T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git
2365S: Maintained 2367S: Maintained
2366F: drivers/net/can/ 2368F: drivers/net/can/
2367F: include/linux/can/dev.h 2369F: include/linux/can/dev.h
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 57ecc5b204f3..9117b7a2d5f8 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -1114,7 +1114,8 @@ static int mlx4_ib_tunnel_steer_add(struct ib_qp *qp, struct ib_flow_attr *flow_
1114 struct mlx4_dev *dev = to_mdev(qp->device)->dev; 1114 struct mlx4_dev *dev = to_mdev(qp->device)->dev;
1115 int err = 0; 1115 int err = 0;
1116 1116
1117 if (dev->caps.tunnel_offload_mode != MLX4_TUNNEL_OFFLOAD_MODE_VXLAN) 1117 if (dev->caps.tunnel_offload_mode != MLX4_TUNNEL_OFFLOAD_MODE_VXLAN ||
1118 dev->caps.dmfs_high_steer_mode == MLX4_STEERING_DMFS_A0_STATIC)
1118 return 0; /* do nothing */ 1119 return 0; /* do nothing */
1119 1120
1120 ib_flow = flow_attr + 1; 1121 ib_flow = flow_attr + 1;
diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c
index f363972cd77d..e36d10520e24 100644
--- a/drivers/net/can/c_can/c_can_platform.c
+++ b/drivers/net/can/c_can/c_can_platform.c
@@ -103,27 +103,34 @@ static void c_can_hw_raminit_syscon(const struct c_can_priv *priv, bool enable)
103 mask = 1 << raminit->bits.start | 1 << raminit->bits.done; 103 mask = 1 << raminit->bits.start | 1 << raminit->bits.done;
104 regmap_read(raminit->syscon, raminit->reg, &ctrl); 104 regmap_read(raminit->syscon, raminit->reg, &ctrl);
105 105
106 /* We clear the done and start bit first. The start bit is 106 /* We clear the start bit first. The start bit is
107 * looking at the 0 -> transition, but is not self clearing; 107 * looking at the 0 -> transition, but is not self clearing;
108 * And we clear the init done bit as well.
109 * NOTE: DONE must be written with 1 to clear it. 108 * NOTE: DONE must be written with 1 to clear it.
109 * We can't clear the DONE bit here using regmap_update_bits()
110 * as it will bypass the write if initial condition is START:0 DONE:1
111 * e.g. on DRA7 which needs START pulse.
110 */ 112 */
111 ctrl &= ~(1 << raminit->bits.start); 113 ctrl &= ~mask; /* START = 0, DONE = 0 */
112 ctrl |= 1 << raminit->bits.done; 114 regmap_update_bits(raminit->syscon, raminit->reg, mask, ctrl);
113 regmap_write(raminit->syscon, raminit->reg, ctrl);
114 115
115 ctrl &= ~(1 << raminit->bits.done); 116 /* check if START bit is 0. Ignore DONE bit for now
116 c_can_hw_raminit_wait_syscon(priv, mask, ctrl); 117 * as it can be either 0 or 1.
118 */
119 c_can_hw_raminit_wait_syscon(priv, 1 << raminit->bits.start, ctrl);
117 120
118 if (enable) { 121 if (enable) {
119 /* Set start bit and wait for the done bit. */ 122 /* Clear DONE bit & set START bit. */
120 ctrl |= 1 << raminit->bits.start; 123 ctrl |= 1 << raminit->bits.start;
121 regmap_write(raminit->syscon, raminit->reg, ctrl); 124 /* DONE must be written with 1 to clear it */
122 125 ctrl |= 1 << raminit->bits.done;
126 regmap_update_bits(raminit->syscon, raminit->reg, mask, ctrl);
127 /* prevent further clearing of DONE bit */
128 ctrl &= ~(1 << raminit->bits.done);
123 /* clear START bit if start pulse is needed */ 129 /* clear START bit if start pulse is needed */
124 if (raminit->needs_pulse) { 130 if (raminit->needs_pulse) {
125 ctrl &= ~(1 << raminit->bits.start); 131 ctrl &= ~(1 << raminit->bits.start);
126 regmap_write(raminit->syscon, raminit->reg, ctrl); 132 regmap_update_bits(raminit->syscon, raminit->reg,
133 mask, ctrl);
127 } 134 }
128 135
129 ctrl |= 1 << raminit->bits.done; 136 ctrl |= 1 << raminit->bits.done;
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 3ec8f6f25e5f..847c1f813261 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -807,10 +807,14 @@ static int can_changelink(struct net_device *dev,
807 if (dev->flags & IFF_UP) 807 if (dev->flags & IFF_UP)
808 return -EBUSY; 808 return -EBUSY;
809 cm = nla_data(data[IFLA_CAN_CTRLMODE]); 809 cm = nla_data(data[IFLA_CAN_CTRLMODE]);
810 if (cm->flags & ~priv->ctrlmode_supported) 810
811 /* check whether changed bits are allowed to be modified */
812 if (cm->mask & ~priv->ctrlmode_supported)
811 return -EOPNOTSUPP; 813 return -EOPNOTSUPP;
814
815 /* clear bits to be modified and copy the flag values */
812 priv->ctrlmode &= ~cm->mask; 816 priv->ctrlmode &= ~cm->mask;
813 priv->ctrlmode |= cm->flags; 817 priv->ctrlmode |= (cm->flags & cm->mask);
814 818
815 /* CAN_CTRLMODE_FD can only be set when driver supports FD */ 819 /* CAN_CTRLMODE_FD can only be set when driver supports FD */
816 if (priv->ctrlmode & CAN_CTRLMODE_FD) 820 if (priv->ctrlmode & CAN_CTRLMODE_FD)
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index d7bc462aafdc..244529881be9 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -955,6 +955,11 @@ static struct net_device *alloc_m_can_dev(void)
955 priv->can.data_bittiming_const = &m_can_data_bittiming_const; 955 priv->can.data_bittiming_const = &m_can_data_bittiming_const;
956 priv->can.do_set_mode = m_can_set_mode; 956 priv->can.do_set_mode = m_can_set_mode;
957 priv->can.do_get_berr_counter = m_can_get_berr_counter; 957 priv->can.do_get_berr_counter = m_can_get_berr_counter;
958
959 /* CAN_CTRLMODE_FD_NON_ISO is fixed with M_CAN IP v3.0.1 */
960 priv->can.ctrlmode = CAN_CTRLMODE_FD_NON_ISO;
961
962 /* CAN_CTRLMODE_FD_NON_ISO can not be changed with M_CAN IP v3.0.1 */
958 priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK | 963 priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK |
959 CAN_CTRLMODE_LISTENONLY | 964 CAN_CTRLMODE_LISTENONLY |
960 CAN_CTRLMODE_BERR_REPORTING | 965 CAN_CTRLMODE_BERR_REPORTING |
diff --git a/drivers/net/can/usb/kvaser_usb.c b/drivers/net/can/usb/kvaser_usb.c
index 541fb7a05625..c32cd61073bc 100644
--- a/drivers/net/can/usb/kvaser_usb.c
+++ b/drivers/net/can/usb/kvaser_usb.c
@@ -520,10 +520,10 @@ static void kvaser_usb_tx_acknowledge(const struct kvaser_usb *dev,
520 skb = alloc_can_err_skb(priv->netdev, &cf); 520 skb = alloc_can_err_skb(priv->netdev, &cf);
521 if (skb) { 521 if (skb) {
522 cf->can_id |= CAN_ERR_RESTARTED; 522 cf->can_id |= CAN_ERR_RESTARTED;
523 netif_rx(skb);
524 523
525 stats->rx_packets++; 524 stats->rx_packets++;
526 stats->rx_bytes += cf->can_dlc; 525 stats->rx_bytes += cf->can_dlc;
526 netif_rx(skb);
527 } else { 527 } else {
528 netdev_err(priv->netdev, 528 netdev_err(priv->netdev,
529 "No memory left for err_skb\n"); 529 "No memory left for err_skb\n");
@@ -770,10 +770,9 @@ static void kvaser_usb_rx_error(const struct kvaser_usb *dev,
770 770
771 priv->can.state = new_state; 771 priv->can.state = new_state;
772 772
773 netif_rx(skb);
774
775 stats->rx_packets++; 773 stats->rx_packets++;
776 stats->rx_bytes += cf->can_dlc; 774 stats->rx_bytes += cf->can_dlc;
775 netif_rx(skb);
777} 776}
778 777
779static void kvaser_usb_rx_can_err(const struct kvaser_usb_net_priv *priv, 778static void kvaser_usb_rx_can_err(const struct kvaser_usb_net_priv *priv,
@@ -805,10 +804,9 @@ static void kvaser_usb_rx_can_err(const struct kvaser_usb_net_priv *priv,
805 stats->rx_over_errors++; 804 stats->rx_over_errors++;
806 stats->rx_errors++; 805 stats->rx_errors++;
807 806
808 netif_rx(skb);
809
810 stats->rx_packets++; 807 stats->rx_packets++;
811 stats->rx_bytes += cf->can_dlc; 808 stats->rx_bytes += cf->can_dlc;
809 netif_rx(skb);
812 } 810 }
813} 811}
814 812
@@ -887,10 +885,9 @@ static void kvaser_usb_rx_can_msg(const struct kvaser_usb *dev,
887 cf->can_dlc); 885 cf->can_dlc);
888 } 886 }
889 887
890 netif_rx(skb);
891
892 stats->rx_packets++; 888 stats->rx_packets++;
893 stats->rx_bytes += cf->can_dlc; 889 stats->rx_bytes += cf->can_dlc;
890 netif_rx(skb);
894} 891}
895 892
896static void kvaser_usb_start_chip_reply(const struct kvaser_usb *dev, 893static void kvaser_usb_start_chip_reply(const struct kvaser_usb *dev,
@@ -1246,6 +1243,9 @@ static int kvaser_usb_close(struct net_device *netdev)
1246 if (err) 1243 if (err)
1247 netdev_warn(netdev, "Cannot stop device, error %d\n", err); 1244 netdev_warn(netdev, "Cannot stop device, error %d\n", err);
1248 1245
1246 /* reset tx contexts */
1247 kvaser_usb_unlink_tx_urbs(priv);
1248
1249 priv->can.state = CAN_STATE_STOPPED; 1249 priv->can.state = CAN_STATE_STOPPED;
1250 close_candev(priv->netdev); 1250 close_candev(priv->netdev);
1251 1251
@@ -1294,12 +1294,14 @@ static netdev_tx_t kvaser_usb_start_xmit(struct sk_buff *skb,
1294 if (!urb) { 1294 if (!urb) {
1295 netdev_err(netdev, "No memory left for URBs\n"); 1295 netdev_err(netdev, "No memory left for URBs\n");
1296 stats->tx_dropped++; 1296 stats->tx_dropped++;
1297 goto nourbmem; 1297 dev_kfree_skb(skb);
1298 return NETDEV_TX_OK;
1298 } 1299 }
1299 1300
1300 buf = kmalloc(sizeof(struct kvaser_msg), GFP_ATOMIC); 1301 buf = kmalloc(sizeof(struct kvaser_msg), GFP_ATOMIC);
1301 if (!buf) { 1302 if (!buf) {
1302 stats->tx_dropped++; 1303 stats->tx_dropped++;
1304 dev_kfree_skb(skb);
1303 goto nobufmem; 1305 goto nobufmem;
1304 } 1306 }
1305 1307
@@ -1334,6 +1336,7 @@ static netdev_tx_t kvaser_usb_start_xmit(struct sk_buff *skb,
1334 } 1336 }
1335 } 1337 }
1336 1338
1339 /* This should never happen; it implies a flow control bug */
1337 if (!context) { 1340 if (!context) {
1338 netdev_warn(netdev, "cannot find free context\n"); 1341 netdev_warn(netdev, "cannot find free context\n");
1339 ret = NETDEV_TX_BUSY; 1342 ret = NETDEV_TX_BUSY;
@@ -1364,9 +1367,6 @@ static netdev_tx_t kvaser_usb_start_xmit(struct sk_buff *skb,
1364 if (unlikely(err)) { 1367 if (unlikely(err)) {
1365 can_free_echo_skb(netdev, context->echo_index); 1368 can_free_echo_skb(netdev, context->echo_index);
1366 1369
1367 skb = NULL; /* set to NULL to avoid double free in
1368 * dev_kfree_skb(skb) */
1369
1370 atomic_dec(&priv->active_tx_urbs); 1370 atomic_dec(&priv->active_tx_urbs);
1371 usb_unanchor_urb(urb); 1371 usb_unanchor_urb(urb);
1372 1372
@@ -1388,8 +1388,6 @@ releasebuf:
1388 kfree(buf); 1388 kfree(buf);
1389nobufmem: 1389nobufmem:
1390 usb_free_urb(urb); 1390 usb_free_urb(urb);
1391nourbmem:
1392 dev_kfree_skb(skb);
1393 return ret; 1391 return ret;
1394} 1392}
1395 1393
@@ -1502,6 +1500,10 @@ static int kvaser_usb_init_one(struct usb_interface *intf,
1502 struct kvaser_usb_net_priv *priv; 1500 struct kvaser_usb_net_priv *priv;
1503 int i, err; 1501 int i, err;
1504 1502
1503 err = kvaser_usb_send_simple_msg(dev, CMD_RESET_CHIP, channel);
1504 if (err)
1505 return err;
1506
1505 netdev = alloc_candev(sizeof(*priv), MAX_TX_URBS); 1507 netdev = alloc_candev(sizeof(*priv), MAX_TX_URBS);
1506 if (!netdev) { 1508 if (!netdev) {
1507 dev_err(&intf->dev, "Cannot alloc candev\n"); 1509 dev_err(&intf->dev, "Cannot alloc candev\n");
@@ -1606,9 +1608,6 @@ static int kvaser_usb_probe(struct usb_interface *intf,
1606 1608
1607 usb_set_intfdata(intf, dev); 1609 usb_set_intfdata(intf, dev);
1608 1610
1609 for (i = 0; i < MAX_NET_DEVICES; i++)
1610 kvaser_usb_send_simple_msg(dev, CMD_RESET_CHIP, i);
1611
1612 err = kvaser_usb_get_software_info(dev); 1611 err = kvaser_usb_get_software_info(dev);
1613 if (err) { 1612 if (err) {
1614 dev_err(&intf->dev, 1613 dev_err(&intf->dev,
diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index 05c6af6c418f..3007d95fbb9f 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -1167,10 +1167,10 @@ static int bgmac_poll(struct napi_struct *napi, int weight)
1167 bgmac->int_status = 0; 1167 bgmac->int_status = 0;
1168 } 1168 }
1169 1169
1170 if (handled < weight) 1170 if (handled < weight) {
1171 napi_complete(napi); 1171 napi_complete(napi);
1172 1172 bgmac_chip_intrs_on(bgmac);
1173 bgmac_chip_intrs_on(bgmac); 1173 }
1174 1174
1175 return handled; 1175 return handled;
1176} 1176}
@@ -1515,6 +1515,8 @@ static int bgmac_probe(struct bcma_device *core)
1515 if (core->bus->sprom.boardflags_lo & BGMAC_BFL_ENETADM) 1515 if (core->bus->sprom.boardflags_lo & BGMAC_BFL_ENETADM)
1516 bgmac_warn(bgmac, "Support for ADMtek ethernet switch not implemented\n"); 1516 bgmac_warn(bgmac, "Support for ADMtek ethernet switch not implemented\n");
1517 1517
1518 netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
1519
1518 err = bgmac_mii_register(bgmac); 1520 err = bgmac_mii_register(bgmac);
1519 if (err) { 1521 if (err) {
1520 bgmac_err(bgmac, "Cannot register MDIO\n"); 1522 bgmac_err(bgmac, "Cannot register MDIO\n");
@@ -1529,8 +1531,6 @@ static int bgmac_probe(struct bcma_device *core)
1529 1531
1530 netif_carrier_off(net_dev); 1532 netif_carrier_off(net_dev);
1531 1533
1532 netif_napi_add(net_dev, &bgmac->napi, bgmac_poll, BGMAC_WEIGHT);
1533
1534 return 0; 1534 return 0;
1535 1535
1536err_mii_unregister: 1536err_mii_unregister:
@@ -1549,9 +1549,9 @@ static void bgmac_remove(struct bcma_device *core)
1549{ 1549{
1550 struct bgmac *bgmac = bcma_get_drvdata(core); 1550 struct bgmac *bgmac = bcma_get_drvdata(core);
1551 1551
1552 netif_napi_del(&bgmac->napi);
1553 unregister_netdev(bgmac->net_dev); 1552 unregister_netdev(bgmac->net_dev);
1554 bgmac_mii_unregister(bgmac); 1553 bgmac_mii_unregister(bgmac);
1554 netif_napi_del(&bgmac->napi);
1555 bgmac_dma_free(bgmac); 1555 bgmac_dma_free(bgmac);
1556 bcma_set_drvdata(core, NULL); 1556 bcma_set_drvdata(core, NULL);
1557 free_netdev(bgmac->net_dev); 1557 free_netdev(bgmac->net_dev);
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 41a0a5498da7..d48806b5cd88 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -4383,8 +4383,9 @@ static int be_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
4383 * distinguish various types of transports (VxLAN, GRE, NVGRE ..). So, offload 4383 * distinguish various types of transports (VxLAN, GRE, NVGRE ..). So, offload
4384 * is expected to work across all types of IP tunnels once exported. Skyhawk 4384 * is expected to work across all types of IP tunnels once exported. Skyhawk
4385 * supports offloads for either VxLAN or NVGRE, exclusively. So we export VxLAN 4385 * supports offloads for either VxLAN or NVGRE, exclusively. So we export VxLAN
4386 * offloads in hw_enc_features only when a VxLAN port is added. Note this only 4386 * offloads in hw_enc_features only when a VxLAN port is added. If other (non
4387 * ensures that other tunnels work fine while VxLAN offloads are not enabled. 4387 * VxLAN) tunnels are configured while VxLAN offloads are enabled, offloads for
4388 * those other tunnels are unexported on the fly through ndo_features_check().
4388 * 4389 *
4389 * Skyhawk supports VxLAN offloads only for one UDP dport. So, if the stack 4390 * Skyhawk supports VxLAN offloads only for one UDP dport. So, if the stack
4390 * adds more than one port, disable offloads and don't re-enable them again 4391 * adds more than one port, disable offloads and don't re-enable them again
@@ -4463,7 +4464,41 @@ static netdev_features_t be_features_check(struct sk_buff *skb,
4463 struct net_device *dev, 4464 struct net_device *dev,
4464 netdev_features_t features) 4465 netdev_features_t features)
4465{ 4466{
4466 return vxlan_features_check(skb, features); 4467 struct be_adapter *adapter = netdev_priv(dev);
4468 u8 l4_hdr = 0;
4469
4470 /* The code below restricts offload features for some tunneled packets.
4471 * Offload features for normal (non tunnel) packets are unchanged.
4472 */
4473 if (!skb->encapsulation ||
4474 !(adapter->flags & BE_FLAGS_VXLAN_OFFLOADS))
4475 return features;
4476
4477 /* It's an encapsulated packet and VxLAN offloads are enabled. We
4478 * should disable tunnel offload features if it's not a VxLAN packet,
4479 * as tunnel offloads have been enabled only for VxLAN. This is done to
4480 * allow other tunneled traffic like GRE work fine while VxLAN
4481 * offloads are configured in Skyhawk-R.
4482 */
4483 switch (vlan_get_protocol(skb)) {
4484 case htons(ETH_P_IP):
4485 l4_hdr = ip_hdr(skb)->protocol;
4486 break;
4487 case htons(ETH_P_IPV6):
4488 l4_hdr = ipv6_hdr(skb)->nexthdr;
4489 break;
4490 default:
4491 return features;
4492 }
4493
4494 if (l4_hdr != IPPROTO_UDP ||
4495 skb->inner_protocol_type != ENCAP_TYPE_ETHER ||
4496 skb->inner_protocol != htons(ETH_P_TEB) ||
4497 skb_inner_mac_header(skb) - skb_transport_header(skb) !=
4498 sizeof(struct udphdr) + sizeof(struct vxlanhdr))
4499 return features & ~(NETIF_F_ALL_CSUM | NETIF_F_GSO_MASK);
4500
4501 return features;
4467} 4502}
4468#endif 4503#endif
4469 4504
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index d0d6dc1b8e46..ac6a8f1eea6c 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -475,7 +475,8 @@ static int mlx4_en_tunnel_steer_add(struct mlx4_en_priv *priv, unsigned char *ad
475{ 475{
476 int err; 476 int err;
477 477
478 if (priv->mdev->dev->caps.tunnel_offload_mode != MLX4_TUNNEL_OFFLOAD_MODE_VXLAN) 478 if (priv->mdev->dev->caps.tunnel_offload_mode != MLX4_TUNNEL_OFFLOAD_MODE_VXLAN ||
479 priv->mdev->dev->caps.dmfs_high_steer_mode == MLX4_STEERING_DMFS_A0_STATIC)
479 return 0; /* do nothing */ 480 return 0; /* do nothing */
480 481
481 err = mlx4_tunnel_steer_add(priv->mdev->dev, addr, priv->port, qpn, 482 err = mlx4_tunnel_steer_add(priv->mdev->dev, addr, priv->port, qpn,
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 03e9eb0dc761..6e08352ec994 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -1744,8 +1744,7 @@ static void choose_tunnel_offload_mode(struct mlx4_dev *dev,
1744 struct mlx4_dev_cap *dev_cap) 1744 struct mlx4_dev_cap *dev_cap)
1745{ 1745{
1746 if (dev->caps.steering_mode == MLX4_STEERING_MODE_DEVICE_MANAGED && 1746 if (dev->caps.steering_mode == MLX4_STEERING_MODE_DEVICE_MANAGED &&
1747 dev_cap->flags2 & MLX4_DEV_CAP_FLAG2_VXLAN_OFFLOADS && 1747 dev_cap->flags2 & MLX4_DEV_CAP_FLAG2_VXLAN_OFFLOADS)
1748 dev->caps.dmfs_high_steer_mode != MLX4_STEERING_DMFS_A0_STATIC)
1749 dev->caps.tunnel_offload_mode = MLX4_TUNNEL_OFFLOAD_MODE_VXLAN; 1748 dev->caps.tunnel_offload_mode = MLX4_TUNNEL_OFFLOAD_MODE_VXLAN;
1750 else 1749 else
1751 dev->caps.tunnel_offload_mode = MLX4_TUNNEL_OFFLOAD_MODE_NONE; 1750 dev->caps.tunnel_offload_mode = MLX4_TUNNEL_OFFLOAD_MODE_NONE;
diff --git a/drivers/net/ethernet/neterion/s2io.c b/drivers/net/ethernet/neterion/s2io.c
index f5e4b820128b..db0c7a9aee60 100644
--- a/drivers/net/ethernet/neterion/s2io.c
+++ b/drivers/net/ethernet/neterion/s2io.c
@@ -6987,7 +6987,9 @@ static int s2io_add_isr(struct s2io_nic *sp)
6987 if (sp->s2io_entries[i].in_use == MSIX_FLG) { 6987 if (sp->s2io_entries[i].in_use == MSIX_FLG) {
6988 if (sp->s2io_entries[i].type == 6988 if (sp->s2io_entries[i].type ==
6989 MSIX_RING_TYPE) { 6989 MSIX_RING_TYPE) {
6990 sprintf(sp->desc[i], "%s:MSI-X-%d-RX", 6990 snprintf(sp->desc[i],
6991 sizeof(sp->desc[i]),
6992 "%s:MSI-X-%d-RX",
6991 dev->name, i); 6993 dev->name, i);
6992 err = request_irq(sp->entries[i].vector, 6994 err = request_irq(sp->entries[i].vector,
6993 s2io_msix_ring_handle, 6995 s2io_msix_ring_handle,
@@ -6996,7 +6998,9 @@ static int s2io_add_isr(struct s2io_nic *sp)
6996 sp->s2io_entries[i].arg); 6998 sp->s2io_entries[i].arg);
6997 } else if (sp->s2io_entries[i].type == 6999 } else if (sp->s2io_entries[i].type ==
6998 MSIX_ALARM_TYPE) { 7000 MSIX_ALARM_TYPE) {
6999 sprintf(sp->desc[i], "%s:MSI-X-%d-TX", 7001 snprintf(sp->desc[i],
7002 sizeof(sp->desc[i]),
7003 "%s:MSI-X-%d-TX",
7000 dev->name, i); 7004 dev->name, i);
7001 err = request_irq(sp->entries[i].vector, 7005 err = request_irq(sp->entries[i].vector,
7002 s2io_msix_fifo_handle, 7006 s2io_msix_fifo_handle,
@@ -8154,7 +8158,8 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
8154 "%s: UDP Fragmentation Offload(UFO) enabled\n", 8158 "%s: UDP Fragmentation Offload(UFO) enabled\n",
8155 dev->name); 8159 dev->name);
8156 /* Initialize device name */ 8160 /* Initialize device name */
8157 sprintf(sp->name, "%s Neterion %s", dev->name, sp->product_name); 8161 snprintf(sp->name, sizeof(sp->name), "%s Neterion %s", dev->name,
8162 sp->product_name);
8158 8163
8159 if (vlan_tag_strip) 8164 if (vlan_tag_strip)
8160 sp->vlan_strip_flag = 1; 8165 sp->vlan_strip_flag = 1;
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 37583a9d8853..6576243222af 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -498,6 +498,8 @@ static struct sh_eth_cpu_data r8a779x_data = {
498 EESR_ECI, 498 EESR_ECI,
499 .fdr_value = 0x00000f0f, 499 .fdr_value = 0x00000f0f,
500 500
501 .trscer_err_mask = DESC_I_RINT8,
502
501 .apr = 1, 503 .apr = 1,
502 .mpr = 1, 504 .mpr = 1,
503 .tpauser = 1, 505 .tpauser = 1,
@@ -538,8 +540,6 @@ static struct sh_eth_cpu_data sh7724_data = {
538 EESR_RDE | EESR_RFRMER | EESR_TFE | EESR_TDE | 540 EESR_RDE | EESR_RFRMER | EESR_TFE | EESR_TDE |
539 EESR_ECI, 541 EESR_ECI,
540 542
541 .trscer_err_mask = DESC_I_RINT8,
542
543 .apr = 1, 543 .apr = 1,
544 .mpr = 1, 544 .mpr = 1,
545 .tpauser = 1, 545 .tpauser = 1,
@@ -1827,6 +1827,9 @@ static int sh_eth_get_settings(struct net_device *ndev,
1827 unsigned long flags; 1827 unsigned long flags;
1828 int ret; 1828 int ret;
1829 1829
1830 if (!mdp->phydev)
1831 return -ENODEV;
1832
1830 spin_lock_irqsave(&mdp->lock, flags); 1833 spin_lock_irqsave(&mdp->lock, flags);
1831 ret = phy_ethtool_gset(mdp->phydev, ecmd); 1834 ret = phy_ethtool_gset(mdp->phydev, ecmd);
1832 spin_unlock_irqrestore(&mdp->lock, flags); 1835 spin_unlock_irqrestore(&mdp->lock, flags);
@@ -1841,6 +1844,9 @@ static int sh_eth_set_settings(struct net_device *ndev,
1841 unsigned long flags; 1844 unsigned long flags;
1842 int ret; 1845 int ret;
1843 1846
1847 if (!mdp->phydev)
1848 return -ENODEV;
1849
1844 spin_lock_irqsave(&mdp->lock, flags); 1850 spin_lock_irqsave(&mdp->lock, flags);
1845 1851
1846 /* disable tx and rx */ 1852 /* disable tx and rx */
@@ -1875,6 +1881,9 @@ static int sh_eth_nway_reset(struct net_device *ndev)
1875 unsigned long flags; 1881 unsigned long flags;
1876 int ret; 1882 int ret;
1877 1883
1884 if (!mdp->phydev)
1885 return -ENODEV;
1886
1878 spin_lock_irqsave(&mdp->lock, flags); 1887 spin_lock_irqsave(&mdp->lock, flags);
1879 ret = phy_start_aneg(mdp->phydev); 1888 ret = phy_start_aneg(mdp->phydev);
1880 spin_unlock_irqrestore(&mdp->lock, flags); 1889 spin_unlock_irqrestore(&mdp->lock, flags);
@@ -2184,6 +2193,7 @@ static int sh_eth_close(struct net_device *ndev)
2184 if (mdp->phydev) { 2193 if (mdp->phydev) {
2185 phy_stop(mdp->phydev); 2194 phy_stop(mdp->phydev);
2186 phy_disconnect(mdp->phydev); 2195 phy_disconnect(mdp->phydev);
2196 mdp->phydev = NULL;
2187 } 2197 }
2188 2198
2189 free_irq(ndev->irq, ndev); 2199 free_irq(ndev->irq, ndev);
@@ -2417,7 +2427,7 @@ static int sh_eth_tsu_purge_all(struct net_device *ndev)
2417 struct sh_eth_private *mdp = netdev_priv(ndev); 2427 struct sh_eth_private *mdp = netdev_priv(ndev);
2418 int i, ret; 2428 int i, ret;
2419 2429
2420 if (unlikely(!mdp->cd->tsu)) 2430 if (!mdp->cd->tsu)
2421 return 0; 2431 return 0;
2422 2432
2423 for (i = 0; i < SH_ETH_TSU_CAM_ENTRIES; i++) { 2433 for (i = 0; i < SH_ETH_TSU_CAM_ENTRIES; i++) {
@@ -2440,7 +2450,7 @@ static void sh_eth_tsu_purge_mcast(struct net_device *ndev)
2440 void *reg_offset = sh_eth_tsu_get_offset(mdp, TSU_ADRH0); 2450 void *reg_offset = sh_eth_tsu_get_offset(mdp, TSU_ADRH0);
2441 int i; 2451 int i;
2442 2452
2443 if (unlikely(!mdp->cd->tsu)) 2453 if (!mdp->cd->tsu)
2444 return; 2454 return;
2445 2455
2446 for (i = 0; i < SH_ETH_TSU_CAM_ENTRIES; i++, reg_offset += 8) { 2456 for (i = 0; i < SH_ETH_TSU_CAM_ENTRIES; i++, reg_offset += 8) {
@@ -2450,8 +2460,8 @@ static void sh_eth_tsu_purge_mcast(struct net_device *ndev)
2450 } 2460 }
2451} 2461}
2452 2462
2453/* Multicast reception directions set */ 2463/* Update promiscuous flag and multicast filter */
2454static void sh_eth_set_multicast_list(struct net_device *ndev) 2464static void sh_eth_set_rx_mode(struct net_device *ndev)
2455{ 2465{
2456 struct sh_eth_private *mdp = netdev_priv(ndev); 2466 struct sh_eth_private *mdp = netdev_priv(ndev);
2457 u32 ecmr_bits; 2467 u32 ecmr_bits;
@@ -2462,7 +2472,9 @@ static void sh_eth_set_multicast_list(struct net_device *ndev)
2462 /* Initial condition is MCT = 1, PRM = 0. 2472 /* Initial condition is MCT = 1, PRM = 0.
2463 * Depending on ndev->flags, set PRM or clear MCT 2473 * Depending on ndev->flags, set PRM or clear MCT
2464 */ 2474 */
2465 ecmr_bits = (sh_eth_read(ndev, ECMR) & ~ECMR_PRM) | ECMR_MCT; 2475 ecmr_bits = sh_eth_read(ndev, ECMR) & ~ECMR_PRM;
2476 if (mdp->cd->tsu)
2477 ecmr_bits |= ECMR_MCT;
2466 2478
2467 if (!(ndev->flags & IFF_MULTICAST)) { 2479 if (!(ndev->flags & IFF_MULTICAST)) {
2468 sh_eth_tsu_purge_mcast(ndev); 2480 sh_eth_tsu_purge_mcast(ndev);
@@ -2491,9 +2503,6 @@ static void sh_eth_set_multicast_list(struct net_device *ndev)
2491 } 2503 }
2492 } 2504 }
2493 } 2505 }
2494 } else {
2495 /* Normal, unicast/broadcast-only mode. */
2496 ecmr_bits = (ecmr_bits & ~ECMR_PRM) | ECMR_MCT;
2497 } 2506 }
2498 2507
2499 /* update the ethernet mode */ 2508 /* update the ethernet mode */
@@ -2701,6 +2710,7 @@ static const struct net_device_ops sh_eth_netdev_ops = {
2701 .ndo_stop = sh_eth_close, 2710 .ndo_stop = sh_eth_close,
2702 .ndo_start_xmit = sh_eth_start_xmit, 2711 .ndo_start_xmit = sh_eth_start_xmit,
2703 .ndo_get_stats = sh_eth_get_stats, 2712 .ndo_get_stats = sh_eth_get_stats,
2713 .ndo_set_rx_mode = sh_eth_set_rx_mode,
2704 .ndo_tx_timeout = sh_eth_tx_timeout, 2714 .ndo_tx_timeout = sh_eth_tx_timeout,
2705 .ndo_do_ioctl = sh_eth_do_ioctl, 2715 .ndo_do_ioctl = sh_eth_do_ioctl,
2706 .ndo_validate_addr = eth_validate_addr, 2716 .ndo_validate_addr = eth_validate_addr,
@@ -2713,7 +2723,7 @@ static const struct net_device_ops sh_eth_netdev_ops_tsu = {
2713 .ndo_stop = sh_eth_close, 2723 .ndo_stop = sh_eth_close,
2714 .ndo_start_xmit = sh_eth_start_xmit, 2724 .ndo_start_xmit = sh_eth_start_xmit,
2715 .ndo_get_stats = sh_eth_get_stats, 2725 .ndo_get_stats = sh_eth_get_stats,
2716 .ndo_set_rx_mode = sh_eth_set_multicast_list, 2726 .ndo_set_rx_mode = sh_eth_set_rx_mode,
2717 .ndo_vlan_rx_add_vid = sh_eth_vlan_rx_add_vid, 2727 .ndo_vlan_rx_add_vid = sh_eth_vlan_rx_add_vid,
2718 .ndo_vlan_rx_kill_vid = sh_eth_vlan_rx_kill_vid, 2728 .ndo_vlan_rx_kill_vid = sh_eth_vlan_rx_kill_vid,
2719 .ndo_tx_timeout = sh_eth_tx_timeout, 2729 .ndo_tx_timeout = sh_eth_tx_timeout,
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
index 698494481d18..b1a271853d85 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
@@ -474,13 +474,19 @@ static int init_rx_ring(struct net_device *dev, u8 queue_no,
474 /* allocate memory for RX skbuff array */ 474 /* allocate memory for RX skbuff array */
475 rx_ring->rx_skbuff_dma = kmalloc_array(rx_rsize, 475 rx_ring->rx_skbuff_dma = kmalloc_array(rx_rsize,
476 sizeof(dma_addr_t), GFP_KERNEL); 476 sizeof(dma_addr_t), GFP_KERNEL);
477 if (rx_ring->rx_skbuff_dma == NULL) 477 if (!rx_ring->rx_skbuff_dma) {
478 goto dmamem_err; 478 dma_free_coherent(priv->device,
479 rx_rsize * sizeof(struct sxgbe_rx_norm_desc),
480 rx_ring->dma_rx, rx_ring->dma_rx_phy);
481 goto error;
482 }
479 483
480 rx_ring->rx_skbuff = kmalloc_array(rx_rsize, 484 rx_ring->rx_skbuff = kmalloc_array(rx_rsize,
481 sizeof(struct sk_buff *), GFP_KERNEL); 485 sizeof(struct sk_buff *), GFP_KERNEL);
482 if (rx_ring->rx_skbuff == NULL) 486 if (!rx_ring->rx_skbuff) {
483 goto rxbuff_err; 487 kfree(rx_ring->rx_skbuff_dma);
488 goto error;
489 }
484 490
485 /* initialise the buffers */ 491 /* initialise the buffers */
486 for (desc_index = 0; desc_index < rx_rsize; desc_index++) { 492 for (desc_index = 0; desc_index < rx_rsize; desc_index++) {
@@ -502,13 +508,6 @@ static int init_rx_ring(struct net_device *dev, u8 queue_no,
502err_init_rx_buffers: 508err_init_rx_buffers:
503 while (--desc_index >= 0) 509 while (--desc_index >= 0)
504 free_rx_ring(priv->device, rx_ring, desc_index); 510 free_rx_ring(priv->device, rx_ring, desc_index);
505 kfree(rx_ring->rx_skbuff);
506rxbuff_err:
507 kfree(rx_ring->rx_skbuff_dma);
508dmamem_err:
509 dma_free_coherent(priv->device,
510 rx_rsize * sizeof(struct sxgbe_rx_norm_desc),
511 rx_ring->dma_rx, rx_ring->dma_rx_phy);
512error: 511error:
513 return -ENOMEM; 512 return -ENOMEM;
514} 513}
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
index 866560ea9e18..b02eed12bfc5 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
@@ -108,10 +108,6 @@ static int sxgbe_platform_probe(struct platform_device *pdev)
108 } 108 }
109 } 109 }
110 110
111 /* Get MAC address if available (DT) */
112 if (mac)
113 ether_addr_copy(priv->dev->dev_addr, mac);
114
115 priv = sxgbe_drv_probe(&(pdev->dev), plat_dat, addr); 111 priv = sxgbe_drv_probe(&(pdev->dev), plat_dat, addr);
116 if (!priv) { 112 if (!priv) {
117 pr_err("%s: main driver probe failed\n", __func__); 113 pr_err("%s: main driver probe failed\n", __func__);
@@ -125,6 +121,10 @@ static int sxgbe_platform_probe(struct platform_device *pdev)
125 goto err_drv_remove; 121 goto err_drv_remove;
126 } 122 }
127 123
124 /* Get MAC address if available (DT) */
125 if (mac)
126 ether_addr_copy(priv->dev->dev_addr, mac);
127
128 /* Get the TX/RX IRQ numbers */ 128 /* Get the TX/RX IRQ numbers */
129 for (i = 0, chan = 1; i < SXGBE_TX_QUEUES; i++) { 129 for (i = 0, chan = 1; i < SXGBE_TX_QUEUES; i++) {
130 priv->txq[i]->irq_no = irq_of_parse_and_map(node, chan++); 130 priv->txq[i]->irq_no = irq_of_parse_and_map(node, chan++);
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 64d1cef4cda1..e068d48b0f21 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1634,16 +1634,24 @@ static inline int cpsw_add_vlan_ale_entry(struct cpsw_priv *priv,
1634 unsigned short vid) 1634 unsigned short vid)
1635{ 1635{
1636 int ret; 1636 int ret;
1637 int unreg_mcast_mask; 1637 int unreg_mcast_mask = 0;
1638 u32 port_mask;
1638 1639
1639 if (priv->ndev->flags & IFF_ALLMULTI) 1640 if (priv->data.dual_emac) {
1640 unreg_mcast_mask = ALE_ALL_PORTS; 1641 port_mask = (1 << (priv->emac_port + 1)) | ALE_PORT_HOST;
1641 else 1642
1642 unreg_mcast_mask = ALE_PORT_1 | ALE_PORT_2; 1643 if (priv->ndev->flags & IFF_ALLMULTI)
1644 unreg_mcast_mask = port_mask;
1645 } else {
1646 port_mask = ALE_ALL_PORTS;
1647
1648 if (priv->ndev->flags & IFF_ALLMULTI)
1649 unreg_mcast_mask = ALE_ALL_PORTS;
1650 else
1651 unreg_mcast_mask = ALE_PORT_1 | ALE_PORT_2;
1652 }
1643 1653
1644 ret = cpsw_ale_add_vlan(priv->ale, vid, 1654 ret = cpsw_ale_add_vlan(priv->ale, vid, port_mask, 0, port_mask,
1645 ALE_ALL_PORTS << priv->host_port,
1646 0, ALE_ALL_PORTS << priv->host_port,
1647 unreg_mcast_mask << priv->host_port); 1655 unreg_mcast_mask << priv->host_port);
1648 if (ret != 0) 1656 if (ret != 0)
1649 return ret; 1657 return ret;
@@ -1654,8 +1662,7 @@ static inline int cpsw_add_vlan_ale_entry(struct cpsw_priv *priv,
1654 goto clean_vid; 1662 goto clean_vid;
1655 1663
1656 ret = cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast, 1664 ret = cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
1657 ALE_ALL_PORTS << priv->host_port, 1665 port_mask, ALE_VLAN, vid, 0);
1658 ALE_VLAN, vid, 0);
1659 if (ret != 0) 1666 if (ret != 0)
1660 goto clean_vlan_ucast; 1667 goto clean_vlan_ucast;
1661 return 0; 1668 return 0;
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index ea712512c7d1..5fae4354722c 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -62,6 +62,7 @@
62#include <linux/of.h> 62#include <linux/of.h>
63#include <linux/of_address.h> 63#include <linux/of_address.h>
64#include <linux/of_device.h> 64#include <linux/of_device.h>
65#include <linux/of_mdio.h>
65#include <linux/of_irq.h> 66#include <linux/of_irq.h>
66#include <linux/of_net.h> 67#include <linux/of_net.h>
67 68
@@ -343,9 +344,7 @@ struct emac_priv {
343 u32 multicast_hash_cnt[EMAC_NUM_MULTICAST_BITS]; 344 u32 multicast_hash_cnt[EMAC_NUM_MULTICAST_BITS];
344 u32 rx_addr_type; 345 u32 rx_addr_type;
345 const char *phy_id; 346 const char *phy_id;
346#ifdef CONFIG_OF
347 struct device_node *phy_node; 347 struct device_node *phy_node;
348#endif
349 struct phy_device *phydev; 348 struct phy_device *phydev;
350 spinlock_t lock; 349 spinlock_t lock;
351 /*platform specific members*/ 350 /*platform specific members*/
@@ -922,6 +921,16 @@ static void emac_int_disable(struct emac_priv *priv)
922 if (priv->int_disable) 921 if (priv->int_disable)
923 priv->int_disable(); 922 priv->int_disable();
924 923
924 /* NOTE: Rx Threshold and Misc interrupts are not enabled */
925
926 /* ack rxen only then a new pulse will be generated */
927 emac_write(EMAC_DM646X_MACEOIVECTOR,
928 EMAC_DM646X_MAC_EOI_C0_RXEN);
929
930 /* ack txen- only then a new pulse will be generated */
931 emac_write(EMAC_DM646X_MACEOIVECTOR,
932 EMAC_DM646X_MAC_EOI_C0_TXEN);
933
925 local_irq_restore(flags); 934 local_irq_restore(flags);
926 935
927 } else { 936 } else {
@@ -951,15 +960,6 @@ static void emac_int_enable(struct emac_priv *priv)
951 * register */ 960 * register */
952 961
953 /* NOTE: Rx Threshold and Misc interrupts are not enabled */ 962 /* NOTE: Rx Threshold and Misc interrupts are not enabled */
954
955 /* ack rxen only then a new pulse will be generated */
956 emac_write(EMAC_DM646X_MACEOIVECTOR,
957 EMAC_DM646X_MAC_EOI_C0_RXEN);
958
959 /* ack txen- only then a new pulse will be generated */
960 emac_write(EMAC_DM646X_MACEOIVECTOR,
961 EMAC_DM646X_MAC_EOI_C0_TXEN);
962
963 } else { 963 } else {
964 /* Set DM644x control registers for interrupt control */ 964 /* Set DM644x control registers for interrupt control */
965 emac_ctrl_write(EMAC_CTRL_EWCTL, 0x1); 965 emac_ctrl_write(EMAC_CTRL_EWCTL, 0x1);
@@ -1537,7 +1537,13 @@ static int emac_dev_open(struct net_device *ndev)
1537 int i = 0; 1537 int i = 0;
1538 struct emac_priv *priv = netdev_priv(ndev); 1538 struct emac_priv *priv = netdev_priv(ndev);
1539 1539
1540 pm_runtime_get(&priv->pdev->dev); 1540 ret = pm_runtime_get_sync(&priv->pdev->dev);
1541 if (ret < 0) {
1542 pm_runtime_put_noidle(&priv->pdev->dev);
1543 dev_err(&priv->pdev->dev, "%s: failed to get_sync(%d)\n",
1544 __func__, ret);
1545 return ret;
1546 }
1541 1547
1542 netif_carrier_off(ndev); 1548 netif_carrier_off(ndev);
1543 for (cnt = 0; cnt < ETH_ALEN; cnt++) 1549 for (cnt = 0; cnt < ETH_ALEN; cnt++)
@@ -1596,8 +1602,20 @@ static int emac_dev_open(struct net_device *ndev)
1596 cpdma_ctlr_start(priv->dma); 1602 cpdma_ctlr_start(priv->dma);
1597 1603
1598 priv->phydev = NULL; 1604 priv->phydev = NULL;
1605
1606 if (priv->phy_node) {
1607 priv->phydev = of_phy_connect(ndev, priv->phy_node,
1608 &emac_adjust_link, 0, 0);
1609 if (!priv->phydev) {
1610 dev_err(emac_dev, "could not connect to phy %s\n",
1611 priv->phy_node->full_name);
1612 ret = -ENODEV;
1613 goto err;
1614 }
1615 }
1616
1599 /* use the first phy on the bus if pdata did not give us a phy id */ 1617 /* use the first phy on the bus if pdata did not give us a phy id */
1600 if (!priv->phy_id) { 1618 if (!priv->phydev && !priv->phy_id) {
1601 struct device *phy; 1619 struct device *phy;
1602 1620
1603 phy = bus_find_device(&mdio_bus_type, NULL, NULL, 1621 phy = bus_find_device(&mdio_bus_type, NULL, NULL,
@@ -1606,7 +1624,7 @@ static int emac_dev_open(struct net_device *ndev)
1606 priv->phy_id = dev_name(phy); 1624 priv->phy_id = dev_name(phy);
1607 } 1625 }
1608 1626
1609 if (priv->phy_id && *priv->phy_id) { 1627 if (!priv->phydev && priv->phy_id && *priv->phy_id) {
1610 priv->phydev = phy_connect(ndev, priv->phy_id, 1628 priv->phydev = phy_connect(ndev, priv->phy_id,
1611 &emac_adjust_link, 1629 &emac_adjust_link,
1612 PHY_INTERFACE_MODE_MII); 1630 PHY_INTERFACE_MODE_MII);
@@ -1627,7 +1645,9 @@ static int emac_dev_open(struct net_device *ndev)
1627 "(mii_bus:phy_addr=%s, id=%x)\n", 1645 "(mii_bus:phy_addr=%s, id=%x)\n",
1628 priv->phydev->drv->name, dev_name(&priv->phydev->dev), 1646 priv->phydev->drv->name, dev_name(&priv->phydev->dev),
1629 priv->phydev->phy_id); 1647 priv->phydev->phy_id);
1630 } else { 1648 }
1649
1650 if (!priv->phydev) {
1631 /* No PHY , fix the link, speed and duplex settings */ 1651 /* No PHY , fix the link, speed and duplex settings */
1632 dev_notice(emac_dev, "no phy, defaulting to 100/full\n"); 1652 dev_notice(emac_dev, "no phy, defaulting to 100/full\n");
1633 priv->link = 1; 1653 priv->link = 1;
@@ -1724,6 +1744,15 @@ static struct net_device_stats *emac_dev_getnetstats(struct net_device *ndev)
1724 struct emac_priv *priv = netdev_priv(ndev); 1744 struct emac_priv *priv = netdev_priv(ndev);
1725 u32 mac_control; 1745 u32 mac_control;
1726 u32 stats_clear_mask; 1746 u32 stats_clear_mask;
1747 int err;
1748
1749 err = pm_runtime_get_sync(&priv->pdev->dev);
1750 if (err < 0) {
1751 pm_runtime_put_noidle(&priv->pdev->dev);
1752 dev_err(&priv->pdev->dev, "%s: failed to get_sync(%d)\n",
1753 __func__, err);
1754 return &ndev->stats;
1755 }
1727 1756
1728 /* update emac hardware stats and reset the registers*/ 1757 /* update emac hardware stats and reset the registers*/
1729 1758
@@ -1766,6 +1795,8 @@ static struct net_device_stats *emac_dev_getnetstats(struct net_device *ndev)
1766 ndev->stats.tx_fifo_errors += emac_read(EMAC_TXUNDERRUN); 1795 ndev->stats.tx_fifo_errors += emac_read(EMAC_TXUNDERRUN);
1767 emac_write(EMAC_TXUNDERRUN, stats_clear_mask); 1796 emac_write(EMAC_TXUNDERRUN, stats_clear_mask);
1768 1797
1798 pm_runtime_put(&priv->pdev->dev);
1799
1769 return &ndev->stats; 1800 return &ndev->stats;
1770} 1801}
1771 1802
@@ -1859,7 +1890,7 @@ davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv)
1859static int davinci_emac_probe(struct platform_device *pdev) 1890static int davinci_emac_probe(struct platform_device *pdev)
1860{ 1891{
1861 int rc = 0; 1892 int rc = 0;
1862 struct resource *res; 1893 struct resource *res, *res_ctrl;
1863 struct net_device *ndev; 1894 struct net_device *ndev;
1864 struct emac_priv *priv; 1895 struct emac_priv *priv;
1865 unsigned long hw_ram_addr; 1896 unsigned long hw_ram_addr;
@@ -1876,6 +1907,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
1876 return -EBUSY; 1907 return -EBUSY;
1877 } 1908 }
1878 emac_bus_frequency = clk_get_rate(emac_clk); 1909 emac_bus_frequency = clk_get_rate(emac_clk);
1910 devm_clk_put(&pdev->dev, emac_clk);
1879 1911
1880 /* TODO: Probe PHY here if possible */ 1912 /* TODO: Probe PHY here if possible */
1881 1913
@@ -1917,11 +1949,20 @@ static int davinci_emac_probe(struct platform_device *pdev)
1917 rc = PTR_ERR(priv->remap_addr); 1949 rc = PTR_ERR(priv->remap_addr);
1918 goto no_pdata; 1950 goto no_pdata;
1919 } 1951 }
1952
1953 res_ctrl = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1954 if (res_ctrl) {
1955 priv->ctrl_base =
1956 devm_ioremap_resource(&pdev->dev, res_ctrl);
1957 if (IS_ERR(priv->ctrl_base))
1958 goto no_pdata;
1959 } else {
1960 priv->ctrl_base = priv->remap_addr + pdata->ctrl_mod_reg_offset;
1961 }
1962
1920 priv->emac_base = priv->remap_addr + pdata->ctrl_reg_offset; 1963 priv->emac_base = priv->remap_addr + pdata->ctrl_reg_offset;
1921 ndev->base_addr = (unsigned long)priv->remap_addr; 1964 ndev->base_addr = (unsigned long)priv->remap_addr;
1922 1965
1923 priv->ctrl_base = priv->remap_addr + pdata->ctrl_mod_reg_offset;
1924
1925 hw_ram_addr = pdata->hw_ram_addr; 1966 hw_ram_addr = pdata->hw_ram_addr;
1926 if (!hw_ram_addr) 1967 if (!hw_ram_addr)
1927 hw_ram_addr = (u32 __force)res->start + pdata->ctrl_ram_offset; 1968 hw_ram_addr = (u32 __force)res->start + pdata->ctrl_ram_offset;
@@ -1980,12 +2021,22 @@ static int davinci_emac_probe(struct platform_device *pdev)
1980 ndev->ethtool_ops = &ethtool_ops; 2021 ndev->ethtool_ops = &ethtool_ops;
1981 netif_napi_add(ndev, &priv->napi, emac_poll, EMAC_POLL_WEIGHT); 2022 netif_napi_add(ndev, &priv->napi, emac_poll, EMAC_POLL_WEIGHT);
1982 2023
2024 pm_runtime_enable(&pdev->dev);
2025 rc = pm_runtime_get_sync(&pdev->dev);
2026 if (rc < 0) {
2027 pm_runtime_put_noidle(&pdev->dev);
2028 dev_err(&pdev->dev, "%s: failed to get_sync(%d)\n",
2029 __func__, rc);
2030 goto no_cpdma_chan;
2031 }
2032
1983 /* register the network device */ 2033 /* register the network device */
1984 SET_NETDEV_DEV(ndev, &pdev->dev); 2034 SET_NETDEV_DEV(ndev, &pdev->dev);
1985 rc = register_netdev(ndev); 2035 rc = register_netdev(ndev);
1986 if (rc) { 2036 if (rc) {
1987 dev_err(&pdev->dev, "error in register_netdev\n"); 2037 dev_err(&pdev->dev, "error in register_netdev\n");
1988 rc = -ENODEV; 2038 rc = -ENODEV;
2039 pm_runtime_put(&pdev->dev);
1989 goto no_cpdma_chan; 2040 goto no_cpdma_chan;
1990 } 2041 }
1991 2042
@@ -1995,9 +2046,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
1995 "(regs: %p, irq: %d)\n", 2046 "(regs: %p, irq: %d)\n",
1996 (void *)priv->emac_base_phys, ndev->irq); 2047 (void *)priv->emac_base_phys, ndev->irq);
1997 } 2048 }
1998 2049 pm_runtime_put(&pdev->dev);
1999 pm_runtime_enable(&pdev->dev);
2000 pm_runtime_resume(&pdev->dev);
2001 2050
2002 return 0; 2051 return 0;
2003 2052
@@ -2071,9 +2120,14 @@ static const struct emac_platform_data am3517_emac_data = {
2071 .hw_ram_addr = 0x01e20000, 2120 .hw_ram_addr = 0x01e20000,
2072}; 2121};
2073 2122
2123static const struct emac_platform_data dm816_emac_data = {
2124 .version = EMAC_VERSION_2,
2125};
2126
2074static const struct of_device_id davinci_emac_of_match[] = { 2127static const struct of_device_id davinci_emac_of_match[] = {
2075 {.compatible = "ti,davinci-dm6467-emac", }, 2128 {.compatible = "ti,davinci-dm6467-emac", },
2076 {.compatible = "ti,am3517-emac", .data = &am3517_emac_data, }, 2129 {.compatible = "ti,am3517-emac", .data = &am3517_emac_data, },
2130 {.compatible = "ti,dm816-emac", .data = &dm816_emac_data, },
2077 {}, 2131 {},
2078}; 2132};
2079MODULE_DEVICE_TABLE(of, davinci_emac_of_match); 2133MODULE_DEVICE_TABLE(of, davinci_emac_of_match);
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 57ec23e8ccfa..bf405f134d3a 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -833,9 +833,6 @@ static void ocp_write_word(struct r8152 *tp, u16 type, u16 index, u32 data)
833 index &= ~3; 833 index &= ~3;
834 } 834 }
835 835
836 generic_ocp_read(tp, index, sizeof(tmp), &tmp, type);
837
838 data |= __le32_to_cpu(tmp) & ~mask;
839 tmp = __cpu_to_le32(data); 836 tmp = __cpu_to_le32(data);
840 837
841 generic_ocp_write(tp, index, byen, sizeof(tmp), &tmp, type); 838 generic_ocp_write(tp, index, byen, sizeof(tmp), &tmp, type);
@@ -874,9 +871,6 @@ static void ocp_write_byte(struct r8152 *tp, u16 type, u16 index, u32 data)
874 index &= ~3; 871 index &= ~3;
875 } 872 }
876 873
877 generic_ocp_read(tp, index, sizeof(tmp), &tmp, type);
878
879 data |= __le32_to_cpu(tmp) & ~mask;
880 tmp = __cpu_to_le32(data); 874 tmp = __cpu_to_le32(data);
881 875
882 generic_ocp_write(tp, index, byen, sizeof(tmp), &tmp, type); 876 generic_ocp_write(tp, index, byen, sizeof(tmp), &tmp, type);
@@ -926,12 +920,6 @@ static void sram_write(struct r8152 *tp, u16 addr, u16 data)
926 ocp_reg_write(tp, OCP_SRAM_DATA, data); 920 ocp_reg_write(tp, OCP_SRAM_DATA, data);
927} 921}
928 922
929static u16 sram_read(struct r8152 *tp, u16 addr)
930{
931 ocp_reg_write(tp, OCP_SRAM_ADDR, addr);
932 return ocp_reg_read(tp, OCP_SRAM_DATA);
933}
934
935static int read_mii_word(struct net_device *netdev, int phy_id, int reg) 923static int read_mii_word(struct net_device *netdev, int phy_id, int reg)
936{ 924{
937 struct r8152 *tp = netdev_priv(netdev); 925 struct r8152 *tp = netdev_priv(netdev);
@@ -2518,24 +2506,18 @@ static void r8153_hw_phy_cfg(struct r8152 *tp)
2518 data = ocp_reg_read(tp, OCP_POWER_CFG); 2506 data = ocp_reg_read(tp, OCP_POWER_CFG);
2519 data |= EN_10M_PLLOFF; 2507 data |= EN_10M_PLLOFF;
2520 ocp_reg_write(tp, OCP_POWER_CFG, data); 2508 ocp_reg_write(tp, OCP_POWER_CFG, data);
2521 data = sram_read(tp, SRAM_IMPEDANCE); 2509 sram_write(tp, SRAM_IMPEDANCE, 0x0b13);
2522 data &= ~RX_DRIVING_MASK;
2523 sram_write(tp, SRAM_IMPEDANCE, data);
2524 2510
2525 ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_PHY_PWR); 2511 ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_PHY_PWR);
2526 ocp_data |= PFM_PWM_SWITCH; 2512 ocp_data |= PFM_PWM_SWITCH;
2527 ocp_write_word(tp, MCU_TYPE_PLA, PLA_PHY_PWR, ocp_data); 2513 ocp_write_word(tp, MCU_TYPE_PLA, PLA_PHY_PWR, ocp_data);
2528 2514
2529 data = sram_read(tp, SRAM_LPF_CFG); 2515 /* Enable LPF corner auto tune */
2530 data |= LPF_AUTO_TUNE; 2516 sram_write(tp, SRAM_LPF_CFG, 0xf70f);
2531 sram_write(tp, SRAM_LPF_CFG, data);
2532 2517
2533 data = sram_read(tp, SRAM_10M_AMP1); 2518 /* Adjust 10M Amplitude */
2534 data |= GDAC_IB_UPALL; 2519 sram_write(tp, SRAM_10M_AMP1, 0x00af);
2535 sram_write(tp, SRAM_10M_AMP1, data); 2520 sram_write(tp, SRAM_10M_AMP2, 0x0208);
2536 data = sram_read(tp, SRAM_10M_AMP2);
2537 data |= AMP_DN;
2538 sram_write(tp, SRAM_10M_AMP2, data);
2539 2521
2540 set_bit(PHY_RESET, &tp->flags); 2522 set_bit(PHY_RESET, &tp->flags);
2541} 2523}
diff --git a/include/linux/genetlink.h b/include/linux/genetlink.h
index 55b685719d52..09460d6d6682 100644
--- a/include/linux/genetlink.h
+++ b/include/linux/genetlink.h
@@ -11,6 +11,10 @@ extern void genl_unlock(void);
11extern int lockdep_genl_is_held(void); 11extern int lockdep_genl_is_held(void);
12#endif 12#endif
13 13
14/* for synchronisation between af_netlink and genetlink */
15extern atomic_t genl_sk_destructing_cnt;
16extern wait_queue_head_t genl_sk_destructing_waitq;
17
14/** 18/**
15 * rcu_dereference_genl - rcu_dereference with debug checking 19 * rcu_dereference_genl - rcu_dereference with debug checking
16 * @p: The pointer to read, prior to dereferencing 20 * @p: The pointer to read, prior to dereferencing
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index 84125088c309..6c92415311ca 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -27,13 +27,18 @@ struct genl_info;
27 * @maxattr: maximum number of attributes supported 27 * @maxattr: maximum number of attributes supported
28 * @netnsok: set to true if the family can handle network 28 * @netnsok: set to true if the family can handle network
29 * namespaces and should be presented in all of them 29 * namespaces and should be presented in all of them
30 * @parallel_ops: operations can be called in parallel and aren't
31 * synchronized by the core genetlink code
30 * @pre_doit: called before an operation's doit callback, it may 32 * @pre_doit: called before an operation's doit callback, it may
31 * do additional, common, filtering and return an error 33 * do additional, common, filtering and return an error
32 * @post_doit: called after an operation's doit callback, it may 34 * @post_doit: called after an operation's doit callback, it may
33 * undo operations done by pre_doit, for example release locks 35 * undo operations done by pre_doit, for example release locks
34 * @mcast_bind: a socket bound to the given multicast group (which 36 * @mcast_bind: a socket bound to the given multicast group (which
35 * is given as the offset into the groups array) 37 * is given as the offset into the groups array)
36 * @mcast_unbind: a socket was unbound from the given multicast group 38 * @mcast_unbind: a socket was unbound from the given multicast group.
39 * Note that unbind() will not be called symmetrically if the
40 * generic netlink family is removed while there are still open
41 * sockets.
37 * @attrbuf: buffer to store parsed attributes 42 * @attrbuf: buffer to store parsed attributes
38 * @family_list: family list 43 * @family_list: family list
39 * @mcgrps: multicast groups used by this family (private) 44 * @mcgrps: multicast groups used by this family (private)
diff --git a/include/uapi/linux/can/netlink.h b/include/uapi/linux/can/netlink.h
index 3e4323a3918d..94ffe0c83ce7 100644
--- a/include/uapi/linux/can/netlink.h
+++ b/include/uapi/linux/can/netlink.h
@@ -98,6 +98,7 @@ struct can_ctrlmode {
98#define CAN_CTRLMODE_BERR_REPORTING 0x10 /* Bus-error reporting */ 98#define CAN_CTRLMODE_BERR_REPORTING 0x10 /* Bus-error reporting */
99#define CAN_CTRLMODE_FD 0x20 /* CAN FD mode */ 99#define CAN_CTRLMODE_FD 0x20 /* CAN FD mode */
100#define CAN_CTRLMODE_PRESUME_ACK 0x40 /* Ignore missing CAN ACKs */ 100#define CAN_CTRLMODE_PRESUME_ACK 0x40 /* Ignore missing CAN ACKs */
101#define CAN_CTRLMODE_FD_NON_ISO 0x80 /* CAN FD in non-ISO mode */
101 102
102/* 103/*
103 * CAN device statistics 104 * CAN device statistics
diff --git a/net/core/dev.c b/net/core/dev.c
index 683d493aa1bf..171420e75b03 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -7072,10 +7072,20 @@ static int dev_cpu_callback(struct notifier_block *nfb,
7072 oldsd->output_queue = NULL; 7072 oldsd->output_queue = NULL;
7073 oldsd->output_queue_tailp = &oldsd->output_queue; 7073 oldsd->output_queue_tailp = &oldsd->output_queue;
7074 } 7074 }
7075 /* Append NAPI poll list from offline CPU. */ 7075 /* Append NAPI poll list from offline CPU, with one exception :
7076 if (!list_empty(&oldsd->poll_list)) { 7076 * process_backlog() must be called by cpu owning percpu backlog.
7077 list_splice_init(&oldsd->poll_list, &sd->poll_list); 7077 * We properly handle process_queue & input_pkt_queue later.
7078 raise_softirq_irqoff(NET_RX_SOFTIRQ); 7078 */
7079 while (!list_empty(&oldsd->poll_list)) {
7080 struct napi_struct *napi = list_first_entry(&oldsd->poll_list,
7081 struct napi_struct,
7082 poll_list);
7083
7084 list_del_init(&napi->poll_list);
7085 if (napi->poll == process_backlog)
7086 napi->state = 0;
7087 else
7088 ____napi_schedule(sd, napi);
7079 } 7089 }
7080 7090
7081 raise_softirq_irqoff(NET_TX_SOFTIRQ); 7091 raise_softirq_irqoff(NET_TX_SOFTIRQ);
@@ -7086,7 +7096,7 @@ static int dev_cpu_callback(struct notifier_block *nfb,
7086 netif_rx_internal(skb); 7096 netif_rx_internal(skb);
7087 input_queue_head_incr(oldsd); 7097 input_queue_head_incr(oldsd);
7088 } 7098 }
7089 while ((skb = __skb_dequeue(&oldsd->input_pkt_queue))) { 7099 while ((skb = skb_dequeue(&oldsd->input_pkt_queue))) {
7090 netif_rx_internal(skb); 7100 netif_rx_internal(skb);
7091 input_queue_head_incr(oldsd); 7101 input_queue_head_incr(oldsd);
7092 } 7102 }
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 8a89c738b7a3..6b85adb05003 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -461,17 +461,13 @@ int ip_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len)
461 461
462 memcpy(&errhdr.ee, &serr->ee, sizeof(struct sock_extended_err)); 462 memcpy(&errhdr.ee, &serr->ee, sizeof(struct sock_extended_err));
463 sin = &errhdr.offender; 463 sin = &errhdr.offender;
464 sin->sin_family = AF_UNSPEC; 464 memset(sin, 0, sizeof(*sin));
465 465
466 if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP || 466 if (serr->ee.ee_origin == SO_EE_ORIGIN_ICMP ||
467 ipv4_pktinfo_prepare_errqueue(sk, skb, serr->ee.ee_origin)) { 467 ipv4_pktinfo_prepare_errqueue(sk, skb, serr->ee.ee_origin)) {
468 struct inet_sock *inet = inet_sk(sk);
469
470 sin->sin_family = AF_INET; 468 sin->sin_family = AF_INET;
471 sin->sin_addr.s_addr = ip_hdr(skb)->saddr; 469 sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
472 sin->sin_port = 0; 470 if (inet_sk(sk)->cmsg_flags)
473 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
474 if (inet->cmsg_flags)
475 ip_cmsg_recv(msg, skb); 471 ip_cmsg_recv(msg, skb);
476 } 472 }
477 473
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 100c589a2a6c..49f5e73db122 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -393,11 +393,10 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len)
393 393
394 memcpy(&errhdr.ee, &serr->ee, sizeof(struct sock_extended_err)); 394 memcpy(&errhdr.ee, &serr->ee, sizeof(struct sock_extended_err));
395 sin = &errhdr.offender; 395 sin = &errhdr.offender;
396 sin->sin6_family = AF_UNSPEC; 396 memset(sin, 0, sizeof(*sin));
397
397 if (serr->ee.ee_origin != SO_EE_ORIGIN_LOCAL) { 398 if (serr->ee.ee_origin != SO_EE_ORIGIN_LOCAL) {
398 sin->sin6_family = AF_INET6; 399 sin->sin6_family = AF_INET6;
399 sin->sin6_flowinfo = 0;
400 sin->sin6_port = 0;
401 if (np->rxopt.all) { 400 if (np->rxopt.all) {
402 if (serr->ee.ee_origin != SO_EE_ORIGIN_ICMP && 401 if (serr->ee.ee_origin != SO_EE_ORIGIN_ICMP &&
403 serr->ee.ee_origin != SO_EE_ORIGIN_ICMP6) 402 serr->ee.ee_origin != SO_EE_ORIGIN_ICMP6)
@@ -412,12 +411,9 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len, int *addr_len)
412 ipv6_iface_scope_id(&sin->sin6_addr, 411 ipv6_iface_scope_id(&sin->sin6_addr,
413 IP6CB(skb)->iif); 412 IP6CB(skb)->iif);
414 } else { 413 } else {
415 struct inet_sock *inet = inet_sk(sk);
416
417 ipv6_addr_set_v4mapped(ip_hdr(skb)->saddr, 414 ipv6_addr_set_v4mapped(ip_hdr(skb)->saddr,
418 &sin->sin6_addr); 415 &sin->sin6_addr);
419 sin->sin6_scope_id = 0; 416 if (inet_sk(sk)->cmsg_flags)
420 if (inet->cmsg_flags)
421 ip_cmsg_recv(msg, skb); 417 ip_cmsg_recv(msg, skb);
422 } 418 }
423 } 419 }
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index c91083156edb..166e33bed222 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1160,12 +1160,9 @@ static void ip6_rt_update_pmtu(struct dst_entry *dst, struct sock *sk,
1160 struct net *net = dev_net(dst->dev); 1160 struct net *net = dev_net(dst->dev);
1161 1161
1162 rt6->rt6i_flags |= RTF_MODIFIED; 1162 rt6->rt6i_flags |= RTF_MODIFIED;
1163 if (mtu < IPV6_MIN_MTU) { 1163 if (mtu < IPV6_MIN_MTU)
1164 u32 features = dst_metric(dst, RTAX_FEATURES);
1165 mtu = IPV6_MIN_MTU; 1164 mtu = IPV6_MIN_MTU;
1166 features |= RTAX_FEATURE_ALLFRAG; 1165
1167 dst_metric_set(dst, RTAX_FEATURES, features);
1168 }
1169 dst_metric_set(dst, RTAX_MTU, mtu); 1166 dst_metric_set(dst, RTAX_MTU, mtu);
1170 rt6_update_expires(rt6, net->ipv6.sysctl.ip6_rt_mtu_expires); 1167 rt6_update_expires(rt6, net->ipv6.sysctl.ip6_rt_mtu_expires);
1171 } 1168 }
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 2c36c4765f47..837a406a9dd6 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1643,7 +1643,7 @@ __ieee80211_sta_handle_tspec_ac_params(struct ieee80211_sub_if_data *sdata)
1643{ 1643{
1644 struct ieee80211_local *local = sdata->local; 1644 struct ieee80211_local *local = sdata->local;
1645 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1645 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
1646 bool ret; 1646 bool ret = false;
1647 int ac; 1647 int ac;
1648 1648
1649 if (local->hw.queues < IEEE80211_NUM_ACS) 1649 if (local->hw.queues < IEEE80211_NUM_ACS)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 84ea76ca3f1f..02fdde28dada 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -61,6 +61,7 @@
61#include <linux/rhashtable.h> 61#include <linux/rhashtable.h>
62#include <asm/cacheflush.h> 62#include <asm/cacheflush.h>
63#include <linux/hash.h> 63#include <linux/hash.h>
64#include <linux/genetlink.h>
64 65
65#include <net/net_namespace.h> 66#include <net/net_namespace.h>
66#include <net/sock.h> 67#include <net/sock.h>
@@ -1095,6 +1096,8 @@ static void netlink_remove(struct sock *sk)
1095 __sk_del_bind_node(sk); 1096 __sk_del_bind_node(sk);
1096 netlink_update_listeners(sk); 1097 netlink_update_listeners(sk);
1097 } 1098 }
1099 if (sk->sk_protocol == NETLINK_GENERIC)
1100 atomic_inc(&genl_sk_destructing_cnt);
1098 netlink_table_ungrab(); 1101 netlink_table_ungrab();
1099} 1102}
1100 1103
@@ -1211,6 +1214,20 @@ static int netlink_release(struct socket *sock)
1211 * will be purged. 1214 * will be purged.
1212 */ 1215 */
1213 1216
1217 /* must not acquire netlink_table_lock in any way again before unbind
1218 * and notifying genetlink is done as otherwise it might deadlock
1219 */
1220 if (nlk->netlink_unbind) {
1221 int i;
1222
1223 for (i = 0; i < nlk->ngroups; i++)
1224 if (test_bit(i, nlk->groups))
1225 nlk->netlink_unbind(sock_net(sk), i + 1);
1226 }
1227 if (sk->sk_protocol == NETLINK_GENERIC &&
1228 atomic_dec_return(&genl_sk_destructing_cnt) == 0)
1229 wake_up(&genl_sk_destructing_waitq);
1230
1214 sock->sk = NULL; 1231 sock->sk = NULL;
1215 wake_up_interruptible_all(&nlk->wait); 1232 wake_up_interruptible_all(&nlk->wait);
1216 1233
@@ -1246,13 +1263,6 @@ static int netlink_release(struct socket *sock)
1246 netlink_table_ungrab(); 1263 netlink_table_ungrab();
1247 } 1264 }
1248 1265
1249 if (nlk->netlink_unbind) {
1250 int i;
1251
1252 for (i = 0; i < nlk->ngroups; i++)
1253 if (test_bit(i, nlk->groups))
1254 nlk->netlink_unbind(sock_net(sk), i + 1);
1255 }
1256 kfree(nlk->groups); 1266 kfree(nlk->groups);
1257 nlk->groups = NULL; 1267 nlk->groups = NULL;
1258 1268
diff --git a/net/netlink/af_netlink.h b/net/netlink/af_netlink.h
index f123a88496f8..f1c31b39aa3e 100644
--- a/net/netlink/af_netlink.h
+++ b/net/netlink/af_netlink.h
@@ -2,6 +2,7 @@
2#define _AF_NETLINK_H 2#define _AF_NETLINK_H
3 3
4#include <linux/rhashtable.h> 4#include <linux/rhashtable.h>
5#include <linux/atomic.h>
5#include <net/sock.h> 6#include <net/sock.h>
6 7
7#define NLGRPSZ(x) (ALIGN(x, sizeof(unsigned long) * 8) / 8) 8#define NLGRPSZ(x) (ALIGN(x, sizeof(unsigned long) * 8) / 8)
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 2e11061ef885..ee57459fc258 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -23,6 +23,9 @@
23static DEFINE_MUTEX(genl_mutex); /* serialization of message processing */ 23static DEFINE_MUTEX(genl_mutex); /* serialization of message processing */
24static DECLARE_RWSEM(cb_lock); 24static DECLARE_RWSEM(cb_lock);
25 25
26atomic_t genl_sk_destructing_cnt = ATOMIC_INIT(0);
27DECLARE_WAIT_QUEUE_HEAD(genl_sk_destructing_waitq);
28
26void genl_lock(void) 29void genl_lock(void)
27{ 30{
28 mutex_lock(&genl_mutex); 31 mutex_lock(&genl_mutex);
@@ -435,15 +438,18 @@ int genl_unregister_family(struct genl_family *family)
435 438
436 genl_lock_all(); 439 genl_lock_all();
437 440
438 genl_unregister_mc_groups(family);
439
440 list_for_each_entry(rc, genl_family_chain(family->id), family_list) { 441 list_for_each_entry(rc, genl_family_chain(family->id), family_list) {
441 if (family->id != rc->id || strcmp(rc->name, family->name)) 442 if (family->id != rc->id || strcmp(rc->name, family->name))
442 continue; 443 continue;
443 444
445 genl_unregister_mc_groups(family);
446
444 list_del(&rc->family_list); 447 list_del(&rc->family_list);
445 family->n_ops = 0; 448 family->n_ops = 0;
446 genl_unlock_all(); 449 up_write(&cb_lock);
450 wait_event(genl_sk_destructing_waitq,
451 atomic_read(&genl_sk_destructing_cnt) == 0);
452 genl_unlock();
447 453
448 kfree(family->attrbuf); 454 kfree(family->attrbuf);
449 genl_ctrl_event(CTRL_CMD_DELFAMILY, family, NULL, 0); 455 genl_ctrl_event(CTRL_CMD_DELFAMILY, family, NULL, 0);
@@ -985,7 +991,7 @@ static struct genl_multicast_group genl_ctrl_groups[] = {
985 991
986static int genl_bind(struct net *net, int group) 992static int genl_bind(struct net *net, int group)
987{ 993{
988 int i, err = 0; 994 int i, err = -ENOENT;
989 995
990 down_read(&cb_lock); 996 down_read(&cb_lock);
991 for (i = 0; i < GENL_FAM_TAB_SIZE; i++) { 997 for (i = 0; i < GENL_FAM_TAB_SIZE; i++) {
@@ -1014,7 +1020,6 @@ static int genl_bind(struct net *net, int group)
1014static void genl_unbind(struct net *net, int group) 1020static void genl_unbind(struct net *net, int group)
1015{ 1021{
1016 int i; 1022 int i;
1017 bool found = false;
1018 1023
1019 down_read(&cb_lock); 1024 down_read(&cb_lock);
1020 for (i = 0; i < GENL_FAM_TAB_SIZE; i++) { 1025 for (i = 0; i < GENL_FAM_TAB_SIZE; i++) {
@@ -1027,14 +1032,11 @@ static void genl_unbind(struct net *net, int group)
1027 1032
1028 if (f->mcast_unbind) 1033 if (f->mcast_unbind)
1029 f->mcast_unbind(net, fam_grp); 1034 f->mcast_unbind(net, fam_grp);
1030 found = true;
1031 break; 1035 break;
1032 } 1036 }
1033 } 1037 }
1034 } 1038 }
1035 up_read(&cb_lock); 1039 up_read(&cb_lock);
1036
1037 WARN_ON(!found);
1038} 1040}
1039 1041
1040static int __net_init genl_pernet_init(struct net *net) 1042static int __net_init genl_pernet_init(struct net *net)
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 2625eccb77d5..aafe94bf292e 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1603,7 +1603,7 @@ static int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1603 sctp_assoc_t associd = 0; 1603 sctp_assoc_t associd = 0;
1604 sctp_cmsgs_t cmsgs = { NULL }; 1604 sctp_cmsgs_t cmsgs = { NULL };
1605 sctp_scope_t scope; 1605 sctp_scope_t scope;
1606 bool fill_sinfo_ttl = false; 1606 bool fill_sinfo_ttl = false, wait_connect = false;
1607 struct sctp_datamsg *datamsg; 1607 struct sctp_datamsg *datamsg;
1608 int msg_flags = msg->msg_flags; 1608 int msg_flags = msg->msg_flags;
1609 __u16 sinfo_flags = 0; 1609 __u16 sinfo_flags = 0;
@@ -1943,6 +1943,7 @@ static int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1943 if (err < 0) 1943 if (err < 0)
1944 goto out_free; 1944 goto out_free;
1945 1945
1946 wait_connect = true;
1946 pr_debug("%s: we associated primitively\n", __func__); 1947 pr_debug("%s: we associated primitively\n", __func__);
1947 } 1948 }
1948 1949
@@ -1980,6 +1981,11 @@ static int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1980 sctp_datamsg_put(datamsg); 1981 sctp_datamsg_put(datamsg);
1981 err = msg_len; 1982 err = msg_len;
1982 1983
1984 if (unlikely(wait_connect)) {
1985 timeo = sock_sndtimeo(sk, msg_flags & MSG_DONTWAIT);
1986 sctp_wait_for_connect(asoc, &timeo);
1987 }
1988
1983 /* If we are already past ASSOCIATE, the lower 1989 /* If we are already past ASSOCIATE, the lower
1984 * layers are responsible for association cleanup. 1990 * layers are responsible for association cleanup.
1985 */ 1991 */
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 7b8309840d4e..d39d1cbc86b1 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1530,45 +1530,40 @@ static void reg_call_notifier(struct wiphy *wiphy,
1530 1530
1531static bool reg_wdev_chan_valid(struct wiphy *wiphy, struct wireless_dev *wdev) 1531static bool reg_wdev_chan_valid(struct wiphy *wiphy, struct wireless_dev *wdev)
1532{ 1532{
1533 struct ieee80211_channel *ch;
1534 struct cfg80211_chan_def chandef; 1533 struct cfg80211_chan_def chandef;
1535 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); 1534 struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
1536 bool ret = true; 1535 enum nl80211_iftype iftype;
1537 1536
1538 wdev_lock(wdev); 1537 wdev_lock(wdev);
1538 iftype = wdev->iftype;
1539 1539
1540 /* make sure the interface is active */
1540 if (!wdev->netdev || !netif_running(wdev->netdev)) 1541 if (!wdev->netdev || !netif_running(wdev->netdev))
1541 goto out; 1542 goto wdev_inactive_unlock;
1542 1543
1543 switch (wdev->iftype) { 1544 switch (iftype) {
1544 case NL80211_IFTYPE_AP: 1545 case NL80211_IFTYPE_AP:
1545 case NL80211_IFTYPE_P2P_GO: 1546 case NL80211_IFTYPE_P2P_GO:
1546 if (!wdev->beacon_interval) 1547 if (!wdev->beacon_interval)
1547 goto out; 1548 goto wdev_inactive_unlock;
1548 1549 chandef = wdev->chandef;
1549 ret = cfg80211_reg_can_beacon(wiphy,
1550 &wdev->chandef, wdev->iftype);
1551 break; 1550 break;
1552 case NL80211_IFTYPE_ADHOC: 1551 case NL80211_IFTYPE_ADHOC:
1553 if (!wdev->ssid_len) 1552 if (!wdev->ssid_len)
1554 goto out; 1553 goto wdev_inactive_unlock;
1555 1554 chandef = wdev->chandef;
1556 ret = cfg80211_reg_can_beacon(wiphy,
1557 &wdev->chandef, wdev->iftype);
1558 break; 1555 break;
1559 case NL80211_IFTYPE_STATION: 1556 case NL80211_IFTYPE_STATION:
1560 case NL80211_IFTYPE_P2P_CLIENT: 1557 case NL80211_IFTYPE_P2P_CLIENT:
1561 if (!wdev->current_bss || 1558 if (!wdev->current_bss ||
1562 !wdev->current_bss->pub.channel) 1559 !wdev->current_bss->pub.channel)
1563 goto out; 1560 goto wdev_inactive_unlock;
1564 1561
1565 ch = wdev->current_bss->pub.channel; 1562 if (!rdev->ops->get_channel ||
1566 if (rdev->ops->get_channel && 1563 rdev_get_channel(rdev, wdev, &chandef))
1567 !rdev_get_channel(rdev, wdev, &chandef)) 1564 cfg80211_chandef_create(&chandef,
1568 ret = cfg80211_chandef_usable(wiphy, &chandef, 1565 wdev->current_bss->pub.channel,
1569 IEEE80211_CHAN_DISABLED); 1566 NL80211_CHAN_NO_HT);
1570 else
1571 ret = !(ch->flags & IEEE80211_CHAN_DISABLED);
1572 break; 1567 break;
1573 case NL80211_IFTYPE_MONITOR: 1568 case NL80211_IFTYPE_MONITOR:
1574 case NL80211_IFTYPE_AP_VLAN: 1569 case NL80211_IFTYPE_AP_VLAN:
@@ -1581,9 +1576,26 @@ static bool reg_wdev_chan_valid(struct wiphy *wiphy, struct wireless_dev *wdev)
1581 break; 1576 break;
1582 } 1577 }
1583 1578
1584out:
1585 wdev_unlock(wdev); 1579 wdev_unlock(wdev);
1586 return ret; 1580
1581 switch (iftype) {
1582 case NL80211_IFTYPE_AP:
1583 case NL80211_IFTYPE_P2P_GO:
1584 case NL80211_IFTYPE_ADHOC:
1585 return cfg80211_reg_can_beacon(wiphy, &chandef, iftype);
1586 case NL80211_IFTYPE_STATION:
1587 case NL80211_IFTYPE_P2P_CLIENT:
1588 return cfg80211_chandef_usable(wiphy, &chandef,
1589 IEEE80211_CHAN_DISABLED);
1590 default:
1591 break;
1592 }
1593
1594 return true;
1595
1596wdev_inactive_unlock:
1597 wdev_unlock(wdev);
1598 return true;
1587} 1599}
1588 1600
1589static void reg_leave_invalid_chans(struct wiphy *wiphy) 1601static void reg_leave_invalid_chans(struct wiphy *wiphy)