[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/17] hw/acpi: Move acpi_set_pci_info to pcihp
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 04/17] hw/acpi: Move acpi_set_pci_info to pcihp |
Date: |
Fri, 8 Sep 2017 17:19:08 +0300 |
From: Anthony PERARD <address@hidden>
HW part of ACPI PCI hotplug in QEMU depends on ACPI_PCIHP_PROP_BSEL
being set on a PCI bus that supports ACPI hotplug. It should work
regardless of the source of ACPI tables (QEMU generator/legacy SeaBIOS/Xen).
So move ACPI_PCIHP_PROP_BSEL initialization into HW ACPI implementation
part from QEMU's ACPI table generator.
To do PCI passthrough with Xen, the property ACPI_PCIHP_PROP_BSEL needs
to be set, but this was done only when ACPI tables are built which is
not needed for a Xen guest. The need for the property starts with commit
"pc: pcihp: avoid adding ACPI_PCIHP_PROP_BSEL twice"
(f0c9d64a68b776374ec4732424a3e27753ce37b6).
Adding find_i440fx into stubs so that mips-softmmu target can be built.
Reported-by: Sander Eikelenboom <address@hidden>
Signed-off-by: Anthony PERARD <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/acpi/pcihp.c | 38 ++++++++++++++++++++++++++++++++++++++
hw/i386/acpi-build.c | 32 --------------------------------
stubs/pci-host-piix.c | 6 ++++++
stubs/Makefile.objs | 1 +
4 files changed, 45 insertions(+), 32 deletions(-)
create mode 100644 stubs/pci-host-piix.c
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 9db3c2e..7da51c0 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -75,6 +75,43 @@ static int acpi_pcihp_get_bsel(PCIBus *bus)
}
}
+/* Assign BSEL property to all buses. In the future, this can be changed
+ * to only assign to buses that support hotplug.
+ */
+static void *acpi_set_bsel(PCIBus *bus, void *opaque)
+{
+ unsigned *bsel_alloc = opaque;
+ unsigned *bus_bsel;
+
+ if (qbus_is_hotpluggable(BUS(bus))) {
+ bus_bsel = g_malloc(sizeof *bus_bsel);
+
+ *bus_bsel = (*bsel_alloc)++;
+ object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
+ bus_bsel, &error_abort);
+ }
+
+ return bsel_alloc;
+}
+
+static void acpi_set_pci_info(void)
+{
+ static bool bsel_is_set;
+ PCIBus *bus;
+ unsigned bsel_alloc = ACPI_PCIHP_BSEL_DEFAULT;
+
+ if (bsel_is_set) {
+ return;
+ }
+ bsel_is_set = true;
+
+ bus = find_i440fx(); /* TODO: Q35 support */
+ if (bus) {
+ /* Scan all PCI buses. Set property to enable acpi based hotplug. */
+ pci_for_each_bus_depth_first(bus, acpi_set_bsel, NULL, &bsel_alloc);
+ }
+}
+
static void acpi_pcihp_test_hotplug_bus(PCIBus *bus, void *opaque)
{
AcpiPciHpFind *find = opaque;
@@ -177,6 +214,7 @@ static void acpi_pcihp_update(AcpiPciHpState *s)
void acpi_pcihp_reset(AcpiPciHpState *s)
{
+ acpi_set_pci_info();
acpi_pcihp_update(s);
}
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 98dd424..4d19d91 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -493,36 +493,6 @@ build_madt(GArray *table_data, BIOSLinker *linker,
PCMachineState *pcms)
table_data->len - madt_start, 1, NULL, NULL);
}
-/* Assign BSEL property to all buses. In the future, this can be changed
- * to only assign to buses that support hotplug.
- */
-static void *acpi_set_bsel(PCIBus *bus, void *opaque)
-{
- unsigned *bsel_alloc = opaque;
- unsigned *bus_bsel;
-
- if (qbus_is_hotpluggable(BUS(bus))) {
- bus_bsel = g_malloc(sizeof *bus_bsel);
-
- *bus_bsel = (*bsel_alloc)++;
- object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
- bus_bsel, &error_abort);
- }
-
- return bsel_alloc;
-}
-
-static void acpi_set_pci_info(void)
-{
- PCIBus *bus = find_i440fx(); /* TODO: Q35 support */
- unsigned bsel_alloc = ACPI_PCIHP_BSEL_DEFAULT;
-
- if (bus) {
- /* Scan all PCI buses. Set property to enable acpi based hotplug. */
- pci_for_each_bus_depth_first(bus, acpi_set_bsel, NULL, &bsel_alloc);
- }
-}
-
static void build_append_pcihp_notify_entry(Aml *method, int slot)
{
Aml *if_ctx;
@@ -2888,8 +2858,6 @@ void acpi_setup(void)
build_state = g_malloc0(sizeof *build_state);
- acpi_set_pci_info();
-
acpi_build_tables_init(&tables);
acpi_build(&tables, MACHINE(pcms));
diff --git a/stubs/pci-host-piix.c b/stubs/pci-host-piix.c
new file mode 100644
index 0000000..6ed81b1
--- /dev/null
+++ b/stubs/pci-host-piix.c
@@ -0,0 +1,6 @@
+#include "qemu/osdep.h"
+#include "hw/i386/pc.h"
+PCIBus *find_i440fx(void)
+{
+ return NULL;
+}
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index e69c217..4a33495 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -40,3 +40,4 @@ stub-obj-y += pc_madt_cpu_entry.o
stub-obj-y += vmgenid.o
stub-obj-y += xen-common.o
stub-obj-y += xen-hvm.o
+stub-obj-y += pci-host-piix.o
--
MST
- [Qemu-devel] [PULL 00/17] pc, pci, virtio: patches queued before 2.10, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 03/17] hw/acpi: Limit hotplug to root bus on legacy mode, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 04/17] hw/acpi: Move acpi_set_pci_info to pcihp,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 06/17] hw/pci: introduce pcie-pci-bridge device, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 05/17] Revert "ACPI: don't call acpi_pcihp_device_plug_cb on xen", Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 02/17] pc: add 2.11 machine types, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 08/17] hw/pci: add QEMU-specific PCI capability to the Generic PCI Express Root Port, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 07/17] hw/pci: introduce bridge-only vendor-specific capability to provide some hints to firmware, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 09/17] docs: update documentation considering PCIE-PCI bridge, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 11/17] acpi/vmgenid: change device category to misc, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 12/17] libvhost-user: support resuming vq->last_avail_idx based on used_idx, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 10/17] intel_iommu: fix missing BQL in pt fast path, Michael S. Tsirkin, 2017/09/08
- [Qemu-devel] [PULL 13/17] vhost-user-bridge: fix resume regression (since 2.9), Michael S. Tsirkin, 2017/09/08