From: Igor Mammedov <imammedo@redhat.com>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: <mst@redhat.com>, Markus Armbruster <armbru@redhat.com>,
<qemu-devel@nongnu.org>, <ankita@nvidia.com>,
<linuxarm@huawei.com>, <linux-cxl@vger.kernel.org>,
<marcel.apfelbaum@gmail.com>, <philmd@linaro.org>,
Richard Henderson <richard.henderson@linaro.org>,
Dave Jiang <dave.jiang@intel.com>,
Huang Ying <ying.huang@intel.com>,
Paolo Bonzini <pbonzini@redhat.com>, <eduardo@habkost.net>,
Michael Roth <michael.roth@amd.com>,
Ani Sinha <anisinha@redhat.com>
Subject: Re: [PATCH v5 06/13] acpi/pci: Move Generic Initiator object handling into acpi/pci.*
Date: Mon, 15 Jul 2024 16:28:24 +0200 [thread overview]
Message-ID: <20240715162824.6574fcd9@imammedo.users.ipa.redhat.com> (raw)
In-Reply-To: <20240712110837.1439736-7-Jonathan.Cameron@huawei.com>
On Fri, 12 Jul 2024 12:08:10 +0100
Jonathan Cameron <Jonathan.Cameron@huawei.com> wrote:
> Whilst ACPI SRAT Generic Initiator Afinity Structures are able to refer to
> both PCI and ACPI Device Handles, the QEMU implementation only implements
> the PCI Device Handle case. For now move the code into the existing
> hw/acpi/pci.c file and header. If support for ACPI Device Handles is
> added in the future, perhaps this will be moved again.
>
> Also push the struct AcpiGenericInitiator down into the c file as not
> used outside pci.c.
>
> Suggested-by: Igor Mammedov <imammedo@redhat.com>
> Tested-by: "Huang, Ying" <ying.huang@intel.com>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
>
> ---
> v5: Carry forward changes from previous patch.
> Move the TYPE_ACPI_GENERIC_INTIATOR define down into the c file
> along with include qom/object_interfaces.h
> ---
> include/hw/acpi/acpi_generic_initiator.h | 24 -----
> include/hw/acpi/pci.h | 3 +
> hw/acpi/acpi_generic_initiator.c | 120 ----------------------
> hw/acpi/pci.c | 124 +++++++++++++++++++++++
> hw/arm/virt-acpi-build.c | 1 -
> hw/i386/acpi-build.c | 1 -
> hw/acpi/meson.build | 1 -
> 7 files changed, 127 insertions(+), 147 deletions(-)
>
> diff --git a/include/hw/acpi/acpi_generic_initiator.h b/include/hw/acpi/acpi_generic_initiator.h
> deleted file mode 100644
> index 7b98676713..0000000000
> --- a/include/hw/acpi/acpi_generic_initiator.h
> +++ /dev/null
> @@ -1,24 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> -/*
> - * Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved
> - */
> -
> -#ifndef ACPI_GENERIC_INITIATOR_H
> -#define ACPI_GENERIC_INITIATOR_H
> -
> -#include "qom/object_interfaces.h"
> -
> -#define TYPE_ACPI_GENERIC_INITIATOR "acpi-generic-initiator"
> -
> -typedef struct AcpiGenericInitiator {
> - /* private */
> - Object parent;
> -
> - /* public */
> - char *pci_dev;
> - uint16_t node;
> -} AcpiGenericInitiator;
> -
> -void build_srat_generic_pci_initiator(GArray *table_data);
> -
> -#endif
> diff --git a/include/hw/acpi/pci.h b/include/hw/acpi/pci.h
> index 467a99461c..3015a8171c 100644
> --- a/include/hw/acpi/pci.h
> +++ b/include/hw/acpi/pci.h
> @@ -40,4 +40,7 @@ Aml *aml_pci_device_dsm(void);
>
> void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus);
> void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope);
> +
> +void build_srat_generic_pci_initiator(GArray *table_data);
> +
> #endif
> diff --git a/hw/acpi/acpi_generic_initiator.c b/hw/acpi/acpi_generic_initiator.c
> deleted file mode 100644
> index 365feb527f..0000000000
> --- a/hw/acpi/acpi_generic_initiator.c
> +++ /dev/null
> @@ -1,120 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> -/*
> - * Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved
> - */
> -
> -#include "qemu/osdep.h"
> -#include "hw/acpi/acpi_generic_initiator.h"
> -#include "hw/acpi/aml-build.h"
> -#include "hw/boards.h"
> -#include "hw/pci/pci_device.h"
> -#include "qemu/error-report.h"
> -#include "qapi/error.h"
> -
> -typedef struct AcpiGenericInitiatorClass {
> - ObjectClass parent_class;
> -} AcpiGenericInitiatorClass;
> -
> -OBJECT_DEFINE_TYPE_WITH_INTERFACES(AcpiGenericInitiator, acpi_generic_initiator,
> - ACPI_GENERIC_INITIATOR, OBJECT,
> - { TYPE_USER_CREATABLE },
> - { NULL })
> -
> -OBJECT_DECLARE_SIMPLE_TYPE(AcpiGenericInitiator, ACPI_GENERIC_INITIATOR)
> -
> -static void acpi_generic_initiator_init(Object *obj)
> -{
> - AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj);
> -
> - gi->node = MAX_NODES;
> - gi->pci_dev = NULL;
> -}
> -
> -static void acpi_generic_initiator_finalize(Object *obj)
> -{
> - AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj);
> -
> - g_free(gi->pci_dev);
> -}
> -
> -static void acpi_generic_initiator_set_pci_device(Object *obj, const char *val,
> - Error **errp)
> -{
> - AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj);
> -
> - gi->pci_dev = g_strdup(val);
> -}
> -
> -static void acpi_generic_initiator_set_node(Object *obj, Visitor *v,
> - const char *name, void *opaque,
> - Error **errp)
> -{
> - AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj);
> - MachineState *ms = MACHINE(qdev_get_machine());
> - uint32_t value;
> -
> - if (!visit_type_uint32(v, name, &value, errp)) {
> - return;
> - }
> -
> - if (value >= MAX_NODES) {
> - error_printf("%s: Invalid NUMA node specified\n",
> - TYPE_ACPI_GENERIC_INITIATOR);
> - exit(1);
> - }
> -
> - gi->node = value;
> - ms->numa_state->nodes[gi->node].has_gi = true;
> -}
> -
> -static void acpi_generic_initiator_class_init(ObjectClass *oc, void *data)
> -{
> - object_class_property_add_str(oc, "pci-dev", NULL,
> - acpi_generic_initiator_set_pci_device);
> - object_class_property_add(oc, "node", "int", NULL,
> - acpi_generic_initiator_set_node, NULL, NULL);
> -}
> -
> -static int build_acpi_generic_initiator(Object *obj, void *opaque)
> -{
> - MachineState *ms = MACHINE(qdev_get_machine());
> - AcpiGenericInitiator *gi;
> - GArray *table_data = opaque;
> - int32_t devfn;
> - uint8_t bus;
> - Object *o;
> -
> - if (!object_dynamic_cast(obj, TYPE_ACPI_GENERIC_INITIATOR)) {
> - return 0;
> - }
> -
> - gi = ACPI_GENERIC_INITIATOR(obj);
> - if (gi->node >= ms->numa_state->num_nodes) {
> - error_printf("%s: Specified node %d is invalid.\n",
> - TYPE_ACPI_GENERIC_INITIATOR, gi->node);
> - exit(1);
> - }
> -
> - o = object_resolve_path_type(gi->pci_dev, TYPE_PCI_DEVICE, NULL);
> - if (!o) {
> - error_printf("%s: Specified device must be a PCI device.\n",
> - TYPE_ACPI_GENERIC_INITIATOR);
> - exit(1);
> - }
> -
> - bus = object_property_get_uint(o, "busnr", &error_fatal);
> - devfn = object_property_get_int(o, "addr", &error_fatal);
> - /* devfn is constrained in PCI to be 8 bit but storage is an int32_t */
> - assert(devfn >= 0 && devfn < PCI_DEVFN_MAX);
> -
> - build_srat_pci_generic_initiator(table_data, gi->node, 0, bus, devfn);
> -
> - return 0;
> -}
> -
> -void build_srat_generic_pci_initiator(GArray *table_data)
> -{
> - object_child_foreach_recursive(object_get_root(),
> - build_acpi_generic_initiator,
> - table_data);
> -}
> diff --git a/hw/acpi/pci.c b/hw/acpi/pci.c
> index 20b70dcd81..3e1db161cc 100644
> --- a/hw/acpi/pci.c
> +++ b/hw/acpi/pci.c
> @@ -24,8 +24,13 @@
> */
>
> #include "qemu/osdep.h"
> +#include "qemu/error-report.h"
> +#include "qom/object_interfaces.h"
> +#include "qapi/error.h"
> +#include "hw/boards.h"
> #include "hw/acpi/aml-build.h"
> #include "hw/acpi/pci.h"
> +#include "hw/pci/pci_device.h"
> #include "hw/pci/pcie_host.h"
>
> /*
> @@ -59,3 +64,122 @@ void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info,
>
> acpi_table_end(linker, &table);
> }
> +
> +typedef struct AcpiGenericInitiator {
> + /* private */
> + Object parent;
> +
> + /* public */
> + char *pci_dev;
> + uint16_t node;
> +} AcpiGenericInitiator;
> +
> +typedef struct AcpiGenericInitiatorClass {
> + ObjectClass parent_class;
> +} AcpiGenericInitiatorClass;
> +
> +#define TYPE_ACPI_GENERIC_INITIATOR "acpi-generic-initiator"
> +
> +OBJECT_DEFINE_TYPE_WITH_INTERFACES(AcpiGenericInitiator, acpi_generic_initiator,
> + ACPI_GENERIC_INITIATOR, OBJECT,
> + { TYPE_USER_CREATABLE },
> + { NULL })
> +
> +OBJECT_DECLARE_SIMPLE_TYPE(AcpiGenericInitiator, ACPI_GENERIC_INITIATOR)
> +
> +static void acpi_generic_initiator_init(Object *obj)
> +{
> + AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj);
> +
> + gi->node = MAX_NODES;
> + gi->pci_dev = NULL;
> +}
> +
> +static void acpi_generic_initiator_finalize(Object *obj)
> +{
> + AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj);
> +
> + g_free(gi->pci_dev);
> +}
> +
> +static void acpi_generic_initiator_set_pci_device(Object *obj, const char *val,
> + Error **errp)
> +{
> + AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj);
> +
> + gi->pci_dev = g_strdup(val);
> +}
> +
> +static void acpi_generic_initiator_set_node(Object *obj, Visitor *v,
> + const char *name, void *opaque,
> + Error **errp)
> +{
> + AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj);
> + MachineState *ms = MACHINE(qdev_get_machine());
> + uint32_t value;
> +
> + if (!visit_type_uint32(v, name, &value, errp)) {
> + return;
> + }
> +
> + if (value >= MAX_NODES) {
> + error_printf("%s: Invalid NUMA node specified\n",
> + TYPE_ACPI_GENERIC_INITIATOR);
> + exit(1);
> + }
> +
> + gi->node = value;
> + ms->numa_state->nodes[gi->node].has_gi = true;
> +}
> +
> +static void acpi_generic_initiator_class_init(ObjectClass *oc, void *data)
> +{
> + object_class_property_add_str(oc, "pci-dev", NULL,
> + acpi_generic_initiator_set_pci_device);
> + object_class_property_add(oc, "node", "int", NULL,
> + acpi_generic_initiator_set_node, NULL, NULL);
> +}
> +
> +static int build_acpi_generic_initiator(Object *obj, void *opaque)
> +{
> + MachineState *ms = MACHINE(qdev_get_machine());
> + AcpiGenericInitiator *gi;
> + GArray *table_data = opaque;
> + int32_t devfn;
> + uint8_t bus;
> + Object *o;
> +
> + if (!object_dynamic_cast(obj, TYPE_ACPI_GENERIC_INITIATOR)) {
> + return 0;
> + }
> +
> + gi = ACPI_GENERIC_INITIATOR(obj);
> + if (gi->node >= ms->numa_state->num_nodes) {
> + error_printf("%s: Specified node %d is invalid.\n",
> + TYPE_ACPI_GENERIC_INITIATOR, gi->node);
> + exit(1);
> + }
> +
> + o = object_resolve_path_type(gi->pci_dev, TYPE_PCI_DEVICE, NULL);
> + if (!o) {
> + error_printf("%s: Specified device must be a PCI device.\n",
> + TYPE_ACPI_GENERIC_INITIATOR);
> + exit(1);
> + }
> +
> + bus = object_property_get_uint(o, "busnr", &error_fatal);
> + devfn = object_property_get_uint(o, "addr", &error_fatal);
> + /* devfn is constrained in PCI to be 8 bit but storage is an int32_t */
> + assert(devfn >= 0 && devfn < PCI_DEVFN_MAX);
> +
> + build_srat_pci_generic_initiator(table_data, gi->node, 0, bus, devfn);
> +
> + return 0;
> +}
> +
> +void build_srat_generic_pci_initiator(GArray *table_data)
> +{
> + object_child_foreach_recursive(object_get_root(),
> + build_acpi_generic_initiator,
> + table_data);
> +}
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index e10cad86dd..a50b00b7c1 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -57,7 +57,6 @@
> #include "migration/vmstate.h"
> #include "hw/acpi/ghes.h"
> #include "hw/acpi/viot.h"
> -#include "hw/acpi/acpi_generic_initiator.h"
> #include "hw/virtio/virtio-acpi.h"
> #include "target/arm/multiprocessing.h"
>
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index f4e366f64f..ee92783836 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -68,7 +68,6 @@
> #include "hw/acpi/utils.h"
> #include "hw/acpi/pci.h"
> #include "hw/acpi/cxl.h"
> -#include "hw/acpi/acpi_generic_initiator.h"
>
> #include "qom/qom-qobject.h"
> #include "hw/i386/amd_iommu.h"
> diff --git a/hw/acpi/meson.build b/hw/acpi/meson.build
> index fa5c07db90..5441c9b1e4 100644
> --- a/hw/acpi/meson.build
> +++ b/hw/acpi/meson.build
> @@ -1,6 +1,5 @@
> acpi_ss = ss.source_set()
> acpi_ss.add(files(
> - 'acpi_generic_initiator.c',
> 'acpi_interface.c',
> 'aml-build.c',
> 'bios-linker-loader.c',
next prev parent reply other threads:[~2024-07-15 14:29 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-12 11:08 [PATCH v5 00/13] acpi: NUMA nodes for CXL HB as GP + complex NUMA test Jonathan Cameron via
2024-07-12 11:08 ` [PATCH v5 01/13] hw/acpi: Fix ordering of BDF in Generic Initiator PCI Device Handle Jonathan Cameron via
2024-07-12 11:08 ` [PATCH v5 02/13] hw/acpi/GI: Fix trivial parameter alignment issue Jonathan Cameron via
2024-07-12 11:08 ` [PATCH v5 03/13] hw/acpi: Move AML building code for Generic Initiators to aml_build.c Jonathan Cameron via
2024-07-12 11:08 ` [PATCH v5 04/13] hw/acpi: Rename build_all_acpi_generic_initiators() to build_acpi_generic_initiator() Jonathan Cameron via
2024-07-12 11:08 ` [PATCH v5 05/13] hw/pci: Add a busnr property to pci_props and use for acpi/gi Jonathan Cameron via
2024-07-12 11:08 ` [PATCH v5 06/13] acpi/pci: Move Generic Initiator object handling into acpi/pci.* Jonathan Cameron via
2024-07-15 14:28 ` Igor Mammedov [this message]
2024-07-15 14:28 ` Igor Mammedov
2024-07-12 11:08 ` [PATCH v5 07/13] hw/pci-bridge: Add acpi_uid property to TYPE_PXB_BUS Jonathan Cameron via
2024-07-15 14:29 ` Igor Mammedov
2024-07-12 11:08 ` [PATCH v5 08/13] hw/i386/acpi: Use TYPE_PXB_BUS property acpi_uid for DSDT Jonathan Cameron via
2024-07-15 14:29 ` Igor Mammedov
2024-07-12 11:08 ` [PATCH v5 09/13] hw/pci-host/gpex-acpi: Use acpi_uid property Jonathan Cameron via
2024-07-15 14:29 ` Igor Mammedov
2024-07-12 11:08 ` [PATCH v5 10/13] hw/acpi: Generic Port Affinity Structure support Jonathan Cameron via
2024-07-15 14:48 ` Igor Mammedov
2024-07-17 15:02 ` Jonathan Cameron via
2024-07-17 15:11 ` Michael S. Tsirkin
2024-07-17 15:40 ` Jonathan Cameron via
2024-08-28 16:54 ` Jonathan Cameron via
2024-07-12 11:08 ` [PATCH v5 11/13] bios-tables-test: Allow for new acpihmat-generic-x test data Jonathan Cameron via
2024-07-12 11:08 ` [PATCH v5 12/13] bios-tables-test: Add complex SRAT / HMAT test for GI GP Jonathan Cameron via
2024-07-12 11:08 ` [PATCH v5 13/13] bios-tables-test: Add data for complex numa test (GI, GP etc) Jonathan Cameron via
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=20240715162824.6574fcd9@imammedo.users.ipa.redhat.com \
--to=imammedo@redhat.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=anisinha@redhat.com \
--cc=ankita@nvidia.com \
--cc=armbru@redhat.com \
--cc=dave.jiang@intel.com \
--cc=eduardo@habkost.net \
--cc=linux-cxl@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=michael.roth@amd.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=ying.huang@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).