From nobody Mon Nov 10 01:17:21 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155245236096260.92294749644748; Tue, 12 Mar 2019 21:46:00 -0700 (PDT) Received: from localhost ([127.0.0.1]:38240 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3vm9-0004dr-W9 for importer@patchew.org; Wed, 13 Mar 2019 00:45:58 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40022) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3vkC-0003Ka-Qg for qemu-devel@nongnu.org; Wed, 13 Mar 2019 00:43:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3vkB-0003Yr-LK for qemu-devel@nongnu.org; Wed, 13 Mar 2019 00:43:56 -0400 Received: from mga17.intel.com ([192.55.52.151]:13002) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h3vkB-0003X3-9e; Wed, 13 Mar 2019 00:43:55 -0400 Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Mar 2019 21:43:53 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga008.fm.intel.com with ESMTP; 12 Mar 2019 21:43:52 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,473,1544515200"; d="scan'208";a="131180343" From: Wei Yang To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Date: Wed, 13 Mar 2019 12:42:51 +0800 Message-Id: <20190313044253.31988-2-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190313044253.31988-1-richardw.yang@linux.intel.com> References: <20190313044253.31988-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.151 Subject: [Qemu-devel] [RFC PATCH 1/3] hw/arm/virt-acpi-build: use acpi_get_mcfg() to calculate bus number X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, mst@redhat.com, shannon.zhaosl@gmail.com, Wei Yang , imammedo@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" To build MCFG, two information is necessary: * bus number * base address Abstract these two information to AcpiMcfgInfo so that build_mcfg and build_mcfg_q35 will have the same declaration. Signed-off-by: Wei Yang --- hw/arm/virt-acpi-build.c | 28 ++++++++++++++++++++-------- hw/i386/acpi-build.c | 5 ----- include/hw/acpi/aml-build.h | 5 +++++ 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 57679a89bf..7713c2d809 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -545,23 +545,32 @@ build_srat(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) "SRAT", table_data->len - srat_start, 3, NULL, NULL); } =20 -static void -build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) +static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) { - AcpiTableMcfg *mcfg; + VirtMachineState *vms =3D VIRT_MACHINE(qdev_get_machine()); const MemMapEntry *memmap =3D vms->memmap; int ecam_id =3D VIRT_ECAM_ID(vms->highmem_ecam); + + mcfg->mcfg_base =3D memmap[ecam_id].base; + mcfg->mcfg_size =3D memmap[ecam_id].size; + + return true; +} + +static void +build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info) +{ + AcpiTableMcfg *mcfg; int len =3D sizeof(*mcfg) + sizeof(mcfg->allocation[0]); int mcfg_start =3D table_data->len; =20 mcfg =3D acpi_data_push(table_data, len); - mcfg->allocation[0].address =3D cpu_to_le64(memmap[ecam_id].base); + mcfg->allocation[0].address =3D cpu_to_le64(info->mcfg_base); =20 /* Only a single allocation so no need to play with segments */ mcfg->allocation[0].pci_segment =3D cpu_to_le16(0); mcfg->allocation[0].start_bus_number =3D 0; - mcfg->allocation[0].end_bus_number =3D - PCIE_MMCFG_BUS(memmap[ecam_id].size - 1); + mcfg->allocation[0].end_bus_number =3D PCIE_MMCFG_BUS(info->mcfg_size = - 1); =20 build_header(linker, table_data, (void *)(table_data->data + mcfg_star= t), "MCFG", table_data->len - mcfg_start, 1, NULL, NULL); @@ -779,6 +788,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTa= bles *tables) VirtMachineClass *vmc =3D VIRT_MACHINE_GET_CLASS(vms); GArray *table_offsets; unsigned dsdt, xsdt; + AcpiMcfgInfo mcfg; GArray *tables_blob =3D tables->table_data; =20 table_offsets =3D g_array_new(false, true /* clear */, @@ -802,8 +812,10 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildT= ables *tables) acpi_add_table(table_offsets, tables_blob); build_gtdt(tables_blob, tables->linker, vms); =20 - acpi_add_table(table_offsets, tables_blob); - build_mcfg(tables_blob, tables->linker, vms); + if (acpi_get_mcfg(&mcfg)) { + acpi_add_table(table_offsets, tables_blob); + build_mcfg(tables_blob, tables->linker, &mcfg); + } =20 acpi_add_table(table_offsets, tables_blob); build_spcr(tables_blob, tables->linker, vms); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 9ecc96dcc7..c5b1c3be99 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -86,11 +86,6 @@ /* Default IOAPIC ID */ #define ACPI_BUILD_IOAPIC_ID 0x0 =20 -typedef struct AcpiMcfgInfo { - uint64_t mcfg_base; - uint32_t mcfg_size; -} AcpiMcfgInfo; - typedef struct AcpiPmInfo { bool s3_disabled; bool s4_disabled; diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 1a563ad756..b63b85d67c 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -223,6 +223,11 @@ struct AcpiBuildTables { BIOSLinker *linker; } AcpiBuildTables; =20 +typedef struct AcpiMcfgInfo { + uint64_t mcfg_base; + uint32_t mcfg_size; +} AcpiMcfgInfo; + /** * init_aml_allocator: * --=20 2.19.1