Blame qemu-0.9.0-atapi-hsm.patch

David Woodhouse 02760b
From: Brandon Philips <brandon@ifup.org>
David Woodhouse 02760b
Newsgroups: gmane.comp.emulators.qemu
David Woodhouse 02760b
Subject: [PATCH][RFC] Fix bugs in the ATAPI cdrom driver
David Woodhouse 02760b
Date: Fri, 17 Aug 2007 16:43:04 -0700
David Woodhouse 02760b
Message-ID: <20070817234304.GB10490@ifup.org>
David Woodhouse 02760b
Reply-To: qemu-devel@nongnu.org
David Woodhouse 02760b
David Woodhouse 02760b
The new libata-eh in the Linux kernel is throwing a fit over the QEMU
David Woodhouse 02760b
cdrom device for two reasons:
David Woodhouse 02760b
David Woodhouse 02760b
1) DRQ can be set with ERR_STAT set.  This is a violation of the ATAPI
David Woodhouse 02760b
state machine.
David Woodhouse 02760b
David Woodhouse 02760b
2) After a TEST_UNIT_READY ATAPI command is sent ERR_STAT is getting set
David Woodhouse 02760b
which is correct.  But, when the OS issues another ATAPI command
David Woodhouse 02760b
ERR_STAT is still set.  Which is bad since the next expected command
David Woodhouse 02760b
from the OS is REQUEST_SENSE to find out why ERR_STAT is set.
David Woodhouse 02760b
David Woodhouse 02760b
bug this fixes: https://bugzilla.novell.com/show_bug.cgi?id=291775
David Woodhouse 02760b
David Woodhouse 02760b
Signed-off-by: Brandon Philips <bphilips@suse.de>
David Woodhouse 02760b
David Woodhouse 02760b
---
David Woodhouse 02760b
 hw/ide.c |    7 +++++--
David Woodhouse 02760b
 1 file changed, 5 insertions(+), 2 deletions(-)
David Woodhouse 02760b
David Woodhouse 02760b
Index: qemu-0.9.0/hw/ide.c
David Woodhouse 02760b
===================================================================
David Woodhouse 02760b
--- qemu-0.9.0.orig/hw/ide.c
David Woodhouse 02760b
+++ qemu-0.9.0/hw/ide.c
David Woodhouse 02760b
@@ -586,7 +586,9 @@ static void ide_transfer_start(IDEState 
David Woodhouse 02760b
     s->end_transfer_func = end_transfer_func;
David Woodhouse 02760b
     s->data_ptr = buf;
David Woodhouse 02760b
     s->data_end = buf + size;
David Woodhouse 02760b
-    s->status |= DRQ_STAT;
David Woodhouse 02760b
+    /* don't violate the HSM */
David Woodhouse 02760b
+    if (!(s->status & ERR_STAT))
David Woodhouse 02760b
+        s->status |= DRQ_STAT;
David Woodhouse 02760b
 }
David Woodhouse 02760b
 
David Woodhouse 02760b
 static void ide_transfer_stop(IDEState *s)
David Woodhouse 02760b
@@ -1805,6 +1807,7 @@ static void ide_ioport_write(void *opaqu
David Woodhouse 02760b
             /* overlapping commands not supported */
David Woodhouse 02760b
             if (s->feature & 0x02)
David Woodhouse 02760b
                 goto abort_cmd;
David Woodhouse 02760b
+            s->status = READY_STAT;
David Woodhouse 02760b
             s->atapi_dma = s->feature & 1;
David Woodhouse 02760b
             s->nsector = 1;
David Woodhouse 02760b
             ide_transfer_start(s, s->io_buffer, ATAPI_PACKET_SIZE, 
David Woodhouse 02760b
David Woodhouse 02760b
David Woodhouse 02760b