acpi: pci: move BSEL into build_append_pcihp_slots()

Generic PCI enumeration code doesn't really need access to
BSEL value, it is only used as means to decide if hotplug
enumerator should be called.

Use stateless object_property_find() to do that, and move
the rest of BSEL handling into build_append_pcihp_slots()
where it belongs.

This cleans up generic code a bit from hotplug stuff
and follow up patch will remove remaining call to
build_append_pcihp_slots() from generic code, making
it possible to use without ACPI PCI hotplug dependencies.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20230302161543.286002-32-imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Igor Mammedov 2023-03-02 17:15:40 +01:00 committed by Michael S. Tsirkin
parent 419233b2b4
commit 62dd55fcf7

View File

@ -520,12 +520,14 @@ static bool is_devfn_ignored_hotplug(const int devfn, const PCIBus *bus)
return false; return false;
} }
static void build_append_pcihp_slots(Aml *parent_scope, PCIBus *bus, static void build_append_pcihp_slots(Aml *parent_scope, PCIBus *bus)
QObject *bsel)
{ {
int devfn; int devfn;
Aml *dev, *notify_method = NULL, *method; Aml *dev, *notify_method = NULL, *method;
QObject *bsel = object_property_get_qobject(OBJECT(bus),
ACPI_PCIHP_PROP_BSEL, NULL);
uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel)); uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
qobject_unref(bsel);
aml_append(parent_scope, aml_name_decl("BSEL", aml_int(bsel_val))); aml_append(parent_scope, aml_name_decl("BSEL", aml_int(bsel_val)));
notify_method = aml_method("DVNT", 2, AML_NOTSERIALIZED); notify_method = aml_method("DVNT", 2, AML_NOTSERIALIZED);
@ -570,12 +572,9 @@ static void build_append_pcihp_slots(Aml *parent_scope, PCIBus *bus,
void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus) void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus)
{ {
QObject *bsel;
int devfn; int devfn;
Aml *dev; Aml *dev;
bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL);
for (devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) { for (devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) {
/* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */ /* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */
int adr = PCI_SLOT(devfn) << 16 | PCI_FUNC(devfn); int adr = PCI_SLOT(devfn) << 16 | PCI_FUNC(devfn);
@ -601,11 +600,9 @@ void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus)
aml_append(parent_scope, dev); aml_append(parent_scope, dev);
} }
if (bsel) { if (object_property_find(OBJECT(bus), ACPI_PCIHP_PROP_BSEL)) {
build_append_pcihp_slots(parent_scope, bus, bsel); build_append_pcihp_slots(parent_scope, bus);
} }
qobject_unref(bsel);
} }
static bool build_append_notfication_callback(Aml *parent_scope, static bool build_append_notfication_callback(Aml *parent_scope,