Skip to contentSkip to conversation

Add a new PIIX option to control PCI hot unplugging of devices on non-root buses

PATCH In review Ani Sinha 6 participants 52 messages Apr 28, 2020 – May 26, 2020

lore
Share & tools
lore
author
#1 lore raw
In reply to Ani Sinha

+julie
+ laine

Rebased patch to latest Qemu master. Only minimal changes.

Quoted 134 lines · Ani Sinha

A new option "use_acpi_unplug" is introduced for PIIX which will selectively only disable hot unplugging of both hot plugged and cold plugged PCI devices on non-root PCI buses. This will prevent hot unplugging of devices from Windows based guests from system tray but will not prevent devices from being hot plugged into the guest.

It has been tested on Windows guests.

---
hw/acpi/piix4.c | 3 +++
hw/i386/acpi-build.c | 40 ++++++++++++++++++++++++++--------------

2 files changed, 29 insertions(+), 14 deletions(-)
hw/acpi/piix4.c +3 -0
index 964d6f5..59fa707 100644
@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {
 
    AcpiPciHpState acpi_pci_hotplug;
    bool use_acpi_pci_hotplug;
+    bool use_acpi_unplug;
 
    uint8_t disable_s3;
    uint8_t disable_s4;
@@ -633,6 +634,8 @@ static Property piix4_pm_properties[] = {
    DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
    DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState,
                     use_acpi_pci_hotplug, true),
+    DEFINE_PROP_BOOL("acpi-pci-hotunplug-enable-bridge", PIIX4PMState,
+                     use_acpi_unplug, true),
    DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
                     acpi_memory_hotplug.is_enabled, true),
    DEFINE_PROP_END_OF_LIST(),
hw/i386/acpi-build.c +26 -14
index 23c77ee..71b3ac3 100644
@@ -96,6 +96,7 @@ typedef struct AcpiPmInfo {
    bool s3_disabled;
    bool s4_disabled;
    bool pcihp_bridge_en;
+    bool pcihup_bridge_en;
    uint8_t s4_val;
    AcpiFadtData fadt;
    uint16_t cpu_hp_io_base;
@@ -240,6 +241,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
    pm->pcihp_bridge_en =
        object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support",
                                 NULL);
+    pm->pcihup_bridge_en =
+        object_property_get_bool(obj, "acpi-pci-hotunplug-enable-bridge",
+                                 NULL);
 }
 
 static void acpi_get_misc_info(AcpiMiscInfo *info)
@@ -451,7 +455,8 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)
 }
 
 static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
-                                         bool pcihp_bridge_en)
+                                         bool pcihp_bridge_en,
+                                         bool pcihup_bridge_en)
 {
    Aml *dev, *notify_method = NULL, *method;
    QObject *bsel;
@@ -479,11 +484,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
                dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
                aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
                aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
-                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-                aml_append(method,
-                    aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-                );
-                aml_append(dev, method);
+                if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                    method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                    aml_append(method,
+                               aml_call2("PCEJ", aml_name("BSEL"),
+                                         aml_name("_SUN"))
+                        );
+                    aml_append(dev, method);
+                }
                aml_append(parent_scope, dev);
 
                build_append_pcihp_notify_entry(notify_method, slot);
@@ -537,12 +545,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
            /* add _SUN/_EJ0 to make slot hotpluggable  */
            aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
 
-            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-            aml_append(method,
-                aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-            );
-            aml_append(dev, method);
-
+            if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                aml_append(method,
+                           aml_call2("PCEJ", aml_name("BSEL"),
+                                     aml_name("_SUN"))
+                    );
+                aml_append(dev, method);
+            }
            if (bsel) {
                build_append_pcihp_notify_entry(notify_method, slot);
            }
@@ -553,7 +563,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
             */
            PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));
 
-            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
+            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en,
+                                         pcihup_bridge_en);
        }
        /* slot descriptor has been composed, add it into parent context */
        aml_append(parent_scope, dev);
@@ -2196,7 +2207,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
        if (bus) {
            Aml *scope = aml_scope("PCI0");
            /* Scan all PCI buses. Generate tables to support hotplug. */
-            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
+            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en,
+                                         pm->pcihup_bridge_en);
 
            if (TPM_IS_TIS_ISA(tpm)) {
                if (misc->tpm_version == TPM_VERSION_2_0) {
Signature · 1 line
1.9.4

Ani Sinha

author
#0 lore raw

PATCH v2 1/1 Add a new PIIX option to control PCI hot unplugging of devices on non-root buses

A new option "use_acpi_unplug" is introduced for PIIX which will selectively only disable hot unplugging of both hot plugged and cold plugged PCI devices on non-root PCI buses. This will prevent hot unplugging of devices from Windows based guests from system tray but will not prevent devices from being hot plugged into the guest.

It has been tested on Windows guests.

---
 hw/acpi/piix4.c      |  3 +++
 hw/i386/acpi-build.c | 40 ++++++++++++++++++++++++++--------------
 2 files changed, 29 insertions(+), 14 deletions(-)
hw/acpi/piix4.c +3 -0
index 964d6f5..59fa707 100644
@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {
 
     AcpiPciHpState acpi_pci_hotplug;
     bool use_acpi_pci_hotplug;
+    bool use_acpi_unplug;
 
     uint8_t disable_s3;
     uint8_t disable_s4;
@@ -633,6 +634,8 @@ static Property piix4_pm_properties[] = {
     DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
     DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState,
                      use_acpi_pci_hotplug, true),
+    DEFINE_PROP_BOOL("acpi-pci-hotunplug-enable-bridge", PIIX4PMState,
+                     use_acpi_unplug, true),
     DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
                      acpi_memory_hotplug.is_enabled, true),
     DEFINE_PROP_END_OF_LIST(),
hw/i386/acpi-build.c +26 -14
index 23c77ee..71b3ac3 100644
@@ -96,6 +96,7 @@ typedef struct AcpiPmInfo {
     bool s3_disabled;
     bool s4_disabled;
     bool pcihp_bridge_en;
+    bool pcihup_bridge_en;
     uint8_t s4_val;
     AcpiFadtData fadt;
     uint16_t cpu_hp_io_base;
@@ -240,6 +241,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
     pm->pcihp_bridge_en =
         object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support",
                                  NULL);
+    pm->pcihup_bridge_en =
+        object_property_get_bool(obj, "acpi-pci-hotunplug-enable-bridge",
+                                 NULL);
 }
 
 static void acpi_get_misc_info(AcpiMiscInfo *info)
@@ -451,7 +455,8 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)
 }
 
 static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
-                                         bool pcihp_bridge_en)
+                                         bool pcihp_bridge_en,
+                                         bool pcihup_bridge_en)
 {
     Aml *dev, *notify_method = NULL, *method;
     QObject *bsel;
@@ -479,11 +484,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
                 dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
                 aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
                 aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
-                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-                aml_append(method,
-                    aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-                );
-                aml_append(dev, method);
+                if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                    method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                    aml_append(method,
+                               aml_call2("PCEJ", aml_name("BSEL"),
+                                         aml_name("_SUN"))
+                        );
+                    aml_append(dev, method);
+                }
                 aml_append(parent_scope, dev);
 
                 build_append_pcihp_notify_entry(notify_method, slot);
@@ -537,12 +545,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
             /* add _SUN/_EJ0 to make slot hotpluggable  */
             aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
 
-            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-            aml_append(method,
-                aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-            );
-            aml_append(dev, method);
-
+            if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                aml_append(method,
+                           aml_call2("PCEJ", aml_name("BSEL"),
+                                     aml_name("_SUN"))
+                    );
+                aml_append(dev, method);
+            }
             if (bsel) {
                 build_append_pcihp_notify_entry(notify_method, slot);
             }
@@ -553,7 +563,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
              */
             PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));
 
-            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
+            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en,
+                                         pcihup_bridge_en);
         }
         /* slot descriptor has been composed, add it into parent context */
         aml_append(parent_scope, dev);
@@ -2196,7 +2207,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         if (bus) {
             Aml *scope = aml_scope("PCI0");
             /* Scan all PCI buses. Generate tables to support hotplug. */
-            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
+            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en,
+                                         pm->pcihup_bridge_en);
 
             if (TPM_IS_TIS_ISA(tpm)) {
                 if (misc->tpm_version == TPM_VERSION_2_0) {
Signature · 1 line
1.9.4
#2 lore raw
Quoted 10 lines · Ani Sinha

A new option "use_acpi_unplug" is introduced for PIIX which will selectively only disable hot unplugging of both hot plugged and cold plugged PCI devices on non-root PCI buses. This will prevent hot unplugging of devices from Windows based guests from system tray but will not prevent devices from being hot plugged into the guest.

It has been tested on Windows guests.

It's still a non starter until we find something similar for PCIE and SHPC. Do guests check command status? Can some unplug commands fail?

Quoted 121 lines
---
 hw/acpi/piix4.c      |  3 +++
 hw/i386/acpi-build.c | 40 ++++++++++++++++++++++++++--------------
 2 files changed, 29 insertions(+), 14 deletions(-)
hw/acpi/piix4.c +3 -0
index 964d6f5..59fa707 100644
@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {
 
     AcpiPciHpState acpi_pci_hotplug;
     bool use_acpi_pci_hotplug;
+    bool use_acpi_unplug;
 
     uint8_t disable_s3;
     uint8_t disable_s4;
@@ -633,6 +634,8 @@ static Property piix4_pm_properties[] = {
     DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
     DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState,
                      use_acpi_pci_hotplug, true),
+    DEFINE_PROP_BOOL("acpi-pci-hotunplug-enable-bridge", PIIX4PMState,
+                     use_acpi_unplug, true),
     DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
                      acpi_memory_hotplug.is_enabled, true),
     DEFINE_PROP_END_OF_LIST(),
hw/i386/acpi-build.c +26 -14
index 23c77ee..71b3ac3 100644
@@ -96,6 +96,7 @@ typedef struct AcpiPmInfo {
     bool s3_disabled;
     bool s4_disabled;
     bool pcihp_bridge_en;
+    bool pcihup_bridge_en;
     uint8_t s4_val;
     AcpiFadtData fadt;
     uint16_t cpu_hp_io_base;
@@ -240,6 +241,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
     pm->pcihp_bridge_en =
         object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support",
                                  NULL);
+    pm->pcihup_bridge_en =
+        object_property_get_bool(obj, "acpi-pci-hotunplug-enable-bridge",
+                                 NULL);
 }
 
 static void acpi_get_misc_info(AcpiMiscInfo *info)
@@ -451,7 +455,8 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)
 }
 
 static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
-                                         bool pcihp_bridge_en)
+                                         bool pcihp_bridge_en,
+                                         bool pcihup_bridge_en)
 {
     Aml *dev, *notify_method = NULL, *method;
     QObject *bsel;
@@ -479,11 +484,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
                 dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
                 aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
                 aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
-                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-                aml_append(method,
-                    aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-                );
-                aml_append(dev, method);
+                if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                    method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                    aml_append(method,
+                               aml_call2("PCEJ", aml_name("BSEL"),
+                                         aml_name("_SUN"))
+                        );
+                    aml_append(dev, method);
+                }
                 aml_append(parent_scope, dev);
 
                 build_append_pcihp_notify_entry(notify_method, slot);
@@ -537,12 +545,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
             /* add _SUN/_EJ0 to make slot hotpluggable  */
             aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
 
-            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-            aml_append(method,
-                aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-            );
-            aml_append(dev, method);
-
+            if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                aml_append(method,
+                           aml_call2("PCEJ", aml_name("BSEL"),
+                                     aml_name("_SUN"))
+                    );
+                aml_append(dev, method);
+            }
             if (bsel) {
                 build_append_pcihp_notify_entry(notify_method, slot);
             }
@@ -553,7 +563,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
              */
             PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));
 
-            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
+            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en,
+                                         pcihup_bridge_en);
         }
         /* slot descriptor has been composed, add it into parent context */
         aml_append(parent_scope, dev);
@@ -2196,7 +2207,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         if (bus) {
             Aml *scope = aml_scope("PCI0");
             /* Scan all PCI buses. Generate tables to support hotplug. */
-            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
+            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en,
+                                         pm->pcihup_bridge_en);
 
             if (TPM_IS_TIS_ISA(tpm)) {
                 if (misc->tpm_version == TPM_VERSION_2_0) {
Signature · 1 line
1.9.4
#4 lore raw
In reply to Ani Sinha
Quoted 15 lines · Ani Sinha

Ani
On Apr 28, 2020, 21:35 +0530, Michael S. Tsirkin <[email protected]>, wrote:

On Tue, Apr 28, 2020 at 10:16:52AM +0000, Ani Sinha wrote:

A new option "use_acpi_unplug" is introduced for PIIX which will selectively only disable hot unplugging of both hot plugged and cold plugged PCI devices on non-root PCI buses. This will prevent hot unplugging of devices from Windows based guests from system tray but will not prevent devices from being hot plugged into the guest.

It has been tested on Windows guests.

Quoted 8 lines

It's still a non starter until we find something similar for PCIE and SHPC. Do guests check command status? Can some unplug commands fail?

Ok I give up! I thought we debated this on the other thread.

Sorry to hear that.
I'd rather you didn't, and worked on a solution that works for everyone. Pushing back on merging code is unfortunately the only mechanism maintainers have to make sure features are complete and orthogonal to each other, so I'm not sure I can help otherwise.

Quoted 135 lines



        ---
        hw/acpi/piix4.c | 3 +++
        hw/i386/acpi-build.c | 40 ++++++++++++++++++++++++++--------------
        2 files changed, 29 insertions(+), 14 deletions(-)

        diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
        index 964d6f5..59fa707 100644
        --- a/hw/acpi/piix4.c
        +++ b/hw/acpi/piix4.c
        @@ -78,6 +78,7 @@ typedef struct PIIX4PMState {

        AcpiPciHpState acpi_pci_hotplug;
        bool use_acpi_pci_hotplug;
        + bool use_acpi_unplug;

        uint8_t disable_s3;
        uint8_t disable_s4;
        @@ -633,6 +634,8 @@ static Property piix4_pm_properties[] = {
        DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
        DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState,
        use_acpi_pci_hotplug, true),
        + DEFINE_PROP_BOOL("acpi-pci-hotunplug-enable-bridge", PIIX4PMState,
        + use_acpi_unplug, true),
        DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
        acpi_memory_hotplug.is_enabled, true),
        DEFINE_PROP_END_OF_LIST(),
        diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
        index 23c77ee..71b3ac3 100644
        --- a/hw/i386/acpi-build.c
        +++ b/hw/i386/acpi-build.c
        @@ -96,6 +96,7 @@ typedef struct AcpiPmInfo {
        bool s3_disabled;
        bool s4_disabled;
        bool pcihp_bridge_en;
        + bool pcihup_bridge_en;
        uint8_t s4_val;
        AcpiFadtData fadt;
        uint16_t cpu_hp_io_base;
        @@ -240,6 +241,9 @@ static void acpi_get_pm_info(MachineState *machine,
        AcpiPmInfo *pm)
        pm->pcihp_bridge_en =
        object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support",
        NULL);
        + pm->pcihup_bridge_en =
        + object_property_get_bool(obj, "acpi-pci-hotunplug-enable-bridge",
        + NULL);
        }

        static void acpi_get_misc_info(AcpiMiscInfo *info)
        @@ -451,7 +455,8 @@ static void build_append_pcihp_notify_entry(Aml
        *method, int slot)
        }

        static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus
        *bus,
        - bool pcihp_bridge_en)
        + bool pcihp_bridge_en,
        + bool pcihup_bridge_en)
        {
        Aml *dev, *notify_method = NULL, *method;
        QObject *bsel;
        @@ -479,11 +484,14 @@ static void build_append_pci_bus_devices(Aml
        *parent_scope, PCIBus *bus,
        dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
        aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
        aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
        - method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
        - aml_append(method,
        - aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
        - );
        - aml_append(dev, method);
        + if (pcihup_bridge_en || pci_bus_is_root(bus)) {
        + method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
        + aml_append(method,
        + aml_call2("PCEJ", aml_name("BSEL"),
        + aml_name("_SUN"))
        + );
        + aml_append(dev, method);
        + }
        aml_append(parent_scope, dev);

        build_append_pcihp_notify_entry(notify_method, slot);
        @@ -537,12 +545,14 @@ static void build_append_pci_bus_devices(Aml
        *parent_scope, PCIBus *bus,
        /* add _SUN/_EJ0 to make slot hotpluggable */
        aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));

        - method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
        - aml_append(method,
        - aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
        - );
        - aml_append(dev, method);
        -
        + if (pcihup_bridge_en || pci_bus_is_root(bus)) {
        + method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
        + aml_append(method,
        + aml_call2("PCEJ", aml_name("BSEL"),
        + aml_name("_SUN"))
        + );
        + aml_append(dev, method);
        + }
        if (bsel) {
        build_append_pcihp_notify_entry(notify_method, slot);
        }
        @@ -553,7 +563,8 @@ static void build_append_pci_bus_devices(Aml
        *parent_scope, PCIBus *bus,
        */
        PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));

        - build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
        + build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en,
        + pcihup_bridge_en);
        }
        /* slot descriptor has been composed, add it into parent context */
        aml_append(parent_scope, dev);
        @@ -2196,7 +2207,8 @@ build_dsdt(GArray *table_data, BIOSLinker
        *linker,
        if (bus) {
        Aml *scope = aml_scope("PCI0");
        /* Scan all PCI buses. Generate tables to support hotplug. */
        - build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
        + build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en,
        + pm->pcihup_bridge_en);

        if (TPM_IS_TIS_ISA(tpm)) {
        if (misc->tpm_version == TPM_VERSION_2_0) {
        --
        1.9.4
#27 lore raw
In reply to Michael S. Tsirkin
Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · Ani Sinha

A new option "use_acpi_unplug" is introduced for PIIX which will selectively only disable hot unplugging of both hot plugged and cold plugged PCI devices on non-root PCI buses. This will prevent hot unplugging of devices from Windows based guests from system tray but will not prevent devices from being hot plugged into the guest.

Quoted 6 lines
Quoted 3 lines

It has been tested on Windows guests.

It's still a non starter until we find something similar for PCIE and SHPC. Do guests check command status? Can some unplug commands fail?

Why does PCIE need anything ? For that we already have ability to control hotplugging per-slot in pcie-root-port. If SHPC doesn't support this that's fine too, it isn't a reason to block its merge and use with x86 i440fx machine.

Quoted 119 lines
Quoted 119 lines

---
 hw/acpi/piix4.c      |  3 +++
 hw/i386/acpi-build.c | 40 ++++++++++++++++++++++++++--------------
 2 files changed, 29 insertions(+), 14 deletions(-)
hw/acpi/piix4.c +3 -0
index 964d6f5..59fa707 100644
@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {
 
     AcpiPciHpState acpi_pci_hotplug;
     bool use_acpi_pci_hotplug;
+    bool use_acpi_unplug;
 
     uint8_t disable_s3;
     uint8_t disable_s4;
@@ -633,6 +634,8 @@ static Property piix4_pm_properties[] = {
     DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
     DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState,
                      use_acpi_pci_hotplug, true),
+    DEFINE_PROP_BOOL("acpi-pci-hotunplug-enable-bridge", PIIX4PMState,
+                     use_acpi_unplug, true),
     DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
                      acpi_memory_hotplug.is_enabled, true),
     DEFINE_PROP_END_OF_LIST(),
hw/i386/acpi-build.c +26 -14
index 23c77ee..71b3ac3 100644
@@ -96,6 +96,7 @@ typedef struct AcpiPmInfo {
     bool s3_disabled;
     bool s4_disabled;
     bool pcihp_bridge_en;
+    bool pcihup_bridge_en;
     uint8_t s4_val;
     AcpiFadtData fadt;
     uint16_t cpu_hp_io_base;
@@ -240,6 +241,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
     pm->pcihp_bridge_en =
         object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support",
                                  NULL);
+    pm->pcihup_bridge_en =
+        object_property_get_bool(obj, "acpi-pci-hotunplug-enable-bridge",
+                                 NULL);
 }
 
 static void acpi_get_misc_info(AcpiMiscInfo *info)
@@ -451,7 +455,8 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)
 }
 
 static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
-                                         bool pcihp_bridge_en)
+                                         bool pcihp_bridge_en,
+                                         bool pcihup_bridge_en)
 {
     Aml *dev, *notify_method = NULL, *method;
     QObject *bsel;
@@ -479,11 +484,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
                 dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
                 aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
                 aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
-                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-                aml_append(method,
-                    aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-                );
-                aml_append(dev, method);
+                if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                    method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                    aml_append(method,
+                               aml_call2("PCEJ", aml_name("BSEL"),
+                                         aml_name("_SUN"))
+                        );
+                    aml_append(dev, method);
+                }
                 aml_append(parent_scope, dev);
 
                 build_append_pcihp_notify_entry(notify_method, slot);
@@ -537,12 +545,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
             /* add _SUN/_EJ0 to make slot hotpluggable  */
             aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
 
-            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-            aml_append(method,
-                aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-            );
-            aml_append(dev, method);
-
+            if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                aml_append(method,
+                           aml_call2("PCEJ", aml_name("BSEL"),
+                                     aml_name("_SUN"))
+                    );
+                aml_append(dev, method);
+            }
             if (bsel) {
                 build_append_pcihp_notify_entry(notify_method, slot);
             }
@@ -553,7 +563,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
              */
             PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));
 
-            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
+            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en,
+                                         pcihup_bridge_en);
         }
         /* slot descriptor has been composed, add it into parent context */
         aml_append(parent_scope, dev);
@@ -2196,7 +2207,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         if (bus) {
             Aml *scope = aml_scope("PCI0");
             /* Scan all PCI buses. Generate tables to support hotplug. */
-            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
+            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en,
+                                         pm->pcihup_bridge_en);
 
Quoted 6 lines
Quoted 4 lines
hw/i386/acpi-build.c +0 -0
             if (TPM_IS_TIS_ISA(tpm)) {
                 if (misc->tpm_version == TPM_VERSION_2_0) {
Signature · 1 line
1.9.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 :|
#28 lore raw
Quoted 11 lines · Daniel P. Berrangé
Quoted 10 lines · Michael S. Tsirkin
Quoted 9 lines · Ani Sinha

A new option "use_acpi_unplug" is introduced for PIIX which will selectively only disable hot unplugging of both hot plugged and cold plugged PCI devices on non-root PCI buses. This will prevent hot unplugging of devices from Windows based guests from system tray but will not prevent devices from being hot plugged into the guest.

It has been tested on Windows guests.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

It's still a non starter until we find something similar for PCIE and SHPC. Do guests check command status? Can some unplug commands fail?

Why does PCIE need anything ? For that we already have ability to control hotplugging per-slot in pcie-root-port.

At the moment that does not support unplug of hotplugged devices.

Quoted 136 lines

If SHPC doesn't
support this that's fine too, it isn't a reason to block its merge and use with x86 i440fx machine.

Quoted 119 lines
Quoted 119 lines

---
 hw/acpi/piix4.c      |  3 +++
 hw/i386/acpi-build.c | 40 ++++++++++++++++++++++++++--------------
 2 files changed, 29 insertions(+), 14 deletions(-)
hw/acpi/piix4.c +3 -0
index 964d6f5..59fa707 100644
@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {
 
     AcpiPciHpState acpi_pci_hotplug;
     bool use_acpi_pci_hotplug;
+    bool use_acpi_unplug;
 
     uint8_t disable_s3;
     uint8_t disable_s4;
@@ -633,6 +634,8 @@ static Property piix4_pm_properties[] = {
     DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
     DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState,
                      use_acpi_pci_hotplug, true),
+    DEFINE_PROP_BOOL("acpi-pci-hotunplug-enable-bridge", PIIX4PMState,
+                     use_acpi_unplug, true),
     DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
                      acpi_memory_hotplug.is_enabled, true),
     DEFINE_PROP_END_OF_LIST(),
hw/i386/acpi-build.c +26 -14
index 23c77ee..71b3ac3 100644
@@ -96,6 +96,7 @@ typedef struct AcpiPmInfo {
     bool s3_disabled;
     bool s4_disabled;
     bool pcihp_bridge_en;
+    bool pcihup_bridge_en;
     uint8_t s4_val;
     AcpiFadtData fadt;
     uint16_t cpu_hp_io_base;
@@ -240,6 +241,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
     pm->pcihp_bridge_en =
         object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support",
                                  NULL);
+    pm->pcihup_bridge_en =
+        object_property_get_bool(obj, "acpi-pci-hotunplug-enable-bridge",
+                                 NULL);
 }
 
 static void acpi_get_misc_info(AcpiMiscInfo *info)
@@ -451,7 +455,8 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)
 }
 
 static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
-                                         bool pcihp_bridge_en)
+                                         bool pcihp_bridge_en,
+                                         bool pcihup_bridge_en)
 {
     Aml *dev, *notify_method = NULL, *method;
     QObject *bsel;
@@ -479,11 +484,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
                 dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
                 aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
                 aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
-                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-                aml_append(method,
-                    aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-                );
-                aml_append(dev, method);
+                if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                    method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                    aml_append(method,
+                               aml_call2("PCEJ", aml_name("BSEL"),
+                                         aml_name("_SUN"))
+                        );
+                    aml_append(dev, method);
+                }
                 aml_append(parent_scope, dev);
 
                 build_append_pcihp_notify_entry(notify_method, slot);
@@ -537,12 +545,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
             /* add _SUN/_EJ0 to make slot hotpluggable  */
             aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
 
-            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-            aml_append(method,
-                aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-            );
-            aml_append(dev, method);
-
+            if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                aml_append(method,
+                           aml_call2("PCEJ", aml_name("BSEL"),
+                                     aml_name("_SUN"))
+                    );
+                aml_append(dev, method);
+            }
             if (bsel) {
                 build_append_pcihp_notify_entry(notify_method, slot);
             }
@@ -553,7 +563,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
              */
             PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));
 
-            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
+            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en,
+                                         pcihup_bridge_en);
         }
         /* slot descriptor has been composed, add it into parent context */
         aml_append(parent_scope, dev);
@@ -2196,7 +2207,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         if (bus) {
             Aml *scope = aml_scope("PCI0");
             /* Scan all PCI buses. Generate tables to support hotplug. */
-            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
+            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en,
+                                         pm->pcihup_bridge_en);
 
Quoted 6 lines
Quoted 4 lines
hw/i386/acpi-build.c +0 -0
             if (TPM_IS_TIS_ISA(tpm)) {
                 if (misc->tpm_version == TPM_VERSION_2_0) {
Signature · 1 line
1.9.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 :|
#29 lore raw
Quoted 14 lines · Michael S. Tsirkin
Quoted 13 lines · Daniel P. Berrangé
Quoted 12 lines · Michael S. Tsirkin
Quoted 10 lines · Ani Sinha

A new option "use_acpi_unplug" is introduced for PIIX which will selectively only disable hot unplugging of both hot plugged and cold plugged PCI devices on non-root PCI buses. This will prevent hot unplugging of devices from Windows based guests from system tray but will not prevent devices from being hot plugged into the guest.

It has been tested on Windows guests.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

It's still a non starter until we find something similar for PCIE and SHPC. Do guests check command status? Can some unplug commands fail?

Why does PCIE need anything ? For that we already have ability to control hotplugging per-slot in pcie-root-port.

At the moment that does not support unplug of hotplugged devices.

I don't see why this patch has to deal with that limitation though, it is a independant problem from this patch which is PCI focused, not PCIe.

Quoted 132 lines
Quoted 132 lines

If SHPC doesn't
support this that's fine too, it isn't a reason to block its merge and use with x86 i440fx machine.

Quoted 125 lines
Quoted 123 lines

---
 hw/acpi/piix4.c      |  3 +++
 hw/i386/acpi-build.c | 40 ++++++++++++++++++++++++++--------------
 2 files changed, 29 insertions(+), 14 deletions(-)
hw/acpi/piix4.c +3 -0
index 964d6f5..59fa707 100644
@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {
 
     AcpiPciHpState acpi_pci_hotplug;
     bool use_acpi_pci_hotplug;
+    bool use_acpi_unplug;
 
     uint8_t disable_s3;
     uint8_t disable_s4;
@@ -633,6 +634,8 @@ static Property piix4_pm_properties[] = {
     DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
     DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState,
                      use_acpi_pci_hotplug, true),
+    DEFINE_PROP_BOOL("acpi-pci-hotunplug-enable-bridge", PIIX4PMState,
+                     use_acpi_unplug, true),
     DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
                      acpi_memory_hotplug.is_enabled, true),
     DEFINE_PROP_END_OF_LIST(),
hw/i386/acpi-build.c +26 -14
index 23c77ee..71b3ac3 100644
@@ -96,6 +96,7 @@ typedef struct AcpiPmInfo {
     bool s3_disabled;
     bool s4_disabled;
     bool pcihp_bridge_en;
+    bool pcihup_bridge_en;
     uint8_t s4_val;
     AcpiFadtData fadt;
     uint16_t cpu_hp_io_base;
@@ -240,6 +241,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
     pm->pcihp_bridge_en =
         object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support",
                                  NULL);
+    pm->pcihup_bridge_en =
+        object_property_get_bool(obj, "acpi-pci-hotunplug-enable-bridge",
+                                 NULL);
 }
 
 static void acpi_get_misc_info(AcpiMiscInfo *info)
@@ -451,7 +455,8 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)
 }
 
 static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
-                                         bool pcihp_bridge_en)
+                                         bool pcihp_bridge_en,
+                                         bool pcihup_bridge_en)
 {
     Aml *dev, *notify_method = NULL, *method;
     QObject *bsel;
@@ -479,11 +484,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
                 dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
                 aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
                 aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
-                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-                aml_append(method,
-                    aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-                );
-                aml_append(dev, method);
+                if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                    method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                    aml_append(method,
+                               aml_call2("PCEJ", aml_name("BSEL"),
+                                         aml_name("_SUN"))
+                        );
+                    aml_append(dev, method);
+                }
                 aml_append(parent_scope, dev);
 
                 build_append_pcihp_notify_entry(notify_method, slot);
@@ -537,12 +545,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
             /* add _SUN/_EJ0 to make slot hotpluggable  */
             aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
 
-            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-            aml_append(method,
-                aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-            );
-            aml_append(dev, method);
-
+            if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                aml_append(method,
+                           aml_call2("PCEJ", aml_name("BSEL"),
+                                     aml_name("_SUN"))
+                    );
+                aml_append(dev, method);
+            }
             if (bsel) {
                 build_append_pcihp_notify_entry(notify_method, slot);
             }
@@ -553,7 +563,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
              */
             PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));
 
-            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
+            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en,
+                                         pcihup_bridge_en);
         }
         /* slot descriptor has been composed, add it into parent context */
         aml_append(parent_scope, dev);
@@ -2196,7 +2207,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         if (bus) {
             Aml *scope = aml_scope("PCI0");
             /* Scan all PCI buses. Generate tables to support hotplug. */
-            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
+            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en,
+                                         pm->pcihup_bridge_en);
 
             if (TPM_IS_TIS_ISA(tpm)) {
                 if (misc->tpm_version == TPM_VERSION_2_0) {
Signature · 1 line
1.9.4
Quoted 7 lines
Quoted 6 lines

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 :|

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 :|
#3 lore raw
In reply to Michael S. Tsirkin

Ani

Quoted 8 lines · On Apr 28, 2020, 21:35 +0530, Michael S. Tsirkin <[email protected]>, wrote:
Quoted 7 lines · Ani Sinha

A new option "use_acpi_unplug" is introduced for PIIX which will selectively only disable hot unplugging of both hot plugged and cold plugged PCI devices on non-root PCI buses. This will prevent hot unplugging of devices from Windows based guests from system tray but will not prevent devices from being hot plugged into the guest.

Quoted 6 lines
Quoted 3 lines

It has been tested on Windows guests.

It's still a non starter until we find something similar for PCIE and SHPC. Do guests check command status? Can some unplug commands fail?

Ok I  give up! I thought we debated this on the other thread.

Quoted 124 lines
Quoted 123 lines

---
hw/acpi/piix4.c | 3 +++
hw/i386/acpi-build.c | 40 ++++++++++++++++++++++++++--------------

2 files changed, 29 insertions(+), 14 deletions(-)
hw/acpi/piix4.c +3 -0
index 964d6f5..59fa707 100644
@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {
 
 AcpiPciHpState acpi_pci_hotplug;
 bool use_acpi_pci_hotplug;
+ bool use_acpi_unplug;
 
 uint8_t disable_s3;
 uint8_t disable_s4;
@@ -633,6 +634,8 @@ static Property piix4_pm_properties[] = {
 DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
 DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState,
 use_acpi_pci_hotplug, true),
+ DEFINE_PROP_BOOL("acpi-pci-hotunplug-enable-bridge", PIIX4PMState,
+ use_acpi_unplug, true),
 DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
 acpi_memory_hotplug.is_enabled, true),
 DEFINE_PROP_END_OF_LIST(),
hw/i386/acpi-build.c +1 -0
index 23c77ee..71b3ac3 100644
@@ -96,6 +96,7 @@ typedef struct AcpiPmInfo {
 bool s3_disabled;
 bool s4_disabled;
 bool pcihp_bridge_en;
+ bool pcihup_bridge_en;
 uint8_t s4_val;
 AcpiFadtData fadt;
 uint16_t cpu_hp_io_base;
@@ -240,6 +241,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)

pm->pcihp_bridge_en =
object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support", NULL);
+ pm->pcihup_bridge_en =
+ object_property_get_bool(obj, "acpi-pci-hotunplug-enable-bridge",
+ NULL);
}

static void acpi_get_misc_info(AcpiMiscInfo *info)

hw/i386/acpi-build.c +22 -15
@@ -451,7 +455,8 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)
 }
 
 static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
- bool pcihp_bridge_en)
+ bool pcihp_bridge_en,
+ bool pcihup_bridge_en)
 {
 Aml *dev, *notify_method = NULL, *method;
 QObject *bsel;
@@ -479,11 +484,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
 dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
 aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
 aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
- method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
- aml_append(method,
- aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
- );
- aml_append(dev, method);
+ if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+ method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+ aml_append(method,
+ aml_call2("PCEJ", aml_name("BSEL"),
+ aml_name("_SUN"))
+ );
+ aml_append(dev, method);
+ }
 aml_append(parent_scope, dev);
 
 build_append_pcihp_notify_entry(notify_method, slot);
@@ -537,12 +545,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
 /* add _SUN/_EJ0 to make slot hotpluggable */
 aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
 
- method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
- aml_append(method,
- aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
- );
- aml_append(dev, method);
-
+ if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+ method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+ aml_append(method,
+ aml_call2("PCEJ", aml_name("BSEL"),
+ aml_name("_SUN"))
+ );
+ aml_append(dev, method);
+ }
 if (bsel) {
 build_append_pcihp_notify_entry(notify_method, slot);
 }
@@ -553,7 +563,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
 */
 PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));
 
- build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
+ build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en,
+ pcihup_bridge_en);
 }
 /* slot descriptor has been composed, add it into parent context */
 aml_append(parent_scope, dev);
@@ -2196,7 +2207,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
 if (bus) {
 Aml *scope = aml_scope("PCI0");
 /* Scan all PCI buses. Generate tables to support hotplug. */
- build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
+ build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en,
+ pm->pcihup_bridge_en);
 
 if (TPM_IS_TIS_ISA(tpm)) {
 if (misc->tpm_version == TPM_VERSION_2_0) {
--

1.9.4

#5 lore raw
In reply to Michael S. Tsirkin
Quoted 20 lines · Michael S. Tsirkin
Quoted 3 lines · Ani Sinha

Ani
On Apr 28, 2020, 21:35 +0530, Michael S. Tsirkin <[email protected]>,

Quoted 15 lines · wrote:

On Tue, Apr 28, 2020 at 10:16:52AM +0000, Ani Sinha wrote:

A new option "use_acpi_unplug" is introduced for PIIX which will selectively only disable hot unplugging of both hot plugged and cold plugged PCI devices on non-root PCI buses. This will prevent hot unplugging of devices from Windows based guests from system tray but will not prevent devices from being hot plugged into the guest.

It has been tested on Windows guests.

Quoted 8 lines
Quoted 5 lines

It's still a non starter until we find something similar for PCIE and SHPC. Do guests check command status? Can some unplug commands fail?

Ok I give up! I thought we debated this on the other thread.

Sorry to hear that.
I'd rather you didn't, and worked on a solution that works for everyone.

That is extremely hard for one person to do, without inputs and ideas from the community. Satisfying the entire world requires lot of time and energy investment, not to mention a broad expertise in multiple technologies.

Quoted 152 lines

Pushing back on merging code is unfortunately the only mechanism maintainers have to make sure features are complete and orthogonal to each other, so I'm not sure I can help otherwise.

Quoted 7 lines



        ---
        hw/acpi/piix4.c | 3 +++
        hw/i386/acpi-build.c | 40

++++++++++++++++++++++++++--------------

Quoted 17 lines
        2 files changed, 29 insertions(+), 14 deletions(-)
        diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
        index 964d6f5..59fa707 100644
        --- a/hw/acpi/piix4.c
        +++ b/hw/acpi/piix4.c
        @@ -78,6 +78,7 @@ typedef struct PIIX4PMState {

        AcpiPciHpState acpi_pci_hotplug;
        bool use_acpi_pci_hotplug;
        + bool use_acpi_unplug;

        uint8_t disable_s3;
        uint8_t disable_s4;
        @@ -633,6 +634,8 @@ static Property piix4_pm_properties[] = {
        DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
        DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support",

PIIX4PMState,

Quoted 2 lines

use_acpi_pci_hotplug, true),
+ DEFINE_PROP_BOOL("acpi-pci-hotunplug-enable-bridge",

PIIX4PMState,

Quoted 9 lines
        + use_acpi_unplug, true),
        DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
        acpi_memory_hotplug.is_enabled, true),
        DEFINE_PROP_END_OF_LIST(),
        diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
        index 23c77ee..71b3ac3 100644
        --- a/hw/i386/acpi-build.c
        +++ b/hw/i386/acpi-build.c
        @@ -96,6 +96,7 @@ typedef struct AcpiPmInfo {
Quoted 8 lines
        bool s3_disabled;
        bool s4_disabled;
        bool pcihp_bridge_en;
        + bool pcihup_bridge_en;
        uint8_t s4_val;
        AcpiFadtData fadt;
        uint16_t cpu_hp_io_base;
        @@ -240,6 +241,9 @@ static void acpi_get_pm_info(MachineState

*machine,

Quoted 3 lines
        AcpiPmInfo *pm)
        pm->pcihp_bridge_en =
        object_property_get_bool(obj,

"acpi-pci-hotplug-with-bridge-support",

Quoted 3 lines

NULL);
+ pm->pcihup_bridge_en =
+ object_property_get_bool(obj,

"acpi-pci-hotunplug-enable-bridge",

Quoted 5 lines

+ NULL);
}

static void acpi_get_misc_info(AcpiMiscInfo *info) @@ -451,7 +455,8 @@ static void

build_append_pcihp_notify_entry(Aml

Quoted 4 lines

*method, int slot)
}

static void build_append_pci_bus_devices(Aml *parent_scope,

PCIBus

Quoted 8 lines
        *bus,
        - bool pcihp_bridge_en)
        + bool pcihp_bridge_en,
        + bool pcihup_bridge_en)
        {
        Aml *dev, *notify_method = NULL, *method;
        QObject *bsel;
        @@ -479,11 +484,14 @@ static void

build_append_pci_bus_devices(Aml

Quoted 19 lines

*parent_scope, PCIBus *bus,
dev = aml_device("S%.02X", PCI_DEVFN(slot, 0)); aml_append(dev, aml_name_decl("_SUN", aml_int(slot))); aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
- method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
- aml_append(method,
- aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
- );
- aml_append(dev, method);
+ if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+ method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+ aml_append(method,
+ aml_call2("PCEJ", aml_name("BSEL"),
+ aml_name("_SUN"))
+ );
+ aml_append(dev, method);
+ }
aml_append(parent_scope, dev);

Quoted 2 lines

build_append_pcihp_notify_entry(notify_method, slot); @@ -537,12 +545,14 @@ static void

build_append_pci_bus_devices(Aml

Quoted 26 lines

*parent_scope, PCIBus *bus,
/* add _SUN/_EJ0 to make slot hotpluggable */ aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));

- method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
- aml_append(method,
- aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
- );
- aml_append(dev, method);
-
+ if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+ method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+ aml_append(method,
+ aml_call2("PCEJ", aml_name("BSEL"),
+ aml_name("_SUN"))
+ );
+ aml_append(dev, method);
+ }
if (bsel) { build_append_pcihp_notify_entry(notify_method, slot); }
@@ -553,7 +563,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
*/
PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));

Quoted 5 lines

- build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
+ build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en,
+ pcihup_bridge_en);
}
/* slot descriptor has been composed, add it into parent context

*/

Quoted 17 lines
        aml_append(parent_scope, dev);
        @@ -2196,7 +2207,8 @@ build_dsdt(GArray *table_data, BIOSLinker
        *linker,
        if (bus) {
        Aml *scope = aml_scope("PCI0");
        /* Scan all PCI buses. Generate tables to support hotplug. */
        - build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
        + build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en,
        + pm->pcihup_bridge_en);

        if (TPM_IS_TIS_ISA(tpm)) {
        if (misc->tpm_version == TPM_VERSION_2_0) {
        --
        1.9.4
#6 lore raw
Quoted 27 lines · Ani Sinha

On Tue, Apr 28, 2020 at 9:51 PM Michael S. Tsirkin <[email protected]> wrote:

On Tue, Apr 28, 2020 at 09:39:16PM +0530, Ani Sinha wrote:
>
> Ani
> On Apr 28, 2020, 21:35 +0530, Michael S. Tsirkin <[email protected]>, wrote:
>
>     On Tue, Apr 28, 2020 at 10:16:52AM +0000, Ani Sinha wrote:
>
>         A new option "use_acpi_unplug" is introduced for PIIX which will >         selectively only disable hot unplugging of both hot plugged and >         cold plugged PCI devices on non-root PCI buses. This will prevent >         hot unplugging of devices from Windows based guests from system >         tray but will not prevent devices from being hot plugged into the >         guest.
>
>         It has been tested on Windows guests.
>
>         Signed-off-by: Ani Sinha <[email protected]>
>
>
>     It's still a non starter until we find something similar for PCIE and >     SHPC. Do guests check command status? Can some unplug commands fail? >
>

Quoted 8 lines

> Ok I  give up! I thought we debated this on the other thread.

Sorry to hear that.
I'd rather you didn't, and worked on a solution that works for everyone.

That is extremely hard for one person to do, without inputs and ideas from the community.

What kind of input are you looking for?

Quoted 157 lines

Satisfying the entire world requires lot of time and energy investment, not to mention a broad expertise in multiple technologies.

    Pushing back on merging code is unfortunately the only mechanism
    maintainers have to make sure features are complete and
    orthogonal to each other, so I'm not sure I can help otherwise.

    >
    >
    >
    >
    >         ---
    >         hw/acpi/piix4.c | 3 +++
    >         hw/i386/acpi-build.c | 40
    ++++++++++++++++++++++++++--------------
    >         2 files changed, 29 insertions(+), 14 deletions(-)
    >
    >         diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
    >         index 964d6f5..59fa707 100644
    >         --- a/hw/acpi/piix4.c
    >         +++ b/hw/acpi/piix4.c
    >         @@ -78,6 +78,7 @@ typedef struct PIIX4PMState {
    >
    >         AcpiPciHpState acpi_pci_hotplug;
    >         bool use_acpi_pci_hotplug;
    >         + bool use_acpi_unplug;
    >
    >         uint8_t disable_s3;
    >         uint8_t disable_s4;
    >         @@ -633,6 +634,8 @@ static Property piix4_pm_properties[] = {
    >         DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
    >         DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support",
    PIIX4PMState,
    >         use_acpi_pci_hotplug, true),
    >         + DEFINE_PROP_BOOL("acpi-pci-hotunplug-enable-bridge",
    PIIX4PMState,
    >         + use_acpi_unplug, true),
    >         DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
    >         acpi_memory_hotplug.is_enabled, true),
    >         DEFINE_PROP_END_OF_LIST(),
    >         diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
    >         index 23c77ee..71b3ac3 100644
    >         --- a/hw/i386/acpi-build.c
    >         +++ b/hw/i386/acpi-build.c
    >         @@ -96,6 +96,7 @@ typedef struct AcpiPmInfo {
    >         bool s3_disabled;
    >         bool s4_disabled;
    >         bool pcihp_bridge_en;
    >         + bool pcihup_bridge_en;
    >         uint8_t s4_val;
    >         AcpiFadtData fadt;
    >         uint16_t cpu_hp_io_base;
    >         @@ -240,6 +241,9 @@ static void acpi_get_pm_info(MachineState
    *machine,
    >         AcpiPmInfo *pm)
    >         pm->pcihp_bridge_en =
    >         object_property_get_bool(obj,
    "acpi-pci-hotplug-with-bridge-support",
    >         NULL);
    >         + pm->pcihup_bridge_en =
    >         + object_property_get_bool(obj,
    "acpi-pci-hotunplug-enable-bridge",
    >         + NULL);
    >         }
    >
    >         static void acpi_get_misc_info(AcpiMiscInfo *info)
    >         @@ -451,7 +455,8 @@ static void build_append_pcihp_notify_entry
    (Aml
    >         *method, int slot)
    >         }
    >
    >         static void build_append_pci_bus_devices(Aml *parent_scope,
    PCIBus
    >         *bus,
    >         - bool pcihp_bridge_en)
    >         + bool pcihp_bridge_en,
    >         + bool pcihup_bridge_en)
    >         {
    >         Aml *dev, *notify_method = NULL, *method;
    >         QObject *bsel;
    >         @@ -479,11 +484,14 @@ static void build_append_pci_bus_devices
    (Aml
    >         *parent_scope, PCIBus *bus,
    >         dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
    >         aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
    >         aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
    >         - method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
    >         - aml_append(method,
    >         - aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
    >         - );
    >         - aml_append(dev, method);
    >         + if (pcihup_bridge_en || pci_bus_is_root(bus)) {
    >         + method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
    >         + aml_append(method,
    >         + aml_call2("PCEJ", aml_name("BSEL"),
    >         + aml_name("_SUN"))
    >         + );
    >         + aml_append(dev, method);
    >         + }
    >         aml_append(parent_scope, dev);
    >
    >         build_append_pcihp_notify_entry(notify_method, slot);
    >         @@ -537,12 +545,14 @@ static void build_append_pci_bus_devices
    (Aml
    >         *parent_scope, PCIBus *bus,
    >         /* add _SUN/_EJ0 to make slot hotpluggable */
    >         aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
    >
    >         - method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
    >         - aml_append(method,
    >         - aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
    >         - );
    >         - aml_append(dev, method);
    >         -
    >         + if (pcihup_bridge_en || pci_bus_is_root(bus)) {
    >         + method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
    >         + aml_append(method,
    >         + aml_call2("PCEJ", aml_name("BSEL"),
    >         + aml_name("_SUN"))
    >         + );
    >         + aml_append(dev, method);
    >         + }
    >         if (bsel) {
    >         build_append_pcihp_notify_entry(notify_method, slot);
    >         }
    >         @@ -553,7 +563,8 @@ static void build_append_pci_bus_devices(Aml
    >         *parent_scope, PCIBus *bus,
    >         */
    >         PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));
    >
    >         - build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
    >         + build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en,
    >         + pcihup_bridge_en);
    >         }
    >         /* slot descriptor has been composed, add it into parent context
    */
    >         aml_append(parent_scope, dev);
    >         @@ -2196,7 +2207,8 @@ build_dsdt(GArray *table_data, BIOSLinker
    >         *linker,
    >         if (bus) {
    >         Aml *scope = aml_scope("PCI0");
    >         /* Scan all PCI buses. Generate tables to support hotplug. */
    >         - build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
    >         + build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en,
    >         + pm->pcihup_bridge_en);
    >
    >         if (TPM_IS_TIS_ISA(tpm)) {
    >         if (misc->tpm_version == TPM_VERSION_2_0) {
    >         --
    >         1.9.4
    >
    >
    >
#30 lore raw
In reply to Daniel P. Berrangé
Quoted 18 lines · Daniel P. Berrangé
Quoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Daniel P. Berrangé
Quoted 14 lines · Michael S. Tsirkin
Quoted 10 lines · Ani Sinha

A new option "use_acpi_unplug" is introduced for PIIX which will selectively only disable hot unplugging of both hot plugged and cold plugged PCI devices on non-root PCI buses. This will prevent hot unplugging of devices from Windows based guests from system tray but will not prevent devices from being hot plugged into the guest.

It has been tested on Windows guests.

It's still a non starter until we find something similar for PCIE and SHPC. Do guests check command status? Can some unplug commands fail?

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Why does PCIE need anything ? For that we already have ability to control hotplugging per-slot in pcie-root-port.

At the moment that does not support unplug of hotplugged devices.

I don't see why this patch has to deal with that limitation though, it is a independant problem from this patch which is PCI focused, not PCIe.

And that's par for the course, each contributor wants to care only about his own corner. The only tool I as a maintainer have for keeping things consistent is by deferring merge until they are.

Quoted 146 lines
Quoted 132 lines
Quoted 132 lines

If SHPC doesn't
support this that's fine too, it isn't a reason to block its merge and use with x86 i440fx machine.

Quoted 125 lines
Quoted 123 lines

---
 hw/acpi/piix4.c      |  3 +++
 hw/i386/acpi-build.c | 40 ++++++++++++++++++++++++++--------------
 2 files changed, 29 insertions(+), 14 deletions(-)
hw/acpi/piix4.c +3 -0
index 964d6f5..59fa707 100644
@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {
 
     AcpiPciHpState acpi_pci_hotplug;
     bool use_acpi_pci_hotplug;
+    bool use_acpi_unplug;
 
     uint8_t disable_s3;
     uint8_t disable_s4;
@@ -633,6 +634,8 @@ static Property piix4_pm_properties[] = {
     DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
     DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState,
                      use_acpi_pci_hotplug, true),
+    DEFINE_PROP_BOOL("acpi-pci-hotunplug-enable-bridge", PIIX4PMState,
+                     use_acpi_unplug, true),
     DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
                      acpi_memory_hotplug.is_enabled, true),
     DEFINE_PROP_END_OF_LIST(),
hw/i386/acpi-build.c +26 -14
index 23c77ee..71b3ac3 100644
@@ -96,6 +96,7 @@ typedef struct AcpiPmInfo {
     bool s3_disabled;
     bool s4_disabled;
     bool pcihp_bridge_en;
+    bool pcihup_bridge_en;
     uint8_t s4_val;
     AcpiFadtData fadt;
     uint16_t cpu_hp_io_base;
@@ -240,6 +241,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
     pm->pcihp_bridge_en =
         object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support",
                                  NULL);
+    pm->pcihup_bridge_en =
+        object_property_get_bool(obj, "acpi-pci-hotunplug-enable-bridge",
+                                 NULL);
 }
 
 static void acpi_get_misc_info(AcpiMiscInfo *info)
@@ -451,7 +455,8 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)
 }
 
 static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
-                                         bool pcihp_bridge_en)
+                                         bool pcihp_bridge_en,
+                                         bool pcihup_bridge_en)
 {
     Aml *dev, *notify_method = NULL, *method;
     QObject *bsel;
@@ -479,11 +484,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
                 dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
                 aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
                 aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
-                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-                aml_append(method,
-                    aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-                );
-                aml_append(dev, method);
+                if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                    method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                    aml_append(method,
+                               aml_call2("PCEJ", aml_name("BSEL"),
+                                         aml_name("_SUN"))
+                        );
+                    aml_append(dev, method);
+                }
                 aml_append(parent_scope, dev);
 
                 build_append_pcihp_notify_entry(notify_method, slot);
@@ -537,12 +545,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
             /* add _SUN/_EJ0 to make slot hotpluggable  */
             aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
 
-            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-            aml_append(method,
-                aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-            );
-            aml_append(dev, method);
-
+            if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                aml_append(method,
+                           aml_call2("PCEJ", aml_name("BSEL"),
+                                     aml_name("_SUN"))
+                    );
+                aml_append(dev, method);
+            }
             if (bsel) {
                 build_append_pcihp_notify_entry(notify_method, slot);
             }
@@ -553,7 +563,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
              */
             PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));
 
-            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
+            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en,
+                                         pcihup_bridge_en);
         }
         /* slot descriptor has been composed, add it into parent context */
         aml_append(parent_scope, dev);
@@ -2196,7 +2207,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         if (bus) {
             Aml *scope = aml_scope("PCI0");
             /* Scan all PCI buses. Generate tables to support hotplug. */
-            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
+            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en,
+                                         pm->pcihup_bridge_en);
 
             if (TPM_IS_TIS_ISA(tpm)) {
                 if (misc->tpm_version == TPM_VERSION_2_0) {
Signature · 1 line
1.9.4
Quoted 7 lines
Quoted 6 lines

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 :|

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 :|
#7 lore raw
In reply to Michael S. Tsirkin
Quoted 41 lines · Michael S. Tsirkin
Quoted 3 lines · Ani Sinha

On Tue, Apr 28, 2020 at 9:51 PM Michael S. Tsirkin <[email protected]>

Quoted 5 lines · wrote:
    On Tue, Apr 28, 2020 at 09:39:16PM +0530, Ani Sinha wrote:
    >
    > Ani
    > On Apr 28, 2020, 21:35 +0530, Michael S. Tsirkin <[email protected]>,
Quoted 4 lines · wrote:
Quoted 4 lines · Ani Sinha

A new option "use_acpi_unplug" is introduced for PIIX

which will

Quoted 1 line
Quoted 1 line

selectively only disable hot unplugging of both hot

plugged and

Quoted 1 line
Quoted 1 line

cold plugged PCI devices on non-root PCI buses. This will

prevent

Quoted 1 line
Quoted 1 line

hot unplugging of devices from Windows based guests from

system

Quoted 1 line
Quoted 1 line

tray but will not prevent devices from being hot plugged

into the

Quoted 8 lines
Quoted 8 lines

guest.

It has been tested on Windows guests.

It's still a non starter until we find something similar for

PCIE and

Quoted 1 line
Quoted 1 line

SHPC. Do guests check command status? Can some unplug commands

fail?

Quoted 6 lines
Quoted 3 lines

Ok I give up! I thought we debated this on the other thread.

Sorry to hear that.
I'd rather you didn't, and worked on a solution that works for

Quoted 8 lines

everyone.

Quoted 3 lines

That is extremely hard for one person to do, without inputs and ideas

from the

Quoted 1 line

community.

What kind of input are you looking for?

Well there were several discussions in the other thread around how PCIE behaves and how we can't change the slot features without a HW reset. Those were useful inputs.

The approach you are taking as a maintainer is very discouraging. All I have gotten from you is negativity and push back. There has been no other engagement from you. If you expect one person to fix every use case, that is an unrealistic expectation IMHO. Even if I could come up with a solution for every case, testing every use case is a huge investment in time and effort. No one outside the big distros will be motivated to do that. So involvement from outside the distro community will be limited to minor changes, bug fixes and easy code reworks.

My 2 cents.

Quoted 175 lines
Quoted 25 lines

Satisfying the entire world requires lot of time and energy investment, not to mention a broad expertise in multiple technologies.

    Pushing back on merging code is unfortunately the only mechanism
    maintainers have to make sure features are complete and
    orthogonal to each other, so I'm not sure I can help otherwise.

    >
    >
    >
    >
    >         ---
    >         hw/acpi/piix4.c | 3 +++
    >         hw/i386/acpi-build.c | 40
    ++++++++++++++++++++++++++--------------
    >         2 files changed, 29 insertions(+), 14 deletions(-)
    >
    >         diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
    >         index 964d6f5..59fa707 100644
    >         --- a/hw/acpi/piix4.c
    >         +++ b/hw/acpi/piix4.c
    >         @@ -78,6 +78,7 @@ typedef struct PIIX4PMState {
Quoted 8 lines
    >
    >         AcpiPciHpState acpi_pci_hotplug;
    >         bool use_acpi_pci_hotplug;
    >         + bool use_acpi_unplug;
    >
    >         uint8_t disable_s3;
    >         uint8_t disable_s4;
    >         @@ -633,6 +634,8 @@ static Property piix4_pm_properties[]

= {

Quoted 1 line
Quoted 1 line

DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState,

s4_val, 2),

Quoted 14 lines
Quoted 1 line

DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support",

    PIIX4PMState,
    >         use_acpi_pci_hotplug, true),
    >         + DEFINE_PROP_BOOL("acpi-pci-hotunplug-enable-bridge",
    PIIX4PMState,
    >         + use_acpi_unplug, true),
    >         DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
    >         acpi_memory_hotplug.is_enabled, true),
    >         DEFINE_PROP_END_OF_LIST(),
    >         diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
    >         index 23c77ee..71b3ac3 100644
    >         --- a/hw/i386/acpi-build.c
    >         +++ b/hw/i386/acpi-build.c
    >         @@ -96,6 +96,7 @@ typedef struct AcpiPmInfo {
Quoted 8 lines
    >         bool s3_disabled;
    >         bool s4_disabled;
    >         bool pcihp_bridge_en;
    >         + bool pcihup_bridge_en;
    >         uint8_t s4_val;
    >         AcpiFadtData fadt;
    >         uint16_t cpu_hp_io_base;
    >         @@ -240,6 +241,9 @@ static void

acpi_get_pm_info(MachineState

Quoted 6 lines
    *machine,
    >         AcpiPmInfo *pm)
    >         pm->pcihp_bridge_en =
    >         object_property_get_bool(obj,
    "acpi-pci-hotplug-with-bridge-support",
    >         NULL);
Quoted 8 lines
    >         + pm->pcihup_bridge_en =
    >         + object_property_get_bool(obj,
    "acpi-pci-hotunplug-enable-bridge",
    >         + NULL);
    >         }
    >
    >         static void acpi_get_misc_info(AcpiMiscInfo *info)
    >         @@ -451,7 +455,8 @@ static void

build_append_pcihp_notify_entry

Quoted 6 lines
    (Aml
    >         *method, int slot)
    >         }
    >
    >         static void build_append_pci_bus_devices(Aml *parent_scope,
    PCIBus
Quoted 8 lines
    >         *bus,
    >         - bool pcihp_bridge_en)
    >         + bool pcihp_bridge_en,
    >         + bool pcihup_bridge_en)
    >         {
    >         Aml *dev, *notify_method = NULL, *method;
    >         QObject *bsel;
    >         @@ -479,11 +484,14 @@ static void

build_append_pci_bus_devices

Quoted 5 lines

(Aml
> *parent_scope, PCIBus *bus,
> dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
> aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
> aml_append(dev, aml_name_decl("_ADR", aml_int(slot <<

16)));

Quoted 15 lines
Quoted 15 lines

- method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
- aml_append(method,
- aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
- );
- aml_append(dev, method);
+ if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+ method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+ aml_append(method,
+ aml_call2("PCEJ", aml_name("BSEL"),
+ aml_name("_SUN"))
+ );
+ aml_append(dev, method);
+ }
aml_append(parent_scope, dev);

Quoted 2 lines
Quoted 2 lines
        build_append_pcihp_notify_entry(notify_method, slot);
        @@ -537,12 +545,14 @@ static void

build_append_pci_bus_devices

Quoted 15 lines
    (Aml
    >         *parent_scope, PCIBus *bus,
    >         /* add _SUN/_EJ0 to make slot hotpluggable */
    >         aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
    >
    >         - method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
    >         - aml_append(method,
    >         - aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
    >         - );
    >         - aml_append(dev, method);
    >         -
    >         + if (pcihup_bridge_en || pci_bus_is_root(bus)) {
    >         + method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
    >         + aml_append(method,
    >         + aml_call2("PCEJ", aml_name("BSEL"),
Quoted 8 lines
    >         + aml_name("_SUN"))
    >         + );
    >         + aml_append(dev, method);
    >         + }
    >         if (bsel) {
    >         build_append_pcihp_notify_entry(notify_method, slot);
    >         }
    >         @@ -553,7 +563,8 @@ static void

build_append_pci_bus_devices(Aml

Quoted 5 lines
Quoted 5 lines

*parent_scope, PCIBus *bus,
*/
PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));

- build_append_pci_bus_devices(dev, sec_bus,

pcihp_bridge_en);

Quoted 1 line
Quoted 1 line

+ build_append_pci_bus_devices(dev, sec_bus,

pcihp_bridge_en,

Quoted 3 lines
Quoted 3 lines
        + pcihup_bridge_en);
        }
        /* slot descriptor has been composed, add it into parent

context

Quoted 3 lines
    */
    >         aml_append(parent_scope, dev);
    >         @@ -2196,7 +2207,8 @@ build_dsdt(GArray *table_data,

BIOSLinker

Quoted 4 lines
Quoted 4 lines
        *linker,
        if (bus) {
        Aml *scope = aml_scope("PCI0");
        /* Scan all PCI buses. Generate tables to support hotplug.

*/

Quoted 1 line
Quoted 1 line

- build_append_pci_bus_devices(scope, bus,

pm->pcihp_bridge_en);

Quoted 1 line
Quoted 1 line

+ build_append_pci_bus_devices(scope, bus,

pm->pcihp_bridge_en,

Quoted 11 lines
Quoted 9 lines
        + pm->pcihup_bridge_en);

        if (TPM_IS_TIS_ISA(tpm)) {
        if (misc->tpm_version == TPM_VERSION_2_0) {
        --
        1.9.4
#8 lore raw
Quoted 3 lines · Ani Sinha

Well there were several discussions in the other thread around how PCIE behaves and how we can't change the slot features without a HW reset. Those were useful inputs.

OK so I'd expect these to be addressed in some way. If we commit to support a feature which has no chance to work on real hardware, we paint ourselves into a tight corner. This kind of thing tends to create maintainance problems down the road. Disabling both hotplug and unplug sounds like a reasonable thing to do, so if there's a need to disable just one of these, commit log needs to do a better job documenting the usecase.

Alternatively, we need to be more creative with achieving what you are trying to do in ways that can work on real hardware.

For example, how about hot-plugging a bridge which doesn't support hotplug itself? Would that happen to make windows do what you want, for both PCI and PCIE? We don't support hotplugging bridges with devices behind them ATM, but that sounds like a useful option.

Also, pcie root ports recently gained ability to disable hotplug, see

	commit 530a0963184e57e71a5b538e9161f115df533e96
	Author: Julia Suvorova <[email protected]>
	Date:   Wed Feb 26 18:46:07 2020 +0100

	    pcie_root_port: Add hotplug disabling option

adding this to pci and pcie bridges sounds very reasonable.

Signature · 1 line
MST
author
#9 lore raw
Quoted 6 lines · Michael S. Tsirkin

For example, how about hot-plugging a bridge which doesn't support hotplug itself?

So now for every device we want to hot plug, we will add a new bridge? Sounds not a scalable and elegant idea.

Quoted 6 lines

Would that happen to make windows
do what you want, for both PCI and PCIE? We don't support hotplugging bridges with devices behind them ATM, but that sounds like a useful option.

Quoted 8 lines

Also, pcie root ports recently gained ability to disable hotplug, see

	commit 530a0963184e57e71a5b538e9161f115df533e96
	Author: Julia Suvorova <[email protected]>
	Date:   Wed Feb 26 18:46:07 2020 +0100

	    pcie_root_port: Add hotplug disabling option

adding this to pci and pcie bridges sounds very reasonable.

This patch uses PCIE native hot plug capability to turn on or turn off per slot hot plug option. This does not enable hot unplugging while allowing devices to be hot plugged on a PCIE port. Besides, PCI-PCI bridges already have an option to disable hot plug capability for all the slots of that bridge. My patch follows that approach.

author
#10 lore raw
In reply to Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin

o if there's a need to disable
just one of these, commit log needs to do a better job documenting the usecase.

The use case is simple. With this feature admins will be able to do what they were forced to do from Windows driver level but now at the bus level. Hence,
(a) They need not have access to the guest VM to change or update windows driver registry settings. They can enable the same setting from admin management console without any access to VM.
(b) It is more robust. No need to mess with driver settings. Incorrect settings can brick guest OS. Also no guest specific knowhow required.
(c) It is more scalable since a single cluster wide setting can be used for all VM power ons and the management plane can take care of the rest automatically. No need to access individual VMs to enforce this.
(d) I am told that the driver level solution does not persist across a reboot.

Ani

#11 lore raw
Quoted 8 lines · Ani Sinha
Quoted 7 lines · Michael S. Tsirkin

o if there's a need to disable
just one of these, commit log needs to do a better job documenting the usecase.

Quoted 7 lines

The use case is simple. With this feature admins will be able to do what they were forced to do from Windows driver level but now at the bus level. Hence,
(a) They need not have access to the guest VM to change or update windows driver registry settings. They can enable the same setting from admin management console without any access to VM.
(b) It is more robust. No need to mess with driver settings. Incorrect settings can brick guest OS. Also no guest specific knowhow required.
(c) It is more scalable since a single cluster wide setting can be used for all VM power ons and the management plane can take care of the rest automatically. No need to access individual VMs to enforce this.
(d) I am told that the driver level solution does not persist across a reboot.

Ani

Looks like disabling both plug and unplug would also address these needs.

Signature · 1 line
MST
author
#12 lore raw
Quoted 19 lines · Michael S. Tsirkin
Quoted 14 lines · Ani Sinha
Quoted 7 lines · Michael S. Tsirkin

o if there's a need to disable
just one of these, commit log needs to do a better job documenting the usecase.

The use case is simple. With this feature admins will be able to do what they were forced to do from Windows driver level but now at the bus level. Hence,
(a) They need not have access to the guest VM to change or update windows driver registry settings. They can enable the same setting from admin management console without any access to VM.
(b) It is more robust. No need to mess with driver settings. Incorrect settings can brick guest OS. Also no guest specific knowhow required.
(c) It is more scalable since a single cluster wide setting can be used for all VM power ons and the management plane can take care of the rest automatically. No need to access individual VMs to enforce this.
(d) I am told that the driver level solution does not persist across a reboot.

Quoted 3 lines
Quoted 1 line

Ani

Looks like disabling both plug and unplug would also address these needs.

No the driver level solution does not prevent hot plugging of devices but blocks just hot unplugging. The solution I am proposing tries to do the same but from the bus/hypervisor level.

Quoted 3 lines
Signature · 1 line
MST
#13 lore raw
Quoted 19 lines · Ani Sinha
Quoted 19 lines · Michael S. Tsirkin
Quoted 14 lines · Ani Sinha
Quoted 7 lines · Michael S. Tsirkin

o if there's a need to disable
just one of these, commit log needs to do a better job documenting the usecase.

The use case is simple. With this feature admins will be able to do what they were forced to do from Windows driver level but now at the bus level. Hence,
(a) They need not have access to the guest VM to change or update windows driver registry settings. They can enable the same setting from admin management console without any access to VM.
(b) It is more robust. No need to mess with driver settings. Incorrect settings can brick guest OS. Also no guest specific knowhow required.
(c) It is more scalable since a single cluster wide setting can be used for all VM power ons and the management plane can take care of the rest automatically. No need to access individual VMs to enforce this.
(d) I am told that the driver level solution does not persist across a reboot.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Ani

Looks like disabling both plug and unplug would also address these needs.

No the driver level solution does not prevent hot plugging of devices but blocks just hot unplugging. The solution I am proposing tries to do the same but from the bus/hypervisor level.

Why does the driver level solution need to prevent just hot unplugging?

Quoted 4 lines
Quoted 4 lines
Signature · 2 lines
-- 
MST
author
#14 lore raw
Quoted 24 lines · Michael S. Tsirkin
Quoted 19 lines · Ani Sinha
Quoted 19 lines · Michael S. Tsirkin
Quoted 14 lines · Ani Sinha
Quoted 7 lines · Michael S. Tsirkin

o if there's a need to disable
just one of these, commit log needs to do a better job documenting the usecase.

The use case is simple. With this feature admins will be able to do what they were forced to do from Windows driver level but now at the bus level. Hence,
(a) They need not have access to the guest VM to change or update windows driver registry settings. They can enable the same setting from admin management console without any access to VM.
(b) It is more robust. No need to mess with driver settings. Incorrect settings can brick guest OS. Also no guest specific knowhow required.
(c) It is more scalable since a single cluster wide setting can be used for all VM power ons and the management plane can take care of the rest automatically. No need to access individual VMs to enforce this.
(d) I am told that the driver level solution does not persist across a reboot.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Ani

Looks like disabling both plug and unplug would also address these needs.

No the driver level solution does not prevent hot plugging of devices but blocks just hot unplugging. The solution I am proposing tries to do the same but from the bus/hypervisor level.

Why does the driver level solution need to prevent just hot unplugging?

Because it not fair to prevent end users from hot plugging new devices when it is the (accidental?) hot unplugging of existing devices which causes issues.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Signature · 2 lines
-- 
MST
author
#16 lore raw
In reply to Michael S. Tsirkin
Quoted 33 lines · Michael S. Tsirkin
Quoted 28 lines · Ani Sinha
Quoted 28 lines · Michael S. Tsirkin
Quoted 23 lines · Ani Sinha
Quoted 22 lines · Michael S. Tsirkin
Quoted 8 lines · Ani Sinha
Quoted 7 lines · Michael S. Tsirkin

o if there's a need to disable
just one of these, commit log needs to do a better job documenting the usecase.

Quoted 7 lines

The use case is simple. With this feature admins will be able to do what they were forced to do from Windows driver level but now at the bus level. Hence,
(a) They need not have access to the guest VM to change or update windows driver registry settings. They can enable the same setting from admin management console without any access to VM.
(b) It is more robust. No need to mess with driver settings. Incorrect settings can brick guest OS. Also no guest specific knowhow required.
(c) It is more scalable since a single cluster wide setting can be used for all VM power ons and the management plane can take care of the rest automatically. No need to access individual VMs to enforce this.
(d) I am told that the driver level solution does not persist across a reboot.

Ani

Looks like disabling both plug and unplug would also address these needs.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

No the driver level solution does not prevent hot plugging of devices but blocks just hot unplugging. The solution I am proposing tries to do the same but from the bus/hypervisor level.

Why does the driver level solution need to prevent just hot unplugging?

Because it not fair to prevent end users from hot plugging new devices when it is the (accidental?) hot unplugging of existing devices which causes issues.

Accidental? So maybe what you need is actually something else then - avoid *removing* the device when it's powered down.

You don’t get it. It is not hypervisor admins who are unplugging it. It is the end users. Even RedHat customers want this feature. See following resources:
https://www.redhat.com/archives/libvir-list/2020-February/msg00110.html
https://bugzilla.redhat.com/show_bug.cgi?id=1802592
https://bugzilla.redhat.com/show_bug.cgi?id=1790899

My approach is much more fine grained than just disable everything approach that we have for q35. For i440fx we can do better than that.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Signature · 2 lines
-- 
MST
#15 lore raw
In reply to Ani Sinha
Quoted 26 lines · Ani Sinha
Quoted 26 lines · Michael S. Tsirkin
Quoted 21 lines · Ani Sinha
Quoted 21 lines · Michael S. Tsirkin
Quoted 15 lines · Ani Sinha
Quoted 7 lines · Michael S. Tsirkin

o if there's a need to disable
just one of these, commit log needs to do a better job documenting the usecase.

The use case is simple. With this feature admins will be able to do what they were forced to do from Windows driver level but now at the bus level. Hence,
(a) They need not have access to the guest VM to change or update windows driver registry settings. They can enable the same setting from admin management console without any access to VM.
(b) It is more robust. No need to mess with driver settings. Incorrect settings can brick guest OS. Also no guest specific knowhow required.
(c) It is more scalable since a single cluster wide setting can be used for all VM power ons and the management plane can take care of the rest automatically. No need to access individual VMs to enforce this.
(d) I am told that the driver level solution does not persist across a reboot.

Ani

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Looks like disabling both plug and unplug would also address these needs.

No the driver level solution does not prevent hot plugging of devices but blocks just hot unplugging. The solution I am proposing tries to do the same but from the bus/hypervisor level.

Why does the driver level solution need to prevent just hot unplugging?

Because it not fair to prevent end users from hot plugging new devices when it is the (accidental?) hot unplugging of existing devices which causes issues.

Accidental? So maybe what you need is actually something else then - avoid *removing* the device when it's powered down.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Signature · 2 lines
-- 
MST
#17 lore raw
In reply to Ani Sinha
Quoted 39 lines · Ani Sinha
Quoted 39 lines · Michael S. Tsirkin
Quoted 33 lines · Ani Sinha
Quoted 24 lines · Michael S. Tsirkin
Quoted 19 lines · Ani Sinha
Quoted 19 lines · Michael S. Tsirkin
Quoted 14 lines · Ani Sinha
Quoted 7 lines · Michael S. Tsirkin

o if there's a need to disable
just one of these, commit log needs to do a better job documenting the usecase.

The use case is simple. With this feature admins will be able to do what they were forced to do from Windows driver level but now at the bus level. Hence,
(a) They need not have access to the guest VM to change or update windows driver registry settings. They can enable the same setting from admin management console without any access to VM.
(b) It is more robust. No need to mess with driver settings. Incorrect settings can brick guest OS. Also no guest specific knowhow required.
(c) It is more scalable since a single cluster wide setting can be used for all VM power ons and the management plane can take care of the rest automatically. No need to access individual VMs to enforce this.
(d) I am told that the driver level solution does not persist across a reboot.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Ani

Looks like disabling both plug and unplug would also address these needs.

No the driver level solution does not prevent hot plugging of devices but blocks just hot unplugging. The solution I am proposing tries to do the same but from the bus/hypervisor level.

Why does the driver level solution need to prevent just hot unplugging?

Because it not fair to prevent end users from hot plugging new devices when it is the (accidental?) hot unplugging of existing devices which causes issues.

Quoted 7 lines
Quoted 2 lines

Accidental? So maybe what you need is actually something else then - avoid *removing* the device when it's powered down.

You don’t get it. It is not hypervisor admins who are unplugging it. It is the end users. Even RedHat customers want this feature. See following resources:
https://www.redhat.com/archives/libvir-list/2020-February/msg00110.html
https://bugzilla.redhat.com/show_bug.cgi?id=1802592
https://bugzilla.redhat.com/show_bug.cgi?id=1790899

That doesn't seem to require that hotplug keeps working.

Quoted 10 lines

My approach is much more fine grained than just disable everything approach that we have for q35. For i440fx we can do better than that.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Signature · 2 lines
-- 
MST
author
#18 lore raw
Quoted 47 lines · Michael S. Tsirkin
Quoted 42 lines · Ani Sinha
Quoted 41 lines · Michael S. Tsirkin
Quoted 26 lines · Ani Sinha
Quoted 26 lines · Michael S. Tsirkin
Quoted 21 lines · Ani Sinha
Quoted 21 lines · Michael S. Tsirkin
Quoted 15 lines · Ani Sinha
Quoted 7 lines · Michael S. Tsirkin

o if there's a need to disable
just one of these, commit log needs to do a better job documenting the usecase.

The use case is simple. With this feature admins will be able to do what they were forced to do from Windows driver level but now at the bus level. Hence,
(a) They need not have access to the guest VM to change or update windows driver registry settings. They can enable the same setting from admin management console without any access to VM.
(b) It is more robust. No need to mess with driver settings. Incorrect settings can brick guest OS. Also no guest specific knowhow required.
(c) It is more scalable since a single cluster wide setting can be used for all VM power ons and the management plane can take care of the rest automatically. No need to access individual VMs to enforce this.
(d) I am told that the driver level solution does not persist across a reboot.

Ani

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Looks like disabling both plug and unplug would also address these needs.

No the driver level solution does not prevent hot plugging of devices but blocks just hot unplugging. The solution I am proposing tries to do the same but from the bus/hypervisor level.

Why does the driver level solution need to prevent just hot unplugging?

Because it not fair to prevent end users from hot plugging new devices when it is the (accidental?) hot unplugging of existing devices which causes issues.

Accidental? So maybe what you need is actually something else then - avoid *removing* the device when it's powered down.

Quoted 6 lines
Quoted 4 lines

You don’t get it. It is not hypervisor admins who are unplugging it. It is the end users. Even RedHat customers want this feature. See following resources:
https://urldefense.proofpoint.com/v2/url?u=https-3A__www.redhat.com_archives_libvir-2Dlist_2020-2DFebruary_msg00110.html&d=DwIFaQ&c=s883GpUCOChKOHiocYtGcg&r=IIUxIyRwG4RGy57y2nvMNYcDkqW-NHozZ2R38VYcg5U&m=Mf70_yU9LUbRFZOy4rYM5N43B_MDbO7SxEMSSJKVaJY&s=KgR1-KlzL-bGr51uY1vupOIgTpTjNAecbuOUIpcuMUs&e=
https://urldefense.proofpoint.com/v2/url?u=https-3A__bugzilla.redhat.com_show-5Fbug.cgi-3Fid-3D1802592&d=DwIFaQ&c=s883GpUCOChKOHiocYtGcg&r=IIUxIyRwG4RGy57y2nvMNYcDkqW-NHozZ2R38VYcg5U&m=Mf70_yU9LUbRFZOy4rYM5N43B_MDbO7SxEMSSJKVaJY&s=KVis9gzVeA7nnGauZpXWm_sEnl_UpsIzSlggwb60Fg8&e=
https://urldefense.proofpoint.com/v2/url?u=https-3A__bugzilla.redhat.com_show-5Fbug.cgi-3Fid-3D1790899&d=DwIFaQ&c=s883GpUCOChKOHiocYtGcg&r=IIUxIyRwG4RGy57y2nvMNYcDkqW-NHozZ2R38VYcg5U&m=Mf70_yU9LUbRFZOy4rYM5N43B_MDbO7SxEMSSJKVaJY&s=Y0K8tiyqpmKeXU245pnhTTAr2e3YSuxxw4BkiDxGwB8&e=

That doesn't seem to require that hotplug keeps working.

Like I said, that is because PCIE limits this at this moment. We can do better than this solution on i440fx. We can be narrower in limiting just hot unplug leaving hot plugging as is. Why should we always go with the least common denominator for all the features? Why do we have to be limited when we can do better?

Quoted 10 lines
Quoted 10 lines

My approach is much more fine grained than just disable everything approach that we have for q35. For i440fx we can do better than that.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Signature · 2 lines
-- 
MST
#19 lore raw
Quoted 52 lines · Ani Sinha
Quoted 52 lines · Michael S. Tsirkin
Quoted 46 lines · Ani Sinha
Quoted 33 lines · Michael S. Tsirkin
Quoted 28 lines · Ani Sinha
Quoted 28 lines · Michael S. Tsirkin
Quoted 23 lines · Ani Sinha
Quoted 22 lines · Michael S. Tsirkin
Quoted 8 lines · Ani Sinha
Quoted 7 lines · Michael S. Tsirkin

o if there's a need to disable
just one of these, commit log needs to do a better job documenting the usecase.

Quoted 7 lines

The use case is simple. With this feature admins will be able to do what they were forced to do from Windows driver level but now at the bus level. Hence,
(a) They need not have access to the guest VM to change or update windows driver registry settings. They can enable the same setting from admin management console without any access to VM.
(b) It is more robust. No need to mess with driver settings. Incorrect settings can brick guest OS. Also no guest specific knowhow required.
(c) It is more scalable since a single cluster wide setting can be used for all VM power ons and the management plane can take care of the rest automatically. No need to access individual VMs to enforce this.
(d) I am told that the driver level solution does not persist across a reboot.

Ani

Looks like disabling both plug and unplug would also address these needs.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

No the driver level solution does not prevent hot plugging of devices but blocks just hot unplugging. The solution I am proposing tries to do the same but from the bus/hypervisor level.

Why does the driver level solution need to prevent just hot unplugging?

Because it not fair to prevent end users from hot plugging new devices when it is the (accidental?) hot unplugging of existing devices which causes issues.

Accidental? So maybe what you need is actually something else then - avoid *removing* the device when it's powered down.

You don’t get it. It is not hypervisor admins who are unplugging it. It is the end users. Even RedHat customers want this feature. See following resources:
https://urldefense.proofpoint.com/v2/url?u=https-3A__www.redhat.com_archives_libvir-2Dlist_2020-2DFebruary_msg00110.html&d=DwIFaQ&c=s883GpUCOChKOHiocYtGcg&r=IIUxIyRwG4RGy57y2nvMNYcDkqW-NHozZ2R38VYcg5U&m=Mf70_yU9LUbRFZOy4rYM5N43B_MDbO7SxEMSSJKVaJY&s=KgR1-KlzL-bGr51uY1vupOIgTpTjNAecbuOUIpcuMUs&e=
https://urldefense.proofpoint.com/v2/url?u=https-3A__bugzilla.redhat.com_show-5Fbug.cgi-3Fid-3D1802592&d=DwIFaQ&c=s883GpUCOChKOHiocYtGcg&r=IIUxIyRwG4RGy57y2nvMNYcDkqW-NHozZ2R38VYcg5U&m=Mf70_yU9LUbRFZOy4rYM5N43B_MDbO7SxEMSSJKVaJY&s=KVis9gzVeA7nnGauZpXWm_sEnl_UpsIzSlggwb60Fg8&e=
https://urldefense.proofpoint.com/v2/url?u=https-3A__bugzilla.redhat.com_show-5Fbug.cgi-3Fid-3D1790899&d=DwIFaQ&c=s883GpUCOChKOHiocYtGcg&r=IIUxIyRwG4RGy57y2nvMNYcDkqW-NHozZ2R38VYcg5U&m=Mf70_yU9LUbRFZOy4rYM5N43B_MDbO7SxEMSSJKVaJY&s=Y0K8tiyqpmKeXU245pnhTTAr2e3YSuxxw4BkiDxGwB8&e=

Quoted 7 lines
Quoted 1 line

That doesn't seem to require that hotplug keeps working.

Like I said, that is because PCIE limits this at this moment. We can do better than this solution on i440fx. We can be narrower in limiting just hot unplug leaving hot plugging as is. Why should we always go with the least common denominator for all the features? Why do we have to be limited when we can do better?

Even if it seems to work for guests now, if we don't stick to emulating capabilities that hardware interfaces provide we can never be sure it will keep working.

Quoted 12 lines
Quoted 11 lines
Quoted 11 lines

My approach is much more fine grained than just disable everything approach that we have for q35. For i440fx we can do better than that.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Signature · 2 lines
-- 
MST
author
#20 lore raw
Quoted 7 lines · Michael S. Tsirkin

Even if it seems to work for guests now, if we don't stick to emulating capabilities that hardware interfaces provide we can never be sure it will keep working.

OS es use ACPI for PCI bridges: https://github.com/qemu/qemu/blob/master/docs/pcie.txt
They use “_EJ0” to detect jot unplug capability: https://uefi.org/sites/default/files/resources/ACPI_3.pdf

6.3.3 _EJx (Eject) These control methods are optional and are supplied for devices that support a software-controlled VCRstyle ejection mechanism or that require an action be performed such as isolation of power/data lines before the device can be removed from the system. To support warm (system is in a sleep state) and hot (system is in S0) removal, an _EJx control method is listed for each sleep state from which the device supports removal, where x is the sleeping state supported. For example, _EJ0 indicates the device supports hot removal; _EJ1–EJ4 indicate the device supports warm removal.

Note that “these control methods are optional” line. If the OS adheres to the spec, it should not expect them to exist all the time.

#22 lore raw
In reply to Ani Sinha
Quoted 4 lines · Ani Sinha
Quoted 4 lines · Michael S. Tsirkin
Quoted 8 lines
Quoted 3 lines

Even if it seems to work for guests now, if we don't stick to emulating capabilities that hardware interfaces provide we can never be sure it will keep working.

OS es use ACPI for PCI bridges: https://github.com/qemu/qemu/blob/master/docs/pcie.txt
They use “_EJ0” to detect jot unplug capability: https://uefi.org/sites/default/files/resources/ACPI_3.pdf

6.3.3 _EJx (Eject) These control methods are optional and are supplied for devices that support a software-controlled VCRstyle ejection mechanism or that require an action be performed such as isolation of power/data lines before the device can be removed from the system. To support warm (system is in a sleep state) and hot (system is in S0) removal, an _EJx control method is listed for each sleep state from which the device supports removal, where x is the sleeping state supported. For example, _EJ0 indicates the device supports hot removal; _EJ1–EJ4 indicate the device supports warm removal.

Yes. So if there's no _EJx then it's reasonable to assume you can't isolate the slot, and so no hot-plug will happen either.

Quoted 3 lines

Note that “these control methods are optional” line. If the OS adheres to the spec, it should not expect them to exist all the time.

Signature · 1 line
MST
author
#23 lore raw
Quoted 13 lines · Michael S. Tsirkin
Quoted 8 lines · Ani Sinha
Quoted 7 lines · Michael S. Tsirkin

Even if it seems to work for guests now, if we don't stick to emulating capabilities that hardware interfaces provide we can never be sure it will keep working.

Quoted 7 lines
Quoted 4 lines

OS es use ACPI for PCI bridges: https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_qemu_qemu_blob_master_docs_pcie.txt&d=DwIFaQ&c=s883GpUCOChKOHiocYtGcg&r=IIUxIyRwG4RGy57y2nvMNYcDkqW-NHozZ2R38VYcg5U&m=9AnuR62iRsUnmV9ggkS_lqen67etHeCjATFLwCJWxQs&s=As__N9BXf0DTSZkD4cxaQsTeg0exh5GSPqkFSh7fxRk&e=
They use “_EJ0” to detect jot unplug capability: https://urldefense.proofpoint.com/v2/url?u=https-3A__uefi.org_sites_default_files_resources_ACPI-5F3.pdf&d=DwIFaQ&c=s883GpUCOChKOHiocYtGcg&r=IIUxIyRwG4RGy57y2nvMNYcDkqW-NHozZ2R38VYcg5U&m=9AnuR62iRsUnmV9ggkS_lqen67etHeCjATFLwCJWxQs&s=SDgOhKGpnlzfbvAOFl2m9a-tdPZEUcCwKWsgkVDafyM&e=

6.3.3 _EJx (Eject) These control methods are optional and are supplied for devices that support a software-controlled VCRstyle ejection mechanism or that require an action be performed such as isolation of power/data lines before the device can be removed from the system. To support warm (system is in a sleep state) and hot (system is in S0) removal, an _EJx control method is listed for each sleep state from which the device supports removal, where x is the sleeping state supported. For example, _EJ0 indicates the device supports hot removal; _EJ1–EJ4 indicate the device supports warm removal.

Yes. So if there's no _EJx then it's reasonable to assume you can't isolate the slot, and so no hot-plug will happen either.

Where are you getting that? This isn’t true. “_SUN” is used to detect the slot unique number. Windows does allow hot plugging on the bridge on which EJ0 has been turned off.

Quoted 10 lines
Quoted 4 lines

Note that “these control methods are optional” line. If the OS adheres to the spec, it should not expect them to exist all the time.

Signature · 1 line
MST
#24 lore raw
Quoted 16 lines · Ani Sinha
Quoted 16 lines · Michael S. Tsirkin
Quoted 11 lines · Ani Sinha
Quoted 7 lines · Michael S. Tsirkin

Even if it seems to work for guests now, if we don't stick to emulating capabilities that hardware interfaces provide we can never be sure it will keep working.

OS es use ACPI for PCI bridges: https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_qemu_qemu_blob_master_docs_pcie.txt&d=DwIFaQ&c=s883GpUCOChKOHiocYtGcg&r=IIUxIyRwG4RGy57y2nvMNYcDkqW-NHozZ2R38VYcg5U&m=9AnuR62iRsUnmV9ggkS_lqen67etHeCjATFLwCJWxQs&s=As__N9BXf0DTSZkD4cxaQsTeg0exh5GSPqkFSh7fxRk&e=
They use “_EJ0” to detect jot unplug capability: https://urldefense.proofpoint.com/v2/url?u=https-3A__uefi.org_sites_default_files_resources_ACPI-5F3.pdf&d=DwIFaQ&c=s883GpUCOChKOHiocYtGcg&r=IIUxIyRwG4RGy57y2nvMNYcDkqW-NHozZ2R38VYcg5U&m=9AnuR62iRsUnmV9ggkS_lqen67etHeCjATFLwCJWxQs&s=SDgOhKGpnlzfbvAOFl2m9a-tdPZEUcCwKWsgkVDafyM&e=

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

6.3.3 _EJx (Eject) These control methods are optional and are supplied for devices that support a software-controlled VCRstyle ejection mechanism or that require an action be performed such as isolation of power/data lines before the device can be removed from the system. To support warm (system is in a sleep state) and hot (system is in S0) removal, an _EJx control method is listed for each sleep state from which the device supports removal, where x is the sleeping state supported. For example, _EJ0 indicates the device supports hot removal; _EJ1–EJ4 indicate the device supports warm removal.

Yes. So if there's no _EJx then it's reasonable to assume you can't isolate the slot, and so no hot-plug will happen either.

Where are you getting that?

It's well known. For example, the pci hot-plug specification, version 1.1, states:

1.6 Asssumptions

...

1.6.2 Orderly Removal and Insertion

...

Furthermore, PCI add-in cards are not generally designed to be connected to a slot that has power applied. Therefore, the operating-system vendor and Platform vendor define a sequence of user actions and system behavior that guarantees that power is always removed from a slot before a card is inserted.

Inserting or removing an add-in card without following the proper sequence leads to unpredictable results, including data corruption, abnormal termination of the operating system, or damage to card or Platform hardware. Unless otherwise stated, it is assumed throughout the remainder of this specification that the user always follows the proper removal and insertion sequence.

...

2.1 System Components

...

The physical
insertion or removal must not occur until the system software has:
• Quiesced any operating system services or drivers using the add-in card
• Isolated and powered down the slot
• Indicated to the user that it is ready
If an add-in card is inserted or removed without following the proper sequence, this is considered an improper operation and error conditions and other unexpected events are possible, including data corruption and hardware damage.

and so on.

Quoted 1 line

This isn’t true. “_SUN” is used to detect the slot unique number.

That's just enumeration.

Quoted 1 line

Windows does allow hot plugging on the bridge on which EJ0 has been turned off.

Given no real or virtual hardware that does that, there's no guarantee that I can see that it will keep supporting that in future versions.

Quoted 11 lines
Quoted 10 lines
Quoted 4 lines

Note that “these control methods are optional” line. If the OS adheres to the spec, it should not expect them to exist all the time.

Signature · 1 line
MST
author
#25 lore raw
Quoted 45 lines
Quoted 6 lines
Quoted 4 lines

Yes. So if there's no _EJx then it's reasonable to assume you can't isolate the slot, and so no hot-plug will happen either.

Where are you getting that?

It's well known. For example, the pci hot-plug specification, version 1.1, states:

1.6 Asssumptions

...

1.6.2 Orderly Removal and Insertion

...

Furthermore, PCI add-in cards are not generally designed to be connected to a slot that has power applied. Therefore, the operating-system vendor and Platform vendor define a sequence of user actions and system behavior that guarantees that power is always removed from a slot before a card is inserted.

Inserting or removing an add-in card without following the proper sequence leads to unpredictable results, including data corruption, abnormal termination of the operating system, or damage to card or Platform hardware. Unless otherwise stated, it is assumed throughout the remainder of this specification that the user always follows the proper removal and insertion sequence.

...

2.1 System Components

...

The physical
insertion or removal must not occur until the system software has:
• Quiesced any operating system services or drivers using the add-in card
• Isolated and powered down the slot
• Indicated to the user that it is ready
If an add-in card is inserted or removed without following the proper sequence, this is considered an improper operation and error conditions and other unexpected events are possible, including data corruption and hardware damage.

Quoted 1 line

and so on.

What does all of this got to so with ACPI hot plug spec which I showed you where it clearly says that availability of EJ0 is optional? How are we violating the spec? I also gave evidence of Linux detecting it at runtime and Windows also seems to allow it.

Quoted 10 lines
Quoted 3 lines

This isn’t true. “_SUN” is used to detect the slot unique number.

That's just enumeration.

Quoted 1 line

Windows does allow hot plugging on the bridge on which EJ0 has been turned off.

Given no real or virtual hardware that does that, there's no guarantee that I can see that it will keep supporting that in future versions.

You do not know that. I gave evidence that we are not violating the spec.

If RedHat had not moved to q35 and they had come up with this patch for i440fx, would you have given this much biased pushback? I seriously doubt it.

#26 lore raw
In reply to Ani Sinha

.

Accidental? So maybe what you need is actually something else then -

avoid *removing* the device when it's powered down.

You don’t get it. It is not hypervisor admins who are unplugging it. It is the end users. Even RedHat customers want this feature. See following resources:
https://www.redhat.com/archives/libvir-list/2020-February/msg00110.html
https://bugzilla.redhat.com/show_bug.cgi?id=1802592
https://bugzilla.redhat.com/show_bug.cgi?id=1790899

My approach is much more fine grained than just disable everything approach that we have for q35. For i440fx we can do better than that

By the way, here's another glaring feature disparity between i440fx and q35 which we perhaps did not debate with as much fervour and push back as we debated here. When we implemented per slot hotplug disable for PCIE, we ignored to implement the same per slot capability for conventional PCI. Why was feature disparity across two machine types wasn't so much of an issue then?

Signature · 1 line
MST
#31 lore raw
In reply to Ani Sinha
Quoted 69 lines · On Tue, 28 Apr 2020 10:16:52 +0000 Ani Sinha <[email protected]> wrote:

A new option "use_acpi_unplug" is introduced for PIIX which will selectively only disable hot unplugging of both hot plugged and cold plugged PCI devices on non-root PCI buses. This will prevent hot unplugging of devices from Windows based guests from system tray but will not prevent devices from being hot plugged into the guest.

It has been tested on Windows guests.

---
 hw/acpi/piix4.c      |  3 +++
 hw/i386/acpi-build.c | 40 ++++++++++++++++++++++++++--------------
 2 files changed, 29 insertions(+), 14 deletions(-)
hw/acpi/piix4.c +3 -0
index 964d6f5..59fa707 100644
@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {
 
     AcpiPciHpState acpi_pci_hotplug;
     bool use_acpi_pci_hotplug;
+    bool use_acpi_unplug;
 
     uint8_t disable_s3;
     uint8_t disable_s4;
@@ -633,6 +634,8 @@ static Property piix4_pm_properties[] = {
     DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
     DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState,
                      use_acpi_pci_hotplug, true),
+    DEFINE_PROP_BOOL("acpi-pci-hotunplug-enable-bridge", PIIX4PMState,
+                     use_acpi_unplug, true),
     DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
                      acpi_memory_hotplug.is_enabled, true),
     DEFINE_PROP_END_OF_LIST(),
hw/i386/acpi-build.c +6 -1
index 23c77ee..71b3ac3 100644
@@ -96,6 +96,7 @@ typedef struct AcpiPmInfo {
     bool s3_disabled;
     bool s4_disabled;
     bool pcihp_bridge_en;
+    bool pcihup_bridge_en;
     uint8_t s4_val;
     AcpiFadtData fadt;
     uint16_t cpu_hp_io_base;
@@ -240,6 +241,9 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
     pm->pcihp_bridge_en =
         object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-support",
                                  NULL);
+    pm->pcihup_bridge_en =
+        object_property_get_bool(obj, "acpi-pci-hotunplug-enable-bridge",
+                                 NULL);
 }
 
 static void acpi_get_misc_info(AcpiMiscInfo *info)
@@ -451,7 +455,8 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)
 }
 
 static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
-                                         bool pcihp_bridge_en)
+                                         bool pcihp_bridge_en,
+                                         bool pcihup_bridge_en)
 {
     Aml *dev, *notify_method = NULL, *method;
     QObject *bsel;

hw/i386/acpi-build.c static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, · line 487

Quoted 9 lines
hw/i386/acpi-build.c +1 -5
@@ -479,11 +484,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
                 dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
                 aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
                 aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
-                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-                aml_append(method,
-                    aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-                );
-                aml_append(dev, method);
+                if (pcihup_bridge_en || pci_bus_is_root(bus)) {

so you are keeping unplug anyway in case of host bridge, so user will see eject icon if device is in root bus?

Other thing about this patch is that it only partially disable hotplug, I'd rather do it the way hardware does i.e. full hotplug or no hotplug at all. (like the other hypervisors have done it, to workaround this Windows 'feature')

which is possible is one puts device on pci bridge without hotplug, i.e.

-global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off

that of cause leaves apci hotplug on and as you noticed earlier Windows will offer to eject any device on root bus including directly attached bridges. And currently there is no way to disable that.

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=off -device e1000,bus=pci.1,addr=01,id=netdev1

-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

3) looks like SHPC kicks in, but it still needs to some bridge description in ACPI that acpi-pci-hotplug-with-bridge-support provides, probably with this you can individually flip hotplug on colplugged bridges using 'shpc' property (requires Vista or newer, tested win10).

This needs some investigation so we could remove unsed AML and IO ports, but I'm not really interested in PCI stuff. So if 1+2 works for you, I'll post formal patches. If #3 is required feel free to use this patch as a starting base to make it complete.

-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=on -device e1000,bus=pci.1,addr=01,id=netdev1

---

hw/acpi/piix4.c +10 -5
index 964d6f5990..5f05b2cb87 100644
@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {
 
     AcpiPciHpState acpi_pci_hotplug;
     bool use_acpi_pci_hotplug;
+    bool use_acpi_pci_hotplug_on_bridges;
 
     uint8_t disable_s3;
     uint8_t disable_s4;
@@ -207,13 +208,13 @@ static const VMStateDescription vmstate_pci_status = {
 static bool vmstate_test_use_acpi_pci_hotplug(void *opaque, int version_id)
 {
     PIIX4PMState *s = opaque;
-    return s->use_acpi_pci_hotplug;
+    return s->use_acpi_pci_hotplug_on_bridges;
 }
 
 static bool vmstate_test_no_use_acpi_pci_hotplug(void *opaque, int version_id)
 {
     PIIX4PMState *s = opaque;
-    return !s->use_acpi_pci_hotplug;
+    return !s->use_acpi_pci_hotplug_on_bridges;
 }
 
 static bool vmstate_test_use_memhp(void *opaque)
@@ -505,7 +506,6 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)
 
     piix4_acpi_system_hot_add_init(pci_address_space_io(dev),
                                    pci_get_bus(dev), s);
-    qbus_set_hotplug_handler(BUS(pci_get_bus(dev)), OBJECT(s), &error_abort);
 
     piix4_pm_add_propeties(s);
 }
@@ -528,7 +528,7 @@ I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
     s->smi_irq = smi_irq;
     s->smm_enabled = smm_enabled;
     if (xen_enabled()) {
-        s->use_acpi_pci_hotplug = false;
+        s->use_acpi_pci_hotplug_on_bridges = false;
     }
 
     qdev_init_nofail(dev);
@@ -593,7 +593,10 @@ 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_pci_hotplug);
+                    s->use_acpi_pci_hotplug_on_bridges);
+    if (s->use_acpi_pci_hotplug) {
+        qbus_set_hotplug_handler(BUS(bus), OBJECT(s), &error_abort);
+    }
 
     s->cpu_hotplug_legacy = true;
     object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy",
@@ -632,6 +635,8 @@ static Property piix4_pm_properties[] = {
     DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 0),
     DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
     DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState,
+                     use_acpi_pci_hotplug_on_bridges, true),
+    DEFINE_PROP_BOOL("acpi-pci-hotplug", PIIX4PMState,
                      use_acpi_pci_hotplug, true),
     DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
                      acpi_memory_hotplug.is_enabled, true),

---

Quoted 51 lines
hw/i386/acpi-build.c +19 -8
+                    method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                    aml_append(method,
+                               aml_call2("PCEJ", aml_name("BSEL"),
+                                         aml_name("_SUN"))
+                        );
+                    aml_append(dev, method);
+                }
                 aml_append(parent_scope, dev);
 
                 build_append_pcihp_notify_entry(notify_method, slot);
@@ -537,12 +545,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
             /* add _SUN/_EJ0 to make slot hotpluggable  */
             aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
 
-            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-            aml_append(method,
-                aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-            );
-            aml_append(dev, method);
-
+            if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                aml_append(method,
+                           aml_call2("PCEJ", aml_name("BSEL"),
+                                     aml_name("_SUN"))
+                    );
+                aml_append(dev, method);
+            }
             if (bsel) {
                 build_append_pcihp_notify_entry(notify_method, slot);
             }
@@ -553,7 +563,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
              */
             PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));
 
-            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
+            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en,
+                                         pcihup_bridge_en);
         }
         /* slot descriptor has been composed, add it into parent context */
         aml_append(parent_scope, dev);
@@ -2196,7 +2207,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         if (bus) {
             Aml *scope = aml_scope("PCI0");
             /* Scan all PCI buses. Generate tables to support hotplug. */
-            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
+            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en,
+                                         pm->pcihup_bridge_en);
 
             if (TPM_IS_TIS_ISA(tpm)) {
                 if (misc->tpm_version == TPM_VERSION_2_0) {
author
#32 lore raw
Quoted 17 lines · Igor Mammedov
Quoted 14 lines

static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,

(quoted diff) +2 -1
-                                         bool pcihp_bridge_en)
+                                         bool pcihp_bridge_en,
+                                         bool pcihup_bridge_en)
{
    Aml *dev, *notify_method = NULL, *method;
    QObject *bsel;
(quoted diff) +0 -1
@@ -479,11 +484,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
                dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
                aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
                aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
-                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
Quoted 8 lines

Review static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, · line 487

Quoted 5 lines
(quoted diff) +1 -4
-                aml_append(method,
-                    aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-                );
-                aml_append(dev, method);
+                if (pcihup_bridge_en || pci_bus_is_root(bus)) {

so you are keeping unplug anyway in case of host bridge, so user will see eject icon if device is in root bus?

Yes, the user will see the eject option from system tray for devices plugged into the root bus. The idea is that whereas we disallow some devices from hot-unplugging, other devices which are plugged into the root bus can be hot plugged and unplugged. This leaves some room for flexibility across devices and VMs.

Quoted 4 lines

Other thing about this patch is that it only partially disable hotplug, I'd rather do it the way hardware does i.e. full hotplug or no hotplug at all. (like the other hypervisors have done it, to workaround this Windows 'feature’)

So the main objection against this patch is that with this option enabled, we are violating what real HW does and since we want emulated HW to mimic real HW behavior as close as possible, we are breaking this assumption. Am I correct?

Quoted 4 lines

which is possible is one puts device on pci bridge without hotplug, i.e.

-global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off

right.

Quoted 4 lines

that of cause leaves apci hotplug on and as you noticed earlier Windows will offer to eject any device on root bus including directly attached bridges. And currently there is no way to disable that.

Right. However, I have tested that even though the PCI bridge shows up as a device in the “safely remove HW” option in the system tray, trying to eject a PCI bridge with devices attached will result in failure with the error message “this device is currently in use”.

Review

Quoted 10 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all

(quoted diff) +0 -2
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=off -device e1000,bus=pci.1,addr=01,id=netdev1
 
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off -device pci-bridge,chassis_nr=1,shpc=doesnt_matter  -device e1000,bus=pci.1,addr=01,id=netdev1

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

(b) Failing above, having a global option to disable all hot plug, including the 32 slots of the root bus would be good. However, this does not give us the flexibility we have with PCIE (that is, to hot plug a device, we can always plug it to a slot with hot plug enabled).

Thanks for looking into my requirement more seriously, ani

Quoted 134 lines

3) looks like SHPC kicks in, but it still needs to some bridge description in ACPI that acpi-pci-hotplug-with-bridge-support provides, probably with this you can individually flip hotplug on colplugged bridges using 'shpc' property (requires Vista or newer, tested win10).

This needs some investigation so we could remove unsed AML and IO ports, but I'm not really interested in PCI stuff. So if 1+2 works for you, I'll post formal patches. If #3 is required feel free to use this patch as a starting base to make it complete.

(quoted diff) +0 -2
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=on -device e1000,bus=pci.1,addr=01,id=netdev1
 
---
hw/acpi/piix4.c +10 -6
index 964d6f5990..5f05b2cb87 100644
@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {
 
    AcpiPciHpState acpi_pci_hotplug;
    bool use_acpi_pci_hotplug;
+    bool use_acpi_pci_hotplug_on_bridges;
 
    uint8_t disable_s3;
    uint8_t disable_s4;
@@ -207,13 +208,13 @@ static const VMStateDescription vmstate_pci_status = {
 static bool vmstate_test_use_acpi_pci_hotplug(void *opaque, int version_id)
 {
    PIIX4PMState *s = opaque;
-    return s->use_acpi_pci_hotplug;
+    return s->use_acpi_pci_hotplug_on_bridges;
 }
 
 static bool vmstate_test_no_use_acpi_pci_hotplug(void *opaque, int version_id)
 {
    PIIX4PMState *s = opaque;
-    return !s->use_acpi_pci_hotplug;
+    return !s->use_acpi_pci_hotplug_on_bridges;
 }
 
 static bool vmstate_test_use_memhp(void *opaque)
@@ -505,7 +506,6 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)
 
    piix4_acpi_system_hot_add_init(pci_address_space_io(dev),
                                   pci_get_bus(dev), s);
-    qbus_set_hotplug_handler(BUS(pci_get_bus(dev)), OBJECT(s), &error_abort);
 
    piix4_pm_add_propeties(s);
 }
@@ -528,7 +528,7 @@ I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
    s->smi_irq = smi_irq;
    s->smm_enabled = smm_enabled;
    if (xen_enabled()) {
-        s->use_acpi_pci_hotplug = false;
+        s->use_acpi_pci_hotplug_on_bridges = false;
    }
 
    qdev_init_nofail(dev);
@@ -593,7 +593,10 @@ 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_pci_hotplug);
+                    s->use_acpi_pci_hotplug_on_bridges);
+    if (s->use_acpi_pci_hotplug) {
+        qbus_set_hotplug_handler(BUS(bus), OBJECT(s), &error_abort);
+    }
 
    s->cpu_hotplug_legacy = true;
    object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy",
@@ -632,6 +635,8 @@ static Property piix4_pm_properties[] = {
    DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 0),
    DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
    DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState,
+                     use_acpi_pci_hotplug_on_bridges, true),
+    DEFINE_PROP_BOOL("acpi-pci-hotplug", PIIX4PMState,
                     use_acpi_pci_hotplug, true),
    DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
                     acpi_memory_hotplug.is_enabled, true),
 
---
Quoted 53 lines
(quoted diff) +19 -8
+                    method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                    aml_append(method,
+                               aml_call2("PCEJ", aml_name("BSEL"),
+                                         aml_name("_SUN"))
+                        );
+                    aml_append(dev, method);
+                }
                aml_append(parent_scope, dev);
 
                build_append_pcihp_notify_entry(notify_method, slot);
@@ -537,12 +545,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
            /* add _SUN/_EJ0 to make slot hotpluggable  */
            aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
 
-            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-            aml_append(method,
-                aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-            );
-            aml_append(dev, method);
-
+            if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                aml_append(method,
+                           aml_call2("PCEJ", aml_name("BSEL"),
+                                     aml_name("_SUN"))
+                    );
+                aml_append(dev, method);
+            }
            if (bsel) {
                build_append_pcihp_notify_entry(notify_method, slot);
            }
@@ -553,7 +563,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
             */
            PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));
 
-            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
+            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en,
+                                         pcihup_bridge_en);
        }
        /* slot descriptor has been composed, add it into parent context */
        aml_append(parent_scope, dev);
@@ -2196,7 +2207,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
        if (bus) {
            Aml *scope = aml_scope("PCI0");
            /* Scan all PCI buses. Generate tables to support hotplug. */
-            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
+            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en,
+                                         pm->pcihup_bridge_en);
 
            if (TPM_IS_TIS_ISA(tpm)) {
                if (misc->tpm_version == TPM_VERSION_2_0) {
#33 lore raw
Quoted 24 lines · On Tue, 12 May 2020 05:26:47 +0000 Ani Sinha <[email protected]> wrote:
Quoted 15 lines · Igor Mammedov
Quoted 14 lines

static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,

(quoted diff) +2 -1
-                                         bool pcihp_bridge_en)
+                                         bool pcihp_bridge_en,
+                                         bool pcihup_bridge_en)
{
    Aml *dev, *notify_method = NULL, *method;
    QObject *bsel;
(quoted diff) +0 -1
@@ -479,11 +484,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
                dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
                aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
                aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
-                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
Quoted 8 lines

Review static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus, · line 487

Quoted 5 lines
(quoted diff) +1 -4
-                aml_append(method,
-                    aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-                );
-                aml_append(dev, method);
+                if (pcihup_bridge_en || pci_bus_is_root(bus)) {  

so you are keeping unplug anyway in case of host bridge, so user will see eject icon if device is in root bus?

Quoted 8 lines

Yes, the user will see the eject option from system tray for devices plugged into the root bus. The idea is that whereas we disallow some devices from hot-unplugging, other devices which are plugged into the root bus can be hot plugged and unplugged. This leaves some room for flexibility across devices and VMs.

Quoted 4 lines

Other thing about this patch is that it only partially disable hotplug, I'd rather do it the way hardware does i.e. full hotplug or no hotplug at all. (like the other hypervisors have done it, to workaround this Windows 'feature’)

So the main objection against this patch is that with this option enabled, we are violating what real HW does and since we want emulated HW to mimic real HW behavior as close as possible, we are breaking this assumption. Am I correct?

Yep, from the very begining I was suggesting to use global hotplug/no hotplug switch.

Quoted 21 lines
Quoted 3 lines

which is possible is one puts device on pci bridge without hotplug, i.e.

-global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off

right.

Quoted 4 lines

that of cause leaves apci hotplug on and as you noticed earlier Windows will offer to eject any device on root bus including directly attached bridges. And currently there is no way to disable that.

Right. However, I have tested that even though the PCI bridge shows up as a device in the “safely remove HW” option in the system tray, trying to eject a PCI bridge with devices attached will result in failure with the error message “this device is currently in use”.

Quoted 8 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=off -device e1000,bus=pci.1,addr=01,id=netdev1

Quoted 6 lines
Quoted 1 line

-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

I don't think it's possible to have per slot hotplug on conventional PCI hardware. it's per bridge property.

Quoted 1 line

(b) Failing above, having a global option to disable all hot plug, including the 32 slots of the root bus would be good. However, this does not give us the flexibility we have with PCIE (that is, to hot plug a device, we can always plug it to a slot with hot plug enabled).

sounds fine to me, at least it will address problem.
Can you post a patch to that effect please?
/It should disable all AML related to hotplug and related hadware code/

As for a way to make it more felixible, theoretically it should be possible to use SHPC on bridges. So one could have a bridge with SHPC enabled to allow hotplug devices during runtime. It's rummored that SHPC should be supported since Vista, but it doesn't work
(at least on QEMU with Windows 10 guest and I don't have a real machine to verify that). That's something to explore (perhaps QEMU doesn't implement it completely so Windows doesn't see it).

Quoted 15 lines

Thanks for looking into my requirement more seriously, ani

Quoted 10 lines

3) looks like SHPC kicks in, but it still needs to some bridge description in ACPI that acpi-pci-hotplug-with-bridge-support provides, probably with this you can individually flip hotplug on colplugged bridges using 'shpc' property (requires Vista or newer, tested win10).

This needs some investigation so we could remove unsed AML and IO ports, but I'm not really interested in PCI stuff. So if 1+2 works for you, I'll post formal patches. If #3 is required feel free to use this patch as a starting base to make it complete.

-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=on -device e1000,bus=pci.1,addr=01,id=netdev1

above is a bug in patch below, look like ,shpc=on tricks code to belive that ACPI hotplug is present and add AML for it.

Quoted 125 lines
Quoted 124 lines

---

hw/acpi/piix4.c +10 -6
index 964d6f5990..5f05b2cb87 100644
@@ -78,6 +78,7 @@ typedef struct PIIX4PMState {
 
    AcpiPciHpState acpi_pci_hotplug;
    bool use_acpi_pci_hotplug;
+    bool use_acpi_pci_hotplug_on_bridges;
 
    uint8_t disable_s3;
    uint8_t disable_s4;
@@ -207,13 +208,13 @@ static const VMStateDescription vmstate_pci_status = {
 static bool vmstate_test_use_acpi_pci_hotplug(void *opaque, int version_id)
 {
    PIIX4PMState *s = opaque;
-    return s->use_acpi_pci_hotplug;
+    return s->use_acpi_pci_hotplug_on_bridges;
 }
 
 static bool vmstate_test_no_use_acpi_pci_hotplug(void *opaque, int version_id)
 {
    PIIX4PMState *s = opaque;
-    return !s->use_acpi_pci_hotplug;
+    return !s->use_acpi_pci_hotplug_on_bridges;
 }
 
 static bool vmstate_test_use_memhp(void *opaque)
@@ -505,7 +506,6 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)
 
    piix4_acpi_system_hot_add_init(pci_address_space_io(dev),
                                   pci_get_bus(dev), s);
-    qbus_set_hotplug_handler(BUS(pci_get_bus(dev)), OBJECT(s), &error_abort);
 
    piix4_pm_add_propeties(s);
 }
@@ -528,7 +528,7 @@ I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
    s->smi_irq = smi_irq;
    s->smm_enabled = smm_enabled;
    if (xen_enabled()) {
-        s->use_acpi_pci_hotplug = false;
+        s->use_acpi_pci_hotplug_on_bridges = false;
    }
 
    qdev_init_nofail(dev);
@@ -593,7 +593,10 @@ 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_pci_hotplug);
+                    s->use_acpi_pci_hotplug_on_bridges);
+    if (s->use_acpi_pci_hotplug) {
+        qbus_set_hotplug_handler(BUS(bus), OBJECT(s), &error_abort);
+    }
 
    s->cpu_hotplug_legacy = true;
    object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy",
@@ -632,6 +635,8 @@ static Property piix4_pm_properties[] = {
    DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 0),
    DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
    DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState,
+                     use_acpi_pci_hotplug_on_bridges, true),
+    DEFINE_PROP_BOOL("acpi-pci-hotplug", PIIX4PMState,
                     use_acpi_pci_hotplug, true),
    DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState,
                     acpi_memory_hotplug.is_enabled, true),
 
---
Quoted 53 lines
(quoted diff) +19 -8
+                    method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                    aml_append(method,
+                               aml_call2("PCEJ", aml_name("BSEL"),
+                                         aml_name("_SUN"))
+                        );
+                    aml_append(dev, method);
+                }
                aml_append(parent_scope, dev);
 
                build_append_pcihp_notify_entry(notify_method, slot);
@@ -537,12 +545,14 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
            /* add _SUN/_EJ0 to make slot hotpluggable  */
            aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
 
-            method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
-            aml_append(method,
-                aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
-            );
-            aml_append(dev, method);
-
+            if (pcihup_bridge_en || pci_bus_is_root(bus)) {
+                method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
+                aml_append(method,
+                           aml_call2("PCEJ", aml_name("BSEL"),
+                                     aml_name("_SUN"))
+                    );
+                aml_append(dev, method);
+            }
            if (bsel) {
                build_append_pcihp_notify_entry(notify_method, slot);
            }
@@ -553,7 +563,8 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
             */
            PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));
 
-            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
+            build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en,
+                                         pcihup_bridge_en);
        }
        /* slot descriptor has been composed, add it into parent context */
        aml_append(parent_scope, dev);
@@ -2196,7 +2207,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
        if (bus) {
            Aml *scope = aml_scope("PCI0");
            /* Scan all PCI buses. Generate tables to support hotplug. */
-            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en);
+            build_append_pci_bus_devices(scope, bus, pm->pcihp_bridge_en,
+                                         pm->pcihup_bridge_en);
 
            if (TPM_IS_TIS_ISA(tpm)) {
                if (misc->tpm_version == TPM_VERSION_2_0) {  
author
#34 lore raw
Quoted 18 lines · Igor Mammedov
Quoted 15 lines

Review

Quoted 12 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all

(quoted diff) +0 -2
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=off -device e1000,bus=pci.1,addr=01,id=netdev1
 
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off -device pci-bridge,chassis_nr=1,shpc=doesnt_matter  -device e1000,bus=pci.1,addr=01,id=netdev1  

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

Quoted 5 lines
Quoted 2 lines

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

I don't think it's possible to have per slot hotplug on conventional PCI hardware. it's per bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

/* When hotplug for bridges is enabled, bridges are
* described in ACPI separately (see build_pci_bus_end).
* In this case they aren't themselves hot-pluggable.
* Hotplugged bridges *are* hot-pluggable.
*/

Quoted 7 lines
Quoted 3 lines

(b) Failing above, having a global option to disable all hot plug, including the 32 slots of the root bus would be good. However, this does not give us the flexibility we have with PCIE (that is, to hot plug a device, we can always plug it to a slot with hot plug enabled).

sounds fine to me, at least it will address problem.
Can you post a patch to that effect please?
/It should disable all AML related to hotplug and related hadware code/

I have tried a patch and sent it.

#35 lore raw
Quoted 50 lines · On Fri, 15 May 2020 12:13:53 +0000 Ani Sinha <[email protected]> wrote:
Quoted 39 lines
Quoted 24 lines · Igor Mammedov
Quoted 16 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=off -device e1000,bus=pci.1,addr=01,id=netdev1

Quoted 4 lines

-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

Quoted 12 lines

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

Quoted 2 lines

I don't think it's possible to have per slot hotplug on conventional PCI hardware. it's per bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

Quoted 8 lines

/* When hotplug for bridges is enabled, bridges are

* described in ACPI separately (see build_pci_bus_end).

* In this case they aren't themselves hot-pluggable.

* Hotplugged bridges *are* hot-pluggable.
*/

thinking some more on this topic, it seems that with ACPI hotplug we already have implicit non-hotpluggble slot (slot with bridge) while the rest are staying hotpluggable.

So my question is: if it's acceptable to add 'PCIDevice::hotpluggable" property to all PCI devices so that user / libvirt could set it to false in case they do not want coldplugged device be considered as hotpluggable? (this way other devices could be treated the same way as bridges)

[...]

#36 lore raw
Quoted 66 lines · Igor Mammedow
Quoted 50 lines · On Fri, 15 May 2020 12:13:53 +0000 Ani Sinha <[email protected]> wrote:
Quoted 39 lines
Quoted 24 lines · Igor Mammedov
Quoted 16 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=off -device e1000,bus=pci.1,addr=01,id=netdev1

Quoted 4 lines

-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

Quoted 12 lines

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

Quoted 2 lines

I don't think it's possible to have per slot hotplug on conventional PCI hardware. it's per bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

Quoted 8 lines

/* When hotplug for bridges is enabled, bridges are

* described in ACPI separately (see build_pci_bus_end).

* In this case they aren't themselves hot-pluggable.

* Hotplugged bridges *are* hot-pluggable.
*/

thinking some more on this topic, it seems that with ACPI hotplug we already have implicit non-hotpluggble slot (slot with bridge) while the rest are staying hotpluggable.

Quoted 7 lines

So my question is: if it's acceptable to add 'PCIDevice::hotpluggable" property to all PCI devices so that user / libvirt could set it to false in case they do not want coldplugged device be considered as hotpluggable? (this way other devices could be treated the same way as bridges)

[...]

I think Julia already posted a patch adding this to downstream pcie bridges. Adding this to pci slots sounds like a reasonable thing.

Signature · 1 line
MST
#37 lore raw
Quoted 73 lines · On Wed, 20 May 2020 05:47:53 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 72 lines · Igor Mammedow
Quoted 50 lines · On Fri, 15 May 2020 12:13:53 +0000 Ani Sinha <[email protected]> wrote:
Quoted 39 lines
Quoted 24 lines · Igor Mammedov
Quoted 16 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=off -device e1000,bus=pci.1,addr=01,id=netdev1

Quoted 4 lines

-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

Quoted 12 lines

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

Quoted 2 lines

I don't think it's possible to have per slot hotplug on conventional PCI hardware. it's per bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

Quoted 8 lines

/* When hotplug for bridges is enabled, bridges are

* described in ACPI separately (see build_pci_bus_end).

* In this case they aren't themselves hot-pluggable.

* Hotplugged bridges *are* hot-pluggable.
*/

thinking some more on this topic, it seems that with ACPI hotplug we already have implicit non-hotpluggble slot (slot with bridge) while the rest are staying hotpluggable.

So my question is: if it's acceptable to add 'PCIDevice::hotpluggable" property to all PCI devices so that user / libvirt could set it to false in case they do not want coldplugged device be considered as hotpluggable? (this way other devices could be treated the same way as bridges)

Quoted 5 lines
Quoted 1 line

[...]

I think Julia already posted a patch adding this to downstream pcie bridges. Adding this to pci slots sounds like a reasonable thing.

Question was more about external interface, were we do not have ports as separate devices with conventional PCI. The only knob we have is a a PCI device, where we have a property to turn on/off hotplug. ex:
-device e1000,hotpluggable=off
and if libvirt would be able to use it

#38 lore raw
Quoted 79 lines · Igor Mammedow
Quoted 76 lines · On Wed, 20 May 2020 05:47:53 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 73 lines · Igor Mammedow
Quoted 50 lines · On Fri, 15 May 2020 12:13:53 +0000 Ani Sinha <[email protected]> wrote:
Quoted 39 lines
Quoted 24 lines · Igor Mammedov
Quoted 16 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=off -device e1000,bus=pci.1,addr=01,id=netdev1

Quoted 4 lines

-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

Quoted 12 lines

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

Quoted 2 lines

I don't think it's possible to have per slot hotplug on conventional PCI hardware. it's per bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

Quoted 8 lines

/* When hotplug for bridges is enabled, bridges are

* described in ACPI separately (see build_pci_bus_end).

* In this case they aren't themselves hot-pluggable.

* Hotplugged bridges *are* hot-pluggable.
*/

thinking some more on this topic, it seems that with ACPI hotplug we already have implicit non-hotpluggble slot (slot with bridge) while the rest are staying hotpluggable.

So my question is: if it's acceptable to add 'PCIDevice::hotpluggable" property to all PCI devices so that user / libvirt could set it to false in case they do not want coldplugged device be considered as hotpluggable? (this way other devices could be treated the same way as bridges)

[...]

Quoted 7 lines
Quoted 2 lines

I think Julia already posted a patch adding this to downstream pcie bridges. Adding this to pci slots sounds like a reasonable thing.

Question was more about external interface, were we do not have ports as separate devices with conventional PCI. The only knob we have is a a PCI device, where we have a property to turn on/off hotplug. ex:
-device e1000,hotpluggable=off
and if libvirt would be able to use it

Libvirt can certainly use a property that is settable per-device, instead of against the pcie-root-port. In fact the application that requested hotplug control (KubeVirt) would strongly prefer if this was doable per-device, because they really dislike the idea of having to deal with pcie-root-port devices.

So if you added it per-device, libvirt would support both the per-device option, and the pcie-root-port option.

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 :|
#42 lore raw
In reply to Igor Mammedow
Quoted 79 lines · Igor Mammedow
Quoted 76 lines · On Wed, 20 May 2020 05:47:53 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 73 lines · Igor Mammedow
Quoted 50 lines · On Fri, 15 May 2020 12:13:53 +0000 Ani Sinha <[email protected]> wrote:
Quoted 39 lines
Quoted 24 lines · Igor Mammedov
Quoted 16 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=off -device e1000,bus=pci.1,addr=01,id=netdev1

Quoted 4 lines

-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

Quoted 12 lines

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

Quoted 2 lines

I don't think it's possible to have per slot hotplug on conventional PCI hardware. it's per bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

Quoted 8 lines

/* When hotplug for bridges is enabled, bridges are

* described in ACPI separately (see build_pci_bus_end).

* In this case they aren't themselves hot-pluggable.

* Hotplugged bridges *are* hot-pluggable.
*/

thinking some more on this topic, it seems that with ACPI hotplug we already have implicit non-hotpluggble slot (slot with bridge) while the rest are staying hotpluggable.

So my question is: if it's acceptable to add 'PCIDevice::hotpluggable" property to all PCI devices so that user / libvirt could set it to false in case they do not want coldplugged device be considered as hotpluggable? (this way other devices could be treated the same way as bridges)

[...]

Quoted 7 lines
Quoted 2 lines

I think Julia already posted a patch adding this to downstream pcie bridges. Adding this to pci slots sounds like a reasonable thing.

Question was more about external interface, were we do not have ports as separate devices with conventional PCI. The only knob we have is a a PCI device, where we have a property to turn on/off hotplug. ex:
-device e1000,hotpluggable=off
and if libvirt would be able to use it

It would make sense but is it practical to add the capability is added in a generic way to all bridges and hosts?
If not how do users probe for presence of the capability?

Signature · 1 line
MST
#43 lore raw
Quoted 91 lines · On Wed, 20 May 2020 06:28:37 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 81 lines · Igor Mammedow
Quoted 78 lines · On Wed, 20 May 2020 05:47:53 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 75 lines · Igor Mammedow
Quoted 52 lines · On Fri, 15 May 2020 12:13:53 +0000 Ani Sinha <[email protected]> wrote:
Quoted 40 lines
Quoted 24 lines · Igor Mammedov
Quoted 16 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=off -device e1000,bus=pci.1,addr=01,id=netdev1

Quoted 4 lines

-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

Quoted 13 lines

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

Quoted 2 lines

I don't think it's possible to have per slot hotplug on conventional PCI hardware. it's per bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

Quoted 8 lines

/* When hotplug for bridges is enabled, bridges are

* described in ACPI separately (see
build_pci_bus_end).
* In this case they aren't themselves hot-pluggable.

* Hotplugged bridges *are* hot-pluggable.
*/

thinking some more on this topic, it seems that with ACPI hotplug we already have implicit non-hotpluggble slot (slot with bridge) while the rest are staying hotpluggable.

So my question is: if it's acceptable to add 'PCIDevice::hotpluggable" property to all PCI devices so that user / libvirt could set it to false in case they do not want coldplugged device be considered as hotpluggable? (this way other devices could be treated the same way as bridges)

[...]

Quoted 8 lines
Quoted 3 lines

I think Julia already posted a patch adding this to downstream pcie bridges. Adding this to pci slots sounds like a reasonable thing.

Question was more about external interface, were we do not have ports as separate devices with conventional PCI. The only knob we have is a a PCI device, where we have a property to turn on/off hotplug. ex: -device e1000,hotpluggable=off
and if libvirt would be able to use it

Quoted 3 lines

It would make sense but is it practical to add the capability is added in a generic way to all bridges and hosts?
If not how do users probe for presence of the capability?

it probably won't work with native SHPC hotplug (which looks to be incomplete in QEMU anyway), but it should work with ACPI and per port PCIE hotplugs.
In case of SHPC, we probably should be able to cleanly error out with 'unsupported' reason if "hotpluggable" conflicts with bridge policy.

#44 lore raw
Quoted 94 lines · Igor Mammedow
Quoted 91 lines · On Wed, 20 May 2020 06:28:37 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 89 lines · Igor Mammedow
Quoted 75 lines · On Wed, 20 May 2020 05:47:53 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 74 lines · Igor Mammedow
Quoted 52 lines · On Fri, 15 May 2020 12:13:53 +0000 Ani Sinha <[email protected]> wrote:
Quoted 40 lines
Quoted 24 lines · Igor Mammedov
Quoted 16 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=off -device e1000,bus=pci.1,addr=01,id=netdev1

Quoted 4 lines

-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

Quoted 13 lines

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

Quoted 2 lines

I don't think it's possible to have per slot hotplug on conventional PCI hardware. it's per bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

Quoted 8 lines

/* When hotplug for bridges is enabled, bridges are

* described in ACPI separately (see
build_pci_bus_end).
* In this case they aren't themselves hot-pluggable.

* Hotplugged bridges *are* hot-pluggable.
*/

thinking some more on this topic, it seems that with ACPI hotplug we already have implicit non-hotpluggble slot (slot with bridge) while the rest are staying hotpluggable.

So my question is: if it's acceptable to add 'PCIDevice::hotpluggable" property to all PCI devices so that user / libvirt could set it to false in case they do not want coldplugged device be considered as hotpluggable? (this way other devices could be treated the same way as bridges)

Quoted 6 lines
Quoted 1 line

[...]

I think Julia already posted a patch adding this to downstream pcie bridges. Adding this to pci slots sounds like a reasonable thing.

Question was more about external interface, were we do not have ports as separate devices with conventional PCI. The only knob we have is a a PCI device, where we have a property to turn on/off hotplug. ex: -device e1000,hotpluggable=off
and if libvirt would be able to use it

Quoted 8 lines
Quoted 3 lines

It would make sense but is it practical to add the capability is added in a generic way to all bridges and hosts?
If not how do users probe for presence of the capability?

it probably won't work with native SHPC hotplug (which looks to be incomplete in QEMU anyway), but it should work with ACPI and per port PCIE hotplugs.
In case of SHPC, we probably should be able to cleanly error out with 'unsupported' reason if "hotpluggable" conflicts with bridge policy.

"Try it and see if it works" is somewhat problematic from management POV since there's a never ending stream of new things they would have to try. If this approach is taken, we'd have to try to loop in some people from libvirt and see what's their take.

Signature · 1 line
MST
#39 lore raw
In reply to Daniel P. Berrangé
Quoted 94 lines · Daniel P. Berrangé
Quoted 79 lines · Igor Mammedow
Quoted 76 lines · On Wed, 20 May 2020 05:47:53 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 73 lines · Igor Mammedow
Quoted 50 lines · On Fri, 15 May 2020 12:13:53 +0000 Ani Sinha <[email protected]> wrote:
Quoted 39 lines
Quoted 24 lines · Igor Mammedov
Quoted 16 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=off -device e1000,bus=pci.1,addr=01,id=netdev1

Quoted 4 lines

-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

Quoted 12 lines

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

Quoted 2 lines

I don't think it's possible to have per slot hotplug on conventional PCI hardware. it's per bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

Quoted 8 lines

/* When hotplug for bridges is enabled, bridges are

* described in ACPI separately (see build_pci_bus_end).

* In this case they aren't themselves hot-pluggable.

* Hotplugged bridges *are* hot-pluggable.
*/

thinking some more on this topic, it seems that with ACPI hotplug we already have implicit non-hotpluggble slot (slot with bridge) while the rest are staying hotpluggable.

So my question is: if it's acceptable to add 'PCIDevice::hotpluggable" property to all PCI devices so that user / libvirt could set it to false in case they do not want coldplugged device be considered as hotpluggable? (this way other devices could be treated the same way as bridges)

[...]

Quoted 7 lines
Quoted 2 lines

I think Julia already posted a patch adding this to downstream pcie bridges. Adding this to pci slots sounds like a reasonable thing.

Question was more about external interface, were we do not have ports as separate devices with conventional PCI. The only knob we have is a a PCI device, where we have a property to turn on/off hotplug. ex:
-device e1000,hotpluggable=off
and if libvirt would be able to use it

Libvirt can certainly use a property that is settable per-device, instead of against the pcie-root-port. In fact the application that requested hotplug control (KubeVirt) would strongly prefer if this was doable per-device, because they really dislike the idea of having to deal with pcie-root-port devices.

Quoted 5 lines

So if you added it per-device, libvirt would support both the per-device option, and the pcie-root-port option.

Regards,
Daniel

The issue is that there then is no a way to check whether the option is supported on a given slot, without simply trying.
This is why we added it on the port, there, presence of the option is a signal that it will work.
Is this a concern for libvirt?

Quoted 4 lines
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 :|
#40 lore raw
Quoted 95 lines · Michael S. Tsirkin
Quoted 94 lines · Daniel P. Berrangé
Quoted 79 lines · Igor Mammedow
Quoted 76 lines · On Wed, 20 May 2020 05:47:53 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 73 lines · Igor Mammedow
Quoted 50 lines · On Fri, 15 May 2020 12:13:53 +0000 Ani Sinha <[email protected]> wrote:
Quoted 39 lines
Quoted 24 lines · Igor Mammedov
Quoted 16 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=off -device e1000,bus=pci.1,addr=01,id=netdev1

Quoted 4 lines

-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

Quoted 12 lines

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

Quoted 2 lines

I don't think it's possible to have per slot hotplug on conventional PCI hardware. it's per bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

Quoted 8 lines

/* When hotplug for bridges is enabled, bridges are

* described in ACPI separately (see build_pci_bus_end).

* In this case they aren't themselves hot-pluggable.

* Hotplugged bridges *are* hot-pluggable.
*/

thinking some more on this topic, it seems that with ACPI hotplug we already have implicit non-hotpluggble slot (slot with bridge) while the rest are staying hotpluggable.

So my question is: if it's acceptable to add 'PCIDevice::hotpluggable" property to all PCI devices so that user / libvirt could set it to false in case they do not want coldplugged device be considered as hotpluggable? (this way other devices could be treated the same way as bridges)

[...]

Quoted 7 lines
Quoted 2 lines

I think Julia already posted a patch adding this to downstream pcie bridges. Adding this to pci slots sounds like a reasonable thing.

Question was more about external interface, were we do not have ports as separate devices with conventional PCI. The only knob we have is a a PCI device, where we have a property to turn on/off hotplug. ex:
-device e1000,hotpluggable=off
and if libvirt would be able to use it

Libvirt can certainly use a property that is settable per-device, instead of against the pcie-root-port. In fact the application that requested hotplug control (KubeVirt) would strongly prefer if this was doable per-device, because they really dislike the idea of having to deal with pcie-root-port devices.

Quoted 8 lines
Quoted 2 lines

So if you added it per-device, libvirt would support both the per-device option, and the pcie-root-port option.

The issue is that there then is no a way to check whether the option is supported on a given slot, without simply trying.
This is why we added it on the port, there, presence of the option is a signal that it will work.
Is this a concern for libvirt?

I'm not sure. What are the scenarios in which it is supported vs not supported, as I'm unclear if they affect libvirt or not ?

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 :|
#41 lore raw
Quoted 105 lines · Daniel P. Berrangé
Quoted 95 lines · Michael S. Tsirkin
Quoted 94 lines · Daniel P. Berrangé
Quoted 79 lines · Igor Mammedow
Quoted 76 lines · On Wed, 20 May 2020 05:47:53 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 73 lines · Igor Mammedow
Quoted 50 lines · On Fri, 15 May 2020 12:13:53 +0000 Ani Sinha <[email protected]> wrote:
Quoted 39 lines
Quoted 24 lines · Igor Mammedov
Quoted 16 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on -device pci-bridge,chassis_nr=1,shpc=off -device e1000,bus=pci.1,addr=01,id=netdev1

Quoted 4 lines

-global PIIX4_PM.acpi-pci-hotplug=off -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off -device pci-bridge,chassis_nr=1,shpc=doesnt_matter -device e1000,bus=pci.1,addr=01,id=netdev1

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

Quoted 12 lines

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

Quoted 2 lines

I don't think it's possible to have per slot hotplug on conventional PCI hardware. it's per bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

Quoted 8 lines

/* When hotplug for bridges is enabled, bridges are

* described in ACPI separately (see build_pci_bus_end).

* In this case they aren't themselves hot-pluggable.

* Hotplugged bridges *are* hot-pluggable.
*/

thinking some more on this topic, it seems that with ACPI hotplug we already have implicit non-hotpluggble slot (slot with bridge) while the rest are staying hotpluggable.

So my question is: if it's acceptable to add 'PCIDevice::hotpluggable" property to all PCI devices so that user / libvirt could set it to false in case they do not want coldplugged device be considered as hotpluggable? (this way other devices could be treated the same way as bridges)

[...]

Quoted 7 lines
Quoted 2 lines

I think Julia already posted a patch adding this to downstream pcie bridges. Adding this to pci slots sounds like a reasonable thing.

Question was more about external interface, were we do not have ports as separate devices with conventional PCI. The only knob we have is a a PCI device, where we have a property to turn on/off hotplug. ex:
-device e1000,hotpluggable=off
and if libvirt would be able to use it

Libvirt can certainly use a property that is settable per-device, instead of against the pcie-root-port. In fact the application that requested hotplug control (KubeVirt) would strongly prefer if this was doable per-device, because they really dislike the idea of having to deal with pcie-root-port devices.

Quoted 8 lines
Quoted 2 lines

So if you added it per-device, libvirt would support both the per-device option, and the pcie-root-port option.

The issue is that there then is no a way to check whether the option is supported on a given slot, without simply trying.
This is why we added it on the port, there, presence of the option is a signal that it will work.
Is this a concern for libvirt?

Quoted 6 lines

I'm not sure. What are the scenarios in which it is supported vs not supported, as I'm unclear if they affect libvirt or not ?

Regards,
Daniel

It would depend on things like the type of the host and pci to pci bridge used.

Quoted 4 lines
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 :|
#45 lore raw
In reply to Michael S. Tsirkin
Quoted 109 lines · On Wed, 20 May 2020 07:23:21 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 101 lines · Igor Mammedow
Quoted 95 lines · On Wed, 20 May 2020 06:28:37 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 85 lines · Igor Mammedow
Quoted 82 lines · On Wed, 20 May 2020 05:47:53 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 78 lines · Igor Mammedow
Quoted 54 lines · On Fri, 15 May 2020 12:13:53 +0000 Ani Sinha <[email protected]> wrote:
Quoted 41 lines
Quoted 24 lines · Igor Mammedov
Quoted 18 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on

(quoted diff) +0 -2
-device pci-bridge,chassis_nr=1,shpc=doesnt_matter
-device e1000,bus=pci.1,addr=01,id=netdev1 

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on
-device pci-bridge,chassis_nr=1,shpc=off -device
e1000,bus=pci.1,addr=01,id=netdev1

-global PIIX4_PM.acpi-pci-hotplug=off -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off

Review

Quoted 2 lines
(quoted diff) +0 -2
-device pci-bridge,chassis_nr=1,shpc=doesnt_matter
-device e1000,bus=pci.1,addr=01,id=netdev1          

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

Quoted 14 lines

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

Quoted 3 lines

I don't think it's possible to have per slot hotplug on conventional PCI hardware. it's per bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

Quoted 8 lines

/* When hotplug for bridges is enabled, bridges are

* described in ACPI separately (see
build_pci_bus_end).
* In this case they aren't themselves
hot-pluggable.
* Hotplugged bridges *are* hot-pluggable.
*/

thinking some more on this topic, it seems that with ACPI hotplug we already have implicit non-hotpluggble slot (slot with bridge) while the rest are staying hotpluggable.

So my question is: if it's acceptable to add 'PCIDevice::hotpluggable" property to all PCI devices so that user / libvirt could set it to false in case they do not want coldplugged device be considered as hotpluggable? (this way other devices could be treated the same way as bridges)

[...]

Quoted 8 lines
Quoted 3 lines

I think Julia already posted a patch adding this to downstream pcie bridges. Adding this to pci slots sounds like a reasonable thing.

Question was more about external interface, were we do not have ports as separate devices with conventional PCI. The only knob we have is a a PCI device, where we have a property to turn on/off hotplug. ex: -device e1000,hotpluggable=off and if libvirt would be able to use it

Quoted 3 lines

It would make sense but is it practical to add the capability is added in a generic way to all bridges and hosts?
If not how do users probe for presence of the capability?

Quoted 6 lines

it probably won't work with native SHPC hotplug (which looks to be incomplete in QEMU anyway), but it should work with ACPI and per port PCIE hotplugs.
In case of SHPC, we probably should be able to cleanly error out with 'unsupported' reason if "hotpluggable" conflicts with bridge policy.

Quoted 4 lines

"Try it and see if it works" is somewhat problematic from management POV since there's a never ending stream of new things they would have to try. If this approach is taken, we'd have to try to loop in some people from libvirt and see what's their take.

to clarify, we are talking here about bridges to conventional PCI with native SHPC hotplug semantics wrt mgmt and potential pcidevice.hotpluggable property.
(the later should work fine in ACPI and PCIE hoptlug cases).

currently by default pci bridges have property shpc=off, so mgmt should know that deals with PCI bridge and has to enable SHPC on bridge explicitly, in which case it could probably be taught that using conflicting hotpluggable for device attached to bridge and shpc values is wrong thing.
If that's not it, then I'm not sure what kind of discovery you are talking about.

#46 lore raw
Quoted 116 lines · Igor Mammedow
Quoted 109 lines · On Wed, 20 May 2020 07:23:21 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 101 lines · Igor Mammedow
Quoted 95 lines · On Wed, 20 May 2020 06:28:37 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 85 lines · Igor Mammedow
Quoted 82 lines · On Wed, 20 May 2020 05:47:53 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 78 lines · Igor Mammedow
Quoted 54 lines · On Fri, 15 May 2020 12:13:53 +0000 Ani Sinha <[email protected]> wrote:
Quoted 41 lines
Quoted 24 lines · Igor Mammedov
Quoted 18 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on

(quoted diff) +0 -2
-device pci-bridge,chassis_nr=1,shpc=doesnt_matter
-device e1000,bus=pci.1,addr=01,id=netdev1 

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on
-device pci-bridge,chassis_nr=1,shpc=off -device
e1000,bus=pci.1,addr=01,id=netdev1

-global PIIX4_PM.acpi-pci-hotplug=off -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off

Review

Quoted 2 lines
(quoted diff) +0 -2
-device pci-bridge,chassis_nr=1,shpc=doesnt_matter
-device e1000,bus=pci.1,addr=01,id=netdev1          

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

Quoted 14 lines

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

Quoted 3 lines

I don't think it's possible to have per slot hotplug on conventional PCI hardware. it's per bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

Quoted 8 lines

/* When hotplug for bridges is enabled, bridges are

* described in ACPI separately (see
build_pci_bus_end).
* In this case they aren't themselves
hot-pluggable.
* Hotplugged bridges *are* hot-pluggable.
*/

thinking some more on this topic, it seems that with ACPI hotplug we already have implicit non-hotpluggble slot (slot with bridge) while the rest are staying hotpluggable.

So my question is: if it's acceptable to add 'PCIDevice::hotpluggable" property to all PCI devices so that user / libvirt could set it to false in case they do not want coldplugged device be considered as hotpluggable? (this way other devices could be treated the same way as bridges)

[...]

Quoted 8 lines
Quoted 3 lines

I think Julia already posted a patch adding this to downstream pcie bridges. Adding this to pci slots sounds like a reasonable thing.

Question was more about external interface, were we do not have ports as separate devices with conventional PCI. The only knob we have is a a PCI device, where we have a property to turn on/off hotplug. ex: -device e1000,hotpluggable=off and if libvirt would be able to use it

Quoted 3 lines

It would make sense but is it practical to add the capability is added in a generic way to all bridges and hosts?
If not how do users probe for presence of the capability?

Quoted 6 lines

it probably won't work with native SHPC hotplug (which looks to be incomplete in QEMU anyway), but it should work with ACPI and per port PCIE hotplugs.
In case of SHPC, we probably should be able to cleanly error out with 'unsupported' reason if "hotpluggable" conflicts with bridge policy.

Quoted 4 lines

"Try it and see if it works" is somewhat problematic from management POV since there's a never ending stream of new things they would have to try. If this approach is taken, we'd have to try to loop in some people from libvirt and see what's their take.

Quoted 8 lines

to clarify, we are talking here about bridges to conventional PCI with native SHPC hotplug semantics wrt mgmt and potential pcidevice.hotpluggable property.
(the later should work fine in ACPI and PCIE hoptlug cases).

currently by default pci bridges have property shpc=off, so mgmt should know that deals with PCI bridge and has to enable SHPC on bridge explicitly,

Wait a second does that actually affect hotplug with ACPI too?

Quoted 5 lines

in which case it could probably be taught that
using conflicting hotpluggable for device attached to bridge and shpc values is wrong thing.
If that's not it, then I'm not sure what kind of discovery you are talking about.

Signature · 1 line
MST
#47 lore raw
Quoted 130 lines · On Wed, 20 May 2020 12:13:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 129 lines · Igor Mammedow
Quoted 116 lines · On Wed, 20 May 2020 07:23:21 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 108 lines · Igor Mammedow
Quoted 102 lines · On Wed, 20 May 2020 06:28:37 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 93 lines · Igor Mammedow
Quoted 84 lines · On Wed, 20 May 2020 05:47:53 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 82 lines · Igor Mammedow
Quoted 58 lines · On Fri, 15 May 2020 12:13:53 +0000 Ani Sinha <[email protected]> wrote:
Quoted 44 lines
Quoted 25 lines · Igor Mammedov
Quoted 19 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on

(quoted diff) +0 -2
-device pci-bridge,chassis_nr=1,shpc=doesnt_matter
-device e1000,bus=pci.1,addr=01,id=netdev1 

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on
-device pci-bridge,chassis_nr=1,shpc=off -device
e1000,bus=pci.1,addr=01,id=netdev1

-global PIIX4_PM.acpi-pci-hotplug=off -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off

Review

Quoted 2 lines
(quoted diff) +0 -2
-device pci-bridge,chassis_nr=1,shpc=doesnt_matter
-device e1000,bus=pci.1,addr=01,id=netdev1

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

Quoted 16 lines

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

Quoted 3 lines

I don't think it's possible to have per slot
hotplug on conventional PCI hardware. it's per
bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

Quoted 8 lines

/* When hotplug for bridges is enabled, bridges are

* described in ACPI separately (see
build_pci_bus_end).
* In this case they aren't themselves
hot-pluggable.
* Hotplugged bridges *are* hot-pluggable.
*/

thinking some more on this topic, it seems that with ACPI hotplug we already have implicit non-hotpluggble slot (slot with bridge) while the rest are staying hotpluggable.

So my question is: if it's acceptable to add 'PCIDevice::hotpluggable" property to all PCI devices so that user / libvirt could set it to false in case they do not want coldplugged device be considered as hotpluggable? (this way other devices could be treated the same way as bridges)

Quoted 6 lines
Quoted 1 line

[...]

I think Julia already posted a patch adding this to downstream pcie bridges. Adding this to pci slots sounds like a reasonable thing.

Quoted 6 lines

Question was more about external interface, were we do not have ports as separate devices with conventional PCI. The only knob we have is a a PCI device, where we have a property to turn on/off hotplug. ex: -device e1000,hotpluggable=off and if libvirt would be able to use it

Quoted 3 lines

It would make sense but is it practical to add the capability is added in a generic way to all bridges and hosts? If not how do users probe for presence of the capability?

Quoted 6 lines

it probably won't work with native SHPC hotplug (which looks to be incomplete in QEMU anyway), but it should work with ACPI and per port PCIE hotplugs.
In case of SHPC, we probably should be able to cleanly error out with 'unsupported' reason if "hotpluggable" conflicts with bridge policy.

Quoted 5 lines

"Try it and see if it works" is somewhat problematic from management POV since there's a never ending stream of new things they would have to try. If this approach is taken, we'd have to try to loop in some people from libvirt and see what's their take.

to clarify, we are talking here about bridges to conventional PCI with native SHPC hotplug semantics wrt mgmt and potential pcidevice.hotpluggable property.
(the later should work fine in ACPI and PCIE hoptlug cases).

Quoted 5 lines
Quoted 3 lines

currently by default pci bridges have property shpc=off, so mgmt should know that deals with PCI bridge and has to enable SHPC on bridge explicitly,

Wait a second does that actually affect hotplug with ACPI too?

What do you mean exactly?

Quoted 9 lines
Quoted 5 lines

in which case it could probably be taught that
using conflicting hotpluggable for device attached to bridge and shpc values is wrong thing.
If that's not it, then I'm not sure what kind of discovery you are talking about.

#48 lore raw
Quoted 133 lines · Igor Mammedow
Quoted 130 lines · On Wed, 20 May 2020 12:13:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 129 lines · Igor Mammedow
Quoted 116 lines · On Wed, 20 May 2020 07:23:21 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 108 lines · Igor Mammedow
Quoted 102 lines · On Wed, 20 May 2020 06:28:37 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 93 lines · Igor Mammedow
Quoted 84 lines · On Wed, 20 May 2020 05:47:53 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 82 lines · Igor Mammedow
Quoted 58 lines · On Fri, 15 May 2020 12:13:53 +0000 Ani Sinha <[email protected]> wrote:
Quoted 44 lines
Quoted 25 lines · Igor Mammedov
Quoted 21 lines

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on
-device pci-bridge,chassis_nr=1,shpc=doesnt_matter
-device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on
-device pci-bridge,chassis_nr=1,shpc=off -device
e1000,bus=pci.1,addr=01,id=netdev1

-global PIIX4_PM.acpi-pci-hotplug=off -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off
-device pci-bridge,chassis_nr=1,shpc=doesnt_matter
-device e1000,bus=pci.1,addr=01,id=netdev1

Given that my patch is not acceptable, I’d prefer the following in the order of preference:

Quoted 16 lines

(a) Have an option to disable hot ejection of PCI-PCI bridge so that Windows does not even show this HW in the “safely remove HW” option. If we can do this then from OS perspective the GUI options will be same as what is available with PCIE/q35 - none of the devices will be hot ejectable if the hot plug option is turned off from the PCIE slots where devices are plugged into. I looked at the code. It seems to manipulate ACPI tables of the empty slots of the root bus where no devices are attached (see comment "/* add hotplug slots for non present devices */ “). For cold plugged bridges, it recurses down to scan the slots of the bridge. Is it possible to disable hot plug for the slot to which the bridge is attached?

Quoted 3 lines

I don't think it's possible to have per slot
hotplug on conventional PCI hardware. it's per
bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

Quoted 8 lines

/* When hotplug for bridges is enabled, bridges are

* described in ACPI separately (see
build_pci_bus_end).
* In this case they aren't themselves
hot-pluggable.
* Hotplugged bridges *are* hot-pluggable.
*/

thinking some more on this topic, it seems that with ACPI hotplug we already have implicit non-hotpluggble slot (slot with bridge) while the rest are staying hotpluggable.

So my question is: if it's acceptable to add 'PCIDevice::hotpluggable" property to all PCI devices so that user / libvirt could set it to false in case they do not want coldplugged device be considered as hotpluggable? (this way other devices could be treated the same way as bridges)

Quoted 6 lines
Quoted 1 line

[...]

I think Julia already posted a patch adding this to downstream pcie bridges. Adding this to pci slots sounds like a reasonable thing.

Quoted 6 lines

Question was more about external interface, were we do not have ports as separate devices with conventional PCI. The only knob we have is a a PCI device, where we have a property to turn on/off hotplug. ex: -device e1000,hotpluggable=off and if libvirt would be able to use it

Quoted 3 lines

It would make sense but is it practical to add the capability is added in a generic way to all bridges and hosts? If not how do users probe for presence of the capability?

Quoted 6 lines

it probably won't work with native SHPC hotplug (which looks to be incomplete in QEMU anyway), but it should work with ACPI and per port PCIE hotplugs.
In case of SHPC, we probably should be able to cleanly error out with 'unsupported' reason if "hotpluggable" conflicts with bridge policy.

Quoted 5 lines

"Try it and see if it works" is somewhat problematic from management POV since there's a never ending stream of new things they would have to try. If this approach is taken, we'd have to try to loop in some people from libvirt and see what's their take.

to clarify, we are talking here about bridges to conventional PCI with native SHPC hotplug semantics wrt mgmt and potential pcidevice.hotpluggable property.
(the later should work fine in ACPI and PCIE hoptlug cases).

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

currently by default pci bridges have property shpc=off, so mgmt should know that deals with PCI bridge and has to enable SHPC on bridge explicitly,

Wait a second does that actually affect hotplug with ACPI too?

What do you mean exactly?

I just tried to figure out why do you say
"mgmt should know that deals with PCI bridge and has to enable SHPC
on bridge explicitly,"
since on x86 bridges support hotplug through ACPI bypassing SHPC.

Quoted 10 lines
Quoted 10 lines
Quoted 6 lines

in which case it could probably be taught that
using conflicting hotpluggable for device attached to bridge and shpc values is wrong thing.
If that's not it, then I'm not sure what kind of discovery you are talking about.

#49 lore raw
Quoted 138 lines · On Thu, 21 May 2020 06:07:25 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 137 lines · Igor Mammedow
Quoted 134 lines · On Wed, 20 May 2020 12:13:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 132 lines · Igor Mammedow
Quoted 116 lines · On Wed, 20 May 2020 07:23:21 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 108 lines · Igor Mammedow
Quoted 102 lines · On Wed, 20 May 2020 06:28:37 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 93 lines · Igor Mammedow
Quoted 84 lines · On Wed, 20 May 2020 05:47:53 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 82 lines · Igor Mammedow
Quoted 58 lines · On Fri, 15 May 2020 12:13:53 +0000 Ani Sinha <[email protected]> wrote:
Quoted 44 lines
Quoted 41 lines · Igor Mammedov

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on
-device pci-bridge,chassis_nr=1,shpc=doesnt_matter
-device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on
-device pci-bridge,chassis_nr=1,shpc=off -device
e1000,bus=pci.1,addr=01,id=netdev1

-global PIIX4_PM.acpi-pci-hotplug=off -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off
-device pci-bridge,chassis_nr=1,shpc=doesnt_matter
-device e1000,bus=pci.1,addr=01,id=netdev1

Given that my patch is not acceptable, I’d prefer
the following in the order of preference:

(a) Have an option to disable hot ejection of
PCI-PCI bridge so that Windows does not even show
this HW in the “safely remove HW” option. If we
can do this then from OS perspective the GUI
options will be same as what is available with
PCIE/q35 - none of the devices will be hot
ejectable if the hot plug option is turned off
from the PCIE slots where devices are plugged
into. I looked at the code. It seems to manipulate
ACPI tables of the empty slots of the root bus
where no devices are attached (see comment "/* add
hotplug slots for non present devices */ “). For
cold plugged bridges, it recurses down to scan the
slots of the bridge. Is it possible to disable hot
plug for the slot to which the bridge is attached?

Quoted 3 lines

I don't think it's possible to have per slot
hotplug on conventional PCI hardware. it's per
bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

Quoted 8 lines

/* When hotplug for bridges is enabled, bridges are

* described in ACPI separately (see
build_pci_bus_end).
* In this case they aren't themselves
hot-pluggable.
* Hotplugged bridges *are* hot-pluggable.
*/

thinking some more on this topic, it seems that with ACPI hotplug we already have implicit non-hotpluggble slot (slot with bridge) while the rest are staying hotpluggable.

So my question is: if it's acceptable to add 'PCIDevice::hotpluggable" property to all PCI devices so that user / libvirt could set it to false in case they do not want coldplugged device be considered as hotpluggable? (this way other devices could be treated the same way as bridges)

Quoted 6 lines
Quoted 1 line

[...]

I think Julia already posted a patch adding this to downstream pcie bridges. Adding this to pci slots sounds like a reasonable thing.

Quoted 6 lines

Question was more about external interface, were we do not have ports as separate devices with conventional PCI. The only knob we have is a a PCI device, where we have a property to turn on/off hotplug. ex: -device e1000,hotpluggable=off and if libvirt would be able to use it

Quoted 3 lines

It would make sense but is it practical to add the capability is added in a generic way to all bridges and hosts? If not how do users probe for presence of the capability?

Quoted 6 lines

it probably won't work with native SHPC hotplug (which looks to be incomplete in QEMU anyway), but it should work with ACPI and per port PCIE hotplugs.
In case of SHPC, we probably should be able to cleanly error out with 'unsupported' reason if "hotpluggable" conflicts with bridge policy.

Quoted 5 lines

"Try it and see if it works" is somewhat problematic from management POV since there's a never ending stream of new things they would have to try. If this approach is taken, we'd have to try to loop in some people from libvirt and see what's their take.

to clarify, we are talking here about bridges to conventional PCI with native SHPC hotplug semantics wrt mgmt and potential pcidevice.hotpluggable property.
(the later should work fine in ACPI and PCIE hoptlug cases).

currently by default pci bridges have property shpc=off, so mgmt should know that deals with PCI bridge and has to enable SHPC on bridge explicitly,

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

Wait a second does that actually affect hotplug with ACPI too?

What do you mean exactly?

I just tried to figure out why do you say
"mgmt should know that deals with PCI bridge and has to enable SHPC
on bridge explicitly,"
since on x86 bridges support hotplug through ACPI bypassing SHPC.

Current state in QEMU is that for ACPI hotplug, it doesn't have to do anything "acpi-pci-hotplug-with-bridge-support=on" by default and it's global setting for coldplugged bridges, also it (sort of) overrides SHPC (even if was enabled with 'shpc=on' on a concrete coldplugged bridge).
(I wouldn't be surprised if mixing modes actually isn't functional)

Then there is hotplugged bridges (added at -S time or at runtime), for those mgmt has to set 'shpc=on' explicitly to be able to hotplug devices into it. (so mgmt has to know that it's dealing wants SHPC and I suppose it can be taught that SHPC doesn't support mixed hotplug policy on slots/devices attached to it). Whether mgmt actually does something with shpc or not, I have no slightest idea. (CCing Laine, perhaps he can clarify if we should care about SHPC here)

Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

in which case it could probably be taught that
using conflicting hotpluggable for device attached to bridge and shpc values is wrong thing.
If that's not it, then I'm not sure what kind of discovery you are talking about.

#50 lore raw
Quoted 149 lines · Igor Mammedov
Quoted 138 lines · On Thu, 21 May 2020 06:07:25 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 137 lines · Igor Mammedow
Quoted 134 lines · On Wed, 20 May 2020 12:13:35 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 132 lines · Igor Mammedow
Quoted 116 lines · On Wed, 20 May 2020 07:23:21 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 108 lines · Igor Mammedow
Quoted 102 lines · On Wed, 20 May 2020 06:28:37 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 93 lines · Igor Mammedow
Quoted 84 lines · On Wed, 20 May 2020 05:47:53 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 82 lines · Igor Mammedow
Quoted 58 lines · On Fri, 15 May 2020 12:13:53 +0000 Ani Sinha <[email protected]> wrote:
Quoted 47 lines

On May 14, 2020, at 1:13 AM, Igor Mammedov
<[email protected]> wrote:

Will following hack work for you?
possible permutations
1) ACPI hotplug everywhere
-global PIIX4_PM.acpi-pci-hotplug=on -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on
-device pci-bridge,chassis_nr=1,shpc=doesnt_matter
-device e1000,bus=pci.1,addr=01,id=netdev1

2) No hotplug at all
-global PIIX4_PM.acpi-pci-hotplug=off -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=on
-device pci-bridge,chassis_nr=1,shpc=off -device
e1000,bus=pci.1,addr=01,id=netdev1

-global PIIX4_PM.acpi-pci-hotplug=off -global
PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off
-device pci-bridge,chassis_nr=1,shpc=doesnt_matter
-device e1000,bus=pci.1,addr=01,id=netdev1

Given that my patch is not acceptable, I’d prefer
the following in the order of preference:

(a) Have an option to disable hot ejection of
PCI-PCI bridge so that Windows does not even show
this HW in the “safely remove HW” option. If we
can do this then from OS perspective the GUI
options will be same as what is available with
PCIE/q35 - none of the devices will be hot
ejectable if the hot plug option is turned off
from the PCIE slots where devices are plugged
into. I looked at the code. It seems to manipulate
ACPI tables of the empty slots of the root bus
where no devices are attached (see comment "/* add
hotplug slots for non present devices */ “). For
cold plugged bridges, it recurses down to scan the
slots of the bridge. Is it possible to disable hot
plug for the slot to which the bridge is attached?

I don't think it's possible to have per slot
hotplug on conventional PCI hardware. it's per
bridge property.

We add the AMLs per empty slot though. When the pic bridge is attached, we do nothing, just recurse into the bridge slots. That is what I was asking, if it was possible to just disable the AMLs or use some tricks to say that this particular slot is not hotpluggable. I am not sure why Windows is trying to eject the PCI bridge and failing. Maybe something related to this comment?

Quoted 8 lines

/* When hotplug for bridges is enabled, bridges are

* described in ACPI separately (see
build_pci_bus_end).
* In this case they aren't themselves
hot-pluggable.
* Hotplugged bridges *are* hot-pluggable.
*/

thinking some more on this topic, it seems that with ACPI hotplug we already have implicit non-hotpluggble slot (slot with bridge) while the rest are staying hotpluggable.

So my question is: if it's acceptable to add 'PCIDevice::hotpluggable" property to all PCI devices so that user / libvirt could set it to false in case they do not want coldplugged device be considered as hotpluggable? (this way other devices could be treated the same way as bridges)

Quoted 6 lines
Quoted 1 line

[...]

I think Julia already posted a patch adding this to downstream pcie bridges. Adding this to pci slots sounds like a reasonable thing.

Quoted 6 lines

Question was more about external interface, were we do not have ports as separate devices with conventional PCI. The only knob we have is a a PCI device, where we have a property to turn on/off hotplug. ex: -device e1000,hotpluggable=off and if libvirt would be able to use it

Quoted 3 lines

It would make sense but is it practical to add the capability is added in a generic way to all bridges and hosts? If not how do users probe for presence of the capability?

Quoted 6 lines

it probably won't work with native SHPC hotplug (which looks to be incomplete in QEMU anyway), but it should work with ACPI and per port PCIE hotplugs.
In case of SHPC, we probably should be able to cleanly error out with 'unsupported' reason if "hotpluggable" conflicts with bridge policy.

Quoted 5 lines

"Try it and see if it works" is somewhat problematic from management POV since there's a never ending stream of new things they would have to try. If this approach is taken, we'd have to try to loop in some people from libvirt and see what's their take.

to clarify, we are talking here about bridges to conventional PCI with native SHPC hotplug semantics wrt mgmt and potential pcidevice.hotpluggable property.
(the later should work fine in ACPI and PCIE hoptlug cases).

currently by default pci bridges have property shpc=off, so mgmt should know that deals with PCI bridge and has to enable SHPC on bridge explicitly,

Quoted 7 lines
Quoted 2 lines
Quoted 1 line

Wait a second does that actually affect hotplug with ACPI too?

What do you mean exactly?

I just tried to figure out why do you say
"mgmt should know that deals with PCI bridge and has to enable SHPC
on bridge explicitly,"
since on x86 bridges support hotplug through ACPI bypassing SHPC.

Quoted 7 lines

Current state in QEMU is that for ACPI hotplug, it doesn't have to do anything "acpi-pci-hotplug-with-bridge-support=on" by default and it's global setting for coldplugged bridges, also it (sort of) overrides SHPC (even if was enabled with 'shpc=on' on a concrete coldplugged bridge).
(I wouldn't be surprised if mixing modes actually isn't functional)

Then there is hotplugged bridges (added at -S time or at runtime),

Aren't hotplugged bridges ignored by essentially every guest OS in existence? (since it requires the entire topology to be rescanned, or something like that - forgive my lack of knowledge about the details, I just remember being told "that doesn't work")

Quoted 6 lines

for those
mgmt has to set 'shpc=on' explicitly to be able to hotplug devices into it. (so mgmt has to know that it's dealing wants SHPC and I suppose it can be taught that SHPC doesn't support mixed hotplug policy on slots/devices attached to it). Whether mgmt actually does something with shpc or not, I have no slightest idea. (CCing Laine, perhaps he can clarify if we should care about SHPC here)

libvirt does nothing with shpc. It uses the bridges with whatever is the default setting of shpc in qemu. I recall at one time someone (Marcel maybe?) proposed changing the default of that setting, but don't remember why.

Quoted 13 lines
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines

in which case it could probably be taught that
using conflicting hotpluggable for device attached to bridge and shpc values is wrong thing.
If that's not it, then I'm not sure what kind of discovery you are talking about.