The ATAPI software reset function is implemented somewhat lackadaisically.
Firstly, it is valid only for ATAPI drives - not HDs. If a HD should
receive this command while BSY, it should be ignored like any other
command instead of aborted. A non-BSY HD is free to abort the command
in the usual fashion to indicate it doesn't understand or doesn't support
Second, for drives that should accept a software reset, they should not
"forget" about all pending AIO during the reset. Since a software reset
resets the DRQ and BSY flags, it is possible to 'stack' multiple
concurrent reads using DMA and alternately chaining software reset and
DMA reads. We mustn't reset BSY/DRQ until we are confident that we
have canceled existing AIO.
Third, the existing software reset routine does not perform a very
This series corrects this by:
(1) Correcting ide_exec_cmd to correctly ignore, not abort, software
reset commands for ide-hd devices that are busy executing a command.
(2) Improving the software reset routine to cancel buffered DMA, then
fall back to synchronously waiting for any pending DMA to finish
before returning, insuring that the reset completes sanely.
(3) Use existing reset routines to comprehensively reset the device.
Reported-by: Kevin Wolf <email@example.com>
Signed-off-by: John Snow <firstname.lastname@example.org>
For convenience, this branch is available at:
https://github.com/jnsnow/qemu.git branch ide-reset-fix
This version is tagged ide-reset-fix-v1: