]> Git Repo - qemu.git/commitdiff
v3: don't call reset functions on cpu initialization
authorGlauber Costa <[email protected]>
Thu, 5 Nov 2009 18:05:15 +0000 (16:05 -0200)
committerBlue Swirl <[email protected]>
Sat, 7 Nov 2009 08:06:58 +0000 (08:06 +0000)
There is absolutely no need to call reset functions when initializing
devices. Since we are already registering them, calling qemu_system_reset()
should suffice. Actually, it is what happens when we reboot the machine,
and using the same process instead of a special case semantics will even
allow us to find bugs easier.

Furthermore, the fact that we initialize things like the cpu quite early,
leads to the need to introduce synchronization stuff like qemu_system_cond.
This patch removes it entirely. All we need to do is call qemu_system_reset()
only when we're already sure the system is up and running

I tested it with qemu (with and without io-thread) and qemu-kvm, and it
seems to be doing okay - although qemu-kvm uses a slightly different patch.

[ v2: user mode still needs cpu_reset, so put it in ifdef. ]
[ v3: leave qemu_system_cond for now. ]

Signed-off-by: Glauber Costa <[email protected]>
Signed-off-by: Blue Swirl <[email protected]>
14 files changed:
hw/apic.c
hw/e1000.c
hw/hpet.c
hw/i8254.c
hw/ide/piix.c
hw/piix4.c
hw/piix_pci.c
hw/rtl8139.c
hw/serial.c
hw/usb-ohci.c
hw/usb-uhci.c
hw/vga.c
target-i386/helper.c
vl.c

index c89008ea851b5d7caef87428d8f9c454d6ecdf6b..87e7dc0ba9e4a5d1ee11faa462ffebafd7f2bfe9 100644 (file)
--- a/hw/apic.c
+++ b/hw/apic.c
@@ -981,7 +981,6 @@ int apic_init(CPUState *env)
     s->id = env->cpuid_apic_id;
     s->cpu_env = env;
 
-    apic_reset(s);
     msix_supported = 1;
 
     /* XXX: mapping more APICs at the same memory location */
index 028afd1504f95b8825c993bed6411d2436d8c12b..8fb299d225e84da977e7c09284e14e19ac32a45f 100644 (file)
@@ -1113,7 +1113,6 @@ static int pci_e1000_init(PCIDevice *pci_dev)
     qemu_format_nic_info_str(d->vc, macaddr);
 
     vmstate_register(-1, &vmstate_e1000, d);
-    e1000_reset(d);
 
     if (!pci_dev->qdev.hotplugged) {
         static int loaded = 0;
index 64163bd52437f9b826994ba645e3d76ff13d4e59..6f397110c0bc6a9d05f4269bf833e9a00f043bc1 100644 (file)
--- a/hw/hpet.c
+++ b/hw/hpet.c
@@ -577,7 +577,6 @@ void hpet_init(qemu_irq *irq) {
         HPETTimer *timer = &s->timer[i];
         timer->qemu_timer = qemu_new_timer(vm_clock, hpet_timer, timer);
     }
-    hpet_reset(s);
     vmstate_register(-1, &vmstate_hpet, s);
     qemu_register_reset(hpet_reset, s);
     /* HPET Area */
index 5c49e6e0ae9fc9540e65ecd8d252c5c2e5cd4a09..faaa884d9d8c9f8ef39140061dd8039c8ec655c9 100644 (file)
@@ -513,7 +513,5 @@ PITState *pit_init(int base, qemu_irq irq)
     register_ioport_write(base, 4, 1, pit_ioport_write, pit);
     register_ioport_read(base, 3, 1, pit_ioport_read, pit);
 
-    pit_reset(pit);
-
     return pit;
 }
index a17bf5951c701100814fb81c63f4980d2041ad70..60b37a36a5bdf99ee361baed5b7fd222d6addaa7 100644 (file)
@@ -120,7 +120,6 @@ static int pci_piix_ide_initfn(PCIIDEState *d)
     pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
 
     qemu_register_reset(piix3_reset, d);
-    piix3_reset(d);
 
     pci_register_bar(&d->dev, 4, 0x10, PCI_ADDRESS_SPACE_IO, bmdma_map);
 
index a6aea15e7802302a6cbea29d368a80680c7fb13a..f75951b3ea4779e0805536e9084b0678d3654960 100644 (file)
@@ -97,7 +97,6 @@ static int piix4_initfn(PCIDevice *d)
         PCI_HEADER_TYPE_NORMAL | PCI_HEADER_TYPE_MULTI_FUNCTION; // header_type = PCI_multifunction, generic
 
     piix4_dev = d;
-    piix4_reset(d);
     qemu_register_reset(piix4_reset, d);
     return 0;
 }
index ed036feb8def45ed89e4fd5e6637c25b8fca691f..20d834fcae75f82da1166d1235e1db2a8c91e606 100644 (file)
@@ -341,7 +341,6 @@ static int piix3_initfn(PCIDevice *dev)
     pci_conf[PCI_HEADER_TYPE] =
         PCI_HEADER_TYPE_NORMAL | PCI_HEADER_TYPE_MULTI_FUNCTION; // header_type = PCI_multifunction, generic
 
-    piix3_reset(d);
     qemu_register_reset(piix3_reset, d);
     return 0;
 }
index d26df4848004061356dd18f9f2d53380e662c1e8..27cc618e00b704408404a0cbe34538d3e564b884 100644 (file)
@@ -3331,7 +3331,7 @@ static int pci_rtl8139_init(PCIDevice *dev)
                            PCI_ADDRESS_SPACE_MEM, rtl8139_mmio_map);
 
     qemu_macaddr_default_if_unset(&s->conf.macaddr);
-    rtl8139_reset(&s->dev.qdev);
+
     s->vc = qemu_new_vlan_client(NET_CLIENT_TYPE_NIC,
                                  s->conf.vlan, s->conf.peer,
                                  dev->qdev.info->name, dev->qdev.id,
index 9353201c5d3f511cf57059674f180e31bbcf43a1..fa12dcc0752d5af8ec63d1384dde33218d178deb 100644 (file)
@@ -725,7 +725,6 @@ static void serial_init_core(SerialState *s)
     s->transmit_timer = qemu_new_timer(vm_clock, (QEMUTimerCB *) serial_xmit, s);
 
     qemu_register_reset(serial_reset, s);
-    serial_reset(s);
 
     qemu_chr_add_handlers(s->chr, serial_can_receive1, serial_receive1,
                           serial_event, s);
index 48ccd49334f9c83ad51fb081814afd77395661cb..f71d6b8d1b174fe94ddb1f8c3bf824ddbf8b4f83 100644 (file)
@@ -1698,7 +1698,6 @@ static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,
 
     ohci->async_td = 0;
     qemu_register_reset(ohci_reset, ohci);
-    ohci_reset(ohci);
 }
 
 typedef struct {
index 67a9a233c6062eb36166768a581292e56343ba58..1580a50a3f3f16034951e87b9b23392cb9017f87 100644 (file)
@@ -1079,7 +1079,6 @@ static int usb_uhci_common_initfn(UHCIState *s)
     s->num_ports_vmstate = NB_PORTS;
 
     qemu_register_reset(uhci_reset, s);
-    uhci_reset(s);
 
     /* Use region 4 for consistency with real hardware.  BSD guests seem
        to rely on this.  */
index 899e66bdd1c8abfe4bd9d62a11b9f2db3cbfdbe5..2cde362cf1154d4176afb317c72518ea726da342 100644 (file)
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -2241,7 +2241,6 @@ void vga_common_init(VGACommonState *s, int vga_ram_size)
         s->update_retrace_info = vga_precise_update_retrace_info;
         break;
     }
-    vga_reset(s);
 }
 
 /* used by both ISA and PCI */
index c9615444e3df065d7b0d5ec38f1032da84686794..3fff1bbed1c1dbcc60fd41ec37bf91c7366b2008 100644 (file)
@@ -1885,7 +1885,9 @@ CPUX86State *cpu_x86_init(const char *cpu_model)
         return NULL;
     }
     mce_init(env);
+#ifdef CONFIG_USER_ONLY
     cpu_reset(env);
+#endif
 
     qemu_init_vcpu(env);
 
diff --git a/vl.c b/vl.c
index e57f58fea0df3ab4ade42fce4cf86d9d2a60a1e2..9031911c513eb2fc15564ec3cd37e8b274c65cc8 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -4034,6 +4034,7 @@ static void main_loop(void)
     qemu_system_ready = 1;
     qemu_cond_broadcast(&qemu_system_cond);
 #endif
+    qemu_system_reset();
 
     for (;;) {
         do {
This page took 0.045366 seconds and 4 git commands to generate.