qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] ATAPI CDROM DMA support is incomplete
@ 2007-01-19 20:55 Juergen Keil
  2007-01-19 23:24 ` Martin Bochnig
  0 siblings, 1 reply; 2+ messages in thread
From: Juergen Keil @ 2007-01-19 20:55 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: TEXT/plain, Size: 754 bytes --]

Hi,


some time ago, ATAPI DMA support was added to hw/ide.c, but the DMA 
support is incomplete:  DMA data transfers are implemented
for ATAPI/SCSI READ commands only (GPCMD_READ_10, GPCMD_READ_12,
GPCMD_READ_CD), but all other ATAPI/SCSI commands still try to
transfer data using PIO mode.

Because of this problem, neither Windows ME nor Windows 2000 guests
will use ATAPI CD DMA transfers and fall back to PIO mode.

Or a OpenSolaris x86 guest will report errors like this
"WARNING: /pci@0,0/pci-ide@1,1/ide@1 (ata1): timeout: abort request,
target=0 lun=0" and is unable to read data from the CD (You had to
force the ata/atapi driver to pio mode to work around this problem).


The attached patch adds DMA support for non-READ ATAPI/SCSI commands.

[-- Attachment #2: ide_dma.patch --]
[-- Type: TEXT/plain, Size: 2243 bytes --]

Index: hw/ide.c
===================================================================
RCS file: /cvsroot/qemu/qemu/hw/ide.c,v
retrieving revision 1.50
diff -u -B -r1.50 ide.c
--- hw/ide.c	5 Jan 2007 18:58:34 -0000	1.50
+++ hw/ide.c	19 Jan 2007 20:32:34 -0000
@@ -394,6 +394,7 @@
 } PCIIDEState;
 
 static void ide_dma_start(IDEState *s, BlockDriverCompletionFunc *dma_cb);
+static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret);
 
 static void padstr(char *str, const char *src, int len)
 {
@@ -1063,11 +1064,17 @@
         size = max_size;
     s->lba = -1; /* no sector read */
     s->packet_transfer_size = size;
+    s->io_buffer_size = size;    /* dma: send the reply data as one chunk */
     s->elementary_transfer_size = 0;
     s->io_buffer_index = 0;
 
-    s->status = READY_STAT;
-    ide_atapi_cmd_reply_end(s);
+    if (s->atapi_dma) {
+    	s->status = READY_STAT | DRQ_STAT;
+	ide_dma_start(s, ide_atapi_cmd_read_dma_cb);
+    } else {
+    	s->status = READY_STAT;
+    	ide_atapi_cmd_reply_end(s);
+    }
 }
 
 /* start a CD-CDROM read command */
@@ -1099,14 +1106,23 @@
     }
 
     if (s->io_buffer_size > 0) {
-        if (s->cd_sector_size == 2352) {
-            n = 1;
-            cd_data_to_raw(s->io_buffer, s->lba);
-        } else {
-            n = s->io_buffer_size >> 11;
-        }
+	/*
+	 * For a cdrom read sector command (s->lba != -1),
+	 * adjust the lba for the next s->io_buffer_size chunk
+	 * and dma the current chunk.
+	 * For a command != read (s->lba == -1), just transfer
+	 * the reply data.
+	 */
+	if (s->lba != -1) {
+	    if (s->cd_sector_size == 2352) {
+		n = 1;
+		cd_data_to_raw(s->io_buffer, s->lba);
+	    } else {
+		n = s->io_buffer_size >> 11;
+	    }
+	    s->lba += n;
+	}
         s->packet_transfer_size -= s->io_buffer_size;
-        s->lba += n;
         if (dma_buf_rw(bm, 1) == 0)
             goto eot;
     }
@@ -1170,7 +1186,8 @@
                                int sector_size)
 {
 #ifdef DEBUG_IDE_ATAPI
-    printf("read: LBA=%d nb_sectors=%d\n", lba, nb_sectors);
+    printf("read %s: LBA=%d nb_sectors=%d\n", s->atapi_dma ? "dma" : "pio",
+	lba, nb_sectors);
 #endif
     if (s->atapi_dma) {
         ide_atapi_cmd_read_dma(s, lba, nb_sectors, sector_size);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] ATAPI CDROM DMA support is incomplete
  2007-01-19 20:55 [Qemu-devel] [PATCH] ATAPI CDROM DMA support is incomplete Juergen Keil
@ 2007-01-19 23:24 ` Martin Bochnig
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Bochnig @ 2007-01-19 23:24 UTC (permalink / raw)
  To: qemu-devel

Hi

Juergen Keil wrote:

>Hi,
>
>
>some time ago, ATAPI DMA support was added to hw/ide.c, but the DMA 
>support is incomplete:  DMA data transfers are implemented
>for ATAPI/SCSI READ commands only (GPCMD_READ_10, GPCMD_READ_12,
>GPCMD_READ_CD), but all other ATAPI/SCSI commands still try to
>transfer data using PIO mode.
>
>Because of this problem, neither Windows ME nor Windows 2000 guests
>will use ATAPI CD DMA transfers and fall back to PIO mode.
>
>Or a OpenSolaris x86 guest will report errors like this
>"WARNING: /pci@0,0/pci-ide@1,1/ide@1 (ata1): timeout: abort request,
>target=0 lun=0" and is unable to read data from the CD (You had to
>force the ata/atapi driver to pio mode to work around this problem).
>
>
>The attached patch adds DMA support for non-READ ATAPI/SCSI commands.
>  
>
>------------------------------------------------------------------------
>
>Index: hw/ide.c
>===================================================================
>


You got it fixed once again, thank you Mr. Keil!


-MB

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-01-19 23:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-19 20:55 [Qemu-devel] [PATCH] ATAPI CDROM DMA support is incomplete Juergen Keil
2007-01-19 23:24 ` Martin Bochnig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).