Skip to contentSkip to conversation

Use ACPI PCI hot-plug for Q35

RFC PATCH Superseded Julia Suvorova 7 participants 40 messages Sep 24, 2020 – Oct 6, 2020

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 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:
* https://bugzilla.redhat.com/show_bug.cgi?id=1752465
* https://bugzilla.redhat.com/show_bug.cgi?id=1690256

Cons:
* lose per-port control over hot-plug (can be resolved)
* no access to possible features presented in slot capabilities (this is only surprise removal AFAIK)

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/pci/pcie: Do not initialize slot capability if acpihp is used hw/acpi/ich9: Enable ACPI PCI hot-plug
bios-tables-test: Allow changes in DSDT ACPI tables hw/acpi/ich9: Set ACPI PCI hot-plug as default
bios-tables-test: Update golden binaries

 hw/i386/acpi-build.h              |   7 ++++
 include/hw/acpi/ich9.h            |   5 +++
 include/hw/acpi/pcihp.h           |   3 +-
 hw/acpi/ich9.c                    |  67 ++++++++++++++++++++++++++++++
 hw/acpi/pcihp.c                   |  16 ++++---
 hw/acpi/piix4.c                   |   4 +-
 hw/i386/acpi-build.c              |  31 ++++++++------
 hw/i386/pc.c                      |   1 +
 hw/pci/pcie.c                     |  16 +++++++
 tests/data/acpi/q35/DSDT          | Bin 7678 -> 7950 bytes
 tests/data/acpi/q35/DSDT.acpihmat | Bin 9002 -> 9274 bytes
 tests/data/acpi/q35/DSDT.bridge   | Bin 7695 -> 9865 bytes
 tests/data/acpi/q35/DSDT.cphp     | Bin 8141 -> 8413 bytes
 tests/data/acpi/q35/DSDT.dimmpxm  | Bin 9331 -> 9603 bytes
 tests/data/acpi/q35/DSDT.ipmibt   | Bin 7753 -> 8025 bytes
 tests/data/acpi/q35/DSDT.memhp    | Bin 9037 -> 9309 bytes
 tests/data/acpi/q35/DSDT.mmio64   | Bin 8808 -> 9080 bytes
 tests/data/acpi/q35/DSDT.numamem  | Bin 7684 -> 7956 bytes
 tests/data/acpi/q35/DSDT.tis      | Bin 8283 -> 8555 bytes
 19 files changed, 129 insertions(+), 21 deletions(-)
Signature · 1 line
2.25.4
#1 lore raw

RFC PATCH v3 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
index 39b1f74442..ff23104aea 100644
@@ -107,13 +107,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.25.4
Reviewed-by on v3 1/7
#2 lore raw

Re: [RFC PATCH v3 1/7] hw/acpi/pcihp: Enhance acpi_pcihp_disable_root_bus() to support Q35

Quoted 5 lines · On Thu, 24 Sep 2020 09:00:07 +0200 Julia Suvorova <[email protected]> wrote:

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.

Quoted 24 lines
---
 hw/acpi/pcihp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/acpi/pcihp.c +2 -1
index 39b1f74442..ff23104aea 100644
@@ -107,13 +107,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);
#3 lore raw

Re: [RFC PATCH v3 1/7] hw/acpi/pcihp: Enhance acpi_pcihp_disable_root_bus() to support Q35

In reply to Julia Suvorova
Quoted 4 lines · Julia Suvorova

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.

I think what this change is doing here is making acpi_pcihp_disable_root_bus() function compatible with q35 as well.

Quoted 29 lines
---
 hw/acpi/pcihp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/acpi/pcihp.c +2 -2
index 39b1f74442..ff23104aea 100644
@@ -107,13 +107,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);
--

2.25.4

#4 lore raw

RFC PATCH v3 2/7 hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35

In reply to Julia Suvorova

Implement 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         |  8 ++++----
 hw/acpi/piix4.c         |  4 +++-
 hw/i386/acpi-build.c    | 27 ++++++++++++++++-----------
 6 files changed, 31 insertions(+), 17 deletions(-)
hw/i386/acpi-build.h +4 -0
index 74df5fc612..487ec7710f 100644
@@ -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
index 28a53181cb..4d19571ed7 100644
@@ -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
index 02f4665767..ce49fb03b9 100644
@@ -54,7 +54,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 +4 -4
index ff23104aea..bb457bc279 100644
@@ -38,7 +38,6 @@
 #include "qom/qom-qobject.h"
 #include "trace.h"
 
-#define ACPI_PCIHP_ADDR 0xae00
 #define ACPI_PCIHP_SIZE 0x0014
 #define PCI_UP_BASE 0x0000
 #define PCI_DOWN_BASE 0x0004
@@ -381,12 +380,13 @@ 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->root = root_bus;
     s->legacy_piix = !bridges_enabled;
 
     memory_region_init_io(&s->io, owner, &acpi_pcihp_io_ops, s,
hw/acpi/piix4.c +3 -1
index 832f8fba82..a505ab5bcf 100644
@@ -50,6 +50,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;
@@ -597,7 +599,7 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
     memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe);
 
     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;
     object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy",
hw/i386/acpi-build.c +16 -11
index 0e0535d2e3..cf503b16af 100644
@@ -201,10 +201,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) {
         struct AcpiGenericAddress r = { .space_id = AML_AS_SYSTEM_IO,
@@ -214,6 +210,10 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
         pm->fadt.flags |= 1 << ACPI_FADT_F_RESET_REG_SUP;
         pm->cpu_hp_io_base = ICH9_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);
 
     /* The above need not be conditional on machine type because the reset port
      * happens to be the same on PIIX (pc) and ICH9 (q35). */
@@ -472,7 +472,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;
             }
 
@@ -1368,7 +1368,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_pci_hotplug(Aml *table, uint64_t pcihp_addr)
 {
     Aml *scope;
     Aml *field;
@@ -1377,20 +1377,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), 0x04));
+        aml_operation_region("BNMR", AML_SYSTEM_IO,
+                             aml_int(pcihp_addr + ACPI_PCIHP_BNMR_BASE), 0x04));
     field = aml_field("BNMR", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
     aml_append(field, aml_named_field("BNUM", 32));
     aml_append(scope, field);
@@ -1504,7 +1506,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         build_hpet_aml(dsdt);
         build_piix4_isa_bridge(dsdt);
         build_isa_devices_aml(dsdt);
-        build_piix4_pci_hotplug(dsdt);
+        build_x86_pci_hotplug(dsdt, pm->pcihp_io_base);
         build_piix4_pci0_int(dsdt);
     } else {
         sb_scope = aml_scope("_SB");
@@ -1520,6 +1522,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         build_hpet_aml(dsdt);
         build_q35_isa_bridge(dsdt);
         build_isa_devices_aml(dsdt);
+        if (pm->pcihp_bridge_en) {
+            build_x86_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);
@@ -1546,7 +1551,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
     {
         aml_append(scope, aml_name_decl("_HID", aml_string("ACPI0006")));
 
-        if (misc->is_piix4) {
+        if (misc->is_piix4 || pm->pcihp_bridge_en) {
             method = aml_method("_E01", 0, AML_NOTSERIALIZED);
             aml_append(method,
                 aml_acquire(aml_name("\\_SB.PCI0.BLCK"), 0xFFFF));
Signature · 1 line
2.25.4
Reviewed-by on v3 2/7
#5 lore raw

Re: [RFC PATCH v3 2/7] hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35

Quoted 2 lines · On Thu, 24 Sep 2020 09:00:08 +0200 Julia Suvorova <[email protected]> wrote:

Implement notifications and gpe to support q35 ACPI PCI hot-plug. Use 0xcc4 - 0xcd7 range for 'acpi-pci-hotplug' io ports.

Gerd,

does picked IO range looks acceptable to you?

Quoted 1 line

with minor nits below fixed:

Quoted 138 lines
---
 hw/i386/acpi-build.h    |  4 ++++
 include/hw/acpi/ich9.h  |  2 ++
 include/hw/acpi/pcihp.h |  3 ++-
 hw/acpi/pcihp.c         |  8 ++++----
 hw/acpi/piix4.c         |  4 +++-
 hw/i386/acpi-build.c    | 27 ++++++++++++++++-----------
 6 files changed, 31 insertions(+), 17 deletions(-)
hw/i386/acpi-build.h +4 -0
index 74df5fc612..487ec7710f 100644
@@ -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
index 28a53181cb..4d19571ed7 100644
@@ -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
index 02f4665767..ce49fb03b9 100644
@@ -54,7 +54,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 +4 -4
index ff23104aea..bb457bc279 100644
@@ -38,7 +38,6 @@
 #include "qom/qom-qobject.h"
 #include "trace.h"
 
-#define ACPI_PCIHP_ADDR 0xae00
 #define ACPI_PCIHP_SIZE 0x0014
 #define PCI_UP_BASE 0x0000
 #define PCI_DOWN_BASE 0x0004
@@ -381,12 +380,13 @@ 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->root = root_bus;
     s->legacy_piix = !bridges_enabled;
 
     memory_region_init_io(&s->io, owner, &acpi_pcihp_io_ops, s,
hw/acpi/piix4.c +3 -1
index 832f8fba82..a505ab5bcf 100644
@@ -50,6 +50,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;
@@ -597,7 +599,7 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
     memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe);
 
     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;
     object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy",
hw/i386/acpi-build.c +5 -5
index 0e0535d2e3..cf503b16af 100644
@@ -201,10 +201,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) {
         struct AcpiGenericAddress r = { .space_id = AML_AS_SYSTEM_IO,
@@ -214,6 +210,10 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
         pm->fadt.flags |= 1 << ACPI_FADT_F_RESET_REG_SUP;
         pm->cpu_hp_io_base = ICH9_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);
 
     /* The above need not be conditional on machine type because the reset port
      * happens to be the same on PIIX (pc) and ICH9 (q35). */
@@ -472,7 +472,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;
             }
 

hw/i386/acpi-build.c static void build_piix4_isa_bridge(Aml *table) · line 1371

Quoted 5 lines
hw/i386/acpi-build.c +1 -1
@@ -1368,7 +1368,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_pci_hotplug(Aml *table, uint64_t pcihp_addr)

maybe
s/_pci_/_acpi_pci_/
otherwise it could be a bit confusing

Quoted 7 lines
hw/i386/acpi-build.c +0 -0
 {
     Aml *scope;
     Aml *field;
@@ -1377,20 +1377,22 @@ static void build_piix4_pci_hotplug(Aml *table)
     scope =  aml_scope("_SB.PCI0");
 
     aml_append(scope,

hw/i386/acpi-build.c static void build_piix4_pci_hotplug(Aml *table) · line 1387

Quoted 10 lines
hw/i386/acpi-build.c +2 -2
-        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,

not aligned properly

Quoted 40 lines
hw/i386/acpi-build.c +8 -3
+                         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), 0x04));
+        aml_operation_region("BNMR", AML_SYSTEM_IO,
+                             aml_int(pcihp_addr + ACPI_PCIHP_BNMR_BASE), 0x04));
     field = aml_field("BNMR", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
     aml_append(field, aml_named_field("BNUM", 32));
     aml_append(scope, field);
@@ -1504,7 +1506,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         build_hpet_aml(dsdt);
         build_piix4_isa_bridge(dsdt);
         build_isa_devices_aml(dsdt);
-        build_piix4_pci_hotplug(dsdt);
+        build_x86_pci_hotplug(dsdt, pm->pcihp_io_base);
         build_piix4_pci0_int(dsdt);
     } else {
         sb_scope = aml_scope("_SB");
@@ -1520,6 +1522,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         build_hpet_aml(dsdt);
         build_q35_isa_bridge(dsdt);
         build_isa_devices_aml(dsdt);
+        if (pm->pcihp_bridge_en) {
+            build_x86_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);
@@ -1546,7 +1551,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
     {
         aml_append(scope, aml_name_decl("_HID", aml_string("ACPI0006")));
 
-        if (misc->is_piix4) {
+        if (misc->is_piix4 || pm->pcihp_bridge_en) {
             method = aml_method("_E01", 0, AML_NOTSERIALIZED);
             aml_append(method,
                 aml_acquire(aml_name("\\_SB.PCI0.BLCK"), 0xFFFF));
Acked-by
#6 lore raw

Re: [RFC PATCH v3 2/7] hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35

Quoted 9 lines · Igor Mammedov
Quoted 2 lines · On Thu, 24 Sep 2020 09:00:08 +0200 Julia Suvorova <[email protected]> wrote:

Implement notifications and gpe to support q35 ACPI PCI hot-plug. Use 0xcc4 - 0xcd7 range for 'acpi-pci-hotplug' io ports.

Gerd,

does picked IO range looks acceptable to you?

Yes, that is fine.

#7 lore raw

Re: [RFC PATCH v3 2/7] hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35

In reply to Julia Suvorova
Quoted 3 lines · Julia Suvorova

Implement notifications and gpe to support q35 ACPI PCI hot-plug. Use 0xcc4 - 0xcd7 range for 'acpi-pci-hotplug' io ports.

For this patch, I would suggest maybe you can also add a diff of the disassembly of the DSDT table so that we know what changes exactly we shall see in the table as a result of this patch.
Add the diff to this commit message as it will be helpful for anyone to take a look at it when they look at this patch.

Quoted 65 lines

---

hw/i386/acpi-build.h    |  4 ++++
include/hw/acpi/ich9.h  |  2 ++
include/hw/acpi/pcihp.h |  3 ++-
hw/acpi/pcihp.c         |  8 ++++----
hw/acpi/piix4.c         |  4 +++-
hw/i386/acpi-build.c    | 27 ++++++++++++++++-----------
6 files changed, 31 insertions(+), 17 deletions(-)
hw/i386/acpi-build.h +4 -0
index 74df5fc612..487ec7710f 100644
@@ -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
index 28a53181cb..4d19571ed7 100644
@@ -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
index 02f4665767..ce49fb03b9 100644
@@ -54,7 +54,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 +0 -1
index ff23104aea..bb457bc279 100644
@@ -38,7 +38,6 @@
 #include "qom/qom-qobject.h"
 #include "trace.h"
 
-#define ACPI_PCIHP_ADDR 0xae00
 #define ACPI_PCIHP_SIZE 0x0014
 #define PCI_UP_BASE 0x0000
 #define PCI_DOWN_BASE 0x0004

hw/acpi/pcihp.c static const MemoryRegionOps acpi_pcihp_io_ops = { · line 387

Quoted 10 lines
hw/acpi/pcihp.c +3 -2
@@ -381,12 +380,13 @@ 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;

Maybe you want to remove ACPI_PCIHP_ADDR ?

Quoted 99 lines
hw/acpi/pcihp.c +1 -1
-    s->root= root_bus;
+    s->root = root_bus;
    s->legacy_piix = !bridges_enabled;
 
    memory_region_init_io(&s->io, owner, &acpi_pcihp_io_ops, s,
hw/acpi/piix4.c +3 -1
index 832f8fba82..a505ab5bcf 100644
@@ -50,6 +50,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;
@@ -597,7 +599,7 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
    memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe);
 
    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;
    object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy",
hw/i386/acpi-build.c +11 -9
index 0e0535d2e3..cf503b16af 100644
@@ -201,10 +201,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) {
        struct AcpiGenericAddress r = { .space_id = AML_AS_SYSTEM_IO,
@@ -214,6 +210,10 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
        pm->fadt.flags |= 1 << ACPI_FADT_F_RESET_REG_SUP;
        pm->cpu_hp_io_base = ICH9_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);
 
    /* The above need not be conditional on machine type because the reset port
     * happens to be the same on PIIX (pc) and ICH9 (q35). */
@@ -472,7 +472,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;
            }
 
@@ -1368,7 +1368,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_pci_hotplug(Aml *table, uint64_t pcihp_addr)
 {
    Aml *scope;
    Aml *field;
@@ -1377,20 +1377,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), 0x04));
+        aml_operation_region("BNMR", AML_SYSTEM_IO,
+                             aml_int(pcihp_addr + ACPI_PCIHP_BNMR_BASE), 0x04));
    field = aml_field("BNMR", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
    aml_append(field, aml_named_field("BNUM", 32));
    aml_append(scope, field);

hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1509

Quoted 5 lines
hw/i386/acpi-build.c +1 -1
@@ -1504,7 +1506,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
        build_hpet_aml(dsdt);
        build_piix4_isa_bridge(dsdt);
        build_isa_devices_aml(dsdt);
-        build_piix4_pci_hotplug(dsdt);
+        build_x86_pci_hotplug(dsdt, pm->pcihp_io_base);

This will conflict here with my patch. I think you need to do something like this:

  if (pm->pcihp_bridge_en || pm->pcihp_root_en) {

You'll get this from my patch.

hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1527

Quoted 10 lines
hw/i386/acpi-build.c +3 -0
        build_piix4_pci0_int(dsdt);
    } else {
        sb_scope = aml_scope("_SB");
@@ -1520,6 +1522,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
        build_hpet_aml(dsdt);
        build_q35_isa_bridge(dsdt);
        build_isa_devices_aml(dsdt);
+        if (pm->pcihp_bridge_en) {
+            build_x86_pci_hotplug(dsdt, pm->pcihp_io_base);
+        }

ditto as above.

Quoted 16 lines
hw/i386/acpi-build.c +1 -1
        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);
@@ -1546,7 +1551,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
    {
        aml_append(scope, aml_name_decl("_HID", aml_string("ACPI0006")));
 
-        if (misc->is_piix4) {
+        if (misc->is_piix4 || pm->pcihp_bridge_en) {
            method = aml_method("_E01", 0, AML_NOTSERIALIZED);
            aml_append(method,
                aml_acquire(aml_name("\\_SB.PCI0.BLCK"), 0xFFFF));
Signature · 1 line
2.25.4
#8 lore raw

Re: [RFC PATCH v3 2/7] hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35

Quoted 9 lines · Ani Sinha
Quoted 3 lines · Julia Suvorova

Implement notifications and gpe to support q35 ACPI PCI hot-plug. Use 0xcc4 - 0xcd7 range for 'acpi-pci-hotplug' io ports.

Quoted 5 lines

For this patch, I would suggest maybe you can also add a diff of the disassembly of the DSDT table so that we know what changes exactly we shall see in the table as a result of this patch.
Add the diff to this commit message as it will be helpful for anyone to take a look at it when they look at this patch.

There is no difference in golden DSDT, because this is an option, which is disabled by default.
The diff is placed in the patch where it actually makes a difference. But I agree that a list of changed registers would be a nice addition to the commit message.

Quoted 67 lines
Quoted 67 lines

---

hw/i386/acpi-build.h    |  4 ++++
include/hw/acpi/ich9.h  |  2 ++
include/hw/acpi/pcihp.h |  3 ++-
hw/acpi/pcihp.c         |  8 ++++----
hw/acpi/piix4.c         |  4 +++-
hw/i386/acpi-build.c    | 27 ++++++++++++++++-----------
6 files changed, 31 insertions(+), 17 deletions(-)
hw/i386/acpi-build.h +4 -0
index 74df5fc612..487ec7710f 100644
@@ -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
index 28a53181cb..4d19571ed7 100644
@@ -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
index 02f4665767..ce49fb03b9 100644
@@ -54,7 +54,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 +0 -1
index ff23104aea..bb457bc279 100644
@@ -38,7 +38,6 @@
 #include "qom/qom-qobject.h"
 #include "trace.h"
 
-#define ACPI_PCIHP_ADDR 0xae00
 #define ACPI_PCIHP_SIZE 0x0014
 #define PCI_UP_BASE 0x0000
 #define PCI_DOWN_BASE 0x0004
@@ -381,12 +380,13 @@ static const MemoryRegionOps acpi_pcihp_io_ops = {
 };
 
Quoted 10 lines

hw/acpi/pcihp.c static const MemoryRegionOps acpi_pcihp_io_ops = { · line 387

Quoted 8 lines
hw/acpi/pcihp.c +3 -2
 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;

Maybe you want to remove ACPI_PCIHP_ADDR ?

It is removed (a bit higher in this patch).

Quoted 107 lines
Quoted 98 lines
hw/acpi/pcihp.c +1 -1
-    s->root= root_bus;
+    s->root = root_bus;
    s->legacy_piix = !bridges_enabled;
 
    memory_region_init_io(&s->io, owner, &acpi_pcihp_io_ops, s,
hw/acpi/piix4.c +3 -1
index 832f8fba82..a505ab5bcf 100644
@@ -50,6 +50,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;
@@ -597,7 +599,7 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
    memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe);
 
    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;
    object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy",
hw/i386/acpi-build.c +11 -9
index 0e0535d2e3..cf503b16af 100644
@@ -201,10 +201,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) {
        struct AcpiGenericAddress r = { .space_id = AML_AS_SYSTEM_IO,
@@ -214,6 +210,10 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
        pm->fadt.flags |= 1 << ACPI_FADT_F_RESET_REG_SUP;
        pm->cpu_hp_io_base = ICH9_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);
 
    /* The above need not be conditional on machine type because the reset port
     * happens to be the same on PIIX (pc) and ICH9 (q35). */
@@ -472,7 +472,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;
            }
 
@@ -1368,7 +1368,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_pci_hotplug(Aml *table, uint64_t pcihp_addr)
 {
    Aml *scope;
    Aml *field;
@@ -1377,20 +1377,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), 0x04));
+        aml_operation_region("BNMR", AML_SYSTEM_IO,
+                             aml_int(pcihp_addr + ACPI_PCIHP_BNMR_BASE), 0x04));
    field = aml_field("BNMR", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
    aml_append(field, aml_named_field("BNUM", 32));
    aml_append(scope, field);

hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1509

Quoted 5 lines
hw/i386/acpi-build.c +1 -1
@@ -1504,7 +1506,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
        build_hpet_aml(dsdt);
        build_piix4_isa_bridge(dsdt);
        build_isa_devices_aml(dsdt);
-        build_piix4_pci_hotplug(dsdt);
+        build_x86_pci_hotplug(dsdt, pm->pcihp_io_base);

This will conflict here with my patch. I think you need to do something like this:

Quoted 1 line
   if (pm->pcihp_bridge_en || pm->pcihp_root_en) {

Yes, and I change it if your patch set gets merged first. Otherwise, you will need to rebase.

Quoted 31 lines

You'll get this from my patch.

hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1527

Quoted 10 lines
hw/i386/acpi-build.c +3 -0
        build_piix4_pci0_int(dsdt);
    } else {
        sb_scope = aml_scope("_SB");
@@ -1520,6 +1522,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
        build_hpet_aml(dsdt);
        build_q35_isa_bridge(dsdt);
        build_isa_devices_aml(dsdt);
+        if (pm->pcihp_bridge_en) {
+            build_x86_pci_hotplug(dsdt, pm->pcihp_io_base);
+        }

ditto as above.

Quoted 16 lines
hw/i386/acpi-build.c +1 -2
        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);
@@ -1546,7 +1551,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
    {
        aml_append(scope, aml_name_decl("_HID", aml_string("ACPI0006")));
 
-        if (misc->is_piix4) {
+        if (misc->is_piix4 || pm->pcihp_bridge_en) {
            method = aml_method("_E01", 0, AML_NOTSERIALIZED);
            aml_append(method,
                aml_acquire(aml_name("\\_SB.PCI0.BLCK"), 0xFFFF));
--

2.25.4

#9 lore raw

RFC PATCH v3 3/7 hw/pci/pcie: Do not initialize slot capability if acpihp is used

In reply to Julia Suvorova

Instead of changing the hot-plug type in _OSC register, do not initialize the slot capability or set the 'Slot Implemented' flag. This way guest will choose ACPI hot-plug if it is preferred and leave the option to use SHPC with pcie-pci-bridge.

---
 hw/i386/acpi-build.h |  2 ++
 hw/i386/acpi-build.c |  2 +-
 hw/pci/pcie.c        | 16 ++++++++++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)
hw/i386/acpi-build.h +2 -0
index 487ec7710f..4c5bfb3d0b 100644
@@ -11,4 +11,6 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;
 
 void acpi_setup(void);
 
+Object *object_resolve_type_unambiguous(const char *typename);
+
 #endif
hw/i386/acpi-build.c +1 -1
index cf503b16af..b7811a8912 100644
@@ -174,7 +174,7 @@ static void init_common_fadt_data(MachineState *ms, Object *o,
     *data = fadt;
 }
 
-static Object *object_resolve_type_unambiguous(const char *typename)
+Object *object_resolve_type_unambiguous(const char *typename)
 {
     bool ambig;
     Object *o = object_resolve_path_type("", typename, &ambig);
hw/pci/pcie.c +16 -0
index 5b48bae0f6..c1a082e8b9 100644
@@ -27,6 +27,8 @@
 #include "hw/pci/pci_bus.h"
 #include "hw/pci/pcie_regs.h"
 #include "hw/pci/pcie_port.h"
+#include "hw/i386/ich9.h"
+#include "hw/i386/acpi-build.h"
 #include "qemu/range.h"
 
 //#define DEBUG_PCIE
@@ -515,12 +517,26 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
     pcie_cap_slot_push_attention_button(hotplug_pdev);
 }
 
+static bool acpi_pcihp_enabled(void)
+{
+    Object *lpc = object_resolve_type_unambiguous(TYPE_ICH9_LPC_DEVICE);
+
+    return lpc &&
+           object_property_get_bool(lpc, "acpi-pci-hotplug-with-bridge-support",
+                                    NULL);
+
+}
+
 /* pci express slot for pci express root/downstream port
    PCI express capability slot registers */
 void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s)
 {
     uint32_t pos = dev->exp.exp_cap;
 
+    if (acpi_pcihp_enabled()) {
+        return;
+    }
+
     pci_word_test_and_set_mask(dev->config + pos + PCI_EXP_FLAGS,
                                PCI_EXP_FLAGS_SLOT);
 
Signature · 1 line
2.25.4
#10 lore raw

Re: [RFC PATCH v3 3/7] hw/pci/pcie: Do not initialize slot capability if acpihp is used

Quoted 41 lines · Julia Suvorova

Instead of changing the hot-plug type in _OSC register, do not initialize the slot capability or set the 'Slot Implemented' flag. This way guest will choose ACPI hot-plug if it is preferred and leave the option to use SHPC with pcie-pci-bridge.

---
 hw/i386/acpi-build.h |  2 ++
 hw/i386/acpi-build.c |  2 +-
 hw/pci/pcie.c        | 16 ++++++++++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)
hw/i386/acpi-build.h +2 -0
index 487ec7710f..4c5bfb3d0b 100644
@@ -11,4 +11,6 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;
 
 void acpi_setup(void);
 
+Object *object_resolve_type_unambiguous(const char *typename);
+
 #endif
hw/i386/acpi-build.c +1 -1
index cf503b16af..b7811a8912 100644
@@ -174,7 +174,7 @@ static void init_common_fadt_data(MachineState *ms, Object *o,
     *data = fadt;
 }
 
-static Object *object_resolve_type_unambiguous(const char *typename)
+Object *object_resolve_type_unambiguous(const char *typename)
 {
     bool ambig;
     Object *o = object_resolve_path_type("", typename, &ambig);
hw/pci/pcie.c +0 -0
index 5b48bae0f6..c1a082e8b9 100644

hw/pci/pcie.c line 34

Quoted 8 lines
hw/pci/pcie.c +2 -0
@@ -27,6 +27,8 @@
 #include "hw/pci/pci_bus.h"
 #include "hw/pci/pcie_regs.h"
 #include "hw/pci/pcie_port.h"
+#include "hw/i386/ich9.h"
+#include "hw/i386/acpi-build.h"
 #include "qemu/range.h"
 
 //#define DEBUG_PCIE

Not really happy with pcie.c getting an i386 dependency.

Quoted 4 lines
hw/pci/pcie.c +0 -0
@@ -515,12 +517,26 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
     pcie_cap_slot_push_attention_button(hotplug_pdev);
 }
 

hw/pci/pcie.c void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, · line 529

Quoted 10 lines
hw/pci/pcie.c +10 -0
+static bool acpi_pcihp_enabled(void)
+{
+    Object *lpc = object_resolve_type_unambiguous(TYPE_ICH9_LPC_DEVICE);
+
+    return lpc &&
+           object_property_get_bool(lpc, "acpi-pci-hotplug-with-bridge-support",
+                                    NULL);
+
+}
+

Why not just check the property unconditionally?

hw/pci/pcie.c void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, · line 539

Quoted 10 lines
hw/pci/pcie.c +4 -0
 /* pci express slot for pci express root/downstream port
    PCI express capability slot registers */
 void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s)
 {
     uint32_t pos = dev->exp.exp_cap;
 
+    if (acpi_pcihp_enabled()) {
+        return;
+    }
+

I think I would rather not teach pcie about acpi. How about we change the polarity, name the property "pci-native-hotplug" or whatever makes sense.

Quoted 5 lines
hw/pci/pcie.c +0 -0
     pci_word_test_and_set_mask(dev->config + pos + PCI_EXP_FLAGS,
                                PCI_EXP_FLAGS_SLOT);
 
Signature · 1 line
2.25.4
#11 lore raw

Re: [RFC PATCH v3 3/7] hw/pci/pcie: Do not initialize slot capability if acpihp is used

Quoted 61 lines · Michael S. Tsirkin
Quoted 41 lines · Julia Suvorova

Instead of changing the hot-plug type in _OSC register, do not initialize the slot capability or set the 'Slot Implemented' flag. This way guest will choose ACPI hot-plug if it is preferred and leave the option to use SHPC with pcie-pci-bridge.

---
 hw/i386/acpi-build.h |  2 ++
 hw/i386/acpi-build.c |  2 +-
 hw/pci/pcie.c        | 16 ++++++++++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)
hw/i386/acpi-build.h +2 -0
index 487ec7710f..4c5bfb3d0b 100644
@@ -11,4 +11,6 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;
 
 void acpi_setup(void);
 
+Object *object_resolve_type_unambiguous(const char *typename);
+
 #endif
hw/i386/acpi-build.c +1 -1
index cf503b16af..b7811a8912 100644
@@ -174,7 +174,7 @@ static void init_common_fadt_data(MachineState *ms, Object *o,
     *data = fadt;
 }
 
-static Object *object_resolve_type_unambiguous(const char *typename)
+Object *object_resolve_type_unambiguous(const char *typename)
 {
     bool ambig;
     Object *o = object_resolve_path_type("", typename, &ambig);
hw/pci/pcie.c +0 -0
index 5b48bae0f6..c1a082e8b9 100644

hw/pci/pcie.c line 34

Quoted 8 lines
hw/pci/pcie.c +2 -0
@@ -27,6 +27,8 @@
 #include "hw/pci/pci_bus.h"
 #include "hw/pci/pcie_regs.h"
 #include "hw/pci/pcie_port.h"
+#include "hw/i386/ich9.h"
+#include "hw/i386/acpi-build.h"
 #include "qemu/range.h"
 
 //#define DEBUG_PCIE

Not really happy with pcie.c getting an i386 dependency.

Quoted 4 lines
hw/pci/pcie.c +0 -0
@@ -515,12 +517,26 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
     pcie_cap_slot_push_attention_button(hotplug_pdev);
 }
 
Quoted 12 lines

hw/pci/pcie.c void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, · line 529

Quoted 10 lines
hw/pci/pcie.c +10 -0
+static bool acpi_pcihp_enabled(void)
+{
+    Object *lpc = object_resolve_type_unambiguous(TYPE_ICH9_LPC_DEVICE);
+
+    return lpc &&
+           object_property_get_bool(lpc, "acpi-pci-hotplug-with-bridge-support",
+                                    NULL);
+
+}
+

Why not just check the property unconditionally?

Ok.

Quoted 6 lines
Quoted 6 lines
hw/pci/pcie.c +0 -0
 /* pci express slot for pci express root/downstream port
    PCI express capability slot registers */
 void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s)
 {
     uint32_t pos = dev->exp.exp_cap;
 
Quoted 8 lines

hw/pci/pcie.c void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, · line 539

Quoted 4 lines
hw/pci/pcie.c +4 -0
+    if (acpi_pcihp_enabled()) {
+        return;
+    }
+

I think I would rather not teach pcie about acpi. How about we change the polarity, name the property "pci-native-hotplug" or whatever makes sense.

I'd prefer not to change the property name since the common code in hw/i386/acpi-build.c depends on it, but I can add a new one if it makes any sense.

Quoted 6 lines
Quoted 5 lines
hw/pci/pcie.c +0 -1
     pci_word_test_and_set_mask(dev->config + pos + PCI_EXP_FLAGS,
                                PCI_EXP_FLAGS_SLOT);
 
--

2.25.4

#12 lore raw

Re: [RFC PATCH v3 3/7] hw/pci/pcie: Do not initialize slot capability if acpihp is used

Quoted 88 lines · Julia Suvorova
Quoted 61 lines · Michael S. Tsirkin
Quoted 41 lines · Julia Suvorova

Instead of changing the hot-plug type in _OSC register, do not initialize the slot capability or set the 'Slot Implemented' flag. This way guest will choose ACPI hot-plug if it is preferred and leave the option to use SHPC with pcie-pci-bridge.

---
 hw/i386/acpi-build.h |  2 ++
 hw/i386/acpi-build.c |  2 +-
 hw/pci/pcie.c        | 16 ++++++++++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)
hw/i386/acpi-build.h +2 -0
index 487ec7710f..4c5bfb3d0b 100644
@@ -11,4 +11,6 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;
 
 void acpi_setup(void);
 
+Object *object_resolve_type_unambiguous(const char *typename);
+
 #endif
hw/i386/acpi-build.c +1 -1
index cf503b16af..b7811a8912 100644
@@ -174,7 +174,7 @@ static void init_common_fadt_data(MachineState *ms, Object *o,
     *data = fadt;
 }
 
-static Object *object_resolve_type_unambiguous(const char *typename)
+Object *object_resolve_type_unambiguous(const char *typename)
 {
     bool ambig;
     Object *o = object_resolve_path_type("", typename, &ambig);
hw/pci/pcie.c +0 -0
index 5b48bae0f6..c1a082e8b9 100644

hw/pci/pcie.c line 34

Quoted 8 lines
hw/pci/pcie.c +2 -0
@@ -27,6 +27,8 @@
 #include "hw/pci/pci_bus.h"
 #include "hw/pci/pcie_regs.h"
 #include "hw/pci/pcie_port.h"
+#include "hw/i386/ich9.h"
+#include "hw/i386/acpi-build.h"
 #include "qemu/range.h"
 
 //#define DEBUG_PCIE

Not really happy with pcie.c getting an i386 dependency.

Quoted 4 lines
hw/pci/pcie.c +0 -0
@@ -515,12 +517,26 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
     pcie_cap_slot_push_attention_button(hotplug_pdev);
 }
 
Quoted 12 lines

hw/pci/pcie.c void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, · line 529

Quoted 10 lines
hw/pci/pcie.c +10 -0
+static bool acpi_pcihp_enabled(void)
+{
+    Object *lpc = object_resolve_type_unambiguous(TYPE_ICH9_LPC_DEVICE);
+
+    return lpc &&
+           object_property_get_bool(lpc, "acpi-pci-hotplug-with-bridge-support",
+                                    NULL);
+
+}
+

Why not just check the property unconditionally?

Ok.

Quoted 11 lines
Quoted 10 lines
hw/pci/pcie.c +4 -0
 /* pci express slot for pci express root/downstream port
    PCI express capability slot registers */
 void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s)
 {
     uint32_t pos = dev->exp.exp_cap;
 
+    if (acpi_pcihp_enabled()) {
+        return;
+    }
+
Quoted 7 lines
Quoted 3 lines

I think I would rather not teach pcie about acpi. How about we change the polarity, name the property "pci-native-hotplug" or whatever makes sense.

I'd prefer not to change the property name since the common code in hw/i386/acpi-build.c depends on it, but I can add a new one if it makes any sense.

And maybe prefix with "x-" so we don't commit to it as an external API.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
hw/pci/pcie.c +0 -1
     pci_word_test_and_set_mask(dev->config + pos + PCI_EXP_FLAGS,
                                PCI_EXP_FLAGS_SLOT);
 
--

2.25.4

#13 lore raw

Re: [RFC PATCH v3 3/7] hw/pci/pcie: Do not initialize slot capability if acpihp is used

In reply to Julia Suvorova
Quoted 75 lines · Julia Suvorova
Quoted 61 lines · Michael S. Tsirkin
Quoted 41 lines · Julia Suvorova

Instead of changing the hot-plug type in _OSC register, do not initialize the slot capability or set the 'Slot Implemented' flag. This way guest will choose ACPI hot-plug if it is preferred and leave the option to use SHPC with pcie-pci-bridge.

---
 hw/i386/acpi-build.h |  2 ++
 hw/i386/acpi-build.c |  2 +-
 hw/pci/pcie.c        | 16 ++++++++++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)
hw/i386/acpi-build.h +2 -0
index 487ec7710f..4c5bfb3d0b 100644
@@ -11,4 +11,6 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;
 
 void acpi_setup(void);
 
+Object *object_resolve_type_unambiguous(const char *typename);
+
 #endif
hw/i386/acpi-build.c +1 -1
index cf503b16af..b7811a8912 100644
@@ -174,7 +174,7 @@ static void init_common_fadt_data(MachineState *ms, Object *o,
     *data = fadt;
 }
 
-static Object *object_resolve_type_unambiguous(const char *typename)
+Object *object_resolve_type_unambiguous(const char *typename)
 {
     bool ambig;
     Object *o = object_resolve_path_type("", typename, &ambig);
hw/pci/pcie.c +0 -0
index 5b48bae0f6..c1a082e8b9 100644

hw/pci/pcie.c line 34

Quoted 8 lines
hw/pci/pcie.c +2 -0
@@ -27,6 +27,8 @@
 #include "hw/pci/pci_bus.h"
 #include "hw/pci/pcie_regs.h"
 #include "hw/pci/pcie_port.h"
+#include "hw/i386/ich9.h"
+#include "hw/i386/acpi-build.h"
 #include "qemu/range.h"
 
 //#define DEBUG_PCIE

Not really happy with pcie.c getting an i386 dependency.

Quoted 4 lines
hw/pci/pcie.c +0 -0
@@ -515,12 +517,26 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
     pcie_cap_slot_push_attention_button(hotplug_pdev);
 }
 
Quoted 12 lines

hw/pci/pcie.c void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, · line 529

Quoted 10 lines
hw/pci/pcie.c +10 -0
+static bool acpi_pcihp_enabled(void)
+{
+    Object *lpc = object_resolve_type_unambiguous(TYPE_ICH9_LPC_DEVICE);
+
+    return lpc &&
+           object_property_get_bool(lpc, "acpi-pci-hotplug-with-bridge-support",
+                                    NULL);
+
+}
+

Why not just check the property unconditionally?

Quoted 1 line

Ok.

I do not see how that would work if lpc is NULL. object_resolve_type_unambiguous() can return NULL, at least in theory.

Quoted 28 lines
Quoted 7 lines
Quoted 7 lines
hw/pci/pcie.c +0 -0
 /* pci express slot for pci express root/downstream port
    PCI express capability slot registers */
 void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s)
 {
     uint32_t pos = dev->exp.exp_cap;
 
Quoted 8 lines

hw/pci/pcie.c void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, · line 539

Quoted 4 lines
hw/pci/pcie.c +4 -0
+    if (acpi_pcihp_enabled()) {
+        return;
+    }
+

I think I would rather not teach pcie about acpi. How about we change the polarity, name the property "pci-native-hotplug" or whatever makes sense.

I'd prefer not to change the property name since the common code in hw/i386/acpi-build.c depends on it, but I can add a new one if it makes any sense.

Quoted 6 lines
Quoted 5 lines
hw/pci/pcie.c +0 -1
     pci_word_test_and_set_mask(dev->config + pos + PCI_EXP_FLAGS,
                                PCI_EXP_FLAGS_SLOT);
 
--

2.25.4

#14 lore raw

Re: [RFC PATCH v3 3/7] hw/pci/pcie: Do not initialize slot capability if acpihp is used

In reply to Julia Suvorova
Quoted 66 lines · On Thu, 24 Sep 2020 09:00:09 +0200 Julia Suvorova <[email protected]> wrote:

Instead of changing the hot-plug type in _OSC register, do not initialize the slot capability or set the 'Slot Implemented' flag. This way guest will choose ACPI hot-plug if it is preferred and leave the option to use SHPC with pcie-pci-bridge.

---
 hw/i386/acpi-build.h |  2 ++
 hw/i386/acpi-build.c |  2 +-
 hw/pci/pcie.c        | 16 ++++++++++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)
hw/i386/acpi-build.h +2 -0
index 487ec7710f..4c5bfb3d0b 100644
@@ -11,4 +11,6 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;
 
 void acpi_setup(void);
 
+Object *object_resolve_type_unambiguous(const char *typename);
+
 #endif
hw/i386/acpi-build.c +1 -1
index cf503b16af..b7811a8912 100644
@@ -174,7 +174,7 @@ static void init_common_fadt_data(MachineState *ms, Object *o,
     *data = fadt;
 }
 
-static Object *object_resolve_type_unambiguous(const char *typename)
+Object *object_resolve_type_unambiguous(const char *typename)
 {
     bool ambig;
     Object *o = object_resolve_path_type("", typename, &ambig);
hw/pci/pcie.c +12 -0
index 5b48bae0f6..c1a082e8b9 100644
@@ -27,6 +27,8 @@
 #include "hw/pci/pci_bus.h"
 #include "hw/pci/pcie_regs.h"
 #include "hw/pci/pcie_port.h"
+#include "hw/i386/ich9.h"
+#include "hw/i386/acpi-build.h"
 #include "qemu/range.h"
 
 //#define DEBUG_PCIE
@@ -515,12 +517,26 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
     pcie_cap_slot_push_attention_button(hotplug_pdev);
 }
 
+static bool acpi_pcihp_enabled(void)
+{
+    Object *lpc = object_resolve_type_unambiguous(TYPE_ICH9_LPC_DEVICE);
+
+    return lpc &&
+           object_property_get_bool(lpc, "acpi-pci-hotplug-with-bridge-support",
+                                    NULL);
+
+}
+
 /* pci express slot for pci express root/downstream port
    PCI express capability slot registers */
 void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s)

hw/pci/pcie.c void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, · line 542

Quoted 10 lines
hw/pci/pcie.c +4 -0
 {
     uint32_t pos = dev->exp.exp_cap;
 
+    if (acpi_pcihp_enabled()) {
+        return;
+    }
+
     pci_word_test_and_set_mask(dev->config + pos + PCI_EXP_FLAGS,
                                PCI_EXP_FLAGS_SLOT);
 

why do you drop all slot caps instead of disabling just "if (s->hotplug) {" branch?

#15 lore raw

Re: [RFC PATCH v3 3/7] hw/pci/pcie: Do not initialize slot capability if acpihp is used

Quoted 72 lines · Igor Mammedov
Quoted 69 lines · On Thu, 24 Sep 2020 09:00:09 +0200 Julia Suvorova <[email protected]> wrote:

Instead of changing the hot-plug type in _OSC register, do not initialize the slot capability or set the 'Slot Implemented' flag. This way guest will choose ACPI hot-plug if it is preferred and leave the option to use SHPC with pcie-pci-bridge.

---
 hw/i386/acpi-build.h |  2 ++
 hw/i386/acpi-build.c |  2 +-
 hw/pci/pcie.c        | 16 ++++++++++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)
hw/i386/acpi-build.h +2 -0
index 487ec7710f..4c5bfb3d0b 100644
@@ -11,4 +11,6 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;
 
 void acpi_setup(void);
 
+Object *object_resolve_type_unambiguous(const char *typename);
+
 #endif
hw/i386/acpi-build.c +1 -1
index cf503b16af..b7811a8912 100644
@@ -174,7 +174,7 @@ static void init_common_fadt_data(MachineState *ms, Object *o,
     *data = fadt;
 }
 
-static Object *object_resolve_type_unambiguous(const char *typename)
+Object *object_resolve_type_unambiguous(const char *typename)
 {
     bool ambig;
     Object *o = object_resolve_path_type("", typename, &ambig);
hw/pci/pcie.c +12 -0
index 5b48bae0f6..c1a082e8b9 100644
@@ -27,6 +27,8 @@
 #include "hw/pci/pci_bus.h"
 #include "hw/pci/pcie_regs.h"
 #include "hw/pci/pcie_port.h"
+#include "hw/i386/ich9.h"
+#include "hw/i386/acpi-build.h"
 #include "qemu/range.h"
 
 //#define DEBUG_PCIE
@@ -515,12 +517,26 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
     pcie_cap_slot_push_attention_button(hotplug_pdev);
 }
 
+static bool acpi_pcihp_enabled(void)
+{
+    Object *lpc = object_resolve_type_unambiguous(TYPE_ICH9_LPC_DEVICE);
+
+    return lpc &&
+           object_property_get_bool(lpc, "acpi-pci-hotplug-with-bridge-support",
+                                    NULL);
+
+}
+
 /* pci express slot for pci express root/downstream port
    PCI express capability slot registers */
 void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s)
 {
     uint32_t pos = dev->exp.exp_cap;
 
Quoted 8 lines

hw/pci/pcie.c void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev, · line 542

Quoted 7 lines
hw/pci/pcie.c +4 -0
+    if (acpi_pcihp_enabled()) {
+        return;
+    }
+
     pci_word_test_and_set_mask(dev->config + pos + PCI_EXP_FLAGS,
                                PCI_EXP_FLAGS_SLOT);
 

why do you drop all slot caps instead of disabling just "if (s->hotplug) {" branch?

+1 to Igor's suggestion.

Quoted 2 lines
#16 lore raw

RFC PATCH v3 4/7 hw/acpi/ich9: Enable ACPI PCI hot-plug

In reply to Julia Suvorova

Add 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         | 67 ++++++++++++++++++++++++++++++++++++++++++
 hw/acpi/pcihp.c        |  5 +++-
 hw/i386/acpi-build.c   |  2 +-
 5 files changed, 76 insertions(+), 2 deletions(-)
hw/i386/acpi-build.h +1 -0
index 4c5bfb3d0b..39f143830a 100644
@@ -10,6 +10,7 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;
 #define ACPI_PCIHP_BNMR_BASE 0x10
 
 void acpi_setup(void);
+Object *acpi_get_i386_pci_host(void);
 
 Object *object_resolve_type_unambiguous(const char *typename);
 
include/hw/acpi/ich9.h +3 -0
index 4d19571ed7..833e62fefe 100644
@@ -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 +67 -0

133 lines not on this page · raw message

hw/acpi/pcihp.c +4 -1
index bb457bc279..8ab65502ce 100644
@@ -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 "exec/address-spaces.h"
 #include "hw/pci/pci_bus.h"
@@ -88,6 +90,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;
 
@@ -96,7 +99,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
index b7811a8912..8787b6fb33 100644
@@ -270,7 +270,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.25.4
#17 lore raw

Re: [RFC PATCH v3 4/7] hw/acpi/ich9: Enable ACPI PCI hot-plug

Quoted 141 lines · Julia Suvorova

Add 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         | 67 ++++++++++++++++++++++++++++++++++++++++++
 hw/acpi/pcihp.c        |  5 +++-
 hw/i386/acpi-build.c   |  2 +-
 5 files changed, 76 insertions(+), 2 deletions(-)
hw/i386/acpi-build.h +1 -0
index 4c5bfb3d0b..39f143830a 100644
@@ -10,6 +10,7 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;
 #define ACPI_PCIHP_BNMR_BASE 0x10
 
 void acpi_setup(void);
+Object *acpi_get_i386_pci_host(void);
 
 Object *object_resolve_type_unambiguous(const char *typename);
 
include/hw/acpi/ich9.h +3 -0
index 4d19571ed7..833e62fefe 100644
@@ -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 +49 -0
index 6a19070cec..987f23e388 100644
@@ -218,6 +218,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),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 const VMStateDescription vmstate_ich9_pm = {
     .name = "ich9_pm",
     .version_id = 1,
@@ -239,6 +259,7 @@ const VMStateDescription vmstate_ich9_pm = {
         &vmstate_memhp_state,
         &vmstate_tco_io_state,
         &vmstate_cpuhp_state,
+        &vmstate_pcihp_state,
         NULL
     }
 };
@@ -260,6 +281,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);
 }
 
@@ -298,6 +320,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;
@@ -369,6 +403,20 @@ static void ich9_pm_set_enable_tco(Object *obj, bool value, Error **errp)
     s->pm.enable_tco = value;
 }
 
+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)
+{
+    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;
@@ -377,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);

hw/acpi/ich9.c void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm) · line 457

Quoted 9 lines
hw/acpi/ich9.c +3 -0
@@ -400,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,

I guess the property name would make sense in pcie.h or something like this.

Quoted 88 lines
hw/acpi/ich9.c +15 -0
@@ -407,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,
@@ -432,6 +489,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)));
@@ -452,6 +512,10 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev,
                !lpc->pm.cpu_hotplug_legacy) {
         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)));
@@ -469,6 +533,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
index bb457bc279..8ab65502ce 100644
@@ -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 "exec/address-spaces.h"
 #include "hw/pci/pci_bus.h"
@@ -88,6 +90,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;
 
@@ -96,7 +99,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
index b7811a8912..8787b6fb33 100644
@@ -270,7 +270,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.25.4
#18 lore raw

Re: [RFC PATCH v3 4/7] hw/acpi/ich9: Enable ACPI PCI hot-plug

In reply to Julia Suvorova
Quoted 85 lines · Julia Suvorova

Add 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         | 67 ++++++++++++++++++++++++++++++++++++++++++
hw/acpi/pcihp.c        |  5 +++-
hw/i386/acpi-build.c   |  2 +-
5 files changed, 76 insertions(+), 2 deletions(-)
hw/i386/acpi-build.h +1 -0
index 4c5bfb3d0b..39f143830a 100644
@@ -10,6 +10,7 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;
 #define ACPI_PCIHP_BNMR_BASE 0x10
 
 void acpi_setup(void);
+Object *acpi_get_i386_pci_host(void);
 
 Object *object_resolve_type_unambiguous(const char *typename);
 
include/hw/acpi/ich9.h +3 -0
index 4d19571ed7..833e62fefe 100644
@@ -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 +21 -0
index 6a19070cec..987f23e388 100644
@@ -218,6 +218,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),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 const VMStateDescription vmstate_ich9_pm = {
    .name = "ich9_pm",
    .version_id = 1,
@@ -239,6 +259,7 @@ const VMStateDescription vmstate_ich9_pm = {
        &vmstate_memhp_state,
        &vmstate_tco_io_state,
        &vmstate_cpuhp_state,
+        &vmstate_pcihp_state,
        NULL
    }
 };

hw/acpi/ich9.c static void pm_reset(void *opaque) · line 284

Quoted 4 lines
hw/acpi/ich9.c +1 -0
@@ -260,6 +281,7 @@ static void pm_reset(void *opaque)
    }
    pm->smi_en_wmask = ~0;
 
+    acpi_pcihp_reset(&pm->acpi_pci_hotplug, true);

Maybe add a comment here that acpi based hotplug is disabled both for PCIE.0 and for the bridges.

Quoted 44 lines
hw/acpi/ich9.c +26 -0
    acpi_update_sci(&pm->acpi_regs, pm->irq);
 }
 
@@ -298,6 +320,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;
@@ -369,6 +403,20 @@ static void ich9_pm_set_enable_tco(Object *obj, bool value, Error **errp)
    s->pm.enable_tco = value;
 }
 
+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)
+{
+    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;

hw/acpi/ich9.c void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm) · line 428

Quoted 4 lines
hw/acpi/ich9.c +1 -0
@@ -377,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;

Ditto regarding the comment as above.

Quoted 78 lines
hw/acpi/ich9.c +18 -0
    object_property_add_uint32_ptr(obj, ACPI_PM_PROP_PM_IO_BASE,
                                   &pm->pm_io_base, OBJ_PROP_FLAG_READ);
@@ -400,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,
@@ -407,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,
@@ -432,6 +489,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)));
@@ -452,6 +512,10 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev,
               !lpc->pm.cpu_hotplug_legacy) {
        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)));
@@ -469,6 +533,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 +3 -0
index bb457bc279..8ab65502ce 100644
@@ -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 "exec/address-spaces.h"
 #include "hw/pci/pci_bus.h"
@@ -88,6 +90,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;
 

hw/acpi/pcihp.c static void acpi_set_pci_info(void) · line 102

Quoted 5 lines
hw/acpi/pcihp.c +1 -1
@@ -96,7 +99,7 @@ static void acpi_set_pci_info(void)
    }
    bsel_is_set = true;
 
-    bus = find_i440fx(); /* TODO: Q35 support */
+    bus = PCI_HOST_BRIDGE(host)->bus;

Isn't this part of a differnet patch?

Quoted 8 lines
hw/acpi/pcihp.c +0 -0
    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 +0 -0
index b7811a8912..8787b6fb33 100644

hw/i386/acpi-build.c static void acpi_get_misc_info(AcpiMiscInfo *info) · line 276

Quoted 8 lines
hw/i386/acpi-build.c +1 -1
@@ -270,7 +270,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;
 

This is also part of the above change, so part of a diffent patch.

Quoted 4 lines
Signature · 1 line
2.25.4
#19 lore raw

Re: [RFC PATCH v3 4/7] hw/acpi/ich9: Enable ACPI PCI hot-plug

Quoted 227 lines · Ani Sinha
Quoted 85 lines · Julia Suvorova

Add 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         | 67 ++++++++++++++++++++++++++++++++++++++++++
hw/acpi/pcihp.c        |  5 +++-
hw/i386/acpi-build.c   |  2 +-
5 files changed, 76 insertions(+), 2 deletions(-)
hw/i386/acpi-build.h +1 -0
index 4c5bfb3d0b..39f143830a 100644
@@ -10,6 +10,7 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;
 #define ACPI_PCIHP_BNMR_BASE 0x10
 
 void acpi_setup(void);
+Object *acpi_get_i386_pci_host(void);
 
 Object *object_resolve_type_unambiguous(const char *typename);
 
include/hw/acpi/ich9.h +3 -0
index 4d19571ed7..833e62fefe 100644
@@ -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 +21 -0
index 6a19070cec..987f23e388 100644
@@ -218,6 +218,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),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 const VMStateDescription vmstate_ich9_pm = {
    .name = "ich9_pm",
    .version_id = 1,
@@ -239,6 +259,7 @@ const VMStateDescription vmstate_ich9_pm = {
        &vmstate_memhp_state,
        &vmstate_tco_io_state,
        &vmstate_cpuhp_state,
+        &vmstate_pcihp_state,
        NULL
    }
 };

hw/acpi/ich9.c static void pm_reset(void *opaque) · line 284

Quoted 4 lines
hw/acpi/ich9.c +1 -0
@@ -260,6 +281,7 @@ static void pm_reset(void *opaque)
    }
    pm->smi_en_wmask = ~0;
 
+    acpi_pcihp_reset(&pm->acpi_pci_hotplug, true);

Maybe add a comment here that acpi based hotplug is disabled both for PCIE.0 and for the bridges.

Quoted 44 lines
hw/acpi/ich9.c +26 -0
    acpi_update_sci(&pm->acpi_regs, pm->irq);
 }
 
@@ -298,6 +320,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;
@@ -369,6 +403,20 @@ static void ich9_pm_set_enable_tco(Object *obj, bool value, Error **errp)
    s->pm.enable_tco = value;
 }
 
+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)
+{
+    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;

hw/acpi/ich9.c void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm) · line 428

Quoted 4 lines
hw/acpi/ich9.c +1 -0
@@ -377,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;

Ditto regarding the comment as above.

Quoted 77 lines
hw/acpi/ich9.c +18 -0
    object_property_add_uint32_ptr(obj, ACPI_PM_PROP_PM_IO_BASE,
                                   &pm->pm_io_base, OBJ_PROP_FLAG_READ);
@@ -400,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,
@@ -407,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,
@@ -432,6 +489,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)));
@@ -452,6 +512,10 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev,
               !lpc->pm.cpu_hotplug_legacy) {
        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)));
@@ -469,6 +533,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 +3 -0
index bb457bc279..8ab65502ce 100644
@@ -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 "exec/address-spaces.h"
 #include "hw/pci/pci_bus.h"
@@ -88,6 +90,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;
 
Quoted 8 lines

hw/acpi/pcihp.c static void acpi_set_pci_info(void) · line 102

Quoted 6 lines
hw/acpi/pcihp.c +1 -1
@@ -96,7 +99,7 @@ static void acpi_set_pci_info(void)
    }
    bsel_is_set = true;
 
-    bus = find_i440fx(); /* TODO: Q35 support */
+    bus = PCI_HOST_BRIDGE(host)->bus;

Isn't this part of a differnet patch?

It was, but since there is no need for a separate function, I merged it into this patch.

Quoted 24 lines
Quoted 8 lines
hw/acpi/pcihp.c +0 -0
    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 +0 -0
index b7811a8912..8787b6fb33 100644

hw/i386/acpi-build.c static void acpi_get_misc_info(AcpiMiscInfo *info) · line 276

Quoted 8 lines
hw/i386/acpi-build.c +1 -1
@@ -270,7 +270,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;
 

This is also part of the above change, so part of a diffent patch.

Quoted 4 lines

--
2.25.4

#20 lore raw

RFC PATCH v3 5/7 bios-tables-test: Allow changes in DSDT ACPI tables

In reply to Julia Suvorova

All DSDT Q35 tables will be modified because ACPI hot-plug is enabled by default.

---
 tests/qtest/bios-tables-test-allowed-diff.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +10 -0
index dfb8523c8b..84f56b14db 100644
@@ -1 +1,11 @@
 /* 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",
Signature · 1 line
2.25.4
Acked-by on v3 5/7
#21 lore raw

Re: [RFC PATCH v3 5/7] bios-tables-test: Allow changes in DSDT ACPI tables

Quoted 5 lines · Julia Suvorova

All DSDT Q35 tables will be modified because ACPI hot-plug is enabled by default.

Quoted 23 lines
---
 tests/qtest/bios-tables-test-allowed-diff.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +10 -1
index dfb8523c8b..84f56b14db 100644
@@ -1 +1,11 @@
 /* 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",
--

2.25.4

#22 lore raw

RFC PATCH v3 6/7 hw/acpi/ich9: Set ACPI PCI hot-plug as default

In reply to Julia Suvorova
---
 hw/acpi/ich9.c | 2 +-
 hw/i386/pc.c   | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
hw/acpi/ich9.c +1 -1
index 987f23e388..c67c20de4e 100644
@@ -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 +1 -0
index b55369357e..5de4475570 100644
@@ -101,6 +101,7 @@ GlobalProperty pc_compat_5_1[] = {};
 const size_t pc_compat_5_1_len = G_N_ELEMENTS(pc_compat_5_1);
 
 GlobalProperty pc_compat_5_0[] = {
+    { "ICH9-LPC", "acpi-pci-hotplug-with-bridge-support", "off" },
 };
 const size_t pc_compat_5_0_len = G_N_ELEMENTS(pc_compat_5_0);
 
Signature · 1 line
2.25.4
#23 lore raw

Re: [RFC PATCH v3 6/7] hw/acpi/ich9: Set ACPI PCI hot-plug as default

Quoted 1 line · On Thu, 24 Sep 2020 09:00:12 +0200 Julia Suvorova <[email protected]> wrote:

I'd drop this patch for now.
mgmt can turn it on for Windows guests to workaround its native hotplug issues.

Quoted 30 lines
---
 hw/acpi/ich9.c | 2 +-
 hw/i386/pc.c   | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
hw/acpi/ich9.c +1 -1
index 987f23e388..c67c20de4e 100644
@@ -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 +1 -0
index b55369357e..5de4475570 100644
@@ -101,6 +101,7 @@ GlobalProperty pc_compat_5_1[] = {};
 const size_t pc_compat_5_1_len = G_N_ELEMENTS(pc_compat_5_1);
 
 GlobalProperty pc_compat_5_0[] = {
+    { "ICH9-LPC", "acpi-pci-hotplug-with-bridge-support", "off" },
 };
 const size_t pc_compat_5_0_len = G_N_ELEMENTS(pc_compat_5_0);
 
#24 lore raw

Re: [RFC PATCH v3 6/7] hw/acpi/ich9: Set ACPI PCI hot-plug as default

Quoted 8 lines · Igor Mammedov
Quoted 1 line · On Thu, 24 Sep 2020 09:00:12 +0200 Julia Suvorova <[email protected]> wrote:

I'd drop this patch for now.
mgmt can turn it on for Windows guests to workaround its native hotplug issues.

It's not just windows either, the hack we have in the hotplug code is an example of a linux issue. I'd rather not let management worry about which type of hotplug is in use. Nothing here sets any policy, this is strictly a mechanism thing.

Quoted 30 lines
Quoted 30 lines
---
 hw/acpi/ich9.c | 2 +-
 hw/i386/pc.c   | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
hw/acpi/ich9.c +1 -1
index 987f23e388..c67c20de4e 100644
@@ -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 +1 -0
index b55369357e..5de4475570 100644
@@ -101,6 +101,7 @@ GlobalProperty pc_compat_5_1[] = {};
 const size_t pc_compat_5_1_len = G_N_ELEMENTS(pc_compat_5_1);
 
 GlobalProperty pc_compat_5_0[] = {
+    { "ICH9-LPC", "acpi-pci-hotplug-with-bridge-support", "off" },
 };
 const size_t pc_compat_5_0_len = G_N_ELEMENTS(pc_compat_5_0);
 
#25 lore raw

Re: [RFC PATCH v3 6/7] hw/acpi/ich9: Set ACPI PCI hot-plug as default

In reply to Julia Suvorova

On Thu, Sep 24, 2020 at 09:00:12AM +0200, Julia Suvorova wrote:

There needs to be a commit message to explain / justify why this change is a benefit. You have a nice list of pros/cons in the cover letter which could serve as a good commit message here.

The cover letter gets discarded, only the commit message is in git history, so its beneficial to capture that info here.

Quoted 35 lines
---
 hw/acpi/ich9.c | 2 +-
 hw/i386/pc.c   | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
hw/acpi/ich9.c +1 -1
index 987f23e388..c67c20de4e 100644
@@ -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 +1 -0
index b55369357e..5de4475570 100644
@@ -101,6 +101,7 @@ GlobalProperty pc_compat_5_1[] = {};
 const size_t pc_compat_5_1_len = G_N_ELEMENTS(pc_compat_5_1);
 
 GlobalProperty pc_compat_5_0[] = {
+    { "ICH9-LPC", "acpi-pci-hotplug-with-bridge-support", "off" },
 };
 const size_t pc_compat_5_0_len = G_N_ELEMENTS(pc_compat_5_0);
 
Signature · 1 line
2.25.4

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#26 lore raw

Re: [RFC PATCH v3 6/7] hw/acpi/ich9: Set ACPI PCI hot-plug as default

Quoted 9 lines · Daniel P. Berrangé

On Thu, Sep 24, 2020 at 09:00:12AM +0200, Julia Suvorova wrote:

There needs to be a commit message to explain / justify why this change is a benefit. You have a nice list of pros/cons in the cover letter which could serve as a good commit message here.

The cover letter gets discarded, only the commit message is in git history, so its beneficial to capture that info here.

Sure, I'll add it.

Quoted 43 lines
Quoted 32 lines
---
 hw/acpi/ich9.c | 2 +-
 hw/i386/pc.c   | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
hw/acpi/ich9.c +1 -1
index 987f23e388..c67c20de4e 100644
@@ -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 +1 -1
index b55369357e..5de4475570 100644
@@ -101,6 +101,7 @@ GlobalProperty pc_compat_5_1[] = {};
 const size_t pc_compat_5_1_len = G_N_ELEMENTS(pc_compat_5_1);
 
 GlobalProperty pc_compat_5_0[] = {
+    { "ICH9-LPC", "acpi-pci-hotplug-with-bridge-support", "off" },
 };
 const size_t pc_compat_5_0_len = G_N_ELEMENTS(pc_compat_5_0);
 
--
Quoted 3 lines

2.25.4

Regards,
Daniel
--

|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#27 lore raw

RFC PATCH v3 7/7 bios-tables-test: Update golden binaries

In reply to Julia Suvorova

Add 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, 0x04)
+        Field (BNMR, DWordAcc, NoLock, WriteAsZeros)
+        {
+            BNUM,   32
+        }
+
+        Mutex (BLCK, 0x00)
+        Method (PCEJ, 2, NotSerialized)
+        {
+            Acquire (BLCK, 0xFFFF)
+            BNUM = Arg0
+            B0EJ = (One << Arg1)
+            Release (BLCK)
+            Return (Zero)

+ }
+ }
+
...

     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
+                    0x14,               // 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 (DVNT, 2, NotSerialized)
+ {
+ If ((Arg0 & One))
+ {
+ Notify (S00, Arg1)
+ }
+
+ If ((Arg0 & 0x02))
+ {
+ Notify (S08, Arg1)
+ }
+
...

---
 tests/qtest/bios-tables-test-allowed-diff.h |  10 ----------
 tests/data/acpi/q35/DSDT                    | Bin 7678 -> 7950 bytes
 tests/data/acpi/q35/DSDT.acpihmat           | Bin 9002 -> 9274 bytes
 tests/data/acpi/q35/DSDT.bridge             | Bin 7695 -> 9865 bytes
 tests/data/acpi/q35/DSDT.cphp               | Bin 8141 -> 8413 bytes
 tests/data/acpi/q35/DSDT.dimmpxm            | Bin 9331 -> 9603 bytes
 tests/data/acpi/q35/DSDT.ipmibt             | Bin 7753 -> 8025 bytes
 tests/data/acpi/q35/DSDT.memhp              | Bin 9037 -> 9309 bytes
 tests/data/acpi/q35/DSDT.mmio64             | Bin 8808 -> 9080 bytes
 tests/data/acpi/q35/DSDT.numamem            | Bin 7684 -> 7956 bytes
 tests/data/acpi/q35/DSDT.tis                | Bin 8283 -> 8555 bytes
 11 files changed, 10 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -10
index 84f56b14db..dfb8523c8b 100644
@@ -1,11 +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 binary +0 -0
index bba8884073a27427b88ac0d733c9c87330a59366..56e5b111f3239ea0af2cfb6dea962e3cd837da80 100644
GIT binary patch
tests/data/acpi/q35/DSDT.acpihmat binary +0 -0
index 9cac92418b5fcc2767dc74603d599642b59623fe..aff5e7d14fdb5b1a332dcc1866d33bff5247a996 100644
GIT binary patch
tests/data/acpi/q35/DSDT.bridge binary +0 -0
index f08b7245f59aad491fcaa60e2bab1085c369ea1c..355c4462bb414efb83f530aa1eb9073dda899379 100644
GIT binary patch
tests/data/acpi/q35/DSDT.cphp binary +0 -0
index 57d859cef9fa16a8f125c4b338611c8472699f38..4d66dc1c564e6b3ff2a5cc1cf9c8447a095ab9a4 100644
GIT binary patch
tests/data/acpi/q35/DSDT.dimmpxm binary +0 -0
index 9d5bd5744e2ba2e0f6126c3aba0bb36af865e499..050533a0353f38cdb4d23fd52898dd4ce1aef9a9 100644
GIT binary patch
tests/data/acpi/q35/DSDT.ipmibt binary +0 -0
index 5cd11de6a8fe47324e5f922823a22746882f19f5..31eeedfb978aaeb469e442ae9748dd62a5285bd2 100644
GIT binary patch
tests/data/acpi/q35/DSDT.memhp binary +0 -0
index 05a7a73ec43130d5c3018bb462fd84981bfb151c..798a12399399ebb163b8231ef54d5e566d8dfc88 100644
GIT binary patch
tests/data/acpi/q35/DSDT.mmio64 binary +0 -0
index efd3f1188f2b55da1514212d4be081a61c2a96e9..61e0515c6007ec2d16db57e8f6052376c6467359 100644
GIT binary patch
tests/data/acpi/q35/DSDT.numamem binary +0 -0
index 1978b55f1255402bf9bade0b91150b5cb49789a4..5ae686dd818d1427dfe4c3e73cc0342cc4e578a7 100644
GIT binary patch
tests/data/acpi/q35/DSDT.tis binary +0 -0
index 638de3872673d17b1958497d0e62c83653de1602..dd712090ee9c09ed98f3b658951ac8a62b31a7d4 100644
GIT binary patch
Signature · 1 line
2.25.4
#28 lore raw
In reply to Julia Suvorova
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#! /bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-mingw@fedora J=14 NETWORK=1
=== TEST SCRIPT END ===

Host machine cpu: x86_64
Target machine cpu family: x86
Target machine cpu: x86_64
../src/meson.build:10: WARNING: Module unstable-keyval has no backwards or forwards compatibility and might not exist in future releases. Program sh found: YES
Program python3 found: YES (/usr/bin/python3)
Configuring ninjatool using configuration
---
The manual pages are in docs.
/usr/lib/gcc/x86_64-w64-mingw32/9.2.1/../../../../x86_64-w64-mingw32/bin/ld: libcommon.fa.p/hw_pci_pcie.c.obj: in function `acpi_pcihp_enabled':
/tmp/qemu-test/build/../src/hw/pci/pcie.c:522: undefined reference to `object_resolve_type_unambiguous'
collect2: error: ld returned 1 exit status
make: *** [Makefile.ninja:1878: qemu-system-aarch64w.exe] Error 1
make: *** Waiting for unfinished jobs....
/usr/lib/gcc/x86_64-w64-mingw32/9.2.1/../../../../x86_64-w64-mingw32/bin/ld: libcommon.fa.p/hw_pci_pcie.c.obj: in function `acpi_pcihp_enabled':
/tmp/qemu-test/build/../src/hw/pci/pcie.c:522: undefined reference to `object_resolve_type_unambiguous'
collect2: error: ld returned 1 exit status
make: *** [Makefile.ninja:1876: qemu-system-aarch64.exe] Error 1
Traceback (most recent call last):
File "./tests/docker/docker.py", line 709, in <module>

    sys.exit(main())

---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--rm', '--label', 'com.qemu.instance.uuid=342bc147a50847f886da9b01c0ca5ec9', '-u', '1003', '--security-opt', 'seccomp=unconfined', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-vmsaoknh/src/docker-src.2020-09-24-04.53.10.30016:/var/tmp/qemu:z,ro', 'qemu/fedora', '/var/tmp/qemu/run', 'test-mingw']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=342bc147a50847f886da9b01c0ca5ec9
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-vmsaoknh/src'
make: *** [docker-run-test-mingw@fedora] Error 2

real 4m42.837s
user 0m18.829s

The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#29 lore raw
In reply to Julia Suvorova
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===

C linker for the host machine: cc ld.bfd 2.27-43
Host machine cpu family: x86_64
Host machine cpu: x86_64
../src/meson.build:10: WARNING: Module unstable-keyval has no backwards or forwards compatibility and might not exist in future releases.
Program sh found: YES
Program python3 found: YES (/usr/bin/python3)
Configuring ninjatool using configuration
---
Linking target tests/test-replication
libcommon.fa.p/hw_pci_pcie.c.o: In function `acpi_pcihp_enabled':
/tmp/qemu-test/build/../src/hw/pci/pcie.c:522: undefined reference to `object_resolve_type_unambiguous'
collect2: error: ld returned 1 exit status
make: *** [qemu-system-aarch64] Error 1
make: *** Waiting for unfinished jobs....
Traceback (most recent call last):
File "./tests/docker/docker.py", line 709, in <module>
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--rm', '--label', 'com.qemu.instance.uuid=38644690a9934226b7e7108ea4390530', '-u', '1003', '--security-opt', 'seccomp=unconfined', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-2jqqex0j/src/docker-src.2020-09-24-04.59.06.4662:/var/tmp/qemu:z,ro', 'qemu/centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=38644690a9934226b7e7108ea4390530
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-2jqqex0j/src'
make: *** [docker-run-test-quick@centos7] Error 2

real 4m43.237s
user 0m20.603s

The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#30 lore raw
In reply to Julia Suvorova
Quoted 32 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 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:
* https://bugzilla.redhat.com/show_bug.cgi?id=1752465
* https://bugzilla.redhat.com/show_bug.cgi?id=1690256

Quoted 4 lines

Cons:
* lose per-port control over hot-plug (can be resolved)
* no access to possible features presented in slot capabilities (this is only surprise removal AFAIK)

something I don't quite get is whether with this one can still add new pcie bridges and then hotplug into these with native hotplug.

the challenge to answering this with certainty is that right now qemu does not allow hotplugging complex devices such as bridges at all,
we only have a hack for multifunction devices.
Maybe adding a bridge as function 1 on command line, then hotplugging another device as function 0 will work to test this.

Quoted 44 lines

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/pci/pcie: Do not initialize slot capability if acpihp is used hw/acpi/ich9: Enable ACPI PCI hot-plug
bios-tables-test: Allow changes in DSDT ACPI tables hw/acpi/ich9: Set ACPI PCI hot-plug as default
bios-tables-test: Update golden binaries

 hw/i386/acpi-build.h              |   7 ++++
 include/hw/acpi/ich9.h            |   5 +++
 include/hw/acpi/pcihp.h           |   3 +-
 hw/acpi/ich9.c                    |  67 ++++++++++++++++++++++++++++++
 hw/acpi/pcihp.c                   |  16 ++++---
 hw/acpi/piix4.c                   |   4 +-
 hw/i386/acpi-build.c              |  31 ++++++++------
 hw/i386/pc.c                      |   1 +
 hw/pci/pcie.c                     |  16 +++++++
 tests/data/acpi/q35/DSDT          | Bin 7678 -> 7950 bytes
 tests/data/acpi/q35/DSDT.acpihmat | Bin 9002 -> 9274 bytes
 tests/data/acpi/q35/DSDT.bridge   | Bin 7695 -> 9865 bytes
 tests/data/acpi/q35/DSDT.cphp     | Bin 8141 -> 8413 bytes
 tests/data/acpi/q35/DSDT.dimmpxm  | Bin 9331 -> 9603 bytes
 tests/data/acpi/q35/DSDT.ipmibt   | Bin 7753 -> 8025 bytes
 tests/data/acpi/q35/DSDT.memhp    | Bin 9037 -> 9309 bytes
 tests/data/acpi/q35/DSDT.mmio64   | Bin 8808 -> 9080 bytes
 tests/data/acpi/q35/DSDT.numamem  | Bin 7684 -> 7956 bytes
 tests/data/acpi/q35/DSDT.tis      | Bin 8283 -> 8555 bytes
 19 files changed, 129 insertions(+), 21 deletions(-)
Signature · 1 line
2.25.4
#31 lore raw
Quoted 34 lines · Michael S. Tsirkin
Quoted 32 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 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:
* https://bugzilla.redhat.com/show_bug.cgi?id=1752465
* https://bugzilla.redhat.com/show_bug.cgi?id=1690256

Quoted 8 lines
Quoted 4 lines

Cons:
* lose per-port control over hot-plug (can be resolved)
* no access to possible features presented in slot capabilities (this is only surprise removal AFAIK)

something I don't quite get is whether with this one can still add new pcie bridges and then hotplug into these with native hotplug.

Right now I disable native if there is acpihp anywhere, but even if you enable it for hotplugged devices, native hot-plug will not work.

Quoted 53 lines

the challenge to answering this with certainty is that right now qemu does not allow hotplugging complex devices such as bridges at all,
we only have a hack for multifunction devices.
Maybe adding a bridge as function 1 on command line, then hotplugging another device as function 0 will work to test this.

Quoted 44 lines

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/pci/pcie: Do not initialize slot capability if acpihp is used hw/acpi/ich9: Enable ACPI PCI hot-plug
bios-tables-test: Allow changes in DSDT ACPI tables hw/acpi/ich9: Set ACPI PCI hot-plug as default
bios-tables-test: Update golden binaries

 hw/i386/acpi-build.h              |   7 ++++
 include/hw/acpi/ich9.h            |   5 +++
 include/hw/acpi/pcihp.h           |   3 +-
 hw/acpi/ich9.c                    |  67 ++++++++++++++++++++++++++++++
 hw/acpi/pcihp.c                   |  16 ++++---
 hw/acpi/piix4.c                   |   4 +-
 hw/i386/acpi-build.c              |  31 ++++++++------
 hw/i386/pc.c                      |   1 +
 hw/pci/pcie.c                     |  16 +++++++
 tests/data/acpi/q35/DSDT          | Bin 7678 -> 7950 bytes
 tests/data/acpi/q35/DSDT.acpihmat | Bin 9002 -> 9274 bytes
 tests/data/acpi/q35/DSDT.bridge   | Bin 7695 -> 9865 bytes
 tests/data/acpi/q35/DSDT.cphp     | Bin 8141 -> 8413 bytes
 tests/data/acpi/q35/DSDT.dimmpxm  | Bin 9331 -> 9603 bytes
 tests/data/acpi/q35/DSDT.ipmibt   | Bin 7753 -> 8025 bytes
 tests/data/acpi/q35/DSDT.memhp    | Bin 9037 -> 9309 bytes
 tests/data/acpi/q35/DSDT.mmio64   | Bin 8808 -> 9080 bytes
 tests/data/acpi/q35/DSDT.numamem  | Bin 7684 -> 7956 bytes
 tests/data/acpi/q35/DSDT.tis      | Bin 8283 -> 8555 bytes
 19 files changed, 129 insertions(+), 21 deletions(-)

--
2.25.4

#32 lore raw
Quoted 40 lines · Julia Suvorova
Quoted 39 lines · Michael S. Tsirkin
Quoted 36 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 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:
* https://bugzilla.redhat.com/show_bug.cgi?id=1752465
* https://bugzilla.redhat.com/show_bug.cgi?id=1690256

Cons:
* lose per-port control over hot-plug (can be resolved)
* no access to possible features presented in slot capabilities (this is only surprise removal AFAIK)

Quoted 6 lines
Quoted 3 lines

something I don't quite get is whether with this one can still add new pcie bridges and then hotplug into these with native hotplug.

Right now I disable native if there is acpihp anywhere, but even if you enable it for hotplugged devices, native hot-plug will not work.

So that's a minor regression in functionality, right? Why is that the case? Because you disable it in ACPI? What if we don't?

Quoted 53 lines
Quoted 53 lines

the challenge to answering this with certainty is that right now qemu does not allow hotplugging complex devices such as bridges at all,
we only have a hack for multifunction devices.
Maybe adding a bridge as function 1 on command line, then hotplugging another device as function 0 will work to test this.

Quoted 44 lines

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/pci/pcie: Do not initialize slot capability if acpihp is used hw/acpi/ich9: Enable ACPI PCI hot-plug
bios-tables-test: Allow changes in DSDT ACPI tables hw/acpi/ich9: Set ACPI PCI hot-plug as default
bios-tables-test: Update golden binaries

 hw/i386/acpi-build.h              |   7 ++++
 include/hw/acpi/ich9.h            |   5 +++
 include/hw/acpi/pcihp.h           |   3 +-
 hw/acpi/ich9.c                    |  67 ++++++++++++++++++++++++++++++
 hw/acpi/pcihp.c                   |  16 ++++---
 hw/acpi/piix4.c                   |   4 +-
 hw/i386/acpi-build.c              |  31 ++++++++------
 hw/i386/pc.c                      |   1 +
 hw/pci/pcie.c                     |  16 +++++++
 tests/data/acpi/q35/DSDT          | Bin 7678 -> 7950 bytes
 tests/data/acpi/q35/DSDT.acpihmat | Bin 9002 -> 9274 bytes
 tests/data/acpi/q35/DSDT.bridge   | Bin 7695 -> 9865 bytes
 tests/data/acpi/q35/DSDT.cphp     | Bin 8141 -> 8413 bytes
 tests/data/acpi/q35/DSDT.dimmpxm  | Bin 9331 -> 9603 bytes
 tests/data/acpi/q35/DSDT.ipmibt   | Bin 7753 -> 8025 bytes
 tests/data/acpi/q35/DSDT.memhp    | Bin 9037 -> 9309 bytes
 tests/data/acpi/q35/DSDT.mmio64   | Bin 8808 -> 9080 bytes
 tests/data/acpi/q35/DSDT.numamem  | Bin 7684 -> 7956 bytes
 tests/data/acpi/q35/DSDT.tis      | Bin 8283 -> 8555 bytes
 19 files changed, 129 insertions(+), 21 deletions(-)

--
2.25.4

#33 lore raw
Quoted 51 lines · On Thu, Oct 1, 2020 at 17:10 Michael S. Tsirkin <[email protected]> wrote:
Quoted 1 line · Julia Suvorova

On Thu, Sep 24, 2020 at 11:20 AM Michael S. Tsirkin <[email protected]>

Quoted 6 lines · wrote:
Quoted 6 lines · Julia Suvorova
Quoted 4 lines

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

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

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,

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

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

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

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

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

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

Quoted 14 lines
Quoted 13 lines
Quoted 9 lines

indicator states, which is racy and uppredictable.
* fixes:
* https://bugzilla.redhat.com/show_bug.cgi?id=1752465
* https://bugzilla.redhat.com/show_bug.cgi?id=1690256

Cons:
* lose per-port control over hot-plug (can be resolved)
* no access to possible features presented in slot capabilities (this is only surprise removal AFAIK)

something I don't quite get is whether with this one can still add new pcie bridges and then hotplug into these with native hotplug.

Quoted 6 lines
Quoted 2 lines

Right now I disable native if there is acpihp anywhere, but even if you enable it for hotplugged devices, native hot-plug will not work.

So that's a minor regression in functionality, right? Why is that the case? Because you disable it in ACPI? What if we don't?

Stupid question. If both native and acpi is enabled which one does OS chose? Does this choice vary between OSes and different flavours of the same OS like Windows?

Quoted 58 lines
Quoted 5 lines
Quoted 5 lines

the challenge to answering this with certainty is that right now qemu does not allow hotplugging complex devices such as bridges at all, we only have a hack for multifunction devices.
Maybe adding a bridge as function 1 on command line, then hotplugging

another device as

Quoted 25 lines
Quoted 25 lines

function 0 will work to test this.

Quoted 21 lines

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/pci/pcie: Do not initialize slot capability if acpihp is used hw/acpi/ich9: Enable ACPI PCI hot-plug
bios-tables-test: Allow changes in DSDT ACPI tables hw/acpi/ich9: Set ACPI PCI hot-plug as default
bios-tables-test: Update golden binaries

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
 hw/i386/acpi-build.h              |   7 ++++
 include/hw/acpi/ich9.h            |   5 +++
 include/hw/acpi/pcihp.h           |   3 +-
 hw/acpi/ich9.c                    |  67

++++++++++++++++++++++++++++++

Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
 hw/acpi/pcihp.c                   |  16 ++++---
 hw/acpi/piix4.c                   |   4 +-
 hw/i386/acpi-build.c              |  31 ++++++++------
 hw/i386/pc.c                      |   1 +
 hw/pci/pcie.c                     |  16 +++++++
 tests/data/acpi/q35/DSDT          | Bin 7678 -> 7950 bytes
 tests/data/acpi/q35/DSDT.acpihmat | Bin 9002 -> 9274 bytes
 tests/data/acpi/q35/DSDT.bridge   | Bin 7695 -> 9865 bytes
 tests/data/acpi/q35/DSDT.cphp     | Bin 8141 -> 8413 bytes
 tests/data/acpi/q35/DSDT.dimmpxm  | Bin 9331 -> 9603 bytes
 tests/data/acpi/q35/DSDT.ipmibt   | Bin 7753 -> 8025 bytes
 tests/data/acpi/q35/DSDT.memhp    | Bin 9037 -> 9309 bytes
 tests/data/acpi/q35/DSDT.mmio64   | Bin 8808 -> 9080 bytes
 tests/data/acpi/q35/DSDT.numamem  | Bin 7684 -> 7956 bytes
 tests/data/acpi/q35/DSDT.tis      | Bin 8283 -> 8555 bytes
 19 files changed, 129 insertions(+), 21 deletions(-)

--
2.25.4

#34 lore raw
Quoted 53 lines · Ani Sinha
Quoted 49 lines · On Thu, Oct 1, 2020 at 17:10 Michael S. Tsirkin <[email protected]> wrote:
Quoted 46 lines · Julia Suvorova
Quoted 34 lines · Michael S. Tsirkin
Quoted 32 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 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:
* https://bugzilla.redhat.com/show_bug.cgi?id=1752465
* https://bugzilla.redhat.com/show_bug.cgi?id=1690256

Quoted 8 lines
Quoted 4 lines

Cons:
* lose per-port control over hot-plug (can be resolved)
* no access to possible features presented in slot capabilities (this is only surprise removal AFAIK)

something I don't quite get is whether with this one can still add new pcie bridges and then hotplug into these with native hotplug.

Right now I disable native if there is acpihp anywhere, but even if you enable it for hotplugged devices, native hot-plug will not work.

Quoted 6 lines
Quoted 3 lines

So that's a minor regression in functionality, right? Why is that the case? Because you disable it in ACPI? What if we don't?

Stupid question. If both native and acpi is enabled which one does OS chose? Does this choice vary between OSes and different flavours of the same OS like Windows?

It will always choose native.

Quoted 56 lines
Quoted 56 lines
Quoted 55 lines
Quoted 55 lines

the challenge to answering this with certainty is that right now qemu does not allow hotplugging complex devices such as bridges at all,
we only have a hack for multifunction devices.
Maybe adding a bridge as function 1 on command line, then hotplugging another device as function 0 will work to test this.

Quoted 44 lines

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/pci/pcie: Do not initialize slot capability if acpihp is used hw/acpi/ich9: Enable ACPI PCI hot-plug
bios-tables-test: Allow changes in DSDT ACPI tables hw/acpi/ich9: Set ACPI PCI hot-plug as default
bios-tables-test: Update golden binaries

 hw/i386/acpi-build.h              |   7 ++++
 include/hw/acpi/ich9.h            |   5 +++
 include/hw/acpi/pcihp.h           |   3 +-
 hw/acpi/ich9.c                    |  67 ++++++++++++++++++++++++++++++
 hw/acpi/pcihp.c                   |  16 ++++---
 hw/acpi/piix4.c                   |   4 +-
 hw/i386/acpi-build.c              |  31 ++++++++------
 hw/i386/pc.c                      |   1 +
 hw/pci/pcie.c                     |  16 +++++++
 tests/data/acpi/q35/DSDT          | Bin 7678 -> 7950 bytes
 tests/data/acpi/q35/DSDT.acpihmat | Bin 9002 -> 9274 bytes
 tests/data/acpi/q35/DSDT.bridge   | Bin 7695 -> 9865 bytes
 tests/data/acpi/q35/DSDT.cphp     | Bin 8141 -> 8413 bytes
 tests/data/acpi/q35/DSDT.dimmpxm  | Bin 9331 -> 9603 bytes
 tests/data/acpi/q35/DSDT.ipmibt   | Bin 7753 -> 8025 bytes
 tests/data/acpi/q35/DSDT.memhp    | Bin 9037 -> 9309 bytes
 tests/data/acpi/q35/DSDT.mmio64   | Bin 8808 -> 9080 bytes
 tests/data/acpi/q35/DSDT.numamem  | Bin 7684 -> 7956 bytes
 tests/data/acpi/q35/DSDT.tis      | Bin 8283 -> 8555 bytes
 19 files changed, 129 insertions(+), 21 deletions(-)

--
2.25.4

#35 lore raw
In reply to Michael S. Tsirkin
Quoted 46 lines · Michael S. Tsirkin
Quoted 44 lines · Julia Suvorova
Quoted 42 lines · Michael S. Tsirkin
Quoted 32 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 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:
* https://bugzilla.redhat.com/show_bug.cgi?id=1752465
* https://bugzilla.redhat.com/show_bug.cgi?id=1690256

Quoted 4 lines

Cons:
* lose per-port control over hot-plug (can be resolved)
* no access to possible features presented in slot capabilities (this is only surprise removal AFAIK)

something I don't quite get is whether with this one can still add new pcie bridges and then hotplug into these with native hotplug.

Quoted 6 lines
Quoted 2 lines

Right now I disable native if there is acpihp anywhere, but even if you enable it for hotplugged devices, native hot-plug will not work.

So that's a minor regression in functionality, right? Why is that the case? Because you disable it in ACPI? What if we don't?

I meant that I disable slot hotplug capabilities, nothing in ACPI prevents native from working. Actually, I don't see if there's any regression at all. Configurations like hot-plugging downstream port or switch to another downstream port haven't worked before, and they don't work now. I can enable native for hotplugged bridges, but that doesn't make sense, because you won't be able to hot-plug anything to it. It's not an issue of ACPI, it's PCIe behaviour. Also, native-acpi combination may seem bizarre to os (slot enumeration is independent, that's why I suggested disabling pcie slot flags).

Quoted 54 lines
Quoted 53 lines
Quoted 53 lines

the challenge to answering this with certainty is that right now qemu does not allow hotplugging complex devices such as bridges at all,
we only have a hack for multifunction devices.
Maybe adding a bridge as function 1 on command line, then hotplugging another device as function 0 will work to test this.

Quoted 44 lines

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/pci/pcie: Do not initialize slot capability if acpihp is used hw/acpi/ich9: Enable ACPI PCI hot-plug
bios-tables-test: Allow changes in DSDT ACPI tables hw/acpi/ich9: Set ACPI PCI hot-plug as default
bios-tables-test: Update golden binaries

 hw/i386/acpi-build.h              |   7 ++++
 include/hw/acpi/ich9.h            |   5 +++
 include/hw/acpi/pcihp.h           |   3 +-
 hw/acpi/ich9.c                    |  67 ++++++++++++++++++++++++++++++
 hw/acpi/pcihp.c                   |  16 ++++---
 hw/acpi/piix4.c                   |   4 +-
 hw/i386/acpi-build.c              |  31 ++++++++------
 hw/i386/pc.c                      |   1 +
 hw/pci/pcie.c                     |  16 +++++++
 tests/data/acpi/q35/DSDT          | Bin 7678 -> 7950 bytes
 tests/data/acpi/q35/DSDT.acpihmat | Bin 9002 -> 9274 bytes
 tests/data/acpi/q35/DSDT.bridge   | Bin 7695 -> 9865 bytes
 tests/data/acpi/q35/DSDT.cphp     | Bin 8141 -> 8413 bytes
 tests/data/acpi/q35/DSDT.dimmpxm  | Bin 9331 -> 9603 bytes
 tests/data/acpi/q35/DSDT.ipmibt   | Bin 7753 -> 8025 bytes
 tests/data/acpi/q35/DSDT.memhp    | Bin 9037 -> 9309 bytes
 tests/data/acpi/q35/DSDT.mmio64   | Bin 8808 -> 9080 bytes
 tests/data/acpi/q35/DSDT.numamem  | Bin 7684 -> 7956 bytes
 tests/data/acpi/q35/DSDT.tis      | Bin 8283 -> 8555 bytes
 19 files changed, 129 insertions(+), 21 deletions(-)

--
2.25.4

#36 lore raw
Quoted 125 lines · Julia Suvorova
Quoted 5 lines · Michael S. Tsirkin
Quoted 1 line · Julia Suvorova

On Thu, Sep 24, 2020 at 11:20 AM Michael S. Tsirkin <[email protected]>

Quoted 11 lines · wrote:
Quoted 11 lines
Quoted 11 lines · Julia Suvorova
Quoted 8 lines

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

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

This way maintainers can decide which way to choose without

breaking

Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

the patch set.

With the feature disabled Q35 falls back to the native hot-plug.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

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

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

removed manually. As there is no power down state exists in

QEMU,

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

we cannot distinguish between an eject and a power down

request.

* no delay during deleting - after the actual power off

software

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

must wait at least 1 second before indicating about it. This

case

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

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,

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the attention button has a 5-second waiting period, during

which

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

the operation can be canceled with a second press. While this

looks fine for manual button control, automation will result

in

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

the need to queue or drop events, and the software receiving

events in all sort of unspecified combinations of

attention/power

Quoted 34 lines
Quoted 24 lines
Quoted 23 lines
Quoted 10 lines

indicator states, which is racy and uppredictable.

* fixes:

* https://bugzilla.redhat.com/show_bug.cgi?id=1752465

* https://bugzilla.redhat.com/show_bug.cgi?id=1690256

Quoted 7 lines

Cons:

* lose per-port control over hot-plug (can be resolved)

* no access to possible features presented in slot capabilities

(this is only surprise removal AFAIK)

something I don't quite get is whether with this one can still add

new pcie bridges and then hotplug into these with native

Quoted 7 lines
Quoted 1 line

hotplug.

Right now I disable native if there is acpihp anywhere, but even if

you enable it for hotplugged devices, native hot-plug will not work.

Quoted 5 lines

So that's a minor regression in functionality, right?

Why is that the case? Because you disable it in ACPI?

What if we don't?

I meant that I disable slot hotplug capabilities, nothing in ACPI

prevents native from working. Actually, I don't see if there's any

regression at all. Configurations like hot-plugging downstream port or

Quoted 7 lines

switch to another downstream port haven't worked before, and they

don't work now. I can enable native for hotplugged bridges, but that

doesn't make sense, because you won't be able to hot-plug anything to

it.

Why is that?

It's not an issue of ACPI, it's PCIe behaviour. Also, native-acpi

Quoted 121 lines

combination may seem bizarre to os (slot enumeration is independent,

that's why I suggested disabling pcie slot flags).

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

the challenge to answering this with certainty is that right now qemu

does not allow hotplugging complex devices such as bridges at all,

we only have a hack for multifunction devices.

Maybe adding a bridge as function 1 on command line, then

hotplugging another device as

Quoted 28 lines
Quoted 27 lines
Quoted 27 lines

function 0 will work to test this.

Quoted 19 lines

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]

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

* drop build_q35_pci_hotplug() wrapper [Igor]

Julia Suvorova (7):

hw/acpi/pcihp: Enhance acpi_pcihp_disable_root_bus() to support

Q35

Quoted 14 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

hw/i386/acpi-build: Add ACPI PCI hot-plug methods to Q35

hw/pci/pcie: Do not initialize slot capability if acpihp is used

hw/acpi/ich9: Enable ACPI PCI hot-plug

bios-tables-test: Allow changes in DSDT ACPI tables

hw/acpi/ich9: Set ACPI PCI hot-plug as default

bios-tables-test: Update golden binaries

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
 hw/i386/acpi-build.h              |   7 ++++
 include/hw/acpi/ich9.h            |   5 +++
 include/hw/acpi/pcihp.h           |   3 +-
 hw/acpi/ich9.c                    |  67

++++++++++++++++++++++++++++++

Quoted 41 lines
Quoted 39 lines
Quoted 39 lines
Quoted 37 lines
 hw/acpi/pcihp.c                   |  16 ++++---
 hw/acpi/piix4.c                   |   4 +-
 hw/i386/acpi-build.c              |  31 ++++++++------
 hw/i386/pc.c                      |   1 +
 hw/pci/pcie.c                     |  16 +++++++
 tests/data/acpi/q35/DSDT          | Bin 7678 -> 7950 bytes
 tests/data/acpi/q35/DSDT.acpihmat | Bin 9002 -> 9274 bytes
 tests/data/acpi/q35/DSDT.bridge   | Bin 7695 -> 9865 bytes
 tests/data/acpi/q35/DSDT.cphp     | Bin 8141 -> 8413 bytes
 tests/data/acpi/q35/DSDT.dimmpxm  | Bin 9331 -> 9603 bytes
 tests/data/acpi/q35/DSDT.ipmibt   | Bin 7753 -> 8025 bytes
 tests/data/acpi/q35/DSDT.memhp    | Bin 9037 -> 9309 bytes
 tests/data/acpi/q35/DSDT.mmio64   | Bin 8808 -> 9080 bytes
 tests/data/acpi/q35/DSDT.numamem  | Bin 7684 -> 7956 bytes
 tests/data/acpi/q35/DSDT.tis      | Bin 8283 -> 8555 bytes
 19 files changed, 129 insertions(+), 21 deletions(-)

--

2.25.4

#37 lore raw
In reply to Julia Suvorova
Quoted 7 lines · Julia Suvorova
Quoted 6 lines
Quoted 2 lines

Right now I disable native if there is acpihp anywhere, but even if you enable it for hotplugged devices, native hot-plug will not work.

So that's a minor regression in functionality, right? Why is that the case? Because you disable it in ACPI? What if we don't?

Quoted 7 lines

I meant that I disable slot hotplug capabilities, nothing in ACPI prevents native from working. Actually, I don't see if there's any regression at all. Configurations like hot-plugging downstream port or switch to another downstream port haven't worked before, and they don't work now. I can enable native for hotplugged bridges, but that doesn't make sense, because you won't be able to hot-plug anything to it.

You can do the following hack right now:
1- add an upstream port as function 1
2- add a downstream port behind it
3- add some other device (e.g. another upstream port?) as function 0

As this point both ports should be detected.

Going forward we can consider support for adding ports in a hidden state (not visible to guest) so one won't need an extra function.

Quoted 2 lines

It's not an issue of ACPI, it's PCIe behaviour. Also, native-acpi combination may seem bizarre to os

Maybe, maybe not ...
Worth testing whether this works with existing guests.

Quoted 2 lines

(slot enumeration is independent,
that's why I suggested disabling pcie slot flags).

Yes that part makes sense imho.

Signature · 1 line
MST
#38 lore raw
In reply to Julia Suvorova
Quoted 10 lines · On Thu, 24 Sep 2020 09:00:06 +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 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.

Quoted 7 lines

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.

if I recall right, you had a idea about
keeping pending removal request to distinguish between eject and poweroff (i.e. eject if mgmt asked for removal and otherwise it could be poweroff|nop) Why it didn't work out in the end?

Quoted 62 lines

* 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:
* https://bugzilla.redhat.com/show_bug.cgi?id=1752465
* https://bugzilla.redhat.com/show_bug.cgi?id=1690256

Cons:
* lose per-port control over hot-plug (can be resolved)
* no access to possible features presented in slot capabilities (this is only surprise removal AFAIK)

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/pci/pcie: Do not initialize slot capability if acpihp is used hw/acpi/ich9: Enable ACPI PCI hot-plug
bios-tables-test: Allow changes in DSDT ACPI tables hw/acpi/ich9: Set ACPI PCI hot-plug as default
bios-tables-test: Update golden binaries

 hw/i386/acpi-build.h              |   7 ++++
 include/hw/acpi/ich9.h            |   5 +++
 include/hw/acpi/pcihp.h           |   3 +-
 hw/acpi/ich9.c                    |  67 ++++++++++++++++++++++++++++++
 hw/acpi/pcihp.c                   |  16 ++++---
 hw/acpi/piix4.c                   |   4 +-
 hw/i386/acpi-build.c              |  31 ++++++++------
 hw/i386/pc.c                      |   1 +
 hw/pci/pcie.c                     |  16 +++++++
 tests/data/acpi/q35/DSDT          | Bin 7678 -> 7950 bytes
 tests/data/acpi/q35/DSDT.acpihmat | Bin 9002 -> 9274 bytes
 tests/data/acpi/q35/DSDT.bridge   | Bin 7695 -> 9865 bytes
 tests/data/acpi/q35/DSDT.cphp     | Bin 8141 -> 8413 bytes
 tests/data/acpi/q35/DSDT.dimmpxm  | Bin 9331 -> 9603 bytes
 tests/data/acpi/q35/DSDT.ipmibt   | Bin 7753 -> 8025 bytes
 tests/data/acpi/q35/DSDT.memhp    | Bin 9037 -> 9309 bytes
 tests/data/acpi/q35/DSDT.mmio64   | Bin 8808 -> 9080 bytes
 tests/data/acpi/q35/DSDT.numamem  | Bin 7684 -> 7956 bytes
 tests/data/acpi/q35/DSDT.tis      | Bin 8283 -> 8555 bytes
 19 files changed, 129 insertions(+), 21 deletions(-)
#39 lore raw
Quoted 21 lines · Igor Mammedov
Quoted 10 lines · On Thu, 24 Sep 2020 09:00:06 +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 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.

Quoted 7 lines

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.

Quoted 4 lines

if I recall right, you had a idea about
keeping pending removal request to distinguish between eject and poweroff (i.e. eject if mgmt asked for removal and otherwise it could be poweroff|nop) Why it didn't work out in the end?

For better or worse guests expect to eject and have it happen, without also asking management to do it ...

Quoted 62 lines
Quoted 62 lines

* 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:
* https://bugzilla.redhat.com/show_bug.cgi?id=1752465
* https://bugzilla.redhat.com/show_bug.cgi?id=1690256

Cons:
* lose per-port control over hot-plug (can be resolved)
* no access to possible features presented in slot capabilities (this is only surprise removal AFAIK)

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/pci/pcie: Do not initialize slot capability if acpihp is used hw/acpi/ich9: Enable ACPI PCI hot-plug
bios-tables-test: Allow changes in DSDT ACPI tables hw/acpi/ich9: Set ACPI PCI hot-plug as default
bios-tables-test: Update golden binaries

 hw/i386/acpi-build.h              |   7 ++++
 include/hw/acpi/ich9.h            |   5 +++
 include/hw/acpi/pcihp.h           |   3 +-
 hw/acpi/ich9.c                    |  67 ++++++++++++++++++++++++++++++
 hw/acpi/pcihp.c                   |  16 ++++---
 hw/acpi/piix4.c                   |   4 +-
 hw/i386/acpi-build.c              |  31 ++++++++------
 hw/i386/pc.c                      |   1 +
 hw/pci/pcie.c                     |  16 +++++++
 tests/data/acpi/q35/DSDT          | Bin 7678 -> 7950 bytes
 tests/data/acpi/q35/DSDT.acpihmat | Bin 9002 -> 9274 bytes
 tests/data/acpi/q35/DSDT.bridge   | Bin 7695 -> 9865 bytes
 tests/data/acpi/q35/DSDT.cphp     | Bin 8141 -> 8413 bytes
 tests/data/acpi/q35/DSDT.dimmpxm  | Bin 9331 -> 9603 bytes
 tests/data/acpi/q35/DSDT.ipmibt   | Bin 7753 -> 8025 bytes
 tests/data/acpi/q35/DSDT.memhp    | Bin 9037 -> 9309 bytes
 tests/data/acpi/q35/DSDT.mmio64   | Bin 8808 -> 9080 bytes
 tests/data/acpi/q35/DSDT.numamem  | Bin 7684 -> 7956 bytes
 tests/data/acpi/q35/DSDT.tis      | Bin 8283 -> 8555 bytes
 19 files changed, 129 insertions(+), 21 deletions(-)