Skip to contentSkip to conversation

remove icc bus/bridge

PATCH Superseded Zhu Guihua 2 participants 11 messages Sep 2, 2015 – Sep 15, 2015

v11 of 12 Superseded Latest is v12 →

lore
Share & tools
lore

Zhu Guihua

author
#0 lore raw

v11 cover remove icc bus/bridge

ICC Bus was used for providing a hotpluggable bus for APIC and CPU, but now we use HotplugHandler to make hotplug. So ICC Bus is unnecessary.

This code has passed the new pc-cpu-test.
And I have tested with kvm along with kernel_irqchip=on/off, it works fine.

This patch series is based on the latest master and '[PATCH v3] i386: keep cpu_model field in MachineState uptodate'
https://lists.nongnu.org/archive/html/qemu-devel/2015-08/msg03375.html
which has been reviewed but not been merged.

v11:
-improve commit messages
-split per CPU AS change into a separate patch

v10:
-improve commit messages in patch 1 and 2
-make the check of cpu->cpu_as_root simplier

v9:
-use a callback to correct reset sequence for x86 -update apic mmio mapping

Chen Fan (2):
apic: move APIC's MMIO region mapping into APIC
cpu/apic: drop icc bus/bridge

Zhu Guihua (3):
apic: use per CPU AS to map APIC MMIO for TCG
x86: use new method to correct reset sequence
icc_bus: drop the unused files

 default-configs/i386-softmmu.mak   |   1 -
 default-configs/x86_64-softmmu.mak |   1 -
 hw/cpu/Makefile.objs               |   1 -
 hw/cpu/icc_bus.c                   | 118 -------------------------------------
 hw/i386/pc.c                       |  46 ++++++++-------
 hw/i386/pc_piix.c                  |   9 +--
 hw/i386/pc_q35.c                   |   9 +--
 hw/intc/apic_common.c              |  11 +---
 include/hw/cpu/icc_bus.h           |  82 --------------------------
 include/hw/i386/apic_internal.h    |   7 ++-
 include/hw/i386/pc.h               |   2 +-
 target-i386/cpu.c                  |  33 ++++++++---
 12 files changed, 58 insertions(+), 262 deletions(-)
 delete mode 100644 hw/cpu/icc_bus.c
 delete mode 100644 include/hw/cpu/icc_bus.h
Signature · 1 line
1.9.3
author
#1 lore raw

PATCH v11 1/5 apic: move APIC's MMIO region mapping into APIC

From: Chen Fan <[email protected]>

When ICC bus/bridge is removed, APIC MMIO will be left unmapped since it was mapped into system's address space indirectly by ICC bridge.
Fix it by moving mapping into APIC code, so it would be possible to remove ICC bus/bridge code later.

---
 hw/i386/pc.c          |  7 -------
 hw/intc/apic_common.c |  6 ------
 target-i386/cpu.c     | 15 +++++++++++++++
 3 files changed, 15 insertions(+), 13 deletions(-)
hw/i386/pc.c +0 -7
index b1c96a8..e15971c 100644
@@ -1157,13 +1157,6 @@ void pc_cpus_init(PCMachineState *pcms, DeviceState *icc_bridge)
         object_unref(OBJECT(cpu));
     }
 
-    /* map APIC MMIO area if CPU has APIC */
-    if (cpu && cpu->apic_state) {
-        /* XXX: what if the base changes? */
-        sysbus_mmio_map_overlap(SYS_BUS_DEVICE(icc_bridge), 0,
-                                APIC_DEFAULT_ADDRESS, 0x1000);
-    }
-
     /* tell smbios about cpuid version and features */
     smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]);
 }
hw/intc/apic_common.c +0 -6
index 0032b97..c0b32eb 100644
@@ -296,7 +296,6 @@ static void apic_common_realize(DeviceState *dev, Error **errp)
     APICCommonClass *info;
     static DeviceState *vapic;
     static int apic_no;
-    static bool mmio_registered;
 
     if (apic_no >= MAX_APICS) {
         error_setg(errp, "%s initialization failed.",
@@ -307,11 +306,6 @@ static void apic_common_realize(DeviceState *dev, Error **errp)
 
     info = APIC_COMMON_GET_CLASS(s);
     info->realize(dev, errp);
-    if (!mmio_registered) {
-        ICCBus *b = ICC_BUS(qdev_get_parent_bus(dev));
-        memory_region_add_subregion(b->apic_address_space, 0, &s->io_memory);
-        mmio_registered = true;
-    }
 
     /* Note: We need at least 1M to map the VAPIC option ROM */
     if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK &&
target-i386/cpu.c +15 -0
index cfb8aa7..66b6b0d 100644
@@ -2745,6 +2745,7 @@ static void x86_cpu_apic_create(X86CPU *cpu, Error **errp)
     /* TODO: convert to link<> */
     apic = APIC_COMMON(cpu->apic_state);
     apic->cpu = cpu;
+    apic->apicbase = APIC_DEFAULT_ADDRESS | MSR_IA32_APICBASE_ENABLE;
 }
 
 static void x86_cpu_apic_realize(X86CPU *cpu, Error **errp)
@@ -2789,8 +2790,10 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
     X86CPU *cpu = X86_CPU(dev);
     X86CPUClass *xcc = X86_CPU_GET_CLASS(dev);
     CPUX86State *env = &cpu->env;
+    APICCommonState *apic;
     Error *local_err = NULL;
     static bool ht_warned;
+    static bool apic_mmio_map_once;
 
     if (cpu->apic_id < 0) {
         error_setg(errp, "apic-id property was not initialized properly");
@@ -2877,6 +2880,18 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
     if (local_err != NULL) {
         goto out;
     }
+
+    /* Map APIC MMIO area */
+    apic = APIC_COMMON(cpu->apic_state);
+    if (!apic_mmio_map_once) {
+        memory_region_add_subregion_overlap(get_system_memory(),
+                                            apic->apicbase &
+                                            MSR_IA32_APICBASE_BASE,
+                                            &apic->io_memory,
+                                            0x1000);
+        apic_mmio_map_once = true;
+    }
+
     cpu_reset(cs);
 
     xcc->parent_realize(dev, &local_err);
Signature · 1 line
1.9.3
#2 lore raw

Re: [Qemu-devel] [PATCH v11 1/5] apic: move APIC's MMIO region mapping into APIC

Quoted 71 lines · On Wed, 2 Sep 2015 17:36:18 +0800 Zhu Guihua <[email protected]> wrote:

From: Chen Fan <[email protected]>

When ICC bus/bridge is removed, APIC MMIO will be left unmapped since it was mapped into system's address space indirectly by ICC bridge.
Fix it by moving mapping into APIC code, so it would be possible to remove ICC bus/bridge code later.

---
 hw/i386/pc.c          |  7 -------
 hw/intc/apic_common.c |  6 ------
 target-i386/cpu.c     | 15 +++++++++++++++
 3 files changed, 15 insertions(+), 13 deletions(-)
hw/i386/pc.c +0 -7
index b1c96a8..e15971c 100644
@@ -1157,13 +1157,6 @@ void pc_cpus_init(PCMachineState *pcms, DeviceState *icc_bridge)
         object_unref(OBJECT(cpu));
     }
 
-    /* map APIC MMIO area if CPU has APIC */
-    if (cpu && cpu->apic_state) {
-        /* XXX: what if the base changes? */
-        sysbus_mmio_map_overlap(SYS_BUS_DEVICE(icc_bridge), 0,
-                                APIC_DEFAULT_ADDRESS, 0x1000);
-    }
-
     /* tell smbios about cpuid version and features */
     smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]);
 }
hw/intc/apic_common.c +0 -6
index 0032b97..c0b32eb 100644
@@ -296,7 +296,6 @@ static void apic_common_realize(DeviceState *dev, Error **errp)
     APICCommonClass *info;
     static DeviceState *vapic;
     static int apic_no;
-    static bool mmio_registered;
 
     if (apic_no >= MAX_APICS) {
         error_setg(errp, "%s initialization failed.",
@@ -307,11 +306,6 @@ static void apic_common_realize(DeviceState *dev, Error **errp)
 
     info = APIC_COMMON_GET_CLASS(s);
     info->realize(dev, errp);
-    if (!mmio_registered) {
-        ICCBus *b = ICC_BUS(qdev_get_parent_bus(dev));
-        memory_region_add_subregion(b->apic_address_space, 0, &s->io_memory);
-        mmio_registered = true;
-    }
 
     /* Note: We need at least 1M to map the VAPIC option ROM */
     if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK &&
target-i386/cpu.c +1 -0
index cfb8aa7..66b6b0d 100644
@@ -2745,6 +2745,7 @@ static void x86_cpu_apic_create(X86CPU *cpu, Error **errp)
     /* TODO: convert to link<> */
     apic = APIC_COMMON(cpu->apic_state);
     apic->cpu = cpu;
+    apic->apicbase = APIC_DEFAULT_ADDRESS | MSR_IA32_APICBASE_ENABLE;
 }
 
 static void x86_cpu_apic_realize(X86CPU *cpu, Error **errp)

target-i386/cpu.c static void x86_cpu_realizefn(DeviceState *dev, Error **errp) · line 2794

Quoted 5 lines
target-i386/cpu.c +1 -0
@@ -2789,8 +2790,10 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
     X86CPU *cpu = X86_CPU(dev);
     X86CPUClass *xcc = X86_CPU_GET_CLASS(dev);
     CPUX86State *env = &cpu->env;
 
+    APICCommonState *apic;

this and below hunks break build for *-linux-user targets, suggest to move it to x86_cpu_apic_realize() which is empty for user-only and softmmu builds.

Quoted 25 lines
target-i386/cpu.c +1 -0
     Error *local_err = NULL;
     static bool ht_warned;
+    static bool apic_mmio_map_once;
 
     if (cpu->apic_id < 0) {
         error_setg(errp, "apic-id property was not initialized properly");
target-i386/cpu.c +12 -0
@@ -2877,6 +2880,18 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
     if (local_err != NULL) {
         goto out;
     }
+
+    /* Map APIC MMIO area */
+    apic = APIC_COMMON(cpu->apic_state);
+    if (!apic_mmio_map_once) {
+        memory_region_add_subregion_overlap(get_system_memory(),
+                                            apic->apicbase &
+                                            MSR_IA32_APICBASE_BASE,
+                                            &apic->io_memory,
+                                            0x1000);
+        apic_mmio_map_once = true;
+    }
+
     cpu_reset(cs);
 
     xcc->parent_realize(dev, &local_err);
author
#3 lore raw

PATCH v11 2/5 apic: use per CPU AS to map APIC MMIO for TCG

In reply to Zhu Guihua

TCG supports per CPU address space, and the emulation quality is a bit better with it.
So use per CPU address space to map APIC MMIO area. This allows the APIC base address of each cpu to be moved indepenedent of others.

---
 target-i386/cpu.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
target-i386/cpu.c +11 -2
index 66b6b0d..0a95162 100644
@@ -2881,9 +2881,18 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
         goto out;
     }
 
-    /* Map APIC MMIO area */
+    /* Map APIC MMIO area, use per-CPU address space if available (TCG
+     * supports it, KVM doesn't). This allows the APIC base address of
+     * each CPU to be moved independently.
+     */
     apic = APIC_COMMON(cpu->apic_state);
-    if (!apic_mmio_map_once) {
+    if (tcg_enabled()) {
+        memory_region_add_subregion_overlap(cpu->cpu_as_root,
+                                            apic->apicbase &
+                                            MSR_IA32_APICBASE_BASE,
+                                            &apic->io_memory,
+                                            0x1000);
+    } else if (!apic_mmio_map_once) {
         memory_region_add_subregion_overlap(get_system_memory(),
                                             apic->apicbase &
                                             MSR_IA32_APICBASE_BASE,
Signature · 1 line
1.9.3
author
#4 lore raw

PATCH v11 3/5 x86: use new method to correct reset sequence

In reply to Zhu Guihua

During reset some devices (such as hpet, rtc) might send IRQ to APIC which changes APIC's state from default one it's supposed to have at machine startup time.
Fix this by resetting APIC after devices have been reset to cancel any changes that qemu_devices_reset() might have done to its state.

---
 hw/i386/pc.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
hw/i386/pc.c +20 -0
index e15971c..4b4a7f3 100644
@@ -1928,6 +1928,25 @@ static void pc_machine_initfn(Object *obj)
                              NULL, &error_abort);
 }
 
+static void pc_machine_reset(void)
+{
+    CPUState *cs;
+    X86CPU *cpu;
+
+    qemu_devices_reset();
+
+    /* Reset APIC after devices have been reset to cancel
+     * any changes that qemu_devices_reset() might have done.
+     */
+    CPU_FOREACH(cs) {
+        cpu = X86_CPU(cs);
+
+        if (cpu->apic_state) {
+            device_reset(cpu->apic_state);
+        }
+    }
+}
+
 static unsigned pc_cpu_index_to_socket_id(unsigned cpu_index)
 {
     unsigned pkg_id, core_id, smt_id;
@@ -1948,6 +1967,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
     mc->default_boot_order = "cad";
     mc->hot_add_cpu = pc_hot_add_cpu;
     mc->max_cpus = 255;
+    mc->reset = pc_machine_reset;
     hc->plug = pc_machine_device_plug_cb;
     hc->unplug_request = pc_machine_device_unplug_request_cb;
     hc->unplug = pc_machine_device_unplug_cb;
Signature · 1 line
1.9.3
author
#5 lore raw

PATCH v11 4/5 cpu/apic: drop icc bus/bridge

In reply to Zhu Guihua

From: Chen Fan <[email protected]>

After CPU hotplug has been converted to BUS-less hot-plug infrastructure, the only function ICC bus performs is to propagate reset to LAPICs. However LAPIC could be reset by registering its reset handler after all device are initialized.
Do so and drop ~200LOC of not needed anymore ICCBus related code.

---
 hw/i386/pc.c                    | 19 ++++---------------
 hw/i386/pc_piix.c               |  9 +--------
 hw/i386/pc_q35.c                |  9 +--------
 hw/intc/apic_common.c           |  5 ++---
 include/hw/i386/apic_internal.h |  7 ++++---
 include/hw/i386/pc.h            |  2 +-
 target-i386/cpu.c               |  9 +--------
 7 files changed, 14 insertions(+), 46 deletions(-)
hw/i386/pc.c +4 -15
index 4b4a7f3..4c1d68a 100644
@@ -59,7 +59,6 @@
 #include "qemu/error-report.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/cpu_hotplug.h"
-#include "hw/cpu/icc_bus.h"
 #include "hw/boards.h"
 #include "hw/pci/pci_host.h"
 #include "acpi-build.h"
@@ -1052,23 +1051,16 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
 }
 
 static X86CPU *pc_new_cpu(const char *cpu_model, int64_t apic_id,
-                          DeviceState *icc_bridge, Error **errp)
+                          Error **errp)
 {
     X86CPU *cpu = NULL;
     Error *local_err = NULL;
 
-    if (icc_bridge == NULL) {
-        error_setg(&local_err, "Invalid icc-bridge value");
-        goto out;
-    }
-
     cpu = cpu_x86_create(cpu_model, &local_err);
     if (local_err != NULL) {
         goto out;
     }
 
-    qdev_set_parent_bus(DEVICE(cpu), qdev_get_child_bus(icc_bridge, "icc"));
-
     object_property_set_int(OBJECT(cpu), apic_id, "apic-id", &local_err);
     object_property_set_bool(OBJECT(cpu), true, "realized", &local_err);
 
@@ -1083,7 +1075,6 @@ out:
 
 void pc_hot_add_cpu(const int64_t id, Error **errp)
 {
-    DeviceState *icc_bridge;
     MachineState *machine = MACHINE(qdev_get_machine());
     X86CPU *cpu;
     int64_t apic_id = x86_cpu_apic_id_from_index(id);
@@ -1113,9 +1104,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
         return;
     }
 
-    icc_bridge = DEVICE(object_resolve_path_type("icc-bridge",
-                                                 TYPE_ICC_BRIDGE, NULL));
-    cpu = pc_new_cpu(machine->cpu_model, apic_id, icc_bridge, &local_err);
+    cpu = pc_new_cpu(machine->cpu_model, apic_id, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         return;
@@ -1123,7 +1112,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
     object_unref(OBJECT(cpu));
 }
 
-void pc_cpus_init(PCMachineState *pcms, DeviceState *icc_bridge)
+void pc_cpus_init(PCMachineState *pcms)
 {
     int i;
     X86CPU *cpu = NULL;
@@ -1149,7 +1138,7 @@ void pc_cpus_init(PCMachineState *pcms, DeviceState *icc_bridge)
 
     for (i = 0; i < smp_cpus; i++) {
         cpu = pc_new_cpu(machine->cpu_model, x86_cpu_apic_id_from_index(i),
-                         icc_bridge, &error);
+                         &error);
         if (error) {
             error_report_err(error);
             exit(1);
hw/i386/pc_piix.c +1 -8
index fd6130d..3a97826 100644
@@ -39,7 +39,6 @@
 #include "hw/kvm/clock.h"
 #include "sysemu/sysemu.h"
 #include "hw/sysbus.h"
-#include "hw/cpu/icc_bus.h"
 #include "sysemu/arch_init.h"
 #include "sysemu/block-backend.h"
 #include "hw/i2c/smbus.h"
@@ -96,7 +95,6 @@ static void pc_init1(MachineState *machine)
     MemoryRegion *ram_memory;
     MemoryRegion *pci_memory;
     MemoryRegion *rom_memory;
-    DeviceState *icc_bridge;
     PcGuestInfo *guest_info;
     ram_addr_t lowmem;
 
@@ -141,11 +139,7 @@ static void pc_init1(MachineState *machine)
         exit(1);
     }
 
-    icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
-    object_property_add_child(qdev_get_machine(), "icc-bridge",
-                              OBJECT(icc_bridge), NULL);
-
-    pc_cpus_init(pcms, icc_bridge);
+    pc_cpus_init(pcms);
 
     if (kvm_enabled() && kvmclock_enabled) {
         kvmclock_create();
@@ -223,7 +217,6 @@ static void pc_init1(MachineState *machine)
     if (pci_enabled) {
         ioapic_init_gsi(gsi_state, "i440fx");
     }
-    qdev_init_nofail(icc_bridge);
 
     pc_register_ferr_irq(gsi[13]);
 
hw/i386/pc_q35.c +1 -8
index 4f76535..414cbbb 100644
@@ -43,7 +43,6 @@
 #include "hw/ide/pci.h"
 #include "hw/ide/ahci.h"
 #include "hw/usb.h"
-#include "hw/cpu/icc_bus.h"
 #include "qemu/error-report.h"
 #include "migration/migration.h"
 
@@ -83,7 +82,6 @@ static void pc_q35_init(MachineState *machine)
     int i;
     ICH9LPCState *ich9_lpc;
     PCIDevice *ahci;
-    DeviceState *icc_bridge;
     PcGuestInfo *guest_info;
     ram_addr_t lowmem;
     DriveInfo *hd[MAX_SATA_PORTS];
@@ -132,11 +130,7 @@ static void pc_q35_init(MachineState *machine)
         exit(1);
     }
 
-    icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
-    object_property_add_child(qdev_get_machine(), "icc-bridge",
-                              OBJECT(icc_bridge), NULL);
-
-    pc_cpus_init(pcms, icc_bridge);
+    pc_cpus_init(pcms);
     pc_acpi_init("q35-acpi-dsdt.aml");
 
     kvmclock_create();
@@ -237,7 +231,6 @@ static void pc_q35_init(MachineState *machine)
     if (pci_enabled) {
         ioapic_init_gsi(gsi_state, "q35");
     }
-    qdev_init_nofail(icc_bridge);
 
     pc_register_ferr_irq(gsi[13]);
 
hw/intc/apic_common.c +2 -3
index c0b32eb..ad959c4 100644
@@ -419,13 +419,12 @@ static Property apic_properties_common[] = {
 
 static void apic_common_class_init(ObjectClass *klass, void *data)
 {
-    ICCDeviceClass *idc = ICC_DEVICE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->vmsd = &vmstate_apic_common;
     dc->reset = apic_reset_common;
     dc->props = apic_properties_common;
-    idc->realize = apic_common_realize;
+    dc->realize = apic_common_realize;
     /*
      * Reason: APIC and CPU need to be wired up by
      * x86_cpu_apic_create()
@@ -435,7 +434,7 @@ static void apic_common_class_init(ObjectClass *klass, void *data)
 
 static const TypeInfo apic_common_type = {
     .name = TYPE_APIC_COMMON,
-    .parent = TYPE_ICC_DEVICE,
+    .parent = TYPE_DEVICE,
     .instance_size = sizeof(APICCommonState),
     .class_size = sizeof(APICCommonClass),
     .class_init = apic_common_class_init,
include/hw/i386/apic_internal.h +4 -3
index 26632ac..905ada7 100644
@@ -22,7 +22,6 @@
 
 #include "cpu.h"
 #include "exec/memory.h"
-#include "hw/cpu/icc_bus.h"
 #include "qemu/timer.h"
 
 /* APIC Local Vector Table */
@@ -79,7 +78,7 @@ typedef struct APICCommonState APICCommonState;
 
 typedef struct APICCommonClass
 {
-    ICCDeviceClass parent_class;
+    DeviceClass parent_class;
 
     DeviceRealize realize;
     void (*set_base)(APICCommonState *s, uint64_t val);
@@ -94,7 +93,9 @@ typedef struct APICCommonClass
 } APICCommonClass;
 
 struct APICCommonState {
-    ICCDevice busdev;
+    /*< private >*/
+    DeviceState parent_obj;
+    /*< public >*/
 
     MemoryRegion io_memory;
     X86CPU *cpu;
include/hw/i386/pc.h +1 -1
index 3732ab5..8eef558 100644
@@ -161,7 +161,7 @@ bool pc_machine_is_smm_enabled(PCMachineState *pcms);
 void pc_register_ferr_irq(qemu_irq irq);
 void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
 
-void pc_cpus_init(PCMachineState *pcms, DeviceState *icc_bridge);
+void pc_cpus_init(PCMachineState *pcms);
 void pc_hot_add_cpu(const int64_t id, Error **errp);
 void pc_acpi_init(const char *default_dsdt);
 
target-i386/cpu.c +1 -8
index 0a95162..6686039 100644
@@ -43,7 +43,6 @@
 
 #include "sysemu/sysemu.h"
 #include "hw/qdev-properties.h"
-#include "hw/cpu/icc_bus.h"
 #ifndef CONFIG_USER_ONLY
 #include "exec/address-spaces.h"
 #include "hw/xen/xen.h"
@@ -2723,7 +2722,6 @@ static void mce_init(X86CPU *cpu)
 #ifndef CONFIG_USER_ONLY
 static void x86_cpu_apic_create(X86CPU *cpu, Error **errp)
 {
-    DeviceState *dev = DEVICE(cpu);
     APICCommonState *apic;
     const char *apic_type = "apic";
 
@@ -2733,11 +2731,7 @@ static void x86_cpu_apic_create(X86CPU *cpu, Error **errp)
         apic_type = "xen-apic";
     }
 
-    cpu->apic_state = qdev_try_create(qdev_get_parent_bus(dev), apic_type);
-    if (cpu->apic_state == NULL) {
-        error_setg(errp, "APIC device '%s' could not be created", apic_type);
-        return;
-    }
+    cpu->apic_state = DEVICE(object_new(apic_type));
 
     object_property_add_child(OBJECT(cpu), "apic",
                               OBJECT(cpu->apic_state), NULL);
@@ -3162,7 +3156,6 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
 
     xcc->parent_realize = dc->realize;
     dc->realize = x86_cpu_realizefn;
-    dc->bus_type = TYPE_ICC_BUS;
     dc->props = x86_cpu_properties;
 
     xcc->parent_reset = cc->reset;
Signature · 1 line
1.9.3
#6 lore raw

Re: [Qemu-devel] [PATCH v11 4/5] cpu/apic: drop icc bus/bridge

Quoted 7 lines · On Wed, 2 Sep 2015 17:36:21 +0800 Zhu Guihua <[email protected]> wrote:

From: Chen Fan <[email protected]>

After CPU hotplug has been converted to BUS-less hot-plug infrastructure, the only function ICC bus performs is to propagate reset to LAPICs. However LAPIC could be reset by registering its reset handler after all device are initialized.
Do so and drop ~200LOC of not needed anymore ICCBus related code.

this patch drops about 30LOCs only ...

PS:
Doesn't apply to current master, please rebase.

Quoted 283 lines
---
 hw/i386/pc.c                    | 19 ++++---------------
 hw/i386/pc_piix.c               |  9 +--------
 hw/i386/pc_q35.c                |  9 +--------
 hw/intc/apic_common.c           |  5 ++---
 include/hw/i386/apic_internal.h |  7 ++++---
 include/hw/i386/pc.h            |  2 +-
 target-i386/cpu.c               |  9 +--------
 7 files changed, 14 insertions(+), 46 deletions(-)
hw/i386/pc.c +4 -15
index 4b4a7f3..4c1d68a 100644
@@ -59,7 +59,6 @@
 #include "qemu/error-report.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/cpu_hotplug.h"
-#include "hw/cpu/icc_bus.h"
 #include "hw/boards.h"
 #include "hw/pci/pci_host.h"
 #include "acpi-build.h"
@@ -1052,23 +1051,16 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
 }
 
 static X86CPU *pc_new_cpu(const char *cpu_model, int64_t apic_id,
-                          DeviceState *icc_bridge, Error **errp)
+                          Error **errp)
 {
     X86CPU *cpu = NULL;
     Error *local_err = NULL;
 
-    if (icc_bridge == NULL) {
-        error_setg(&local_err, "Invalid icc-bridge value");
-        goto out;
-    }
-
     cpu = cpu_x86_create(cpu_model, &local_err);
     if (local_err != NULL) {
         goto out;
     }
 
-    qdev_set_parent_bus(DEVICE(cpu), qdev_get_child_bus(icc_bridge, "icc"));
-
     object_property_set_int(OBJECT(cpu), apic_id, "apic-id", &local_err);
     object_property_set_bool(OBJECT(cpu), true, "realized", &local_err);
 
@@ -1083,7 +1075,6 @@ out:
 
 void pc_hot_add_cpu(const int64_t id, Error **errp)
 {
-    DeviceState *icc_bridge;
     MachineState *machine = MACHINE(qdev_get_machine());
     X86CPU *cpu;
     int64_t apic_id = x86_cpu_apic_id_from_index(id);
@@ -1113,9 +1104,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
         return;
     }
 
-    icc_bridge = DEVICE(object_resolve_path_type("icc-bridge",
-                                                 TYPE_ICC_BRIDGE, NULL));
-    cpu = pc_new_cpu(machine->cpu_model, apic_id, icc_bridge, &local_err);
+    cpu = pc_new_cpu(machine->cpu_model, apic_id, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         return;
@@ -1123,7 +1112,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
     object_unref(OBJECT(cpu));
 }
 
-void pc_cpus_init(PCMachineState *pcms, DeviceState *icc_bridge)
+void pc_cpus_init(PCMachineState *pcms)
 {
     int i;
     X86CPU *cpu = NULL;
@@ -1149,7 +1138,7 @@ void pc_cpus_init(PCMachineState *pcms, DeviceState *icc_bridge)
 
     for (i = 0; i < smp_cpus; i++) {
         cpu = pc_new_cpu(machine->cpu_model, x86_cpu_apic_id_from_index(i),
-                         icc_bridge, &error);
+                         &error);
         if (error) {
             error_report_err(error);
             exit(1);
hw/i386/pc_piix.c +1 -8
index fd6130d..3a97826 100644
@@ -39,7 +39,6 @@
 #include "hw/kvm/clock.h"
 #include "sysemu/sysemu.h"
 #include "hw/sysbus.h"
-#include "hw/cpu/icc_bus.h"
 #include "sysemu/arch_init.h"
 #include "sysemu/block-backend.h"
 #include "hw/i2c/smbus.h"
@@ -96,7 +95,6 @@ static void pc_init1(MachineState *machine)
     MemoryRegion *ram_memory;
     MemoryRegion *pci_memory;
     MemoryRegion *rom_memory;
-    DeviceState *icc_bridge;
     PcGuestInfo *guest_info;
     ram_addr_t lowmem;
 
@@ -141,11 +139,7 @@ static void pc_init1(MachineState *machine)
         exit(1);
     }
 
-    icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
-    object_property_add_child(qdev_get_machine(), "icc-bridge",
-                              OBJECT(icc_bridge), NULL);
-
-    pc_cpus_init(pcms, icc_bridge);
+    pc_cpus_init(pcms);
 
     if (kvm_enabled() && kvmclock_enabled) {
         kvmclock_create();
@@ -223,7 +217,6 @@ static void pc_init1(MachineState *machine)
     if (pci_enabled) {
         ioapic_init_gsi(gsi_state, "i440fx");
     }
-    qdev_init_nofail(icc_bridge);
 
     pc_register_ferr_irq(gsi[13]);
 
hw/i386/pc_q35.c +1 -8
index 4f76535..414cbbb 100644
@@ -43,7 +43,6 @@
 #include "hw/ide/pci.h"
 #include "hw/ide/ahci.h"
 #include "hw/usb.h"
-#include "hw/cpu/icc_bus.h"
 #include "qemu/error-report.h"
 #include "migration/migration.h"
 
@@ -83,7 +82,6 @@ static void pc_q35_init(MachineState *machine)
     int i;
     ICH9LPCState *ich9_lpc;
     PCIDevice *ahci;
-    DeviceState *icc_bridge;
     PcGuestInfo *guest_info;
     ram_addr_t lowmem;
     DriveInfo *hd[MAX_SATA_PORTS];
@@ -132,11 +130,7 @@ static void pc_q35_init(MachineState *machine)
         exit(1);
     }
 
-    icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
-    object_property_add_child(qdev_get_machine(), "icc-bridge",
-                              OBJECT(icc_bridge), NULL);
-
-    pc_cpus_init(pcms, icc_bridge);
+    pc_cpus_init(pcms);
     pc_acpi_init("q35-acpi-dsdt.aml");
 
     kvmclock_create();
@@ -237,7 +231,6 @@ static void pc_q35_init(MachineState *machine)
     if (pci_enabled) {
         ioapic_init_gsi(gsi_state, "q35");
     }
-    qdev_init_nofail(icc_bridge);
 
     pc_register_ferr_irq(gsi[13]);
 
hw/intc/apic_common.c +2 -3
index c0b32eb..ad959c4 100644
@@ -419,13 +419,12 @@ static Property apic_properties_common[] = {
 
 static void apic_common_class_init(ObjectClass *klass, void *data)
 {
-    ICCDeviceClass *idc = ICC_DEVICE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->vmsd = &vmstate_apic_common;
     dc->reset = apic_reset_common;
     dc->props = apic_properties_common;
-    idc->realize = apic_common_realize;
+    dc->realize = apic_common_realize;
     /*
      * Reason: APIC and CPU need to be wired up by
      * x86_cpu_apic_create()
@@ -435,7 +434,7 @@ static void apic_common_class_init(ObjectClass *klass, void *data)
 
 static const TypeInfo apic_common_type = {
     .name = TYPE_APIC_COMMON,
-    .parent = TYPE_ICC_DEVICE,
+    .parent = TYPE_DEVICE,
     .instance_size = sizeof(APICCommonState),
     .class_size = sizeof(APICCommonClass),
     .class_init = apic_common_class_init,
include/hw/i386/apic_internal.h +4 -3
index 26632ac..905ada7 100644
@@ -22,7 +22,6 @@
 
 #include "cpu.h"
 #include "exec/memory.h"
-#include "hw/cpu/icc_bus.h"
 #include "qemu/timer.h"
 
 /* APIC Local Vector Table */
@@ -79,7 +78,7 @@ typedef struct APICCommonState APICCommonState;
 
 typedef struct APICCommonClass
 {
-    ICCDeviceClass parent_class;
+    DeviceClass parent_class;
 
     DeviceRealize realize;
     void (*set_base)(APICCommonState *s, uint64_t val);
@@ -94,7 +93,9 @@ typedef struct APICCommonClass
 } APICCommonClass;
 
 struct APICCommonState {
-    ICCDevice busdev;
+    /*< private >*/
+    DeviceState parent_obj;
+    /*< public >*/
 
     MemoryRegion io_memory;
     X86CPU *cpu;
include/hw/i386/pc.h +1 -1
index 3732ab5..8eef558 100644
@@ -161,7 +161,7 @@ bool pc_machine_is_smm_enabled(PCMachineState *pcms);
 void pc_register_ferr_irq(qemu_irq irq);
 void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
 
-void pc_cpus_init(PCMachineState *pcms, DeviceState *icc_bridge);
+void pc_cpus_init(PCMachineState *pcms);
 void pc_hot_add_cpu(const int64_t id, Error **errp);
 void pc_acpi_init(const char *default_dsdt);
 
target-i386/cpu.c +1 -8
index 0a95162..6686039 100644
@@ -43,7 +43,6 @@
 
 #include "sysemu/sysemu.h"
 #include "hw/qdev-properties.h"
-#include "hw/cpu/icc_bus.h"
 #ifndef CONFIG_USER_ONLY
 #include "exec/address-spaces.h"
 #include "hw/xen/xen.h"
@@ -2723,7 +2722,6 @@ static void mce_init(X86CPU *cpu)
 #ifndef CONFIG_USER_ONLY
 static void x86_cpu_apic_create(X86CPU *cpu, Error **errp)
 {
-    DeviceState *dev = DEVICE(cpu);
     APICCommonState *apic;
     const char *apic_type = "apic";
 
@@ -2733,11 +2731,7 @@ static void x86_cpu_apic_create(X86CPU *cpu, Error **errp)
         apic_type = "xen-apic";
     }
 
-    cpu->apic_state = qdev_try_create(qdev_get_parent_bus(dev), apic_type);
-    if (cpu->apic_state == NULL) {
-        error_setg(errp, "APIC device '%s' could not be created", apic_type);
-        return;
-    }
+    cpu->apic_state = DEVICE(object_new(apic_type));
 
     object_property_add_child(OBJECT(cpu), "apic",
                               OBJECT(cpu->apic_state), NULL);
@@ -3162,7 +3156,6 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
 
     xcc->parent_realize = dc->realize;
     dc->realize = x86_cpu_realizefn;
-    dc->bus_type = TYPE_ICC_BUS;
     dc->props = x86_cpu_properties;
 
     xcc->parent_reset = cc->reset;
author
#7 lore raw

Re: [Qemu-devel] [PATCH v11 4/5] cpu/apic: drop icc bus/bridge

Quoted 10 lines · Igor Mammedov
Quoted 7 lines · On Wed, 2 Sep 2015 17:36:21 +0800 Zhu Guihua <[email protected]> wrote:

From: Chen Fan <[email protected]>

After CPU hotplug has been converted to BUS-less hot-plug infrastructure, the only function ICC bus performs is to propagate reset to LAPICs. However LAPIC could be reset by registering its reset handler after all device are initialized.
Do so and drop ~200LOC of not needed anymore ICCBus related code.

Quoted 5 lines

this patch drops about 30LOCs only ...

PS:
Doesn't apply to current master, please rebase.

This patch rebased on my another patch
'[PATCH v3] i386: keep cpu_model field in MachineState uptodate'
https://lists.nongnu.org/archive/html/qemu-devel/2015-08/msg03375.html

The patch has been reviewed by Eduardo, but not been merged.

Should I only rebase on current master?

Thanks,
Zhu

Quoted 284 lines
Quoted 275 lines
---
  hw/i386/pc.c                    | 19 ++++---------------
  hw/i386/pc_piix.c               |  9 +--------
  hw/i386/pc_q35.c                |  9 +--------
  hw/intc/apic_common.c           |  5 ++---
  include/hw/i386/apic_internal.h |  7 ++++---
  include/hw/i386/pc.h            |  2 +-
  target-i386/cpu.c               |  9 +--------
  7 files changed, 14 insertions(+), 46 deletions(-)
hw/i386/pc.c +4 -15
index 4b4a7f3..4c1d68a 100644
@@ -59,7 +59,6 @@
  #include "qemu/error-report.h"
  #include "hw/acpi/acpi.h"
  #include "hw/acpi/cpu_hotplug.h"
-#include "hw/cpu/icc_bus.h"
  #include "hw/boards.h"
  #include "hw/pci/pci_host.h"
  #include "acpi-build.h"
@@ -1052,23 +1051,16 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
  }
 
  static X86CPU *pc_new_cpu(const char *cpu_model, int64_t apic_id,
-                          DeviceState *icc_bridge, Error **errp)
+                          Error **errp)
  {
      X86CPU *cpu = NULL;
      Error *local_err = NULL;
 
-    if (icc_bridge == NULL) {
-        error_setg(&local_err, "Invalid icc-bridge value");
-        goto out;
-    }
-
      cpu = cpu_x86_create(cpu_model, &local_err);
      if (local_err != NULL) {
          goto out;
      }
 
-    qdev_set_parent_bus(DEVICE(cpu), qdev_get_child_bus(icc_bridge, "icc"));
-
      object_property_set_int(OBJECT(cpu), apic_id, "apic-id", &local_err);
      object_property_set_bool(OBJECT(cpu), true, "realized", &local_err);
 
@@ -1083,7 +1075,6 @@ out:
 
  void pc_hot_add_cpu(const int64_t id, Error **errp)
  {
-    DeviceState *icc_bridge;
      MachineState *machine = MACHINE(qdev_get_machine());
      X86CPU *cpu;
      int64_t apic_id = x86_cpu_apic_id_from_index(id);
@@ -1113,9 +1104,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
          return;
      }
 
-    icc_bridge = DEVICE(object_resolve_path_type("icc-bridge",
-                                                 TYPE_ICC_BRIDGE, NULL));
-    cpu = pc_new_cpu(machine->cpu_model, apic_id, icc_bridge, &local_err);
+    cpu = pc_new_cpu(machine->cpu_model, apic_id, &local_err);
      if (local_err) {
          error_propagate(errp, local_err);
          return;
@@ -1123,7 +1112,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
      object_unref(OBJECT(cpu));
  }
 
-void pc_cpus_init(PCMachineState *pcms, DeviceState *icc_bridge)
+void pc_cpus_init(PCMachineState *pcms)
  {
      int i;
      X86CPU *cpu = NULL;
@@ -1149,7 +1138,7 @@ void pc_cpus_init(PCMachineState *pcms, DeviceState *icc_bridge)
 
      for (i = 0; i < smp_cpus; i++) {
          cpu = pc_new_cpu(machine->cpu_model, x86_cpu_apic_id_from_index(i),
-                         icc_bridge, &error);
+                         &error);
          if (error) {
              error_report_err(error);
              exit(1);
hw/i386/pc_piix.c +1 -8
index fd6130d..3a97826 100644
@@ -39,7 +39,6 @@
  #include "hw/kvm/clock.h"
  #include "sysemu/sysemu.h"
  #include "hw/sysbus.h"
-#include "hw/cpu/icc_bus.h"
  #include "sysemu/arch_init.h"
  #include "sysemu/block-backend.h"
  #include "hw/i2c/smbus.h"
@@ -96,7 +95,6 @@ static void pc_init1(MachineState *machine)
      MemoryRegion *ram_memory;
      MemoryRegion *pci_memory;
      MemoryRegion *rom_memory;
-    DeviceState *icc_bridge;
      PcGuestInfo *guest_info;
      ram_addr_t lowmem;
 
@@ -141,11 +139,7 @@ static void pc_init1(MachineState *machine)
          exit(1);
      }
 
-    icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
-    object_property_add_child(qdev_get_machine(), "icc-bridge",
-                              OBJECT(icc_bridge), NULL);
-
-    pc_cpus_init(pcms, icc_bridge);
+    pc_cpus_init(pcms);
 
      if (kvm_enabled() && kvmclock_enabled) {
          kvmclock_create();
@@ -223,7 +217,6 @@ static void pc_init1(MachineState *machine)
      if (pci_enabled) {
          ioapic_init_gsi(gsi_state, "i440fx");
      }
-    qdev_init_nofail(icc_bridge);
 
      pc_register_ferr_irq(gsi[13]);
 
hw/i386/pc_q35.c +1 -8
index 4f76535..414cbbb 100644
@@ -43,7 +43,6 @@
  #include "hw/ide/pci.h"
  #include "hw/ide/ahci.h"
  #include "hw/usb.h"
-#include "hw/cpu/icc_bus.h"
  #include "qemu/error-report.h"
  #include "migration/migration.h"
 
@@ -83,7 +82,6 @@ static void pc_q35_init(MachineState *machine)
      int i;
      ICH9LPCState *ich9_lpc;
      PCIDevice *ahci;
-    DeviceState *icc_bridge;
      PcGuestInfo *guest_info;
      ram_addr_t lowmem;
      DriveInfo *hd[MAX_SATA_PORTS];
@@ -132,11 +130,7 @@ static void pc_q35_init(MachineState *machine)
          exit(1);
      }
 
-    icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
-    object_property_add_child(qdev_get_machine(), "icc-bridge",
-                              OBJECT(icc_bridge), NULL);
-
-    pc_cpus_init(pcms, icc_bridge);
+    pc_cpus_init(pcms);
      pc_acpi_init("q35-acpi-dsdt.aml");
 
      kvmclock_create();
@@ -237,7 +231,6 @@ static void pc_q35_init(MachineState *machine)
      if (pci_enabled) {
          ioapic_init_gsi(gsi_state, "q35");
      }
-    qdev_init_nofail(icc_bridge);
 
      pc_register_ferr_irq(gsi[13]);
 
hw/intc/apic_common.c +2 -3
index c0b32eb..ad959c4 100644
@@ -419,13 +419,12 @@ static Property apic_properties_common[] = {
 
  static void apic_common_class_init(ObjectClass *klass, void *data)
  {
-    ICCDeviceClass *idc = ICC_DEVICE_CLASS(klass);
      DeviceClass *dc = DEVICE_CLASS(klass);
 
      dc->vmsd = &vmstate_apic_common;
      dc->reset = apic_reset_common;
      dc->props = apic_properties_common;
-    idc->realize = apic_common_realize;
+    dc->realize = apic_common_realize;
      /*
       * Reason: APIC and CPU need to be wired up by
       * x86_cpu_apic_create()
@@ -435,7 +434,7 @@ static void apic_common_class_init(ObjectClass *klass, void *data)
 
  static const TypeInfo apic_common_type = {
      .name = TYPE_APIC_COMMON,
-    .parent = TYPE_ICC_DEVICE,
+    .parent = TYPE_DEVICE,
      .instance_size = sizeof(APICCommonState),
      .class_size = sizeof(APICCommonClass),
      .class_init = apic_common_class_init,
include/hw/i386/apic_internal.h +4 -3
index 26632ac..905ada7 100644
@@ -22,7 +22,6 @@
 
  #include "cpu.h"
  #include "exec/memory.h"
-#include "hw/cpu/icc_bus.h"
  #include "qemu/timer.h"
 
  /* APIC Local Vector Table */
@@ -79,7 +78,7 @@ typedef struct APICCommonState APICCommonState;
 
  typedef struct APICCommonClass
  {
-    ICCDeviceClass parent_class;
+    DeviceClass parent_class;
 
      DeviceRealize realize;
      void (*set_base)(APICCommonState *s, uint64_t val);
@@ -94,7 +93,9 @@ typedef struct APICCommonClass
  } APICCommonClass;
 
  struct APICCommonState {
-    ICCDevice busdev;
+    /*< private >*/
+    DeviceState parent_obj;
+    /*< public >*/
 
      MemoryRegion io_memory;
      X86CPU *cpu;
include/hw/i386/pc.h +1 -1
index 3732ab5..8eef558 100644
@@ -161,7 +161,7 @@ bool pc_machine_is_smm_enabled(PCMachineState *pcms);
  void pc_register_ferr_irq(qemu_irq irq);
  void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
 
-void pc_cpus_init(PCMachineState *pcms, DeviceState *icc_bridge);
+void pc_cpus_init(PCMachineState *pcms);
  void pc_hot_add_cpu(const int64_t id, Error **errp);
  void pc_acpi_init(const char *default_dsdt);
 
target-i386/cpu.c +1 -7
index 0a95162..6686039 100644
@@ -43,7 +43,6 @@
 
  #include "sysemu/sysemu.h"
  #include "hw/qdev-properties.h"
-#include "hw/cpu/icc_bus.h"
  #ifndef CONFIG_USER_ONLY
  #include "exec/address-spaces.h"
  #include "hw/xen/xen.h"
@@ -2723,7 +2722,6 @@ static void mce_init(X86CPU *cpu)
  #ifndef CONFIG_USER_ONLY
  static void x86_cpu_apic_create(X86CPU *cpu, Error **errp)
  {
-    DeviceState *dev = DEVICE(cpu);
      APICCommonState *apic;
      const char *apic_type = "apic";
 
@@ -2733,11 +2731,7 @@ static void x86_cpu_apic_create(X86CPU *cpu, Error **errp)
          apic_type = "xen-apic";
      }
 
-    cpu->apic_state = qdev_try_create(qdev_get_parent_bus(dev), apic_type);
-    if (cpu->apic_state == NULL) {
-        error_setg(errp, "APIC device '%s' could not be created", apic_type);
-        return;
-    }
+    cpu->apic_state = DEVICE(object_new(apic_type));
 
      object_property_add_child(OBJECT(cpu), "apic",
                                OBJECT(cpu->apic_state), NULL);

target-i386/cpu.c static void x86_cpu_common_class_init(ObjectClass *oc, void *data) · line 3161

Quoted 7 lines
target-i386/cpu.c +0 -1
@@ -3162,7 +3156,6 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
 
      xcc->parent_realize = dc->realize;
      dc->realize = x86_cpu_realizefn;
-    dc->bus_type = TYPE_ICC_BUS;
      dc->props = x86_cpu_properties;
 
      xcc->parent_reset = cc->reset;

.

#8 lore raw

Re: [Qemu-devel] [PATCH v11 4/5] cpu/apic: drop icc bus/bridge

Quoted 18 lines · On Tue, 15 Sep 2015 08:52:34 +0800 Zhu Guihua <[email protected]> wrote:
Quoted 10 lines · Igor Mammedov
Quoted 7 lines · On Wed, 2 Sep 2015 17:36:21 +0800 Zhu Guihua <[email protected]> wrote:

From: Chen Fan <[email protected]>

After CPU hotplug has been converted to BUS-less hot-plug infrastructure, the only function ICC bus performs is to propagate reset to LAPICs. However LAPIC could be reset by registering its reset handler after all device are initialized.
Do so and drop ~200LOC of not needed anymore ICCBus related code.

Quoted 5 lines

this patch drops about 30LOCs only ...

PS:
Doesn't apply to current master, please rebase.

Quoted 7 lines

This patch rebased on my another patch
'[PATCH v3] i386: keep cpu_model field in MachineState uptodate'
https://lists.nongnu.org/archive/html/qemu-devel/2015-08/msg03375.html

The patch has been reviewed by Eduardo, but not been merged.

Should I only rebase on current master?

you could pull dependency in this series, it's only one patch.

Quoted 290 lines

Thanks,
Zhu

Quoted 284 lines
Quoted 275 lines
---
  hw/i386/pc.c                    | 19 ++++---------------
  hw/i386/pc_piix.c               |  9 +--------
  hw/i386/pc_q35.c                |  9 +--------
  hw/intc/apic_common.c           |  5 ++---
  include/hw/i386/apic_internal.h |  7 ++++---
  include/hw/i386/pc.h            |  2 +-
  target-i386/cpu.c               |  9 +--------
  7 files changed, 14 insertions(+), 46 deletions(-)
hw/i386/pc.c +4 -15
index 4b4a7f3..4c1d68a 100644
@@ -59,7 +59,6 @@
  #include "qemu/error-report.h"
  #include "hw/acpi/acpi.h"
  #include "hw/acpi/cpu_hotplug.h"
-#include "hw/cpu/icc_bus.h"
  #include "hw/boards.h"
  #include "hw/pci/pci_host.h"
  #include "acpi-build.h"
@@ -1052,23 +1051,16 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
  }
 
  static X86CPU *pc_new_cpu(const char *cpu_model, int64_t apic_id,
-                          DeviceState *icc_bridge, Error **errp)
+                          Error **errp)
  {
      X86CPU *cpu = NULL;
      Error *local_err = NULL;
 
-    if (icc_bridge == NULL) {
-        error_setg(&local_err, "Invalid icc-bridge value");
-        goto out;
-    }
-
      cpu = cpu_x86_create(cpu_model, &local_err);
      if (local_err != NULL) {
          goto out;
      }
 
-    qdev_set_parent_bus(DEVICE(cpu), qdev_get_child_bus(icc_bridge, "icc"));
-
      object_property_set_int(OBJECT(cpu), apic_id, "apic-id", &local_err);
      object_property_set_bool(OBJECT(cpu), true, "realized", &local_err);
 
@@ -1083,7 +1075,6 @@ out:
 
  void pc_hot_add_cpu(const int64_t id, Error **errp)
  {
-    DeviceState *icc_bridge;
      MachineState *machine = MACHINE(qdev_get_machine());
      X86CPU *cpu;
      int64_t apic_id = x86_cpu_apic_id_from_index(id);
@@ -1113,9 +1104,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
          return;
      }
 
-    icc_bridge = DEVICE(object_resolve_path_type("icc-bridge",
-                                                 TYPE_ICC_BRIDGE, NULL));
-    cpu = pc_new_cpu(machine->cpu_model, apic_id, icc_bridge, &local_err);
+    cpu = pc_new_cpu(machine->cpu_model, apic_id, &local_err);
      if (local_err) {
          error_propagate(errp, local_err);
          return;
@@ -1123,7 +1112,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
      object_unref(OBJECT(cpu));
  }
 
-void pc_cpus_init(PCMachineState *pcms, DeviceState *icc_bridge)
+void pc_cpus_init(PCMachineState *pcms)
  {
      int i;
      X86CPU *cpu = NULL;
@@ -1149,7 +1138,7 @@ void pc_cpus_init(PCMachineState *pcms, DeviceState *icc_bridge)
 
      for (i = 0; i < smp_cpus; i++) {
          cpu = pc_new_cpu(machine->cpu_model, x86_cpu_apic_id_from_index(i),
-                         icc_bridge, &error);
+                         &error);
          if (error) {
              error_report_err(error);
              exit(1);
hw/i386/pc_piix.c +1 -8
index fd6130d..3a97826 100644
@@ -39,7 +39,6 @@
  #include "hw/kvm/clock.h"
  #include "sysemu/sysemu.h"
  #include "hw/sysbus.h"
-#include "hw/cpu/icc_bus.h"
  #include "sysemu/arch_init.h"
  #include "sysemu/block-backend.h"
  #include "hw/i2c/smbus.h"
@@ -96,7 +95,6 @@ static void pc_init1(MachineState *machine)
      MemoryRegion *ram_memory;
      MemoryRegion *pci_memory;
      MemoryRegion *rom_memory;
-    DeviceState *icc_bridge;
      PcGuestInfo *guest_info;
      ram_addr_t lowmem;
 
@@ -141,11 +139,7 @@ static void pc_init1(MachineState *machine)
          exit(1);
      }
 
-    icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
-    object_property_add_child(qdev_get_machine(), "icc-bridge",
-                              OBJECT(icc_bridge), NULL);
-
-    pc_cpus_init(pcms, icc_bridge);
+    pc_cpus_init(pcms);
 
      if (kvm_enabled() && kvmclock_enabled) {
          kvmclock_create();
@@ -223,7 +217,6 @@ static void pc_init1(MachineState *machine)
      if (pci_enabled) {
          ioapic_init_gsi(gsi_state, "i440fx");
      }
-    qdev_init_nofail(icc_bridge);
 
      pc_register_ferr_irq(gsi[13]);
 
hw/i386/pc_q35.c +1 -8
index 4f76535..414cbbb 100644
@@ -43,7 +43,6 @@
  #include "hw/ide/pci.h"
  #include "hw/ide/ahci.h"
  #include "hw/usb.h"
-#include "hw/cpu/icc_bus.h"
  #include "qemu/error-report.h"
  #include "migration/migration.h"
 
@@ -83,7 +82,6 @@ static void pc_q35_init(MachineState *machine)
      int i;
      ICH9LPCState *ich9_lpc;
      PCIDevice *ahci;
-    DeviceState *icc_bridge;
      PcGuestInfo *guest_info;
      ram_addr_t lowmem;
      DriveInfo *hd[MAX_SATA_PORTS];
@@ -132,11 +130,7 @@ static void pc_q35_init(MachineState *machine)
          exit(1);
      }
 
-    icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
-    object_property_add_child(qdev_get_machine(), "icc-bridge",
-                              OBJECT(icc_bridge), NULL);
-
-    pc_cpus_init(pcms, icc_bridge);
+    pc_cpus_init(pcms);
      pc_acpi_init("q35-acpi-dsdt.aml");
 
      kvmclock_create();
@@ -237,7 +231,6 @@ static void pc_q35_init(MachineState *machine)
      if (pci_enabled) {
          ioapic_init_gsi(gsi_state, "q35");
      }
-    qdev_init_nofail(icc_bridge);
 
      pc_register_ferr_irq(gsi[13]);
 
hw/intc/apic_common.c +2 -3
index c0b32eb..ad959c4 100644
@@ -419,13 +419,12 @@ static Property apic_properties_common[] = {
 
  static void apic_common_class_init(ObjectClass *klass, void *data)
  {
-    ICCDeviceClass *idc = ICC_DEVICE_CLASS(klass);
      DeviceClass *dc = DEVICE_CLASS(klass);
 
      dc->vmsd = &vmstate_apic_common;
      dc->reset = apic_reset_common;
      dc->props = apic_properties_common;
-    idc->realize = apic_common_realize;
+    dc->realize = apic_common_realize;
      /*
       * Reason: APIC and CPU need to be wired up by
       * x86_cpu_apic_create()
@@ -435,7 +434,7 @@ static void apic_common_class_init(ObjectClass *klass, void *data)
 
  static const TypeInfo apic_common_type = {
      .name = TYPE_APIC_COMMON,
-    .parent = TYPE_ICC_DEVICE,
+    .parent = TYPE_DEVICE,
      .instance_size = sizeof(APICCommonState),
      .class_size = sizeof(APICCommonClass),
      .class_init = apic_common_class_init,
include/hw/i386/apic_internal.h +4 -3
index 26632ac..905ada7 100644
@@ -22,7 +22,6 @@
 
  #include "cpu.h"
  #include "exec/memory.h"
-#include "hw/cpu/icc_bus.h"
  #include "qemu/timer.h"
 
  /* APIC Local Vector Table */
@@ -79,7 +78,7 @@ typedef struct APICCommonState APICCommonState;
 
  typedef struct APICCommonClass
  {
-    ICCDeviceClass parent_class;
+    DeviceClass parent_class;
 
      DeviceRealize realize;
      void (*set_base)(APICCommonState *s, uint64_t val);
@@ -94,7 +93,9 @@ typedef struct APICCommonClass
  } APICCommonClass;
 
  struct APICCommonState {
-    ICCDevice busdev;
+    /*< private >*/
+    DeviceState parent_obj;
+    /*< public >*/
 
      MemoryRegion io_memory;
      X86CPU *cpu;
include/hw/i386/pc.h +1 -1
index 3732ab5..8eef558 100644
@@ -161,7 +161,7 @@ bool pc_machine_is_smm_enabled(PCMachineState *pcms);
  void pc_register_ferr_irq(qemu_irq irq);
  void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
 
-void pc_cpus_init(PCMachineState *pcms, DeviceState *icc_bridge);
+void pc_cpus_init(PCMachineState *pcms);
  void pc_hot_add_cpu(const int64_t id, Error **errp);
  void pc_acpi_init(const char *default_dsdt);
 
target-i386/cpu.c +1 -7
index 0a95162..6686039 100644
@@ -43,7 +43,6 @@
 
  #include "sysemu/sysemu.h"
  #include "hw/qdev-properties.h"
-#include "hw/cpu/icc_bus.h"
  #ifndef CONFIG_USER_ONLY
  #include "exec/address-spaces.h"
  #include "hw/xen/xen.h"
@@ -2723,7 +2722,6 @@ static void mce_init(X86CPU *cpu)
  #ifndef CONFIG_USER_ONLY
  static void x86_cpu_apic_create(X86CPU *cpu, Error **errp)
  {
-    DeviceState *dev = DEVICE(cpu);
      APICCommonState *apic;
      const char *apic_type = "apic";
 
@@ -2733,11 +2731,7 @@ static void x86_cpu_apic_create(X86CPU *cpu, Error **errp)
          apic_type = "xen-apic";
      }
 
-    cpu->apic_state = qdev_try_create(qdev_get_parent_bus(dev), apic_type);
-    if (cpu->apic_state == NULL) {
-        error_setg(errp, "APIC device '%s' could not be created", apic_type);
-        return;
-    }
+    cpu->apic_state = DEVICE(object_new(apic_type));
 
      object_property_add_child(OBJECT(cpu), "apic",
                                OBJECT(cpu->apic_state), NULL);

target-i386/cpu.c static void x86_cpu_common_class_init(ObjectClass *oc, void *data) · line 3161

Quoted 7 lines
target-i386/cpu.c +0 -1
@@ -3162,7 +3156,6 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
 
      xcc->parent_realize = dc->realize;
      dc->realize = x86_cpu_realizefn;
-    dc->bus_type = TYPE_ICC_BUS;
      dc->props = x86_cpu_properties;
 
      xcc->parent_reset = cc->reset;

.

author
#9 lore raw

PATCH v11 5/5 icc_bus: drop the unused files

In reply to Zhu Guihua

ICC bus impl has been droped, so all icc related files are not useful any more; delete them.

---
 default-configs/i386-softmmu.mak   |   1 -
 default-configs/x86_64-softmmu.mak |   1 -
 hw/cpu/Makefile.objs               |   1 -
 hw/cpu/icc_bus.c                   | 118 -------------------------------------
 include/hw/cpu/icc_bus.h           |  82 --------------------------
 5 files changed, 203 deletions(-)
 delete mode 100644 hw/cpu/icc_bus.c
 delete mode 100644 include/hw/cpu/icc_bus.h
default-configs/i386-softmmu.mak +0 -1
index 5eaafa1..70391ed 100644
@@ -43,7 +43,6 @@ CONFIG_LPC_ICH9=y
 CONFIG_PCI_Q35=y
 CONFIG_APIC=y
 CONFIG_IOAPIC=y
-CONFIG_ICC_BUS=y
 CONFIG_PVPANIC=y
 CONFIG_MEM_HOTPLUG=y
 CONFIG_XIO3130=y
default-configs/x86_64-softmmu.mak +0 -1
index 28e2099..dfb8095 100644
@@ -44,7 +44,6 @@ CONFIG_LPC_ICH9=y
 CONFIG_PCI_Q35=y
 CONFIG_APIC=y
 CONFIG_IOAPIC=y
-CONFIG_ICC_BUS=y
 CONFIG_PVPANIC=y
 CONFIG_MEM_HOTPLUG=y
 CONFIG_XIO3130=y
hw/cpu/Makefile.objs +0 -1
index 6381238..0954a18 100644
@@ -2,5 +2,4 @@ obj-$(CONFIG_ARM11MPCORE) += arm11mpcore.o
 obj-$(CONFIG_REALVIEW) += realview_mpcore.o
 obj-$(CONFIG_A9MPCORE) += a9mpcore.o
 obj-$(CONFIG_A15MPCORE) += a15mpcore.o
-obj-$(CONFIG_ICC_BUS) += icc_bus.o
 
hw/cpu/icc_bus.c deleted +0 -118

118 lines not on this page · raw message

include/hw/cpu/icc_bus.h deleted +0 -82

82 lines not on this page · raw message

Signature · 1 line
1.9.3
author
#10 lore raw
In reply to Zhu Guihua

ping ...

Quoted 48 lines · Zhu Guihua

ICC Bus was used for providing a hotpluggable bus for APIC and CPU, but now we use HotplugHandler to make hotplug. So ICC Bus is unnecessary.

This code has passed the new pc-cpu-test.
And I have tested with kvm along with kernel_irqchip=on/off, it works fine.

This patch series is based on the latest master and '[PATCH v3] i386: keep cpu_model field in MachineState uptodate'
https://lists.nongnu.org/archive/html/qemu-devel/2015-08/msg03375.html
which has been reviewed but not been merged.

v11:
-improve commit messages
-split per CPU AS change into a separate patch

v10:
-improve commit messages in patch 1 and 2
-make the check of cpu->cpu_as_root simplier

v9:
-use a callback to correct reset sequence for x86 -update apic mmio mapping

Chen Fan (2):
apic: move APIC's MMIO region mapping into APIC cpu/apic: drop icc bus/bridge

Zhu Guihua (3):
apic: use per CPU AS to map APIC MMIO for TCG
x86: use new method to correct reset sequence
icc_bus: drop the unused files

  default-configs/i386-softmmu.mak   |   1 -
  default-configs/x86_64-softmmu.mak |   1 -
  hw/cpu/Makefile.objs               |   1 -
  hw/cpu/icc_bus.c                   | 118 -------------------------------------
  hw/i386/pc.c                       |  46 ++++++++-------
  hw/i386/pc_piix.c                  |   9 +--
  hw/i386/pc_q35.c                   |   9 +--
  hw/intc/apic_common.c              |  11 +---
  include/hw/cpu/icc_bus.h           |  82 --------------------------
  include/hw/i386/apic_internal.h    |   7 ++-
  include/hw/i386/pc.h               |   2 +-
  target-i386/cpu.c                  |  33 ++++++++---
  12 files changed, 58 insertions(+), 262 deletions(-)

delete mode 100644 hw/cpu/icc_bus.c
delete mode 100644 include/hw/cpu/icc_bus.h