* [PATCH net v2] r8169: recheck the TX descriptor after a vector-map interrupt
@ 2026-11-29 13:42 Vlad Banea
2026-11-29 13:48 ` netdev-bot+sinfo
2026-11-30 13:45 ` netdev-bot+sashiko
0 siblings, 2 replies; 5+ messages in thread
From: Vlad Banea @ 2026-11-29 13:42 UTC (permalink / raw)
To: netdev
Cc: hkallweit1, javen_xu, nic_swsd, andrew+netdev, davem, edumazet,
kuba, pabeni, linux-kernel
With the vector-map interrupt model, the TX interrupt can arrive before
the descriptor write-back is visible to the CPU. rtl_tx() then stops at
a descriptor that still looks owned by the chip, and completed packets
stay unreaped until BQL stops the queue and the watchdog resets the
chip. The legacy handler is not affected because it reads IntrStatus
before polling.
If the first pending descriptor still looks owned, read the vector-map
interrupt status register, which makes the write-back visible, and check
it once more. RX was checked the same way with a request/response test
and showed no stranded descriptors, so it is left unchanged.
Fixes: 677f8f8c4c5f ("r8169: add support for new interrupt mapping")
Signed-off-by: Vlad Banea <montrealtango@gmail.com>
---
Notes:
Changes in v2:
- read ISR_VEC_MAP_REG instead of IMR_CLEAR_VEC_MAP_REG (Sashiko)
- say why RX is left unchanged (Sashiko)
- v1: https://lore.kernel.org/netdev/20261125022643.1169045-1-montrealtango@gmail.com/
Javen Xu confirmed that the RTL8127A, the chip upstream uses this
interrupt model for, is affected:
https://lore.kernel.org/netdev/d672fb6d16b04fb4a1c9b3202d276662@realsil.com.cn/
drivers/net/ethernet/realtek/r8169_main.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index f151ab681393..844c48119028 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -5228,6 +5228,7 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
int budget)
{
unsigned int dirty_tx, bytes_compl = 0, pkts_compl = 0;
+ bool recheck = tp->irq_nvecs > 1;
struct sk_buff *skb;
dirty_tx = tp->dirty_tx;
@@ -5237,8 +5238,18 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
u32 status;
status = le32_to_cpu(READ_ONCE(tp->TxDescArray[entry].opts1));
- if (status & DescOwn)
- break;
+ if (status & DescOwn) {
+ /* The vector-map TX interrupt can arrive before the
+ * descriptor write-back is visible. Reading the
+ * interrupt status register makes it visible, as in
+ * the legacy handler; look once more.
+ */
+ if (!recheck)
+ break;
+ recheck = false;
+ RTL_R32(tp, ISR_VEC_MAP_REG);
+ continue;
+ }
skb = tp->tx_skb[entry].skb;
rtl8169_unmap_tx_skb(tp, entry);
base-commit: 28a371228d4eb4857cc31eeb1a0d7d01e9c3ea2f
--
2.53.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net v2] r8169: recheck the TX descriptor after a vector-map interrupt
2026-11-29 13:42 [PATCH net v2] r8169: recheck the TX descriptor after a vector-map interrupt Vlad Banea
@ 2026-11-29 13:48 ` netdev-bot+sinfo
2026-11-29 13:58 ` Vlad Banea
2026-11-30 13:45 ` netdev-bot+sashiko
1 sibling, 1 reply; 5+ messages in thread
From: netdev-bot+sinfo @ 2026-11-29 13:48 UTC (permalink / raw)
To: Vlad Banea
Cc: netdev, hkallweit1, javen_xu, nic_swsd, andrew+netdev, davem,
edumazet, kuba, pabeni, linux-kernel
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net v2] r8169: recheck the TX descriptor after a vector-map interrupt
2026-11-29 13:48 ` netdev-bot+sinfo
@ 2026-11-29 13:58 ` Vlad Banea
0 siblings, 0 replies; 5+ messages in thread
From: Vlad Banea @ 2026-11-29 13:58 UTC (permalink / raw)
To: netdev-bot+sinfo
Cc: netdev, hkallweit1, javen_xu, nic_swsd, andrew+netdev, davem,
edumazet, kuba, pabeni, linux-kernel
The issue was hit during development: while enabling RSS on the
RTL8125B with the vector-map interrupt model, bursty TCP traffic
triggered NETDEV WATCHDOG TX timeouts. Debugging showed rtl_tx()
stopping at a descriptor that still looked owned right after the TX
interrupt.
Tested on two RTL8125B (XID 641, firmware rtl8125b-2_0.0.2 07/13/20)
connected back to back, in an x86_64 KVM guest with VFIO passthrough.
Upstream uses the vector-map interrupt model only on the RTL8127A, which
I don't have, so the test kernel also had the RTL8125B RSS series from
the RFC to enable it on these chips. Without the fix, a burst test hit
19 TX timeouts in 31 bursts; with this version (ISR_VEC_MAP_REG read),
none, and sustained traffic ran at 2.36 Gbit/s with no retransmits.
Javen Xu confirmed that the RTL8127A is affected as well.
Vlad
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net v2] r8169: recheck the TX descriptor after a vector-map interrupt
2026-11-29 13:42 [PATCH net v2] r8169: recheck the TX descriptor after a vector-map interrupt Vlad Banea
2026-11-29 13:48 ` netdev-bot+sinfo
@ 2026-11-30 13:45 ` netdev-bot+sashiko
2026-11-30 16:01 ` Vlad Banea
1 sibling, 1 reply; 5+ messages in thread
From: netdev-bot+sashiko @ 2026-11-30 13:45 UTC (permalink / raw)
To: montrealtango
Cc: netdev, hkallweit1, javen_xu, nic_swsd, andrew+netdev, davem,
edumazet, kuba, pabeni, linux-kernel
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The fix may not close the TX stall it targets.
--
r8169: recheck the TX descriptor after a vector-map interrupt
With the vector-map interrupt model, the TX MSI-X interrupt can arrive
before the descriptor write-back is visible to the CPU. In that case
rtl_tx() stops at a descriptor that still looks owned by the chip. When
irq_nvecs > 1, this patch reads ISR_VEC_MAP_REG once to flush the
write-back and then checks the first pending descriptor once more.
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index f151ab6813932..844c48119028f 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
[ ... ]
> @@ -5237,8 +5238,18 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
> u32 status;
>
> status = le32_to_cpu(READ_ONCE(tp->TxDescArray[entry].opts1));
> - if (status & DescOwn)
> - break;
> + if (status & DescOwn) {
> + /* The vector-map TX interrupt can arrive before the
> + * descriptor write-back is visible. Reading the
> + * interrupt status register makes it visible, as in
> + * the legacy handler; look once more.
> + */
> + if (!recheck)
> + break;
> + recheck = false;
> + RTL_R32(tp, ISR_VEC_MAP_REG);
> + continue;
> + }
[Severity: Medium]
Does this fully close the TX stall it targets, or only make it less likely?
A non-posted MMIO read only orders posted writes that the device has
already queued ahead of the read completion. It does not stop the chip
from answering the ISR_VEC_MAP_REG read before it has queued the
descriptor write-back.
The commit message says the TX MSI-X can arrive before the write-back is
visible. Both of those are posted writes from the chip, so the chip can
evidently signal completion before the write-back is ordered.
Is there a Realtek guarantee that the ISR_VEC_MAP_REG read completion is
ordered behind the TX write-back in vector-map mode? The comparison with
the legacy handler looks empirical. The legacy handler also does its read
in hard IRQ context, not from NAPI.
If the second look still sees DescOwn, the loop breaks and nothing
revisits the descriptor. The vector's ISR bit was already cleared in
hard IRQ:
rtl8169_interrupt_msix()
rtl8169_disable_hw_interrupt_msix(tp, message_id);
rtl8169_clear_hw_isr(tp, message_id);
napi_schedule(napi);
and rtl8169_poll_msix_tx() then re-arms without checking the ring again:
rtl_tx(dev, tp, budget);
if (budget && napi_complete_done(napi, 0))
rtl8169_enable_hw_interrupt_msix(tp, (int)(napi - tp->rtl8169_napi));
Suppose that descriptor was the last one in flight, for example after BQL
stopped the queue. Then no later TOK interrupt would arrive, the
completion would stay unreaped, and the netdev watchdog would reset the
chip. That is the failure the commit message describes.
Would a fallback make sense if the single flush is not enough? Options
include a bounded retry, rescheduling NAPI, or rechecking the ring after
re-arming the interrupt.
>
> skb = tp->tx_skb[entry].skb;
> rtl8169_unmap_tx_skb(tp, entry);
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129134257.2722047-1-montrealtango%40gmail.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net v2] r8169: recheck the TX descriptor after a vector-map interrupt
2026-11-30 13:45 ` netdev-bot+sashiko
@ 2026-11-30 16:01 ` Vlad Banea
0 siblings, 0 replies; 5+ messages in thread
From: Vlad Banea @ 2026-11-30 16:01 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: netdev, hkallweit1, javen_xu, nic_swsd, andrew+netdev, davem,
edumazet, kuba, pabeni, linux-kernel
> - [Medium] The fix may not close the TX stall it targets.
You're right that the read is not guaranteed by PCIe ordering alone, and
I cheecked: with the burst test that shows the stall (19 TX timeouts
in 31 bursts without the fix):
register read (IMR_CLEAR, ISR_VEC_MAP_REG or ChipCmd): 0 in 217 bursts
udelay(5) instead of the read: 1 in 155 bursts
So the effect is probably timing, and the read has not failed in testing,
but the numbers do not actually prove that it orders the write-back.
A fallback that keeps NAPI polling while the descriptor looks owned does
not work well: at line rate the second look finds a descriptor still in
flight in most TX polls, so it would busy-poll under load.
The robust fix is to stop relying on the write-back. The RTL8125 has a
"TX no-close" mode (TxConfig bit 6) in which the chip reports completion
through a hardware pointer register (HW_CLO_PTR0, 0x2802) and the driver
never checks DescOwn. An experimental patch for the RTL8125B gave 0 TX
timeouts in 93 bursts and passes my other tests. Since vector-map mode is
only enabled on the RTL8125B by my RSS series, I would propose no-close
for net-next together with it, and keep this patch as the minimal fix
for net.
Javen, does the RTL8127A support the same mode in vector-map operation,
and would Realtek prefer it there too? I have no RTL8127A to test.
Vlad
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-30 16:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-29 13:42 [PATCH net v2] r8169: recheck the TX descriptor after a vector-map interrupt Vlad Banea
2026-11-29 13:48 ` netdev-bot+sinfo
2026-11-29 13:58 ` Vlad Banea
2026-11-30 13:45 ` netdev-bot+sashiko
2026-11-30 16:01 ` Vlad Banea
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®