* [PATCH v2] acpi: x86: pcihp: add support hotplug on multifunction bridges
@ 2021-07-23 9:04 Igor Mammedov
2021-07-25 8:11 ` Marcel Apfelbaum
0 siblings, 1 reply; 2+ messages in thread
From: Igor Mammedov @ 2021-07-23 9:04 UTC (permalink / raw)
To: qemu-devel; +Cc: Laurent Vivier, peter.maydell, berrange, mst, jusual
Commit [1] switched PCI hotplug from native to ACPI one by default.
That however breaks hotplug on following CLI that used to work:
-nodefaults -machine q35 \
-device pcie-root-port,id=pcie-root-port-0,multifunction=on,bus=pcie.0,addr=0x1,chassis=1 \
-device pcie-root-port,id=pcie-root-port-1,port=0x1,addr=0x1.0x1,bus=pcie.0,chassis=2
where PCI device is hotplugged to pcie-root-port-1 with error on guest side:
ACPI BIOS Error (bug): Could not resolve symbol [^S0B.PCNT], AE_NOT_FOUND (20201113/psargs-330)
ACPI Error: Aborting method \_SB.PCI0.PCNT due to previous error (AE_NOT_FOUND) (20201113/psparse-531)
ACPI Error: Aborting method \_GPE._E01 due to previous error (AE_NOT_FOUND) (20201113/psparse-531)
ACPI Error: AE_NOT_FOUND, while evaluating GPE method [_E01] (20201113/evgpe-515)
cause is that QEMU's ACPI hotplug never supported functions other then 0
and due to bug it was generating notification entries for not described
functions.
Technically there is no reason not to describe cold-plugged bridges
(root ports) on functions other then 0, as they similarly to bridge
on function 0 are unpluggable.
So since we need to describe multifunction devices iterate over
fuctions as well. But describe only cold-plugged bridges[root ports]
on functions other than 0 as well.
1)
Fixes: 17858a169508609ca9063c544833e5a1adeb7b52 (hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35)
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reported-by: Laurent Vivier <lvivier@redhat.com>
---
v2:
* squash 1/2 "acpi: x86: pcihp: cleanup devfn usage in build_append_pci_bus_devices()"
into the main patch
* drop Sxx -> Sxxx change as devfn fits into 2 digits anyway
* cleanup PCI_FUN/DEVFN and use func/devfn local variables instead
* fix typos
---
hw/i386/acpi-build.c | 44 ++++++++++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 14 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 17836149fe..a33ac8b91e 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -374,7 +374,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
Aml *dev, *notify_method = NULL, *method;
QObject *bsel;
PCIBus *sec;
- int i;
+ int devfn;
bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL);
if (bsel) {
@@ -384,23 +384,31 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
notify_method = aml_method("DVNT", 2, AML_NOTSERIALIZED);
}
- for (i = 0; i < ARRAY_SIZE(bus->devices); i += PCI_FUNC_MAX) {
+ for (devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) {
DeviceClass *dc;
PCIDeviceClass *pc;
- PCIDevice *pdev = bus->devices[i];
- int slot = PCI_SLOT(i);
+ PCIDevice *pdev = bus->devices[devfn];
+ int slot = PCI_SLOT(devfn);
+ int func = PCI_FUNC(devfn);
+ /* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */
+ int adr = slot << 16 | func;
bool hotplug_enabled_dev;
bool bridge_in_acpi;
bool cold_plugged_bridge;
if (!pdev) {
- if (bsel) { /* add hotplug slots for non present devices */
+ /*
+ * add hotplug slots for non present devices.
+ * hotplug is supported only for non-multifunction device
+ * so generate device description only for function 0
+ */
+ if (bsel && !func) {
if (pci_bus_is_express(bus) && slot > 0) {
break;
}
- dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
+ dev = aml_device("S%.02X", devfn);
aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
- aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
+ aml_append(dev, aml_name_decl("_ADR", aml_int(adr)));
method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
aml_append(method,
aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
@@ -436,9 +444,18 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
continue;
}
- /* start to compose PCI slot descriptor */
- dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
- aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
+ /*
+ * allow describing coldplugged bridges in ACPI even if they are not
+ * on function 0, as they are not unpluggable, for all other devices
+ * generate description only for function 0 per slot
+ */
+ if (func && !bridge_in_acpi) {
+ continue;
+ }
+
+ /* start to compose PCI device descriptor */
+ dev = aml_device("S%.02X", devfn);
+ aml_append(dev, aml_name_decl("_ADR", aml_int(adr)));
if (bsel) {
/*
@@ -496,7 +513,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
}
- /* slot descriptor has been composed, add it into parent context */
+ /* device descriptor has been composed, add it into parent context */
aml_append(parent_scope, dev);
}
@@ -525,13 +542,12 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
/* Notify about child bus events in any case */
if (pcihp_bridge_en) {
QLIST_FOREACH(sec, &bus->child, sibling) {
- int32_t devfn = sec->parent_dev->devfn;
-
if (pci_bus_is_root(sec)) {
continue;
}
- aml_append(method, aml_name("^S%.02X.PCNT", devfn));
+ aml_append(method, aml_name("^S%.02X.PCNT",
+ sec->parent_dev->devfn));
}
}
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] acpi: x86: pcihp: add support hotplug on multifunction bridges
2021-07-23 9:04 [PATCH v2] acpi: x86: pcihp: add support hotplug on multifunction bridges Igor Mammedov
@ 2021-07-25 8:11 ` Marcel Apfelbaum
0 siblings, 0 replies; 2+ messages in thread
From: Marcel Apfelbaum @ 2021-07-25 8:11 UTC (permalink / raw)
To: Igor Mammedov
Cc: Laurent Vivier, Peter Maydell, Daniel P. Berrangé,
Michael S. Tsirkin, Julia Suvorova, qemu devel list
[-- Attachment #1: Type: text/plain, Size: 6459 bytes --]
Hi Igor,
On Fri, Jul 23, 2021 at 12:04 PM Igor Mammedov <imammedo@redhat.com> wrote:
> Commit [1] switched PCI hotplug from native to ACPI one by default.
>
> That however breaks hotplug on following CLI that used to work:
> -nodefaults -machine q35 \
> -device
> pcie-root-port,id=pcie-root-port-0,multifunction=on,bus=pcie.0,addr=0x1,chassis=1
> \
> -device
> pcie-root-port,id=pcie-root-port-1,port=0x1,addr=0x1.0x1,bus=pcie.0,chassis=2
>
> where PCI device is hotplugged to pcie-root-port-1 with error on guest
> side:
>
> ACPI BIOS Error (bug): Could not resolve symbol [^S0B.PCNT],
> AE_NOT_FOUND (20201113/psargs-330)
> ACPI Error: Aborting method \_SB.PCI0.PCNT due to previous error
> (AE_NOT_FOUND) (20201113/psparse-531)
> ACPI Error: Aborting method \_GPE._E01 due to previous error
> (AE_NOT_FOUND) (20201113/psparse-531)
> ACPI Error: AE_NOT_FOUND, while evaluating GPE method [_E01]
> (20201113/evgpe-515)
>
> cause is that QEMU's ACPI hotplug never supported functions other then 0
> and due to bug it was generating notification entries for not described
> functions.
>
> Technically there is no reason not to describe cold-plugged bridges
> (root ports) on functions other then 0, as they similarly to bridge
> on function 0 are unpluggable.
>
> So since we need to describe multifunction devices iterate over
> fuctions as well. But describe only cold-plugged bridges[root ports]
> on functions other than 0 as well.
>
> 1)
> Fixes: 17858a169508609ca9063c544833e5a1adeb7b52 (hw/acpi/ich9: Set ACPI
> PCI hot-plug as default on Q35)
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reported-by: Laurent Vivier <lvivier@redhat.com>
> ---
> v2:
> * squash 1/2 "acpi: x86: pcihp: cleanup devfn usage in
> build_append_pci_bus_devices()"
> into the main patch
> * drop Sxx -> Sxxx change as devfn fits into 2 digits anyway
> * cleanup PCI_FUN/DEVFN and use func/devfn local variables instead
> * fix typos
> ---
> hw/i386/acpi-build.c | 44 ++++++++++++++++++++++++++++++--------------
> 1 file changed, 30 insertions(+), 14 deletions(-)
>
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 17836149fe..a33ac8b91e 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -374,7 +374,7 @@ static void build_append_pci_bus_devices(Aml
> *parent_scope, PCIBus *bus,
> Aml *dev, *notify_method = NULL, *method;
> QObject *bsel;
> PCIBus *sec;
> - int i;
> + int devfn;
>
> bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
> NULL);
> if (bsel) {
> @@ -384,23 +384,31 @@ static void build_append_pci_bus_devices(Aml
> *parent_scope, PCIBus *bus,
> notify_method = aml_method("DVNT", 2, AML_NOTSERIALIZED);
> }
>
> - for (i = 0; i < ARRAY_SIZE(bus->devices); i += PCI_FUNC_MAX) {
> + for (devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) {
> DeviceClass *dc;
> PCIDeviceClass *pc;
> - PCIDevice *pdev = bus->devices[i];
> - int slot = PCI_SLOT(i);
> + PCIDevice *pdev = bus->devices[devfn];
> + int slot = PCI_SLOT(devfn);
> + int func = PCI_FUNC(devfn);
> + /* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */
> + int adr = slot << 16 | func;
> bool hotplug_enabled_dev;
> bool bridge_in_acpi;
> bool cold_plugged_bridge;
>
> if (!pdev) {
> - if (bsel) { /* add hotplug slots for non present devices */
> + /*
> + * add hotplug slots for non present devices.
> + * hotplug is supported only for non-multifunction device
> + * so generate device description only for function 0
> + */
> + if (bsel && !func) {
> if (pci_bus_is_express(bus) && slot > 0) {
> break;
> }
> - dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
> + dev = aml_device("S%.02X", devfn);
> aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
> - aml_append(dev, aml_name_decl("_ADR", aml_int(slot <<
> 16)));
> + aml_append(dev, aml_name_decl("_ADR", aml_int(adr)));
> method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
> aml_append(method,
> aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
> @@ -436,9 +444,18 @@ static void build_append_pci_bus_devices(Aml
> *parent_scope, PCIBus *bus,
> continue;
> }
>
> - /* start to compose PCI slot descriptor */
> - dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
> - aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
> + /*
> + * allow describing coldplugged bridges in ACPI even if they are
> not
> + * on function 0, as they are not unpluggable, for all other
> devices
> + * generate description only for function 0 per slot
> + */
> + if (func && !bridge_in_acpi) {
> + continue;
> + }
> +
> + /* start to compose PCI device descriptor */
> + dev = aml_device("S%.02X", devfn);
> + aml_append(dev, aml_name_decl("_ADR", aml_int(adr)));
>
> if (bsel) {
> /*
> @@ -496,7 +513,7 @@ static void build_append_pci_bus_devices(Aml
> *parent_scope, PCIBus *bus,
>
> build_append_pci_bus_devices(dev, sec_bus, pcihp_bridge_en);
> }
> - /* slot descriptor has been composed, add it into parent context
> */
> + /* device descriptor has been composed, add it into parent
> context */
> aml_append(parent_scope, dev);
> }
>
> @@ -525,13 +542,12 @@ static void build_append_pci_bus_devices(Aml
> *parent_scope, PCIBus *bus,
> /* Notify about child bus events in any case */
> if (pcihp_bridge_en) {
> QLIST_FOREACH(sec, &bus->child, sibling) {
> - int32_t devfn = sec->parent_dev->devfn;
> -
> if (pci_bus_is_root(sec)) {
> continue;
> }
>
> - aml_append(method, aml_name("^S%.02X.PCNT", devfn));
> + aml_append(method, aml_name("^S%.02X.PCNT",
> + sec->parent_dev->devfn));
> }
> }
>
> --
> 2.27.0
>
>
Thanks for fixing it!
Reviewed-by: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Thanks,
Marcel
[-- Attachment #2: Type: text/html, Size: 8172 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-25 8:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-23 9:04 [PATCH v2] acpi: x86: pcihp: add support hotplug on multifunction bridges Igor Mammedov
2021-07-25 8:11 ` Marcel Apfelbaum
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).