kernel: bump 6.1 to 6.1.70
[openwrt/staging/nbd.git] / target / linux / ipq806x / patches-6.1 / 700-01-net-introduce-napi_is_scheduled-helper.patch
1 From b5532bdc6d09e6e789417f0c7a0b665b57b0e7be Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Mon, 18 Sep 2023 14:21:56 +0200
4 Subject: [PATCH 1/4] net: introduce napi_is_scheduled helper
5
6 We currently have napi_if_scheduled_mark_missed that can be used to
7 check if napi is scheduled but that does more thing than simply checking
8 it and return a bool. Some driver already implement custom function to
9 check if napi is scheduled.
10
11 Drop these custom function and introduce napi_is_scheduled that simply
12 check if napi is scheduled atomically.
13
14 Update any driver and code that implement a similar check and instead
15 use this new helper.
16
17 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
18 ---
19 drivers/net/ethernet/chelsio/cxgb3/sge.c | 8 --------
20 drivers/net/wireless/realtek/rtw89/core.c | 2 +-
21 include/linux/netdevice.h | 5 +++++
22 net/core/dev.c | 2 +-
23 4 files changed, 7 insertions(+), 10 deletions(-)
24
25 --- a/drivers/net/ethernet/chelsio/cxgb3/sge.c
26 +++ b/drivers/net/ethernet/chelsio/cxgb3/sge.c
27 @@ -2507,14 +2507,6 @@ static int napi_rx_handler(struct napi_s
28 return work_done;
29 }
30
31 -/*
32 - * Returns true if the device is already scheduled for polling.
33 - */
34 -static inline int napi_is_scheduled(struct napi_struct *napi)
35 -{
36 - return test_bit(NAPI_STATE_SCHED, &napi->state);
37 -}
38 -
39 /**
40 * process_pure_responses - process pure responses from a response queue
41 * @adap: the adapter
42 --- a/drivers/net/wireless/realtek/rtw89/core.c
43 +++ b/drivers/net/wireless/realtek/rtw89/core.c
44 @@ -1479,7 +1479,7 @@ static void rtw89_core_rx_to_mac80211(st
45 struct napi_struct *napi = &rtwdev->napi;
46
47 /* In low power mode, napi isn't scheduled. Receive it to netif. */
48 - if (unlikely(!test_bit(NAPI_STATE_SCHED, &napi->state)))
49 + if (unlikely(!napi_is_scheduled(napi)))
50 napi = NULL;
51
52 rtw89_core_hw_to_sband_rate(rx_status);
53 --- a/include/linux/netdevice.h
54 +++ b/include/linux/netdevice.h
55 @@ -468,6 +468,11 @@ static inline bool napi_prefer_busy_poll
56 return test_bit(NAPI_STATE_PREFER_BUSY_POLL, &n->state);
57 }
58
59 +static inline bool napi_is_scheduled(struct napi_struct *n)
60 +{
61 + return test_bit(NAPI_STATE_SCHED, &n->state);
62 +}
63 +
64 bool napi_schedule_prep(struct napi_struct *n);
65
66 /**
67 --- a/net/core/dev.c
68 +++ b/net/core/dev.c
69 @@ -6594,7 +6594,7 @@ static int __napi_poll(struct napi_struc
70 * accidentally calling ->poll() when NAPI is not scheduled.
71 */
72 work = 0;
73 - if (test_bit(NAPI_STATE_SCHED, &n->state)) {
74 + if (napi_is_scheduled(n)) {
75 work = n->poll(n, weight);
76 trace_napi_poll(n, work, weight);
77 }