🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
5 messages
5 total messages Started by Dane Linssen Fri, 09 Oct 2026 12:23
Re: r8152: RX stops until rebind after -EPROTO on the bulk-in endpoint
#1220
Author: Dane Linssen
Date: Fri, 09 Oct 2026 12:23
41 lines
11249 bytes
> You could try it. We may consider increasing retries in mainline if
> this turns out to solve real world problems. Though so far, in the only
> reported case of 3 retries not working, 10 retries over a span of 100ms
> weren't helping either...

Thanks, I'd like to try it. It needs some setup here first (signed
modules), so it may take a while before I can report back.

> Any results yet?

Yes: three more stalls on the same host in 11 days (09-30, 10-04,
10-06), all with virt_state 0x40, each recovered by the watchdog's
rebind in about 30 s. Dynamic debug was on for the last two. Both
start with a single burst, and in the 11 days there wasn't one
"Transfer error" on ep 2 outside the stalls. 10-04:

  22:36:09.251 Transfer error for slot 4 ep 2 on endpoint
  22:36:09.252 Soft-reset ep 2, slot 4
  22:36:09.255 Transfer error for slot 4 ep 2 on endpoint
  22:36:09.255 Soft-reset ep 2, slot 4
  22:36:09.258 Transfer error for slot 4 ep 2 on endpoint
  22:36:09.259 Soft-reset ep 2, slot 4
  22:36:09.262 Transfer error for slot 4 ep 2 on endpoint
  22:36:09.262 Soft-reset ep 2, slot 4
  22:36:09.265 Transfer error for slot 4 ep 2 on endpoint
  22:36:09.266 Hard-reset ep 2, slot 4

From there it's Transfer error + Hard-reset pairs at about 275/s
until the rebind 40 s later. 10-06 is the same: four soft retries
about 3.5 ms apart, the hard reset at +15 ms, then the same loop. So
here all the retries are spent within 15 ms.

usbmon, 2 s from each of the three stalls: every bulk-in (0x81)
completion is -71 (571, 553 and 551 of them), none succeed, and
bulk-out and the interrupt endpoint complete normally.

The other host with the same adapter logged no transfer errors at all
in the same 11 days.

Dane
Re: r8152: RX stops until rebind after -EPROTO on the bulk-in endpoint
#2935
Author: Michal Pecio
Date: Tue, 13 Oct 2026 21:25
71 lines
12128 bytes
[Adding Realtek people who contributed to r8152 before]

On Fri, 9 Oct 2026 14:23:57 +0200, Dane Linssen wrote:
> > You could try it. We may consider increasing retries in mainline if
> > this turns out to solve real world problems. Though so far, in the
> > only reported case of 3 retries not working, 10 retries over a span
> > of 100ms weren't helping either...  
> 
> Thanks, I'd like to try it. It needs some setup here first (signed
> modules), so it may take a while before I can report back.

Looking at the log below I'm not sure if it will help. 15 ms is quite
a long time and my gut feeling is that a temporary link disruption
would be unlikely to last so long and not affect TX, unless TX is idle
through all that time. Do you still have those usbmon logs, were other
endpoints active in the 15 ms preceding the first -71 status?

Absence of errors at other times suggests that this is not a case of
barely functional cable causing high rate of USB packet loss.

The other possibility is that a HW bug gets the endpoint in some bogus
state and only resetting the endpoint or whole device can fix it. Maybe
resetting the RX endpoint would suffice, and the driver schedules some
work on -EPROTO where usb_clear_halt() could be inserted.

Question remains, how to get the chip to abort the botched transfer
and start a new transfer into a new URB cleanly? Is it enough to keep
submitting URBs and eventually things will resynchronize? The driver
seems to believe so, but does this really work? It will need to.

> > Any results yet?  
> 
> Yes: three more stalls on the same host in 11 days (09-30, 10-04,
> 10-06), all with virt_state 0x40, each recovered by the watchdog's
> rebind in about 30 s. Dynamic debug was on for the last two. Both
> start with a single burst, and in the 11 days there wasn't one
> "Transfer error" on ep 2 outside the stalls. 10-04:
> 
>   22:36:09.251 Transfer error for slot 4 ep 2 on endpoint
>   22:36:09.252 Soft-reset ep 2, slot 4
>   22:36:09.255 Transfer error for slot 4 ep 2 on endpoint
>   22:36:09.255 Soft-reset ep 2, slot 4
>   22:36:09.258 Transfer error for slot 4 ep 2 on endpoint
>   22:36:09.259 Soft-reset ep 2, slot 4
>   22:36:09.262 Transfer error for slot 4 ep 2 on endpoint
>   22:36:09.262 Soft-reset ep 2, slot 4
>   22:36:09.265 Transfer error for slot 4 ep 2 on endpoint
>   22:36:09.266 Hard-reset ep 2, slot 4
> 
> From there it's Transfer error + Hard-reset pairs at about 275/s
> until the rebind 40 s later. 10-06 is the same: four soft retries
> about 3.5 ms apart, the hard reset at +15 ms, then the same loop.
> So here all the retries are spent within 15 ms.

After "hard reset" it's a 97% chance of endpoint sequence state being
out of sync. On USB3, resubmitting without usb_clear_halt() is futile.

Notice how baf33d7a7564 ("r8152: avoid to resubmit rx immediately")
only talks about disconnection and not recovering from these errors.
I suspect no one has seen such recovery, at least on USB3. Easily
recoverable errors don't reach drivers due to retries in HW and SW.

> usbmon, 2 s from each of the three stalls: every bulk-in (0x81)
> completion is -71 (571, 553 and 551 of them), none succeed, and
> bulk-out and the interrupt endpoint complete normally.
> 
> The other host with the same adapter logged no transfer errors at
> all in the same 11 days.
> 
> Dane
Re: r8152: RX stops until rebind after -EPROTO on the bulk-in endpoint
#8355
Author: Dane Linssen
Date: Wed, 28 Oct 2026 21:15
143 lines
19428 bytes
Hi Michal,

> Looking at the log below I'm not sure if it will help.

Agreed. All four soft retries failed within about 14 ms, so I'll skip
the retry patch unless you think it's still worth a try.

> 15 ms is quite
> a long time and my gut feeling is that a temporary link disruption
> would be unlikely to last so long and not affect TX, unless TX is idle
> through all that time. Do you still have those usbmon logs, were other
> endpoints active in the 15 ms preceding the first -71 status?

The pcaps don't reach back that far. The watchdog takes them when it
notices the stall, 8 to 33 s after the first error. In each of them
0x81 completes only with -71, and 0x02 and 0x83 complete with 0.

What I do have about the onset:

- xhci dynamic debug logs every "Transfer error", on any endpoint.
  Each burst starts on ep 2 (0x81), and no other endpoint logs an
  error near any of the stalls.
- Nothing else is in the kernel log in the 20 s before any onset:
  no carrier change, no USB event.
- Traffic is sampled once a minute, so it can't show a 15 ms gap in
  TX. Averages in the minutes before each onset:

    10-09, 4 stalls   NFS copies, 25-40 MB/s each way
    10-26 19:31       250-480 packets/s each way, under 0.5 MB/s
    10-26 20:19       1.8k-2.0k packets/s each way, about 2.5 MB/s

  So heavy traffic isn't needed, although the 09-27 and 10-09
  stalls came under load.

The onset is the same in all eight stalls logged with dynamic debug
(10-04 to 10-26): four soft resets about 3.5 ms apart, then the hard
reset 13.6 to 15.5 ms after the first error. After the hard reset the
-71 completions keep that pace, about one per 3.6 ms (~275/s). So
each soft retry takes as long to fail as the transfers after the
endpoint is out of sync.

Since my last mail there were six more stalls, all with virt_state
0x40, each fixed by the watchdog's rebind: four on 10-09 within
20 minutes (kernel 7.2.7) and two on 10-26 (7.2.11).

> The other possibility is that a HW bug gets the endpoint in some bogus
> state and only resetting the endpoint or whole device can fix it. Maybe
> resetting the RX endpoint would suffice, and the driver schedules some
> work on -EPROTO where usb_clear_halt() could be inserted.

I can test a patch like that here. Since today (10-28) this host no longer
runs cluster workloads and the adapter is on another USB port, so I
don't know how often it will stall now.

> Question remains, how to get the chip to abort the botched transfer
> and start a new transfer into a new URB cleanly? Is it enough to keep
> submitting URBs and eventually things will resynchronize? The driver
> seems to believe so, but does this really work? It will need to.

Without a clear_halt it never resynchronized here. The longest stall
left alone (09-27) still read virt_state 0x40 after 15 minutes, and
RX only came back with the rebind after 23 minutes.

For the Realtek side: RTL8156B, 0bda:8156, bcdDevice 31.04, firmware
rtl8156b-2 v3 10/20/23, on an Intel xHCI (8086:9d2f) at 5 Gbps.

Thanks,
Dane

On Tue, Oct 13, 2026 at 11:25 PM Michal Pecio <michal.pecio@gmail.com> wrote:
>
> [Adding Realtek people who contributed to r8152 before]
>
> On Fri, 9 Oct 2026 14:23:57 +0200, Dane Linssen wrote:
> > > You could try it. We may consider increasing retries in mainline if
> > > this turns out to solve real world problems. Though so far, in the
> > > only reported case of 3 retries not working, 10 retries over a span
> > > of 100ms weren't helping either...
> >
> > Thanks, I'd like to try it. It needs some setup here first (signed
> > modules), so it may take a while before I can report back.
>
> Looking at the log below I'm not sure if it will help. 15 ms is quite
> a long time and my gut feeling is that a temporary link disruption
> would be unlikely to last so long and not affect TX, unless TX is idle
> through all that time. Do you still have those usbmon logs, were other
> endpoints active in the 15 ms preceding the first -71 status?
>
> Absence of errors at other times suggests that this is not a case of
> barely functional cable causing high rate of USB packet loss.
>
> The other possibility is that a HW bug gets the endpoint in some bogus
> state and only resetting the endpoint or whole device can fix it. Maybe
> resetting the RX endpoint would suffice, and the driver schedules some
> work on -EPROTO where usb_clear_halt() could be inserted.
>
> Question remains, how to get the chip to abort the botched transfer
> and start a new transfer into a new URB cleanly? Is it enough to keep
> submitting URBs and eventually things will resynchronize? The driver
> seems to believe so, but does this really work? It will need to.
>
> > > Any results yet?
> >
> > Yes: three more stalls on the same host in 11 days (09-30, 10-04,
> > 10-06), all with virt_state 0x40, each recovered by the watchdog's
> > rebind in about 30 s. Dynamic debug was on for the last two. Both
> > start with a single burst, and in the 11 days there wasn't one
> > "Transfer error" on ep 2 outside the stalls. 10-04:
> >
> >   22:36:09.251 Transfer error for slot 4 ep 2 on endpoint
> >   22:36:09.252 Soft-reset ep 2, slot 4
> >   22:36:09.255 Transfer error for slot 4 ep 2 on endpoint
> >   22:36:09.255 Soft-reset ep 2, slot 4
> >   22:36:09.258 Transfer error for slot 4 ep 2 on endpoint
> >   22:36:09.259 Soft-reset ep 2, slot 4
> >   22:36:09.262 Transfer error for slot 4 ep 2 on endpoint
> >   22:36:09.262 Soft-reset ep 2, slot 4
> >   22:36:09.265 Transfer error for slot 4 ep 2 on endpoint
> >   22:36:09.266 Hard-reset ep 2, slot 4
> >
> > From there it's Transfer error + Hard-reset pairs at about 275/s
> > until the rebind 40 s later. 10-06 is the same: four soft retries
> > about 3.5 ms apart, the hard reset at +15 ms, then the same loop.
> > So here all the retries are spent within 15 ms.
>
> After "hard reset" it's a 97% chance of endpoint sequence state being
> out of sync. On USB3, resubmitting without usb_clear_halt() is futile.
>
> Notice how baf33d7a7564 ("r8152: avoid to resubmit rx immediately")
> only talks about disconnection and not recovering from these errors.
> I suspect no one has seen such recovery, at least on USB3. Easily
> recoverable errors don't reach drivers due to retries in HW and SW.
>
> > usbmon, 2 s from each of the three stalls: every bulk-in (0x81)
> > completion is -71 (571, 553 and 551 of them), none succeed, and
> > bulk-out and the interrupt endpoint complete normally.
> >
> > The other host with the same adapter logged no transfer errors at
> > all in the same 11 days.
> >
> > Dane
Re: r8152: RX stops until rebind after -EPROTO on the bulk-in endpoint
#9639
Author: Michal Pecio
Date: Mon, 02 Nov 2026 12:51
145 lines
17173 bytes
[Adding another Realtek contact I found in r8152.c]

Hi,

I found a way to artificially produce something similar, though not
mid-operation, so there is no partly completed transfer in flight.

This patch works for the simplified case, you could try if it helps
with your issues too.

It adds usb_clear_halt() and logs its return status just in case.

The commented code is my artificial trigger. To test:

  ifconfig up
  # receive a few packets
  ifconfig down
  ethtool
  ifconfig up
  # receive another packet
  # dmesg shows "transfer errors" and "usb_clear_halt(pipe_in): 0"

The rest is xHCI changes to delay execution of URBs queued in advance
until the pipe is cleared. This keeps them from failing and may actually
be necessary under heavy RX, because a concurrently processed URB could
cause usb_clear_halt() to leave the pipe desynchronized again.

In principle drivers should unlink URBs before calling that, but xHCI
is tolerant in this case. And HCDs aren't really supposed to continue
URB execution after a halt, so that was arguably a bug anyway.

The xHCI part is written a bit "oddly" to avoid conflicts with changes
between 7.2 and 7.3 (EP_DROP_PENDING).

Regards,
Michal

---
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index f61686433031..e59af0e2ca1d 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -7044,9 +7044,15 @@ static void rtl_work_func_t(struct work_struct *work)
 	    netif_carrier_ok(tp->netdev))
 		tasklet_schedule(&tp->tx_tl);
 
-	if (test_and_clear_bit(RX_EPROTO, &tp->flags) &&
-	    !list_empty(&tp->rx_done))
-		napi_schedule(&tp->napi);
+	if (test_and_clear_bit(RX_EPROTO, &tp->flags)) {
+		/* On USB3 the pipe won't work until we clear halt */
+		if (tp->udev->speed >= USB_SPEED_SUPER)
+			dev_info(&tp->intf->dev, "usb_clear_halt(pipe_in): %d\n",
+					usb_clear_halt(tp->udev, tp->pipe_in));
+
+		if (!list_empty(&tp->rx_done))
+			napi_schedule(&tp->napi);
+	}
 
 	mutex_unlock(&tp->control);
 
@@ -8935,6 +8941,9 @@ int rtl8152_get_link_ksettings(struct net_device *netdev,
 
 	mutex_lock(&tp->control);
 
+	//dev_err(&tp->intf->dev, "breaking RX\n");
+	//usb_reset_endpoint(tp->udev, 0x81);
+
 	mii_ethtool_get_link_ksettings(&tp->mii, cmd);
 
 	linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT,
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index b634f1089bb1..25910c40ee74 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -556,6 +556,8 @@ void xhci_ring_ep_doorbell(struct xhci_hcd *xhci,
 	struct xhci_virt_ep *ep = &xhci->devs[slot_id]->eps[ep_index];
 	unsigned int ep_state = ep->ep_state;
 
+	if (ep_state & EP_WAIT_CLEAR)
+		return;
 	/* Don't ring the doorbell for this endpoint if there are pending
 	 * cancellations because we don't want to interrupt processing.
 	 * We don't want to restart any stream rings if there's a set dequeue
@@ -2563,8 +2567,15 @@ static void process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_virt_ep *ep,
 	case COMP_USB_TRANSACTION_ERROR:
 		if (xhci->quirks & XHCI_NO_SOFT_RETRY ||
 		    (ep->err_count++ > MAX_SOFT_RETRY) ||
-		    le32_to_cpu(slot_ctx->tt_info) & TT_SLOT)
+		    le32_to_cpu(slot_ctx->tt_info) & TT_SLOT) {
+			/* halted endpoint */
+			if (td->urb->dev->speed >= USB_SPEED_SUPER) {
+				dev_info(&td->urb->dev->dev, "waiting for ep 0x%X clear halt\n",
+						td->urb->ep->desc.bEndpointAddress);
+				ep->ep_state |= EP_WAIT_CLEAR;
+			}
 			break;
+		}
 
 		td->status = 0;
 
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 6d997e07cb84..277911ebf65c 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1855,6 +1855,8 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
 		xhci_dbg(xhci, "Invalidating TDs instantly on slot %d ep %d in state 0x%x\n",
 				urb->dev->slot_id, ep_index, ep->ep_state);
 		xhci_process_cancelled_tds(xhci, ep);
+	} else if (ep->ep_state & EP_WAIT_CLEAR) {
+		xhci_process_cancelled_tds(xhci, ep);
 	} else {
 		/* Otherwise, queue a new Stop Endpoint command */
 		command = xhci_alloc_command(xhci, false, GFP_ATOMIC);
@@ -3403,7 +3405,7 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd,
 	/* Bail out if toggle is already being cleared by a endpoint reset */
 	spin_lock_irqsave(&xhci->lock, flags);
 	if (ep->ep_state & EP_HARD_CLEAR_TOGGLE) {
-		ep->ep_state &= ~EP_HARD_CLEAR_TOGGLE;
+		ep->ep_state &= ~(EP_HARD_CLEAR_TOGGLE | EP_WAIT_CLEAR);
 		spin_unlock_irqrestore(&xhci->lock, flags);
 		return;
 	}
@@ -3495,7 +3497,7 @@ static void xhci_endpoint_reset(struct usb_hcd *hcd,
 	xhci_free_command(xhci, stop_cmd);
 	spin_lock_irqsave(&xhci->lock, flags);
 	if (ep->ep_state & EP_SOFT_CLEAR_TOGGLE)
-		ep->ep_state &= ~EP_SOFT_CLEAR_TOGGLE;
+		ep->ep_state &= ~(EP_SOFT_CLEAR_TOGGLE | EP_WAIT_CLEAR);
 	spin_unlock_irqrestore(&xhci->lock, flags);
 }
 
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 379374a67c64..34ace464e155 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -670,6 +670,7 @@ struct xhci_virt_ep {
 	struct xhci_ring		*new_ring;
 	unsigned int			err_count;
 	unsigned int			ep_state;
+#define EP_WAIT_CLEAR		BIT(12)
 #define SET_DEQ_PENDING		BIT(0)
 #define EP_HALTED		BIT(1)	/* For stall handling */
 #define EP_STOP_CMD_PENDING	BIT(2)	/* For URB cancellation */
Re: r8152: RX stops until rebind after -EPROTO on the bulk-in endpoint
#9843
Author: Dane Linssen
Date: Mon, 02 Nov 2026 16:18
38 lines
14168 bytes
Hi Michal,

Your patch works here for the simplified case. I applied it to
openSUSE's 7.3.0 (offsets only) and tested on a second host with the
same RTL8156B (bcdDevice 31.04) and an Intel xHCI (8086:02ed), 5 Gbps.

Without the fix (stock xhci, r8152 with only your trigger), down /
ethtool / up gave exactly the stall I see on the other host: four
soft resets about 3.5 ms apart, the hard reset at +14 ms, then
Transfer error + Hard-reset at ~270/s, and virt_state 0x40. So the
onset of my real stalls can't be told apart from a desync that starts
at the first error.

With the patch, three rounds of down / ethtool / up all recovered.
Round 1:

  15:56:52.892  Transfer error for slot 1 ep 2 on endpoint
                (3 more Transfer error + Soft-reset, ~3.5 ms apart)
  15:56:52.907  Transfer error for slot 1 ep 2 on endpoint
  15:56:52.907  waiting for ep 0x81 clear halt
  15:56:52.908  Hard-reset ep 2, slot 1
  15:56:52.908  usb_clear_halt(pipe_in): 0

No errors after that, and RX worked: the gateway answered pings and
rx_packets kept rising. usb_clear_halt() returned 0 every time.

The host that stalls on its own hasn't stalled since 10-28. Three
things changed around then: the adapter moved to another USB port,
the kernel went from 7.2.11 to 7.3.0 the day before, and the host now
carries much less traffic. However, a 74 GB copy at ~15 MB/s over the
new port on 10-28 didn't stall it.

Testing your patch on that host needs signed modules, and I can't get
to it for a while.

Thanks,
Dane
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads