From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dor Laor Subject: [Patch][Fix win2k install] Add delay between dma issue & result. Date: Wed, 07 Nov 2007 18:48:33 +0200 Message-ID: <4731EC61.3050008@qumranet.com> Reply-To: dor.laor-atKUWr5tajBWk0Htik3J/w@public.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: qemu-devel-qX2TKyscuCcdnm+yROfE0A@public.gmane.org, kvm-devel Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org 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 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/ From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ipo59-0001ic-Ev for qemu-devel@nongnu.org; Wed, 07 Nov 2007 11:48:47 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ipo53-0001fs-VW for qemu-devel@nongnu.org; Wed, 07 Nov 2007 11:48:45 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ipo53-0001fg-Mw for qemu-devel@nongnu.org; Wed, 07 Nov 2007 11:48:41 -0500 Received: from nf-out-0910.google.com ([64.233.182.189]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ipo50-0001sp-NS for qemu-devel@nongnu.org; Wed, 07 Nov 2007 11:48:39 -0500 Received: by nf-out-0910.google.com with SMTP id 30so2025693nfu for ; Wed, 07 Nov 2007 08:48:35 -0800 (PST) Message-ID: <4731EC61.3050008@qumranet.com> Date: Wed, 07 Nov 2007 18:48:33 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit From: Dor Laor Subject: [Qemu-devel] [Patch][Fix win2k install] Add delay between dma issue & result. Reply-To: dor.laor@qumranet.com, qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, kvm-devel 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 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); } }