acpi: NUMA nodes for CXL HB as GP + complex NUMA test
v5 cover acpi: NUMA nodes for CXL HB as GP + complex NUMA test
v5: Thanks to Igor for review.
Patch 5:
- Add an assert to catch out of range PCI devfn retrieved from addr property which is oddly an int32_t
Patch 6:
- Push TYPE_ACPI_GENERIC_INTIATOR define down into c file along with qom_interfaces.h include as they are only needed there.
Patch 7:
- Add missing object class property description.
Patch 8/9:
- Use busnr for naming of of ACPI nodes so as to avoid having to check if the uid is small enough (it is as they have the same value but nice not to have to check!)
Patch 10:
- Push TYPE_ACPI_GENERIC_PORT definition down into c file (similar to patch 6 change.
Title becoming a little misleading as now this does a bunch of other stuff as precursors, but I've kept it to maintain association with v3 and before. A more accurate series title is probably
acpi: Rework GI affinity structure generation, add GPs + complex NUMA test.
ACPI 6.5 introduced Generic Port Affinity Structures to close a system description gap that was a problem for CXL memory systems.
It defines an new SRAT Affinity structure (and hence allows creation of an ACPI Proximity Node which can only be defined via an SRAT structure) for the boundary between a discoverable fabric and a non discoverable system interconnects etc.
The HMAT data on latency and bandwidth is combined with discoverable information from the CXL bus (link speeds, lane counts) and CXL devices (switch port to port characteristics and USP to memory, via CDAT tables read from the device). QEMU has supported the rest of the elements of this chain for a while but now the kernel has caught up and we need the missing element of Generic Ports (this code has been used extensively in testing and debugging that kernel support, some resulting fixes currently under review).
Generic Port Affinity Structures are very similar to the recently added Generic Initiator Affinity Structures (GI) so this series factors out and reuses much of that infrastructure for reuse There are subtle differences (beyond the obvious structure ID change).
- The ACPI spec example (and linux kernel support) has a Generic Port not as associated with the CXL root port, but rather with the CXL Host bridge. As a result, an ACPI handle is used (rather than the PCI SBDF option for GIs). In QEMU the easiest way to get to this is to target the root bridge PCI Bus, and conveniently the root bridge bus number is used for the UID allowing us to construct an appropriate entry.
A key addition of this series is a complex NUMA topology example that stretches the QEMU emulation code for GI, GP and nodes with just CPUS, just memory, just hot pluggable memory, mixture of memory and CPUs.
A similar test showed up a few NUMA related bugs with fixes applied for 9.0 (note that one of these needs linux booted to identify that it rejects the HMAT table and this test is a regression test for the table generation only).
https://lore.kernel.org/qemu-devel/2eb6672cfdaea7dacd8e9bb0523887f13b9f85ce.1710282274.git.mst@redhat.com/
https://lore.kernel.org/qemu-devel/74e2845c5f95b0c139c79233ddb65bb17f2dd679.1710282274.git.mst@redhat.com/
Jonathan Cameron (13):
hw/acpi: Fix ordering of BDF in Generic Initiator PCI Device Handle. hw/acpi/GI: Fix trivial parameter alignment issue. hw/acpi: Move AML building code for Generic Initiators to aml_build.c hw/acpi: Rename build_all_acpi_generic_initiators() to
build_acpi_generic_initiator()
hw/pci: Add a busnr property to pci_props and use for acpi/gi acpi/pci: Move Generic Initiator object handling into acpi/pci.* hw/pci-bridge: Add acpi_uid property to TYPE_PXB_BUS hw/i386/acpi: Use TYPE_PXB_BUS property acpi_uid for DSDT hw/pci-host/gpex-acpi: Use acpi_uid property.
hw/acpi: Generic Port Affinity Structure support
bios-tables-test: Allow for new acpihmat-generic-x test data.
bios-tables-test: Add complex SRAT / HMAT test for GI GP
bios-tables-test: Add data for complex numa test (GI, GP etc)
qapi/qom.json | 34 +++ include/hw/acpi/acpi_generic_initiator.h | 47 ---- include/hw/acpi/aml-build.h | 8 + include/hw/acpi/pci.h | 3 + include/hw/pci/pci_bridge.h | 1 + hw/acpi/acpi_generic_initiator.c | 148 ----------- hw/acpi/aml-build.c | 84 +++++++ hw/acpi/pci.c | 234 ++++++++++++++++++ hw/arm/virt-acpi-build.c | 3 +- hw/i386/acpi-build.c | 8 +- hw/pci-bridge/pci_expander_bridge.c | 14 +- hw/pci-host/gpex-acpi.c | 5 +- hw/pci/pci.c | 14 ++ tests/qtest/bios-tables-test.c | 97 ++++++++ hw/acpi/meson.build | 1 - .../data/acpi/x86/q35/APIC.acpihmat-generic-x | Bin 0 -> 136 bytes .../data/acpi/x86/q35/CEDT.acpihmat-generic-x | Bin 0 -> 68 bytes .../data/acpi/x86/q35/DSDT.acpihmat-generic-x | Bin 0 -> 10849 bytes .../data/acpi/x86/q35/HMAT.acpihmat-generic-x | Bin 0 -> 360 bytes .../data/acpi/x86/q35/SRAT.acpihmat-generic-x | Bin 0 -> 520 bytes 20 files changed, 498 insertions(+), 203 deletions(-) delete mode 100644 include/hw/acpi/acpi_generic_initiator.h delete mode 100644 hw/acpi/acpi_generic_initiator.c create mode 100644 tests/data/acpi/x86/q35/APIC.acpihmat-generic-x create mode 100644 tests/data/acpi/x86/q35/CEDT.acpihmat-generic-x create mode 100644 tests/data/acpi/x86/q35/DSDT.acpihmat-generic-x create mode 100644 tests/data/acpi/x86/q35/HMAT.acpihmat-generic-x create mode 100644 tests/data/acpi/x86/q35/SRAT.acpihmat-generic-x
Signature · 1 line
2.43.0
PATCH v5 1/13 hw/acpi: Fix ordering of BDF in Generic Initiator PCI Device Handle.
The ordering in ACPI specification [1] has bus number in the lowest byte. As ACPI tables are little endian this is the reverse of the ordering used by PCI_BUILD_BDF(). As a minimal fix split the QEMU BDF up into bus and devfn and write them as single bytes in the correct order.
[1] ACPI Spec 6.3, Table 5.80
---
v5: No change
--- hw/acpi/acpi_generic_initiator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/acpi/acpi_generic_initiator.c +2 -1
@@ -92,7 +92,8 @@ build_srat_generic_pci_initiator_affinity(GArray *table_data, int node,/* Device Handle - PCI */ build_append_int_noprefix (table_data, handle->segment,2 ); -build_append_int_noprefix (table_data, handle->bdf,2 ); +build_append_int_noprefix (table_data,PCI_BUS_NUM (handle->bdf),1 ); +build_append_int_noprefix (table_data,PCI_BDF_TO_DEVFN (handle->bdf),1 );for (index =0 ; index <12 ; index++) {build_append_int_noprefix (table_data,0 ,1 ); }
Signature · 1 line
2.43.0
PATCH v5 2/13 hw/acpi/GI: Fix trivial parameter alignment issue.
In reply to Jonathan CameronBefore making additional modification, tidy up this misleading indentation.
---
v5: No change
--- hw/acpi/acpi_generic_initiator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/acpi/acpi_generic_initiator.c +1 -1
@@ -133,7 +133,7 @@ static int build_all_acpi_generic_initiators(Object *obj, void *opaque) dev_handle.segment =0 ; dev_handle.bdf =PCI_BUILD_BDF (pci_bus_num (pci_get_bus (pci_dev)), - pci_dev->devfn); + pci_dev->devfn);build_srat_generic_pci_initiator_affinity (table_data, gi->node, &dev_handle);
Signature · 1 line
2.43.0
PATCH v5 3/13 hw/acpi: Move AML building code for Generic Initiators to aml_build.c
In reply to Jonathan CameronRather than attempting to create a generic function with mess of the two different device handle types, use a PCI handle specific variant. If the ACPI handle form is needed then that can be introduced alongside this with little duplicated code.
Drop the PCIDeviceHandle in favor of just passing the bus, devfn and segment directly. devfn kept as a single byte because ARI means that in this case it is just an 8 bit function number.
---
v5: No change
--- include/hw/acpi/acpi_generic_initiator.h | 23 ------------- include/hw/acpi/aml-build.h | 4 +++ hw/acpi/acpi_generic_initiator.c | 39 ++------------------- hw/acpi/aml-build.c | 44 ++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 59 deletions(-)
include/hw/acpi/acpi_generic_initiator.h +0 -23
@@ -19,29 +19,6 @@ typedef struct AcpiGenericInitiator { uint16_t node; } AcpiGenericInitiator; -/* -* ACPI 6.3: -* Table 5-81 Flags – Generic Initiator Affinity Structure -*/ -typedef enum { -/* -* If clear, the OSPM ignores the contents of the Generic -* Initiator/Port Affinity Structure. This allows system firmware -* to populate the SRAT with a static number of structures, but only -* enable them as necessary. -*/ -GEN_AFFINITY_ENABLED = (1 <<0 ), -}GenericAffinityFlags ; - -/* -* ACPI 6.3: -* Table 5-80 Device Handle - PCI -*/ -typedef struct PCIDeviceHandle { -uint16_t segment; -uint16_t bdf; -}PCIDeviceHandle ; -void build_srat_generic_pci_initiator (GArray *table_data);#endif
include/hw/acpi/aml-build.h +4 -0
@@ -486,6 +486,10 @@ Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set, uint32_t io_offset,void build_srat_memory (GArray *table_data,uint64_t base,uint64_t len,int node,MemoryAffinityFlags flags); +void build_srat_pci_generic_initiator (GArray *table_data,int node, +uint16_t segment,uint8_t bus, +uint8_t devfn); +void build_slit (GArray *table_data,BIOSLinker *linker,MachineState *ms,const char *oem_id,const char *oem_table_id);
hw/acpi/acpi_generic_initiator.c +3 -36
@@ -74,40 +74,11 @@ static void acpi_generic_initiator_class_init(ObjectClass *oc, void *data) acpi_generic_initiator_set_node, NULL, NULL); } -/* -* ACPI 6.3: -* Table 5-78 Generic Initiator Affinity Structure -*/ -static void -build_srat_generic_pci_initiator_affinity (GArray *table_data,int node, -PCIDeviceHandle *handle) -{ -uint8_t index; - -build_append_int_noprefix (table_data,5 ,1 );/* Type */ -build_append_int_noprefix (table_data,32 ,1 );/* Length */ -build_append_int_noprefix (table_data,0 ,1 );/* Reserved */ -build_append_int_noprefix (table_data,1 ,1 );/* Device Handle Type: PCI */ -build_append_int_noprefix (table_data, node,4 );/* Proximity Domain */ - -/* Device Handle - PCI */ -build_append_int_noprefix (table_data, handle->segment,2 ); -build_append_int_noprefix (table_data,PCI_BUS_NUM (handle->bdf),1 ); -build_append_int_noprefix (table_data,PCI_BDF_TO_DEVFN (handle->bdf),1 ); -for (index =0 ; index <12 ; index++) { -build_append_int_noprefix (table_data,0 ,1 ); - } - -build_append_int_noprefix (table_data,GEN_AFFINITY_ENABLED ,4 );/* Flags */ -build_append_int_noprefix (table_data,0 ,4 );/* Reserved */ -} -static int build_all_acpi_generic_initiators (Object *obj,void *opaque) {MachineState *ms =MACHINE (qdev_get_machine ());AcpiGenericInitiator *gi;GArray *table_data = opaque; -PCIDeviceHandle dev_handle;PCIDevice *pci_dev;Object *o;
@@ -130,13 +101,9 @@ static int build_all_acpi_generic_initiators(Object *obj, void *opaque) } pci_dev =PCI_DEVICE (o); - - dev_handle.segment =0 ; - dev_handle.bdf =PCI_BUILD_BDF (pci_bus_num (pci_get_bus (pci_dev)), - pci_dev->devfn); - -build_srat_generic_pci_initiator_affinity (table_data, - gi->node, &dev_handle); +build_srat_pci_generic_initiator (table_data, gi->node,0 , +pci_bus_num (pci_get_bus (pci_dev)), + pci_dev->devfn);return 0 ; }
hw/acpi/aml-build.c +44 -0
50 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v5 4/13 hw/acpi: Rename build_all_acpi_generic_initiators() to build_acpi_generic_initiator()
In reply to Jonathan CameronIgor noted that this function only builds one instance, so was rather misleadingly named. Fix that.
---
v5: No change
--- hw/acpi/acpi_generic_initiator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/acpi/acpi_generic_initiator.c +2 -2
@@ -74,7 +74,7 @@ static void acpi_generic_initiator_class_init(ObjectClass *oc, void *data) acpi_generic_initiator_set_node, NULL, NULL); } -static int build_all_acpi_generic_initiators (Object *obj,void *opaque) +static int build_acpi_generic_initiator (Object *obj,void *opaque) {MachineState *ms =MACHINE (qdev_get_machine ());AcpiGenericInitiator *gi;
@@ -111,6 +111,6 @@ static int build_all_acpi_generic_initiators(Object *obj, void *opaque)void build_srat_generic_pci_initiator (GArray *table_data) {object_child_foreach_recursive (object_get_root (), - build_all_acpi_generic_initiators, + build_acpi_generic_initiator, table_data); }
Signature · 1 line
2.43.0
PATCH v5 5/13 hw/pci: Add a busnr property to pci_props and use for acpi/gi
In reply to Jonathan CameronUsing a property allows us to hide the internal details of the PCI device from the code to build a SRAT Generic Initiator Affinity Structure with PCI Device Handle.
---
V5: Add assert() to catch if devfn is out of permissible range of
0 to 255. --- hw/acpi/acpi_generic_initiator.c | 14 +++++++++----- hw/pci/pci.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-)
hw/acpi/acpi_generic_initiator.c +9 -5
@@ -9,6 +9,7 @@#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;
@@ -79,7 +80,8 @@ static int build_acpi_generic_initiator(Object *obj, void *opaque)MachineState *ms =MACHINE (qdev_get_machine ());AcpiGenericInitiator *gi;GArray *table_data = opaque; -PCIDevice *pci_dev; +int32_t devfn; +uint8_t bus;Object *o;if (!object_dynamic_cast (obj,TYPE_ACPI_GENERIC_INITIATOR )) {
@@ -100,10 +102,12 @@ static int build_acpi_generic_initiator(Object *obj, void *opaque)exit (1 ); } - pci_dev =PCI_DEVICE (o); -build_srat_pci_generic_initiator (table_data, gi->node,0 , -pci_bus_num (pci_get_bus (pci_dev)), - pci_dev->devfn); + 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 ; }
hw/pci/pci.c +14 -0
@@ -67,6 +67,19 @@ static char *pcibus_get_fw_dev_path(DeviceState *dev);static void pcibus_reset_hold (Object *obj,ResetType type);static bool pcie_has_upstream_port (PCIDevice *dev); +static void prop_pci_busnr_get (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) +{ +uint8_t busnr =pci_dev_bus_num (PCI_DEVICE (obj)); + +visit_type_uint8 (v, name, &busnr, errp); +} + +static const PropertyInfo prop_pci_busnr = { + .name ="busnr" , + .get = prop_pci_busnr_get, +}; +static Property pci_props[] = {DEFINE_PROP_PCI_DEVFN ("addr" , PCIDevice, devfn,-1 ),DEFINE_PROP_STRING ("romfile" , PCIDevice, romfile),
@@ -85,6 +98,7 @@ static Property pci_props[] = { QEMU_PCIE_ERR_UNC_MASK_BITNR, true),DEFINE_PROP_BIT ("x-pcie-ari-nextfn-1" , PCIDevice, cap_present,QEMU_PCIE_ARI_NEXTFN_1_BITNR , false), + { .name = "busnr", .info = &prop_pci_busnr }, DEFINE_PROP_END_OF_LIST() };
Signature · 1 line
2.43.0
PATCH v5 6/13 acpi/pci: Move Generic Initiator object handling into acpi/pci.*
In reply to Jonathan CameronWhilst 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.
---
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(-)
include/hw/acpi/acpi_generic_initiator.h deleted +0 -24
@@ -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
include/hw/acpi/pci.h +3 -0
@@ -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
hw/acpi/acpi_generic_initiator.c deleted +0 -120
120 lines not on this page · raw message
hw/acpi/pci.c +124 -0
135 lines not on this page · raw message
hw/arm/virt-acpi-build.c +0 -1
@@ -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"
hw/i386/acpi-build.c +0 -1
@@ -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"
hw/acpi/meson.build +0 -1
@@ -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',
Signature · 1 line
2.43.0
Re: [PATCH v5 06/13] acpi/pci: Move Generic Initiator object handling into acpi/pci.*
Quoted 6 lines · On Fri, 12 Jul 2024 12:08:10 +0100 Jonathan Cameron…
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.cfile and header. If support for ACPI Device Handles is added in the future, perhaps this will be moved again.
Quoted 6 lines
Also push the struct AcpiGenericInitiator down into the c file as not used outside
pci.c.Suggested-by Igor Mammedov <[email protected]>Tested-by "Huang, Ying" <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>
Quoted 359 lines
---
v5: Carry forward changes from previous patch.
Move theTYPE_ACPI_GENERIC_INTIATORdefine down into the c file along with includeqom/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(-)include/hw/acpi/acpi_generic_initiator.h deleted +0
-24@@ -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 include/hw/acpi/pci.h +3
-0@@ -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 hw/acpi/acpi_generic_initiator.c deleted +0
-120@@ -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); -}hw/acpi/pci.c +124
-0@@ -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); +}hw/arm/virt-acpi-build.c +0
-1@@ -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" hw/i386/acpi-build.c +0
-1@@ -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" hw/acpi/meson.build +0
-1@@ -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',
Re: [PATCH v5 06/13] acpi/pci: Move Generic Initiator object handling into acpi/pci.*
In reply to Jonathan CameronQuoted 6 lines · On Fri, 12 Jul 2024 12:08:10 +0100 Jonathan Cameron…
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.cfile and header. If support for ACPI Device Handles is added in the future, perhaps this will be moved again.
Quoted 6 lines
Also push the struct AcpiGenericInitiator down into the c file as not used outside
pci.c.Suggested-by Igor Mammedov <[email protected]>Tested-by "Huang, Ying" <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>
Quoted 359 lines
---
v5: Carry forward changes from previous patch.
Move theTYPE_ACPI_GENERIC_INTIATORdefine down into the c file along with includeqom/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(-)include/hw/acpi/acpi_generic_initiator.h deleted +0
-24@@ -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 include/hw/acpi/pci.h +3
-0@@ -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 hw/acpi/acpi_generic_initiator.c deleted +0
-120@@ -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); -}hw/acpi/pci.c +124
-0@@ -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); +}hw/arm/virt-acpi-build.c +0
-1@@ -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" hw/i386/acpi-build.c +0
-1@@ -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" hw/acpi/meson.build +0
-1@@ -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',
PATCH v5 7/13 hw/pci-bridge: Add acpi_uid property to TYPE_PXB_BUS
In reply to Jonathan CameronEnable ACPI table creation for PCI Expander Bridges to be independent of PCI internals. Note that the UID is currently the PCI bus number. This is motivated by the forthcoming ACPI Generic Port SRAT entries which can be made completely independent of PCI internals.
---
v5: Add missing property description.
--- hw/pci-bridge/pci_expander_bridge.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
hw/pci-bridge/pci_expander_bridge.c +13 -0
@@ -85,12 +85,25 @@ static uint16_t pxb_bus_numa_node(PCIBus *bus)return pxb->numa_node; } +static void prop_pxb_uid_get (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) +{ +uint32_t uid =pci_bus_num (PCI_BUS (obj)); + +visit_type_uint32 (v, name, &uid, errp); +} +static void pxb_bus_class_init (ObjectClass *class,void *data) {PCIBusClass *pbc =PCI_BUS_CLASS (class); pbc->bus_num = pxb_bus_num; pbc->numa_node = pxb_bus_numa_node; + +object_class_property_add (class,"acpi_uid" ,"uint32" , + prop_pxb_uid_get,NULL ,NULL ,NULL ); +object_class_property_set_description (class,"acpi_uid" , +"ACPI Unique ID used to distinguish this PCI Host Bridge / ACPI00016" ); }static const TypeInfo pxb_bus_info = {
Signature · 1 line
2.43.0
Re: [PATCH v5 07/13] hw/pci-bridge: Add acpi_uid property to TYPE_PXB_BUS
Quoted 9 lines · On Fri, 12 Jul 2024 12:08:11 +0100 Jonathan Cameron…
Enable ACPI table creation for PCI Expander Bridges to be independent of PCI internals. Note that the UID is currently the PCI bus number. This is motivated by the forthcoming ACPI Generic Port SRAT entries which can be made completely independent of PCI internals.
Suggested-by Igor Mammedov <[email protected]>Tested-by "Huang, Ying" <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>
Quoted 36 lines
---
v5: Add missing property description.--- hw/pci-bridge/pci_expander_bridge.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)hw/pci-bridge/pci_expander_bridge.c +13
-0@@ -85,12 +85,25 @@ static uint16_t pxb_bus_numa_node(PCIBus *bus)return pxb->numa_node; } +static void prop_pxb_uid_get (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) +{ +uint32_t uid =pci_bus_num (PCI_BUS (obj)); + +visit_type_uint32 (v, name, &uid, errp); +} +static void pxb_bus_class_init (ObjectClass *class,void *data) {PCIBusClass *pbc =PCI_BUS_CLASS (class); pbc->bus_num = pxb_bus_num; pbc->numa_node = pxb_bus_numa_node; + +object_class_property_add (class,"acpi_uid" ,"uint32" , + prop_pxb_uid_get,NULL ,NULL ,NULL ); +object_class_property_set_description (class,"acpi_uid" , +"ACPI Unique ID used to distinguish this PCI Host Bridge / ACPI00016" ); }static const TypeInfo pxb_bus_info = {
PATCH v5 8/13 hw/i386/acpi: Use TYPE_PXB_BUS property acpi_uid for DSDT
In reply to Jonathan CameronRather than relying on PCI internals, use the new acpi_property to obtain the ACPI _UID values. These are still the same as the PCI Bus numbers so no functional change.
---
v5: Leave the device naming as using bus_num so that we can
relax assumption of the UID being only 8 bits (it is but we don't need to assume that)
--- hw/i386/acpi-build.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
hw/i386/acpi-build.c +4 -1
@@ -1550,6 +1550,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, QLIST_FOREACH(bus, &bus->child, sibling) {uint8_t bus_num =pci_bus_num (bus);uint8_t numa_node =pci_bus_numa_node (bus); +uint32_t uid;/* look only for expander root buses */ if (!pci_bus_is_root (bus)) {
@@ -1560,6 +1561,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, root_bus_limit = bus_num -1 ; } + uid =object_property_get_uint (OBJECT (bus),"acpi_uid" , + &error_fatal); scope =aml_scope ("\\_SB" );if (pci_bus_is_cxl (bus)) {
@@ -1567,7 +1570,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, }else { dev =aml_device ("PC%.02X" , bus_num); } -aml_append (dev,aml_name_decl ("_UID" ,aml_int (bus_num))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (uid)));aml_append (dev,aml_name_decl ("_BBN" ,aml_int (bus_num)));if (pci_bus_is_cxl (bus)) {struct Aml *aml_pkg =aml_package (2 );
Signature · 1 line
2.43.0
Re: [PATCH v5 08/13] hw/i386/acpi: Use TYPE_PXB_BUS property acpi_uid for DSDT
Quoted 7 lines · On Fri, 12 Jul 2024 12:08:12 +0100 Jonathan Cameron…
Rather than relying on PCI internals, use the new
acpi_propertyto obtain the ACPI_UIDvalues. These are still the same as the PCI Bus numbers so no functional change.Suggested-by Igor Mammedov <[email protected]>Tested-by "Huang, Ying" <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>
Quoted 38 lines
---
v5: Leave the device naming as usingbus_numso that we can
relax assumption of the UID being only 8 bits (it is but we don't need to assume that)--- hw/i386/acpi-build.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)hw/i386/acpi-build.c +4
-1@@ -1550,6 +1550,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, QLIST_FOREACH(bus, &bus->child, sibling) {uint8_t bus_num =pci_bus_num (bus);uint8_t numa_node =pci_bus_numa_node (bus); +uint32_t uid;/* look only for expander root buses */ if (!pci_bus_is_root (bus)) {@@ -1560,6 +1561,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, root_bus_limit = bus_num -1 ; } + uid =object_property_get_uint (OBJECT (bus),"acpi_uid" , + &error_fatal); scope =aml_scope ("\\_SB" );if (pci_bus_is_cxl (bus)) {@@ -1567,7 +1570,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, }else { dev =aml_device ("PC%.02X" , bus_num); } -aml_append (dev,aml_name_decl ("_UID" ,aml_int (bus_num))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (uid)));aml_append (dev,aml_name_decl ("_BBN" ,aml_int (bus_num)));if (pci_bus_is_cxl (bus)) {struct Aml *aml_pkg =aml_package (2 );
PATCH v5 9/13 hw/pci-host/gpex-acpi: Use acpi_uid property.
In reply to Jonathan CameronReduce the direct use of PCI internals inside ACPI table creation.
---
v5: Similar to previous, use bus number, not uid in ACPI device naming so
that uid can be 32 bits and we don't need checks to ensure it is only 8 bits. Not change to the actual numbers as the UID == bus_num
--- hw/pci-host/gpex-acpi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
hw/pci-host/gpex-acpi.c +4 -1
@@ -140,6 +140,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) QLIST_FOREACH(bus, &bus->child, sibling) {uint8_t bus_num =pci_bus_num (bus);uint8_t numa_node =pci_bus_numa_node (bus); +uint32_t uid;bool is_cxl =pci_bus_is_cxl (bus);if (!pci_bus_is_root (bus)) {
@@ -155,6 +156,8 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) nr_pcie_buses = bus_num; } + uid =object_property_get_uint (OBJECT (bus),"acpi_uid" , + &error_fatal); dev =aml_device ("PC%.02X" , bus_num);if (is_cxl) {struct Aml *pkg =aml_package (2 );
@@ -167,7 +170,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)aml_append (dev,aml_name_decl ("_CID" ,aml_string ("PNP0A03" ))); }aml_append (dev,aml_name_decl ("_BBN" ,aml_int (bus_num))); -aml_append (dev,aml_name_decl ("_UID" ,aml_int (bus_num))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (uid)));aml_append (dev,aml_name_decl ("_STR" ,aml_unicode ("pxb Device" )));aml_append (dev,aml_name_decl ("_CCA" ,aml_int (1 )));if (numa_node !=NUMA_NODE_UNASSIGNED ) {
Signature · 1 line
2.43.0
Re: [PATCH v5 09/13] hw/pci-host/gpex-acpi: Use acpi_uid property.
Quoted 5 lines · On Fri, 12 Jul 2024 12:08:13 +0100 Jonathan Cameron…
Reduce the direct use of PCI internals inside ACPI table creation.
Suggested-by Igor Mammedov <[email protected]>Tested-by "Huang, Ying" <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>
Quoted 38 lines
---
v5: Similar to previous, use bus number, not uid in ACPI device naming so
that uid can be 32 bits and we don't need checks to ensure it is only 8 bits. Not change to the actual numbers as the UID ==bus_num--- hw/pci-host/gpex-acpi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)hw/pci-host/gpex-acpi.c +4
-1@@ -140,6 +140,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) QLIST_FOREACH(bus, &bus->child, sibling) {uint8_t bus_num =pci_bus_num (bus);uint8_t numa_node =pci_bus_numa_node (bus); +uint32_t uid;bool is_cxl =pci_bus_is_cxl (bus);if (!pci_bus_is_root (bus)) {@@ -155,6 +156,8 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) nr_pcie_buses = bus_num; } + uid =object_property_get_uint (OBJECT (bus),"acpi_uid" , + &error_fatal); dev =aml_device ("PC%.02X" , bus_num);if (is_cxl) {struct Aml *pkg =aml_package (2 );@@ -167,7 +170,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)aml_append (dev,aml_name_decl ("_CID" ,aml_string ("PNP0A03" ))); }aml_append (dev,aml_name_decl ("_BBN" ,aml_int (bus_num))); -aml_append (dev,aml_name_decl ("_UID" ,aml_int (bus_num))); +aml_append (dev,aml_name_decl ("_UID" ,aml_int (uid)));aml_append (dev,aml_name_decl ("_STR" ,aml_unicode ("pxb Device" )));aml_append (dev,aml_name_decl ("_CCA" ,aml_int (1 )));if (numa_node !=NUMA_NODE_UNASSIGNED ) {
PATCH v5 10/13 hw/acpi: Generic Port Affinity Structure support
In reply to Jonathan CameronThese are very similar to the recently added Generic Initiators but instead of representing an initiator of memory traffic they represent an edge point beyond which may lie either targets or initiators. Here we add these ports such that they may be targets of hmat_lb records to describe the latency and bandwidth from host side initiators to the port. A discoverable mechanism such as UEFI CDAT read from CXL devices and switches is used to discover the remainder of the path, and the OS can build up full latency and bandwidth numbers as need for work and data placement decisions.
---
v5: Push the definition of TYPE_ACPI_GENERIC_PORT down into the
c file (similar to TYPE_ACPI_GENERIC_INITIATOR in earlier patch)
--- qapi/qom.json | 34 +++++++++ include/hw/acpi/aml-build.h | 4 + include/hw/acpi/pci.h | 2 +- include/hw/pci/pci_bridge.h | 1 + hw/acpi/aml-build.c | 40 ++++++++++ hw/acpi/pci.c | 112 +++++++++++++++++++++++++++- hw/arm/virt-acpi-build.c | 2 +- hw/i386/acpi-build.c | 2 +- hw/pci-bridge/pci_expander_bridge.c | 1 - 9 files changed, 193 insertions(+), 5 deletions(-)
qapi/qom.json +34 -0
@@ -838,6 +838,38 @@ 'data': { 'pci-dev': 'str', 'node': 'uint32' } } +## +# @AcpiGenericPortProperties: +# +# Properties for acpi-generic-port objects. +# +# @pci-bus: QOM path of the PCI bus of the hostbridge associated with +# this SRAT Generic Port Affinity Structure. This is the same as +# the bus parameter for the root ports attached to this host +# bridge. The resulting SRAT Generic Port Affinity Structure will +# refer to the ACPI object in DSDT that represents the host bridge +# (e.g. ACPI0016 for CXL host bridges). See ACPI 6.5 Section +# 5.2.16.7 for more information. +# +# @node: Similar to a NUMA node ID, but instead of providing a +# reference point used for defining NUMA distances and access +# characteristics to memory or from an initiator (e.g. CPU), this +# node defines the boundary point between non-discoverable system +# buses which must be described by firmware, and a discoverable +# bus. NUMA distances and access characteristics are defined to +# and from that point. For system software to establish full +# initiator to target characteristics this information must be +# combined with information retrieved from the discoverable part +# of the path. An example would use CDAT (see UEFI.org) +# information read from devices and switches in conjunction with +# link characteristics read from PCIe Configuration space. +# +# Since: 9.1 +## +{ 'struct': 'AcpiGenericPortProperties', + 'data': { 'pci-bus': 'str', + 'node': 'uint32' } } + ## # @RngProperties: #
@@ -1031,6 +1063,7 @@ { 'enum': 'ObjectType', 'data': [ 'acpi-generic-initiator', + 'acpi-generic-port', 'authz-list', 'authz-listfile', 'authz-pam',
@@ -1106,6 +1139,7 @@ 'discriminator': 'qom-type', 'data': { 'acpi-generic-initiator': 'AcpiGenericInitiatorProperties', + 'acpi-generic-port': 'AcpiGenericPortProperties', 'authz-list': 'AuthZListProperties', 'authz-listfile': 'AuthZListFileProperties', 'authz-pam': 'AuthZPAMProperties',
include/hw/acpi/aml-build.h +4 -0
@@ -490,6 +490,10 @@ void build_srat_pci_generic_initiator(GArray *table_data, int node, uint16_t segment, uint8_t bus, uint8_t devfn); +void build_srat_acpi_generic_port (GArray *table_data,int node, +const char *hid, +uint32_t uid); +void build_slit (GArray *table_data,BIOSLinker *linker,MachineState *ms,const char *oem_id,const char *oem_table_id);
include/hw/acpi/pci.h +1 -1
@@ -41,6 +41,6 @@ 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); +void build_srat_generic_affinity_structures (GArray *table_data);#endif
include/hw/pci/pci_bridge.h +1 -0
@@ -102,6 +102,7 @@ typedef struct PXBPCIEDev {PXBDev parent_obj; } PXBPCIEDev; +#define TYPE_PXB_CXL_BUS "pxb-cxl-bus"#define TYPE_PXB_DEV "pxb"OBJECT_DECLARE_SIMPLE_TYPE (PXBDev,PXB_DEV )
hw/acpi/aml-build.c +40 -0
@@ -1955,6 +1955,19 @@ static void build_append_srat_pci_device_handle(GArray *table_data,build_append_int_noprefix (table_data,0 ,12 ); } +static void build_append_srat_acpi_device_handle (GArray *table_data, +const char *hid, +uint32_t uid) +{ +assert (strlen (hid) ==8 ); +/* Device Handle - ACPI */ +for (int i =0 ; i <sizeof (hid); i++) { +build_append_int_noprefix (table_data, hid[i],1 ); + } +build_append_int_noprefix (table_data, uid,4 ); +build_append_int_noprefix (table_data,0 ,4 ); +} +/* * ACPI spec, Revision 6.3 * 5.2.16.6 Generic Initiator Affinity Structure
@@ -1982,6 +1995,33 @@ void build_srat_pci_generic_initiator(GArray *table_data, int node,build_append_int_noprefix (table_data,0 ,4 ); } +/* +* ACPI spec, Revision 6.5 +* 5.2.16.7 Generic Port Affinity Structure +* With ACPI Device Handle. +*/ +void build_srat_acpi_generic_port (GArray *table_data,int node, +const char *hid, +uint32_t uid) +{ +/* Type */ +build_append_int_noprefix (table_data,6 ,1 ); +/* Length */ +build_append_int_noprefix (table_data,32 ,1 ); +/* Reserved */ +build_append_int_noprefix (table_data,0 ,1 ); +/* Device Handle Type: ACPI */ +build_append_int_noprefix (table_data,0 ,1 ); +/* Proximity Domain */ +build_append_int_noprefix (table_data, node,4 ); +/* Device Handle */ +build_append_srat_acpi_device_handle (table_data, hid, uid); +/* Flags - GP Enabled */ +build_append_int_noprefix (table_data,1 ,4 ); +/* Reserved */ +build_append_int_noprefix (table_data,0 ,4 ); +} +/* * ACPI spec 5.2.17 System Locality Distance Information Table * (Revision 2.0 or later)
hw/acpi/pci.c +111 -1
126 lines not on this page · raw message
hw/arm/virt-acpi-build.c +1 -1
@@ -510,7 +510,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) } } -build_srat_generic_pci_initiator (table_data); +build_srat_generic_affinity_structures (table_data);if (ms->nvdimms_state->is_enabled) {nvdimm_build_srat (table_data);
hw/i386/acpi-build.c +1 -1
@@ -2048,7 +2048,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)build_srat_memory (table_data,0 ,0 ,0 ,MEM_AFFINITY_NOFLAGS ); } -build_srat_generic_pci_initiator (table_data); +build_srat_generic_affinity_structures (table_data);/* * Entry is required for Windows to enable memory hotplug in OS
hw/pci-bridge/pci_expander_bridge.c +0 -1
@@ -38,7 +38,6 @@ DECLARE_INSTANCE_CHECKER(PXBBus, PXB_BUS,DECLARE_INSTANCE_CHECKER (PXBBus,PXB_PCIE_BUS , TYPE_PXB_PCIE_BUS) -#define TYPE_PXB_CXL_BUS "pxb-cxl-bus"DECLARE_INSTANCE_CHECKER (PXBBus,PXB_CXL_BUS ,TYPE_PXB_CXL_BUS )
Signature · 1 line
2.43.0
Re: [PATCH v5 10/13] hw/acpi: Generic Port Affinity Structure support
Quoted 11 lines · On Fri, 12 Jul 2024 12:08:14 +0100 Jonathan Cameron…
These are very similar to the recently added Generic Initiators but instead of representing an initiator of memory traffic they represent an edge point beyond which may lie either targets or initiators. Here we add these ports such that they may be targets of
hmat_lbrecords to describe the latency and bandwidth from host side initiators to the port. A discoverable mechanism such as UEFI CDAT read from CXL devices and switches is used to discover the remainder of the path, and the OS can build up full latency and bandwidth numbers as need for work and data placement decisions.
Quoted 3 lines
Tested-by "Huang, Ying" <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>
ACPI tables generation LGTM
As for the rest my review is perfunctory mostly.
Quoted 39 lines
---
v5: Push the definition ofTYPE_ACPI_GENERIC_PORTdown into the
c file (similar toTYPE_ACPI_GENERIC_INITIATORin earlier patch)--- qapi/qom.json | 34 +++++++++ include/hw/acpi/aml-build.h | 4 + include/hw/acpi/pci.h | 2 +- include/hw/pci/pci_bridge.h | 1 + hw/acpi/aml-build.c | 40 ++++++++++ hw/acpi/pci.c | 112 +++++++++++++++++++++++++++- hw/arm/virt-acpi-build.c | 2 +- hw/i386/acpi-build.c | 2 +- hw/pci-bridge/pci_expander_bridge.c | 1 - 9 files changed, 193 insertions(+), 5 deletions(-)qapi/qom.json +15
-0@@ -838,6 +838,38 @@ 'data': { 'pci-dev': 'str', 'node': 'uint32' } } +## +# @AcpiGenericPortProperties: +# +# Properties for acpi-generic-port objects. +# +# @pci-bus: QOM path of the PCI bus of the hostbridge associated with +# this SRAT Generic Port Affinity Structure. This is the same as +# the bus parameter for the root ports attached to this host +# bridge. The resulting SRAT Generic Port Affinity Structure will +# refer to the ACPI object in DSDT that represents the host bridge +# (e.g. ACPI0016 for CXL host bridges). See ACPI 6.5 Section +# 5.2.16.7 for more information. +# +# @node: Similar to a NUMA node ID, but instead of providing a +# reference point used for defining NUMA distances and access
qapi/qom.json line 866
Quoted 10 lines
qapi/qom.json +10
-0+# characteristics to memory or from an initiator (e.g. CPU), this +# node defines the boundary point between non-discoverable system +# buses which must be described by firmware, and a discoverable +# bus. NUMA distances and access characteristics are defined to +# and from that point. For system software to establish full +# initiator to target characteristics this information must be +# combined with information retrieved from the discoverable part +# of the path. An example would use CDAT (see UEFI.org) +# information read from devices and switches in conjunction with +# link characteristics read from PCIe Configuration space.
you lost me here (even reading this several time doesn't help). Perhaps I lack specific domain knowledge, but is there a way to make it more comprehensible for layman?
Quoted 90 lines
qapi/qom.json +7
-0+# +# Since: 9.1 +## +{ 'struct': 'AcpiGenericPortProperties', + 'data': { 'pci-bus': 'str', + 'node': 'uint32' } } + ## # @RngProperties:#
qapi/qom.json +2
-0@@ -1031,6 +1063,7 @@ { 'enum': 'ObjectType', 'data': [ 'acpi-generic-initiator', + 'acpi-generic-port', 'authz-list', 'authz-listfile', 'authz-pam',@@ -1106,6 +1139,7 @@ 'discriminator': 'qom-type', 'data': { 'acpi-generic-initiator': 'AcpiGenericInitiatorProperties', + 'acpi-generic-port': 'AcpiGenericPortProperties', 'authz-list': 'AuthZListProperties', 'authz-listfile': 'AuthZListFileProperties', 'authz-pam': 'AuthZPAMProperties',include/hw/acpi/aml-build.h +4
-0@@ -490,6 +490,10 @@ void build_srat_pci_generic_initiator(GArray *table_data, int node, uint16_t segment, uint8_t bus, uint8_t devfn); +void build_srat_acpi_generic_port (GArray *table_data,int node, +const char *hid, +uint32_t uid); +void build_slit (GArray *table_data,BIOSLinker *linker,MachineState *ms,const char *oem_id,const char *oem_table_id);include/hw/acpi/pci.h +1
-1@@ -41,6 +41,6 @@ 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); +void build_srat_generic_affinity_structures (GArray *table_data);#endif include/hw/pci/pci_bridge.h +1
-0@@ -102,6 +102,7 @@ typedef struct PXBPCIEDev {PXBDev parent_obj; } PXBPCIEDev; +#define TYPE_PXB_CXL_BUS "pxb-cxl-bus"#define TYPE_PXB_DEV "pxb"OBJECT_DECLARE_SIMPLE_TYPE (PXBDev,PXB_DEV )hw/acpi/aml-build.c +13
-0@@ -1955,6 +1955,19 @@ static void build_append_srat_pci_device_handle(GArray *table_data,build_append_int_noprefix (table_data,0 ,12 ); } +static void build_append_srat_acpi_device_handle (GArray *table_data, +const char *hid, +uint32_t uid) +{ +assert (strlen (hid) ==8 ); +/* Device Handle - ACPI */ +for (int i =0 ; i <sizeof (hid); i++) { +build_append_int_noprefix (table_data, hid[i],1 ); + } +build_append_int_noprefix (table_data, uid,4 ); +build_append_int_noprefix (table_data,0 ,4 ); +} +/* * ACPI spec, Revision 6.3 * 5.2.16.6 Generic Initiator Affinity Structure
hw/acpi/aml-build.c void build_srat_pci_generic_initiator(GArray *table_data, int node, · line 2003
Quoted 9 lines
hw/acpi/aml-build.c +6
-0@@ -1982,6 +1995,33 @@ void build_srat_pci_generic_initiator(GArray *table_data, int node,build_append_int_noprefix (table_data,0 ,4 ); } +/* +* ACPI spec, Revision 6.5 +* 5.2.16.7 Generic Port Affinity Structure +* With ACPI Device Handle. +*/ +void build_srat_acpi_generic_port(GArray *table_data, int node,
shouldn't node be uint32_t?
Quoted 38 lines
hw/acpi/aml-build.c +21
-0+const char *hid, + uint32_t uid) +{ +/* Type */ + build_append_int_noprefix(table_data, 6, 1); +/* Length */ +build_append_int_noprefix (table_data,32 ,1 ); +/* Reserved */ +build_append_int_noprefix (table_data,0 ,1 ); +/* Device Handle Type: ACPI */ +build_append_int_noprefix (table_data,0 ,1 ); +/* Proximity Domain */ +build_append_int_noprefix (table_data, node,4 ); +/* Device Handle */ +build_append_srat_acpi_device_handle (table_data, hid, uid); +/* Flags - GP Enabled */ +build_append_int_noprefix (table_data,1 ,4 ); +/* Reserved */ +build_append_int_noprefix (table_data,0 ,4 ); +} +/* * ACPI spec 5.2.17 System Locality Distance Information Table * (Revision 2.0 or later) hw/acpi/pci.c +1
-0@@ -30,6 +30,7 @@#include "hw/boards.h" #include "hw/acpi/aml-build.h" #include "hw/acpi/pci.h" +#include "hw/pci/pci_bridge.h" #include "hw/pci/pci_device.h" #include "hw/pci/pcie_host.h" @@ -177,9 +178,118 @@ static int build_acpi_generic_initiator(Object *obj, void *opaque)return 0 ;
hw/acpi/pci.c static int build_acpi_generic_initiator(Object *obj, void *opaque) · line 187
Quoted 10 lines
hw/acpi/pci.c +7
-1} -void build_srat_generic_pci_initiator (GArray *table_data) +typedef struct AcpiGenericPort { + /* private */ + Object parent; + + /* public */ + char *pci_bus; + uint16_t node;
ditto
Quoted 46 lines
hw/acpi/pci.c +46
-0+} AcpiGenericPort; + +typedef struct AcpiGenericPortClass { +ObjectClass parent_class; +}AcpiGenericPortClass ; + +#define TYPE_ACPI_GENERIC_PORT "acpi-generic-port" + +OBJECT_DEFINE_TYPE_WITH_INTERFACES (AcpiGenericPort, acpi_generic_port, +ACPI_GENERIC_PORT ,OBJECT , + { TYPE_USER_CREATABLE }, + { NULL }) + +OBJECT_DECLARE_SIMPLE_TYPE(AcpiGenericPort, ACPI_GENERIC_PORT) + +static void acpi_generic_port_init (Object *obj) +{ +AcpiGenericPort *gp =ACPI_GENERIC_PORT (obj); + + gp->node =MAX_NODES ; + gp->pci_bus =NULL ; +} + +static void acpi_generic_port_finalize (Object *obj) +{ +AcpiGenericPort *gp =ACPI_GENERIC_PORT (obj); + +g_free (gp->pci_bus); +} + +static void acpi_generic_port_set_pci_bus (Object *obj,const char *val, +Error **errp) +{ +AcpiGenericPort *gp =ACPI_GENERIC_PORT (obj); + + gp->pci_bus =g_strdup (val); +} + +static void acpi_generic_port_set_node (Object *obj,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +AcpiGenericPort *gp =ACPI_GENERIC_PORT (obj); +uint32_t value; + +if (!visit_type_uint32 (v, name, &value, errp)) {
hw/acpi/pci.c static int build_acpi_generic_initiator(Object *obj, void *opaque) · line 243
Quoted 10 lines
hw/acpi/pci.c +10
-0+return ; + } + +if (value >=MAX_NODES ) { +error_printf ("%s: Invalid NUMA node specified\n" , +TYPE_ACPI_GENERIC_INITIATOR ); +exit (1 ); + } + + gp->node = value;
as long as gp->node is uint32_t it should be fine. otherwise it's too fragile.
hw/acpi/pci.c static int build_acpi_generic_initiator(Object *obj, void *opaque) · line 251
Quoted 8 lines
hw/acpi/pci.c +8
-0+} + +static void acpi_generic_port_class_init (ObjectClass *oc,void *data) +{ +object_class_property_add_str (oc,"pci-bus" ,NULL , + acpi_generic_port_set_pci_bus); +object_class_property_add (oc,"node" ,"int" ,NULL , + acpi_generic_port_set_node,NULL ,NULL );
missing property description calls.
Quoted 12 lines
hw/acpi/pci.c +12
-0+} + +static int build_acpi_generic_port (Object *obj,void *opaque) +{ +MachineState *ms =MACHINE (qdev_get_machine ()); +const char *hid ="ACPI0016" ; +GArray *table_data = opaque; +AcpiGenericPort *gp; +uint32_t uid; +Object *o; + +if (!object_dynamic_cast (obj,TYPE_ACPI_GENERIC_PORT )) {
hw/acpi/pci.c static int build_acpi_generic_initiator(Object *obj, void *opaque) · line 272
Quoted 10 lines
hw/acpi/pci.c +9
-0+return 0 ; + } + + gp =ACPI_GENERIC_PORT (obj); + +if (gp->node >= ms->numa_state->num_nodes) { +error_printf ("%s: node %d is invalid.\n" , +TYPE_ACPI_GENERIC_PORT , gp->node); +exit (1 );
not sure,
maybe use error_fatal instead of using exit(1)?
CCing Markus to check if it's ok.
hw/acpi/pci.c static int build_acpi_generic_initiator(Object *obj, void *opaque) · line 280
Quoted 8 lines
hw/acpi/pci.c +8
-0+ } + + o =object_resolve_path_type (gp->pci_bus,TYPE_PXB_CXL_BUS ,NULL ); +if (!o) { +error_printf ("%s: device must be a CXL host bridge.\n" , +TYPE_ACPI_GENERIC_PORT ); +exit (1 ); + }
ditto
Quoted 53 lines
hw/acpi/pci.c +10
-0+ + uid =object_property_get_uint (o,"acpi_uid" , &error_fatal); +build_srat_acpi_generic_port (table_data, gp->node, hid, uid); + +return 0 ; +} + +void build_srat_generic_affinity_structures (GArray *table_data) {object_child_foreach_recursive (object_get_root (), build_acpi_generic_initiator, table_data); +object_child_foreach_recursive (object_get_root (), build_acpi_generic_port, + table_data);}
hw/arm/virt-acpi-build.c +1
-1@@ -510,7 +510,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) } } -build_srat_generic_pci_initiator (table_data); +build_srat_generic_affinity_structures (table_data);if (ms->nvdimms_state->is_enabled) {nvdimm_build_srat (table_data);hw/i386/acpi-build.c +1
-1@@ -2048,7 +2048,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)build_srat_memory (table_data,0 ,0 ,0 ,MEM_AFFINITY_NOFLAGS ); } -build_srat_generic_pci_initiator (table_data); +build_srat_generic_affinity_structures (table_data);/* * Entry is required for Windows to enable memory hotplug in OS hw/pci-bridge/pci_expander_bridge.c +0
-1@@ -38,7 +38,6 @@ DECLARE_INSTANCE_CHECKER(PXBBus, PXB_BUS,DECLARE_INSTANCE_CHECKER (PXBBus,PXB_PCIE_BUS , TYPE_PXB_PCIE_BUS) -#define TYPE_PXB_CXL_BUS "pxb-cxl-bus"DECLARE_INSTANCE_CHECKER (PXBBus,PXB_CXL_BUS ,TYPE_PXB_CXL_BUS )
Re: [PATCH v5 10/13] hw/acpi: Generic Port Affinity Structure support
Quoted 14 lines · On Mon, 15 Jul 2024 16:48:41 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 11 lines · On Fri, 12 Jul 2024 12:08:14 +0100 Jonathan Cameron…
These are very similar to the recently added Generic Initiators but instead of representing an initiator of memory traffic they represent an edge point beyond which may lie either targets or initiators. Here we add these ports such that they may be targets of
hmat_lbrecords to describe the latency and bandwidth from host side initiators to the port. A discoverable mechanism such as UEFI CDAT read from CXL devices and switches is used to discover the remainder of the path, and the OS can build up full latency and bandwidth numbers as need for work and data placement decisions.
Quoted 6 lines
Quoted 3 lines
Tested-by "Huang, Ying" <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>ACPI tables generation LGTM
As for the rest my review is perfunctory mostly.
The node type points and missing descriptor applying equally to generic initiators. I'll add a couple of patches cleaning that up as well as fixing them up for generic ports.
For the exit(1) that was copying other similar locations. I don't mind changing it though if something else is preferred.
Given tight timescales (and I was away for a few days which didn't help), I'll send out a v6 with changes as below.
Jonathan
Quoted 38 lines
Quoted 37 lines
---
v5: Push the definition ofTYPE_ACPI_GENERIC_PORTdown into the
c file (similar toTYPE_ACPI_GENERIC_INITIATORin earlier patch)--- qapi/qom.json | 34 +++++++++ include/hw/acpi/aml-build.h | 4 + include/hw/acpi/pci.h | 2 +- include/hw/pci/pci_bridge.h | 1 + hw/acpi/aml-build.c | 40 ++++++++++ hw/acpi/pci.c | 112 +++++++++++++++++++++++++++- hw/arm/virt-acpi-build.c | 2 +- hw/i386/acpi-build.c | 2 +- hw/pci-bridge/pci_expander_bridge.c | 1 - 9 files changed, 193 insertions(+), 5 deletions(-)qapi/qom.json +13
-0@@ -838,6 +838,38 @@ 'data': { 'pci-dev': 'str', 'node': 'uint32' } } +## +# @AcpiGenericPortProperties: +# +# Properties for acpi-generic-port objects. +# +# @pci-bus: QOM path of the PCI bus of the hostbridge associated with +# this SRAT Generic Port Affinity Structure. This is the same as +# the bus parameter for the root ports attached to this host +# bridge. The resulting SRAT Generic Port Affinity Structure will +# refer to the ACPI object in DSDT that represents the host bridge +# (e.g. ACPI0016 for CXL host bridges). See ACPI 6.5 Section +# 5.2.16.7 for more information. +#
Quoted 16 lines
qapi/qom.json line 865
Quoted 12 lines
qapi/qom.json +12
-0+# @node: Similar to a NUMA node ID, but instead of providing a +# reference point used for defining NUMA distances and access +# characteristics to memory or from an initiator (e.g. CPU), this +# node defines the boundary point between non-discoverable system +# buses which must be described by firmware, and a discoverable +# bus. NUMA distances and access characteristics are defined to +# and from that point. For system software to establish full +# initiator to target characteristics this information must be +# combined with information retrieved from the discoverable part +# of the path. An example would use CDAT (see UEFI.org) +# information read from devices and switches in conjunction with +# link characteristics read from PCIe Configuration space.you lost me here (even reading this several time doesn't help). Perhaps I lack specific domain knowledge, but is there a way to make it more comprehensible for layman?
This is far from the first version (which Markus really didn't like ;) It is really easy to draw as a sequence of diagrams and really tricky to put in text! Not so easy to get the kernel code right either as it turns out but that's another story.
Perhaps if I add something to the end to say what you do with it that might help?
"To get the full path latency, from CPU to CXL attached DRAM on a type 3
CXL device: Add the latency from CPU to Generic Port (from HMAT indexed via the the node ID in this SRAT structure) to that for CXL bus links, the latency across intermediate switches and from the EP port to the actual memory. Bandwidth is more complex as there may be interleaving across multiple devices and shared links in the path."
Quoted 8 lines
Quoted 8 lines
qapi/qom.json +7
-0+# +# Since: 9.1 +## +{ 'struct': 'AcpiGenericPortProperties', + 'data': { 'pci-bus': 'str', + 'node': 'uint32' } } +
Re: [PATCH v5 10/13] hw/acpi: Generic Port Affinity Structure support
Quoted 28 lines · Jonathan Cameron
Quoted 14 lines · On Mon, 15 Jul 2024 16:48:41 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 11 lines · On Fri, 12 Jul 2024 12:08:14 +0100 Jonathan Cameron…
These are very similar to the recently added Generic Initiators but instead of representing an initiator of memory traffic they represent an edge point beyond which may lie either targets or initiators. Here we add these ports such that they may be targets of
hmat_lbrecords to describe the latency and bandwidth from host side initiators to the port. A discoverable mechanism such as UEFI CDAT read from CXL devices and switches is used to discover the remainder of the path, and the OS can build up full latency and bandwidth numbers as need for work and data placement decisions.Quoted 6 lines
Quoted 3 lines
Tested-by "Huang, Ying" <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>ACPI tables generation LGTM
As for the rest my review is perfunctory mostly.The node type points and missing descriptor applying equally to generic initiators. I'll add a couple of patches cleaning that up as well as fixing them up for generic ports.
Quoted 8 lines
For the exit(1) that was copying other similar locations. I don't mind changing it though if something else is preferred.
Given tight timescales (and I was away for a few days which didn't help), I'll send out a v6 with changes as below.
Jonathan
I'm working on a pull and going offline for a week guys, what's not in will be in the next release. Sorry.
Quoted 79 lines
Quoted 38 lines
Quoted 37 lines
---
v5: Push the definition ofTYPE_ACPI_GENERIC_PORTdown into the
c file (similar toTYPE_ACPI_GENERIC_INITIATORin earlier patch)--- qapi/qom.json | 34 +++++++++ include/hw/acpi/aml-build.h | 4 + include/hw/acpi/pci.h | 2 +- include/hw/pci/pci_bridge.h | 1 + hw/acpi/aml-build.c | 40 ++++++++++ hw/acpi/pci.c | 112 +++++++++++++++++++++++++++- hw/arm/virt-acpi-build.c | 2 +- hw/i386/acpi-build.c | 2 +- hw/pci-bridge/pci_expander_bridge.c | 1 - 9 files changed, 193 insertions(+), 5 deletions(-)qapi/qom.json +13
-0@@ -838,6 +838,38 @@ 'data': { 'pci-dev': 'str', 'node': 'uint32' } } +## +# @AcpiGenericPortProperties: +# +# Properties for acpi-generic-port objects. +# +# @pci-bus: QOM path of the PCI bus of the hostbridge associated with +# this SRAT Generic Port Affinity Structure. This is the same as +# the bus parameter for the root ports attached to this host +# bridge. The resulting SRAT Generic Port Affinity Structure will +# refer to the ACPI object in DSDT that represents the host bridge +# (e.g. ACPI0016 for CXL host bridges). See ACPI 6.5 Section +# 5.2.16.7 for more information. +#Quoted 16 lines
qapi/qom.json line 865
Quoted 12 lines
qapi/qom.json +12
-0+# @node: Similar to a NUMA node ID, but instead of providing a +# reference point used for defining NUMA distances and access +# characteristics to memory or from an initiator (e.g. CPU), this +# node defines the boundary point between non-discoverable system +# buses which must be described by firmware, and a discoverable +# bus. NUMA distances and access characteristics are defined to +# and from that point. For system software to establish full +# initiator to target characteristics this information must be +# combined with information retrieved from the discoverable part +# of the path. An example would use CDAT (see UEFI.org) +# information read from devices and switches in conjunction with +# link characteristics read from PCIe Configuration space.you lost me here (even reading this several time doesn't help). Perhaps I lack specific domain knowledge, but is there a way to make it more comprehensible for layman?
This is far from the first version (which Markus really didn't like ;) It is really easy to draw as a sequence of diagrams and really tricky to put in text! Not so easy to get the kernel code right either as it turns out but that's another story.
Perhaps if I add something to the end to say what you do with it that might help?
"To get the full path latency, from CPU to CXL attached DRAM on a type 3
CXL device: Add the latency from CPU to Generic Port (from HMAT indexed via the the node ID in this SRAT structure) to that for CXL bus links, the latency across intermediate switches and from the EP port to the actual memory. Bandwidth is more complex as there may be interleaving across multiple devices and shared links in the path."Quoted 8 lines
Quoted 8 lines
qapi/qom.json +7
-0+# +# Since: 9.1 +## +{ 'struct': 'AcpiGenericPortProperties', + 'data': { 'pci-bus': 'str', + 'node': 'uint32' } } +
Re: [PATCH v5 10/13] hw/acpi: Generic Port Affinity Structure support
Quoted 32 lines · On Wed, 17 Jul 2024 11:11:06 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 31 lines · Jonathan Cameron
Quoted 14 lines · On Mon, 15 Jul 2024 16:48:41 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 11 lines · On Fri, 12 Jul 2024 12:08:14 +0100 Jonathan Cameron…
These are very similar to the recently added Generic Initiators but instead of representing an initiator of memory traffic they represent an edge point beyond which may lie either targets or initiators. Here we add these ports such that they may be targets of
hmat_lbrecords to describe the latency and bandwidth from host side initiators to the port. A discoverable mechanism such as UEFI CDAT read from CXL devices and switches is used to discover the remainder of the path, and the OS can build up full latency and bandwidth numbers as need for work and data placement decisions.Quoted 6 lines
Quoted 3 lines
Tested-by "Huang, Ying" <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>ACPI tables generation LGTM
As for the rest my review is perfunctory mostly.The node type points and missing descriptor applying equally to generic initiators. I'll add a couple of patches cleaning that up as well as fixing them up for generic ports.
For the exit(1) that was copying other similar locations. I don't mind changing it though if something else is preferred.
Quoted 8 lines
Quoted 5 lines
Given tight timescales (and I was away for a few days which didn't help), I'll send out a v6 with changes as below.
Jonathan
I'm working on a pull and going offline for a week guys, what's not in will be in the next release. Sorry.
No problem. Thanks for letting us know!
In that case I'll sit on v6 for a while and hopefully we can get it lined up early next cycle without too much bios-tables test churn pain.
Jonathan
Re: [PATCH v5 10/13] hw/acpi: Generic Port Affinity Structure support
In reply to Igor MammedovQuoted 14 lines · On Mon, 15 Jul 2024 16:48:41 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 11 lines · On Fri, 12 Jul 2024 12:08:14 +0100 Jonathan Cameron…
These are very similar to the recently added Generic Initiators but instead of representing an initiator of memory traffic they represent an edge point beyond which may lie either targets or initiators. Here we add these ports such that they may be targets of
hmat_lbrecords to describe the latency and bandwidth from host side initiators to the port. A discoverable mechanism such as UEFI CDAT read from CXL devices and switches is used to discover the remainder of the path, and the OS can build up full latency and bandwidth numbers as need for work and data placement decisions.
Quoted 6 lines
Quoted 3 lines
Tested-by "Huang, Ying" <[email protected]>Signed-off-by Jonathan Cameron <[email protected]>ACPI tables generation LGTM
As for the rest my review is perfunctory mostly.
Hi Igor,
Given I guess we will soon be in the 9.2 cycle, revisiting this to prepare a v6.
Added missing parameter descriptions for properties in here and an additional patch for the ones missing for generic initiators. Another patch fixes the uint32_t fragilty you pointed out for generic initiators (fixed here as well)
2 things remain, the docs and the question you are asked Markus.
See inline.
Quoted 38 lines
Quoted 37 lines
---
v5: Push the definition ofTYPE_ACPI_GENERIC_PORTdown into the
c file (similar toTYPE_ACPI_GENERIC_INITIATORin earlier patch)--- qapi/qom.json | 34 +++++++++ include/hw/acpi/aml-build.h | 4 + include/hw/acpi/pci.h | 2 +- include/hw/pci/pci_bridge.h | 1 + hw/acpi/aml-build.c | 40 ++++++++++ hw/acpi/pci.c | 112 +++++++++++++++++++++++++++- hw/arm/virt-acpi-build.c | 2 +- hw/i386/acpi-build.c | 2 +- hw/pci-bridge/pci_expander_bridge.c | 1 - 9 files changed, 193 insertions(+), 5 deletions(-)qapi/qom.json +13
-0@@ -838,6 +838,38 @@ 'data': { 'pci-dev': 'str', 'node': 'uint32' } } +## +# @AcpiGenericPortProperties: +# +# Properties for acpi-generic-port objects. +# +# @pci-bus: QOM path of the PCI bus of the hostbridge associated with +# this SRAT Generic Port Affinity Structure. This is the same as +# the bus parameter for the root ports attached to this host +# bridge. The resulting SRAT Generic Port Affinity Structure will +# refer to the ACPI object in DSDT that represents the host bridge +# (e.g. ACPI0016 for CXL host bridges). See ACPI 6.5 Section +# 5.2.16.7 for more information. +#
Quoted 16 lines
qapi/qom.json line 865
Quoted 12 lines
qapi/qom.json +12
-0+# @node: Similar to a NUMA node ID, but instead of providing a +# reference point used for defining NUMA distances and access +# characteristics to memory or from an initiator (e.g. CPU), this +# node defines the boundary point between non-discoverable system +# buses which must be described by firmware, and a discoverable +# bus. NUMA distances and access characteristics are defined to +# and from that point. For system software to establish full +# initiator to target characteristics this information must be +# combined with information retrieved from the discoverable part +# of the path. An example would use CDAT (see UEFI.org) +# information read from devices and switches in conjunction with +# link characteristics read from PCIe Configuration space.you lost me here (even reading this several time doesn't help). Perhaps I lack specific domain knowledge, but is there a way to make it more comprehensible for layman?
I've had a few passes and clearly still failing :(
Maybe an example is the way to go? Does the following help? (replacing the 'An example sentence' above).
# For example, a CXL Memory device M is directly # plugged into a CXL root port P which is part of a # CXL root bridge B. To calculate latency from a CPU in # the host to the memory on M, the latency from that CPU # to the bridge B (and hence port P)* must be added # to the latency due to the CXL Link between P and M # (calculated from link status registers) and that from # the CXL port on device M to the actual memory (read from # CDAT via a mailbox on the device). # The CPU to root bridge latency (*) is provided by ACPI HMAT. # HMAT latency data is indexed with the combination of the # proximity domain for the CPU and that for the root bridge. # This node value is the root bridge part of that index pair.
...
Quoted 17 lines
Quoted 16 lines
qapi/qom.json +16
-0+static int build_acpi_generic_port(Object *obj, void *opaque) +{ + MachineState *ms = MACHINE(qdev_get_machine()); + const char *hid = "ACPI0016"; + GArray *table_data = opaque; + AcpiGenericPort *gp; + uint32_t uid; + Object *o; + + if (!object_dynamic_cast(obj, TYPE_ACPI_GENERIC_PORT)) { + return 0; + } + + gp = ACPI_GENERIC_PORT(obj); + + if (gp->node >= ms->numa_state->num_nodes) {
Quoted 8 lines
qapi/qom.json
Quoted 3 lines
qapi/qom.json +3
-0+ error_printf("%s: node %d is invalid.\n", + TYPE_ACPI_GENERIC_PORT, gp->node); + exit(1);not sure,
maybe useerror_fatalinstead of using exit(1)?CCing Markus to check if it's ok.
Markus?
Quoted 12 lines
qapi/qom.json
Quoted 10 lines
qapi/qom.json +8
-0+ } + + o = object_resolve_path_type(gp->pci_bus, TYPE_PXB_CXL_BUS, NULL); + if (!o) { + error_printf("%s: device must be a CXL host bridge.\n", + TYPE_ACPI_GENERIC_PORT); + exit(1); + }ditto
PATCH v5 11/13 bios-tables-test: Allow for new acpihmat-generic-x test data.
In reply to Jonathan CameronThe test to be added exercises many corner cases of the SRAT and HMAT table generation.
---
v5: No change.
--- tests/qtest/bios-tables-test-allowed-diff.h | 5 +++++ tests/data/acpi/x86/q35/APIC.acpihmat-generic-x | 0 tests/data/acpi/x86/q35/CEDT.acpihmat-generic-x | 0 tests/data/acpi/x86/q35/DSDT.acpihmat-generic-x | 0 tests/data/acpi/x86/q35/HMAT.acpihmat-generic-x | 0 tests/data/acpi/x86/q35/SRAT.acpihmat-generic-x | 0 6 files changed, 5 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +5 -0
@@ -1 +1,6 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/x86/q35/APIC.acpihmat-generic-x" , +"tests/data/acpi/x86/q35/CEDT.acpihmat-generic-x" , +"tests/data/acpi/x86/q35/DSDT.acpihmat-generic-x" , +"tests/data/acpi/x86/q35/HMAT.acpihmat-generic-x" , +"tests/data/acpi/x86/q35/SRAT.acpihmat-generic-x",
tests/data/acpi/x86/q35/APIC.acpihmat-generic-x new file +0 -0
tests/data/acpi/x86/q35/CEDT.acpihmat-generic-x new file +0 -0
tests/data/acpi/x86/q35/DSDT.acpihmat-generic-x new file +0 -0
tests/data/acpi/x86/q35/HMAT.acpihmat-generic-x new file +0 -0
tests/data/acpi/x86/q35/SRAT.acpihmat-generic-x new file +0 -0
Signature · 1 line
2.43.0
PATCH v5 12/13 bios-tables-test: Add complex SRAT / HMAT test for GI GP
In reply to Jonathan CameronAdd a test with 6 nodes to exercise most interesting corner cases of SRAT and HMAT generation including the new Generic Initiator and Generic Port Affinity structures. More details of the set up in the following patch adding the table data.
---
v5: No change
--- tests/qtest/bios-tables-test.c | 97 ++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+)
tests/qtest/bios-tables-test.c +97 -0
@@ -1924,6 +1924,101 @@ static void test_acpi_q35_tcg_acpi_hmat_noinitiator(void)free_test_data (&data); } +/* Test intended to hit corner cases of SRAT and HMAT */ +static void test_acpi_q35_tcg_acpi_hmat_generic_x (void ) +{ +test_data data = {}; + + data.machine =MACHINE_Q35 ; + data.arch ="x86" ; + data.variant =".acpihmat-generic-x" ; +test_acpi_one (" -machine hmat=on,cxl=on" +" -smp 3,sockets=3" +" -m 128M,maxmem=384M,slots=2" +" -device pcie-root-port,chassis=1,id=pci.1" +" -device pci-testdev,bus=pci.1," +"multifunction=on,addr=00.0" +" -device pci-testdev,bus=pci.1,addr=00.1" +" -device pci-testdev,bus=pci.1,id=gidev,addr=00.2" +" -device pxb-cxl,bus_nr=64,bus=pcie.0,id=cxl.1" +" -object memory-backend-ram,size=64M,id=ram0" +" -object memory-backend-ram,size=64M,id=ram1" +" -numa node,nodeid=0,cpus=0,memdev=ram0" +" -numa node,nodeid=1" +" -object acpi-generic-initiator,id=gi0,pci-dev=gidev,node=1" +" -numa node,nodeid=2" +" -object acpi-generic-port,id=gp0,pci-bus=cxl.1,node=2" +" -numa node,nodeid=3,cpus=1" +" -numa node,nodeid=4,memdev=ram1" +" -numa node,nodeid=5,cpus=2" +" -numa hmat-lb,initiator=0,target=0,hierarchy=memory," +"data-type=access-latency,latency=10" +" -numa hmat-lb,initiator=0,target=0,hierarchy=memory," +"data-type=access-bandwidth,bandwidth=800M" +" -numa hmat-lb,initiator=0,target=2,hierarchy=memory," +"data-type=access-latency,latency=100" +" -numa hmat-lb,initiator=0,target=2,hierarchy=memory," +"data-type=access-bandwidth,bandwidth=200M" +" -numa hmat-lb,initiator=0,target=4,hierarchy=memory," +"data-type=access-latency,latency=100" +" -numa hmat-lb,initiator=0,target=4,hierarchy=memory," +"data-type=access-bandwidth,bandwidth=200M" +" -numa hmat-lb,initiator=0,target=5,hierarchy=memory," +"data-type=access-latency,latency=200" +" -numa hmat-lb,initiator=0,target=5,hierarchy=memory," +"data-type=access-bandwidth,bandwidth=400M" +" -numa hmat-lb,initiator=1,target=0,hierarchy=memory," +"data-type=access-latency,latency=500" +" -numa hmat-lb,initiator=1,target=0,hierarchy=memory," +"data-type=access-bandwidth,bandwidth=100M" +" -numa hmat-lb,initiator=1,target=2,hierarchy=memory," +"data-type=access-latency,latency=50" +" -numa hmat-lb,initiator=1,target=2,hierarchy=memory," +"data-type=access-bandwidth,bandwidth=400M" +" -numa hmat-lb,initiator=1,target=4,hierarchy=memory," +"data-type=access-latency,latency=50" +" -numa hmat-lb,initiator=1,target=4,hierarchy=memory," +"data-type=access-bandwidth,bandwidth=800M" +" -numa hmat-lb,initiator=1,target=5,hierarchy=memory," +"data-type=access-latency,latency=500" +" -numa hmat-lb,initiator=1,target=5,hierarchy=memory," +"data-type=access-bandwidth,bandwidth=100M" +" -numa hmat-lb,initiator=3,target=0,hierarchy=memory," +"data-type=access-latency,latency=20" +" -numa hmat-lb,initiator=3,target=0,hierarchy=memory," +"data-type=access-bandwidth,bandwidth=400M" +" -numa hmat-lb,initiator=3,target=2,hierarchy=memory," +"data-type=access-latency,latency=80" +" -numa hmat-lb,initiator=3,target=2,hierarchy=memory," +"data-type=access-bandwidth,bandwidth=200M" +" -numa hmat-lb,initiator=3,target=4,hierarchy=memory," +"data-type=access-latency,latency=80" +" -numa hmat-lb,initiator=3,target=4,hierarchy=memory," +"data-type=access-bandwidth,bandwidth=200M" +" -numa hmat-lb,initiator=3,target=5,hierarchy=memory," +"data-type=access-latency,latency=20" +" -numa hmat-lb,initiator=3,target=5,hierarchy=memory," +"data-type=access-bandwidth,bandwidth=400M" +" -numa hmat-lb,initiator=5,target=0,hierarchy=memory," +"data-type=access-latency,latency=20" +" -numa hmat-lb,initiator=5,target=0,hierarchy=memory," +"data-type=access-bandwidth,bandwidth=400M" +" -numa hmat-lb,initiator=5,target=2,hierarchy=memory," +"data-type=access-latency,latency=80" +" -numa hmat-lb,initiator=5,target=4,hierarchy=memory," +"data-type=access-bandwidth,bandwidth=200M" +" -numa hmat-lb,initiator=5,target=4,hierarchy=memory," +"data-type=access-latency,latency=80" +" -numa hmat-lb,initiator=5,target=2,hierarchy=memory," +"data-type=access-bandwidth,bandwidth=200M" +" -numa hmat-lb,initiator=5,target=5,hierarchy=memory," +"data-type=access-latency,latency=10" +" -numa hmat-lb,initiator=5,target=5,hierarchy=memory," +"data-type=access-bandwidth,bandwidth=800M" , + &data); +free_test_data (&data); +} +#ifdef CONFIG_POSIX static void test_acpi_erst (const char *machine,const char *arch) {
@@ -2380,6 +2475,8 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/q35/nohpet" , test_acpi_q35_tcg_nohpet);qtest_add_func ("acpi/q35/acpihmat-noinitiator" , test_acpi_q35_tcg_acpi_hmat_noinitiator); +qtest_add_func ("acpi/q35/acpihmat-genericx" , + test_acpi_q35_tcg_acpi_hmat_generic_x);/* i386 does not support memory hotplug */ if (strcmp (arch,"i386" )) {
Signature · 1 line
2.43.0
PATCH v5 13/13 bios-tables-test: Add data for complex numa test (GI, GP etc)
In reply to Jonathan CameronGiven this is a new configuration, there are affects on APIC, CEDT and DSDT, but the key elements are in SRAT (plus related data in HMAT). The configuration has node to exercise many different combinations.
0) CPUs + Memory
1) GI only
2) GP only
3) CPUS only
4) Memory only
5) CPUs + HP memory
GI node, GP Node, Memory only node, hotplug memory
only node, latency and bandwidth such that in Linux Access0 (any initiator) and Access1 (CPU initiators only) given different answers. Following cropped to remove details of each entry.
[000h 0000 004h] Signature : "SRAT" [System Resource Affinity Table]
...
[030h 0048 001h] Subtable Type : 00 [Processor Local APIC/SAPIC Affinity]
...
[032h 0050 001h] Proximity Domain Low(8) : 00
[033h 0051 001h] Apic ID : 00
...
[040h 0064 001h] Subtable Type : 00 [Processor Local APIC/SAPIC Affinity]
...
[042h 0066 001h] Proximity Domain Low(8) : 03
[043h 0067 001h] Apic ID : 01
...
[050h 0080 001h] Subtable Type : 00 [Processor Local APIC/SAPIC Affinity]
...
[052h 0082 001h] Proximity Domain Low(8) : 05
[053h 0083 001h] Apic ID : 02
...
[060h 0096 001h] Subtable Type : 01 [Memory Affinity]
...
[062h 0098 004h] Proximity Domain : 00000000
...
[068h 0104 008h] Base Address : 0000000000000000
[070h 0112 008h] Address Length : 00000000000A0000
...
[088h 0136 001h] Subtable Type : 01 [Memory Affinity]
...
[08Ah 0138 004h] Proximity Domain : 00000000
...
[090h 0144 008h] Base Address : 0000000000100000
[098h 0152 008h] Address Length : 0000000003F00000
...
[0B0h 0176 001h] Subtable Type : 01 [Memory Affinity]
...
[0B2h 0178 004h] Proximity Domain : 00000004
...
[0B8h 0184 008h] Base Address : 0000000004000000
[0C0h 0192 008h] Address Length : 0000000004000000
... some zero length entries follow...
[1A0h 0416 001h] Subtable Type : 05 [Generic Initiator Affinity]
[1A1h 0417 001h] Length : 20
[1A2h 0418 001h] Reserved1 : 00
[1A3h 0419 001h] Device Handle Type : 01
[1A4h 0420 004h] Proximity Domain : 00000001
[1A8h 0424 010h] Device Handle : 00 00 01 02 00 00 00 00 00 00 00 00 00 00 00 00
[1B8h 0440 004h] Flags (decoded below) : 00000001
Enabled : 1
Architectural Transactions : 0
[1BCh 0444 004h] Reserved2 : 00000000
[1C0h 0448 001h] Subtable Type : 06 [Generic Port Affinity]
[1C1h 0449 001h] Length : 20
[1C2h 0450 001h] Reserved1 : 00
[1C3h 0451 001h] Device Handle Type : 00
[1C4h 0452 004h] Proximity Domain : 00000002
[1C8h 0456 010h] Device Handle : 41 43 50 49 30 30 31 36 40 00 00 00 00 00 00 00
[1D8h 0472 004h] Flags (decoded below) : 00000001
Enabled : 1
Architectural Transactions : 0
[1DCh 0476 004h] Reserved2 : 00000000
[1E0h 0480 001h] Subtable Type : 01 [Memory Affinity]
...
[1E2h 0482 004h] Proximity Domain : 00000005
...
[1E8h 0488 008h] Base Address : 0000000100000000
[1F0h 0496 008h] Address Length : 0000000090000000
Example block from HMAT:
[0F0h 0240 002h] Structure Type : 0001 [System Locality Latency and Bandwidth Information]
[0F2h 0242 002h] Reserved : 0000
[0F4h 0244 004h] Length : 00000078
[0F8h 0248 001h] Flags (decoded below) : 00
Memory Hierarchy : 0
Use Minimum Transfer Size : 0
Non-sequential Transfers : 0
[0F9h 0249 001h] Data Type : 03
[0FAh 0250 001h] Minimum Transfer Size : 00
[0FBh 0251 001h] Reserved1 : 00
[0FCh 0252 004h] Initiator Proximity Domains # : 00000004 [100h 0256 004h] Target Proximity Domains # : 00000006
[104h 0260 004h] Reserved2 : 00000000
[108h 0264 008h] Entry Base Unit : 0000000000000004
[110h 0272 004h] Initiator Proximity Domain List : 00000000 [114h 0276 004h] Initiator Proximity Domain List : 00000001 [118h 0280 004h] Initiator Proximity Domain List : 00000003 [11Ch 0284 004h] Initiator Proximity Domain List : 00000005 [120h 0288 004h] Target Proximity Domain List : 00000000 [124h 0292 004h] Target Proximity Domain List : 00000001 [128h 0296 004h] Target Proximity Domain List : 00000002 [12Ch 0300 004h] Target Proximity Domain List : 00000003 [130h 0304 004h] Target Proximity Domain List : 00000004 [134h 0308 004h] Target Proximity Domain List : 00000005
[138h 0312 002h] Entry : 00C8 [13Ah 0314 002h] Entry : 0000 [13Ch 0316 002h] Entry : 0032 [13Eh 0318 002h] Entry : 0000 [140h 0320 002h] Entry : 0032 [142h 0322 002h] Entry : 0064 [144h 0324 002h] Entry : 0019 [146h 0326 002h] Entry : 0000 [148h 0328 002h] Entry : 0064 [14Ah 0330 002h] Entry : 0000 [14Ch 0332 002h] Entry : 00C8 [14Eh 0334 002h] Entry : 0019 [150h 0336 002h] Entry : 0064 [152h 0338 002h] Entry : 0000 [154h 0340 002h] Entry : 0032 [156h 0342 002h] Entry : 0000 [158h 0344 002h] Entry : 0032 [15Ah 0346 002h] Entry : 0064 [15Ch 0348 002h] Entry : 0064 [15Eh 0350 002h] Entry : 0000 [160h 0352 002h] Entry : 0032 [162h 0354 002h] Entry : 0000 [164h 0356 002h] Entry : 0032 [166h 0358 002h] Entry : 00C8
Note the zeros represent entries where the target node has no memory. These could be surpressed but it isn't 'wrong' to provide them and it is (probably) permissible under ACPI to hotplug memory into these nodes later.
---
v5: No change
--- tests/qtest/bios-tables-test-allowed-diff.h | 5 ----- tests/data/acpi/x86/q35/APIC.acpihmat-generic-x | Bin 0 -> 136 bytes tests/data/acpi/x86/q35/CEDT.acpihmat-generic-x | Bin 0 -> 68 bytes tests/data/acpi/x86/q35/DSDT.acpihmat-generic-x | Bin 0 -> 10849 bytes tests/data/acpi/x86/q35/HMAT.acpihmat-generic-x | Bin 0 -> 360 bytes tests/data/acpi/x86/q35/SRAT.acpihmat-generic-x | Bin 0 -> 520 bytes 6 files changed, 5 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -5
@@ -1,6 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/x86/q35/APIC.acpihmat-generic-x" , -"tests/data/acpi/x86/q35/CEDT.acpihmat-generic-x" , -"tests/data/acpi/x86/q35/DSDT.acpihmat-generic-x" , -"tests/data/acpi/x86/q35/HMAT.acpihmat-generic-x" , -"tests/data/acpi/x86/q35/SRAT.acpihmat-generic-x",
tests/data/acpi/x86/q35/APIC.acpihmat-generic-x binary +0 -0
tests/data/acpi/x86/q35/CEDT.acpihmat-generic-x binary +0 -0
tests/data/acpi/x86/q35/DSDT.acpihmat-generic-x binary +0 -0
tests/data/acpi/x86/q35/HMAT.acpihmat-generic-x binary +0 -0
tests/data/acpi/x86/q35/SRAT.acpihmat-generic-x binary +0 -0
Signature · 1 line
2.43.0