blob: ef18a4923beafb65e1188252cbcf0dae90acbcfa [file] [log] [blame]
developer5d148cb2023-06-02 13:08:11 +08001From a3eac970a1a3e2fc8cdc98acd2594e0578725ad6 Mon Sep 17 00:00:00 2001
2From: Sam Shih <sam.shih@mediatek.com>
3Date: Fri, 2 Jun 2023 13:06:30 +0800
4Subject: [PATCH]
5 [networking][999-2711-net-fix-premature-exit-from-napi-state-polling-in-napi-disable-v2.patch]
6
7---
8 net/core/dev.c | 7 +++++--
9 1 file changed, 5 insertions(+), 2 deletions(-)
10
11diff --git a/net/core/dev.c b/net/core/dev.c
12index cccd7b407..794c768e3 100644
13--- a/net/core/dev.c
14+++ b/net/core/dev.c
15@@ -6394,7 +6394,7 @@ void napi_disable(struct napi_struct *n)
16 might_sleep();
17 set_bit(NAPI_STATE_DISABLE, &n->state);
18
19- do {
20+ for ( ; ; ) {
21 val = READ_ONCE(n->state);
22 if (val & (NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC)) {
23 usleep_range(20, 200);
24@@ -6403,7 +6403,10 @@ void napi_disable(struct napi_struct *n)
25
26 new = val | NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC;
27 new &= ~(NAPIF_STATE_THREADED);
28- } while (cmpxchg(&n->state, val, new) != val);
29+
30+ if (cmpxchg(&n->state, val, new) == val)
31+ break;
32+ }
33
34 hrtimer_cancel(&n->timer);
35
36--
372.34.1
38