Juergen Keil
2007-Jan-12 18:56 UTC
[qemu-discuss] Patch: atapi cd dma problems with Solaris x86 quests
I''ve had a look why the Opensolaris kernel running inside qemu-cvs is reporting timeout errors when booting from the Solaris Express (x86) CD/DVD, with the default "atapi-cd-dma-enabled=1" setting. It seems the problem is that qemu hw/ide.c implements "atapi-cd-dma" only for scsi READ commands, and assumes that all other scsi commands transfer data in PIO mode. But the Solaris ata (atapi) driver expects that scsi commands like INQUIRY, MODE SENSE, ... transfer their data using DMA transfers, too. I''ve experimented with the attached patch; it adds DMA support for non-READ scsi commands to qemu-cvs. With this patch installed, the Solaris Express installer is able to boot from the install media, and I don''t have to specify "-B atapi-cd-dma-enabled=0" any more. With this patch installed, a Windows ME or Windows 2000 qemu guest reports that it uses DMA with the CD, too. -------------- next part -------------- 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 12 Jan 2007 18:07:42 -0000 @@ -394,6 +395,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) { @@ -1062,12 +1064,17 @@ if (size > max_size) size = max_size; s->lba = -1; /* no sector read */ - s->packet_transfer_size = size; + s->io_buffer_size = s->packet_transfer_size = size; 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,16 @@ } 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; - } + 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; }
Ben Taylor
2007-Jan-12 19:45 UTC
[qemu-discuss] Re: Patch: atapi cd dma problems with Solaris x86 quests
> > I''ve had a look why the Opensolaris kernel running > inside qemu-cvs is > reporting timeout errors when booting from the > Solaris Express (x86) CD/DVD, > with the default "atapi-cd-dma-enabled=1" setting.Booting with Solaris NVb54 from CDROM iso and from the installed B54, I''m no longer seeing timeouts on the installed version either. Nice job Ben -- This message posted from opensolaris.org
Carlo Marcelo Arenas Belon
2007-Jan-15 01:28 UTC
[qemu-discuss] Re: Patch: atapi cd dma problems with Solaris x86 quests
tested in a Gentoo Linux qemu 0.8.2 host running Solaris 10u3 and NexentaOS alpha 6 guests -- This message posted from opensolaris.org
Carlo Marcelo Arenas Belon
2007-Jan-15 01:29 UTC
[qemu-discuss] Re: Patch: atapi cd dma problems with Solaris x86 quests
attached file with the patch in diff format so it can be easier to apply and test -- This message posted from opensolaris.org -------------- next part -------------- A non-text attachment was scrubbed... Name: qemu-atapidma.patch Type: application/octet-stream Size: 1747 bytes Desc: not available URL: <http://mail.opensolaris.org/pipermail/qemu-discuss/attachments/20070114/21edab33/attachment.obj>
Martin Bochnig
2007-Jan-20 23:28 UTC
[qemu-discuss] Re: Patch: atapi cd dma problems with Solaris x86 quests
> > I''ve had a look why the Opensolaris kernel running > inside qemu-cvs is > reporting timeout errors when booting from the > Solaris Express (x86) CD/DVD, > with the default "atapi-cd-dma-enabled=1" setting. > > > It seems the problem is that qemu hw/ide.c implements > "atapi-cd-dma" only > for scsi READ commands, and assumes that all other > scsi commands transfer > data in PIO mode. > > But the Solaris ata (atapi) driver expects that scsi > commands like INQUIRY, > MODE SENSE, ... transfer their data using DMA > transfers, too. > > > I''ve experimented with the attached patch; it adds > DMA support for > non-READ scsi commands to qemu-cvs. With this patch > installed, > the Solaris Express installer is able to boot from > the install media, > and I don''t have to specify "-B > atapi-cd-dma-enabled=0" any more.I can confirm this for your patch merged into qemu_cvs20070120sat on a sparc HOST with sol-nv-b54-x86-v1.iso as guest. Awesome, thanks Mr. Keil! > With this patch installed, a Windows ME or Windows> 2000 qemu guest reports > that it uses DMA with the CD, too. > Index: hw/ide.cDoes SiSoft Sandra also confirm this (not just the ControlPanel)?? -MB -- This message posted from opensolaris.org
Martin Bochnig
2007-Jan-20 23:31 UTC
[qemu-discuss] Re: Patch: atapi cd dma problems with Solaris x86 quests
> I can confirm this for your patch merged into > qemu_cvs20070120sat on a sparc HOSTI mean, it is already inside cvs, as you had submitted it yesterday. -MB -- This message posted from opensolaris.org