diff --git a/package/kernel/mac80211/patches/subsys/010-v5.10-net-Add-netif_rx_any_context.patch b/package/kernel/mac80211/patches/subsys/010-v5.10-net-Add-netif_rx_any_context.patch new file mode 100644 index 0000000000..1ab9f96a0d --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/010-v5.10-net-Add-netif_rx_any_context.patch @@ -0,0 +1,74 @@ +From 3440d5e562d57dad40a180f580431db480f6233a Mon Sep 17 00:00:00 2001 +From: Sebastian Andrzej Siewior +Date: Tue, 29 Sep 2020 22:25:12 +0200 +Subject: [PATCH] net: Add netif_rx_any_context() + +Quite some drivers make conditional decisions based on in_interrupt() to +invoke either netif_rx() or netif_rx_ni(). + +Conditionals based on in_interrupt() or other variants of preempt count +checks in drivers should not exist for various reasons and Linus clearly +requested to either split the code pathes or pass an argument to the +common functions which provides the context. + +This is obviously the correct solution, but for some of the affected +drivers this needs a major rewrite due to their convoluted structure. + +As in_interrupt() usage in drivers needs to be phased out, provide +netif_rx_any_context() as a stop gap for these drivers. + +This confines the in_interrupt() conditional to core code which in turn +allows to remove the access to this check for driver code and provides one +central place to do further modifications once the driver maze is cleaned +up. + +Suggested-by: Thomas Gleixner +Signed-off-by: Sebastian Andrzej Siewior +Signed-off-by: Thomas Gleixner +Signed-off-by: David S. Miller +--- + include/linux/netdevice.h | 1 + + net/core/dev.c | 15 +++++++++++++++ + 2 files changed, 16 insertions(+) + +diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h +index fbd689c15974..cf2771f5c8a7 100644 +--- a/include/linux/netdevice.h ++++ b/include/linux/netdevice.h +@@ -3571,6 +3571,7 @@ void generic_xdp_tx(struct sk_buff *skb, struct bpf_prog *xdp_prog); + int do_xdp_generic(struct bpf_prog *xdp_prog, struct sk_buff *skb); + int netif_rx(struct sk_buff *skb); + int netif_rx_ni(struct sk_buff *skb); ++int netif_rx_any_context(struct sk_buff *skb); + int netif_receive_skb(struct sk_buff *skb); + int netif_receive_skb_core(struct sk_buff *skb); + void netif_receive_skb_list(struct list_head *head); +diff --git a/net/core/dev.c b/net/core/dev.c +index a6798117bb1a..e5c65e67d1eb 100644 +--- a/net/core/dev.c ++++ b/net/core/dev.c +@@ -4533,6 +4533,21 @@ int netif_rx_ni(struct sk_buff *skb) + } + EXPORT_SYMBOL(netif_rx_ni); + ++int netif_rx_any_context(struct sk_buff *skb) ++{ ++ /* ++ * If invoked from contexts which do not invoke bottom half ++ * processing either at return from interrupt or when softrqs are ++ * reenabled, use netif_rx_ni() which invokes bottomhalf processing ++ * directly. ++ */ ++ if (in_interrupt()) ++ return netif_rx(skb); ++ else ++ return netif_rx_ni(skb); ++} ++EXPORT_SYMBOL(netif_rx_any_context); ++ + static __latent_entropy void net_tx_action(struct softirq_action *h) + { + struct softnet_data *sd = this_cpu_ptr(&softnet_data); +-- +2.25.1 +