From patchwork Thu Feb 4 11:47:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 8220281 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E4C2FBEEE5 for ; Thu, 4 Feb 2016 11:48:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3AE11201C0 for ; Thu, 4 Feb 2016 11:48:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 68A612017D for ; Thu, 4 Feb 2016 11:48:10 +0000 (UTC) Received: from localhost ([::1]:41046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRIOP-0007w4-P8 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 04 Feb 2016 06:48:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRIO9-0007Y1-1d for qemu-devel@nongnu.org; Thu, 04 Feb 2016 06:47:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRIO5-0000BP-17 for qemu-devel@nongnu.org; Thu, 04 Feb 2016 06:47:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47208) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRIO4-0000BK-Pl for qemu-devel@nongnu.org; Thu, 04 Feb 2016 06:47:48 -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 66B8BC003569 for ; Thu, 4 Feb 2016 11:47:48 +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 u14Blg7m002812; Thu, 4 Feb 2016 06:47:47 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 4 Feb 2016 12:47:29 +0100 Message-Id: <1454586455-10202-3-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 3/9] pc: acpi: cleanup qdev_get_machine() calls 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP call qdev_get_machine() once at acpi_build() and pass its result to child functions that need it. Signed-off-by: Igor Mammedov Reviewed-by: Marcel Apfelbaum --- Later it will also allow to reduce number of arguments passed around by build_foo() functions called from acpi_build() once guest_info fields are moved into PCMachineState. --- hw/i386/acpi-build.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 2028ed7..faf541c 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1937,13 +1937,13 @@ static Aml *build_q35_osc_method(void) static void build_dsdt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc, - PcPciInfo *pci, PcGuestInfo *guest_info) + PcPciInfo *pci, PcGuestInfo *guest_info, + MachineState *machine) { CrsRangeEntry *entry; Aml *dsdt, *sb_scope, *scope, *dev, *method, *field, *pkg, *crs; GPtrArray *mem_ranges = g_ptr_array_new_with_free_func(crs_range_free); GPtrArray *io_ranges = g_ptr_array_new_with_free_func(crs_range_free); - MachineState *machine = MACHINE(qdev_get_machine()); uint32_t nr_mem = machine->ram_slots; int root_bus_limit = 0xFF; PCIBus *bus = NULL; @@ -2365,7 +2365,8 @@ acpi_build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, } static void -build_srat(GArray *table_data, GArray *linker, PcGuestInfo *guest_info) +build_srat(GArray *table_data, GArray *linker, PcGuestInfo *guest_info, + MachineState *machine) { AcpiSystemResourceAffinityTable *srat; AcpiSratProcessorAffinity *core; @@ -2375,7 +2376,7 @@ build_srat(GArray *table_data, GArray *linker, PcGuestInfo *guest_info) uint64_t curnode; int srat_start, numa_start, slots; uint64_t mem_len, mem_base, next_base; - PCMachineState *pcms = PC_MACHINE(qdev_get_machine()); + PCMachineState *pcms = PC_MACHINE(machine); ram_addr_t hotplugabble_address_space_size = object_property_get_int(OBJECT(pcms), PC_MACHINE_MEMHP_REGION_SIZE, NULL); @@ -2579,9 +2580,9 @@ static bool acpi_has_iommu(void) return intel_iommu && !ambiguous; } -static bool acpi_has_nvdimm(void) +static bool acpi_has_nvdimm(MachineState *machine) { - PCMachineState *pcms = PC_MACHINE(qdev_get_machine()); + PCMachineState *pcms = PC_MACHINE(machine); return pcms->nvdimm; } @@ -2599,6 +2600,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) uint8_t *u; size_t aml_len = 0; GArray *tables_blob = tables->table_data; + MachineState *machine = MACHINE(qdev_get_machine()); acpi_get_cpu_info(&cpu); acpi_get_pm_info(&pm); @@ -2624,7 +2626,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, - guest_info); + guest_info, machine); /* Count the size of the DSDT and SSDT, we will need it for legacy * sizing of ACPI tables. @@ -2655,7 +2657,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) } if (guest_info->numa_nodes) { acpi_add_table(table_offsets, tables_blob); - build_srat(tables_blob, tables->linker, guest_info); + build_srat(tables_blob, tables->linker, guest_info, machine); } if (acpi_get_mcfg(&mcfg)) { acpi_add_table(table_offsets, tables_blob); @@ -2666,7 +2668,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) build_dmar_q35(tables_blob, tables->linker); } - if (acpi_has_nvdimm()) { + if (acpi_has_nvdimm(machine)) { nvdimm_build_acpi(table_offsets, tables_blob, tables->linker); }