VGA: Flush coalesced MMIO on related MMIO/PIO accesses

In preparation of stopping to flush coalesced MMIO unconditionally on
vmexits, mark VGA MMIO and PIO regions as synchronous /wrt coalesced
MMIO and flush the buffer explicitly on PIO accesses that do not use
generic memory regions yet.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
This commit is contained in:
Jan Kiszka 2012-08-23 13:02:33 +02:00 committed by Marcelo Tosatti
parent bb880ded7a
commit bd8f2f5d70
5 changed files with 15 additions and 0 deletions

View File

@ -2441,6 +2441,8 @@ static uint32_t cirrus_vga_ioport_read(void *opaque, uint32_t addr)
VGACommonState *s = &c->vga; VGACommonState *s = &c->vga;
int val, index; int val, index;
qemu_flush_coalesced_mmio_buffer();
if (vga_ioport_invalid(s, addr)) { if (vga_ioport_invalid(s, addr)) {
val = 0xff; val = 0xff;
} else { } else {
@ -2534,6 +2536,8 @@ static void cirrus_vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
VGACommonState *s = &c->vga; VGACommonState *s = &c->vga;
int index; int index;
qemu_flush_coalesced_mmio_buffer();
/* check port range access depending on color/monochrome mode */ /* check port range access depending on color/monochrome mode */
if (vga_ioport_invalid(s, addr)) { if (vga_ioport_invalid(s, addr)) {
return; return;
@ -2854,6 +2858,7 @@ static void cirrus_init_common(CirrusVGAState * s, int device_id, int is_pci,
/* I/O handler for LFB */ /* I/O handler for LFB */
memory_region_init_io(&s->cirrus_linear_io, &cirrus_linear_io_ops, s, memory_region_init_io(&s->cirrus_linear_io, &cirrus_linear_io_ops, s,
"cirrus-linear-io", VGA_RAM_SIZE); "cirrus-linear-io", VGA_RAM_SIZE);
memory_region_set_flush_coalesced(&s->cirrus_linear_io);
/* I/O handler for LFB */ /* I/O handler for LFB */
memory_region_init_io(&s->cirrus_linear_bitblt_io, memory_region_init_io(&s->cirrus_linear_bitblt_io,
@ -2861,10 +2866,12 @@ static void cirrus_init_common(CirrusVGAState * s, int device_id, int is_pci,
s, s,
"cirrus-bitblt-mmio", "cirrus-bitblt-mmio",
0x400000); 0x400000);
memory_region_set_flush_coalesced(&s->cirrus_linear_bitblt_io);
/* I/O handler for memory-mapped I/O */ /* I/O handler for memory-mapped I/O */
memory_region_init_io(&s->cirrus_mmio_io, &cirrus_mmio_io_ops, s, memory_region_init_io(&s->cirrus_mmio_io, &cirrus_mmio_io_ops, s,
"cirrus-mmio", CIRRUS_PNPMMIO_SIZE); "cirrus-mmio", CIRRUS_PNPMMIO_SIZE);
memory_region_set_flush_coalesced(&s->cirrus_mmio_io);
s->real_vram_size = s->real_vram_size =
(s->device_id == CIRRUS_ID_CLGD5446) ? 4096 * 1024 : 2048 * 1024; (s->device_id == CIRRUS_ID_CLGD5446) ? 4096 * 1024 : 2048 * 1024;

View File

@ -1910,6 +1910,7 @@ static int qxl_init_common(PCIQXLDevice *qxl)
if (qxl->id == 0) { if (qxl->id == 0) {
vga_dirty_log_start(&qxl->vga); vga_dirty_log_start(&qxl->vga);
} }
memory_region_set_flush_coalesced(&qxl->io_bar);
pci_register_bar(&qxl->pci, QXL_IO_RANGE_INDEX, pci_register_bar(&qxl->pci, QXL_IO_RANGE_INDEX,

View File

@ -107,6 +107,7 @@ static void vga_mm_init(ISAVGAMMState *s, target_phys_addr_t vram_base,
s_ioport_ctrl = g_malloc(sizeof(*s_ioport_ctrl)); s_ioport_ctrl = g_malloc(sizeof(*s_ioport_ctrl));
memory_region_init_io(s_ioport_ctrl, &vga_mm_ctrl_ops, s, memory_region_init_io(s_ioport_ctrl, &vga_mm_ctrl_ops, s,
"vga-mm-ctrl", 0x100000); "vga-mm-ctrl", 0x100000);
memory_region_set_flush_coalesced(s_ioport_ctrl);
vga_io_memory = g_malloc(sizeof(*vga_io_memory)); vga_io_memory = g_malloc(sizeof(*vga_io_memory));
/* XXX: endianness? */ /* XXX: endianness? */

View File

@ -361,6 +361,8 @@ uint32_t vga_ioport_read(void *opaque, uint32_t addr)
VGACommonState *s = opaque; VGACommonState *s = opaque;
int val, index; int val, index;
qemu_flush_coalesced_mmio_buffer();
if (vga_ioport_invalid(s, addr)) { if (vga_ioport_invalid(s, addr)) {
val = 0xff; val = 0xff;
} else { } else {
@ -453,6 +455,8 @@ void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val)
VGACommonState *s = opaque; VGACommonState *s = opaque;
int index; int index;
qemu_flush_coalesced_mmio_buffer();
/* check port range access depending on color/monochrome mode */ /* check port range access depending on color/monochrome mode */
if (vga_ioport_invalid(s, addr)) { if (vga_ioport_invalid(s, addr)) {
return; return;
@ -2338,6 +2342,7 @@ MemoryRegion *vga_init_io(VGACommonState *s,
vga_mem = g_malloc(sizeof(*vga_mem)); vga_mem = g_malloc(sizeof(*vga_mem));
memory_region_init_io(vga_mem, &vga_mem_ops, s, memory_region_init_io(vga_mem, &vga_mem_ops, s,
"vga-lowmem", 0x20000); "vga-lowmem", 0x20000);
memory_region_set_flush_coalesced(vga_mem);
return vga_mem; return vga_mem;
} }

View File

@ -1186,6 +1186,7 @@ static int pci_vmsvga_initfn(PCIDevice *dev)
memory_region_init_io(&s->io_bar, &vmsvga_io_ops, &s->chip, memory_region_init_io(&s->io_bar, &vmsvga_io_ops, &s->chip,
"vmsvga-io", 0x10); "vmsvga-io", 0x10);
memory_region_set_flush_coalesced(&s->io_bar);
pci_register_bar(&s->card, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io_bar); pci_register_bar(&s->card, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io_bar);
vmsvga_init(&s->chip, pci_address_space(dev), vmsvga_init(&s->chip, pci_address_space(dev),