* [Qemu-devel] [PATCH 3/5] cirrus: avoid resetting vga dirty logging unnecessarily
2009-01-19 8:15 [Qemu-devel] [PATCH 0/5] cirrus fixes, improvements and cleanups Jan Kiszka
@ 2009-01-19 8:15 ` Jan Kiszka
2009-01-19 8:15 ` [Qemu-devel] [PATCH 1/5] cirrus: unmap vram on reset Jan Kiszka
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Jan Kiszka @ 2009-01-19 8:15 UTC (permalink / raw)
To: qemu-devel; +Cc: Avi Kivity
From: Avi Kivity <avi@redhat.com>
cirrus bitblt reset will stop and start dirty logging even when there is no
need; this causes full redraws.
avoid by only updating memory access when exiting cpu-to-video update mode.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
hw/cirrus_vga.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 706c4c3..fc7c9ca 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -850,11 +850,17 @@ static void cirrus_bitblt_cputovideo_next(CirrusVGAState * s)
static void cirrus_bitblt_reset(CirrusVGAState * s)
{
+ int need_update;
+
s->gr[0x31] &=
~(CIRRUS_BLT_START | CIRRUS_BLT_BUSY | CIRRUS_BLT_FIFOUSED);
+ need_update = s->cirrus_srcptr != &s->cirrus_bltbuf[0]
+ || s->cirrus_srcptr_end != &s->cirrus_bltbuf[0];
s->cirrus_srcptr = &s->cirrus_bltbuf[0];
s->cirrus_srcptr_end = &s->cirrus_bltbuf[0];
s->cirrus_srccounter = 0;
+ if (!need_update)
+ return;
cirrus_update_memory_access(s);
}
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 1/5] cirrus: unmap vram on reset
2009-01-19 8:15 [Qemu-devel] [PATCH 0/5] cirrus fixes, improvements and cleanups Jan Kiszka
2009-01-19 8:15 ` [Qemu-devel] [PATCH 3/5] cirrus: avoid resetting vga dirty logging unnecessarily Jan Kiszka
@ 2009-01-19 8:15 ` Jan Kiszka
2009-01-19 8:15 ` [Qemu-devel] [PATCH 2/5] cirrus: stop dirty logging during remaps Jan Kiszka
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Jan Kiszka @ 2009-01-19 8:15 UTC (permalink / raw)
To: qemu-devel; +Cc: Avi Kivity
Fix the broken text mode after reset by unmapping potentially mapped
vram.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
hw/cirrus_vga.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index ef939ae..f7b01c3 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -3169,6 +3169,7 @@ static void cirrus_reset(void *opaque)
CirrusVGAState *s = opaque;
vga_reset(s);
+ unmap_linear_vram(s);
s->sr[0x06] = 0x0f;
if (s->device_id == CIRRUS_ID_CLGD5446) {
/* 4MB 64 bit memory config, always PCI */
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 2/5] cirrus: stop dirty logging during remaps
2009-01-19 8:15 [Qemu-devel] [PATCH 0/5] cirrus fixes, improvements and cleanups Jan Kiszka
2009-01-19 8:15 ` [Qemu-devel] [PATCH 3/5] cirrus: avoid resetting vga dirty logging unnecessarily Jan Kiszka
2009-01-19 8:15 ` [Qemu-devel] [PATCH 1/5] cirrus: unmap vram on reset Jan Kiszka
@ 2009-01-19 8:15 ` Jan Kiszka
2009-01-19 8:15 ` [Qemu-devel] [PATCH 5/5] cirrus: unify unmapping of vram Jan Kiszka
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Jan Kiszka @ 2009-01-19 8:15 UTC (permalink / raw)
To: qemu-devel; +Cc: Avi Kivity
Cleaned-up port from kvm-userspace: We have to stop any vram logging
while doing remaps. Otherwise the logger gets confused. This reward is
enormously accelerated cirrus vga in kvm mode.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
hw/cirrus_vga.c | 34 ++++++++++++++++++++++++++++------
1 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index f7b01c3..706c4c3 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -2620,12 +2620,12 @@ static CPUWriteMemoryFunc *cirrus_linear_bitblt_write[3] = {
static void map_linear_vram(CirrusVGAState *s)
{
+ vga_dirty_log_stop((VGAState *)s);
if (!s->map_addr && s->lfb_addr && s->lfb_end) {
s->map_addr = s->lfb_addr;
s->map_end = s->lfb_end;
cpu_register_physical_memory(s->map_addr, s->map_end - s->map_addr, s->vram_offset);
- vga_dirty_log_start((VGAState *)s);
}
if (!s->map_addr)
@@ -2644,24 +2644,26 @@ static void map_linear_vram(CirrusVGAState *s)
(s->vram_offset + s->cirrus_bank_base[1]) | IO_MEM_RAM);
s->lfb_vram_mapped = 1;
- vga_dirty_log_start((VGAState *)s);
}
else {
cpu_register_physical_memory(isa_mem_base + 0xa0000, 0x8000, s->vga_io_memory);
cpu_register_physical_memory(isa_mem_base + 0xa8000, 0x8000, s->vga_io_memory);
}
+ vga_dirty_log_start((VGAState *)s);
}
static void unmap_linear_vram(CirrusVGAState *s)
{
- if (s->map_addr && s->lfb_addr && s->lfb_end) {
- vga_dirty_log_stop((VGAState *)s);
+ vga_dirty_log_stop((VGAState *)s);
+
+ if (s->map_addr && s->lfb_addr && s->lfb_end)
s->map_addr = s->map_end = 0;
- }
cpu_register_physical_memory(isa_mem_base + 0xa0000, 0x20000,
s->vga_io_memory);
+
+ vga_dirty_log_start((VGAState *)s);
}
/* Compute the memory access functions */
@@ -3317,6 +3319,8 @@ static void cirrus_pci_lfb_map(PCIDevice *d, int region_num,
{
CirrusVGAState *s = &((PCICirrusVGAState *)d)->cirrus_vga;
+ vga_dirty_log_stop((VGAState *)s);
+
/* XXX: add byte swapping apertures */
cpu_register_physical_memory(addr, s->vram_size,
s->cirrus_linear_io_addr);
@@ -3329,6 +3333,8 @@ static void cirrus_pci_lfb_map(PCIDevice *d, int region_num,
/* account for overflow */
if (s->lfb_end < addr + VGA_RAM_SIZE)
s->lfb_end = addr + VGA_RAM_SIZE;
+
+ vga_dirty_log_start((VGAState *)s);
}
static void cirrus_pci_mmio_map(PCIDevice *d, int region_num,
@@ -3340,6 +3346,22 @@ static void cirrus_pci_mmio_map(PCIDevice *d, int region_num,
s->cirrus_mmio_io_addr);
}
+static void pci_cirrus_write_config(PCIDevice *d,
+ uint32_t address, uint32_t val, int len)
+{
+ PCICirrusVGAState *pvs = container_of(d, PCICirrusVGAState, dev);
+ CirrusVGAState *s = &pvs->cirrus_vga;
+
+ vga_dirty_log_stop((VGAState *)s);
+
+ pci_default_write_config(d, address, val, len);
+ if (s->map_addr && pvs->dev.io_regions[0].addr == -1)
+ s->map_addr = 0;
+ cirrus_update_memory_access(s);
+
+ vga_dirty_log_start((VGAState *)s);
+}
+
void pci_cirrus_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
ram_addr_t vga_ram_offset, int vga_ram_size)
{
@@ -3353,7 +3375,7 @@ void pci_cirrus_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
/* setup PCI configuration registers */
d = (PCICirrusVGAState *)pci_register_device(bus, "Cirrus VGA",
sizeof(PCICirrusVGAState),
- -1, NULL, NULL);
+ -1, NULL, pci_cirrus_write_config);
pci_conf = d->dev.config;
pci_conf[0x00] = (uint8_t) (PCI_VENDOR_CIRRUS & 0xff);
pci_conf[0x01] = (uint8_t) (PCI_VENDOR_CIRRUS >> 8);
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 5/5] cirrus: unify unmapping of vram
2009-01-19 8:15 [Qemu-devel] [PATCH 0/5] cirrus fixes, improvements and cleanups Jan Kiszka
` (2 preceding siblings ...)
2009-01-19 8:15 ` [Qemu-devel] [PATCH 2/5] cirrus: stop dirty logging during remaps Jan Kiszka
@ 2009-01-19 8:15 ` Jan Kiszka
2009-01-19 8:15 ` [Qemu-devel] [PATCH 4/5] cirrus: cleanup reset handler Jan Kiszka
2009-01-21 18:32 ` [Qemu-devel] [PATCH 0/5] cirrus fixes, improvements and cleanups Anthony Liguori
5 siblings, 0 replies; 7+ messages in thread
From: Jan Kiszka @ 2009-01-19 8:15 UTC (permalink / raw)
To: qemu-devel; +Cc: Avi Kivity
Switc vram unmapping in map_linear_vram to the simpler pattern used by
unmap_linear_vram.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
hw/cirrus_vga.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 0ded898..8f93911 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -2652,8 +2652,8 @@ static void map_linear_vram(CirrusVGAState *s)
s->lfb_vram_mapped = 1;
}
else {
- cpu_register_physical_memory(isa_mem_base + 0xa0000, 0x8000, s->vga_io_memory);
- cpu_register_physical_memory(isa_mem_base + 0xa8000, 0x8000, s->vga_io_memory);
+ cpu_register_physical_memory(isa_mem_base + 0xa0000, 0x20000,
+ s->vga_io_memory);
}
vga_dirty_log_start((VGAState *)s);
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 4/5] cirrus: cleanup reset handler
2009-01-19 8:15 [Qemu-devel] [PATCH 0/5] cirrus fixes, improvements and cleanups Jan Kiszka
` (3 preceding siblings ...)
2009-01-19 8:15 ` [Qemu-devel] [PATCH 5/5] cirrus: unify unmapping of vram Jan Kiszka
@ 2009-01-19 8:15 ` Jan Kiszka
2009-01-21 18:32 ` [Qemu-devel] [PATCH 0/5] cirrus fixes, improvements and cleanups Anthony Liguori
5 siblings, 0 replies; 7+ messages in thread
From: Jan Kiszka @ 2009-01-19 8:15 UTC (permalink / raw)
To: qemu-devel; +Cc: Avi Kivity
We should not re-register the cirrus io-memory regions on each reset.
Moreover, this patch removes some dead code and pushes other static
field initializations from reset to init_common.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
hw/cirrus_vga.c | 61 ++++++++++++++++++++++++-------------------------------
1 files changed, 27 insertions(+), 34 deletions(-)
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index fc7c9ca..0ded898 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -3183,22 +3183,13 @@ static void cirrus_reset(void *opaque)
/* 4MB 64 bit memory config, always PCI */
s->sr[0x1F] = 0x2d; // MemClock
s->gr[0x18] = 0x0f; // fastest memory configuration
-#if 1
s->sr[0x0f] = 0x98;
s->sr[0x17] = 0x20;
s->sr[0x15] = 0x04; /* memory size, 3=2MB, 4=4MB */
- s->real_vram_size = 4096 * 1024;
-#else
- s->sr[0x0f] = 0x18;
- s->sr[0x17] = 0x20;
- s->sr[0x15] = 0x03; /* memory size, 3=2MB, 4=4MB */
- s->real_vram_size = 2048 * 1024;
-#endif
} else {
s->sr[0x1F] = 0x22; // MemClock
s->sr[0x0F] = CIRRUS_MEMSIZE_2M;
s->sr[0x17] = s->bustype;
- s->real_vram_size = 2048 * 1024;
s->sr[0x15] = 0x03; /* memory size, 3=2MB, 4=4MB */
}
s->cr[0x27] = s->device_id;
@@ -3209,31 +3200,6 @@ static void cirrus_reset(void *opaque)
s->cirrus_hidden_dac_lockindex = 5;
s->cirrus_hidden_dac_data = 0;
-
- /* I/O handler for LFB */
- s->cirrus_linear_io_addr =
- cpu_register_io_memory(0, cirrus_linear_read, cirrus_linear_write,
- s);
- s->cirrus_linear_write = cpu_get_io_memory_write(s->cirrus_linear_io_addr);
-
- /* I/O handler for LFB */
- s->cirrus_linear_bitblt_io_addr =
- cpu_register_io_memory(0, cirrus_linear_bitblt_read, cirrus_linear_bitblt_write,
- s);
-
- /* I/O handler for memory-mapped I/O */
- s->cirrus_mmio_io_addr =
- cpu_register_io_memory(0, cirrus_mmio_read, cirrus_mmio_write, s);
-
- /* XXX: s->vram_size must be a power of two */
- s->cirrus_addr_mask = s->real_vram_size - 1;
- s->linear_mmio_mask = s->real_vram_size - 256;
-
- s->get_bpp = cirrus_get_bpp;
- s->get_offsets = cirrus_get_offsets;
- s->get_resolution = cirrus_get_resolution;
- s->cursor_invalidate = cirrus_cursor_invalidate;
- s->cursor_draw_line = cirrus_cursor_draw_line;
}
static void cirrus_init_common(CirrusVGAState * s, int device_id, int is_pci)
@@ -3288,6 +3254,33 @@ static void cirrus_init_common(CirrusVGAState * s, int device_id, int is_pci)
s->vga_io_memory);
qemu_register_coalesced_mmio(isa_mem_base + 0x000a0000, 0x20000);
+ /* I/O handler for LFB */
+ s->cirrus_linear_io_addr =
+ cpu_register_io_memory(0, cirrus_linear_read, cirrus_linear_write, s);
+ s->cirrus_linear_write = cpu_get_io_memory_write(s->cirrus_linear_io_addr);
+
+ /* I/O handler for LFB */
+ s->cirrus_linear_bitblt_io_addr =
+ cpu_register_io_memory(0, cirrus_linear_bitblt_read,
+ cirrus_linear_bitblt_write, s);
+
+ /* I/O handler for memory-mapped I/O */
+ s->cirrus_mmio_io_addr =
+ cpu_register_io_memory(0, cirrus_mmio_read, cirrus_mmio_write, s);
+
+ s->real_vram_size =
+ (s->device_id == CIRRUS_ID_CLGD5446) ? 4096 * 1024 : 2048 * 1024;
+
+ /* XXX: s->vram_size must be a power of two */
+ s->cirrus_addr_mask = s->real_vram_size - 1;
+ s->linear_mmio_mask = s->real_vram_size - 256;
+
+ s->get_bpp = cirrus_get_bpp;
+ s->get_offsets = cirrus_get_offsets;
+ s->get_resolution = cirrus_get_resolution;
+ s->cursor_invalidate = cirrus_cursor_invalidate;
+ s->cursor_draw_line = cirrus_cursor_draw_line;
+
qemu_register_reset(cirrus_reset, s);
cirrus_reset(s);
register_savevm("cirrus_vga", 0, 2, cirrus_vga_save, cirrus_vga_load, s);
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH 0/5] cirrus fixes, improvements and cleanups
2009-01-19 8:15 [Qemu-devel] [PATCH 0/5] cirrus fixes, improvements and cleanups Jan Kiszka
` (4 preceding siblings ...)
2009-01-19 8:15 ` [Qemu-devel] [PATCH 4/5] cirrus: cleanup reset handler Jan Kiszka
@ 2009-01-21 18:32 ` Anthony Liguori
5 siblings, 0 replies; 7+ messages in thread
From: Anthony Liguori @ 2009-01-21 18:32 UTC (permalink / raw)
To: qemu-devel; +Cc: Avi Kivity
Jan Kiszka wrote:
> This series fixes the reset issue of the cirrus vga emulation I reported
> a few days ago (text mode broken after reset from graphic mode),
> improves the performance in kvm mode and cleans up some corners of the
> code I came along.
>
> Find the patches also at git://git.kiszka.org/qemu.git queue/cirrus
>
Applied all. Thanks.
Regards,
Anthony Liguori
> Jan
>
> --
> Siemens AG, Corporate Technology, CT SE 2
> Corporate Competence Center Embedded Linux
>
>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread