From a70d20704ad5230912b6f0113d7226cea19cde91 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 6 Mar 2022 22:57:44 +0100 Subject: [PATCH 01/10] s390: net: Use netif_rx(). Since commit baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.") the function netif_rx() can be used in preemptible/thread context as well as in interrupt context. Use netif_rx(). Cc: Alexander Gordeev Cc: Alexandra Winter Cc: Christian Borntraeger Cc: Heiko Carstens Cc: Sven Schnelle Cc: Vasily Gorbik Cc: Wenjia Zhang Cc: linux-s390@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: David S. Miller --- drivers/s390/net/ctcm_main.c | 2 +- drivers/s390/net/netiucv.c | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c index 5ea7eeb07002..e0fdd54bfeb7 100644 --- a/drivers/s390/net/ctcm_main.c +++ b/drivers/s390/net/ctcm_main.c @@ -166,7 +166,7 @@ void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb) ch->logflags = 0; priv->stats.rx_packets++; priv->stats.rx_bytes += skblen; - netif_rx_ni(skb); + netif_rx(skb); if (len > 0) { skb_pull(pskb, header->length); if (skb_tailroom(pskb) < LL_HEADER_LENGTH) { diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c index 981e7b1c6b96..65aa0a96c21d 100644 --- a/drivers/s390/net/netiucv.c +++ b/drivers/s390/net/netiucv.c @@ -620,11 +620,7 @@ static void netiucv_unpack_skb(struct iucv_connection *conn, pskb->ip_summed = CHECKSUM_UNNECESSARY; privptr->stats.rx_packets++; privptr->stats.rx_bytes += skb->len; - /* - * Since receiving is always initiated from a tasklet (in iucv.c), - * we must use netif_rx_ni() instead of netif_rx() - */ - netif_rx_ni(skb); + netif_rx(skb); skb_pull(pskb, header->next); skb_put(pskb, NETIUCV_HDRLEN); } From 4bcc4249b4cf4df17429a5299c456ba9e76de779 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 6 Mar 2022 22:57:45 +0100 Subject: [PATCH 02/10] staging: Use netif_rx(). Since commit baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.") the function netif_rx() can be used in preemptible/thread context as well as in interrupt context. Use netif_rx(). Cc: Greg Kroah-Hartman Cc: linux-staging@lists.linux.dev Signed-off-by: Sebastian Andrzej Siewior Acked-by: Greg Kroah-Hartman Signed-off-by: David S. Miller --- drivers/staging/gdm724x/gdm_lte.c | 2 +- drivers/staging/wlan-ng/p80211netdev.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c index 493ed4821515..2587309da766 100644 --- a/drivers/staging/gdm724x/gdm_lte.c +++ b/drivers/staging/gdm724x/gdm_lte.c @@ -78,7 +78,7 @@ static int gdm_lte_rx(struct sk_buff *skb, struct nic *nic, int nic_type) { int ret; - ret = netif_rx_ni(skb); + ret = netif_rx(skb); if (ret == NET_RX_DROP) { nic->stats.rx_dropped++; } else { diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index 255500448ad3..e04fc666d218 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -255,7 +255,7 @@ static int p80211_convert_to_ether(struct wlandevice *wlandev, if (skb_p80211_to_ether(wlandev, wlandev->ethconv, skb) == 0) { wlandev->netdev->stats.rx_packets++; wlandev->netdev->stats.rx_bytes += skb->len; - netif_rx_ni(skb); + netif_rx(skb); return 0; } @@ -290,7 +290,7 @@ static void p80211netdev_rx_bh(struct tasklet_struct *t) dev->stats.rx_packets++; dev->stats.rx_bytes += skb->len; - netif_rx_ni(skb); + netif_rx(skb); continue; } else { if (!p80211_convert_to_ether(wlandev, skb)) From 3d391f6518fddcd44367d463aa20a50145f3ea3f Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 6 Mar 2022 22:57:46 +0100 Subject: [PATCH 03/10] tun: vxlan: Use netif_rx(). Since commit baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.") the function netif_rx() can be used in preemptible/thread context as well as in interrupt context. Use netif_rx(). Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: David S. Miller --- drivers/net/tun.c | 2 +- drivers/net/vxlan/vxlan_core.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index bab92e489fba..2b9a22669a12 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1984,7 +1984,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile, } else if (!IS_ENABLED(CONFIG_4KSTACKS)) { tun_rx_batched(tun, tfile, skb, more); } else { - netif_rx_ni(skb); + netif_rx(skb); } rcu_read_unlock(); diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 4ab09dd5a32a..b3cbd37c4b93 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1877,7 +1877,7 @@ static int arp_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni) reply->ip_summed = CHECKSUM_UNNECESSARY; reply->pkt_type = PACKET_HOST; - if (netif_rx_ni(reply) == NET_RX_DROP) { + if (netif_rx(reply) == NET_RX_DROP) { dev->stats.rx_dropped++; vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_RX_DROPS, 0); @@ -2036,7 +2036,7 @@ static int neigh_reduce(struct net_device *dev, struct sk_buff *skb, __be32 vni) if (reply == NULL) goto out; - if (netif_rx_ni(reply) == NET_RX_DROP) { + if (netif_rx(reply) == NET_RX_DROP) { dev->stats.rx_dropped++; vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_RX_DROPS, 0); From a0f0db8292e6fdb6b467a2270fa88b219ac98fb7 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 6 Mar 2022 22:57:47 +0100 Subject: [PATCH 04/10] tipc: Use netif_rx(). Since commit baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.") the function netif_rx() can be used in preemptible/thread context as well as in interrupt context. Use netif_rx(). Cc: Jon Maloy Cc: Ying Xue Cc: tipc-discussion@lists.sourceforge.net Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: David S. Miller --- net/tipc/bearer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 473a790f5894..9dfe2bdf1482 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c @@ -768,7 +768,7 @@ void tipc_clone_to_loopback(struct net *net, struct sk_buff_head *pkts) skb->pkt_type = PACKET_HOST; skb->ip_summed = CHECKSUM_UNNECESSARY; skb->protocol = eth_type_trans(skb, dev); - netif_rx_ni(skb); + netif_rx(skb); } } From 94da81e2fc4285db373fe9a1eb012c2ee205b110 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 6 Mar 2022 22:57:48 +0100 Subject: [PATCH 05/10] batman-adv: Use netif_rx(). Since commit baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.") the function netif_rx() can be used in preemptible/thread context as well as in interrupt context. Use netif_rx(). Cc: Antonio Quartulli Cc: Marek Lindner Cc: Simon Wunderlich Cc: Sven Eckelmann Cc: b.a.t.m.a.n@lists.open-mesh.org Signed-off-by: Sebastian Andrzej Siewior Acked-by: Sven Eckelmann Signed-off-by: David S. Miller --- net/batman-adv/bridge_loop_avoidance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 337e20b6586d..7f8a14d99cdb 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -444,7 +444,7 @@ static void batadv_bla_send_claim(struct batadv_priv *bat_priv, const u8 *mac, batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES, skb->len + ETH_HLEN); - netif_rx_any_context(skb); + netif_rx(skb); out: batadv_hardif_put(primary_if); } From d33d0dc9275d29be68ae1bacf430e30dc112d769 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 6 Mar 2022 22:57:49 +0100 Subject: [PATCH 06/10] bluetooth: Use netif_rx(). Since commit baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.") the function netif_rx() can be used in preemptible/thread context as well as in interrupt context. Use netif_rx(). Cc: Marcel Holtmann Cc: Johan Hedberg Cc: Luiz Augusto von Dentz Cc: linux-bluetooth@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: David S. Miller --- net/bluetooth/6lowpan.c | 2 +- net/bluetooth/bnep/core.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index 8e8c07541153..215af9b3b589 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -240,7 +240,7 @@ static int give_skb_to_upper(struct sk_buff *skb, struct net_device *dev) if (!skb_cp) return NET_RX_DROP; - return netif_rx_ni(skb_cp); + return netif_rx(skb_cp); } static int iphc_decompress(struct sk_buff *skb, struct net_device *netdev, diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index 40baa6b7321a..5a6a49885ab6 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c @@ -400,7 +400,7 @@ static int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb) dev->stats.rx_packets++; nskb->ip_summed = CHECKSUM_NONE; nskb->protocol = eth_type_trans(nskb, dev); - netif_rx_ni(nskb); + netif_rx(nskb); return 0; badframe: From 63d57cd674541f3633d7e3e025c26c0ec01090fc Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 6 Mar 2022 22:57:50 +0100 Subject: [PATCH 07/10] phonet: Use netif_rx(). Since commit baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.") the function netif_rx() can be used in preemptible/thread context as well as in interrupt context. Use netif_rx(). Cc: Remi Denis-Courmont Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: David S. Miller --- net/phonet/af_phonet.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c index 65218b7ce9f9..2b582da1e88c 100644 --- a/net/phonet/af_phonet.c +++ b/net/phonet/af_phonet.c @@ -146,7 +146,7 @@ EXPORT_SYMBOL(phonet_header_ops); * Prepends an ISI header and sends a datagram. */ static int pn_send(struct sk_buff *skb, struct net_device *dev, - u16 dst, u16 src, u8 res, u8 irq) + u16 dst, u16 src, u8 res) { struct phonethdr *ph; int err; @@ -182,7 +182,7 @@ static int pn_send(struct sk_buff *skb, struct net_device *dev, if (skb->pkt_type == PACKET_LOOPBACK) { skb_reset_mac_header(skb); skb_orphan(skb); - err = (irq ? netif_rx(skb) : netif_rx_ni(skb)) ? -ENOBUFS : 0; + err = netif_rx(skb) ? -ENOBUFS : 0; } else { err = dev_hard_header(skb, dev, ntohs(skb->protocol), NULL, NULL, skb->len); @@ -214,7 +214,7 @@ static int pn_raw_send(const void *data, int len, struct net_device *dev, skb_reserve(skb, MAX_PHONET_HEADER); __skb_put(skb, len); skb_copy_to_linear_data(skb, data, len); - return pn_send(skb, dev, dst, src, res, 1); + return pn_send(skb, dev, dst, src, res); } /* @@ -269,7 +269,7 @@ int pn_skb_send(struct sock *sk, struct sk_buff *skb, if (!pn_addr(src)) src = pn_object(saddr, pn_obj(src)); - err = pn_send(skb, dev, dst, src, res, 0); + err = pn_send(skb, dev, dst, src, res); dev_put(dev); return err; From e1f9e434617fb28097223d9484de66218bc0b52d Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 6 Mar 2022 22:57:51 +0100 Subject: [PATCH 08/10] net: phy: micrel: Use netif_rx(). Since commit baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.") the function netif_rx() can be used in preemptible/thread context as well as in interrupt context. Use netif_rx(). Cc: Andrew Lunn Cc: Heiner Kallweit Cc: Russell King Cc: Divya Koppera Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: David S. Miller --- drivers/net/phy/micrel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 9e6b29b23935..d46b74ef3d6f 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -2034,7 +2034,7 @@ static bool lan8814_match_rx_ts(struct kszphy_ptp_priv *ptp_priv, memset(shhwtstamps, 0, sizeof(*shhwtstamps)); shhwtstamps->hwtstamp = ktime_set(rx_ts->seconds, rx_ts->nsec); - netif_rx_ni(skb); + netif_rx(skb); list_del(&rx_ts->list); kfree(rx_ts); @@ -2387,7 +2387,7 @@ static bool lan8814_match_skb(struct kszphy_ptp_priv *ptp_priv, shhwtstamps = skb_hwtstamps(skb); memset(shhwtstamps, 0, sizeof(*shhwtstamps)); shhwtstamps->hwtstamp = ktime_set(rx_ts->seconds, rx_ts->nsec); - netif_rx_ni(skb); + netif_rx(skb); } return ret; From 2655926aea9beea62c9ba80c032485456fd848f0 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 6 Mar 2022 22:57:52 +0100 Subject: [PATCH 09/10] net: Remove netif_rx_any_context() and netif_rx_ni(). Remove netif_rx_any_context and netif_rx_ni() because there are no more users in tree. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: David S. Miller --- include/linux/netdevice.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 19a27ac361ef..29a850a8d460 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3718,16 +3718,6 @@ int do_xdp_generic(struct bpf_prog *xdp_prog, struct sk_buff *skb); int netif_rx(struct sk_buff *skb); int __netif_rx(struct sk_buff *skb); -static inline int netif_rx_ni(struct sk_buff *skb) -{ - return netif_rx(skb); -} - -static inline int netif_rx_any_context(struct sk_buff *skb) -{ - return netif_rx(skb); -} - int netif_receive_skb(struct sk_buff *skb); int netif_receive_skb_core(struct sk_buff *skb); void netif_receive_skb_list_internal(struct list_head *head); From 67dbd6c0a2c427211244e344b85a55d6e82886bf Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sun, 6 Mar 2022 22:57:53 +0100 Subject: [PATCH 10/10] net: phy: micrel: Move netif_rx() outside of IRQ-off section. lan8814_match_rx_ts() invokes netif_rx() with disables interrupts outside which will create a warning. Invoking netif_rx_ni() with disabled interrupts is wrong even without the recent rework because netif_rx_ni() would enable interrupts while processing the softirq. This in turn can lead to dead lock if an interrupts triggers and attempts to acquire kszphy_ptp_priv::rx_ts_lock. Move netif_rx() outside the IRQ-off section. Cc: Andrew Lunn Cc: Heiner Kallweit Cc: Russell King Cc: Divya Koppera Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: David S. Miller --- drivers/net/phy/micrel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index d46b74ef3d6f..19b11e896460 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -2034,8 +2034,6 @@ static bool lan8814_match_rx_ts(struct kszphy_ptp_priv *ptp_priv, memset(shhwtstamps, 0, sizeof(*shhwtstamps)); shhwtstamps->hwtstamp = ktime_set(rx_ts->seconds, rx_ts->nsec); - netif_rx(skb); - list_del(&rx_ts->list); kfree(rx_ts); @@ -2044,6 +2042,8 @@ static bool lan8814_match_rx_ts(struct kszphy_ptp_priv *ptp_priv, } spin_unlock_irqrestore(&ptp_priv->rx_ts_lock, flags); + if (ret) + netif_rx(skb); return ret; }