x86: fixing and cleaning up ACPI PCI code part 3
cover x86: fixing and cleaning up ACPI PCI code part 3
Series continues refactoring on top of [1].
It focuses on isolating creation of non hotplug and hotplug slot descriptions. In state it's posted, it's not complete, but pretty close to it. The series contains stable patches from refactoring and is already too large to keep it to myself, hence I'm publishing it fro review.
It will be followed by separate series on top of this one, that will finish concrete feature[s] in following order:
1 introduce acpi-index support for non-hotpluggable PCI
devices (i.e. NICs directly attached to Q35 host-bridge) making acpi-index support complete within pc/q35 machines.
2 let guest OS to re-arrange bridge resources when ACPI PCI
hotplug is enabled. (should fix insuficient resources issue during PCI hotplug)
3 finish isolating hotplug code from non-hotplug one,
which should allow to re-use non-hotplug parts in other machines (arm/virt and microvm) and bring acpi-index support there.
PS:
Refactoring also adds testing for various corner cases and fixes (present/latent/imagined) bugs where they were spotted.
1) "[PATCH 00/11] x86: clean up ACPI PCI code part 2"
https://www.mail-archive.com/[email protected]/msg915493.html
Igor Mammedov (40):
tests: qtest: print device_add error before failing test
tests: acpi: cleanup arguments to make them more readable
tests: acpi: whitelist DSDT blobs for tests that use pci-bridges
tests: acpi: extend pcihp with nested bridges
tests: acpi: update expected blobs
tests: acpi: cleanup use_uefi argument usage
pci_bridge: remove whitespace
x86: acpi: pcihp: clean up duplicate bridge_in_acpi assignment
pci: acpi hotplug: rename x-native-hotplug to
x-do-not-expose-native-hotplug-cap
pcihp: piix4: do not call acpi_pcihp_reset() when ACPI PCI hotplug is
disabled
pci: acpihp: assign BSEL only to coldplugged bridges
x86: pcihp: fix invalid AML PCNT calls to hotplugged bridges
tests: boot_sector_test: avoid crashing if status is not available yet
tests: acpi: extend bridge tests with hotplugged bridges
tests: boot_sector_test(): make it multi-shot
tests: acpi: add reboot cycle to bridge test
tests: acpi: whitelist DSDT before refactoring acpi based PCI hotplug
machinery
pcihp: drop pcihp_bridge_en dependency when composing PCNT method
tests: acpi: update expected blobs
tests: acpi: whitelist DSDT before refactoring acpi based PCI hotplug
machinery
pcihp: compose PCNT callchain right before its user _GPE._E01
pcihp: do not put empty PCNT in DSDT
tests: acpi: update expected blobs
whitelist DSDT before adding endpoint devices to bridge testcases
tests: acpi: add endpoint devices to bridges
tests: acpi: update expected blobs
x86: pcihp: acpi: prepare slot ignore rule to work with self
describing bridges
pci: acpi: wire up AcpiDevAmlIf interface to generic bridge
pcihp: make bridge describe itself using
AcpiDevAmlIfClass:build_dev_aml
pci: make sure pci_bus_is_express() won't error out with "discards
‘const’ qualifier"
pcihp: isolate rule whether slot should be described in DSDT
tests: acpi: whitelist DSDT before decoupling PCI hotplug code from
basic slots description
pcihp: acpi: decouple hotplug and generic slots description
tests: acpi: update expected blobs
tests: acpi: whitelist DSDT blobs before removing dynamic _DSM on
coldplugged bridges
pcihp: acpi: ignore coldplugged bridges when composing hotpluggable
slots
tests: acpi: update expected blobs
tests: acpi: whitelist DSDT before moving non-hotpluggble slots
description from hotplug path
pcihp: generate populated non-hotpluggble slot descriptions on
non-hotplug path
tests: acpi: update expected blobs
include/hw/acpi/pci.h | 4 + include/hw/pci/pci.h | 2 +- include/hw/pci/pcie_port.h | 3 +- hw/acpi/Kconfig | 4 + hw/acpi/meson.build | 4 +- hw/acpi/pci-bridge-stub.c | 20 ++ hw/acpi/pci-bridge.c | 27 ++ hw/acpi/pcihp.c | 35 ++- hw/acpi/piix4.c | 4 +- hw/i386/Kconfig | 1 + hw/i386/acpi-build.c | 279 ++++++++++-------- hw/i386/pc_q35.c | 5 +- hw/pci-bridge/gen_pcie_root_port.c | 7 +- hw/pci-bridge/pci_bridge_dev.c | 1 - hw/pci/pci.c | 2 +- hw/pci/pci_bridge.c | 14 + hw/pci/pcie.c | 6 +- hw/pci/pcie_port.c | 3 +- tests/data/acpi/pc/DSDT | Bin 6458 -> 6360 bytes tests/data/acpi/pc/DSDT.acpierst | Bin 6418 -> 6283 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7783 -> 7685 bytes tests/data/acpi/pc/DSDT.bridge | Bin 9532 -> 12487 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6922 -> 6824 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 8112 -> 8014 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 6418 -> 6289 bytes tests/data/acpi/pc/DSDT.hpbrroot | Bin 3064 -> 3081 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6530 -> 6432 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7817 -> 7719 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 6316 -> 6218 bytes tests/data/acpi/pc/DSDT.numamem | Bin 6464 -> 6366 bytes tests/data/acpi/pc/DSDT.roothp | Bin 6656 -> 9745 bytes tests/data/acpi/q35/DSDT | Bin 8310 -> 8252 bytes tests/data/acpi/q35/DSDT.acpierst | Bin 8327 -> 8269 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9635 -> 9577 bytes tests/data/acpi/q35/DSDT.acpihmat-noinitiator | Bin 8589 -> 8531 bytes tests/data/acpi/q35/DSDT.applesmc | Bin 8356 -> 8298 bytes tests/data/acpi/q35/DSDT.bridge | Bin 11439 -> 11481 bytes tests/data/acpi/q35/DSDT.core-count2 | Bin 32450 -> 32392 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8774 -> 8716 bytes tests/data/acpi/q35/DSDT.cxl | Bin 9636 -> 9578 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9964 -> 9906 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 8385 -> 8327 bytes tests/data/acpi/q35/DSDT.ipmismbus | Bin 8398 -> 8340 bytes tests/data/acpi/q35/DSDT.ivrs | Bin 8327 -> 8269 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9669 -> 9611 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 9440 -> 9382 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 8630 -> 12337 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 8168 -> 8110 bytes tests/data/acpi/q35/DSDT.numamem | Bin 8316 -> 8258 bytes tests/data/acpi/q35/DSDT.pvpanic-isa | Bin 8411 -> 8353 bytes tests/data/acpi/q35/DSDT.tis.tpm12 | Bin 8916 -> 8858 bytes tests/data/acpi/q35/DSDT.tis.tpm2 | Bin 8942 -> 8884 bytes tests/data/acpi/q35/DSDT.viot | Bin 9419 -> 9361 bytes tests/data/acpi/q35/DSDT.xapic | Bin 35673 -> 35615 bytes tests/qtest/bios-tables-test.c | 144 ++++++--- tests/qtest/boot-sector.c | 6 +- tests/qtest/libqtest.c | 4 + 57 files changed, 394 insertions(+), 181 deletions(-) create mode 100644 hw/acpi/pci-bridge-stub.c create mode 100644 hw/acpi/pci-bridge.c
Signature · 1 line
2.31.1
PATCH 1/40 tests: qtest: print device_add error before failing test
---
CC: Thomas Huth <[email protected]>
CC: Laurent Vivier <[email protected]>
--- tests/qtest/libqtest.c | 4 ++++ 1 file changed, 4 insertions(+)
tests/qtest/libqtest.c +4 -0
@@ -1417,6 +1417,10 @@ void qtest_qmp_device_add_qdict(QTestState *qts, const char *drv, resp =qtest_qmp (qts,"{'execute': 'device_add', 'arguments': %p}" , args);g_assert (resp);g_assert (!qdict_haskey (resp,"event" ));/* We don't expect any events */ +if (qdict_haskey (resp,"error" )) { +fprintf (stderr,"error: %s\n" , +qdict_get_str (qdict_get_qdict (resp,"error" ),"desc" )); + }g_assert (!qdict_haskey (resp,"error" ));qobject_unref (resp); }
Signature · 1 line
2.31.1
PATCH 2/40 tests: acpi: cleanup arguments to make them more readable
In reply to Igor Mammedovno functional change
---
CC: Thomas Huth <[email protected]>
CC: Laurent Vivier <[email protected]>
--- tests/qtest/bios-tables-test.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
tests/qtest/bios-tables-test.c +7 -10
@@ -951,8 +951,7 @@ static void test_acpi_q35_tcg_bridge(void) data.variant =".bridge" ; data.required_struct_types = base_required_struct_types; data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types); -test_acpi_one ("-device pci-bridge,chassis_nr=1" , - &data); +test_acpi_one ("-device pci-bridge,chassis_nr=1" , &data);free_test_data (&data); }
@@ -962,14 +961,12 @@ static void test_acpi_q35_multif_bridge(void) .machine = MACHINE_Q35, .variant = ".multi-bridge", }; -test_acpi_one ("-device pcie-root-port,id=pcie-root-port-0," -"multifunction=on," -"port=0x0,chassis=1,addr=0x2,bus=pcie.0 " -"-device pcie-root-port,id=pcie-root-port-1," -"port=0x1,chassis=2,addr=0x3.0x1,bus=pcie.0 " -"-device virtio-balloon,id=balloon0," -"bus=pcie.0,addr=0x4.0x2" , - &data); +test_acpi_one ( +" -device virtio-balloon,id=balloon0,addr=0x4.0x2" +" -device pcie-root-port,id=rp0,multifunction=on," +"port=0x0,chassis=1,addr=0x2" +" -device pcie-root-port,id=rp1,port=0x1,chassis=2,addr=0x3.0x1" , + &data);free_test_data (&data); }
Signature · 1 line
2.31.1
PATCH 3/40 tests: acpi: whitelist DSDT blobs for tests that use pci-bridges
In reply to Igor Mammedov--- tests/qtest/bios-tables-test-allowed-diff.h | 4 ++++ 1 file changed, 4 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +4 -0
@@ -1 +1,5 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/DSDT.multi-bridge" , +"tests/data/acpi/pc/DSDT.bridge" , +"tests/data/acpi/pc/DSDT.roothp" , +"tests/data/acpi/pc/DSDT.hpbridge",
Signature · 1 line
2.31.1
PATCH 4/40 tests: acpi: extend pcihp with nested bridges
In reply to Igor Mammedovadd nested bridges/root-ports to pcihp tests, to make sure follow up patches don't break nested enumeration of bridges in DSDT.
--- tests/qtest/bios-tables-test.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
tests/qtest/bios-tables-test.c +13 -4
@@ -863,7 +863,8 @@ static void test_acpi_piix4_tcg_bridge(void) data.variant =".bridge" ; data.required_struct_types = base_required_struct_types; data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types); -test_acpi_one ("-device pci-bridge,chassis_nr=1" , &data); +test_acpi_one ("-device pci-bridge,chassis_nr=1 " +"-device pci-bridge,bus=pci.1,addr=1.0,chassis_nr=2 " , &data);free_test_data (&data); }
@@ -877,7 +878,8 @@ static void test_acpi_piix4_no_root_hotplug(void) data.required_struct_types = base_required_struct_types; data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types);test_acpi_one ("-global PIIX4_PM.acpi-root-pci-hotplug=off " -"-device pci-bridge,chassis_nr=1" , &data); +"-device pci-bridge,chassis_nr=1 " +"-device pci-bridge,bus=pci.1,addr=1.0,chassis_nr=2 " , &data);free_test_data (&data); }
@@ -891,7 +893,8 @@ static void test_acpi_piix4_no_bridge_hotplug(void) data.required_struct_types = base_required_struct_types; data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types);test_acpi_one ("-global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off " -"-device pci-bridge,chassis_nr=1" , &data); +"-device pci-bridge,chassis_nr=1 " +"-device pci-bridge,bus=pci.1,addr=1.0,chassis_nr=2 " , &data);free_test_data (&data); }
@@ -965,8 +968,14 @@ static void test_acpi_q35_multif_bridge(void)" -device virtio-balloon,id=balloon0,addr=0x4.0x2" " -device pcie-root-port,id=rp0,multifunction=on," "port=0x0,chassis=1,addr=0x2" -" -device pcie-root-port,id=rp1,port=0x1,chassis=2,addr=0x3.0x1" , +" -device pcie-root-port,id=rp1,port=0x1,chassis=2,addr=0x3.0x1" +" -device pcie-root-port,id=rp2,port=0x0,chassis=3,bus=rp1,addr=0.0" +" -device pci-bridge,bus=rp2,chassis_nr=4,id=br1" +" -device pcie-root-port,id=rphptgt1,port=0x0,chassis=5,addr=2.1" +" -device pcie-root-port,id=rphptgt2,port=0x0,chassis=6,addr=2.2" +" -device pcie-root-port,id=rphptgt3,port=0x0,chassis=7,addr=2.3" , &data); +free_test_data (&data); }
Signature · 1 line
2.31.1
PATCH 5/40 tests: acpi: update expected blobs
In reply to Igor Mammedovadd extra nested bridges/root ports to blobs so it would be posible to check how follow up patches would affect it.
--- tests/qtest/bios-tables-test-allowed-diff.h | 4 ---- tests/data/acpi/pc/DSDT.bridge | Bin 9532 -> 12608 bytes tests/data/acpi/pc/DSDT.roothp | Bin 6656 -> 9732 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 8630 -> 12301 bytes 4 files changed, 4 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -4
@@ -1,5 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/DSDT.multi-bridge" , -"tests/data/acpi/pc/DSDT.bridge" , -"tests/data/acpi/pc/DSDT.roothp" , -"tests/data/acpi/pc/DSDT.hpbridge",
tests/data/acpi/pc/DSDT.bridge binary +0 -0
tests/data/acpi/pc/DSDT.roothp binary +0 -0
tests/data/acpi/q35/DSDT.multi-bridge binary +0 -0
Signature · 1 line
2.31.1
PATCH 6/40 tests: acpi: cleanup use_uefi argument usage
In reply to Igor Mammedov'use_uefi' is used for the flag is a part of 'test_data *data' argument that is passed to the same functions, which makes use_uefi argument redundant.
Drop it and use 'data::uefi_*' directly, instead.
--- tests/qtest/bios-tables-test.c | 35 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 20 deletions(-)
tests/qtest/bios-tables-test.c +15 -20
@@ -748,9 +748,9 @@ static void test_smbios_structs(test_data *data, SmbiosEntryPointType ep_type) } } -static void test_acpi_load_tables (test_data *data,bool use_uefi) +static void test_acpi_load_tables (test_data *data) { -if (use_uefi) { +if (data->uefi_fl1 && data->uefi_fl2) {/* use UEFI */ g_assert (data->scan_len); data->rsdp_addr =acpi_find_rsdp_address_uefi (data->qts, data->ram_start, data->scan_len);
@@ -766,12 +766,11 @@ static void test_acpi_load_tables(test_data *data, bool use_uefi)test_acpi_fadt_table (data); } -static char *test_acpi_create_args (test_data *data,const char *params, -bool use_uefi) +static char *test_acpi_create_args (test_data *data,const char *params) {char *args; -if (use_uefi) { +if (data->uefi_fl1 && data->uefi_fl2) {/* use UEFI */ /* * TODO: convert '-drive if=pflash' to new syntax (see e33763be7cd3) * when arm/virt boad starts to support it.
@@ -809,11 +808,10 @@ static char *test_acpi_create_args(test_data *data, const char *params,static void test_acpi_one (const char *params,test_data *data) {char *args; -bool use_uefi = data->uefi_fl1 && data->uefi_fl2; - args =test_acpi_create_args (data, params, use_uefi); + args =test_acpi_create_args (data, params); data->qts =qtest_init (args); -test_acpi_load_tables (data, use_uefi); +test_acpi_load_tables (data);if (getenv (ACPI_REBUILD_EXPECTED_AML )) {dump_aml_files (data, true);
@@ -826,7 +824,7 @@ static void test_acpi_one(const char *params, test_data *data)* Bug on uefi-test-tools to provide entry point: * https://bugs.launchpad.net/qemu/+bug/1821884 */ -if (!use_uefi) { +if (!(data->uefi_fl1 && data->uefi_fl2)) {SmbiosEntryPointType ep_type =test_smbios_entry_point (data);test_smbios_structs (data, ep_type); }
@@ -1904,10 +1902,9 @@ static void test_acpi_piix4_oem_fields(void) data.required_struct_types = base_required_struct_types; data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types); - args =test_acpi_create_args (&data, -OEM_TEST_ARGS , false); + args =test_acpi_create_args (&data,OEM_TEST_ARGS ); data.qts =qtest_init (args); -test_acpi_load_tables (&data, false); +test_acpi_load_tables (&data);test_oem_fields (&data);qtest_quit (data.qts);free_test_data (&data);
@@ -1924,10 +1921,9 @@ static void test_acpi_q35_oem_fields(void) data.required_struct_types = base_required_struct_types; data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types); - args =test_acpi_create_args (&data, -OEM_TEST_ARGS , false); + args =test_acpi_create_args (&data,OEM_TEST_ARGS ); data.qts =qtest_init (args); -test_acpi_load_tables (&data, false); +test_acpi_load_tables (&data);test_oem_fields (&data);qtest_quit (data.qts);free_test_data (&data);
@@ -1942,9 +1938,9 @@ static void test_acpi_microvm_oem_fields(void)test_acpi_microvm_prepare (&data); args =test_acpi_create_args (&data, -OEM_TEST_ARGS ",acpi=on" , false); +OEM_TEST_ARGS ",acpi=on" ); data.qts =qtest_init (args); -test_acpi_load_tables (&data, false); +test_acpi_load_tables (&data);test_oem_fields (&data);qtest_quit (data.qts);free_test_data (&data);
@@ -1964,10 +1960,9 @@ static void test_acpi_virt_oem_fields(void) };char *args; - args =test_acpi_create_args (&data, -"-cpu cortex-a57 " OEM_TEST_ARGS , true); + args =test_acpi_create_args (&data,"-cpu cortex-a57 " OEM_TEST_ARGS ); data.qts =qtest_init (args); -test_acpi_load_tables (&data, true); +test_acpi_load_tables (&data);test_oem_fields (&data);qtest_quit (data.qts);free_test_data (&data);
Signature · 1 line
2.31.1
PATCH 7/40 pci_bridge: remove whitespace
In reply to Igor Mammedov--- hw/pci-bridge/pci_bridge_dev.c | 1 - 1 file changed, 1 deletion(-)
hw/pci-bridge/pci_bridge_dev.c +0 -1
@@ -186,7 +186,6 @@ static Property pci_bridge_dev_properties[] = { res_reserve.mem_pref_32, -1), DEFINE_PROP_SIZE("pref64-reserve", PCIBridgeDev, res_reserve.mem_pref_64, -1), - DEFINE_PROP_END_OF_LIST(), };
Signature · 1 line
2.31.1
PATCH 8/40 x86: acpi: pcihp: clean up duplicate bridge_in_acpi assignment
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 1 - 1 file changed, 1 deletion(-)
hw/i386/acpi-build.c +0 -1
@@ -466,7 +466,6 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,call_dev_aml_func (DEVICE (pdev), dev); - bridge_in_acpi = cold_plugged_bridge && pcihp_bridge_en;if (bridge_in_acpi) {/* * device is coldplugged bridge,
Signature · 1 line
2.31.1
PATCH 9/40 pci: acpi hotplug: rename x-native-hotplug to x-do-not-expose-native-hotplug-cap
In reply to Igor MammedovWhen ACPI PCI hotplug for Q35 was introduced (6.1), it was implemented by hiding HPC capability on PCIE slot. That however led to a number of regressions and to fix it, it was decided to keep HPC cap exposed in ACPI PCI hotplug case and force guest in ACPI PCI hotplug mode by other means [1].
That reduced meaning of x-native-hotplug to a compat knob [2] for broken 6.1 machine type.
Rename property to match its current purpose.
1) 211afe5c69 (hw/i386/acpi-build: Deny control on PCIe Native Hot-plug in _OSC)
2) c318bef762 (hw/acpi/ich9: Add compat prop to keep HPC bit set for 6.1 machine type)
--- include/hw/pci/pcie_port.h | 3 ++- hw/i386/pc_q35.c | 5 +++-- hw/pci-bridge/gen_pcie_root_port.c | 7 ++++++- hw/pci/pcie.c | 6 +++--- hw/pci/pcie_port.c | 3 ++- 5 files changed, 16 insertions(+), 8 deletions(-)
include/hw/pci/pcie_port.h +2 -1
@@ -63,7 +63,8 @@ struct PCIESlot {/* Indicates whether any type of hot-plug is allowed on the slot */ bool hotplug; -bool native_hotplug; +/* broken ACPI hotplug compat knob to preserve 6.1 ABI intact */ +bool hide_native_hotplug_cap;QLIST_ENTRY (PCIESlot) next; };
hw/i386/pc_q35.c +3 -2
@@ -256,8 +256,9 @@ static void pc_q35_init(MachineState *machine) NULL);if (!keep_pci_slot_hpc && acpi_pcihp) { -object_register_sugar_prop (TYPE_PCIE_SLOT ,"x-native-hotplug" , -"false" , true); +object_register_sugar_prop (TYPE_PCIE_SLOT , +"x-do-not-expose-native-hotplug-cap" , +"true" , true); }/* irq lines */
hw/pci-bridge/gen_pcie_root_port.c +6 -1
@@ -87,7 +87,12 @@ static void gen_rp_realize(DeviceState *dev, Error **errp)return ; } -if (grp->res_reserve.io ==-1 && s->hotplug && !s->native_hotplug) { +/* +* reserving IO space led to worse issues in 6.1, when this hunk was +* introduced. (see commit: 211afe5c69b59). Keep this broken for 6.1 +* machine type ABI compatibility only +*/ +if (s->hide_native_hotplug_cap && grp->res_reserve.io ==-1 && s->hotplug) { grp->res_reserve.io =GEN_PCIE_ROOT_DEFAULT_IO_RANGE ; } int rc = pci_bridge_qemu_reserve_cap_init(d, 0,
hw/pci/pcie.c +3 -3
@@ -611,11 +611,11 @@ void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s) PCI_EXP_SLTCAP_ABP);/* -* Enable native hot-plug on all hot-plugged bridges unless -* hot-plug is disabled on the slot. +* Expose native hot-plug on all bridges if hot-plug is enabled on the slot. +* (unless broken 6.1 ABI is enforced for compat reasons) */ if (s->hotplug && - (s->native_hotplug ||DEVICE (dev)->hotplugged)) { + (!s->hide_native_hotplug_cap ||DEVICE (dev)->hotplugged)) {pci_long_test_and_set_mask (dev->config + pos +PCI_EXP_SLTCAP ,PCI_EXP_SLTCAP_HPS |PCI_EXP_SLTCAP_HPC );
hw/pci/pcie_port.c +2 -1
@@ -173,7 +173,8 @@ static Property pcie_slot_props[] = {DEFINE_PROP_UINT8 ("chassis" , PCIESlot, chassis,0 ),DEFINE_PROP_UINT16 ("slot" , PCIESlot, slot,0 ),DEFINE_PROP_BOOL ("hotplug" , PCIESlot, hotplug, true), -DEFINE_PROP_BOOL ("x-native-hotplug" , PCIESlot, native_hotplug, true), +DEFINE_PROP_BOOL ("x-do-not-expose-native-hotplug-cap" , PCIESlot, + hide_native_hotplug_cap, false), DEFINE_PROP_END_OF_LIST() };
Signature · 1 line
2.31.1
PATCH 10/40 pcihp: piix4: do not call acpi_pcihp_reset() when ACPI PCI hotplug is disabled
In reply to Igor Mammedovpiix4_pm_reset() is calling acpi_pcihp_reset() when ACPI PCI hotplug is disabled, which leads to assigning BSEL properties to bridges on path
acpi_set_bsel()
...
if (qbus_is_hotpluggable(BUS(bus))) {
// above happens to be true by default (though it's SHPC hotplug handler)
// set BSEL
}At the moment the issue is masked by the fact that we use not only BSEL, to decide if we should generated hoplug AML but also pcihp_bridge_en knob. However the later patches will drop dependency on pcihp_bridge_en, and use only BSEL exclusively to decide if hotplug AML for slots should be built, which exposes issue.
We should not ever call acpi_pcihp_reset() if ACPI PCI hotplug is disabled, make it so.
PS:
* Q35 does the right thing (i.e. it calls acpi_pcihp_reset only when pcihp is enabled)
* the issue also makes acpi_pcihp_update() logic run on SHPC enabled bridges, which seems to be harmless
---
CC: "Philippe Mathieu-Daudé" <[email protected]>
--- hw/acpi/piix4.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/acpi/piix4.c +3 -1
@@ -305,7 +305,9 @@ static void piix4_pm_reset(DeviceState *dev)acpi_update_sci (&s->ar, s->irq);pm_io_space_update (s); -acpi_pcihp_reset (&s->acpi_pci_hotplug, !s->use_acpi_root_pci_hotplug); +if (s->use_acpi_hotplug_bridge || s->use_acpi_root_pci_hotplug) { +acpi_pcihp_reset (&s->acpi_pci_hotplug, !s->use_acpi_root_pci_hotplug); + } }static void piix4_pm_powerdown_req (Notifier *n,void *opaque)
Signature · 1 line
2.31.1
PATCH 11/40 pci: acpihp: assign BSEL only to coldplugged bridges
In reply to Igor MammedovACPI PCI hotplug would broken after bridge hotplug and then migration if hotplugged bridge were specified on target at command line. Currently it's not possible since, 'hotplugged' property was made read-only for some time now.
The issue would happen due to BSEL being assigned to all bridges during 1st 'reset':
source seq:
1. start 'pc' machine => sets BSEL to 0 on pci.0 (host-bridge)
2. hotplug bridge, no bsel is assigned (so far is ok)
target seq:
1. start 'pc' machine with
-S -device pci-bridge,id=hp_br,hotplugged=on
BSEL gets assigned to as follows
hp_br: 0
pci.0: 1
as result hotplug requests with migrated AML generated on source would be misdirected to 'hp_br' instead of intended pci.0
While it's not issue at the moment, it's based on implicit assumptions
* 'hotplugged' property is read-only
* 1st reset happens before QEMU drops into monitor mode which lets add hotplugged on source bridges as hotplugged ones (anything added at that stage counts as hotplugged
(yet another assumption))
All of it looks too fragile to me, so lets restrict BSEL only to cold-plugged bridges explicitly.
Migration wise it shouldn't break anything since assignment order stays the same:
* user can't specify 'hotplugged=on' on CLI
* user can't specify 'hotplugged=off' at monitor stage or later
on older QEMU versions where 'hotplugged' is RW, hotplug is broken after migration anyways and we cannot do anything to fix that.
--- hw/acpi/pcihp.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-)
hw/acpi/pcihp.c +22 -13
@@ -85,31 +85,40 @@ static int acpi_pcihp_get_bsel(PCIBus *bus) } } -/* Assign BSEL property to all buses. In the future, this can be changed -* to only assign to buses that support hotplug. -*/ +typedef struct { +unsigned bsel_alloc; +bool has_bridge_hotplug; +}BSELInfo ; + +/* Assign BSEL property only to buses that support hotplug. */ static void *acpi_set_bsel (PCIBus *bus,void *opaque) { -unsigned *bsel_alloc = opaque; +BSELInfo *info = opaque;unsigned *bus_bsel; +DeviceState *br = bus->qbus.parent; +bool is_bridge =IS_PCI_BRIDGE (br); +/* hotplugged bridges can't be described in ACPI ignore them */ if (qbus_is_hotpluggable (BUS (bus))) { - bus_bsel =g_malloc (sizeof *bus_bsel); +if (!is_bridge || (!br->hotplugged && info->has_bridge_hotplug)) { + bus_bsel =g_malloc (sizeof *bus_bsel); - *bus_bsel = (*bsel_alloc)++; -object_property_add_uint32_ptr (OBJECT (bus),ACPI_PCIHP_PROP_BSEL , - bus_bsel,OBJ_PROP_FLAG_READ ); + *bus_bsel = info->bsel_alloc++; +object_property_add_uint32_ptr (OBJECT (bus),ACPI_PCIHP_PROP_BSEL , + bus_bsel,OBJ_PROP_FLAG_READ ); + } } -return bsel_alloc; +return info; } -static void acpi_set_pci_info (void ) +static void acpi_set_pci_info (bool has_bridge_hotplug) {static bool bsel_is_set;Object *host =acpi_get_i386_pci_host ();PCIBus *bus; -unsigned bsel_alloc =ACPI_PCIHP_BSEL_DEFAULT ; +BSELInfo info = { .bsel_alloc =ACPI_PCIHP_BSEL_DEFAULT , + .has_bridge_hotplug = has_bridge_hotplug };if (bsel_is_set) {return ;
@@ -123,7 +132,7 @@ static void acpi_set_pci_info(void) bus =PCI_HOST_BRIDGE (host)->bus;if (bus) {/* Scan all PCI buses. Set property to enable acpi based hotplug. */ -pci_for_each_bus_depth_first (bus, acpi_set_bsel,NULL , &bsel_alloc); +pci_for_each_bus_depth_first (bus, acpi_set_bsel,NULL , &info); } }
@@ -287,7 +296,7 @@ void acpi_pcihp_reset(AcpiPciHpState *s, bool acpihp_root_off)if (acpihp_root_off) {acpi_pcihp_disable_root_bus (); } -acpi_set_pci_info (); +acpi_set_pci_info (!s->legacy_piix);acpi_pcihp_update (s); }
Signature · 1 line
2.31.1
PATCH 12/40 x86: pcihp: fix invalid AML PCNT calls to hotplugged bridges
In reply to Igor MammedovWhen QEMU is started with hotplugged bridges (think migration):
QEMU -S -monitor stdio \
-device pci-bridge,chassis_nr=1 \
-device pci-bridge,bus=pci.1,addr=1.0,chassis_nr=2 (qemu) device_add pci-bridge,id=hpbr,bus=pci.1,addr=2.0,chassis_nr=3 (qemu) cont
it will generate AML calls to hpbr's PCNT, which doesn't exists since it's hotplugged bridge. As result DSDT becomes malformed, with consequences that hotplug might stop working at best or crash guest OS at worst, when it attempts to call non existing PCNT method or during OS guest reboot when parsing DSDT again.
IASL de-compiles malformed AML of above config DSDT as:
+ External (_SB_.PCI0.S18_.S10_.PCNT, MethodObj) // Warning: Unknown method, guessing 1 arguments
+ External (_SB_.PCI0.S18_.S19_.PCNT, MethodObj) // Warning: Unknown method, guessing 2 arguments
...
BNUM = One
DVNT (PCIU, One)
DVNT (PCID, 0x03)
- ^S08.PCNT ()
+ ^S19.PCNT (^S10.PCNT (^S08.PCNT ()))
}
}With BSEL assignment limited only to coldplugged bridges [1], it should be possible to add PCNT call to a child bridge only if the child has BSEL property, otherwise ignore it since it's hotplugged. Which should fix the issue.
1) ("pci: acpihp: assign BSEL only to coldplugged bridges")
--- hw/i386/acpi-build.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/i386/acpi-build.c +2 -1
@@ -517,7 +517,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,/* Notify about child bus events in any case */ if (pcihp_bridge_en) { QLIST_FOREACH(sec, &bus->child, sibling) { -if (pci_bus_is_root (sec)) { +if (pci_bus_is_root (sec) || + !object_property_find (OBJECT (sec),ACPI_PCIHP_PROP_BSEL )) {continue ; }
Signature · 1 line
2.31.1
PATCH 13/40 tests: boot_sector_test: avoid crashing if status is not available yet
In reply to Igor MammedovIf test case was started in paused mode (-S CLI option) and then allowed to continue via QMP, boot_sector_test could assert on transient state with following error:
assertion failed (qdict_get_try_str(qret, "status") == "running"): (NULL == "running")
Instead of crashing test if 'status' is not available yet, skip check and repeat iteration again after TEST_DELAY has elapsed.
---
CC: Thomas Huth <[email protected]>
CC: Laurent Vivier <[email protected]>
--- tests/qtest/boot-sector.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tests/qtest/boot-sector.c +3 -1
@@ -160,7 +160,9 @@ void boot_sector_test(QTestState *qts) qrsp =qtest_qmp (qts,"{ 'execute': 'query-status' }" ); qret =qdict_get_qdict (qrsp,"return" );g_assert_nonnull (qret); - g_assert_cmpstr(qdict_get_try_str(qret, "status"), ==, "running"); +if (qdict_get_try_str (qret,"status" )) { + g_assert_cmpstr(qdict_get_try_str(qret, "status"), ==, "running"); + }qobject_unref (qrsp);g_usleep (TEST_DELAY );
Signature · 1 line
2.31.1
PATCH 14/40 tests: acpi: extend bridge tests with hotplugged bridges
In reply to Igor Mammedovwith previous commit fixing malformed PCNT calls to hotplugged bridges, it should be possible add coldplug/hotplug test when describing PCI topology in DSDT without breeaking CI.
---
PS:
no need to update expected blobs as hotplugged bridges shouldn't be visible (i.e. have its own slots described)
--- tests/qtest/bios-tables-test.c | 48 ++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 8 deletions(-)
tests/qtest/bios-tables-test.c +40 -8
@@ -805,12 +805,15 @@ static char *test_acpi_create_args(test_data *data, const char *params)return args; } -static void test_acpi_one (const char *params,test_data *data) +static void test_vm_prepare (const char *params,test_data *data) { -char *args; - - args =test_acpi_create_args (data, params); +char *args =test_acpi_create_args (data, params); data->qts =qtest_init (args); +g_free (args); +} + +static void process_acpi_tables (test_data *data) +{test_acpi_load_tables (data);if (getenv (ACPI_REBUILD_EXPECTED_AML )) {
@@ -830,7 +833,12 @@ static void test_acpi_one(const char *params, test_data *data) }qtest_quit (data->qts); -g_free (args); +} + +static void test_acpi_one (const char *params,test_data *data) +{ +test_vm_prepare (params, data); +process_acpi_tables (data); }static uint8_t base_required_struct_types[] = {
@@ -861,8 +869,21 @@ static void test_acpi_piix4_tcg_bridge(void) data.variant =".bridge" ; data.required_struct_types = base_required_struct_types; data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types); -test_acpi_one ("-device pci-bridge,chassis_nr=1 " -"-device pci-bridge,bus=pci.1,addr=1.0,chassis_nr=2 " , &data); +test_vm_prepare ("-S" +" -device pci-bridge,chassis_nr=1" +" -device pci-bridge,bus=pci.1,addr=1.0,chassis_nr=2" , &data); + +/* hotplugged bridges section */ +qtest_qmp_device_add (data.qts,"pci-bridge" ,"hpbr" , +"{'bus': 'pci.1', 'addr': '2.0', 'chassis_nr': 3 }" ); +qtest_qmp_device_add (data.qts,"pci-bridge" ,"hpbr_multifunc" , +"{'bus': 'pci.1', 'addr': '0xf.1', 'chassis_nr': 4 }" ); +qtest_qmp_device_add (data.qts,"pci-bridge" ,"hpbrhost" , +"{'bus': 'pci.0', 'addr': '4.0', 'chassis_nr': 5 }" ); +qtest_qmp_send (data.qts,"{'execute':'cont' }" ); +qtest_qmp_eventwait (data.qts,"RESUME" ); + +process_acpi_tables (&data);free_test_data (&data); }
@@ -962,7 +983,7 @@ static void test_acpi_q35_multif_bridge(void) .machine = MACHINE_Q35, .variant = ".multi-bridge", }; -test_acpi_one ( +test_vm_prepare ("-S" " -device virtio-balloon,id=balloon0,addr=0x4.0x2" " -device pcie-root-port,id=rp0,multifunction=on," "port=0x0,chassis=1,addr=0x2"
@@ -974,6 +995,17 @@ static void test_acpi_q35_multif_bridge(void)" -device pcie-root-port,id=rphptgt3,port=0x0,chassis=7,addr=2.3" , &data); +/* hotplugged bridges section */ +qtest_qmp_device_add (data.qts,"pci-bridge" ,"hpbr1" , +"{'bus': 'br1', 'addr': '6.0', 'chassis_nr': 128 }" ); +qtest_qmp_device_add (data.qts,"pci-bridge" ,"hpbr2-multiif" , +"{ 'bus': 'br1', 'addr': '2.2', 'chassis_nr': 129 }" ); +qtest_qmp_device_add (data.qts,"pcie-pci-bridge" ,"hpbr3" , +"{'bus': 'rp0', 'addr': '0.0' }" ); +qtest_qmp_send (data.qts,"{'execute':'cont' }" ); +qtest_qmp_eventwait (data.qts,"RESUME" ); + +process_acpi_tables (&data);free_test_data (&data); }
Signature · 1 line
2.31.1
PATCH 15/40 tests: boot_sector_test(): make it multi-shot
In reply to Igor Mammedovif the function is called the 2nd time within the same qtest session, it will prematurely return before boot sector is executed due to remaining signature.
Follow up patch will add VM reboot to a test case and will call boot_sector_test() again within the same qtest env, which may lead to above issue.
To fix it make sure signature in VM RAM is no more before exiting boot_sector_test(), so next time it's called it will wait boot sector is completed again.
---
CC: Thomas Huth <[email protected]>
CC: Laurent Vivier <[email protected]>
--- tests/qtest/boot-sector.c | 2 ++ 1 file changed, 2 insertions(+)
tests/qtest/boot-sector.c +2 -0
@@ -153,6 +153,8 @@ void boot_sector_test(QTestState *qts) signature_high =qtest_readb (qts,SIGNATURE_ADDR +1 ); signature = (signature_high <<8 ) | signature_low;if (signature ==SIGNATURE ) { +/* wipe signature */ +qtest_writeb (qts,SIGNATURE_ADDR ,0x00 );break ; }
Signature · 1 line
2.31.1
PATCH 16/40 tests: acpi: add reboot cycle to bridge test
In reply to Igor Mammedovhotplugged bridges should not be described in DSDT, while it works on cold boot, some ACPPI PCI code are invoked during reboot.
This patch will let us catch unexpected AML if hotplug checks are broken.
--- tests/qtest/bios-tables-test.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
tests/qtest/bios-tables-test.c +15 -1
@@ -812,7 +812,7 @@ static void test_vm_prepare(const char *params, test_data *data)g_free (args); } -static void process_acpi_tables (test_data *data) +static void process_acpi_tables_noexit (test_data *data) {test_acpi_load_tables (data);
@@ -831,7 +831,11 @@ static void process_acpi_tables(test_data *data)SmbiosEntryPointType ep_type =test_smbios_entry_point (data);test_smbios_structs (data, ep_type); } +} +static void process_acpi_tables (test_data *data) +{ +process_acpi_tables_noexit (data);qtest_quit (data->qts); }
@@ -883,6 +887,11 @@ static void test_acpi_piix4_tcg_bridge(void)qtest_qmp_send (data.qts,"{'execute':'cont' }" );qtest_qmp_eventwait (data.qts,"RESUME" ); +process_acpi_tables_noexit (&data); +free_test_data (&data); + +/* check that reboot/reset doesn't change any ACPI tables */ +qtest_qmp_send (data.qts,"{'execute':'system_reset' }" );process_acpi_tables (&data);free_test_data (&data); }
@@ -1005,6 +1014,11 @@ static void test_acpi_q35_multif_bridge(void)qtest_qmp_send (data.qts,"{'execute':'cont' }" );qtest_qmp_eventwait (data.qts,"RESUME" ); +process_acpi_tables_noexit (&data); +free_test_data (&data); + +/* check that reboot/reset doesn't change any ACPI tables */ +qtest_qmp_send (data.qts,"{'execute':'system_reset' }" );process_acpi_tables (&data);free_test_data (&data); }
Signature · 1 line
2.31.1
PATCH 17/40 tests: acpi: whitelist DSDT before refactoring acpi based PCI hotplug machinery
In reply to Igor Mammedov--- tests/qtest/bios-tables-test-allowed-diff.h | 1 + 1 file changed, 1 insertion(+)
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
@@ -1 +1,2 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/DSDT.hpbrroot",
Signature · 1 line
2.31.1
PATCH 18/40 pcihp: drop pcihp_bridge_en dependency when composing PCNT method
In reply to Igor Mammedov .. and use only BSEL presence to decide on how PCNT should be composed.
That simplifies possible combinations to consider, but mainly it makes PCIHP AML be governed only by BSEL, which is property of PCIBus (aka part of bridge) and as result it opens possibility to convert build_append_pci_bus_devices() into AcpiDevAmlIf::build_dev_aml callback to make bridges self describing.
PS:
used approach leaves unused PCNT, when ACPI hotplug is completely disabled but that's harmless and followup commits will get rid of it later.
Scope (PCI0)
...
Method (PCNT, 0, NotSerialized)
{
}
...
}--- hw/i386/acpi-build.c | 47 ++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 26 deletions(-)
hw/i386/acpi-build.c +21 -26
@@ -496,39 +496,34 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_append (parent_scope, notify_method); } -/* Append PCNT method to notify about events on local and child buses. -* Add this method for root bus only when hotplug is enabled since DSDT -* expects it. +/* +* Append PCNT method to notify about events on local and child buses. */ -if (bsel || pcihp_bridge_en) { - method =aml_method ("PCNT" ,0 ,AML_NOTSERIALIZED ); - -/* If bus supports hotplug select it and notify about local events */ -if (bsel) { -uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel)); + method =aml_method ("PCNT" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_store (aml_int (bsel_val),aml_name ("BNUM" ))); -aml_append (method,aml_call2 ("DVNT" ,aml_name ("PCIU" ), -aml_int (1 )));/* Device Check */ -aml_append (method,aml_call2 ("DVNT" ,aml_name ("PCID" ), -aml_int (3 )));/* Eject Request */ - } +/* If bus supports hotplug select it and notify about local events */ +if (bsel) { +uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel)); -/* Notify about child bus events in any case */ -if (pcihp_bridge_en) { - QLIST_FOREACH(sec, &bus->child, sibling) { -if (pci_bus_is_root (sec) || - !object_property_find (OBJECT (sec),ACPI_PCIHP_PROP_BSEL )) { -continue ; - } +aml_append (method,aml_store (aml_int (bsel_val),aml_name ("BNUM" ))); +aml_append (method,aml_call2 ("DVNT" ,aml_name ("PCIU" ), +aml_int (1 )));/* Device Check */ +aml_append (method,aml_call2 ("DVNT" ,aml_name ("PCID" ), +aml_int (3 )));/* Eject Request */ + } -aml_append (method,aml_name ("^S%.02X.PCNT" , - sec->parent_dev->devfn)); - } +/* Notify about child bus events in any case */ + QLIST_FOREACH(sec, &bus->child, sibling) { +if (pci_bus_is_root (sec) || + !object_property_find (OBJECT (sec),ACPI_PCIHP_PROP_BSEL )) { +continue ; } -aml_append (parent_scope, method); +aml_append (method,aml_name ("^S%.02X.PCNT" , sec->parent_dev->devfn)); } + +aml_append (parent_scope, method); +qobject_unref (bsel); }
Signature · 1 line
2.31.1
PATCH 19/40 tests: acpi: update expected blobs
In reply to Igor Mammedovexpected change:
Scope (PCI0)
...
Method (PCNT, 0, NotSerialized)
{
}
...
}--- tests/qtest/bios-tables-test-allowed-diff.h | 1 - tests/data/acpi/pc/DSDT.hpbrroot | Bin 3064 -> 3071 bytes 2 files changed, 1 deletion(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
@@ -1,2 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/DSDT.hpbrroot",
tests/data/acpi/pc/DSDT.hpbrroot binary +0 -0
Signature · 1 line
2.31.1
PATCH 20/40 tests: acpi: whitelist DSDT before refactoring acpi based PCI hotplug machinery
In reply to Igor Mammedov--- tests/qtest/bios-tables-test-allowed-diff.h | 36 +++++++++++++++++++++ 1 file changed, 36 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +36 -0
@@ -1 +1,37 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/DSDT" , +"tests/data/acpi/pc/DSDT.bridge" , +"tests/data/acpi/pc/DSDT.ipmikcs" , +"tests/data/acpi/pc/DSDT.cphp" , +"tests/data/acpi/pc/DSDT.memhp" , +"tests/data/acpi/pc/DSDT.numamem" , +"tests/data/acpi/pc/DSDT.nohpet" , +"tests/data/acpi/pc/DSDT.dimmpxm" , +"tests/data/acpi/pc/DSDT.acpihmat" , +"tests/data/acpi/pc/DSDT.acpierst" , +"tests/data/acpi/pc/DSDT.roothp" , +"tests/data/acpi/pc/DSDT.hpbrroot" , +"tests/data/acpi/pc/DSDT.hpbridge" , +"tests/data/acpi/q35/DSDT" , +"tests/data/acpi/q35/DSDT.tis.tpm2" , +"tests/data/acpi/q35/DSDT.tis.tpm12" , +"tests/data/acpi/q35/DSDT.bridge" , +"tests/data/acpi/q35/DSDT.multi-bridge" , +"tests/data/acpi/q35/DSDT.mmio64" , +"tests/data/acpi/q35/DSDT.ipmibt" , +"tests/data/acpi/q35/DSDT.cphp" , +"tests/data/acpi/q35/DSDT.memhp" , +"tests/data/acpi/q35/DSDT.numamem" , +"tests/data/acpi/q35/DSDT.nohpet" , +"tests/data/acpi/q35/DSDT.dimmpxm" , +"tests/data/acpi/q35/DSDT.acpihmat" , +"tests/data/acpi/q35/DSDT.acpierst" , +"tests/data/acpi/q35/DSDT.applesmc" , +"tests/data/acpi/q35/DSDT.pvpanic-isa" , +"tests/data/acpi/q35/DSDT.ivrs" , +"tests/data/acpi/q35/DSDT.viot" , +"tests/data/acpi/q35/DSDT.cxl" , +"tests/data/acpi/q35/DSDT.ipmismbus" , +"tests/data/acpi/q35/DSDT.xapic" , +"tests/data/acpi/q35/DSDT.acpihmat-noinitiator" , +"tests/data/acpi/q35/DSDT.core-count2",
Signature · 1 line
2.31.1
PATCH 21/40 pcihp: compose PCNT callchain right before its user _GPE._E01
In reply to Igor Mammedovit's a stepping stone to making build_append_pci_bus_devices() suitable for AcpiDevAmlIfClass:build_dev_aml callback and lets further simplify it by separating PCNT generation from slots descriptions.
It also makes PCNT callchain ASL much more readable since callchain not longer cluttered by slots descriptors.
Plus, move will let next patch easily drop empty PCNT (pc/q35) when there is nothing hotpluggable.
--- hw/i386/acpi-build.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-)
hw/i386/acpi-build.c +30 -2
@@ -390,7 +390,6 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, {Aml *dev, *notify_method =NULL , *method;QObject *bsel; -PCIBus *sec;int devfn; bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL );
@@ -496,12 +495,35 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,aml_append (parent_scope, notify_method); } +qobject_unref (bsel); +} + +static void build_append_notfication_callback (Aml *parent_scope, +const PCIBus *bus) +{ +Aml *method; +PCIBus *sec; +QObject *bsel; + + QLIST_FOREACH(sec, &bus->child, sibling) { +Aml *br_scope =aml_scope ("S%.02X" , sec->parent_dev->devfn); +if (pci_bus_is_root (sec) || + !object_property_find (OBJECT (sec),ACPI_PCIHP_PROP_BSEL )) { +continue ; + } +build_append_notfication_callback (br_scope, sec); +aml_append (parent_scope, br_scope); + } +/* * Append PCNT method to notify about events on local and child buses. +* ps: hostbridge might not have hotplug (bsel) enabled but might have +* child bridges that do have bsel. */ method =aml_method ("PCNT" ,0 ,AML_NOTSERIALIZED );/* If bus supports hotplug select it and notify about local events */ + bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL );if (bsel) {uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel));
@@ -523,7 +545,6 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, }aml_append (parent_scope, method); -qobject_unref (bsel); }
@@ -1723,6 +1744,13 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (dsdt, sb_scope);if (pm->pcihp_bridge_en || pm->pcihp_root_en) { +Object *pci_host =acpi_get_i386_pci_host (); +PCIBus *bus =PCI_HOST_BRIDGE (pci_host)->bus; + + scope =aml_scope ("\\_SB.PCI0" ); +build_append_notfication_callback (scope, bus); +aml_append (dsdt, scope); + scope =aml_scope ("_GPE" ); { method =aml_method ("_E01" ,0 ,AML_NOTSERIALIZED );
Signature · 1 line
2.31.1
PATCH 22/40 pcihp: do not put empty PCNT in DSDT
In reply to Igor Mammedovcount number of PCNT methods that actually call Notify and if there aren't any, drop PCNT altogether.
It mostly affects 'Q35' tests where there is no root-ports /bridges attached and 'PC' machine when ACPI PCI hotplug is completely disabled.
Expected ASL change:
- Method (PCNT, 0, NotSerialized)
- {
- }
...
Method (_E01, 0, NotSerialized) // _Exx: Edge-Triggered GPE
{
- Acquire (\_SB.PCI0.BLCK, 0xFFFF)
- \_SB.PCI0.PCNT ()
- Release (\_SB.PCI0.BLCK)
}--- hw/i386/acpi-build.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
hw/i386/acpi-build.c +18 -8
@@ -498,12 +498,13 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,qobject_unref (bsel); } -static void build_append_notfication_callback (Aml *parent_scope, +static bool build_append_notfication_callback (Aml *parent_scope,const PCIBus *bus) {Aml *method;PCIBus *sec;QObject *bsel; +int nr_notifiers =0 ; QLIST_FOREACH(sec, &bus->child, sibling) {Aml *br_scope =aml_scope ("S%.02X" , sec->parent_dev->devfn);
@@ -511,7 +512,8 @@ static void build_append_notfication_callback(Aml *parent_scope, !object_property_find(OBJECT(sec), ACPI_PCIHP_PROP_BSEL)) {continue ; } -build_append_notfication_callback (br_scope, sec); + nr_notifiers = nr_notifiers + +build_append_notfication_callback (br_scope, sec);aml_append (parent_scope, br_scope); }
@@ -532,6 +534,7 @@ static void build_append_notfication_callback(Aml *parent_scope, aml_int(1))); /* Device Check */aml_append (method,aml_call2 ("DVNT" ,aml_name ("PCID" ),aml_int (3 )));/* Eject Request */ + nr_notifiers++; }/* Notify about child bus events in any case */
@@ -546,6 +549,7 @@ static void build_append_notfication_callback(Aml *parent_scope,aml_append (parent_scope, method);qobject_unref (bsel); +return !!nr_notifiers; }static Aml *aml_pci_pdsm (void )
@@ -1744,20 +1748,26 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (dsdt, sb_scope);if (pm->pcihp_bridge_en || pm->pcihp_root_en) { +bool has_pcnt; +Object *pci_host =acpi_get_i386_pci_host ();PCIBus *bus =PCI_HOST_BRIDGE (pci_host)->bus; scope =aml_scope ("\\_SB.PCI0" ); -build_append_notfication_callback (scope, bus); -aml_append (dsdt, scope); + has_pcnt =build_append_notfication_callback (scope, bus); +if (has_pcnt) { +aml_append (dsdt, scope); + } scope =aml_scope ("_GPE" ); { method =aml_method ("_E01" ,0 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_acquire (aml_name ("\\_SB.PCI0.BLCK" ),0xFFFF )); -aml_append (method,aml_call0 ("\\_SB.PCI0.PCNT" )); -aml_append (method,aml_release (aml_name ("\\_SB.PCI0.BLCK" ))); +if (has_pcnt) { +aml_append (method, +aml_acquire (aml_name ("\\_SB.PCI0.BLCK" ),0xFFFF )); +aml_append (method,aml_call0 ("\\_SB.PCI0.PCNT" )); +aml_append (method,aml_release (aml_name ("\\_SB.PCI0.BLCK" ))); + }aml_append (scope, method); }aml_append (dsdt, scope);
Signature · 1 line
2.31.1
PATCH 23/40 tests: acpi: update expected blobs
In reply to Igor MammedovExpected changes:
* pc/bridge testcase due to
("pcihp: compose PCNT callchain right before its user _GPE._E01")
...
+ Scope (\_SB.PCI0)
+ {
+ Scope (S18)
+ {
+ Scope (S08)
+ {
+ Method (PCNT, 0, NotSerialized)
+ {
+ BNUM = 0x02 + DVNT (PCIU, One) + DVNT (PCID, 0x03)
+ }
+ }
Method (PCNT, 0, NotSerialized)
{
- BNUM = Zero
+ BNUM = One
DVNT (PCIU, One)
DVNT (PCID, 0x03)
- ^S18.PCNT ()
+ ^S08.PCNT ()
}
}
+
+ Method (PCNT, 0, NotSerialized)
+ {
+ BNUM = Zero
+ DVNT (PCIU, One)
+ DVNT (PCID, 0x03)
+ ^S18.PCNT ()
+ }
}
Scope (_GPE) * due to ("pcihp: do not put empty PCNT in DSDT") in the most Q35 tests
...
{
Name (_ADR, 0x001F0003) // _ADR: Address
}
-
- Method (PCNT, 0, NotSerialized)
- {
- }
}
} ...
{
Method (_E01, 0, NotSerialized) // _Exx: Edge-Triggered GPE
{
- Acquire (\_SB.PCI0.BLCK, 0xFFFF)
- \_SB.PCI0.PCNT ()
- Release (\_SB.PCI0.BLCK)
}
}--- tests/qtest/bios-tables-test-allowed-diff.h | 36 ------------------ tests/data/acpi/pc/DSDT | Bin 6458 -> 6470 bytes tests/data/acpi/pc/DSDT.acpierst | Bin 6418 -> 6430 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7783 -> 7795 bytes tests/data/acpi/pc/DSDT.bridge | Bin 12608 -> 12634 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6922 -> 6934 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 8112 -> 8124 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 6418 -> 6430 bytes tests/data/acpi/pc/DSDT.hpbrroot | Bin 3071 -> 3064 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6530 -> 6542 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7817 -> 7829 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 6316 -> 6328 bytes tests/data/acpi/pc/DSDT.numamem | Bin 6464 -> 6476 bytes tests/data/acpi/pc/DSDT.roothp | Bin 9732 -> 9758 bytes tests/data/acpi/q35/DSDT | Bin 8310 -> 8252 bytes tests/data/acpi/q35/DSDT.acpierst | Bin 8327 -> 8269 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9635 -> 9577 bytes tests/data/acpi/q35/DSDT.acpihmat-noinitiator | Bin 8589 -> 8531 bytes tests/data/acpi/q35/DSDT.applesmc | Bin 8356 -> 8298 bytes tests/data/acpi/q35/DSDT.bridge | Bin 11439 -> 11458 bytes tests/data/acpi/q35/DSDT.core-count2 | Bin 32450 -> 32392 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8774 -> 8716 bytes tests/data/acpi/q35/DSDT.cxl | Bin 9636 -> 9578 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9964 -> 9906 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 8385 -> 8327 bytes tests/data/acpi/q35/DSDT.ipmismbus | Bin 8398 -> 8340 bytes tests/data/acpi/q35/DSDT.ivrs | Bin 8327 -> 8269 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9669 -> 9611 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 9440 -> 9382 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 12301 -> 12358 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 8168 -> 8110 bytes tests/data/acpi/q35/DSDT.numamem | Bin 8316 -> 8258 bytes tests/data/acpi/q35/DSDT.pvpanic-isa | Bin 8411 -> 8353 bytes tests/data/acpi/q35/DSDT.tis.tpm12 | Bin 8916 -> 8858 bytes tests/data/acpi/q35/DSDT.tis.tpm2 | Bin 8942 -> 8884 bytes tests/data/acpi/q35/DSDT.viot | Bin 9419 -> 9361 bytes tests/data/acpi/q35/DSDT.xapic | Bin 35673 -> 35615 bytes 37 files changed, 36 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -36
@@ -1,37 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/DSDT" , -"tests/data/acpi/pc/DSDT.bridge" , -"tests/data/acpi/pc/DSDT.ipmikcs" , -"tests/data/acpi/pc/DSDT.cphp" , -"tests/data/acpi/pc/DSDT.memhp" , -"tests/data/acpi/pc/DSDT.numamem" , -"tests/data/acpi/pc/DSDT.nohpet" , -"tests/data/acpi/pc/DSDT.dimmpxm" , -"tests/data/acpi/pc/DSDT.acpihmat" , -"tests/data/acpi/pc/DSDT.acpierst" , -"tests/data/acpi/pc/DSDT.roothp" , -"tests/data/acpi/pc/DSDT.hpbrroot" , -"tests/data/acpi/pc/DSDT.hpbridge" , -"tests/data/acpi/q35/DSDT" , -"tests/data/acpi/q35/DSDT.tis.tpm2" , -"tests/data/acpi/q35/DSDT.tis.tpm12" , -"tests/data/acpi/q35/DSDT.bridge" , -"tests/data/acpi/q35/DSDT.multi-bridge" , -"tests/data/acpi/q35/DSDT.mmio64" , -"tests/data/acpi/q35/DSDT.ipmibt" , -"tests/data/acpi/q35/DSDT.cphp" , -"tests/data/acpi/q35/DSDT.memhp" , -"tests/data/acpi/q35/DSDT.numamem" , -"tests/data/acpi/q35/DSDT.nohpet" , -"tests/data/acpi/q35/DSDT.dimmpxm" , -"tests/data/acpi/q35/DSDT.acpihmat" , -"tests/data/acpi/q35/DSDT.acpierst" , -"tests/data/acpi/q35/DSDT.applesmc" , -"tests/data/acpi/q35/DSDT.pvpanic-isa" , -"tests/data/acpi/q35/DSDT.ivrs" , -"tests/data/acpi/q35/DSDT.viot" , -"tests/data/acpi/q35/DSDT.cxl" , -"tests/data/acpi/q35/DSDT.ipmismbus" , -"tests/data/acpi/q35/DSDT.xapic" , -"tests/data/acpi/q35/DSDT.acpihmat-noinitiator" , -"tests/data/acpi/q35/DSDT.core-count2",
tests/data/acpi/pc/DSDT binary +0 -0
tests/data/acpi/pc/DSDT.acpierst binary +0 -0
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
tests/data/acpi/pc/DSDT.bridge binary +0 -0
tests/data/acpi/pc/DSDT.cphp binary +0 -0
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
tests/data/acpi/pc/DSDT.hpbrroot binary +0 -0
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
tests/data/acpi/pc/DSDT.memhp binary +0 -0
tests/data/acpi/pc/DSDT.nohpet binary +0 -0
tests/data/acpi/pc/DSDT.numamem binary +0 -0
tests/data/acpi/pc/DSDT.roothp binary +0 -0
tests/data/acpi/q35/DSDT binary +0 -0
tests/data/acpi/q35/DSDT.acpierst binary +0 -0
tests/data/acpi/q35/DSDT.acpihmat binary +0 -0
tests/data/acpi/q35/DSDT.acpihmat-noinitiator binary +0 -0
tests/data/acpi/q35/DSDT.applesmc binary +0 -0
tests/data/acpi/q35/DSDT.bridge binary +0 -0
tests/data/acpi/q35/DSDT.core-count2 binary +0 -0
tests/data/acpi/q35/DSDT.cphp binary +0 -0
tests/data/acpi/q35/DSDT.cxl binary +0 -0
tests/data/acpi/q35/DSDT.dimmpxm binary +0 -0
tests/data/acpi/q35/DSDT.ipmibt binary +0 -0
tests/data/acpi/q35/DSDT.ipmismbus binary +0 -0
tests/data/acpi/q35/DSDT.ivrs binary +0 -0
tests/data/acpi/q35/DSDT.memhp binary +0 -0
tests/data/acpi/q35/DSDT.mmio64 binary +0 -0
tests/data/acpi/q35/DSDT.multi-bridge binary +0 -0
tests/data/acpi/q35/DSDT.nohpet binary +0 -0
tests/data/acpi/q35/DSDT.numamem binary +0 -0
tests/data/acpi/q35/DSDT.pvpanic-isa binary +0 -0
tests/data/acpi/q35/DSDT.tis.tpm12 binary +0 -0
tests/data/acpi/q35/DSDT.tis.tpm2 binary +0 -0
tests/data/acpi/q35/DSDT.viot binary +0 -0
tests/data/acpi/q35/DSDT.xapic binary +0 -0
Signature · 1 line
2.31.1
PATCH 24/40 whitelist DSDT before adding endpoint devices to bridge testcases
In reply to Igor Mammedov--- tests/qtest/bios-tables-test-allowed-diff.h | 4 ++++ 1 file changed, 4 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +4 -0
@@ -1 +1,5 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/DSDT.roothp" , +"tests/data/acpi/pc/DSDT.hpbrroot" , +"tests/data/acpi/q35/DSDT.bridge" , +"tests/data/acpi/q35/DSDT.multi-bridge",
Signature · 1 line
2.31.1
PATCH 25/40 tests: acpi: add endpoint devices to bridges
In reply to Igor Mammedovto make sure that they are enumerated or ignored as expected
--- tests/qtest/bios-tables-test.c | 37 ++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-)
tests/qtest/bios-tables-test.c +29 -8
@@ -875,7 +875,9 @@ static void test_acpi_piix4_tcg_bridge(void) data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types);test_vm_prepare ("-S" " -device pci-bridge,chassis_nr=1" -" -device pci-bridge,bus=pci.1,addr=1.0,chassis_nr=2" , &data); +" -device pci-bridge,bus=pci.1,addr=1.0,chassis_nr=2" +" -device pci-testdev,bus=pci.0,addr=5.0" +" -device pci-testdev,bus=pci.1" , &data);/* hotplugged bridges section */ qtest_qmp_device_add(data.qts, "pci-bridge", "hpbr",
@@ -884,6 +886,10 @@ static void test_acpi_piix4_tcg_bridge(void) "{'bus': 'pci.1', 'addr': '0xf.1', 'chassis_nr': 4 }");qtest_qmp_device_add (data.qts,"pci-bridge" ,"hpbrhost" ,"{'bus': 'pci.0', 'addr': '4.0', 'chassis_nr': 5 }" ); +qtest_qmp_device_add (data.qts,"pci-testdev" ,"d1" ,"{'bus': 'pci.0' }" ); +qtest_qmp_device_add (data.qts,"pci-testdev" ,"d2" ,"{'bus': 'pci.1' }" ); +qtest_qmp_device_add (data.qts,"pci-testdev" ,"d3" ,"{'bus': 'hpbr', " +"'addr': '1.0' }" );qtest_qmp_send (data.qts,"{'execute':'cont' }" );qtest_qmp_eventwait (data.qts,"RESUME" );
@@ -907,7 +913,9 @@ static void test_acpi_piix4_no_root_hotplug(void) data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types);test_acpi_one ("-global PIIX4_PM.acpi-root-pci-hotplug=off " "-device pci-bridge,chassis_nr=1 " -"-device pci-bridge,bus=pci.1,addr=1.0,chassis_nr=2 " , &data); +"-device pci-bridge,bus=pci.1,addr=1.0,chassis_nr=2 " +"-device pci-testdev,bus=pci.0 " +"-device pci-testdev,bus=pci.1" , &data);free_test_data (&data); }
@@ -922,7 +930,9 @@ static void test_acpi_piix4_no_bridge_hotplug(void) data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types);test_acpi_one ("-global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off " "-device pci-bridge,chassis_nr=1 " -"-device pci-bridge,bus=pci.1,addr=1.0,chassis_nr=2 " , &data); +"-device pci-bridge,bus=pci.1,addr=1.0,chassis_nr=2 " +"-device pci-testdev,bus=pci.0 " +"-device pci-testdev,bus=pci.1,addr=2.0" , &data);free_test_data (&data); }
@@ -937,7 +947,9 @@ static void test_acpi_piix4_no_acpi_pci_hotplug(void) data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types);test_acpi_one ("-global PIIX4_PM.acpi-root-pci-hotplug=off " "-global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off " -"-device pci-bridge,chassis_nr=1" , &data); +"-device pci-bridge,chassis_nr=1 " +"-device pci-testdev,bus=pci.0 " +"-device pci-testdev,bus=pci.1" , &data);free_test_data (&data); }
@@ -982,7 +994,9 @@ static void test_acpi_q35_tcg_bridge(void) data.variant =".bridge" ; data.required_struct_types = base_required_struct_types; data.required_struct_types_len =ARRAY_SIZE (base_required_struct_types); -test_acpi_one ("-device pci-bridge,chassis_nr=1" , &data); +test_acpi_one ("-device pci-bridge,chassis_nr=1,id=br1" +" -device pci-testdev,bus=pcie.0" +" -device pci-testdev,bus=br1" , &data);free_test_data (&data); }
@@ -1001,8 +1015,11 @@ static void test_acpi_q35_multif_bridge(void)" -device pci-bridge,bus=rp2,chassis_nr=4,id=br1" " -device pcie-root-port,id=rphptgt1,port=0x0,chassis=5,addr=2.1" " -device pcie-root-port,id=rphptgt2,port=0x0,chassis=6,addr=2.2" -" -device pcie-root-port,id=rphptgt3,port=0x0,chassis=7,addr=2.3" , - &data); +" -device pcie-root-port,id=rphptgt3,port=0x0,chassis=7,addr=2.3" +" -device pci-testdev,bus=pcie.0,addr=2.4" +" -device pci-testdev,bus=pcie.0,addr=5.0" +" -device pci-testdev,bus=rp0,addr=0.0" + " -device pci-testdev,bus=br1", &data);/* hotplugged bridges section */ qtest_qmp_device_add(data.qts, "pci-bridge", "hpbr1",
@@ -1010,7 +1027,11 @@ static void test_acpi_q35_multif_bridge(void)qtest_qmp_device_add (data.qts,"pci-bridge" ,"hpbr2-multiif" ,"{ 'bus': 'br1', 'addr': '2.2', 'chassis_nr': 129 }" );qtest_qmp_device_add (data.qts,"pcie-pci-bridge" ,"hpbr3" , -"{'bus': 'rp0', 'addr': '0.0' }" ); +"{'bus': 'rphptgt1', 'addr': '0.0' }" ); +qtest_qmp_device_add (data.qts,"pcie-root-port" ,"hprp" , +"{'bus': 'rphptgt2', 'addr': '0.0' }" ); +qtest_qmp_device_add (data.qts,"pci-testdev" ,"hpnic" , +"{'bus': 'rphptgt3', 'addr': '0.0' }" );qtest_qmp_send (data.qts,"{'execute':'cont' }" );qtest_qmp_eventwait (data.qts,"RESUME" );
Signature · 1 line
2.31.1
PATCH 26/40 tests: acpi: update expected blobs
In reply to Igor Mammedovprevious commit added endpoint devices to bridge testcases, which exposes extra non-hotpluggable slot in DSDT on bus where hotplug is not available.
It should look like this (numbers may vary):
+ Device (S28)
+ {
+ Name (_ADR, 0x00050000) // _ADR: Address
+ }
--- tests/qtest/bios-tables-test-allowed-diff.h | 4 ---- tests/data/acpi/pc/DSDT.hpbrroot | Bin 3064 -> 3081 bytes tests/data/acpi/pc/DSDT.roothp | Bin 9758 -> 9775 bytes tests/data/acpi/q35/DSDT.bridge | Bin 11458 -> 11475 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 12358 -> 12375 bytes 5 files changed, 4 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -4
@@ -1,5 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/DSDT.roothp" , -"tests/data/acpi/pc/DSDT.hpbrroot" , -"tests/data/acpi/q35/DSDT.bridge" , -"tests/data/acpi/q35/DSDT.multi-bridge",
tests/data/acpi/pc/DSDT.hpbrroot binary +0 -0
tests/data/acpi/pc/DSDT.roothp binary +0 -0
tests/data/acpi/q35/DSDT.bridge binary +0 -0
tests/data/acpi/q35/DSDT.multi-bridge binary +0 -0
Signature · 1 line
2.31.1
PATCH 27/40 x86: pcihp: acpi: prepare slot ignore rule to work with self describing bridges
In reply to Igor MammedovBefore switching pci bridges to AcpiDevAmlIf interface, ensure that ignored slots are handled correctly.
(existing rule works but only if bridge doesn't have AcpiDevAmlIf interface). While at it rewrite related comments to be less confusing (hopefully).
--- hw/i386/acpi-build.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
hw/i386/acpi-build.c +16 -8
@@ -425,14 +425,22 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, hotpluggbale_slot = bsel && dc->hotpluggable && !cold_plugged_bridge; -/* -* allow describing coldplugged bridges in ACPI even if they are not -* on function 0, as they are not unpluggable, for all other devices -* generate description only for function 0 per slot, and for other -* functions if device on function provides its own AML -*/ -if (func && !bridge_in_acpi && !get_dev_aml_func (DEVICE (pdev))) { -continue ; +if (func) { +if (IS_PCI_BRIDGE (pdev)) { +/* +* Ignore only hotplugged PCI bridges on !0 functions, but +* allow describing cold plugged bridges on all functions +*/ +if (DEVICE (pdev)->hotplugged) { +continue ; + } + }else if (!get_dev_aml_func (DEVICE (pdev))) { +/* +* Ignore all other devices on !0 functions unless they +* have AML description (i.e have get_dev_aml_func() != 0) +*/ +continue ; + } } }else {/*
Signature · 1 line
2.31.1
PATCH 28/40 pci: acpi: wire up AcpiDevAmlIf interface to generic bridge
In reply to Igor Mammedov... so that the concrete impl. won't has to duplicate it every time. By default it doesn't do anything unless leaf class defines and sets AcpiDevAmlIfClass::build_dev_aml handler.
--- hw/pci/pci_bridge.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/pci/pci_bridge.c +5 -0
@@ -36,6 +36,7 @@#include "qemu/module.h" #include "qemu/range.h" #include "qapi/error.h" +#include "hw/acpi/acpi_aml_interface.h" /* PCI bridge subsystem vendor ID helper functions */ #define PCI_SSVID_SIZEOF 8
@@ -472,6 +473,10 @@ static const TypeInfo pci_bridge_type_info = { .parent = TYPE_PCI_DEVICE, .instance_size = sizeof(PCIBridge), .abstract = true, + .interfaces = (InterfaceInfo []) { + {TYPE_ACPI_DEV_AML_IF }, + { }, + }, };static void pci_bridge_register_types (void )
Signature · 1 line
2.31.1
PATCH 29/40 pcihp: make bridge describe itself using AcpiDevAmlIfClass:build_dev_aml
In reply to Igor Mammedovsimplify build_append_pci_bus_devices() a bit by handling bridge specific logic in bridge dedicated AcpiDevAmlIfClass::build_dev_aml callback.
--- include/hw/acpi/pci.h | 4 ++++ hw/acpi/Kconfig | 4 ++++ hw/acpi/meson.build | 4 +++- hw/acpi/pci-bridge-stub.c | 20 ++++++++++++++++++++ hw/acpi/pci-bridge.c | 27 +++++++++++++++++++++++++++ hw/i386/Kconfig | 1 + hw/i386/acpi-build.c | 17 ++--------------- hw/pci/pci_bridge.c | 9 +++++++++ 8 files changed, 70 insertions(+), 16 deletions(-) create mode 100644 hw/acpi/pci-bridge-stub.c create mode 100644 hw/acpi/pci-bridge.c
include/hw/acpi/pci.h +4 -0
@@ -27,6 +27,7 @@#define HW_ACPI_PCI_H #include "hw/acpi/bios-linker-loader.h" +#include "hw/acpi/acpi_aml_interface.h" typedef struct AcpiMcfgInfo { uint64_t base;
@@ -36,4 +37,7 @@ typedef struct AcpiMcfgInfo {void build_mcfg (GArray *table_data,BIOSLinker *linker,AcpiMcfgInfo *info,const char *oem_id,const char *oem_table_id);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);#endif
hw/acpi/Kconfig +4 -0
@@ -39,6 +39,10 @@ config ACPI_PCIHP bool depends on ACPI +config ACPI_PCI_BRIDGE + bool + depends on ACPI && PCI && ACPI_PCIHP + config ACPI_HMAT bool depends on ACPI
hw/acpi/meson.build +3 -1
@@ -19,6 +19,7 @@ acpi_ss.add(when: 'CONFIG_ACPI_HW_REDUCED', if_true: files('generic_event_device acpi_ss.add(when: 'CONFIG_ACPI_HMAT', if_true: files('hmat.c')) acpi_ss.add(when: 'CONFIG_ACPI_APEI', if_true: files('ghes.c'), if_false: files('ghes-stub.c')) acpi_ss.add(when: 'CONFIG_ACPI_PIIX4', if_true: files('piix4.c')) +acpi_ss.add(when: 'CONFIG_ACPI_PCI_BRIDGE', if_true: files('pci-bridge.c')) acpi_ss.add(when: 'CONFIG_ACPI_PCIHP', if_true: files('pcihp.c')) acpi_ss.add(when: 'CONFIG_ACPI_PCIHP', if_false: files('acpi-pci-hotplug-stub.c')) acpi_ss.add(when: 'CONFIG_ACPI_VIOT', if_true: files('viot.c'))
@@ -30,9 +31,10 @@ if have_tpm acpi_ss.add(files('tpm.c')) endif softmmu_ss.add(when: 'CONFIG_ACPI', if_false: files('acpi-stub.c', 'aml-build-stub.c', 'ghes-stub.c', 'acpi_interface.c')) +softmmu_ss.add(when: 'CONFIG_ACPI_PCI_BRIDGE', if_false: files('pci-bridge-stub.c')) softmmu_ss.add_all(when: 'CONFIG_ACPI', if_true: acpi_ss) softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('acpi-stub.c', 'aml-build-stub.c', 'acpi-x86-stub.c', 'ipmi-stub.c', 'ghes-stub.c', 'acpi-mem-hotplug-stub.c', 'acpi-cpu-hotplug-stub.c', 'acpi-pci-hotplug-stub.c', 'acpi-nvdimm-stub.c', - 'cxl-stub.c')) + 'cxl-stub.c', 'pci-bridge-stub.c'))
hw/acpi/pci-bridge-stub.c new file +20 -0
@@ -0,0 +1,20 @@ +/* +* QEMU ACPI PCI bridge stub +* +* Copyright (c) 2023 Red Hat, Inc. +* +* Author: +* Igor Mammedov <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "hw/acpi/pci.h" + +void build_pci_bridge_aml (AcpiDevAmlIf *adev,Aml *scope) +{ +}
hw/acpi/pci-bridge.c new file +27 -0
@@ -0,0 +1,27 @@ +/* +* QEMU ACPI PCI bridge +* +* Copyright (c) 2023 Red Hat, Inc. +* +* Author: +* Igor Mammedov <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "hw/acpi/pci.h" +#include "hw/pci/pci_bridge.h" +#include "hw/acpi/pcihp.h" + +void build_pci_bridge_aml (AcpiDevAmlIf *adev,Aml *scope) +{ +PCIBridge *br =PCI_BRIDGE (adev); + +if (object_property_find (OBJECT (&br->sec_bus),ACPI_PCIHP_PROP_BSEL )) { +build_append_pci_bus_devices (scope,pci_bridge_get_sec_bus (br)); + } +}
hw/i386/Kconfig +1 -0
@@ -58,6 +58,7 @@ config PC_ACPI select ACPI_X86 select ACPI_CPU_HOTPLUG select ACPI_MEMORY_HOTPLUG + select ACPI_PCI_BRIDGE select ACPI_VIOT select SMBUS_EEPROM select PFLASH_CFI01
hw/i386/acpi-build.c +2 -15
@@ -385,8 +385,7 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)aml_append (method, if_ctx); } -static void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus, -bool pcihp_bridge_en) +void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus) {Aml *dev, *notify_method =NULL , *method;QObject *bsel;
@@ -408,7 +407,6 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,/* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */ int adr = slot <<16 | func;bool hotpluggbale_slot = false; -bool bridge_in_acpi = false;bool cold_plugged_bridge = false;if (pdev) {
@@ -420,7 +418,6 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,*/ cold_plugged_bridge =IS_PCI_BRIDGE (pdev) && !DEVICE (pdev)->hotplugged; - bridge_in_acpi = cold_plugged_bridge && pcihp_bridge_en; hotpluggbale_slot = bsel && dc->hotpluggable && !cold_plugged_bridge;
@@ -473,16 +470,6 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,call_dev_aml_func (DEVICE (pdev), dev); -if (bridge_in_acpi) { -/* -* device is coldplugged bridge, -* add child device descriptions into its scope -*/ -PCIBus *sec_bus =pci_bridge_get_sec_bus (PCI_BRIDGE (pdev)); - -build_append_pci_bus_devices (dev, sec_bus, pcihp_bridge_en); - } -if (hotpluggbale_slot) {aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));/* add _EJ0 to make slot hotpluggable */
@@ -1706,7 +1693,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,PCIBus *bus =PCI_HOST_BRIDGE (pci_host)->bus;Aml *scope =aml_scope ("PCI0" );/* Scan all PCI buses. Generate tables to support hotplug. */ -build_append_pci_bus_devices (scope, bus, pm->pcihp_bridge_en); +build_append_pci_bus_devices (scope, bus);aml_append (sb_scope, scope); } }
hw/pci/pci_bridge.c +9 -0
@@ -37,6 +37,7 @@#include "qemu/range.h" #include "qapi/error.h" #include "hw/acpi/acpi_aml_interface.h" +#include "hw/acpi/pci.h" /* PCI bridge subsystem vendor ID helper functions */ #define PCI_SSVID_SIZEOF 8
@@ -468,10 +469,18 @@ int pci_bridge_qemu_reserve_cap_init(PCIDevice *dev, int cap_offset,return 0 ; } +static void pci_bridge_class_init (ObjectClass *klass,void *data) +{ +AcpiDevAmlIfClass *adevc =ACPI_DEV_AML_IF_CLASS (klass); + + adevc->build_dev_aml = build_pci_bridge_aml; +} +static const TypeInfo pci_bridge_type_info = { .name =TYPE_PCI_BRIDGE , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (PCIBridge), + .class_init = pci_bridge_class_init, .abstract = true, .interfaces = (InterfaceInfo []) { {TYPE_ACPI_DEV_AML_IF },
Signature · 1 line
2.31.1
PATCH 30/40 pci: make sure pci_bus_is_express() won't error out with "discards ‘const’ qualifier"
In reply to Igor Mammedovfunction doesn't need RW aceess to passed in bus pointer, make it const.
--- include/hw/pci/pci.h | 2 +- hw/pci/pci.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/hw/pci/pci.h +1 -1
@@ -270,7 +270,7 @@ typedef void (*pci_bus_dev_fn)(PCIBus *b, PCIDevice *d, void *opaque);typedef void (*pci_bus_fn )(PCIBus *b,void *opaque);typedef void *(*pci_bus_ret_fn )(PCIBus *b,void *opaque); -bool pci_bus_is_express (PCIBus *bus); +bool pci_bus_is_express (const PCIBus *bus); void pci_root_bus_init(PCIBus *bus, size_t bus_size, DeviceState *parent, const char *name,
hw/pci/pci.c +1 -1
@@ -482,7 +482,7 @@ static void pci_bus_uninit(PCIBus *bus)pci_host_bus_unregister (BUS (bus)->parent); } -bool pci_bus_is_express (PCIBus *bus) +bool pci_bus_is_express (const PCIBus *bus) {return object_dynamic_cast (OBJECT (bus),TYPE_PCIE_BUS ); }
Signature · 1 line
2.31.1
PATCH 31/40 pcihp: isolate rule whether slot should be described in DSDT
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 83 +++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 40 deletions(-)
hw/i386/acpi-build.c +43 -40
@@ -385,6 +385,42 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)aml_append (method, if_ctx); } +static bool is_devfn_ignored (const int devfn,const PCIBus *bus, +bool bus_has_hotplug) +{ +const PCIDevice *pdev = bus->devices[devfn]; + +if (pdev) { +if (PCI_FUNC (devfn)) { +if (IS_PCI_BRIDGE (pdev)) { +/* +* Ignore only hotplugged PCI bridges on !0 functions, but +* allow describing cold plugged bridges on all functions +*/ +if (DEVICE (pdev)->hotplugged) { +return true; + } + }else if (!get_dev_aml_func (DEVICE (pdev))) { +/* +* Ignore all other devices on !0 functions unless they +* have AML description (i.e have get_dev_aml_func() != 0) +*/ +return true; + } + } + }else {/* non populated slots */ +/* +* hotplug is supported only for non-multifunction device +* so generate device description only for function 0 +*/ +if (!bus_has_hotplug ||PCI_FUNC (devfn) || + (pci_bus_is_express (bus) &&PCI_SLOT (devfn) >0 )) { +return true; + } + } +return false; +} +void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus) {Aml *dev, *notify_method =NULL , *method;
@@ -400,59 +436,26 @@ void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus) }for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) { -DeviceClass *dc;PCIDevice *pdev = bus->devices[devfn];int slot =PCI_SLOT (devfn);int func =PCI_FUNC (devfn);/* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */ int adr = slot <<16 | func; -bool hotpluggbale_slot = false; -bool cold_plugged_bridge = false; +bool hotpluggbale_slot = true; -if (pdev) { - dc =DEVICE_GET_CLASS (pdev); +if (is_devfn_ignored (devfn, bus, !!bsel)) { +continue ; + } +if (pdev) {/* * Cold plugged bridges aren't themselves hot-pluggable. * Hotplugged bridges *are* hot-pluggable. */ - cold_plugged_bridge =IS_PCI_BRIDGE (pdev) && +bool cold_plugged_bridge =IS_PCI_BRIDGE (pdev) && !DEVICE (pdev)->hotplugged; - - hotpluggbale_slot = bsel && dc->hotpluggable && + hotpluggbale_slot = bsel &&DEVICE_GET_CLASS (pdev)->hotpluggable && !cold_plugged_bridge; - -if (func) { -if (IS_PCI_BRIDGE (pdev)) { -/* -* Ignore only hotplugged PCI bridges on !0 functions, but -* allow describing cold plugged bridges on all functions -*/ -if (DEVICE (pdev)->hotplugged) { -continue ; - } - }else if (!get_dev_aml_func (DEVICE (pdev))) { -/* -* Ignore all other devices on !0 functions unless they -* have AML description (i.e have get_dev_aml_func() != 0) -*/ -continue ; - } - } - }else { -/* -* hotplug is supported only for non-multifunction device -* so generate device description only for function 0 -*/ -if (bsel && !func) { -if (pci_bus_is_express (bus) && slot >0 ) { -break ; - } -/* mark it as empty hotpluggable slot */ - hotpluggbale_slot = true; - }else { -continue ; - } }/* start to compose PCI device descriptor */
Signature · 1 line
2.31.1
PATCH 32/40 tests: acpi: whitelist DSDT before decoupling PCI hotplug code from basic slots description
In reply to Igor Mammedov--- tests/qtest/bios-tables-test-allowed-diff.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +14 -0
@@ -1 +1,15 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/DSDT" , +"tests/data/acpi/pc/DSDT.acpierst" , +"tests/data/acpi/pc/DSDT.acpihmat" , +"tests/data/acpi/pc/DSDT.bridge" , +"tests/data/acpi/pc/DSDT.cphp" , +"tests/data/acpi/pc/DSDT.dimmpxm" , +"tests/data/acpi/pc/DSDT.hpbridge" , +"tests/data/acpi/pc/DSDT.ipmikcs" , +"tests/data/acpi/pc/DSDT.memhp" , +"tests/data/acpi/pc/DSDT.nohpet" , +"tests/data/acpi/pc/DSDT.numamem" , +"tests/data/acpi/pc/DSDT.roothp" , +"tests/data/acpi/q35/DSDT.bridge" , +"tests/data/acpi/q35/DSDT.multi-bridge",
Signature · 1 line
2.31.1
PATCH 33/40 pcihp: acpi: decouple hotplug and generic slots description
In reply to Igor MammedovSplit build_append_pci_bus_devices() onto generic part that builds AML descriptions only for populated slots which is applicable to both hotplug disabled and enabled bridges. And a hotplug only part that complements generic AML with hotplug depended bits (that depend on BSEL), like _SUN/_EJ0 entries, dynamic _DSM.
Hotplug part, will generate full 'Device' descriptors for non-populated slots (like it used to be) and complementary 'Scope' descriptors for populated slots that are hotplug capable. i.e. something like this:
- ...
+ Name (BSEL, 0x03)
+ Scope (S00)
+ {
+ Name (ASUN, Zero)
+ Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
+ { + Local0 = Package (0x02)
+ {
+ BSEL,
+ ASUN
+ }
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, Local0))
+ }
+ [ ... other hotplug depended bits ]
+ }
While generic build_append_pci_bus_devices() still calls hotplug part at its end it doesn't really depend on any hotplug bits anymore and later both could be completely separated when it's necessary.
Main benefit though is that both build_append_pci_bus_devices() and build_append_pcihp_slots() become more readable and it makes easier to modify them with less risk of affecting another part. Also it opens possibility to re-use generic part elsewhere (microvm, arm/virt).
---
PS:
All that comes at cost of some code duplication and extra AML (Scope), but I think simpler and more resuable code well worth of it.
--- hw/i386/acpi-build.c | 121 +++++++++++++++++++++++++------------------ 1 file changed, 72 insertions(+), 49 deletions(-)
hw/i386/acpi-build.c +72 -49
@@ -385,35 +385,40 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)aml_append (method, if_ctx); } -static bool is_devfn_ignored (const int devfn,const PCIBus *bus, -bool bus_has_hotplug) +static bool is_devfn_ignored_generic (const int devfn,const PCIBus *bus) {const PCIDevice *pdev = bus->devices[devfn]; -if (pdev) { -if (PCI_FUNC (devfn)) { -if (IS_PCI_BRIDGE (pdev)) { -/* -* Ignore only hotplugged PCI bridges on !0 functions, but -* allow describing cold plugged bridges on all functions -*/ -if (DEVICE (pdev)->hotplugged) { -return true; - } - }else if (!get_dev_aml_func (DEVICE (pdev))) { -/* -* Ignore all other devices on !0 functions unless they -* have AML description (i.e have get_dev_aml_func() != 0) -*/ +if (PCI_FUNC (devfn)) { +if (IS_PCI_BRIDGE (pdev)) { +/* +* Ignore only hotplugged PCI bridges on !0 functions, but +* allow describing cold plugged bridges on all functions +*/ +if (DEVICE (pdev)->hotplugged) {return true; } + }else if (!get_dev_aml_func (DEVICE (pdev))) { +/* +* Ignore all other devices on !0 functions unless they +* have AML description (i.e have get_dev_aml_func() != 0) +*/ +return true; } + } +return false; +} + +static bool is_devfn_ignored_hotplug (const int devfn,const PCIBus *bus) +{ +if (bus->devices[devfn]) { +return is_devfn_ignored_generic (devfn, bus); }else {/* non populated slots */ -/* +/* * hotplug is supported only for non-multifunction device * so generate device description only for function 0 */ -if (!bus_has_hotplug ||PCI_FUNC (devfn) || +if (PCI_FUNC (devfn) || (pci_bus_is_express (bus) &&PCI_SLOT (devfn) >0 )) {return true; }
@@ -421,29 +426,23 @@ static bool is_devfn_ignored(const int devfn, const PCIBus *bus,return false; } -void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus) +static void build_append_pcihp_slots (Aml *parent_scope,PCIBus *bus, +QObject *bsel) { -Aml *dev, *notify_method =NULL , *method; -QObject *bsel;int devfn; +Aml *dev, *notify_method =NULL , *method; +uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel)); - bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL ); -if (bsel) { -uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel)); - -aml_append (parent_scope,aml_name_decl ("BSEL" ,aml_int (bsel_val))); - notify_method =aml_method ("DVNT" ,2 ,AML_NOTSERIALIZED ); - } +aml_append (parent_scope,aml_name_decl ("BSEL" ,aml_int (bsel_val))); + notify_method =aml_method ("DVNT" ,2 ,AML_NOTSERIALIZED );for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) {PCIDevice *pdev = bus->devices[devfn];int slot =PCI_SLOT (devfn); -int func =PCI_FUNC (devfn); -/* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */ -int adr = slot <<16 | func; +int adr = slot <<16 |PCI_FUNC (devfn);bool hotpluggbale_slot = true; -if (is_devfn_ignored (devfn, bus, !!bsel)) { +if (is_devfn_ignored_hotplug (devfn, bus)) {continue ; }
@@ -454,24 +453,20 @@ void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus)*/ bool cold_plugged_bridge =IS_PCI_BRIDGE (pdev) && !DEVICE (pdev)->hotplugged; - hotpluggbale_slot = bsel &&DEVICE_GET_CLASS (pdev)->hotpluggable && + hotpluggbale_slot =DEVICE_GET_CLASS (pdev)->hotpluggable && !cold_plugged_bridge; + dev =aml_scope ("S%.02X" , devfn); + }else { + dev =aml_device ("S%.02X" , devfn); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); } -/* start to compose PCI device descriptor */ - dev =aml_device ("S%.02X" , devfn); -aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); - -if (bsel) { -/* -* Can't declare _SUN here for every device as it changes 'slot' -* enumeration order in linux kernel, so use another variable for it -*/ -aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot))); -aml_append (dev,aml_pci_device_dsm ()); - } - -call_dev_aml_func (DEVICE (pdev), dev); +/* +* Can't declare _SUN here for every device as it changes 'slot' +* enumeration order in linux kernel, so use another variable for it +*/ +aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot))); +aml_append (dev,aml_pci_device_dsm ());if (hotpluggbale_slot) {aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));
@@ -488,9 +483,37 @@ void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus)/* device descriptor has been composed, add it into parent context */ aml_append (parent_scope, dev); } +aml_append (parent_scope, notify_method); +} + +void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus) +{ +QObject *bsel; +int devfn; +Aml *dev; + + bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL ); + +for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) { +/* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */ +int adr =PCI_SLOT (devfn) <<16 |PCI_FUNC (devfn); + +if (!bus->devices[devfn] ||is_devfn_ignored_generic (devfn, bus)) { +continue ; + } + +/* start to compose PCI device descriptor */ + dev =aml_device ("S%.02X" , devfn); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); + +call_dev_aml_func (DEVICE (bus->devices[devfn]), dev); + +/* device descriptor has been composed, add it into parent context */ +aml_append (parent_scope, dev); + }if (bsel) { -aml_append (parent_scope, notify_method); +build_append_pcihp_slots (parent_scope, bus, bsel); }qobject_unref (bsel);
Signature · 1 line
2.31.1
PATCH 34/40 tests: acpi: update expected blobs
In reply to Igor MammedovExpected change for non-populated slots is that thay are moved after non-hotpluggable PCI tree description.
And expected change for hotplug capable populated slots is:
- ...
+ Name (BSEL, 0x03)
+ Scope (S00)
+ {
+ Name (ASUN, Zero)
+ Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
+ { + Local0 = Package (0x02)
+ {
+ BSEL,
+ ASUN
+ }
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, Local0))
+ }
[ ... other hotplug depended bits ]
+ }
--- tests/qtest/bios-tables-test-allowed-diff.h | 14 -------------- tests/data/acpi/pc/DSDT | Bin 6470 -> 6487 bytes tests/data/acpi/pc/DSDT.acpierst | Bin 6430 -> 6453 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7795 -> 7812 bytes tests/data/acpi/pc/DSDT.bridge | Bin 12634 -> 12699 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6934 -> 6951 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 8124 -> 8141 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 6430 -> 6459 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6542 -> 6559 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7829 -> 7846 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 6328 -> 6345 bytes tests/data/acpi/pc/DSDT.numamem | Bin 6476 -> 6493 bytes tests/data/acpi/pc/DSDT.roothp | Bin 9775 -> 9787 bytes tests/data/acpi/q35/DSDT.bridge | Bin 11475 -> 11481 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 12375 -> 12423 bytes 15 files changed, 14 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -14
@@ -1,15 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/DSDT" , -"tests/data/acpi/pc/DSDT.acpierst" , -"tests/data/acpi/pc/DSDT.acpihmat" , -"tests/data/acpi/pc/DSDT.bridge" , -"tests/data/acpi/pc/DSDT.cphp" , -"tests/data/acpi/pc/DSDT.dimmpxm" , -"tests/data/acpi/pc/DSDT.hpbridge" , -"tests/data/acpi/pc/DSDT.ipmikcs" , -"tests/data/acpi/pc/DSDT.memhp" , -"tests/data/acpi/pc/DSDT.nohpet" , -"tests/data/acpi/pc/DSDT.numamem" , -"tests/data/acpi/pc/DSDT.roothp" , -"tests/data/acpi/q35/DSDT.bridge" , -"tests/data/acpi/q35/DSDT.multi-bridge",
tests/data/acpi/pc/DSDT binary +0 -0
tests/data/acpi/pc/DSDT.acpierst binary +0 -0
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
tests/data/acpi/pc/DSDT.bridge binary +0 -0
tests/data/acpi/pc/DSDT.cphp binary +0 -0
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
tests/data/acpi/pc/DSDT.memhp binary +0 -0
tests/data/acpi/pc/DSDT.nohpet binary +0 -0
tests/data/acpi/pc/DSDT.numamem binary +0 -0
tests/data/acpi/pc/DSDT.roothp binary +0 -0
tests/data/acpi/q35/DSDT.bridge binary +0 -0
tests/data/acpi/q35/DSDT.multi-bridge binary +0 -0
Signature · 1 line
2.31.1
PATCH 35/40 tests: acpi: whitelist DSDT blobs before removing dynamic _DSM on coldplugged bridges
In reply to Igor Mammedov--- tests/qtest/bios-tables-test-allowed-diff.h | 4 ++++ 1 file changed, 4 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +4 -0
@@ -1 +1,5 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/DSDT.bridge" , +"tests/data/acpi/pc/DSDT.roothp" , +"tests/data/acpi/pc/DSDT.hpbridge" , +"tests/data/acpi/q35/DSDT.multi-bridge",
Signature · 1 line
2.31.1
PATCH 36/40 pcihp: acpi: ignore coldplugged bridges when composing hotpluggable slots
In reply to Igor Mammedovcoldplugged bridges are not unpluggable, so there is no need to describe slots where they are plugged as hotpluggable. To that effect we have a condition that marks slot as non-hotpluggable if it's populated by coldplugged bridge and prevents generation _SUN/_EJ0 objects for it. That leaves dynamic _DSM method on such slot (which also depends on BSEL and pcihp hardware). This _DSM method provides only dynamic acpi-index support so far, which is not actually used/supported by linux kernel for bridges and it's doubtful there will be need for it at all.
So it's rather pointless to generate acpi-index related AML for bridges and we can simplify hotplug slots generator a bit more by completely ignoring coldplugged bridges on hotplug path.
Another point in favor of dropping dynamic _DSM support, is that we can replace it with static _DSM if necessary since a slot with bridge can't change during VM runtime and without any dependency on ACPI PCI hotplug at that.
Later I plan to implement bridge specific static _DSM
PCI Firmware Specification 3.2
4.6.5. _DSM for Ignoring PCI Boot Configurations
part of spec, to fix longstanding issue with fixed IO/MEM resource assignment that often leads to hotplugged device being in-operational within the guest due limited IO/MEM windows programmed on bridge at boot time.
Expected change when coldplugged bridge is ignored by hotplug code, should look like:
- Scope (S18)
- {
- Name (ASUN, 0x03)
- Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
- {- Local0 = Package (0x02)
- {
- BSEL,
- ASUN
- }
- Return (PDSM (Arg0, Arg1, Arg2, Arg3, Local0))
- }
- }
--- hw/i386/acpi-build.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
hw/i386/acpi-build.c +6 -10
@@ -411,8 +411,11 @@ static bool is_devfn_ignored_generic(const int devfn, const PCIBus *bus)static bool is_devfn_ignored_hotplug (const int devfn,const PCIBus *bus) { -if (bus->devices[devfn]) { -return is_devfn_ignored_generic (devfn, bus); +PCIDevice *pdev = bus->devices[devfn]; +if (pdev) { +return is_devfn_ignored_generic (devfn, bus) || +/* Cold plugged bridges aren't themselves hot-pluggable */ + (IS_PCI_BRIDGE (pdev) && !DEVICE (pdev)->hotplugged); }else {/* non populated slots */ /* * hotplug is supported only for non-multifunction device
@@ -447,14 +450,7 @@ static void build_append_pcihp_slots(Aml *parent_scope, PCIBus *bus, }if (pdev) { -/* -* Cold plugged bridges aren't themselves hot-pluggable. -* Hotplugged bridges *are* hot-pluggable. -*/ -bool cold_plugged_bridge =IS_PCI_BRIDGE (pdev) && - !DEVICE (pdev)->hotplugged; - hotpluggbale_slot =DEVICE_GET_CLASS (pdev)->hotpluggable && - !cold_plugged_bridge; + hotpluggbale_slot =DEVICE_GET_CLASS (pdev)->hotpluggable; dev =aml_scope ("S%.02X" , devfn); }else { dev =aml_device ("S%.02X" , devfn);
Signature · 1 line
2.31.1
PATCH 37/40 tests: acpi: update expected blobs
In reply to Igor Mammedovexpected change is removal of dynamic _DSM bits from slots populated by coldplugged bridges (something like):
- Scope (S18)
- {
- Name (ASUN, 0x03)
- Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
- {
- Local0 = Package (0x02)
- {
- BSEL,
- ASUN
- }
- Return (PDSM (Arg0, Arg1, Arg2, Arg3, Local0))
- }
- }
--- tests/qtest/bios-tables-test-allowed-diff.h | 4 ---- tests/data/acpi/pc/DSDT.bridge | Bin 12699 -> 12614 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 6459 -> 6416 bytes tests/data/acpi/pc/DSDT.roothp | Bin 9787 -> 9745 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 12423 -> 12337 bytes 5 files changed, 4 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -4
@@ -1,5 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/DSDT.bridge" , -"tests/data/acpi/pc/DSDT.roothp" , -"tests/data/acpi/pc/DSDT.hpbridge" , -"tests/data/acpi/q35/DSDT.multi-bridge",
tests/data/acpi/pc/DSDT.bridge binary +0 -0
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
tests/data/acpi/pc/DSDT.roothp binary +0 -0
tests/data/acpi/q35/DSDT.multi-bridge binary +0 -0
Signature · 1 line
2.31.1
PATCH 38/40 tests: acpi: whitelist DSDT before moving non-hotpluggble slots description from hotplug path
In reply to Igor Mammedov--- tests/qtest/bios-tables-test-allowed-diff.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +11 -0
@@ -1 +1,12 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/DSDT" , +"tests/data/acpi/pc/DSDT.acpierst" , +"tests/data/acpi/pc/DSDT.acpihmat" , +"tests/data/acpi/pc/DSDT.bridge" , +"tests/data/acpi/pc/DSDT.cphp" , +"tests/data/acpi/pc/DSDT.dimmpxm" , +"tests/data/acpi/pc/DSDT.hpbridge" , +"tests/data/acpi/pc/DSDT.ipmikcs" , +"tests/data/acpi/pc/DSDT.memhp" , +"tests/data/acpi/pc/DSDT.nohpet" , +"tests/data/acpi/pc/DSDT.numamem",
Signature · 1 line
2.31.1
PATCH 39/40 pcihp: generate populated non-hotpluggble slot descriptions on non-hotplug path
In reply to Igor MammedovGenerating slots descriptions populated by non-hotpluggable devices is akward at best and complicates hotplug path (build_append_pcihp_slots) needlessly, and builds only dynamic _DSM for such slots which is overlkill. Clean it up and let non-hotplug path (build_append_pci_bus_devices) to handle that task.
Such clean up effectively drops dynamic _DSM methods on non-hotpluggable slots (even though bus itself is hotpluggable), but in practice it affects only built-in devices (ide controllers/various bridges) that don't use acpi-index anyways so effectively it doesn't matter (NICs are hotpluggble).
Follow up series will add static _DSM for non-hotpluggble devices/buses that will not depend on ACPI PCI hotplug at all, and potentially would allows us to reuse non-hotplug path elsewhere (PBX/microvm/arm-virt), including new support for acpi-index for non-hotpluggable devices.
--- hw/i386/acpi-build.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-)
hw/i386/acpi-build.c +12 -15
@@ -414,6 +414,7 @@ static bool is_devfn_ignored_hotplug(const int devfn, const PCIBus *bus)PCIDevice *pdev = bus->devices[devfn];if (pdev) {return is_devfn_ignored_generic (devfn, bus) || + !DEVICE_GET_CLASS (pdev)->hotpluggable ||/* Cold plugged bridges aren't themselves hot-pluggable */ (IS_PCI_BRIDGE (pdev) && !DEVICE (pdev)->hotplugged); }else {/* non populated slots */
@@ -440,17 +441,14 @@ static void build_append_pcihp_slots(Aml *parent_scope, PCIBus *bus, notify_method =aml_method ("DVNT" ,2 ,AML_NOTSERIALIZED );for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) { -PCIDevice *pdev = bus->devices[devfn];int slot =PCI_SLOT (devfn);int adr = slot <<16 |PCI_FUNC (devfn); -bool hotpluggbale_slot = true;if (is_devfn_ignored_hotplug (devfn, bus)) {continue ; } -if (pdev) { - hotpluggbale_slot =DEVICE_GET_CLASS (pdev)->hotpluggable; +if (bus->devices[devfn]) { dev =aml_scope ("S%.02X" , devfn); }else { dev =aml_device ("S%.02X" , devfn);
@@ -464,17 +462,15 @@ static void build_append_pcihp_slots(Aml *parent_scope, PCIBus *bus,aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot)));aml_append (dev,aml_pci_device_dsm ()); -if (hotpluggbale_slot) { -aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); -/* add _EJ0 to make slot hotpluggable */ - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) - ); -aml_append (dev, method); +aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); +/* add _EJ0 to make slot hotpluggable */ + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) + ); +aml_append (dev, method); -build_append_pcihp_notify_entry (notify_method, slot); - } +build_append_pcihp_notify_entry (notify_method, slot);/* device descriptor has been composed, add it into parent context */ aml_append (parent_scope, dev);
@@ -493,8 +489,9 @@ void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus)for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) {/* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */ int adr =PCI_SLOT (devfn) <<16 |PCI_FUNC (devfn); +PCIDevice *pdev = bus->devices[devfn]; -if (!bus->devices[devfn] ||is_devfn_ignored_generic (devfn, bus)) { +if (!pdev ||is_devfn_ignored_generic (devfn, bus)) {continue ; }
Signature · 1 line
2.31.1
PATCH 40/40 tests: acpi: update expected blobs
In reply to Igor MammedovExpected change removal of dynamic _DSM AML for non-hotpluggable hots-bridge, storage, isa bridge devices from PC machine blobs:
- Scope (S00)
- {
- Name (ASUN, Zero)
- Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
- {
- Local0 = Package (0x02)
- {
- BSEL,
- ASUN
- }
- Return (PDSM (Arg0, Arg1, Arg2, Arg3, Local0))
- }
- }
-
- Scope (S08)
- {
- Name (ASUN, One)
- Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
- {
- Local0 = Package (0x02)
- {
- BSEL,
- ASUN
- }
- Return (PDSM (Arg0, Arg1, Arg2, Arg3, Local0))
- }
- }
-
- Scope (S10)
- {
- Name (ASUN, 0x02)
- Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
- { - Local0 = Package (0x02)
- {
- BSEL,
- ASUN
- }
- Return (PDSM (Arg0, Arg1, Arg2, Arg3, Local0))
- }
- }
--- tests/qtest/bios-tables-test-allowed-diff.h | 11 ----------- tests/data/acpi/pc/DSDT | Bin 6487 -> 6360 bytes tests/data/acpi/pc/DSDT.acpierst | Bin 6453 -> 6283 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7812 -> 7685 bytes tests/data/acpi/pc/DSDT.bridge | Bin 12614 -> 12487 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6951 -> 6824 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 8141 -> 8014 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 6416 -> 6289 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6559 -> 6432 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7846 -> 7719 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 6345 -> 6218 bytes tests/data/acpi/pc/DSDT.numamem | Bin 6493 -> 6366 bytes 12 files changed, 11 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -11
@@ -1,12 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/DSDT" , -"tests/data/acpi/pc/DSDT.acpierst" , -"tests/data/acpi/pc/DSDT.acpihmat" , -"tests/data/acpi/pc/DSDT.bridge" , -"tests/data/acpi/pc/DSDT.cphp" , -"tests/data/acpi/pc/DSDT.dimmpxm" , -"tests/data/acpi/pc/DSDT.hpbridge" , -"tests/data/acpi/pc/DSDT.ipmikcs" , -"tests/data/acpi/pc/DSDT.memhp" , -"tests/data/acpi/pc/DSDT.nohpet" , -"tests/data/acpi/pc/DSDT.numamem",
tests/data/acpi/pc/DSDT binary +0 -0
tests/data/acpi/pc/DSDT.acpierst binary +0 -0
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
tests/data/acpi/pc/DSDT.bridge binary +0 -0
tests/data/acpi/pc/DSDT.cphp binary +0 -0
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
tests/data/acpi/pc/DSDT.memhp binary +0 -0
tests/data/acpi/pc/DSDT.nohpet binary +0 -0
tests/data/acpi/pc/DSDT.numamem binary +0 -0
Signature · 1 line
2.31.1
On Thu, 12 Jan 2023 15:02:32 +0100
Igor Mammedov <[email protected]> wrote:
ping,
Michael can you take a look at this series and queue it if it looks acceptable to you.
PS:
I'm waiting on this being merged, to send acpi-index support on non-hotpluggable ports (due to heavy dependency on this refactoring). After which I plan to post series that allows resources reallocation on bridges. (both should be doable in 8.0 timeframe)
(the rest: acpi-index for pxb and other targets/machines, pci-hostbridge cleanups will be after that but probably won't make into 8.0)
Quoted 147 lines
Series continues refactoring on top of [1].
It focuses on isolating creation of non hotplug and hotplug slot descriptions. In state it's posted, it's not complete, but pretty close to it. The series contains stable patches from refactoring and is already too large to keep it to myself, hence I'm publishing it fro review.
It will be followed by separate series on top of this one, that will finish concrete feature[s] in following order:
1 introduce acpi-index support for non-hotpluggable PCI
devices (i.e. NICs directly attached to Q35 host-bridge) making acpi-index support complete within pc/q35 machines.
2 let guest OS to re-arrange bridge resources when ACPI PCI
hotplug is enabled. (should fix insuficient resources issue during PCI hotplug)
3 finish isolating hotplug code from non-hotplug one,
which should allow to re-use non-hotplug parts in other machines (arm/virt and microvm) and bring acpi-index support there.PS:
Refactoring also adds testing for various corner cases and fixes (present/latent/imagined) bugs where they were spotted.1) "[PATCH 00/11] x86: clean up ACPI PCI code part 2"
https://www.mail-archive.com/[email protected]/msg915493.htmlCC "Michael S. Tsirkin" <[email protected]>CC Ani Sinha <[email protected]>Igor Mammedov (40):
tests: qtest: printdevice_adderror before failing test
tests: acpi: cleanup arguments to make them more readable
tests: acpi: whitelist DSDT blobs for tests that use pci-bridges
tests: acpi: extend pcihp with nested bridges
tests: acpi: update expected blobs
tests: acpi: cleanupuse_uefiargument usage
pci_bridge: remove whitespace
x86: acpi: pcihp: clean up duplicatebridge_in_acpiassignment
pci: acpi hotplug: rename x-native-hotplug to
x-do-not-expose-native-hotplug-cap
pcihp: piix4: do not callacpi_pcihp_reset()when ACPI PCI hotplug is
disabled
pci: acpihp: assign BSEL only to coldplugged bridges
x86: pcihp: fix invalid AML PCNT calls to hotplugged bridges
tests:boot_sector_test: avoid crashing if status is not available yet
tests: acpi: extend bridge tests with hotplugged bridges
tests:boot_sector_test(): make it multi-shot
tests: acpi: add reboot cycle to bridge test
tests: acpi: whitelist DSDT before refactoring acpi based PCI hotplug
machinery
pcihp: droppcihp_bridge_endependency when composing PCNT method
tests: acpi: update expected blobs
tests: acpi: whitelist DSDT before refactoring acpi based PCI hotplug
machinery
pcihp: compose PCNT callchain right before its user _GPE._E01
pcihp: do not put empty PCNT in DSDT
tests: acpi: update expected blobs
whitelist DSDT before adding endpoint devices to bridge testcases
tests: acpi: add endpoint devices to bridges
tests: acpi: update expected blobs
x86: pcihp: acpi: prepare slot ignore rule to work with self
describing bridges
pci: acpi: wire up AcpiDevAmlIf interface to generic bridge
pcihp: make bridge describe itself using
AcpiDevAmlIfClass:build_dev_aml
pci: make surepci_bus_is_express()won't error out with "discards
‘const’ qualifier"
pcihp: isolate rule whether slot should be described in DSDT
tests: acpi: whitelist DSDT before decoupling PCI hotplug code from
basic slots description
pcihp: acpi: decouple hotplug and generic slots description
tests: acpi: update expected blobs
tests: acpi: whitelist DSDT blobs before removing dynamic_DSMon
coldplugged bridges
pcihp: acpi: ignore coldplugged bridges when composing hotpluggable
slots
tests: acpi: update expected blobs
tests: acpi: whitelist DSDT before moving non-hotpluggble slots
description from hotplug path
pcihp: generate populated non-hotpluggble slot descriptions on
non-hotplug path
tests: acpi: update expected blobsinclude/hw/acpi/pci.h | 4 + include/hw/pci/pci.h | 2 +- include/hw/pci/pcie_port.h | 3 +- hw/acpi/Kconfig | 4 + hw/acpi/meson.build | 4 +- hw/acpi/pci-bridge-stub.c | 20 ++ hw/acpi/pci-bridge.c | 27 ++ hw/acpi/pcihp.c | 35 ++- hw/acpi/piix4.c | 4 +- hw/i386/Kconfig | 1 + hw/i386/acpi-build.c | 279 ++++++++++-------- hw/i386/pc_q35.c | 5 +- hw/pci-bridge/gen_pcie_root_port.c | 7 +- hw/pci-bridge/pci_bridge_dev.c | 1 - hw/pci/pci.c | 2 +- hw/pci/pci_bridge.c | 14 + hw/pci/pcie.c | 6 +- hw/pci/pcie_port.c | 3 +- tests/data/acpi/pc/DSDT | Bin 6458 -> 6360 bytes tests/data/acpi/pc/DSDT.acpierst | Bin 6418 -> 6283 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7783 -> 7685 bytes tests/data/acpi/pc/DSDT.bridge | Bin 9532 -> 12487 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6922 -> 6824 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 8112 -> 8014 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 6418 -> 6289 bytes tests/data/acpi/pc/DSDT.hpbrroot | Bin 3064 -> 3081 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6530 -> 6432 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7817 -> 7719 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 6316 -> 6218 bytes tests/data/acpi/pc/DSDT.numamem | Bin 6464 -> 6366 bytes tests/data/acpi/pc/DSDT.roothp | Bin 6656 -> 9745 bytes tests/data/acpi/q35/DSDT | Bin 8310 -> 8252 bytes tests/data/acpi/q35/DSDT.acpierst | Bin 8327 -> 8269 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9635 -> 9577 bytes tests/data/acpi/q35/DSDT.acpihmat-noinitiator | Bin 8589 -> 8531 bytes tests/data/acpi/q35/DSDT.applesmc | Bin 8356 -> 8298 bytes tests/data/acpi/q35/DSDT.bridge | Bin 11439 -> 11481 bytes tests/data/acpi/q35/DSDT.core-count2 | Bin 32450 -> 32392 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8774 -> 8716 bytes tests/data/acpi/q35/DSDT.cxl | Bin 9636 -> 9578 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9964 -> 9906 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 8385 -> 8327 bytes tests/data/acpi/q35/DSDT.ipmismbus | Bin 8398 -> 8340 bytes tests/data/acpi/q35/DSDT.ivrs | Bin 8327 -> 8269 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9669 -> 9611 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 9440 -> 9382 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 8630 -> 12337 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 8168 -> 8110 bytes tests/data/acpi/q35/DSDT.numamem | Bin 8316 -> 8258 bytes tests/data/acpi/q35/DSDT.pvpanic-isa | Bin 8411 -> 8353 bytes tests/data/acpi/q35/DSDT.tis.tpm12 | Bin 8916 -> 8858 bytes tests/data/acpi/q35/DSDT.tis.tpm2 | Bin 8942 -> 8884 bytes tests/data/acpi/q35/DSDT.viot | Bin 9419 -> 9361 bytes tests/data/acpi/q35/DSDT.xapic | Bin 35673 -> 35615 bytes tests/qtest/bios-tables-test.c | 144 ++++++--- tests/qtest/boot-sector.c | 6 +- tests/qtest/libqtest.c | 4 + 57 files changed, 394 insertions(+), 181 deletions(-) create mode 100644 hw/acpi/pci-bridge-stub.c create mode 100644 hw/acpi/pci-bridge.c
Quoted 7 lines · Igor Mammedov
On Thu, 12 Jan 2023 15:02:32 +0100
Igor Mammedov <[email protected]> wrote:ping,
Michael can you take a look at this series and queue it if it looks acceptable to you.
Yes it's tagged already. RSN.
Quoted 159 lines
PS:
I'm waiting on this being merged, to send acpi-index support on non-hotpluggable ports (due to heavy dependency on this refactoring). After which I plan to post series that allows resources reallocation on bridges. (both should be doable in 8.0 timeframe)(the rest: acpi-index for pxb and other targets/machines, pci-hostbridge cleanups will be after that but probably won't make into 8.0)
Quoted 147 lines
Series continues refactoring on top of [1].
It focuses on isolating creation of non hotplug and hotplug slot descriptions. In state it's posted, it's not complete, but pretty close to it. The series contains stable patches from refactoring and is already too large to keep it to myself, hence I'm publishing it fro review.
It will be followed by separate series on top of this one, that will finish concrete feature[s] in following order:
1 introduce acpi-index support for non-hotpluggable PCI
devices (i.e. NICs directly attached to Q35 host-bridge) making acpi-index support complete within pc/q35 machines.
2 let guest OS to re-arrange bridge resources when ACPI PCI
hotplug is enabled. (should fix insuficient resources issue during PCI hotplug)
3 finish isolating hotplug code from non-hotplug one,
which should allow to re-use non-hotplug parts in other machines (arm/virt and microvm) and bring acpi-index support there.PS:
Refactoring also adds testing for various corner cases and fixes (present/latent/imagined) bugs where they were spotted.1) "[PATCH 00/11] x86: clean up ACPI PCI code part 2"
https://www.mail-archive.com/[email protected]/msg915493.htmlCC "Michael S. Tsirkin" <[email protected]>CC Ani Sinha <[email protected]>Igor Mammedov (40):
tests: qtest: printdevice_adderror before failing test
tests: acpi: cleanup arguments to make them more readable
tests: acpi: whitelist DSDT blobs for tests that use pci-bridges
tests: acpi: extend pcihp with nested bridges
tests: acpi: update expected blobs
tests: acpi: cleanupuse_uefiargument usage
pci_bridge: remove whitespace
x86: acpi: pcihp: clean up duplicatebridge_in_acpiassignment
pci: acpi hotplug: rename x-native-hotplug to
x-do-not-expose-native-hotplug-cap
pcihp: piix4: do not callacpi_pcihp_reset()when ACPI PCI hotplug is
disabled
pci: acpihp: assign BSEL only to coldplugged bridges
x86: pcihp: fix invalid AML PCNT calls to hotplugged bridges
tests:boot_sector_test: avoid crashing if status is not available yet
tests: acpi: extend bridge tests with hotplugged bridges
tests:boot_sector_test(): make it multi-shot
tests: acpi: add reboot cycle to bridge test
tests: acpi: whitelist DSDT before refactoring acpi based PCI hotplug
machinery
pcihp: droppcihp_bridge_endependency when composing PCNT method
tests: acpi: update expected blobs
tests: acpi: whitelist DSDT before refactoring acpi based PCI hotplug
machinery
pcihp: compose PCNT callchain right before its user _GPE._E01
pcihp: do not put empty PCNT in DSDT
tests: acpi: update expected blobs
whitelist DSDT before adding endpoint devices to bridge testcases
tests: acpi: add endpoint devices to bridges
tests: acpi: update expected blobs
x86: pcihp: acpi: prepare slot ignore rule to work with self
describing bridges
pci: acpi: wire up AcpiDevAmlIf interface to generic bridge
pcihp: make bridge describe itself using
AcpiDevAmlIfClass:build_dev_aml
pci: make surepci_bus_is_express()won't error out with "discards
‘const’ qualifier"
pcihp: isolate rule whether slot should be described in DSDT
tests: acpi: whitelist DSDT before decoupling PCI hotplug code from
basic slots description
pcihp: acpi: decouple hotplug and generic slots description
tests: acpi: update expected blobs
tests: acpi: whitelist DSDT blobs before removing dynamic_DSMon
coldplugged bridges
pcihp: acpi: ignore coldplugged bridges when composing hotpluggable
slots
tests: acpi: update expected blobs
tests: acpi: whitelist DSDT before moving non-hotpluggble slots
description from hotplug path
pcihp: generate populated non-hotpluggble slot descriptions on
non-hotplug path
tests: acpi: update expected blobsinclude/hw/acpi/pci.h | 4 + include/hw/pci/pci.h | 2 +- include/hw/pci/pcie_port.h | 3 +- hw/acpi/Kconfig | 4 + hw/acpi/meson.build | 4 +- hw/acpi/pci-bridge-stub.c | 20 ++ hw/acpi/pci-bridge.c | 27 ++ hw/acpi/pcihp.c | 35 ++- hw/acpi/piix4.c | 4 +- hw/i386/Kconfig | 1 + hw/i386/acpi-build.c | 279 ++++++++++-------- hw/i386/pc_q35.c | 5 +- hw/pci-bridge/gen_pcie_root_port.c | 7 +- hw/pci-bridge/pci_bridge_dev.c | 1 - hw/pci/pci.c | 2 +- hw/pci/pci_bridge.c | 14 + hw/pci/pcie.c | 6 +- hw/pci/pcie_port.c | 3 +- tests/data/acpi/pc/DSDT | Bin 6458 -> 6360 bytes tests/data/acpi/pc/DSDT.acpierst | Bin 6418 -> 6283 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 7783 -> 7685 bytes tests/data/acpi/pc/DSDT.bridge | Bin 9532 -> 12487 bytes tests/data/acpi/pc/DSDT.cphp | Bin 6922 -> 6824 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 8112 -> 8014 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 6418 -> 6289 bytes tests/data/acpi/pc/DSDT.hpbrroot | Bin 3064 -> 3081 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 6530 -> 6432 bytes tests/data/acpi/pc/DSDT.memhp | Bin 7817 -> 7719 bytes tests/data/acpi/pc/DSDT.nohpet | Bin 6316 -> 6218 bytes tests/data/acpi/pc/DSDT.numamem | Bin 6464 -> 6366 bytes tests/data/acpi/pc/DSDT.roothp | Bin 6656 -> 9745 bytes tests/data/acpi/q35/DSDT | Bin 8310 -> 8252 bytes tests/data/acpi/q35/DSDT.acpierst | Bin 8327 -> 8269 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9635 -> 9577 bytes tests/data/acpi/q35/DSDT.acpihmat-noinitiator | Bin 8589 -> 8531 bytes tests/data/acpi/q35/DSDT.applesmc | Bin 8356 -> 8298 bytes tests/data/acpi/q35/DSDT.bridge | Bin 11439 -> 11481 bytes tests/data/acpi/q35/DSDT.core-count2 | Bin 32450 -> 32392 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8774 -> 8716 bytes tests/data/acpi/q35/DSDT.cxl | Bin 9636 -> 9578 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9964 -> 9906 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 8385 -> 8327 bytes tests/data/acpi/q35/DSDT.ipmismbus | Bin 8398 -> 8340 bytes tests/data/acpi/q35/DSDT.ivrs | Bin 8327 -> 8269 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9669 -> 9611 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 9440 -> 9382 bytes tests/data/acpi/q35/DSDT.multi-bridge | Bin 8630 -> 12337 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 8168 -> 8110 bytes tests/data/acpi/q35/DSDT.numamem | Bin 8316 -> 8258 bytes tests/data/acpi/q35/DSDT.pvpanic-isa | Bin 8411 -> 8353 bytes tests/data/acpi/q35/DSDT.tis.tpm12 | Bin 8916 -> 8858 bytes tests/data/acpi/q35/DSDT.tis.tpm2 | Bin 8942 -> 8884 bytes tests/data/acpi/q35/DSDT.viot | Bin 9419 -> 9361 bytes tests/data/acpi/q35/DSDT.xapic | Bin 35673 -> 35615 bytes tests/qtest/bios-tables-test.c | 144 ++++++--- tests/qtest/boot-sector.c | 6 +- tests/qtest/libqtest.c | 4 + 57 files changed, 394 insertions(+), 181 deletions(-) create mode 100644 hw/acpi/pci-bridge-stub.c create mode 100644 hw/acpi/pci-bridge.c