| From a3eac970a1a3e2fc8cdc98acd2594e0578725ad6 Mon Sep 17 00:00:00 2001 |
| From: Sam Shih <sam.shih@mediatek.com> |
| Date: Fri, 2 Jun 2023 13:06:30 +0800 |
| Subject: [PATCH] |
| [networking][999-2711-net-fix-premature-exit-from-napi-state-polling-in-napi-disable-v2.patch] |
| |
| --- |
| net/core/dev.c | 7 +++++-- |
| 1 file changed, 5 insertions(+), 2 deletions(-) |
| |
| diff --git a/net/core/dev.c b/net/core/dev.c |
| index cccd7b407..794c768e3 100644 |
| --- a/net/core/dev.c |
| +++ b/net/core/dev.c |
| @@ -6394,7 +6394,7 @@ void napi_disable(struct napi_struct *n) |
| might_sleep(); |
| set_bit(NAPI_STATE_DISABLE, &n->state); |
| |
| - do { |
| + for ( ; ; ) { |
| val = READ_ONCE(n->state); |
| if (val & (NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC)) { |
| usleep_range(20, 200); |
| @@ -6403,7 +6403,10 @@ void napi_disable(struct napi_struct *n) |
| |
| new = val | NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC; |
| new &= ~(NAPIF_STATE_THREADED); |
| - } while (cmpxchg(&n->state, val, new) != val); |
| + |
| + if (cmpxchg(&n->state, val, new) == val) |
| + break; |
| + } |
| |
| hrtimer_cancel(&n->timer); |
| |
| -- |
| 2.34.1 |
| |