fix(mt1959): run_init returns Ok once load_firmware confirms the unlock (D10)

load_firmware returns Ok only after its own do_unlock succeeded. run_init
then slept 10 s and re-ran do_unlock, and on attempt 2 fell out of the loop
returning Err(last_err), discarding a real unlock. Return Ok at once; the
firmware upload itself is unchanged (stop-design-v5 §1 D10, ST-D10).
This commit is contained in:
Matthew Jackson
2026-09-27 23:32:30 -07:00
parent 226be3a9f0
commit 712e58d316
+19 -4
View File
@@ -291,8 +291,15 @@ impl Mt1959 {
);
return Err(e);
}
// Every exit below returns or overwrites `last_err` with the reload's error.
Err(e) => {
last_err = e;
tracing::debug!(
target: "freemkv::disc",
phase = "mt1959_unlock_failed_reloading",
attempt,
error = %e,
"unlock failed; reloading firmware"
);
let loaded = if self.mode == MODE_A {
variant_a::load_firmware(self, scsi)
} else {
@@ -320,10 +327,18 @@ impl Mt1959 {
last_err = e;
continue;
}
// D10 (stop-design-v5 §1): "`run_init` must `return Ok(())` as soon as
// `load_firmware` confirms the unlock" — its own do_unlock already did.
// Looping re-ran it after a 10 s settle and discarded it on attempt 2.
Ok(()) => {
// Firmware upload resets the drive. Give it time to
// fully recover before retrying unlock.
std::thread::sleep(std::time::Duration::from_secs(10));
tracing::debug!(
target: "freemkv::disc",
phase = "mt1959_unlock_ok_after_upload",
attempt,
unlocked = self.unlocked,
"MT1959 unlock confirmed by the firmware upload"
);
return Ok(());
}
}
}