mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
sfp: do not block the main loop while a module wakes up
handle_sfp() called sfp_module_read() as soon as it saw a module appear, and that path opened with delay(100). delay() spins on PCON until the tick counter runs down, so the main loop stood still for 100 ticks - half a second at SYS_TICK_HZ 200. Nothing else ran in that window: no STP, no LACP, no packet handling. A diagnostic build measured the sfp phase at up to 107 ticks, the longest stall of any phase in the loop. Remember when the module showed up and let the loop continue. The I2C read happens on a later pass, once the wake-up period has elapsed. Pulling a module cancels a pending read, and a failed read still restores the detect bit, so the existing retry-on-the-next-poll behaviour is unchanged. The comparison is written out rather than using a helper so that this does not depend on anything outside the current tree. The pending flag is an array indexed by slot, like the other per-slot state in this file. Cost on SWTGW218AS, measured against the branch point: BANK3 11173 -> 11264, CSEG, BANK1 and BANK2 unchanged, plus 4 bytes of xdata.
This commit is contained in:
1 parent
b1961c6955
commit
a3860c29cb
2 files changed
+12
-1