Use ACPI PCI hot-plug for Q35
v4 cover Use ACPI PCI hot-plug for Q35
The patch set consists of two parts:
patches 1-4: introduce new feature
'acpi-pci-hotplug-with-bridge-support' on Q35
patches 5-7: make the feature default along with changes in ACPI tables
This way maintainers can decide which way to choose without breaking the patch set.
With the feature disabled Q35 falls back to the native hot-plug.
Pros
* no racy behavior during boot (see 110c477c2ed)
* eject is possible - according to PCIe spec, attention button press should lead to power off, and then the adapter should be removed manually. As there is no power down state exists in QEMU, we cannot distinguish between an eject and a power down request.
* no delay during deleting - after the actual power off software must wait at least 1 second before indicating about it. This case is quite important for users, it even has its own bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1594168
* no timer-based behavior - in addition to the previous example, the attention button has a 5-second waiting period, during which the operation can be canceled with a second press. While this looks fine for manual button control, automation will result in the need to queue or drop events, and the software receiving events in all sort of unspecified combinations of attention/power indicator states, which is racy and uppredictable.
* fixes or reduces the likelihood of the bugs:
* https://bugzilla.redhat.com/show_bug.cgi?id=1833187
* https://bugzilla.redhat.com/show_bug.cgi?id=1657077
* https://bugzilla.redhat.com/show_bug.cgi?id=1669931
* https://bugzilla.redhat.com/show_bug.cgi?id=1678290
Cons:
* no access to possible features presented in slot capabilities (this is only surprise removal AFAIK)
v4:
* regain per-port control over hot-plug
* rebased over acpi-index changes
* set property on machine type to
make pci code more generic [Igor, Michael]
v3:
* drop change of _OSC to allow SHPC on hotplugged bridges
* use 'acpi-root-pci-hotplug'
* add migration states [Igor]
* minor style changes
v2:
* new ioport range for acpiphp [Gerd]
* drop find_pci_host() [Igor]
* explain magic numbers in _OSC [Igor]
* drop build_q35_pci_hotplug() wrapper [Igor]
Julia Suvorova (7):
hw/acpi/pcihp: Enhance acpi_pcihp_disable_root_bus() to support Q35 hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35 hw/acpi/ich9: Enable ACPI PCI hot-plug
hw/pci/pcie: Do not set HPC flag if acpihp is used
bios-tables-test: Allow changes in DSDT ACPI tables hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35
bios-tables-test: Update golden binaries
hw/i386/acpi-build.h | 5 +++ include/hw/acpi/ich9.h | 5 +++ include/hw/acpi/pcihp.h | 3 +- include/hw/boards.h | 1 + hw/acpi/ich9.c | 68 ++++++++++++++++++++++++++++++ hw/acpi/pcihp.c | 22 +++++++--- hw/acpi/piix4.c | 4 +- hw/core/machine.c | 19 +++++++++ hw/i386/acpi-build.c | 32 ++++++++------ hw/i386/pc.c | 4 +- hw/i386/pc_q35.c | 8 ++++ hw/pci/pcie.c | 11 ++++- tests/data/acpi/q35/DSDT | Bin 7859 -> 8289 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9184 -> 9614 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7877 -> 11003 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8323 -> 8753 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9513 -> 9943 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7934 -> 8364 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9218 -> 9648 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8990 -> 9419 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 7717 -> 8147 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7865 -> 8295 bytes tests/data/acpi/q35/DSDT.tis | Bin 8465 -> 8894 bytes 23 files changed, 161 insertions(+), 21 deletions(-)
Signature · 1 line
2.30.2
RFC PATCH v4 1/7 hw/acpi/pcihp: Enhance acpi_pcihp_disable_root_bus() to support Q35
PCI Express does not allow hot-plug on pcie.0. Check for Q35 in acpi_pcihp_disable_root_bus() to be able to forbid hot-plug using the 'acpi-root-pci-hotplug' flag.
--- hw/acpi/pcihp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/acpi/pcihp.c +2 -1
@@ -122,13 +122,14 @@ static void acpi_set_pci_info(void)static void acpi_pcihp_disable_root_bus (void ) {static bool root_hp_disabled; +Object *host =acpi_get_i386_pci_host ();PCIBus *bus;if (root_hp_disabled) {return ; } - bus =find_i440fx (); + bus =PCI_HOST_BRIDGE (host)->bus;if (bus) {/* setting the hotplug handler to NULL makes the bus non-hotpluggable */ qbus_set_hotplug_handler (BUS (bus),NULL );
Signature · 1 line
2.30.2
RFC PATCH v4 2/7 hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35
In reply to Julia SuvorovaImplement notifications and gpe to support q35 ACPI PCI hot-plug. Use 0xcc4 - 0xcd7 range for 'acpi-pci-hotplug' io ports.
--- hw/i386/acpi-build.h | 4 ++++ include/hw/acpi/ich9.h | 2 ++ include/hw/acpi/pcihp.h | 3 ++- hw/acpi/pcihp.c | 6 +++--- hw/acpi/piix4.c | 4 +++- hw/i386/acpi-build.c | 30 +++++++++++++++++++----------- 6 files changed, 33 insertions(+), 16 deletions(-)
hw/i386/acpi-build.h +4 -0
@@ -5,6 +5,10 @@extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio; +/* PCI Hot-plug registers bases. See docs/spec/acpi_pci_hotplug.txt */ +#define ACPI_PCIHP_SEJ_BASE 0x8 +#define ACPI_PCIHP_BNMR_BASE 0x10 +void acpi_setup (void );#endif
include/hw/acpi/ich9.h +2 -0
@@ -28,6 +28,8 @@#include "hw/acpi/acpi_dev_interface.h" #include "hw/acpi/tco.h" +#define ACPI_PCIHP_ADDR_ICH9 0x0cc4 + typedef struct ICH9LPCPMRegs { /* * In ich9 spec says that pm1_cnt register is 32bit width and
include/hw/acpi/pcihp.h +2 -1
@@ -55,7 +55,8 @@ typedef struct AcpiPciHpState { } AcpiPciHpState;void acpi_pcihp_init (Object *owner,AcpiPciHpState *,PCIBus *root, -MemoryRegion *address_space_io,bool bridges_enabled); +MemoryRegion *address_space_io,bool bridges_enabled, +uint16_t io_base);void acpi_pcihp_device_pre_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp);
hw/acpi/pcihp.c +3 -3
@@ -37,7 +37,6 @@#include "qom/qom-qobject.h" #include "trace.h" -#define ACPI_PCIHP_ADDR 0xae00#define ACPI_PCIHP_SIZE 0x0018#define PCI_UP_BASE 0x0000#define PCI_DOWN_BASE 0x0004
@@ -489,10 +488,11 @@ static const MemoryRegionOps acpi_pcihp_io_ops = { };void acpi_pcihp_init (Object *owner,AcpiPciHpState *s,PCIBus *root_bus, -MemoryRegion *address_space_io,bool bridges_enabled) +MemoryRegion *address_space_io,bool bridges_enabled, +uint16_t io_base) { s->io_len =ACPI_PCIHP_SIZE ; - s->io_base =ACPI_PCIHP_ADDR ; + s->io_base = io_base; s->root = root_bus; s->legacy_piix = !bridges_enabled;
hw/acpi/piix4.c +3 -1
@@ -49,6 +49,8 @@#define GPE_BASE 0xafe0#define GPE_LEN 4 +#define ACPI_PCIHP_ADDR_PIIX4 0xae00 +struct pci_status {uint32_t up;/* deprecated, maintained for migration compatibility */ uint32_t down;
@@ -607,7 +609,7 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,if (s->use_acpi_hotplug_bridge || s->use_acpi_root_pci_hotplug) {acpi_pcihp_init (OBJECT (s), &s->acpi_pci_hotplug, bus, parent, - s->use_acpi_hotplug_bridge); + s->use_acpi_hotplug_bridge,ACPI_PCIHP_ADDR_PIIX4 ); } s->cpu_hotplug_legacy = true;
hw/i386/acpi-build.c +19 -11
@@ -217,10 +217,6 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)/* w2k requires FADT(rev1) or it won't boot, keep PC compatible */ pm->fadt.rev =1 ; pm->cpu_hp_io_base =PIIX4_CPU_HOTPLUG_IO_BASE ; - pm->pcihp_io_base = -object_property_get_uint (obj,ACPI_PCIHP_IO_BASE_PROP ,NULL ); - pm->pcihp_io_len = -object_property_get_uint (obj,ACPI_PCIHP_IO_LEN_PROP ,NULL ); }if (lpc) { uint64_t smi_features = object_property_get_uint(lpc,
@@ -236,6 +232,10 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm) pm->smi_on_cpu_unplug = !!(smi_features &BIT_ULL (ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT )); } + pm->pcihp_io_base = +object_property_get_uint (obj,ACPI_PCIHP_IO_BASE_PROP ,NULL ); + pm->pcihp_io_len = +object_property_get_uint (obj,ACPI_PCIHP_IO_LEN_PROP ,NULL );/* The above need not be conditional on machine type because the reset port * happens to be the same on PIIX (pc) and ICH9 (q35). */
@@ -388,6 +388,9 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,if (!pdev) {if (bsel) {/* add hotplug slots for non present devices */ +if (pci_bus_is_express (bus) && slot >0 ) { +break ; + } dev =aml_device ("S%.02X" ,PCI_DEVFN (slot,0 ));aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot)));aml_append (dev,aml_name_decl ("_ADR" ,aml_int (slot <<16 )));
@@ -512,7 +515,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, QLIST_FOREACH(sec, &bus->child, sibling) {int32_t devfn = sec->parent_dev->devfn; -if (pci_bus_is_root (sec) ||pci_bus_is_express (sec)) { +if (pci_bus_is_root (sec)) {continue ; }
@@ -1242,7 +1245,7 @@ static void build_piix4_isa_bridge(Aml *table)aml_append (table, scope); } -static void build_piix4_pci_hotplug (Aml *table) +static void build_x86_acpi_pci_hotplug (Aml *table,uint64_t pcihp_addr) {Aml *scope;Aml *field;
@@ -1251,20 +1254,22 @@ static void build_piix4_pci_hotplug(Aml *table) scope =aml_scope ("_SB.PCI0" );aml_append (scope, -aml_operation_region ("PCST" ,AML_SYSTEM_IO ,aml_int (0xae00 ),0x08 )); +aml_operation_region ("PCST" ,AML_SYSTEM_IO ,aml_int (pcihp_addr),0x08 )); field =aml_field ("PCST" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS );aml_append (field,aml_named_field ("PCIU" ,32 ));aml_append (field,aml_named_field ("PCID" ,32 ));aml_append (scope, field);aml_append (scope, -aml_operation_region ("SEJ" ,AML_SYSTEM_IO ,aml_int (0xae08 ),0x04 )); +aml_operation_region ("SEJ" ,AML_SYSTEM_IO , +aml_int (pcihp_addr +ACPI_PCIHP_SEJ_BASE ),0x04 )); field =aml_field ("SEJ" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS );aml_append (field,aml_named_field ("B0EJ" ,32 ));aml_append (scope, field);aml_append (scope, -aml_operation_region ("BNMR" ,AML_SYSTEM_IO ,aml_int (0xae10 ),0x08 )); +aml_operation_region ("BNMR" ,AML_SYSTEM_IO , +aml_int (pcihp_addr +ACPI_PCIHP_BNMR_BASE ),0x08 )); field =aml_field ("BNMR" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS );aml_append (field,aml_named_field ("BNUM" ,32 ));aml_append (field,aml_named_field ("PIDX" ,32 ));
@@ -1396,7 +1401,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,build_piix4_isa_bridge (dsdt);build_isa_devices_aml (dsdt);if (pm->pcihp_bridge_en || pm->pcihp_root_en) { -build_piix4_pci_hotplug (dsdt); +build_x86_acpi_pci_hotplug (dsdt, pm->pcihp_io_base); }build_piix4_pci0_int (dsdt); }else {
@@ -1444,6 +1449,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, }build_q35_isa_bridge (dsdt);build_isa_devices_aml (dsdt); +if (pm->pcihp_bridge_en) { +build_x86_acpi_pci_hotplug (dsdt, pm->pcihp_io_base); + }build_q35_pci0_int (dsdt);if (pcms->smbus && !pcmc->do_not_add_smb_acpi) {build_smb0 (dsdt, pcms->smbus,ICH9_SMB_DEV ,ICH9_SMB_FUNC );
@@ -1478,7 +1486,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, {aml_append (scope,aml_name_decl ("_HID" ,aml_string ("ACPI0006" ))); -if (misc->is_piix4 && (pm->pcihp_bridge_en || pm->pcihp_root_en)) { +if (pm->pcihp_bridge_en || pm->pcihp_root_en) { method =aml_method ("_E01" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_acquire (aml_name ("\\_SB.PCI0.BLCK" ),0xFFFF ));
Signature · 1 line
2.30.2
RFC PATCH v4 3/7 hw/acpi/ich9: Enable ACPI PCI hot-plug
In reply to Julia SuvorovaAdd acpi_pcihp to ich9_pm as part of 'acpi-pci-hotplug-with-bridge-support' option. Set default to false.
--- hw/i386/acpi-build.h | 1 + include/hw/acpi/ich9.h | 3 ++ hw/acpi/ich9.c | 68 ++++++++++++++++++++++++++++++++++++++++++ hw/acpi/pcihp.c | 5 +++- hw/i386/acpi-build.c | 2 +- 5 files changed, 77 insertions(+), 2 deletions(-)
hw/i386/acpi-build.h +1 -0
@@ -10,5 +10,6 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;#define ACPI_PCIHP_BNMR_BASE 0x10void acpi_setup (void ); +Object *acpi_get_i386_pci_host (void );#endif
include/hw/acpi/ich9.h +3 -0
@@ -24,6 +24,7 @@#include "hw/acpi/acpi.h" #include "hw/acpi/cpu_hotplug.h" #include "hw/acpi/cpu.h" +#include "hw/acpi/pcihp.h" #include "hw/acpi/memory_hotplug.h" #include "hw/acpi/acpi_dev_interface.h" #include "hw/acpi/tco.h"
@@ -55,6 +56,8 @@ typedef struct ICH9LPCPMRegs {AcpiCpuHotplug gpe_cpu;CPUHotplugState cpuhp_state; +bool use_acpi_hotplug_bridge; +AcpiPciHpState acpi_pci_hotplug;MemHotplugState acpi_memory_hotplug;uint8_t disable_s3;
hw/acpi/ich9.c +68 -0
134 lines not on this page · raw message
hw/acpi/pcihp.c +4 -1
@@ -30,6 +30,8 @@#include "hw/pci-host/i440fx.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" +#include "hw/pci/pci_host.h" +#include "hw/i386/acpi-build.h" #include "hw/acpi/acpi.h" #include "hw/pci/pci_bus.h" #include "migration/vmstate.h"
@@ -103,6 +105,7 @@ static void *acpi_set_bsel(PCIBus *bus, void *opaque)static void acpi_set_pci_info (void ) {static bool bsel_is_set; +Object *host =acpi_get_i386_pci_host ();PCIBus *bus;unsigned bsel_alloc =ACPI_PCIHP_BSEL_DEFAULT ;
@@ -111,7 +114,7 @@ static void acpi_set_pci_info(void) } bsel_is_set = true; - bus =find_i440fx ();/* TODO: Q35 support */ + 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);
hw/i386/acpi-build.c +1 -1
@@ -295,7 +295,7 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)* Because of the PXB hosts we cannot simply query TYPE_PCI_HOST_BRIDGE. * On i386 arch we only have two pci hosts, so we can look only for them. */ -static Object *acpi_get_i386_pci_host (void ) +Object *acpi_get_i386_pci_host (void ) {PCIHostState *host;
Signature · 1 line
2.30.2
Re: [RFC PATCH v4 3/7] hw/acpi/ich9: Enable ACPI PCI hot-plug
Quoted 4 lines · On Thu, 13 May 2021 08:26:38 +0200 Julia Suvorova <[email protected]> wrote:
Add
acpi_pcihptoich9_pmas part of 'acpi-pci-hotplug-with-bridge-support' option. Set default to false.Signed-off-by Julia Suvorova <[email protected]>
Modulo code style nit below, looks fine to me:
With that fixed,
Quoted 109 lines
--- hw/i386/acpi-build.h | 1 + include/hw/acpi/ich9.h | 3 ++ hw/acpi/ich9.c | 68 ++++++++++++++++++++++++++++++++++++++++++ hw/acpi/pcihp.c | 5 +++- hw/i386/acpi-build.c | 2 +- 5 files changed, 77 insertions(+), 2 deletions(-)hw/i386/acpi-build.h +1
-0@@ -10,5 +10,6 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;#define ACPI_PCIHP_BNMR_BASE 0x10void acpi_setup (void ); +Object *acpi_get_i386_pci_host (void );#endif include/hw/acpi/ich9.h +3
-0@@ -24,6 +24,7 @@#include "hw/acpi/acpi.h" #include "hw/acpi/cpu_hotplug.h" #include "hw/acpi/cpu.h" +#include "hw/acpi/pcihp.h" #include "hw/acpi/memory_hotplug.h" #include "hw/acpi/acpi_dev_interface.h" #include "hw/acpi/tco.h" @@ -55,6 +56,8 @@ typedef struct ICH9LPCPMRegs {AcpiCpuHotplug gpe_cpu;CPUHotplugState cpuhp_state; +bool use_acpi_hotplug_bridge; +AcpiPciHpState acpi_pci_hotplug;MemHotplugState acpi_memory_hotplug;uint8_t disable_s3;hw/acpi/ich9.c +34
-0@@ -217,6 +217,26 @@ static const VMStateDescription vmstate_cpuhp_state = { } }; +static bool vmstate_test_use_pcihp (void *opaque) +{ +ICH9LPCPMRegs *s = opaque; + +return s->use_acpi_hotplug_bridge; +} + +static const VMStateDescription vmstate_pcihp_state = { + .name ="ich9_pm/pcihp" , + .version_id =1 , + .minimum_version_id =1 , + .needed = vmstate_test_use_pcihp, + .fields = (VMStateField []) { +VMSTATE_PCI_HOTPLUG (acpi_pci_hotplug, + ICH9LPCPMRegs, +NULL ,NULL ), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_ich9_pm = { .name ="ich9_pm" , .version_id =1 ,@@ -238,6 +258,7 @@ const VMStateDescription vmstate_ich9_pm = { &vmstate_memhp_state, &vmstate_tco_io_state, &vmstate_cpuhp_state, + &vmstate_pcihp_state, NULL } };@@ -259,6 +280,7 @@ static void pm_reset(void *opaque) } pm->smi_en_wmask = ~0 ; +acpi_pcihp_reset (&pm->acpi_pci_hotplug, true);acpi_update_sci (&pm->acpi_regs, pm->irq); }@@ -297,6 +319,18 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, pm->enable_tco = true;acpi_pm_tco_init (&pm->tco_regs, &pm->io); +if (pm->use_acpi_hotplug_bridge) { +acpi_pcihp_init (OBJECT (lpc_pci), + &pm->acpi_pci_hotplug, +pci_get_bus (lpc_pci), +pci_address_space_io (lpc_pci), + true, +ACPI_PCIHP_ADDR_ICH9 ); + +qbus_set_hotplug_handler (BUS (pci_get_bus (lpc_pci)), +OBJECT (lpc_pci)); + } + pm->irq = sci_irq;qemu_register_reset (pm_reset, pm); pm->powerdown_notifier.notify = pm_powerdown_req;@@ -368,6 +402,21 @@ static void ich9_pm_set_enable_tco(Object *obj, bool value, Error **errp) s->pm.enable_tco = value; }
hw/acpi/ich9.c static void ich9_pm_set_enable_tco(Object *obj, bool value, Error **errp) · line 413
Quoted 10 lines
hw/acpi/ich9.c +9
-0+static bool ich9_pm_get_acpi_pci_hotplug (Object *obj,Error **errp) +{ +ICH9LPCState *s =ICH9_LPC_DEVICE (obj); + +return s->pm.use_acpi_hotplug_bridge; +} + +static void ich9_pm_set_acpi_pci_hotplug (Object *obj,bool value, +Error **errp)
misaligned line
Quoted 113 lines
hw/acpi/ich9.c +25
-0+{ +ICH9LPCState *s =ICH9_LPC_DEVICE (obj); + + s->pm.use_acpi_hotplug_bridge = value; +} +void ich9_pm_add_properties (Object *obj,ICH9LPCPMRegs *pm) {static const uint32_t gpe0_len =ICH9_PMIO_GPE0_LEN ;@@ -376,6 +425,7 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm) pm->disable_s3 =0 ; pm->disable_s4 =0 ; pm->s4_val =2 ; + pm->use_acpi_hotplug_bridge = false;object_property_add_uint32_ptr (obj,ACPI_PM_PROP_PM_IO_BASE , &pm->pm_io_base,OBJ_PROP_FLAG_READ );@@ -399,6 +449,9 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm)object_property_add_bool (obj,ACPI_PM_PROP_TCO_ENABLED , ich9_pm_get_enable_tco, ich9_pm_set_enable_tco); +object_property_add_bool (obj,"acpi-pci-hotplug-with-bridge-support" , + ich9_pm_get_acpi_pci_hotplug, + ich9_pm_set_acpi_pci_hotplug); } void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,@@ -406,6 +459,11 @@ void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, {ICH9LPCState *lpc =ICH9_LPC_DEVICE (hotplug_dev); +if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { +acpi_pcihp_device_pre_plug_cb (hotplug_dev, dev, errp); +return ; + } +if (object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM ) && !lpc->pm.acpi_memory_hotplug.is_enabled) { error_setg(errp,@@ -441,6 +499,9 @@ void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, }else {acpi_cpu_plug_cb (hotplug_dev, &lpc->pm.cpuhp_state, dev, errp); } + }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { +acpi_pcihp_device_plug_cb (hotplug_dev, &lpc->pm.acpi_pci_hotplug, + dev, errp); }else {error_setg (errp,"acpi: device plug request for not supported device" " type: %s" ,object_get_typename (OBJECT (dev)));@@ -473,6 +534,10 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev,acpi_cpu_unplug_request_cb (hotplug_dev, &lpc->pm.cpuhp_state, dev, errp); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { +acpi_pcihp_device_unplug_request_cb (hotplug_dev, + &lpc->pm.acpi_pci_hotplug, + dev, errp); }else {error_setg (errp,"acpi: device unplug request for not supported device" " type: %s" ,object_get_typename (OBJECT (dev)));@@ -490,6 +555,9 @@ void ich9_pm_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU ) && !lpc->pm.cpu_hotplug_legacy) {acpi_cpu_unplug_cb (&lpc->pm.cpuhp_state, dev, errp); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { +acpi_pcihp_device_unplug_cb (hotplug_dev, &lpc->pm.acpi_pci_hotplug, + dev, errp); }else {error_setg (errp,"acpi: device unplug for not supported device" " type: %s" ,object_get_typename (OBJECT (dev)));hw/acpi/pcihp.c +4
-1@@ -30,6 +30,8 @@#include "hw/pci-host/i440fx.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" +#include "hw/pci/pci_host.h" +#include "hw/i386/acpi-build.h" #include "hw/acpi/acpi.h" #include "hw/pci/pci_bus.h" #include "migration/vmstate.h" @@ -103,6 +105,7 @@ static void *acpi_set_bsel(PCIBus *bus, void *opaque)static void acpi_set_pci_info (void ) {static bool bsel_is_set; +Object *host =acpi_get_i386_pci_host ();PCIBus *bus;unsigned bsel_alloc =ACPI_PCIHP_BSEL_DEFAULT ;@@ -111,7 +114,7 @@ static void acpi_set_pci_info(void) } bsel_is_set = true; - bus =find_i440fx ();/* TODO: Q35 support */ + 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);hw/i386/acpi-build.c +1
-1@@ -295,7 +295,7 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)* Because of the PXB hosts we cannot simply query TYPE_PCI_HOST_BRIDGE. * On i386 arch we only have two pci hosts, so we can look only for them. */ -static Object *acpi_get_i386_pci_host (void ) +Object *acpi_get_i386_pci_host (void ) {PCIHostState *host;
RFC PATCH v4 4/7 hw/pci/pcie: Do not set HPC flag if acpihp is used
In reply to Julia SuvorovaInstead of changing the hot-plug type in _OSC register, do not set the 'Hot-Plug Capable' flag. This way guest will choose ACPI hot-plug if it is preferred and leave the option to use SHPC with pcie-pci-bridge.
The ability to control hot-plug for each downstream port is retained, while 'hotplug=off' on the port means all hot-plug types are disabled.
--- include/hw/boards.h | 1 + hw/acpi/pcihp.c | 8 ++++++++ hw/core/machine.c | 19 +++++++++++++++++++ hw/i386/pc_q35.c | 8 ++++++++ hw/pci/pcie.c | 11 ++++++++++- 5 files changed, 46 insertions(+), 1 deletion(-)
include/hw/boards.h +1 -0
@@ -334,6 +334,7 @@ struct MachineState {CpuTopology smp;struct NVDIMMState *nvdimms_state;struct NumaState *numa_state; +bool native_pci_hotplug; };#define DEFINE_MACHINE (namestr, machine_initfn) \
hw/acpi/pcihp.c +8 -0
@@ -31,6 +31,7 @@#include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_host.h" +#include "hw/pci/pcie_port.h" #include "hw/i386/acpi-build.h" #include "hw/acpi/acpi.h" #include "hw/pci/pci_bus.h"
@@ -332,6 +333,13 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s, object_dynamic_cast(OBJECT(dev), TYPE_PCI_BRIDGE)) {PCIBus *sec =pci_bridge_get_sec_bus (PCI_BRIDGE (pdev)); +/* Remove all hot-plug handlers if hot-plug is disabled on slot */ +if (object_dynamic_cast (OBJECT (dev),TYPE_PCIE_SLOT ) && + !PCIE_SLOT (pdev)->hotplug) { +qbus_set_hotplug_handler (BUS (sec),NULL ); +return ; + } +qbus_set_hotplug_handler (BUS (sec),OBJECT (hotplug_dev));/* We don't have to overwrite any other hotplug handler yet */ assert (QLIST_EMPTY (&sec->child));
hw/core/machine.c +19 -0
@@ -581,6 +581,21 @@ static void machine_set_memdev(Object *obj, const char *value, Error **errp) ms->ram_memdev_id =g_strdup (value); } +static void machine_set_native_pci_hotplug (Object *obj,bool value, +Error **errp) +{ +MachineState *ms =MACHINE (obj); + + ms->native_pci_hotplug = value; +} + +static bool machine_get_native_pci_hotplug (Object *obj,Error **errp) +{ +MachineState *ms =MACHINE (obj); + +return ms->native_pci_hotplug; +} +static void machine_init_notify (Notifier *notifier,void *data) {
@@ -891,6 +906,10 @@ static void machine_class_init(ObjectClass *oc, void *data)object_class_property_set_description (oc,"confidential-guest-support" ,"Set confidential guest scheme to support" ); +object_class_property_add_bool (oc,"x-native-pci-hotplug" , + machine_get_native_pci_hotplug, + machine_set_native_pci_hotplug); +/* For compatibility */ object_class_property_add_str (oc,"memory-encryption" , machine_get_memory_encryption, machine_set_memory_encryption);
hw/i386/pc_q35.c +8 -0
@@ -136,6 +136,7 @@ static void pc_q35_init(MachineState *machine)ram_addr_t lowmem;DriveInfo *hd[MAX_SATA_PORTS ];MachineClass *mc =MACHINE_GET_CLASS (machine); +bool acpi_pcihp;/* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory * and 256 Mbytes for PCI Express Enhanced Configuration Access Mapping
@@ -236,6 +237,13 @@ static void pc_q35_init(MachineState *machine)object_property_set_link (OBJECT (machine),PC_MACHINE_ACPI_DEVICE_PROP ,OBJECT (lpc), &error_abort); + acpi_pcihp =object_property_get_bool (OBJECT (lpc), +"acpi-pci-hotplug-with-bridge-support" , +NULL ); + +object_property_set_bool (OBJECT (machine),"x-native-pci-hotplug" , + !acpi_pcihp,NULL ); +/* irq lines */ gsi_state =pc_gsi_create (&x86ms->gsi, pcmc->pci_enabled);
hw/pci/pcie.c +10 -1
@@ -517,6 +517,9 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,void pcie_cap_slot_init (PCIDevice *dev,PCIESlot *s) {uint32_t pos = dev->exp.exp_cap; +bool native_pcihp_enabled =object_property_get_bool (qdev_get_machine (), +"x-native-pci-hotplug" , +NULL );pci_word_test_and_set_mask (dev->config + pos +PCI_EXP_FLAGS ,PCI_EXP_FLAGS_SLOT );
@@ -529,7 +532,13 @@ void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s)PCI_EXP_SLTCAP_PIP |PCI_EXP_SLTCAP_AIP | PCI_EXP_SLTCAP_ABP); -if (s->hotplug) { + +/* +* Enable native hot-plug on all hot-plugged bridges unless +* hot-plug is disabled on the slot. +*/ +if (s->hotplug && + (native_pcihp_enabled ||DEVICE (dev)->hotplugged)) {pci_long_test_and_set_mask (dev->config + pos +PCI_EXP_SLTCAP ,PCI_EXP_SLTCAP_HPS |PCI_EXP_SLTCAP_HPC );
Signature · 1 line
2.30.2
Re: [RFC PATCH v4 4/7] hw/pci/pcie: Do not set HPC flag if acpihp is used
Quoted 122 lines · On Thu, 13 May 2021 08:26:39 +0200 Julia Suvorova <[email protected]> wrote:
Instead of changing the hot-plug type in
_OSCregister, do not set the 'Hot-Plug Capable' flag. This way guest will choose ACPI hot-plug if it is preferred and leave the option to use SHPC with pcie-pci-bridge.The ability to control hot-plug for each downstream port is retained, while 'hotplug=off' on the port means all hot-plug types are disabled.
Signed-off-by Julia Suvorova <[email protected]>--- include/hw/boards.h | 1 + hw/acpi/pcihp.c | 8 ++++++++ hw/core/machine.c | 19 +++++++++++++++++++ hw/i386/pc_q35.c | 8 ++++++++ hw/pci/pcie.c | 11 ++++++++++- 5 files changed, 46 insertions(+), 1 deletion(-)include/hw/boards.h +1
-0@@ -334,6 +334,7 @@ struct MachineState {CpuTopology smp;struct NVDIMMState *nvdimms_state;struct NumaState *numa_state; +bool native_pci_hotplug; };#define DEFINE_MACHINE (namestr, machine_initfn) \hw/acpi/pcihp.c +8
-0@@ -31,6 +31,7 @@#include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_host.h" +#include "hw/pci/pcie_port.h" #include "hw/i386/acpi-build.h" #include "hw/acpi/acpi.h" #include "hw/pci/pci_bus.h" @@ -332,6 +333,13 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s, object_dynamic_cast(OBJECT(dev), TYPE_PCI_BRIDGE)) {PCIBus *sec =pci_bridge_get_sec_bus (PCI_BRIDGE (pdev)); +/* Remove all hot-plug handlers if hot-plug is disabled on slot */ +if (object_dynamic_cast (OBJECT (dev),TYPE_PCIE_SLOT ) && + !PCIE_SLOT (pdev)->hotplug) { +qbus_set_hotplug_handler (BUS (sec),NULL ); +return ; + } +qbus_set_hotplug_handler (BUS (sec),OBJECT (hotplug_dev));/* We don't have to overwrite any other hotplug handler yet */ assert (QLIST_EMPTY (&sec->child));hw/core/machine.c +19
-0@@ -581,6 +581,21 @@ static void machine_set_memdev(Object *obj, const char *value, Error **errp) ms->ram_memdev_id =g_strdup (value); } +static void machine_set_native_pci_hotplug (Object *obj,bool value, +Error **errp) +{ +MachineState *ms =MACHINE (obj); + + ms->native_pci_hotplug = value; +} + +static bool machine_get_native_pci_hotplug (Object *obj,Error **errp) +{ +MachineState *ms =MACHINE (obj); + +return ms->native_pci_hotplug; +} +static void machine_init_notify (Notifier *notifier,void *data) {@@ -891,6 +906,10 @@ static void machine_class_init(ObjectClass *oc, void *data)object_class_property_set_description (oc,"confidential-guest-support" ,"Set confidential guest scheme to support" ); +object_class_property_add_bool (oc,"x-native-pci-hotplug" , + machine_get_native_pci_hotplug, + machine_set_native_pci_hotplug); +/* For compatibility */ object_class_property_add_str (oc,"memory-encryption" , machine_get_memory_encryption, machine_set_memory_encryption);hw/i386/pc_q35.c +7
-0@@ -136,6 +136,7 @@ static void pc_q35_init(MachineState *machine)ram_addr_t lowmem;DriveInfo *hd[MAX_SATA_PORTS ];MachineClass *mc =MACHINE_GET_CLASS (machine); +bool acpi_pcihp;/* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory * and 256 Mbytes for PCI Express Enhanced Configuration Access Mapping @@ -236,6 +237,13 @@ static void pc_q35_init(MachineState *machine)object_property_set_link (OBJECT (machine),PC_MACHINE_ACPI_DEVICE_PROP ,OBJECT (lpc), &error_abort); + acpi_pcihp =object_property_get_bool (OBJECT (lpc), +"acpi-pci-hotplug-with-bridge-support" , +NULL ); + +object_property_set_bool (OBJECT (machine),"x-native-pci-hotplug" , + !acpi_pcihp,NULL );/* irq lines */ gsi_state =pc_gsi_create (&x86ms->gsi, pcmc->pci_enabled);hw/pci/pcie.c +0
-0
hw/pci/pcie.c void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, · line 522
Quoted 6 lines
hw/pci/pcie.c +3
-0@@ -517,6 +517,9 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,void pcie_cap_slot_init (PCIDevice *dev,PCIESlot *s) {uint32_t pos = dev->exp.exp_cap; +bool native_pcihp_enabled =object_property_get_bool (qdev_get_machine (), +"x-native-pci-hotplug" , +NULL );
how about replacing of q35_machine -> machine -> qdev_get_machine() with PCIESlot::enable_native_hotplug property
and then in pc_q35_init() just adding compat/global property at runtime
if(acpi_hotplug)
object_register_sugar_prop(TYPE_PCIE_ROOT_PORT, "enable_native_hotplug",
"false", true);after that every port created will have that property set automatically. or something like this.
It's also hackish but a bit better as you don't have pollute generic machine code with "x-native-pci-hotplug" and don't have to call qdev_get_machine() for every port.
Quoted 17 lines
hw/pci/pcie.c +7
-1pci_word_test_and_set_mask (dev->config + pos +PCI_EXP_FLAGS ,PCI_EXP_FLAGS_SLOT );@@ -529,7 +532,13 @@ void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s)PCI_EXP_SLTCAP_PIP |PCI_EXP_SLTCAP_AIP | PCI_EXP_SLTCAP_ABP); -if (s->hotplug) { + +/* +* Enable native hot-plug on all hot-plugged bridges unless +* hot-plug is disabled on the slot. +*/ +if (s->hotplug && + (native_pcihp_enabled ||DEVICE (dev)->hotplugged)) {pci_long_test_and_set_mask (dev->config + pos +PCI_EXP_SLTCAP ,PCI_EXP_SLTCAP_HPS |PCI_EXP_SLTCAP_HPC );
RFC PATCH v4 5/7 bios-tables-test: Allow changes in DSDT ACPI tables
In reply to Julia SuvorovaAll DSDT Q35 tables will be modified because ACPI hot-plug is enabled by default.
--- 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/q35/DSDT" , +"tests/data/acpi/q35/DSDT.tis" , +"tests/data/acpi/q35/DSDT.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.acpihmat" , +"tests/data/acpi/q35/DSDT.numamem" , +"tests/data/acpi/q35/DSDT.dimmpxm" , +"tests/data/acpi/q35/DSDT.nohpet",
Signature · 1 line
2.30.2
Re: [RFC PATCH v4 5/7] bios-tables-test: Allow changes in DSDT ACPI tables
Quoted 4 lines · On Thu, 13 May 2021 08:26:40 +0200 Julia Suvorova <[email protected]> wrote:
All DSDT Q35 tables will be modified because ACPI hot-plug is enabled by default.
Signed-off-by Julia Suvorova <[email protected]>
Quoted 21 lines
--- 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/q35/DSDT" , +"tests/data/acpi/q35/DSDT.tis" , +"tests/data/acpi/q35/DSDT.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.acpihmat" , +"tests/data/acpi/q35/DSDT.numamem" , +"tests/data/acpi/q35/DSDT.dimmpxm" , +"tests/data/acpi/q35/DSDT.nohpet",
RFC PATCH v4 6/7 hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35
In reply to Julia SuvorovaQ35 has three different types of PCI devices hot-plug: PCIe Native, SHPC Native and ACPI hot-plug. This patch changes the default choice for cold-plugged bridges from PCIe Native to ACPI Hot-plug with ability to use SHPC and PCIe Native for hot-plugged bridges.
This is a list of the PCIe Native hot-plug issues that led to this change:
* no racy behavior during boot (see 110c477c2ed)
* no delay during deleting - after the actual power off software must wait at least 1 second before indicating about it. This case is quite important for users, it even has its own bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1594168
* no timer-based behavior - in addition to the previous example, the attention button has a 5-second waiting period, during which the operation can be canceled with a second press. While this looks fine for manual button control, automation will result in the need to queue or drop events, and the software receiving events in all sort of unspecified combinations of attention/power indicator states, which is racy and uppredictable.
* fixes or reduces the likelihood of the bug:
* https://bugzilla.redhat.com/show_bug.cgi?id=1833187
* https://bugzilla.redhat.com/show_bug.cgi?id=1657077
* https://bugzilla.redhat.com/show_bug.cgi?id=1669931
* https://bugzilla.redhat.com/show_bug.cgi?id=1678290
To return to PCIe Native hot-plug:
-global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off
--- hw/acpi/ich9.c | 2 +- hw/i386/pc.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-)
hw/acpi/ich9.c +1 -1
@@ -425,7 +425,7 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm) pm->disable_s3 =0 ; pm->disable_s4 =0 ; pm->s4_val =2 ; - pm->use_acpi_hotplug_bridge = false; + pm->use_acpi_hotplug_bridge = true;object_property_add_uint32_ptr (obj,ACPI_PM_PROP_PM_IO_BASE , &pm->pm_io_base,OBJ_PROP_FLAG_READ );
hw/i386/pc.c +3 -1
@@ -94,7 +94,9 @@#include "trace.h" #include CONFIG_DEVICES -GlobalProperty pc_compat_6_0[] = {}; +GlobalProperty pc_compat_6_0[] = { + {"ICH9-LPC" ,"acpi-pci-hotplug-with-bridge-support" ,"off" }, +};const size_t pc_compat_6_0_len =G_N_ELEMENTS (pc_compat_6_0);GlobalProperty pc_compat_5_2[] = {
Signature · 1 line
2.30.2
Re: [RFC PATCH v4 6/7] hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35
Quoted 25 lines · On Thu, 13 May 2021 08:26:41 +0200 Julia Suvorova <[email protected]> wrote:
Q35 has three different types of PCI devices hot-plug: PCIe Native, SHPC Native and ACPI hot-plug. This patch changes the default choice for cold-plugged bridges from PCIe Native to ACPI Hot-plug with ability to use SHPC and PCIe Native for hot-plugged bridges.
This is a list of the PCIe Native hot-plug issues that led to this change:
* no racy behavior during boot (see110c477c2ed)
* no delay during deleting - after the actual power off software must wait at least 1 second before indicating about it. This case is quite important for users, it even has its own bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1594168
* no timer-based behavior - in addition to the previous example, the attention button has a 5-second waiting period, during which the operation can be canceled with a second press. While this looks fine for manual button control, automation will result in the need to queue or drop events, and the software receiving events in all sort of unspecified combinations of attention/power indicator states, which is racy and uppredictable.
* fixes or reduces the likelihood of the bug:
* https://bugzilla.redhat.com/show_bug.cgi?id=1833187
* https://bugzilla.redhat.com/show_bug.cgi?id=1657077
* https://bugzilla.redhat.com/show_bug.cgi?id=1669931
* https://bugzilla.redhat.com/show_bug.cgi?id=1678290
Quoted 4 lines
To return to PCIe Native hot-plug:
-global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=offSigned-off-by Julia Suvorova <[email protected]>
Quoted 33 lines
--- hw/acpi/ich9.c | 2 +- hw/i386/pc.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-)hw/acpi/ich9.c +1
-1@@ -425,7 +425,7 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm) pm->disable_s3 =0 ; pm->disable_s4 =0 ; pm->s4_val =2 ; - pm->use_acpi_hotplug_bridge = false; + pm->use_acpi_hotplug_bridge = true;object_property_add_uint32_ptr (obj,ACPI_PM_PROP_PM_IO_BASE , &pm->pm_io_base,OBJ_PROP_FLAG_READ );hw/i386/pc.c +3
-1@@ -94,7 +94,9 @@#include "trace.h" #include CONFIG_DEVICES -GlobalProperty pc_compat_6_0[] = {}; +GlobalProperty pc_compat_6_0[] = { + {"ICH9-LPC" ,"acpi-pci-hotplug-with-bridge-support" ,"off" }, +};const size_t pc_compat_6_0_len =G_N_ELEMENTS (pc_compat_6_0);GlobalProperty pc_compat_5_2[] = {
RFC PATCH v4 7/7 bios-tables-test: Update golden binaries
In reply to Julia SuvorovaAdd ACPI hot-plug registers to DSDT Q35 tables.
Changes in the tables:
+ Scope (_SB.PCI0)
+ {
+ OperationRegion (PCST, SystemIO, 0x0CC4, 0x08)
+ Field (PCST, DWordAcc, NoLock, WriteAsZeros)
+ {
+ PCIU, 32,
+ PCID, 32
+ }
+
+ OperationRegion (SEJ, SystemIO, 0x0CCC, 0x04)
+ Field (SEJ, DWordAcc, NoLock, WriteAsZeros)
+ {
+ B0EJ, 32
+ }
+
+ OperationRegion (BNMR, SystemIO, 0x0CD4, 0x08)
+ Field (BNMR, DWordAcc, NoLock, WriteAsZeros)
+ {
+ BNUM, 32,
+ PIDX, 32
+ }
+
+ Mutex (BLCK, 0x00)
+ Method (PCEJ, 2, NotSerialized)
+ {
+ Acquire (BLCK, 0xFFFF)
+ BNUM = Arg0
+ B0EJ = (One << Arg1)
+ Release (BLCK)
+ Return (Zero)+ }
+
+ Method (AIDX, 2, NotSerialized)
+ {
+ Acquire (BLCK, 0xFFFF) + BNUM = Arg0 + PIDX = (One << Arg1) + Local0 = PIDX /* \_SB_.PCI0.PIDX */ + Release (BLCK) + Return (Local0)
+ }
+
+ Method (PDSM, 6, Serialized)
+ {
+ If ((Arg0 == ToUUID ("e5c937d0-3553-4d7a-9117-ea4d19c3434d") /* Device Labeling Interface */))
+ {
+ Local0 = AIDX (Arg4, Arg5)
+ If ((Arg2 == Zero))
+ {+ If ((Arg1 == 0x02))
+ {
+ If (!((Local0 == Zero) | (Local0 == 0xFFFFFFFF)))
+ {
+ Return (Buffer (One)
+ {
+ 0x81 // .
+ })
+ }
+ }
+
+ Return (Buffer (One)
+ {
+ 0x00 // .
+ })
+ }
+ ElseIf ((Arg2 == 0x07))
+ {+ Local1 = Package (0x02)
+ {
+ Zero,
+ ""
+ }
+ Local1 [Zero] = Local0
+ Return (Local1)
+ }
+ }
+ }
+ }
+
...
Scope (_GPE)
{
Name (_HID, "ACPI0006" /* GPE Block Device */) // _HID: Hardware ID
+ Method (_E01, 0, NotSerialized) // _Exx: Edge-Triggered GPE, xx=0x00-0xFF
+ {
+ Acquire (\_SB.PCI0.BLCK, 0xFFFF)
+ \_SB.PCI0.PCNT ()
+ Release (\_SB.PCI0.BLCK)+ }
...
+
+ Device (PHPR)
+ {
+ Name (_HID, "PNP0A06" /* Generic Container Device */) // _HID: Hardware ID
+ Name (_UID, "PCI Hotplug resources") // _UID: Unique ID
+ Name (_STA, 0x0B) // _STA: Status
+ Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings
+ {
+ IO (Decode16,
+ 0x0CC4, // Range Minimum
+ 0x0CC4, // Range Maximum
+ 0x01, // Alignment
+ 0x18, // Length
+ )
+ })
+ }
}...
And if there is a port in configuration:
Device (S10)
{
Name (_ADR, 0x00020000) // _ADR: Address
+ Name (BSEL, Zero)
+ Device (S00)
+ {
+ Name (_SUN, Zero) // _SUN: Slot User Number
+ Name (_ADR, Zero) // _ADR: Address
+ Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device, x=0-9
+ {+ PCEJ (BSEL, _SUN)
+ }
+
+ Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method
+ {
+ Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN))
+ }
+ }
+
...
+ Method (DVNT, 2, NotSerialized)
+ {
+ If ((Arg0 & One))
+ {
+ Notify (S00, Arg1)
+ }
...
--- tests/qtest/bios-tables-test-allowed-diff.h | 11 ----------- tests/data/acpi/q35/DSDT | Bin 7859 -> 8289 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9184 -> 9614 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7877 -> 11003 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8323 -> 8753 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9513 -> 9943 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7934 -> 8364 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9218 -> 9648 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8990 -> 9419 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 7717 -> 8147 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7865 -> 8295 bytes tests/data/acpi/q35/DSDT.tis | Bin 8465 -> 8894 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/q35/DSDT" , -"tests/data/acpi/q35/DSDT.tis" , -"tests/data/acpi/q35/DSDT.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.acpihmat" , -"tests/data/acpi/q35/DSDT.numamem" , -"tests/data/acpi/q35/DSDT.dimmpxm" , -"tests/data/acpi/q35/DSDT.nohpet",
tests/data/acpi/q35/DSDT binary +0 -0
tests/data/acpi/q35/DSDT.acpihmat binary +0 -0
tests/data/acpi/q35/DSDT.bridge binary +0 -0
tests/data/acpi/q35/DSDT.cphp 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.memhp binary +0 -0
tests/data/acpi/q35/DSDT.mmio64 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.tis binary +0 -0
Signature · 1 line
2.30.2
Quoted 25 lines · On Thu, 13 May 2021 08:26:35 +0200 Julia Suvorova <[email protected]> wrote:
The patch set consists of two parts:
patches 1-4: introduce new feature
'acpi-pci-hotplug-with-bridge-support' on Q35
patches 5-7: make the feature default along with changes in ACPI tablesThis way maintainers can decide which way to choose without breaking the patch set.
With the feature disabled Q35 falls back to the native hot-plug.
Pros
* no racy behavior during boot (see110c477c2ed)
* eject is possible - according to PCIe spec, attention button press should lead to power off, and then the adapter should be removed manually. As there is no power down state exists in QEMU, we cannot distinguish between an eject and a power down request.
* no delay during deleting - after the actual power off software must wait at least 1 second before indicating about it. This case is quite important for users, it even has its own bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1594168
* no timer-based behavior - in addition to the previous example, the attention button has a 5-second waiting period, during which the operation can be canceled with a second press. While this looks fine for manual button control, automation will result in
Quoted 8 lines
the need to queue or drop events, and the software receiving events in all sort of unspecified combinations of attention/power indicator states, which is racy and uppredictable.
* fixes or reduces the likelihood of the bugs:
* https://bugzilla.redhat.com/show_bug.cgi?id=1833187
* https://bugzilla.redhat.com/show_bug.cgi?id=1657077
* https://bugzilla.redhat.com/show_bug.cgi?id=1669931
* https://bugzilla.redhat.com/show_bug.cgi?id=1678290
in addition,
while it's not trivial to test ACPI hotplug at 'make check' time (as it needs AML execution on guest side), it should be possible to test native PCI-E and SHPC hotplug by using existing qpci_foo() to read/write respective PCI device registers, so we could test that we didn't regress current native/SHPC with this series.
It's would be better if test would come as part of this series, but I'm fine with test being a separate patch on top if you will take care of it within the same release cycle.
Quoted 56 lines
Cons:
* no access to possible features presented in slot capabilities (this is only surprise removal AFAIK)v4:
* regain per-port control over hot-plug
* rebased over acpi-index changes
* set property on machine type to
make pci code more generic [Igor, Michael]v3:
* drop change of_OSCto allow SHPC on hotplugged bridges
* use 'acpi-root-pci-hotplug'
* add migration states [Igor]
* minor style changesv2:
* new ioport range for acpiphp [Gerd]
* dropfind_pci_host()[Igor]
* explain magic numbers in_OSC[Igor]
* dropbuild_q35_pci_hotplug()wrapper [Igor]Julia Suvorova (7):
hw/acpi/pcihp: Enhanceacpi_pcihp_disable_root_bus()to support Q35 hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35 hw/acpi/ich9: Enable ACPI PCI hot-plug
hw/pci/pcie: Do not set HPC flag if acpihp is used
bios-tables-test: Allow changes in DSDT ACPI tables hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35
bios-tables-test: Update golden binarieshw/i386/acpi-build.h | 5 +++ include/hw/acpi/ich9.h | 5 +++ include/hw/acpi/pcihp.h | 3 +- include/hw/boards.h | 1 + hw/acpi/ich9.c | 68 ++++++++++++++++++++++++++++++ hw/acpi/pcihp.c | 22 +++++++--- hw/acpi/piix4.c | 4 +- hw/core/machine.c | 19 +++++++++ hw/i386/acpi-build.c | 32 ++++++++------ hw/i386/pc.c | 4 +- hw/i386/pc_q35.c | 8 ++++ hw/pci/pcie.c | 11 ++++- tests/data/acpi/q35/DSDT | Bin 7859 -> 8289 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9184 -> 9614 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7877 -> 11003 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8323 -> 8753 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9513 -> 9943 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7934 -> 8364 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9218 -> 9648 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8990 -> 9419 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 7717 -> 8147 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7865 -> 8295 bytes tests/data/acpi/q35/DSDT.tis | Bin 8465 -> 8894 bytes 23 files changed, 161 insertions(+), 21 deletions(-)
Quoted 9 lines · Julia Suvorova
The patch set consists of two parts:
patches 1-4: introduce new feature
'acpi-pci-hotplug-with-bridge-support' on Q35
patches 5-7: make the feature default along with changes in ACPI tablesThis way maintainers can decide which way to choose without breaking the patch set.
With the feature disabled Q35 falls back to the native hot-plug.
Overall I think this version has addressed my concerns, good job! I see Igor has some suggestions on how to structure the code, they seem easy to address.
Question: what makes this an RFC? Any known bugs/missing functionality? I don't see anything obvious - what did I miss?
Quoted 82 lines
Pros
* no racy behavior during boot (see110c477c2ed)
* eject is possible - according to PCIe spec, attention button press should lead to power off, and then the adapter should be removed manually. As there is no power down state exists in QEMU, we cannot distinguish between an eject and a power down request.
* no delay during deleting - after the actual power off software must wait at least 1 second before indicating about it. This case is quite important for users, it even has its own bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1594168
* no timer-based behavior - in addition to the previous example, the attention button has a 5-second waiting period, during which the operation can be canceled with a second press. While this looks fine for manual button control, automation will result in the need to queue or drop events, and the software receiving events in all sort of unspecified combinations of attention/power indicator states, which is racy and uppredictable.
* fixes or reduces the likelihood of the bugs:
* https://bugzilla.redhat.com/show_bug.cgi?id=1833187
* https://bugzilla.redhat.com/show_bug.cgi?id=1657077
* https://bugzilla.redhat.com/show_bug.cgi?id=1669931
* https://bugzilla.redhat.com/show_bug.cgi?id=1678290Cons:
* no access to possible features presented in slot capabilities (this is only surprise removal AFAIK)v4:
* regain per-port control over hot-plug
* rebased over acpi-index changes
* set property on machine type to
make pci code more generic [Igor, Michael]v3:
* drop change of_OSCto allow SHPC on hotplugged bridges
* use 'acpi-root-pci-hotplug'
* add migration states [Igor]
* minor style changesv2:
* new ioport range for acpiphp [Gerd]
* dropfind_pci_host()[Igor]
* explain magic numbers in_OSC[Igor]
* dropbuild_q35_pci_hotplug()wrapper [Igor]Julia Suvorova (7):
hw/acpi/pcihp: Enhanceacpi_pcihp_disable_root_bus()to support Q35 hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35 hw/acpi/ich9: Enable ACPI PCI hot-plug
hw/pci/pcie: Do not set HPC flag if acpihp is used
bios-tables-test: Allow changes in DSDT ACPI tables hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35
bios-tables-test: Update golden binarieshw/i386/acpi-build.h | 5 +++ include/hw/acpi/ich9.h | 5 +++ include/hw/acpi/pcihp.h | 3 +- include/hw/boards.h | 1 + hw/acpi/ich9.c | 68 ++++++++++++++++++++++++++++++ hw/acpi/pcihp.c | 22 +++++++--- hw/acpi/piix4.c | 4 +- hw/core/machine.c | 19 +++++++++ hw/i386/acpi-build.c | 32 ++++++++------ hw/i386/pc.c | 4 +- hw/i386/pc_q35.c | 8 ++++ hw/pci/pcie.c | 11 ++++- tests/data/acpi/q35/DSDT | Bin 7859 -> 8289 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9184 -> 9614 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7877 -> 11003 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8323 -> 8753 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9513 -> 9943 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7934 -> 8364 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9218 -> 9648 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8990 -> 9419 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 7717 -> 8147 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7865 -> 8295 bytes tests/data/acpi/q35/DSDT.tis | Bin 8465 -> 8894 bytes 23 files changed, 161 insertions(+), 21 deletions(-)Signature · 1 line
2.30.2
Quoted 10 lines · Michael S. Tsirkin
Quoted 8 lines · Julia Suvorova
The patch set consists of two parts:
patches 1-4: introduce new feature
'acpi-pci-hotplug-with-bridge-support' on Q35
patches 5-7: make the feature default along with changes in ACPI tablesThis way maintainers can decide which way to choose without breaking the patch set.
Quoted 7 lines
Quoted 1 line
With the feature disabled Q35 falls back to the native hot-plug.
Overall I think this version has addressed my concerns, good job! I see Igor has some suggestions on how to structure the code, they seem easy to address.
Question: what makes this an RFC? Any known bugs/missing functionality? I don't see anything obvious - what did I miss?
No known issues, just indecisiveness about the default. The next version will be non-RFC.
Best regards, Julia Suvorova.
Quoted 83 lines
Quoted 82 lines
Pros
* no racy behavior during boot (see110c477c2ed)
* eject is possible - according to PCIe spec, attention button press should lead to power off, and then the adapter should be removed manually. As there is no power down state exists in QEMU, we cannot distinguish between an eject and a power down request.
* no delay during deleting - after the actual power off software must wait at least 1 second before indicating about it. This case is quite important for users, it even has its own bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1594168
* no timer-based behavior - in addition to the previous example, the attention button has a 5-second waiting period, during which the operation can be canceled with a second press. While this looks fine for manual button control, automation will result in the need to queue or drop events, and the software receiving events in all sort of unspecified combinations of attention/power indicator states, which is racy and uppredictable.
* fixes or reduces the likelihood of the bugs:
* https://bugzilla.redhat.com/show_bug.cgi?id=1833187
* https://bugzilla.redhat.com/show_bug.cgi?id=1657077
* https://bugzilla.redhat.com/show_bug.cgi?id=1669931
* https://bugzilla.redhat.com/show_bug.cgi?id=1678290Cons:
* no access to possible features presented in slot capabilities (this is only surprise removal AFAIK)v4:
* regain per-port control over hot-plug
* rebased over acpi-index changes
* set property on machine type to
make pci code more generic [Igor, Michael]v3:
* drop change of_OSCto allow SHPC on hotplugged bridges
* use 'acpi-root-pci-hotplug'
* add migration states [Igor]
* minor style changesv2:
* new ioport range for acpiphp [Gerd]
* dropfind_pci_host()[Igor]
* explain magic numbers in_OSC[Igor]
* dropbuild_q35_pci_hotplug()wrapper [Igor]Julia Suvorova (7):
hw/acpi/pcihp: Enhanceacpi_pcihp_disable_root_bus()to support Q35 hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35 hw/acpi/ich9: Enable ACPI PCI hot-plug
hw/pci/pcie: Do not set HPC flag if acpihp is used
bios-tables-test: Allow changes in DSDT ACPI tables hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35
bios-tables-test: Update golden binarieshw/i386/acpi-build.h | 5 +++ include/hw/acpi/ich9.h | 5 +++ include/hw/acpi/pcihp.h | 3 +- include/hw/boards.h | 1 + hw/acpi/ich9.c | 68 ++++++++++++++++++++++++++++++ hw/acpi/pcihp.c | 22 +++++++--- hw/acpi/piix4.c | 4 +- hw/core/machine.c | 19 +++++++++ hw/i386/acpi-build.c | 32 ++++++++------ hw/i386/pc.c | 4 +- hw/i386/pc_q35.c | 8 ++++ hw/pci/pcie.c | 11 ++++- tests/data/acpi/q35/DSDT | Bin 7859 -> 8289 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9184 -> 9614 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7877 -> 11003 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8323 -> 8753 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9513 -> 9943 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7934 -> 8364 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9218 -> 9648 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8990 -> 9419 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 7717 -> 8147 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7865 -> 8295 bytes tests/data/acpi/q35/DSDT.tis | Bin 8465 -> 8894 bytes 23 files changed, 161 insertions(+), 21 deletions(-)--
2.30.2
Quoted 7 lines · Julia Suvorova
The patch set consists of two parts:
patches 1-4: introduce new feature
'acpi-pci-hotplug-with-bridge-support' on Q35
patches 5-7: make the feature default along with changes in ACPI tablesThis way maintainers can decide which way to choose without breaking the patch set.
This is in good shape, I think the next version can be a non-RFC series.
Quoted 84 lines
With the feature disabled Q35 falls back to the native hot-plug.
Pros
* no racy behavior during boot (see110c477c2ed)
* eject is possible - according to PCIe spec, attention button press should lead to power off, and then the adapter should be removed manually. As there is no power down state exists in QEMU, we cannot distinguish between an eject and a power down request.
* no delay during deleting - after the actual power off software must wait at least 1 second before indicating about it. This case is quite important for users, it even has its own bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1594168
* no timer-based behavior - in addition to the previous example, the attention button has a 5-second waiting period, during which the operation can be canceled with a second press. While this looks fine for manual button control, automation will result in the need to queue or drop events, and the software receiving events in all sort of unspecified combinations of attention/power indicator states, which is racy and uppredictable.
* fixes or reduces the likelihood of the bugs:
* https://bugzilla.redhat.com/show_bug.cgi?id=1833187
* https://bugzilla.redhat.com/show_bug.cgi?id=1657077
* https://bugzilla.redhat.com/show_bug.cgi?id=1669931
* https://bugzilla.redhat.com/show_bug.cgi?id=1678290Cons:
* no access to possible features presented in slot capabilities (this is only surprise removal AFAIK)v4:
* regain per-port control over hot-plug
* rebased over acpi-index changes
* set property on machine type to
make pci code more generic [Igor, Michael]v3:
* drop change of_OSCto allow SHPC on hotplugged bridges
* use 'acpi-root-pci-hotplug'
* add migration states [Igor]
* minor style changesv2:
* new ioport range for acpiphp [Gerd]
* dropfind_pci_host()[Igor]
* explain magic numbers in_OSC[Igor]
* dropbuild_q35_pci_hotplug()wrapper [Igor]Julia Suvorova (7):
hw/acpi/pcihp: Enhanceacpi_pcihp_disable_root_bus()to support Q35 hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35 hw/acpi/ich9: Enable ACPI PCI hot-plug
hw/pci/pcie: Do not set HPC flag if acpihp is used
bios-tables-test: Allow changes in DSDT ACPI tables hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35
bios-tables-test: Update golden binarieshw/i386/acpi-build.h | 5 +++ include/hw/acpi/ich9.h | 5 +++ include/hw/acpi/pcihp.h | 3 +- include/hw/boards.h | 1 + hw/acpi/ich9.c | 68 ++++++++++++++++++++++++++++++ hw/acpi/pcihp.c | 22 +++++++--- hw/acpi/piix4.c | 4 +- hw/core/machine.c | 19 +++++++++ hw/i386/acpi-build.c | 32 ++++++++------ hw/i386/pc.c | 4 +- hw/i386/pc_q35.c | 8 ++++ hw/pci/pcie.c | 11 ++++- tests/data/acpi/q35/DSDT | Bin 7859 -> 8289 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9184 -> 9614 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7877 -> 11003 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8323 -> 8753 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9513 -> 9943 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7934 -> 8364 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9218 -> 9648 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8990 -> 9419 bytes tests/data/acpi/q35/DSDT.nohpet | Bin 7717 -> 8147 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7865 -> 8295 bytes tests/data/acpi/q35/DSDT.tis | Bin 8465 -> 8894 bytes 23 files changed, 161 insertions(+), 21 deletions(-)Signature · 1 line
2.30.2