Repository navigation
SBP-2: re-login/reconnect after rediscovery, not on a 100 ms timer - #216
Conversation
|
Timing from the LS-9000, build
Breakdown: 100 ms discovery delay + ~550 ms ROM scan. The LS-9000 reports Unrelated observation, same session: pulling the Thunderbolt adapter restarts the dext against a scanner that still holds the old login. The LS-9000 then accepts login and LUN reset but never executes an ORB until it is power-cycled while disconnected. Pre-existing (the powercycle/re-login case from #61), not touched by this PR. |
mrmidi
left a comment
There was a problem hiding this comment.
Approving as is. The change matches both references (Linux sbp2_update, Apple resumeNotify), and the 650 ms measurement settles the timing for now. Most of that time is our ROM scan, which re-reads every node's whole ROM after each reset instead of checking the bus info block against the cache, as Apple does. We'll fix that in discovery separately.
One known gap, for a follow-up PR: RefreshTargets decides between Login and Reconnect with LoginID() == 0. SBP-2 doesn't reserve login_ID 0, so a target that assigns it would get a Login after every reset while it still holds our old login. That login is rejected with "access denied" (§8.2), and the session only recovers when the target drops the old login. Could you check which login IDs the LS-9000 and the H4D report in your logs (login successful — loginID=)? If either shows 0, the follow-up below becomes urgent.
Instead of patching the sentinel, I'd like LoginSession as a std::variant state machine once #217–#219 have landed, so it covers their states too:
- Each state carries its own data, e.g.
LoggedIn{loginID, commandBlockAgent, reconnectHold, generation, node}, andSuspendedsplit into "login held" (reconnect) and "no login" (log in). No sentinels, no stale side fields. - One transition function
(state, event) → state, plus a transition table in the PR checked against AppleIOFireWireSBP2Login(suspendedNotify/resumeNotify) and Linuxsbp2_login/sbp2_reconnect. - Threading:
state_,loginID_andloginGeneration_are atomics because the user client reads them from another queue (SBP2Handler.hpp:227). Keep the variant on the driver queue and publish an atomic snapshot of what observers read. LoginStatestays as the reported enum, so the registry, the bridge and the user client don't change.- One test per transition, including a login with login_ID 0 that reconnects after a reset.
|
Login IDs from the logs:
So the H4D hits the sentinel: with this PR it gets a Login instead of a Reconnect after every bus reset. I haven't seen the resulting "access denied" in a log yet, since that capture doesn't show the login status after the escalation reset. I'll take the |
Split of #213 (merge order):
Split out of #213 per review.
HandleBusResetarmed a 100 ms timer that calledReconnect()(orLogin()if the login was in flight).Reconnect()takes the node ID fromtargetInfo_, which is only refreshed byRefreshTargetsafter rediscovery, so the timer addressed the pre-reset node ID. Both references reconnect after re-enumeration: Linuxsbp2_update→sbp2_reconnect, AppleIOFireWireSBP2Login::resumeNotify. Now the session goes Suspended andRefreshTargetslogs in (if the login never completed) or reconnects with the refreshed node ID.The open question from review is whether rediscovery completes within
reconnect_hold + 1 s. I'll post bus reset → Reconnect-write timing from the LS-9000 with Discovery/ROMScanner logging in this PR before marking it ready.Host tests:
LoginSessionTestsupdated (two tests replaced), newSessionRegistryTests.BusResetDuringLoginLogsInAgainAfterRediscovery.