dgesswein / mfm

MFM emulator code
GNU General Public License v3.0
50 stars 11 forks source link

Avoid 2 hangs during shutdown #41

Closed wohali closed 9 months ago

wohali commented 9 months ago

Unstable system power resulted in hung PRUs in two separate ways that prevented powerfail from performing an orderly shutdown, as mfm_emu never terminated:

  1. If /SEEK is endlessly asserted, shutdown fails because PRU0 will not leave an infinite loop until /SEEK goes high again.

  2. After glitched external signals, due to disorderly shutdown in an ornery host, PRU1 signals PRU0 write_done and is in write_done_wait waiting to hear PRU0 is in STATE_READ. But PRU0 is in selected waiting to hear STATE_READ_DONE from PRU1. Deadlock.

In both cases a check for PRU0_EXIT is now made, and EXIT is immediately performed should it be found. Putting a check for EXIT into glitch did not avoid the second case, unfortunately, so the PRU0_EXIT check was inlined directly where the deadlock was observed.

This patch eliminates all observed failed shutdowns during extensive testing.