All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dor Laor <dor.laor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: qemu-devel-qX2TKyscuCcdnm+yROfE0A@public.gmane.org,
	kvm-devel
	<kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: [Patch][Fix win2k install] Add delay between dma issue & result.
Date: Wed, 07 Nov 2007 18:48:33 +0200	[thread overview]
Message-ID: <4731EC61.3050008@qumranet.com> (raw)

Fix win2k install] Add delay between dma issue & result.
    
    Using synchonous io leads the guest to unexplored places:
    If it issues a dma command, it goes to qemu and executed
    synchrnously and return with irq for data ready.
    This is not real world scenario and happens when not using asyncio.
    This fix adds a delay of 1msec once every 8 dma writes.
    
    Signed-off-by: Dor Laor <dor.laor-atKUWr5tajBWk0Htik3J/w@public.gmane.org>

btw: It also applies against qemu cvs head.

diff --git a/qemu/hw/ide.c b/qemu/hw/ide.c
index 329d053..da972c8 100644
--- a/qemu/hw/ide.c
+++ b/qemu/hw/ide.c
@@ -366,6 +366,8 @@ typedef struct IDEState {
     uint32_t mdata_size;
     uint8_t *mdata_storage;
     int media_changed;
+
+    QEMUTimer *dma_write_timer; /* only used for win2k instal hack */
 } IDEState;
 
 #define BM_STATUS_DMAING 0x01
@@ -862,9 +864,21 @@ static void ide_sector_read_dma(IDEState *s)
 static void ide_sector_write_timer_cb(void *opaque)
 {
     IDEState *s = opaque;
+
     ide_set_irq(s);
 }
 
+static void ide_write_dma_cb(void *opaque, int ret);
+static void ide_dma_write_timer_cb(void *opaque)
+{
+      IDEState *s = opaque;
+      
+      s->status = READY_STAT | SEEK_STAT | DRQ_STAT | BUSY_STAT;
+      s->io_buffer_index = 0;
+      s->io_buffer_size = 0;
+      ide_dma_start(s, ide_write_dma_cb);
+}
+
 static void ide_sector_write_aio_cb(void *opaque, int ret)
 {
     BMDMAState *bm = opaque;
@@ -975,10 +989,19 @@ static void ide_write_dma_cb(void *opaque, int ret)
 
 static void ide_sector_write_dma(IDEState *s)
 {
-    s->status = READY_STAT | SEEK_STAT | DRQ_STAT | BUSY_STAT;
-    s->io_buffer_index = 0;
-    s->io_buffer_size = 0;
-    ide_dma_start(s, ide_write_dma_cb);
+    #ifdef TARGET_I386
+        if (win2k_install_hack && ((++s->irq_count % 8) == 0)) {
+        /* It seems there is a bug in the Windows 2000 installer HDD
+           IDE driver which fills the disk with empty logs when the
+           IDE write IRQ comes too early. This hack tries to correct
+           that at the expense of slower write performances. Use this
+           option _only_ to install Windows 2000. You must disable it
+           for normal use. */
+           qemu_mod_timer(s->dma_write_timer,
+                          qemu_get_clock(vm_clock) + (ticks_per_sec / 
1000));
+        } else
+    #endif
+        ide_dma_write_timer_cb(s);
 }
 
 static void ide_atapi_cmd_ok(IDEState *s)
@@ -2497,6 +2520,8 @@ static void ide_init2(IDEState *ide_state,
         s->irq = irq;
         s->sector_write_timer = qemu_new_timer(vm_clock,
                                                
ide_sector_write_timer_cb, s);
+        s->dma_write_timer = qemu_new_timer(vm_clock,
+                                               ide_dma_write_timer_cb, s);
         ide_reset(s);
     }
 }


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

WARNING: multiple messages have this Message-ID (diff)
From: Dor Laor <dor.laor@gmail.com>
To: qemu-devel@nongnu.org, kvm-devel <kvm-devel@lists.sourceforge.net>
Subject: [Qemu-devel] [Patch][Fix win2k install] Add delay between dma issue & result.
Date: Wed, 07 Nov 2007 18:48:33 +0200	[thread overview]
Message-ID: <4731EC61.3050008@qumranet.com> (raw)

Fix win2k install] Add delay between dma issue & result.
    
    Using synchonous io leads the guest to unexplored places:
    If it issues a dma command, it goes to qemu and executed
    synchrnously and return with irq for data ready.
    This is not real world scenario and happens when not using asyncio.
    This fix adds a delay of 1msec once every 8 dma writes.
    
    Signed-off-by: Dor Laor <dor.laor@qumranet.com>

btw: It also applies against qemu cvs head.

diff --git a/qemu/hw/ide.c b/qemu/hw/ide.c
index 329d053..da972c8 100644
--- a/qemu/hw/ide.c
+++ b/qemu/hw/ide.c
@@ -366,6 +366,8 @@ typedef struct IDEState {
     uint32_t mdata_size;
     uint8_t *mdata_storage;
     int media_changed;
+
+    QEMUTimer *dma_write_timer; /* only used for win2k instal hack */
 } IDEState;
 
 #define BM_STATUS_DMAING 0x01
@@ -862,9 +864,21 @@ static void ide_sector_read_dma(IDEState *s)
 static void ide_sector_write_timer_cb(void *opaque)
 {
     IDEState *s = opaque;
+
     ide_set_irq(s);
 }
 
+static void ide_write_dma_cb(void *opaque, int ret);
+static void ide_dma_write_timer_cb(void *opaque)
+{
+      IDEState *s = opaque;
+      
+      s->status = READY_STAT | SEEK_STAT | DRQ_STAT | BUSY_STAT;
+      s->io_buffer_index = 0;
+      s->io_buffer_size = 0;
+      ide_dma_start(s, ide_write_dma_cb);
+}
+
 static void ide_sector_write_aio_cb(void *opaque, int ret)
 {
     BMDMAState *bm = opaque;
@@ -975,10 +989,19 @@ static void ide_write_dma_cb(void *opaque, int ret)
 
 static void ide_sector_write_dma(IDEState *s)
 {
-    s->status = READY_STAT | SEEK_STAT | DRQ_STAT | BUSY_STAT;
-    s->io_buffer_index = 0;
-    s->io_buffer_size = 0;
-    ide_dma_start(s, ide_write_dma_cb);
+    #ifdef TARGET_I386
+        if (win2k_install_hack && ((++s->irq_count % 8) == 0)) {
+        /* It seems there is a bug in the Windows 2000 installer HDD
+           IDE driver which fills the disk with empty logs when the
+           IDE write IRQ comes too early. This hack tries to correct
+           that at the expense of slower write performances. Use this
+           option _only_ to install Windows 2000. You must disable it
+           for normal use. */
+           qemu_mod_timer(s->dma_write_timer,
+                          qemu_get_clock(vm_clock) + (ticks_per_sec / 
1000));
+        } else
+    #endif
+        ide_dma_write_timer_cb(s);
 }
 
 static void ide_atapi_cmd_ok(IDEState *s)
@@ -2497,6 +2520,8 @@ static void ide_init2(IDEState *ide_state,
         s->irq = irq;
         s->sector_write_timer = qemu_new_timer(vm_clock,
                                                
ide_sector_write_timer_cb, s);
+        s->dma_write_timer = qemu_new_timer(vm_clock,
+                                               ide_dma_write_timer_cb, s);
         ide_reset(s);
     }
 }

             reply	other threads:[~2007-11-07 16:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-07 16:48 Dor Laor [this message]
2007-11-07 16:48 ` [Qemu-devel] [Patch][Fix win2k install] Add delay between dma issue & result Dor Laor

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=4731EC61.3050008@qumranet.com \
    --to=dor.laor-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=dor.laor-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=qemu-devel-qX2TKyscuCcdnm+yROfE0A@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.