qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Brittain <jason@brittainweb.org>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] enabling bus-master IDE driver
Date: Fri, 12 Nov 2004 10:02:24 -0800	[thread overview]
Message-ID: <4194FAB0.6000103@brittainweb.org> (raw)
In-Reply-To: <200411121427.iACERgAV027831@leo.tools.intra>

Juergen Keil wrote:
> 
>>I just pulled the latest source from CVS (today's), and tried
>>looking at DMA again.
>>
>>Host: Linux 2.6 (Fedora Core 2)
>>Guest: XP corp.
>>It still says the primary IDE channel is in PIO mode, and
>>doesn't seem any faster.
> 
> 
> I guess Windows 2000/XP is confused about the fact that a qemu hdd now
> supports ultra dma modes, but no multiword dma modes.  Maybe the windows
> ata driver gives up on dma as soon as it notices that the hdd drive does
> not support any multiword dma modes?
> 
> Try to add a "put_le16(p + 63, 0x07);" to hw/ide.c ide_identify() and
> ide_atapi_identify().  This announces support for multiword dma modes 0-2.
> This change appears to enable DMA on Win 2000.
> 
> 
> I'm currently using the following changes (note: this diff is against the
> previous version of ide.c, qemu-cvs already contains a few of these changes),
> and seem to get DMA with Win ME, Win 2000 and Solaris x86.
> 
> 
> Index: hw/ide.c
> ===================================================================
> RCS file: /cvsroot/qemu/qemu/hw/ide.c,v
> retrieving revision 1.28
> diff -u -B -r1.28 ide.c
> --- hw/ide.c    9 Oct 2004 20:27:55 -0000       1.28
> +++ hw/ide.c    12 Nov 2004 14:15:25 -0000
> @@ -416,10 +416,10 @@
>      put_le16(p + 47, 0x8000 | MAX_MULT_SECTORS);
>  #endif
>      put_le16(p + 48, 1); /* dword I/O */
> -    put_le16(p + 49, 1 << 9); /* LBA supported, no DMA */
> +    put_le16(p + 49, 1 << 8 | 1 << 9); /* DMA and LBA supported */
>      put_le16(p + 51, 0x200); /* PIO transfer cycle */
>      put_le16(p + 52, 0x200); /* DMA transfer cycle */
> -    put_le16(p + 53, 1); /* words 54-58 are valid */
> +    put_le16(p + 53, 1 | 1 << 2); /* words 54-58,88 are valid */
>      put_le16(p + 54, s->cylinders);
>      put_le16(p + 55, s->heads);
>      put_le16(p + 56, s->sectors);
> @@ -430,6 +430,8 @@
>          put_le16(p + 59, 0x100 | s->mult_sectors);
>      put_le16(p + 60, s->nb_sectors);
>      put_le16(p + 61, s->nb_sectors >> 16);
> +    put_le16(p + 63, 0x07 /*| 0x4 << 8*/); /* Multiword DMA supported/selected 
> */
> +    put_le16(p + 64, 0x3f); /* PIO modes supported */
>      put_le16(p + 80, (1 << 1) | (1 << 2));
>      put_le16(p + 82, (1 << 14));
>      put_le16(p + 83, (1 << 14));
> @@ -437,6 +439,8 @@
>      put_le16(p + 85, (1 << 14));
>      put_le16(p + 86, 0);
>      put_le16(p + 87, (1 << 14));
> +    put_le16(p + 88, 0x3f | 0x20 << 8); /* UltraDMA modes supported/selected */
> +    put_le16(p + 93, 1 | (1 << 1) | (1 << 3) | (1 << 13) | (1 << 14));
>  }
>  
>  static void ide_atapi_identify(IDEState *s)
> @@ -456,10 +460,10 @@
>      padstr((uint8_t *)(p + 23), QEMU_VERSION, 8); /* firmware version */
>      padstr((uint8_t *)(p + 27), "QEMU CD-ROM", 40); /* model */
>      put_le16(p + 48, 1); /* dword I/O (XXX: should not be set on CDROM) */
> -    put_le16(p + 49, 1 << 9); /* LBA supported, no DMA */
> -    put_le16(p + 53, 3); /* words 64-70, 54-58 valid */
> -    put_le16(p + 63, 0x103); /* DMA modes XXX: may be incorrect */
> -    put_le16(p + 64, 1); /* PIO modes */
> +    put_le16(p + 49, 1 << 8 | 1 << 9); /* DMA and LBA supported */
> +    put_le16(p + 53, 7); /* words 64-70, 54-58, 88 valid */
> +    put_le16(p + 63, 0x07 /*| 0x4 << 8*/); /* Multiword DMA supported/selected 
> */
> +    put_le16(p + 64, 0x3f); /* PIO modes supported */
>      put_le16(p + 65, 0xb4); /* minimum DMA multiword tx cycle time */
>      put_le16(p + 66, 0xb4); /* recommended DMA multiword tx cycle time */
>      put_le16(p + 67, 0x12c); /* minimum PIO cycle time without flow control */
> @@ -469,6 +473,7 @@
>      put_le16(p + 72, 30); /* in ns */
>  
>      put_le16(p + 80, 0x1e); /* support up to ATA/ATAPI-4 */
> +    put_le16(p + 88, 0x3f | 0x20 << 8); /* UltraDMA modes supported/selected */
>  }
>  
>  static void ide_set_signature(IDEState *s)
> @@ -498,6 +503,10 @@
>  static inline void ide_set_irq(IDEState *s)
>  {
>      if (!(s->cmd & IDE_CMD_DISABLE_IRQ)) {
> +       BMDMAState *bm = s->bmdma;
> +       if(bm)
> +           bm->status |= BM_STATUS_INT;
> +
>  #ifdef TARGET_PPC
>          if (s->openpic) 
>              openpic_set_irq(s->openpic, s->irq, 1);
> @@ -1560,7 +1569,7 @@
>              case 0x82: /* write cache disable */
>              case 0xaa: /* read look-ahead enable */
>              case 0x55: /* read look-ahead disable */
> -                s->status = READY_STAT;
> +                s->status = READY_STAT | SEEK_STAT;
>                  ide_set_irq(s);
>                  break;
>              default:
> @@ -2174,6 +2183,7 @@
>      pci_conf[0x01] = 0x80;
>      pci_conf[0x02] = 0x10;
>      pci_conf[0x03] = 0x70;
> +    pci_conf[0x09] = 0x8a; // programming interface = PCI_IDE bus master is 
> supported
>      pci_conf[0x0a] = 0x01; // class_sub = PCI_IDE
>      pci_conf[0x0b] = 0x01; // class_base = PCI_mass_storage
>      pci_conf[0x0e] = 0x00; // header_type

This is interesting..

I carefully applied these changes to my ide.c and retried:

Host: Linux 2.6 (Fedora Core 2)
Guest: XP corp.
It now says "Current Transfer Mode: Multi-Word DMA Mode 2".
I'm not real sure how I test to see if disk access is faster,
or by how much, but this appears to be progress for XP.

Host: Linux 2.6 (Fedora Core 2)
Guest: Linux 2.6
Upon boot I used hdparm to show the settings for /dev/hda.  It
said that DMA was on.  So I did some hdparm -t /dev/hda timings.
It is now half the speed it was when I used the source from CVS
HEAD (~25MB/s now, compared with ~45MB/s when I tested CVS HEAD).
I used hdparm to turn off DMA, and to list the settings again
to verify the change took affect.  Then I did more hdparm -t
timings.  Transfer rate went down to 10MB/s.  Turning it back on
with hdparm brings it back up to ~25MB/s.  So, compared with
what's in CVS HEAD, this appears significantly slower for Linux.

-- 
Jason Brittain

  reply	other threads:[~2004-11-12 18:24 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-12 14:27 [Qemu-devel] enabling bus-master IDE driver Juergen Keil
2004-11-12 18:02 ` Jason Brittain [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-11-26 10:48 Juergen Keil
2004-11-28 20:09 ` Juergen Lock
2004-11-12 19:07 Juergen Keil
2004-11-16 19:41 ` Juergen Lock
2004-11-23  5:12   ` Norikatsu Shigemura
2004-11-25 21:12     ` Juergen Lock
2004-11-05 15:37 Juergen Keil
2004-11-05 15:43 ` zitu
2004-11-05 15:45 ` zitu
2004-11-05 15:52   ` Jens Axboe
2004-11-05 16:10     ` zitu
2004-11-05 17:30       ` Damien Mascord
2004-11-04 20:35 Simon Frew
2004-11-05 13:32 ` zitu
2004-11-05 15:02   ` zitu
2004-11-06  1:53     ` Jason Brittain
2004-11-06 14:27       ` Johannes Schindelin
2004-11-06 21:52         ` Jason Brittain
2004-11-07  9:03           ` Jens Axboe
2004-11-07  9:21             ` Jens Axboe
2004-11-07  9:38               ` Jens Axboe
2004-11-07 11:01                 ` Hetz Ben Hamo
2004-11-07 11:16                   ` Jens Axboe
2004-11-08 10:15                     ` zitu
2004-11-08 16:51                       ` Andreas Bollhalder
2004-11-09  7:38                     ` Paul Jakma
2004-11-09 10:28                       ` Hetz Ben Hamo
2004-11-09 13:53                         ` Paul Jakma
2004-11-11 17:29                     ` Jason Brittain
2004-11-11 19:06                       ` Jens Axboe
2004-11-11 19:02                         ` Jason Brittain
2004-11-11 19:16                           ` Jens Axboe
2004-11-12  8:42                             ` Jens Axboe
2004-11-07 11:02             ` James Boddington
2004-11-10  1:41             ` James Boddington
2004-11-06 21:57         ` James Boddington
2004-11-06 22:11           ` James Boddington
2004-11-06 23:46             ` zitu
2004-11-07  0:41               ` jeebs
2004-11-07  7:12               ` Jason Brittain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4194FAB0.6000103@brittainweb.org \
    --to=jason@brittainweb.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).