[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/20] vga: do not dynamically allocate chain4_alias
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 09/20] vga: do not dynamically allocate chain4_alias |
Date: |
Tue, 19 Aug 2014 12:42:52 +0200 |
Instead, add a boolean variable to indicate the presence of the region.
This avoids a repeated malloc/free (later we can also avoid the
add_child/unparent by changing the offset/size of the alias).
Reviewed-by: Peter Crosthwaite <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/display/vga.c | 24 ++++++++++--------------
hw/display/vga_int.h | 3 ++-
2 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/hw/display/vga.c b/hw/display/vga.c
index 4b089a3..68cfee2 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -168,15 +168,18 @@ static uint8_t expand4to8[16];
static void vga_update_memory_access(VGACommonState *s)
{
- MemoryRegion *region, *old_region = s->chain4_alias;
hwaddr base, offset, size;
if (s->legacy_address_space == NULL) {
return;
}
- s->chain4_alias = NULL;
-
+ if (s->has_chain4_alias) {
+ memory_region_del_subregion(s->legacy_address_space, &s->chain4_alias);
+ memory_region_destroy(&s->chain4_alias);
+ s->has_chain4_alias = false;
+ s->plane_updated = 0xf;
+ }
if ((s->sr[VGA_SEQ_PLANE_WRITE] & VGA_SR02_ALL_PLANES) ==
VGA_SR02_ALL_PLANES && s->sr[VGA_SEQ_MEMORY_MODE] & VGA_SR04_CHN_4M) {
offset = 0;
@@ -201,18 +204,11 @@ static void vga_update_memory_access(VGACommonState *s)
break;
}
base += isa_mem_base;
- region = g_malloc(sizeof(*region));
- memory_region_init_alias(region, memory_region_owner(&s->vram),
+ memory_region_init_alias(&s->chain4_alias,
memory_region_owner(&s->vram),
"vga.chain4", &s->vram, offset, size);
memory_region_add_subregion_overlap(s->legacy_address_space, base,
- region, 2);
- s->chain4_alias = region;
- }
- if (old_region) {
- memory_region_del_subregion(s->legacy_address_space, old_region);
- memory_region_destroy(old_region);
- g_free(old_region);
- s->plane_updated = 0xf;
+ &s->chain4_alias, 2);
+ s->has_chain4_alias = true;
}
}
@@ -1321,7 +1317,7 @@ static void vga_draw_text(VGACommonState *s, int
full_update)
s->font_offsets[1] = offset;
full_update = 1;
}
- if (s->plane_updated & (1 << 2) || s->chain4_alias) {
+ if (s->plane_updated & (1 << 2) || s->has_chain4_alias) {
/* if the plane 2 was modified since the last display, it
indicates the font may have been modified */
s->plane_updated = 0;
diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
index 5320abd..641f8f4 100644
--- a/hw/display/vga_int.h
+++ b/hw/display/vga_int.h
@@ -94,7 +94,8 @@ typedef struct VGACommonState {
uint32_t vram_size;
uint32_t vram_size_mb; /* property */
uint32_t latch;
- MemoryRegion *chain4_alias;
+ bool has_chain4_alias;
+ MemoryRegion chain4_alias;
uint8_t sr_index;
uint8_t sr[256];
uint8_t gr_index;
--
1.8.3.1
- [Qemu-devel] [PULL 00/20] SCSI and memory changes for 2014-08-18, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 01/20] scsi-bus: prepare scsi_req_new for introduction of parse_cdb, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 02/20] scsi-bus: introduce parse_cdb in SCSIDeviceClass and SCSIBusInfo, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 03/20] scsi-block: extract scsi_block_is_passthrough, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 04/20] scsi-block, scsi-generic: implement parse_cdb, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 05/20] virtio-scsi: implement parse_cdb, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 06/20] qom: object: delete properties before calling instance_finalize, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 07/20] qom: object: move unparenting to the child property's release callback, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 08/20] sysbus: remove unused function sysbus_del_io, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 09/20] vga: do not dynamically allocate chain4_alias,
Paolo Bonzini <=
- [Qemu-devel] [PULL 10/20] nic: do not destroy memory regions in cleanup functions, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 11/20] ioport: split deletion and destruction, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 12/20] memory: convert memory_region_destroy to object_unparent, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 13/20] memory: remove memory_region_destroy, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 14/20] tpm_tis: remove instance_finalize callback, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 15/20] loader: Abstract away ref to memory region names, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 16/20] exec: Abstract away ref to memory region names, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 17/20] memory: constify memory_region_name, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 18/20] memory: Use memory_region_name for name access, Paolo Bonzini, 2014/08/19
- [Qemu-devel] [PULL 19/20] memory: Use canonical path component as the name, Paolo Bonzini, 2014/08/19