qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: mst@redhat.com, ani@anisinha.ca, berrange@redhat.com
Subject: [PATCH 33/33] pcihp: add ACPI PCI hotplug specific is_hotpluggable_bus() callback
Date: Fri, 24 Feb 2023 16:38:12 +0100	[thread overview]
Message-ID: <20230224153812.4176226-34-imammedo@redhat.com> (raw)
In-Reply-To: <20230224153812.4176226-1-imammedo@redhat.com>

Provide pcihp specific callback to check if bus is hotpluggable
and consolidate its scattered hotplug criteria there.
While at it clean up no longer needed
   qbus_set_hotplug_handler(BUS(bus), NULL)
workarounds since callback makes qbus_is_hotpluggable() return
correct answer even if hotplug_handler is set on bus.

PS:
see ("pci: fix 'hotplugglable' property behavior") for details
why callback was introduced.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 include/hw/acpi/ich9.h          |  1 +
 include/hw/acpi/pcihp.h         |  1 +
 hw/acpi/acpi-pci-hotplug-stub.c |  4 ++++
 hw/acpi/ich9.c                  |  6 +++++
 hw/acpi/pcihp.c                 | 42 ++++++++++++++-------------------
 hw/acpi/piix4.c                 |  8 +++++++
 hw/isa/lpc_ich9.c               |  1 +
 7 files changed, 39 insertions(+), 24 deletions(-)

diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
index d41866a229..d2f980359e 100644
--- a/include/hw/acpi/ich9.h
+++ b/include/hw/acpi/ich9.h
@@ -89,6 +89,7 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev,
                                       DeviceState *dev, Error **errp);
 void ich9_pm_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
                               Error **errp);
+bool ich9_pm_is_hotpluggable_bus(HotplugHandler *hotplug_dev, BusState *bus);
 
 void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list);
 #endif /* HW_ACPI_ICH9_H */
diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
index 04c98511a4..ef59810c17 100644
--- a/include/hw/acpi/pcihp.h
+++ b/include/hw/acpi/pcihp.h
@@ -58,6 +58,7 @@ typedef struct AcpiPciHpState {
 void acpi_pcihp_init(Object *owner, AcpiPciHpState *, PCIBus *root,
                      MemoryRegion *address_space_io, uint16_t io_base);
 
+bool acpi_pcihp_is_hotpluggbale_bus(AcpiPciHpState *s, BusState *bus);
 void acpi_pcihp_device_pre_plug_cb(HotplugHandler *hotplug_dev,
                                    DeviceState *dev, Error **errp);
 void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
diff --git a/hw/acpi/acpi-pci-hotplug-stub.c b/hw/acpi/acpi-pci-hotplug-stub.c
index d1794399f7..dcee3ad7a1 100644
--- a/hw/acpi/acpi-pci-hotplug-stub.c
+++ b/hw/acpi/acpi-pci-hotplug-stub.c
@@ -40,3 +40,7 @@ void acpi_pcihp_reset(AcpiPciHpState *s)
     return;
 }
 
+bool acpi_pcihp_is_hotpluggbale_bus(AcpiPciHpState *s, BusState *bus)
+{
+    return true;
+}
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 34a58fc07c..e625adbbab 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -582,6 +582,12 @@ void ich9_pm_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
     }
 }
 
+bool ich9_pm_is_hotpluggable_bus(HotplugHandler *hotplug_dev, BusState *bus)
+{
+    ICH9LPCState *lpc = ICH9_LPC_DEVICE(hotplug_dev);
+    return acpi_pcihp_is_hotpluggbale_bus(&lpc->pm.acpi_pci_hotplug, bus);
+}
+
 void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list)
 {
     ICH9LPCState *s = ICH9_LPC_DEVICE(adev);
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 34cad061a8..dcfb779a7a 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -121,20 +121,6 @@ static void acpi_set_pci_info(bool has_bridge_hotplug)
     }
 }
 
-static void acpi_pcihp_disable_root_bus(void)
-{
-    Object *host = acpi_get_i386_pci_host();
-    PCIBus *bus;
-
-    bus = PCI_HOST_BRIDGE(host)->bus;
-    if (bus && qbus_is_hotpluggable(BUS(bus))) {
-        /* setting the hotplug handler to NULL makes the bus non-hotpluggable */
-        qbus_set_hotplug_handler(BUS(bus), NULL);
-    }
-
-    return;
-}
-
 static void acpi_pcihp_test_hotplug_bus(PCIBus *bus, void *opaque)
 {
     AcpiPciHpFind *find = opaque;
@@ -278,9 +264,6 @@ static void acpi_pcihp_update(AcpiPciHpState *s)
 
 void acpi_pcihp_reset(AcpiPciHpState *s)
 {
-    if (!s->use_acpi_root_pci_hotplug) {
-        acpi_pcihp_disable_root_bus();
-    }
     acpi_set_pci_info(s->use_acpi_hotplug_bridge);
     acpi_pcihp_update(s);
 }
@@ -320,13 +303,6 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
             object_dynamic_cast(OBJECT(dev), TYPE_PCI_BRIDGE)) {
             PCIBus *sec = pci_bridge_get_sec_bus(PCI_BRIDGE(pdev));
 
-            /* Remove all hot-plug handlers if hot-plug is disabled on slot */
-            if (object_dynamic_cast(OBJECT(dev), TYPE_PCIE_SLOT) &&
-                !PCIE_SLOT(pdev)->hotplug) {
-                qbus_set_hotplug_handler(BUS(sec), NULL);
-                return;
-            }
-
             qbus_set_hotplug_handler(BUS(sec), OBJECT(hotplug_dev));
             /* We don't have to overwrite any other hotplug handler yet */
             assert(QLIST_EMPTY(&sec->child));
@@ -385,6 +361,24 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
     acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS);
 }
 
+bool acpi_pcihp_is_hotpluggbale_bus(AcpiPciHpState *s, BusState *bus)
+{
+    Object *o = OBJECT(bus->parent);
+
+    if (s->use_acpi_hotplug_bridge &&
+        object_dynamic_cast(o, TYPE_PCI_BRIDGE)) {
+        if (object_dynamic_cast(o, TYPE_PCIE_SLOT) && !PCIE_SLOT(o)->hotplug) {
+            return false;
+        }
+        return true;
+    }
+
+    if (s->use_acpi_root_pci_hotplug) {
+        return true;
+    }
+    return false;
+}
+
 static uint64_t pci_read(void *opaque, hwaddr addr, unsigned int size)
 {
     AcpiPciHpState *s = opaque;
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 0a233fa95d..63d2113b86 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -404,6 +404,13 @@ static void piix4_device_unplug_cb(HotplugHandler *hotplug_dev,
     }
 }
 
+static bool piix4_is_hotpluggable_bus(HotplugHandler *hotplug_dev,
+                                      BusState *bus)
+{
+    PIIX4PMState *s = PIIX4_PM(hotplug_dev);
+    return acpi_pcihp_is_hotpluggbale_bus(&s->acpi_pci_hotplug, bus);
+}
+
 static void piix4_pm_machine_ready(Notifier *n, void *opaque)
 {
     PIIX4PMState *s = container_of(n, PIIX4PMState, machine_ready);
@@ -644,6 +651,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data)
     hc->plug = piix4_device_plug_cb;
     hc->unplug_request = piix4_device_unplug_request_cb;
     hc->unplug = piix4_device_unplug_cb;
+    hc->is_hotpluggable_bus = piix4_is_hotpluggable_bus;
     adevc->ospm_status = piix4_ospm_status;
     adevc->send_event = piix4_send_gpe;
     adevc->madt_cpu = pc_madt_cpu_entry;
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 1fba3c210c..0e09e6b02c 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -865,6 +865,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data)
     hc->plug = ich9_pm_device_plug_cb;
     hc->unplug_request = ich9_pm_device_unplug_request_cb;
     hc->unplug = ich9_pm_device_unplug_cb;
+    hc->is_hotpluggable_bus = ich9_pm_is_hotpluggable_bus;
     adevc->ospm_status = ich9_pm_ospm_status;
     adevc->send_event = ich9_send_gpe;
     adevc->madt_cpu = pc_madt_cpu_entry;
-- 
2.39.1



  parent reply	other threads:[~2023-02-24 15:40 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-24 15:37 [PATCH 00/33] pci(pc/q35): acpi-index support on non-hotpluggable slots Igor Mammedov
2023-02-24 15:37 ` [PATCH 01/33] tests: acpi: whitelist new q35.noacpihp test and pc.hpbrroot Igor Mammedov
2023-02-24 15:37 ` [PATCH 02/33] tests: acpi: add test_acpi_q35_tcg_no_acpi_hotplug test and extend test_acpi_piix4_no_acpi_pci_hotplug Igor Mammedov
2023-02-24 15:37 ` [PATCH 03/33] tests: acpi: update expected blobs Igor Mammedov
2023-02-24 15:37 ` [PATCH 04/33] tests: acpi: whitelist q35/DSDT.multi-bridge before extending testcase Igor Mammedov
2023-02-24 15:37 ` [PATCH 05/33] tests: acpi: extend multi-bridge case with case 'root-port, id=HOHP, hotplug=off root-port, bus=NOHP' Igor Mammedov
2023-02-24 15:37 ` [PATCH 06/33] x86: pcihp: fix missing PCNT callchain when intermediate root-port has 'hotplug=off' set Igor Mammedov
2023-02-24 15:37 ` [PATCH 07/33] tests: acpi: whitelist pc/DSDT.hpbrroot and pc/DSDT.hpbridge tests Igor Mammedov
2023-02-24 15:37 ` [PATCH 08/33] x86: pcihp: fix missing bridge AML when intermediate root-port has 'hotplug=off' set Igor Mammedov
2023-02-24 15:37 ` [PATCH 09/33] tests: acpi: update expected blobs Igor Mammedov
2023-02-24 15:37 ` [PATCH 10/33] pcihp: piix4: do not redirect hotplug controller to piix4 when ACPI hotplug is disabled Igor Mammedov
2023-02-24 15:37 ` [PATCH 11/33] pci: fix 'hotplugglable' property behavior Igor Mammedov
2023-02-24 15:37 ` [PATCH 12/33] tests: acpi: whitelist DSDT blobs before isolating PCI _DSM func 0 prolog Igor Mammedov
2023-02-24 15:37 ` [PATCH 13/33] pcihp: move PCI _DSM function 0 prolog into separate function Igor Mammedov
2023-02-24 15:37 ` [PATCH 14/33] tests: acpi: update expected blobs Igor Mammedov
2023-03-02  0:27   ` Michael S. Tsirkin
2023-03-02 12:02     ` Igor Mammedov
2023-03-02 12:55       ` Fabiano Rosas
2023-03-02 14:57         ` Igor Mammedov
2023-03-02 15:43           ` Fabiano Rosas
2023-03-02 15:59             ` Igor Mammedov
2023-03-02  0:37   ` Michael S. Tsirkin
2023-02-24 15:37 ` [PATCH 15/33] tests: acpi: whitelist DSDT before adding EDSM method Igor Mammedov
2023-02-24 15:37 ` [PATCH 16/33] acpi: pci: add EDSM method to DSDT Igor Mammedov
2023-02-24 15:37 ` [PATCH 17/33] tests: acpi: update expected blobs Igor Mammedov
2023-02-24 15:37 ` [PATCH 18/33] tests: acpi: whitelist DSDT before adding device with acpi-index to testcases Igor Mammedov
2023-02-24 15:37 ` [PATCH 19/33] tests: acpi: add device with acpi-index on non-hotpluggble bus Igor Mammedov
2023-02-24 15:37 ` [PATCH 20/33] acpi: pci: support acpi-index for non-hotpluggable devices Igor Mammedov
2023-02-24 15:38 ` [PATCH 21/33] tests: acpi: update expected blobs Igor Mammedov
2023-02-24 15:38 ` [PATCH 22/33] tests: acpi: whitelist DSDT before exposing non zero functions Igor Mammedov
2023-02-24 15:38 ` [PATCH 23/33] acpi: pci: describe all functions on populated slots Igor Mammedov
2023-02-24 15:38 ` [PATCH 24/33] tests: acpi: update expected blobs Igor Mammedov
2023-02-24 15:38 ` [PATCH 25/33] tests: acpi: whitelist DSDT before adding non-0 function device with acpi-index to testcases Igor Mammedov
2023-02-24 15:38 ` [PATCH 26/33] tests: acpi: add non zero function device with acpi-index on non-hotpluggble bus Igor Mammedov
2023-02-24 15:38 ` [PATCH 27/33] tests: acpi: update expected blobs Igor Mammedov
2023-02-24 15:38 ` [PATCH 28/33] pci: move acpi-index uniqueness check to generic PCI device code Igor Mammedov
2023-02-24 15:38 ` [PATCH 29/33] acpi: pci: drop BSEL usage when deciding that device isn't hotpluggable Igor Mammedov
2023-02-24 15:38 ` [PATCH 30/33] acpi: pci: move BSEL into build_append_pcihp_slots() Igor Mammedov
2023-02-24 15:38 ` [PATCH 31/33] acpi: pci: move out ACPI PCI hotplug generator from generic slot generator build_append_pci_bus_devices() Igor Mammedov
2023-02-24 15:38 ` [PATCH 32/33] pcihp: move fields enabling hotplug into AcpiPciHpState Igor Mammedov
2023-02-24 15:38 ` Igor Mammedov [this message]
2023-03-02 10:59 ` [PATCH 00/33] pci(pc/q35): acpi-index support on non-hotpluggable slots Michael S. Tsirkin
2023-03-02 12:05   ` Jonathan Cameron via
2023-03-02 12:07   ` Igor Mammedov
2023-03-02 23:21     ` Michael S. Tsirkin
2023-03-06 10:49       ` Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230224153812.4176226-34-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=ani@anisinha.ca \
    --cc=berrange@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).