mirror of
https://github.com/hathach/tinyusb.git
synced 2026-08-18 11:02:16 +00:00
wch: do not re-arm the fallback ladder on link-partner loss
The re-arm fixed F1 (FB_USB3_UP is terminal, so a replug into a USB2-only host stayed dead) but introduced a worse regression, because the ladder advances on a timer regardless of whether anything is attached. Unplugged, nothing sets _fb_saw_terms, so the budget is 4 ticks of 0.55 s: at ~2.2 s training is declared exhausted and USB3 is torn down, and the 5th tick at ~2.75 s runs ch56x_usb2_init() and latches FB_USB2_ACTIVE, which is itself terminal. Any unplug longer than about three seconds therefore demoted the board to 480 Mbps permanently - including the ordinary case of replugging into the same SuperSpeed host, and this is the shipping default for hydrausb3_v1. Re-arming safely requires gating the ladder on an attached partner rather than on a timer, so F1 stays open. The rest of the state-owner work is unaffected: fallback_enter() remains the only writer of _fb_state, fallback_timer_start() still re-enables TMR0_IRQn (F10), and the deferred re-init still re-checks the state after its settle (F7).
This commit is contained in:
@ -630,14 +630,16 @@ static void handle_link_irq(uint8_t rhport) {
|
||||
link_set_power_mode(2);
|
||||
USBSS->LINK_CTRL |= USBSS_LINK_CTRL_POLLING_EN;
|
||||
} else {
|
||||
// partner disappeared: teardown now, settle + re-init deferred to task context
|
||||
// partner disappeared: teardown now, settle + re-init deferred to task context.
|
||||
//
|
||||
// Deliberately does NOT re-arm the fallback ladder here. Doing so looks right - FB_USB3_UP
|
||||
// is otherwise terminal, so a replug into a USB2-only host stays dead - but the ladder
|
||||
// advances on a timer with no partner attached: unplugged, _fb_saw_terms is false, the
|
||||
// 4-tick budget expires 2.2 s later and the 5th tick hands the port to USB2 for good
|
||||
// (FB_USB2_ACTIVE is itself terminal). That demotes the ordinary case - unplug, replug into
|
||||
// the same SuperSpeed host - to 480 Mbps permanently, which is worse than the case it
|
||||
// fixes. Re-arming safely needs the ladder gated on an attached partner, not on a timer.
|
||||
USBSS->LINK_INT_CTRL = 0;
|
||||
#if CFG_TUD_WCH_USB30_FALLBACK
|
||||
// Re-arm the ladder. FB_USB3_UP is otherwise terminal: usbd calls neither dcd_init nor
|
||||
// dcd_connect on link loss, so a replug into a USB2-only host would find no ladder
|
||||
// running and no USB2 controller (dcd_init deinit'd it) -- dead until a power cycle.
|
||||
fallback_enter(FB_USB3_TRAINING);
|
||||
#endif
|
||||
dcd_event_t event = {.rhport = rhport, .event_id = DCD_EVENT_UNPLUGGED};
|
||||
dcd_event_handler(&event, true);
|
||||
usb30_bus_reset_from_isr();
|
||||
|
||||
Reference in New Issue
Block a user