* [PATCH][QEMU] Clear bios framebuffer with minimal writes
@ 2007-10-24 21:04 Ben Guthro
2007-10-25 14:20 ` Keir Fraser
0 siblings, 1 reply; 6+ messages in thread
From: Ben Guthro @ 2007-10-24 21:04 UTC (permalink / raw)
To: xen-devel; +Cc: Gary Grebus
[-- Attachment #1: Type: text/plain, Size: 169 bytes --]
Support for VGA bios to clear framebuffer with minimal writes.
Signed-off-by: Ben Guthro <bguthro@virtualron.com>
Signed-off-by: Gary Grebus <ggrebus@virtualiron.com>
[-- Attachment #2: qemu-vga-fb-clear.patch --]
[-- Type: text/x-patch, Size: 3584 bytes --]
diff -r abca07dac924 tools/firmware/hvmloader/Makefile
--- a/tools/firmware/hvmloader/Makefile Tue Aug 07 09:24:25 2007 -0400
+++ b/tools/firmware/hvmloader/Makefile Tue Aug 07 09:27:14 2007 -0400
@@ -51,10 +51,10 @@ acpi/acpi.a:
acpi/acpi.a:
$(MAKE) -C acpi
-roms.h: ../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest.bin ../vgabios/VGABIOS-lgpl-latest.cirrus.bin ../vmxassist/vmxassist.bin ../etherboot/eb-rtl8139.zrom.h
+roms.h: ../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest$(DEBUG_ROM).bin ../vgabios/VGABIOS-lgpl-latest.cirrus$(DEBUG_ROM).bin ../vmxassist/vmxassist.bin ../etherboot/eb-rtl8139.zrom.h
sh ./mkhex rombios ../rombios/BIOS-bochs-latest > roms.h
- sh ./mkhex vgabios_stdvga ../vgabios/VGABIOS-lgpl-latest.bin >> roms.h
- sh ./mkhex vgabios_cirrusvga ../vgabios/VGABIOS-lgpl-latest.cirrus.bin >> roms.h
+ sh ./mkhex vgabios_stdvga ../vgabios/VGABIOS-lgpl-latest$(DEBUG_ROM).bin >> roms.h
+ sh ./mkhex vgabios_cirrusvga ../vgabios/VGABIOS-lgpl-latest.cirrus$(DEBUG_ROM).bin >> roms.h
sh ./mkhex vmxassist ../vmxassist/vmxassist.bin >> roms.h
cat ../etherboot/eb-rtl8139.zrom.h >> roms.h
diff -r abca07dac924 tools/firmware/vgabios/clext.c
--- a/tools/firmware/vgabios/clext.c Tue Aug 07 09:24:25 2007 -0400
+++ b/tools/firmware/vgabios/clext.c Tue Aug 07 09:24:25 2007 -0400
@@ -1489,19 +1489,31 @@ cirrus_clear_vram_1:
mov dx, #0x3ce
out dx, ax
push ax
- mov cx, #0xa000
- mov es, cx
- xor di, di
+
+;; Windows Vista appears to be emulating this sequence as part of changing
+;; screen resolution, but it generates 4096 writes per iteration.
+;; Instead, use a magic register sequence to write the whole bank.
+;; to avoid
+;;mov cx, #0xa000
+;;mov es, cx
+;;xor di, di
+;;mov ax, si
+;;mov cx, #8192
+;;cld
+;;rep
+;; stosw
mov ax, si
- mov cx, #8192
- cld
- rep
- stosw
+ shl ax, #8
+ mov al, #0xfe
+ out dx, ax ;; Low byte of value to be written to the bank
+ mov ax, si
+ mov al, #0xff
+ out dx, ax ;; High byte and trigger the write
+
pop ax
inc ah
cmp ah, bl
jne cirrus_clear_vram_1
-
pop es
popa
ret
@@ -1628,6 +1640,6 @@ static void cirrus_debugmsg(DI, SI, BP,
Bit16u DI, SI, BP, SP, BX, DX, CX, AX, ES, DS, FLAGS;
{
if((GET_AH()!=0x0E)&&(GET_AH()!=0x02)&&(GET_AH()!=0x09)&&(AX!=0x4F05))
- printf("vgabios call ah%02x al%02x bx%04x cx%04x dx%04x\n",GET_AH(),GET_AL(),BX,CX,DX);
+ printf("cirrusbios call ah%02x al%02x bx%04x cx%04x dx%04x\n",GET_AH(),GET_AL(),BX,CX,DX);
}
#endif
diff -r abca07dac924 tools/ioemu/hw/cirrus_vga.c
--- a/tools/ioemu/hw/cirrus_vga.c Tue Aug 07 09:24:25 2007 -0400
+++ b/tools/ioemu/hw/cirrus_vga.c Tue Aug 07 09:24:25 2007 -0400
@@ -294,6 +294,7 @@ void *shared_vram;
static void cirrus_bitblt_reset(CirrusVGAState *s);
static void cirrus_update_memory_access(CirrusVGAState *s);
+static void cirrus_vga_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val);
/***************************************
*
@@ -1497,6 +1498,17 @@ cirrus_hook_write_gr(CirrusVGAState * s,
case 0x31: // BLT STATUS/START
cirrus_write_bitblt(s, reg_value);
break;
+
+ // Extension to allow BIOS to clear 16K VRAM bank in one operation
+ case 0xFE:
+ s->gr[reg_index] = reg_value; // Lower byte of value to be written
+ break;
+ case 0xFF: {
+ target_phys_addr_t addr;
+ for (addr = 0xa0000; addr < 0xa4000; addr+=2)
+ cirrus_vga_mem_writew(s, addr, (reg_value << 8) | s->gr[0xFE]);
+ }
+ break;
default:
#ifdef DEBUG_CIRRUS
printf("cirrus: outport gr_index %02x, gr_value %02x\n", reg_index,
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][QEMU] Clear bios framebuffer with minimal writes
2007-10-24 21:04 [PATCH][QEMU] Clear bios framebuffer with minimal writes Ben Guthro
@ 2007-10-25 14:20 ` Keir Fraser
2007-10-25 15:23 ` Gary Grebus
0 siblings, 1 reply; 6+ messages in thread
From: Keir Fraser @ 2007-10-25 14:20 UTC (permalink / raw)
To: Ben Guthro, xen-devel; +Cc: Gary Grebus
On 24/10/07 22:04, "Ben Guthro" <bguthro@virtualiron.com> wrote:
> Support for VGA bios to clear framebuffer with minimal writes.
>
> Signed-off-by: Ben Guthro <bguthro@virtualron.com>
> Signed-off-by: Gary Grebus <ggrebus@virtualiron.com>
Is this really just a workaround for the insane-sounding case of Vista
clearing the screen, as described in one of the comments? Do I understand
correctly, and it looks like Vista does 4096 writes for each iteration of
the rep stosw?
-- Keir
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][QEMU] Clear bios framebuffer with minimal writes
2007-10-25 14:20 ` Keir Fraser
@ 2007-10-25 15:23 ` Gary Grebus
2007-10-25 15:34 ` Keir Fraser
0 siblings, 1 reply; 6+ messages in thread
From: Gary Grebus @ 2007-10-25 15:23 UTC (permalink / raw)
To: Keir Fraser; +Cc: xen-devel, Ben Guthro
On Thu, 2007-10-25 at 15:20 +0100, Keir Fraser wrote:
> On 24/10/07 22:04, "Ben Guthro" <bguthro@virtualiron.com> wrote:
>
> > Support for VGA bios to clear framebuffer with minimal writes.
> >
> > Signed-off-by: Ben Guthro <bguthro@virtualron.com>
> > Signed-off-by: Gary Grebus <ggrebus@virtualiron.com>
>
> Is this really just a workaround for the insane-sounding case of Vista
> clearing the screen, as described in one of the comments? Do I understand
> correctly, and it looks like Vista does 4096 writes for each iteration of
> the rep stosw?
Yep. This happens when resizing the screen in Vista. It appears to do
this by executing the VGA BIOS code in some sort of emulation, and the
BIOS function to clear the screen (which uses a rep stosw) gets emulated
as 4096 separate writes.
This is so slow that occasionally some watchdog timer in Vista (that was
timing the BIOS emulation) would expire and cause a blue screen.
This fix was a bit of a hack. It might be possible to speed up VGA
writes enough to make this unnecessary, but that was more of a challenge
than I wanted at the time.
/gary
--
Gary Grebus
Virtual Iron Software, Inc.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][QEMU] Clear bios framebuffer with minimal writes
2007-10-25 15:23 ` Gary Grebus
@ 2007-10-25 15:34 ` Keir Fraser
2007-10-25 17:14 ` Gary Grebus
0 siblings, 1 reply; 6+ messages in thread
From: Keir Fraser @ 2007-10-25 15:34 UTC (permalink / raw)
To: Gary Grebus; +Cc: xen-devel, Ben Guthro
On 25/10/07 16:23, "Gary Grebus" <ggrebus@virtualiron.com> wrote:
>> Is this really just a workaround for the insane-sounding case of Vista
>> clearing the screen, as described in one of the comments? Do I understand
>> correctly, and it looks like Vista does 4096 writes for each iteration of
>> the rep stosw?
>
> Yep. This happens when resizing the screen in Vista. It appears to do
> this by executing the VGA BIOS code in some sort of emulation, and the
> BIOS function to clear the screen (which uses a rep stosw) gets emulated
> as 4096 separate writes.
>
> This is so slow that occasionally some watchdog timer in Vista (that was
> timing the BIOS emulation) would expire and cause a blue screen.
>
> This fix was a bit of a hack. It might be possible to speed up VGA
> writes enough to make this unnecessary, but that was more of a challenge
> than I wanted at the time.
Ugh, that is awkward. Did you do this hack before the stdvga
emulation-in-xen and buffered-io patch that you guys also sent out today? I
wonder whether that speeds up vga writes enough, or whether you needed this
hack despite the speedups that other patch achieved? Overall, I guess I'm
not against this patch even though it is a bit sleazy. :-) But obviously
it's even better if the problem goes away by other means...
-- Keir
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][QEMU] Clear bios framebuffer with minimal writes
2007-10-25 15:34 ` Keir Fraser
@ 2007-10-25 17:14 ` Gary Grebus
2007-10-30 17:52 ` Gary Grebus
0 siblings, 1 reply; 6+ messages in thread
From: Gary Grebus @ 2007-10-25 17:14 UTC (permalink / raw)
To: Keir Fraser; +Cc: xen-devel, Ben Guthro
On Thu, 2007-10-25 at 16:34 +0100, Keir Fraser wrote:
> Ugh, that is awkward. Did you do this hack before the stdvga
> emulation-in-xen and buffered-io patch that you guys also sent out today? I
> wonder whether that speeds up vga writes enough, or whether you needed this
> hack despite the speedups that other patch achieved? Overall, I guess I'm
> not against this patch even though it is a bit sleazy. :-) But obviously
> it's even better if the problem goes away by other means...
>
This patch predates the stdvga emulation-in-xen and buffered-io changes.
I'll try with only the later changes and see if they are sufficient.
/gary
--
Gary Grebus
Virtual Iron Software, Inc.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH][QEMU] Clear bios framebuffer with minimal writes
2007-10-25 17:14 ` Gary Grebus
@ 2007-10-30 17:52 ` Gary Grebus
0 siblings, 0 replies; 6+ messages in thread
From: Gary Grebus @ 2007-10-30 17:52 UTC (permalink / raw)
To: Keir Fraser; +Cc: xen-devel, Ben Guthro
On Thu, 2007-10-25 at 13:14 -0400, Gary Grebus wrote:
> On Thu, 2007-10-25 at 16:34 +0100, Keir Fraser wrote:
>
> > Ugh, that is awkward. Did you do this hack before the stdvga
> > emulation-in-xen and buffered-io patch that you guys also sent out today? I
> > wonder whether that speeds up vga writes enough, or whether you needed this
> > hack despite the speedups that other patch achieved? Overall, I guess I'm
> > not against this patch even though it is a bit sleazy. :-) But obviously
> > it's even better if the problem goes away by other means...
> >
>
> This patch predates the stdvga emulation-in-xen and buffered-io changes.
> I'll try with only the later changes and see if they are sufficient.
>
I tried with only the stdvga and buffered-io patch. Things got worse,
to the point that Vista no longer boots, encountering a BSOD due to a
timeout in Vista graphics driver.
Apparently the stdvga and buffered-io patch de-optimizes this particular
case, but we didn't notice due to the vgabios patch.
The vgabios patch fixes the intermittent "BSOD on screen resize" problem
either way. We won't know if it's really necessary until we can fix the
stdvga etc. patch which at the moment looks a little suspect.
/gary
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-10-30 17:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-24 21:04 [PATCH][QEMU] Clear bios framebuffer with minimal writes Ben Guthro
2007-10-25 14:20 ` Keir Fraser
2007-10-25 15:23 ` Gary Grebus
2007-10-25 15:34 ` Keir Fraser
2007-10-25 17:14 ` Gary Grebus
2007-10-30 17:52 ` Gary Grebus
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.