All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Wei Yang <richardw.yang@linux.intel.com>
Cc: peter.maydell@linaro.org, mst@redhat.com, qemu-devel@nongnu.org,
	shannon.zhaosl@gmail.com, qemu-arm@nongnu.org,
	marcel.apfelbaum@gmail.com
Subject: Re: [Qemu-arm] [RFC PATCH 1/3] hw/arm/virt-acpi-build: use acpi_get_mcfg() to calculate bus number
Date: Wed, 13 Mar 2019 13:00:22 +0100	[thread overview]
Message-ID: <20190313130022.34105087@redhat.com> (raw)
In-Reply-To: <20190313044253.31988-2-richardw.yang@linux.intel.com>

On Wed, 13 Mar 2019 12:42:51 +0800
Wei Yang <richardw.yang@linux.intel.com> wrote:

> 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 <richardw.yang@linux.intel.com>
> ---
>  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, VirtMachineState *vms)
>                   "SRAT", table_data->len - srat_start, 3, NULL, NULL);
>  }
>  
> -static void
> -build_mcfg(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
> +static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
>  {
> -    AcpiTableMcfg *mcfg;
> +    VirtMachineState *vms = VIRT_MACHINE(qdev_get_machine());
>      const MemMapEntry *memmap = vms->memmap;
>      int ecam_id = VIRT_ECAM_ID(vms->highmem_ecam);
> +
> +    mcfg->mcfg_base = memmap[ecam_id].base;
> +    mcfg->mcfg_size = memmap[ecam_id].size;
> +
> +    return true;
> +}
> +
> +static void
> +build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info)
> +{
> +    AcpiTableMcfg *mcfg;
>      int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]);
>      int mcfg_start = table_data->len;
>  
>      mcfg = acpi_data_push(table_data, len);
> -    mcfg->allocation[0].address = cpu_to_le64(memmap[ecam_id].base);
> +    mcfg->allocation[0].address = cpu_to_le64(info->mcfg_base);
>  
>      /* Only a single allocation so no need to play with segments */
>      mcfg->allocation[0].pci_segment = cpu_to_le16(0);
>      mcfg->allocation[0].start_bus_number = 0;
> -    mcfg->allocation[0].end_bus_number =
> -        PCIE_MMCFG_BUS(memmap[ecam_id].size - 1);
> +    mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1);
>  
>      build_header(linker, table_data, (void *)(table_data->data + mcfg_start),
>                   "MCFG", table_data->len - mcfg_start, 1, NULL, NULL);
> @@ -779,6 +788,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
>      VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
>      GArray *table_offsets;
>      unsigned dsdt, xsdt;
> +    AcpiMcfgInfo mcfg;
>      GArray *tables_blob = tables->table_data;
>  
>      table_offsets = g_array_new(false, true /* clear */,
> @@ -802,8 +812,10 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
>      acpi_add_table(table_offsets, tables_blob);
>      build_gtdt(tables_blob, tables->linker, vms);
>  
> -    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);
> +    }

acpi_get_mcfg used only once and always true so one doesn't need condition
I'd go for simpler:

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index d7e2e4885b..a28e04c249 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -803,8 +803,13 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
     build_gtdt(tables_blob, tables->linker, vms);
 
     acpi_add_table(table_offsets, tables_blob);
-    build_mcfg(tables_blob, tables->linker, vms);
-
+    {
+        const AcpiTableMcfg mcfg = {
+           .mcfg_base = vms->memmap[VIRT_ECAM_ID(vms->highmem_ecam)].base;
+           .mcfg_size = vms->memmap[VIRT_ECAM_ID(vms->highmem_ecam)].size;
+        };
+        build_mcfg(tables_blob, tables->linker, &mcfg);
+    }
     acpi_add_table(table_offsets, tables_blob);
     build_spcr(tables_blob, tables->linker, vms);

and get rid of acpi_get_mcfg() helper function

>      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
>  
> -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;
>  
> +typedef struct AcpiMcfgInfo {
> +    uint64_t mcfg_base;
> +    uint32_t mcfg_size;
mcfg_ prefix in fields probably isn't necessary.

> +} AcpiMcfgInfo;
> +
>  /**
>   * init_aml_allocator:
>   *


  reply	other threads:[~2019-03-13 12:12 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13  4:42 [Qemu-devel] [RFC PATCH 0/3] Extract build_mcfg Wei Yang
2019-03-13  4:42 ` [Qemu-devel] [RFC PATCH 1/3] hw/arm/virt-acpi-build: use acpi_get_mcfg() to calculate bus number Wei Yang
2019-03-13 12:00   ` Igor Mammedov [this message]
2019-03-13 13:26     ` Wei Yang
2019-03-13  4:42 ` [Qemu-arm] [RFC PATCH 2/3] hw/arm/virt-acpi-build: remove unnecessary variable mcfg_start Wei Yang
2019-03-13 12:06   ` Igor Mammedov
2019-03-13  4:42 ` [Qemu-devel] [RFC PATCH 3/3] hw/acpi: Extract build_mcfg Wei Yang
2019-03-13 12:23   ` [Qemu-arm] " Igor Mammedov
2019-03-13 13:33     ` [Qemu-devel] " Wei Yang
2019-03-13 16:09       ` [Qemu-arm] " Igor Mammedov
2019-03-13 21:31         ` Wei Yang
2019-03-14  9:18           ` Igor Mammedov
2019-03-14 11:54             ` [Qemu-arm] " Wei Yang
2019-03-16 10:31             ` Wei Yang
2019-03-20 13:40               ` Wei Yang
2019-04-02  3:53         ` [Qemu-arm] " Wei Yang
2019-04-02  3:53           ` Wei Yang
2019-04-02  6:15           ` [Qemu-arm] " Igor Mammedov
2019-04-02  6:15             ` Igor Mammedov
2019-04-05  8:55             ` [Qemu-arm] " Wei Yang
2019-04-05  8:55               ` Wei Yang
2019-04-05  8:55               ` Wei Yang
2019-04-09 14:54               ` [Qemu-arm] " Igor Mammedov
2019-04-09 14:54                 ` Igor Mammedov
2019-04-12  5:44                 ` [Qemu-arm] " Wei Yang
2019-04-12  5:44                   ` Wei Yang
2019-04-12  5:44                   ` Wei Yang
2019-04-12  8:14                   ` [Qemu-arm] " Igor Mammedov
2019-04-12  8:14                     ` Igor Mammedov
2019-03-13 12:30 ` [Qemu-arm] [Qemu-devel] [RFC PATCH 0/3] " Igor Mammedov
2019-03-13 13:24   ` Wei Yang
2019-03-13 16:17     ` [Qemu-arm] " Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190313130022.34105087@redhat.com \
    --to=imammedo@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richardw.yang@linux.intel.com \
    --cc=shannon.zhaosl@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.