.../wireless/realtek/rtl8xxxu/.kunitconfig | 16 + drivers/net/wireless/realtek/rtl8xxxu/Kconfig | 11 + .../net/wireless/realtek/rtl8xxxu/Makefile | 3 + drivers/net/wireless/realtek/rtl8xxxu/core.c | 236 +++++++-- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 3 + .../net/wireless/realtek/rtl8xxxu/rx-test.c | 461 ++++++++++++++++++ .../net/wireless/realtek/rtl8xxxu/rx-test.h | 27 + 7 files changed, 707 insertions(+), 50 deletions(-) create mode 100644 drivers/net/wireless/realtek/rtl8xxxu/.kunitconfig create mode 100644 drivers/net/wireless/realtek/rtl8xxxu/rx-test.c create mode 100644 drivers/net/wireless/realtek/rtl8xxxu/rx-test.h
This resends the same patches after line wrapping damaged the previous
posting and prevented it from being applied. There are no code changes.
Previous posting:
https://lore.kernel.org/linux-wireless/CAH1Bc_wBUmmNyzF3c2H1aFBRBbAPSw0hR=1MnPOAcCXypVL_Dg@mail.gmail.com/
rtl8xxxu maintains a pool of 32 RX URBs. Successful completions return
their URBs to a pending list and schedule the RX worker when more than
eight URBs are waiting. The worker allocates fresh receive buffers and
resubmits the queued URBs in a batch.
Completion errors free the affected URBs, reducing the pool. Once eight
or fewer survive, their completions can leave all remaining requests on
the pending list without reaching the worker scheduling threshold. If no
request is in flight and no worker is pending or running, nothing triggers
further submissions, so RX remains stalled after the errors stop.
Temporary submission failures can leave requests in the same state, while
retaining an skb that the next submission attempt overwrites.
This series fixes buffer ownership on failed submission, unwinds
incomplete startup, and preserves requests through one delayed retry path.
The retry worker schedules submission even for a single request. A
separate error list provides a 100 ms batch delay from the first error
while preserving normal successful RX batching. Shutdown drains retry
work, submission work and active requests in that order.
Completion retries cover EPROTO, EILSEQ, ETIME, EOVERFLOW, ECOMM and ENOSR;
ENOMEM/EAGAIN from startup or worker submission uses the same retry path.
Cancellation and removal keep their release behavior. EPIPE endpoint-halt
recovery is outside this series.
With 24 injected EPROTO completions, the original driver stopped at eight
pending requests and zero in flight for about 30 seconds. Under the same
error budget, the patched driver retained all 32 requests and resumed RX
without restarting the interface.
Validation:
- ARM64 QEMU KUnit: 11/11 cases passed, covering the actual RX helpers,
worker, buffer ownership, startup failures and shutdown.
- RTL8192EU on Raspberry Pi, kernel 6.18.46-thesis-test-rt+: 13/13 cases
passed using a compatibility backport. The lab fixture substitutes
completion statuses and injects submission and allocation failures.
Each of the six completion statuses recovered after 32 completion
errors followed by 96 submission failures. Error-window, pending-retry
stop, startup failure and clean RX/down-up cases also passed.
- W=1 ARM64 allmodconfig and allyesconfig builds passed with incremental
caches; the changed driver and KUnit objects rebuilt in both.
Sparse added no diagnostics relative to baseline.
- Each intermediate production commit compiled, and sequential patch
application reproduced the corresponding source trees.
kimwooseok (4):
wifi: rtl8xxxu: free RX skb when URB submission fails
wifi: rtl8xxxu: unwind incomplete receive startup
wifi: rtl8xxxu: preserve RX requests across recoverable transfer
errors
wifi: rtl8xxxu: test RX ownership and recovery across failures
.../wireless/realtek/rtl8xxxu/.kunitconfig | 16 +
drivers/net/wireless/realtek/rtl8xxxu/Kconfig | 11 +
.../net/wireless/realtek/rtl8xxxu/Makefile | 3 +
drivers/net/wireless/realtek/rtl8xxxu/core.c | 236 +++++++--
.../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 3 +
.../net/wireless/realtek/rtl8xxxu/rx-test.c | 461 ++++++++++++++++++
.../net/wireless/realtek/rtl8xxxu/rx-test.h | 27 +
7 files changed, 707 insertions(+), 50 deletions(-)
create mode 100644 drivers/net/wireless/realtek/rtl8xxxu/.kunitconfig
create mode 100644 drivers/net/wireless/realtek/rtl8xxxu/rx-test.c
create mode 100644 drivers/net/wireless/realtek/rtl8xxxu/rx-test.h
base-commit: f71dd599a98182d6bc34dce39977f928068ecd64
--
2.48.1
A failed RX URB submission can leak the skb allocated for that attempt.
rtl8xxxu_submit_rx_urb() allocates the buffer and stores it in urb.context,
but if usb_submit_urb() fails, it only unanchors the URB. The RX worker
queues ENOMEM/EAGAIN failures for retry with that buffer still attached.
On the next attempt, rtl8xxxu_submit_rx_urb() allocates another skb and
overwrites urb.context, losing the reference to the previous buffer.
Stopping before the retry also leaks the buffer because pending-request
cleanup frees only the URB.
Fix the leak at the submission failure by making rtl8xxxu_submit_rx_urb()
responsible for both allocating the skb and releasing it when submission
fails. Free the newly allocated skb and clear urb.context before returning
the error, so neither retry nor stop receives a pending URB that still
owns a buffer. Remove the caller-side skb cleanup from start and the RX
worker; those callers now handle only whether to retry or release the URB.
Fixes: 26f1fad29ad9 ("New driver: rtl8xxxu (mac80211)")
Assisted-by: GPT-6 Astra
Signed-off-by: kimwooseok <5mghybrid@khu.ac.kr>
---
drivers/net/wireless/realtek/rtl8xxxu/core.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
kimwooseok <5mghybrid@khu.ac.kr> wrote: > drivers/net/wireless/realtek/rtl8xxxu/core.c | 16 +++++----------- > 1 file changed, 5 insertions(+), 11 deletions(-) Please send patch like non-RESEND version without patch attached. Ping-Ke
Ping-Ke Shih <pkshih@realtek.com> wrote: > kimwooseok <5mghybrid@khu.ac.kr> wrote: > > drivers/net/wireless/realtek/rtl8xxxu/core.c | 16 +++++----------- > > 1 file changed, 5 insertions(+), 11 deletions(-) > > Please send patch like non-RESEND version without patch attached. > Forgot to say the codebase should be rtw-next branch of https://github.com/pkshih/rtw.git, and patch tag is 'rtw-next'. Ping-Ke
rtl8xxxu_start() allocates and submits RX URBs one at a time. If a later
allocation fails, earlier requests may already be active. After a
successful submission, that allocation failure can also leave ret set
to zero. The error path then frees TX resources and disables RX filters
without draining the earlier RX requests, yet reports startup success.
Separate pool allocation from submission so an allocation failure can be
handled before any RX request is active. Introduce rtl8xxxu_alloc_rx_urbs()
to allocate all 32 wrappers, then rtl8xxxu_start_rx() to submit the
completed pool. Return ENOMEM for every RX or TX URB pool allocation
failure so a partial allocation is reported as an error.
Once submission begins, keep ENOMEM/EAGAIN failures queued for retry.
For other submission errors, rtl8xxxu_start_rx() frees the unsubmitted
requests and returns the error. Since earlier submissions may already be
active at that point, route the outer start failure through the existing
rtl8xxxu_stop() path. This drains queued work and active requests and
cleans up RF state and TX resources together. Interrupt URB submission
failure uses the same cleanup path.
Fixes: 26f1fad29ad9 ("New driver: rtl8xxxu (mac80211)")
Assisted-by: GPT-6 Astra
Signed-off-by: kimwooseok <5mghybrid@khu.ac.kr>
---
drivers/net/wireless/realtek/rtl8xxxu/core.c | 99 ++++++++++++++------
1 file changed, 71 insertions(+), 28 deletions(-)
rtl8xxxu normally reuses 32 RX URBs, scheduling the submission worker when
more than eight completed requests have accumulated on the pending list.
Completion errors free URBs instead. A finite error burst can therefore
leave eight or fewer requests, which cannot reach that threshold after
they all complete. With no request in flight and no worker pending or
running, RX stays stopped even after the errors cease.
To prevent these errors from shrinking the pool below the number
needed for normal resubmission, retain URBs after EPROTO, EILSEQ, ETIME,
EOVERFLOW, ECOMM and ENOSR completions. EHCI can report ENOSR for IN data-buffer
errors, and FHCI maps RX buffer overrun to ECOMM. Free the failed
transfer's skb and keep its URB on a separate retry list.
Keeping the URBs is only part of the fix: the driver must also submit
them again without waiting for nine requests to accumulate. When the
first failed request enters the retry list, schedule delayed work for
100 ms. Further failures join that list while the work is pending.
When it runs, move the collected requests to normal pending and schedule
the submission worker even if only one request is waiting. Keeping
failed requests separate until then prevents normal completions from
triggering an immediate retry; successful RX keeps its existing batching.
A retry can itself fail with ENOMEM/EAGAIN. Returning that request to
normal pending would bring back the same threshold problem, so route
temporary submission failures from both start and the RX worker through
the delayed retry list as well.
Serialize retry insertion and scheduling with shutdown so late
completions cannot schedule fresh retries during stop. Cancel retry work
first, then wait for submission work before killing active URBs, so a
running worker cannot submit a request after the active requests have
been drained.
Cancellation and removal keep their release behavior. EPIPE endpoint-halt
recovery remains outside this change because it requires quiescing
requests and distinguishing recovery cancellation from shutdown.
Fixes: 26f1fad29ad9 ("New driver: rtl8xxxu (mac80211)")
Assisted-by: GPT-6 Astra
Signed-off-by: kimwooseok <5mghybrid@khu.ac.kr>
---
drivers/net/wireless/realtek/rtl8xxxu/core.c | 71 +++++++++++++++++--
.../net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 3 +
2 files changed, 70 insertions(+), 4 deletions(-)
Add 11 KUnit cases for the RX allocation, submission, completion and retry paths. Cover each retryable completion followed by ENOMEM/EAGAIN, batch sizes 1, 8, 9 and 32, skb allocation failure, startup failure positions, cancellation and shutdown. Run the actual RX helpers and worker with task-scoped stubs for allocation and USB submission. Observer references check that the driver releases its URB and skb references. A delayed-work case checks that one retry request schedules the submission worker. Assisted-by: GPT-6 Astra Signed-off-by: kimwooseok <5mghybrid@khu.ac.kr> --- .../wireless/realtek/rtl8xxxu/.kunitconfig | 16 + drivers/net/wireless/realtek/rtl8xxxu/Kconfig | 11 + .../net/wireless/realtek/rtl8xxxu/Makefile | 3 + drivers/net/wireless/realtek/rtl8xxxu/core.c | 66 ++- .../net/wireless/realtek/rtl8xxxu/rx-test.c | 461 ++++++++++++++++++ .../net/wireless/realtek/rtl8xxxu/rx-test.h | 27 + 6 files changed, 569 insertions(+), 15 deletions(-) create mode 100644 drivers/net/wireless/realtek/rtl8xxxu/.kunitconfig create mode 100644 drivers/net/wireless/realtek/rtl8xxxu/rx-test.c create mode 100644 drivers/net/wireless/realtek/rtl8xxxu/rx-test.h
© 2016 - 2026 Red Hat, Inc.