From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KiV4V-0001Bp-C6 for qemu-devel@nongnu.org; Wed, 24 Sep 2008 10:10:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KiV4T-0001AV-Cx for qemu-devel@nongnu.org; Wed, 24 Sep 2008 10:10:26 -0400 Received: from [199.232.76.173] (port=56575 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KiV4S-0001AM-Vp for qemu-devel@nongnu.org; Wed, 24 Sep 2008 10:10:25 -0400 Received: from ecfrec.frec.bull.fr ([129.183.4.8]:57073) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KiV4S-0007Tu-Fr for qemu-devel@nongnu.org; Wed, 24 Sep 2008 10:10:24 -0400 From: Laurent Vivier Content-Type: multipart/mixed; boundary="=-qoG0VS1I92uto85UJ7SG" Date: Wed, 24 Sep 2008 16:09:36 +0200 Message-Id: <1222265376.4166.11.camel@frecb07144> Mime-Version: 1.0 Subject: [Qemu-devel] [PATCH][RFC] lsi53c895a: manage aborted read Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "qemu-devel@nongnu.org" Cc: Paul Brook --=-qoG0VS1I92uto85UJ7SG Content-Type: text/plain Content-Transfer-Encoding: 7bit When we connect a "real" tape device to the LSI controller using scsi-generic, we can have aborted read. When controller sends a read it is waiting for a given amount of data, but if the tape meets the end of data before this value the controller is not able to manage it. This patch is trying to correct this. All comments are welcome... Signed-off-by: Laurent Vivier -- ------------- Laurent.Vivier@bull.net -------------- "In short: just say NO TO DRUGS and maybe you won't end up like the Hurd people." -- Linus Torvald --=-qoG0VS1I92uto85UJ7SG Content-Disposition: attachment; filename=scsi-generic-empty-DMA.patch Content-Type: text/x-vhdl; name=scsi-generic-empty-DMA.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit --- --- 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; } --=-qoG0VS1I92uto85UJ7SG--