Thread (1 message) 1 message, 1 author, 2025-08-30

Re: [PATCH 1/1] r8169: hardening and stability improvements

From: Andrew Lunn <andrew@lunn.ch>
Date: 2025-08-30 02:30:11
Also in: lkml

On Sat, Aug 30, 2025 at 02:21:18AM +0330, mohammad Hosseini wrote:
From 40b549f1f955a177729374b73b58ec89d40f37a7 Mon Sep 17 00:00:00 2001
From: mohammad amin hosseini <redacted>
Date: Fri, 29 Aug 2025 21:18:21 +0000
Subject: [PATCH 1/1] r8169: hardening and stability improvements

This patch improves robustness and reliability of the r8169 driver. The
changes cover buffer management, interrupt handling, parameter validation,
and resource cleanup.

While the updates touch multiple areas, they are interdependent parts of a
cohesive hardening effort. Splitting them would leave intermediate states
with incomplete validation.

Key changes:
- Buffer handling: add packet length checks, NUMA-aware fallback allocation,
  descriptor zero-initialization, and memory barriers.
- Interrupt handling: fix return codes, selective NAPI scheduling, and
  improved SYSErr handling for RTL_GIGA_MAC_VER_52.
- Parameter validation: stricter RX/TX bounds checking and consistent
  error codes.
- Resource management: safer workqueue shutdown, proper clock lifecycle,
  WARN_ON for unexpected device states.
- Logging: use severity-appropriate levels, add rate limiting, and extend
  statistics tracking.

Testing:
- Kernel builds and module loads without warnings.
- Runtime tested in QEMU (rtl8139 emulation).
- Hardware validation requested from community due to lack of local device.

Signed-off-by: Mohammad Amin Hosseini <redacted>
---
 drivers/net/ethernet/realtek/r8169_main.c | 150 ++++++++++++++++++----
 1 file changed, 123 insertions(+), 27 deletions(-)

rtl8169_private *tp,
  int node = dev_to_node(d);
  dma_addr_t mapping;
  struct page *data;
+ gfp_t gfp_flags = GFP_KERNEL;
 
- data = alloc_pages_node(node, GFP_KERNEL, get_order(R8169_RX_BUF_SIZE));
- if (!data)
- return NULL;
+ /* Use atomic allocation in interrupt/atomic context */
+ if (in_atomic() || irqs_disabled())
+ gfp_flags = GFP_ATOMIC;
+
+ data = alloc_pages_node(node, gfp_flags, get_order(R8169_RX_BUF_SIZE));
+ if (unlikely(!data)) {
+ /* Try fallback allocation on any node if local node fails */
+ data = alloc_pages(gfp_flags | __GFP_NOWARN, get_order(R8169_RX_BUF_SIZE));
+ if (unlikely(!data)) {
+ if (net_ratelimit())
+ netdev_err(tp->dev, "Failed to allocate RX buffer\n");
+ return NULL;
+ }
As you can see, your patch is whitespace damaged. Please try to use
"get send-email", or "b4 send" to avoid these issues.

    Andrew

---
pw-bot: cr
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help