--- --- hw/lsi53c895a.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) Index: qemu/hw/lsi53c895a.c =================================================================== --- qemu.orig/hw/lsi53c895a.c 2008-09-24 13:25:09.000000000 +0200 +++ qemu/hw/lsi53c895a.c 2008-09-24 16:00:55.000000000 +0200 @@ -452,6 +452,10 @@ static void lsi_do_dma(LSIState *s, int if (!s->current_dma_len) { /* Wait until data is available. */ DPRINTF("DMA no data available\n"); + if (s->command_complete == 2) { + /* no data available, call the complete function */ + s->current_dev->read_data(s->current_dev, s->current_tag); + } return; } @@ -598,7 +602,7 @@ static void lsi_command_complete(void *o if (reason == SCSI_REASON_DONE) { DPRINTF("Command complete sense=%d\n", (int)arg); s->sense = arg; - s->command_complete = 2; + s->command_complete = 3; if (s->waiting && s->dbc != 0) { /* Raise phase mismatch for short transfers. */ lsi_bad_phase(s, out, PHASE_ST); @@ -615,7 +619,7 @@ static void lsi_command_complete(void *o } DPRINTF("Data ready tag=0x%x len=%d\n", tag, arg); s->current_dma_len = arg; - s->command_complete = 1; + s->command_complete = s->current_dma_len ? 1 : 2; if (!s->waiting) return; if (s->waiting == 1 || s->dbc == 0) { @@ -829,7 +833,7 @@ static void lsi_wait_reselect(LSIState * break; } } - if (s->current_dma_len == 0) { + if (s->current_dma_len == 0 && s->command_complete != 2) { s->waiting = 1; } } @@ -935,7 +939,8 @@ again: switch (opcode) { case 0: /* Select */ s->sdid = id; - if (s->current_dma_len && (s->ssid & 0xf) == id) { + if ((s->current_dma_len || s->command_complete == 2) && + (s->ssid & 0xf) == id) { DPRINTF("Already reselected by target %d\n", id); break; }