From patchwork Thu Feb 4 11:47:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 578855 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9B5481402DE for ; Thu, 4 Feb 2016 22:48:41 +1100 (AEDT) Received: from localhost ([::1]:41051 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRIOt-0001MX-PI for incoming@patchwork.ozlabs.org; Thu, 04 Feb 2016 06:48:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRIOF-0007ry-7N for qemu-devel@nongnu.org; Thu, 04 Feb 2016 06:48:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRIOD-0000FC-VV for qemu-devel@nongnu.org; Thu, 04 Feb 2016 06:47:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44534) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRIOD-0000Ee-OY for qemu-devel@nongnu.org; Thu, 04 Feb 2016 06:47:57 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 5D32CC00230B for ; Thu, 4 Feb 2016 11:47:57 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u14Blg7q002812; Thu, 4 Feb 2016 06:47:54 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 4 Feb 2016 12:47:33 +0100 Message-Id: <1454586455-10202-7-git-send-email-imammedo@redhat.com> In-Reply-To: <1454586455-10202-1-git-send-email-imammedo@redhat.com> References: <1454586455-10202-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, ehabkost@redhat.com, mst@redhat.com Subject: [Qemu-devel] [PATCH 7/9] pc: acpi: drop not needed intermediate bitmap cpu->found_cpus X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org cpu->found_cpus bitmap is used for setting present flag in CPON AML package at start up. But it takes a bunch of code to fill bitmap and cloud be simplified by calling qemu_get_cpu_by_arch_id(apic_id) directly. Hence do so and remove not used anymore bitmap with related utilities, which saves us ~32LOC and also would simplify consolidating APCI parts of CPU hotplug. Signed-off-by: Igor Mammedov --- hw/i386/acpi-build.c | 42 +++++------------------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 9eeeffa..921830e 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -76,10 +76,6 @@ #define ACPI_BUILD_DPRINTF(fmt, ...) #endif -typedef struct AcpiCpuInfo { - DECLARE_BITMAP(found_cpus, ACPI_CPU_HOTPLUG_ID_LIMIT); -} AcpiCpuInfo; - typedef struct AcpiMcfgInfo { uint64_t mcfg_base; uint32_t mcfg_size; @@ -121,31 +117,6 @@ typedef struct AcpiBuildPciBusHotplugState { bool pcihp_bridge_en; } AcpiBuildPciBusHotplugState; -static -int acpi_add_cpu_info(Object *o, void *opaque) -{ - AcpiCpuInfo *cpu = opaque; - uint64_t apic_id; - - if (object_dynamic_cast(o, TYPE_CPU)) { - apic_id = object_property_get_int(o, "apic-id", NULL); - assert(apic_id < ACPI_CPU_HOTPLUG_ID_LIMIT); - - set_bit(apic_id, cpu->found_cpus); - } - - object_child_foreach(o, acpi_add_cpu_info, opaque); - return 0; -} - -static void acpi_get_cpu_info(AcpiCpuInfo *cpu) -{ - Object *root = object_get_root(); - - memset(cpu->found_cpus, 0, sizeof cpu->found_cpus); - object_child_foreach(root, acpi_add_cpu_info, cpu); -} - static void acpi_get_pm_info(AcpiPmInfo *pm) { Object *piix = piix4_pm_find(); @@ -967,8 +938,7 @@ static Aml *build_crs(PCIHostState *host, } static void build_processor_devices(Aml *sb_scope, unsigned acpi_cpus, - AcpiCpuInfo *cpu, AcpiPmInfo *pm, - MachineState *machine) + AcpiPmInfo *pm, MachineState *machine) { int i; Aml *dev; @@ -1063,7 +1033,7 @@ static void build_processor_devices(Aml *sb_scope, unsigned acpi_cpus, aml_varpackage(acpi_cpus); for (i = 0; i < acpi_cpus; i++) { - uint8_t b = test_bit(i, cpu->found_cpus) ? 0x01 : 0x00; + uint8_t b = qemu_get_cpu_by_arch_id(i) ? 0x01 : 0x00; aml_append(pkg, aml_int(b)); } aml_append(sb_scope, aml_name_decl(CPU_ON_BITMAP, pkg)); @@ -1955,7 +1925,7 @@ static Aml *build_q35_osc_method(void) static void build_dsdt(GArray *table_data, GArray *linker, - AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc, + AcpiPmInfo *pm, AcpiMiscInfo *misc, PcPciInfo *pci, PcGuestInfo *guest_info, MachineState *machine) { @@ -2263,7 +2233,7 @@ build_dsdt(GArray *table_data, GArray *linker, sb_scope = aml_scope("\\_SB"); { - build_processor_devices(sb_scope, guest_info->apic_id_limit, cpu, pm, + build_processor_devices(sb_scope, guest_info->apic_id_limit, pm, machine); build_memory_devices(sb_scope, nr_mem, pm->mem_hp_io_base, @@ -2618,7 +2588,6 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) { GArray *table_offsets; unsigned facs, dsdt, rsdt, fadt; - AcpiCpuInfo cpu; AcpiPmInfo pm; AcpiMiscInfo misc; AcpiMcfgInfo mcfg; @@ -2628,7 +2597,6 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) GArray *tables_blob = tables->table_data; MachineState *machine = MACHINE(qdev_get_machine()); - acpi_get_cpu_info(&cpu); acpi_get_pm_info(&pm); acpi_get_misc_info(&misc); acpi_get_pci_info(&pci); @@ -2651,7 +2619,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) /* DSDT is pointed to by FADT */ dsdt = tables_blob->len; - build_dsdt(tables_blob, tables->linker, &cpu, &pm, &misc, &pci, + build_dsdt(tables_blob, tables->linker, &pm, &misc, &pci, guest_info, machine); /* Count the size of the DSDT and SSDT, we will need it for legacy