hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop
Move the ACPI_PCIHP_PROP_BSEL property to the PCIBus object and update all callers accordingly. Since the existing logic checks for the existence of the ACPI_PCIHP_PROP_BSEL property to enable the relevant ACPI changes, set the type of the underlying variable to uint32_t with a default value of UINT32_MAX indicating that the property has not been set. Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20260825134320.1039012-15-mark.caveayland@nutanix.com>
Mark Cave-Ayland committed
Aug 25, 2026 at 14:41 UTC
9ef643bbc8362dd69420acdadef4674d9b10d18e
6 files changed
+39
-19
hw/acpi/pci-bridge.c
+8
-1
@@ -23,6 +23,8 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
23
24
if (!DEVICE(br)->hotplugged) {
25
PCIBus *sec_bus = pci_bridge_get_sec_bus(br);
26
+ Error *local_err = NULL;
27
+ uint32_t bsel;
28
29
build_append_pci_bus_devices(scope, sec_bus);
30
@@ -30,9 +32,14 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
32
* generate hotplug slots descriptors if
33
* bridge has ACPI PCI hotplug attached,
34
*/
33
- if (object_property_find(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL)) {
35
+ bsel = object_property_get_uint(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL,
36
+ &local_err);
37
+
38
+ if (local_err == NULL && bsel != UINT32_MAX) {
39
build_append_pcihp_slots(scope, sec_bus);
40
}
41
+
42
+ error_free(local_err);
43
}
44
}
45
hw/acpi/pcihp.c
+14
-16
@@ -58,7 +58,7 @@ typedef struct AcpiPciHpFind {
58
static int acpi_pcihp_get_bsel(PCIBus *bus)
59
{
60
Error *local_err = NULL;
61
- uint64_t bsel = object_property_get_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
61
+ uint32_t bsel = object_property_get_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
62
&local_err);
63
64
if (local_err || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) {
@@ -78,18 +78,14 @@ typedef struct {
78
static void *acpi_set_bsel(PCIBus *bus, void *opaque)
79
{
80
BSELInfo *info = opaque;
81
- unsigned *bus_bsel;
81
DeviceState *br = bus->qbus.parent;
82
bool is_bridge = IS_PCI_BRIDGE(br);
83
84
/* hotplugged bridges can't be described in ACPI ignore them */
85
if (qbus_is_hotpluggable(BUS(bus))) {
86
if (!is_bridge || (!br->hotplugged && info->has_bridge_hotplug)) {
88
- bus_bsel = g_malloc(sizeof *bus_bsel);
89
-
90
- *bus_bsel = info->bsel_alloc++;
91
- object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
92
- bus_bsel, OBJ_PROP_FLAG_READ);
87
+ object_property_set_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
88
+ info->bsel_alloc++, NULL);
89
}
90
}
91
@@ -730,14 +726,16 @@ bool build_append_notification_callback(Aml *parent_scope, const PCIBus *bus)
726
/* If bus supports hotplug select it and notify about local events */
727
bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL);
728
if (bsel) {
733
- uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
734
-
735
- aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
736
- aml_append(method, aml_call2("DVNT", aml_name("PCIU"),
737
- aml_int(1))); /* Device Check */
738
- aml_append(method, aml_call2("DVNT", aml_name("PCID"),
739
- aml_int(3))); /* Eject Request */
740
- nr_notifiers++;
729
+ uint32_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
730
+
731
+ if (bsel_val != UINT32_MAX) {
732
+ aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
733
+ aml_append(method, aml_call2("DVNT", aml_name("PCIU"),
734
+ aml_int(1))); /* Device Check */
735
+ aml_append(method, aml_call2("DVNT", aml_name("PCID"),
736
+ aml_int(3))); /* Eject Request */
737
+ nr_notifiers++;
738
+ }
739
}
740
741
/* Notify about child bus events in any case */
@@ -848,7 +846,7 @@ void build_append_pcihp_slots(Aml *parent_scope, PCIBus *bus)
846
Aml *dev, *notify_method = NULL, *method;
847
QObject *bsel = object_property_get_qobject(OBJECT(bus),
848
ACPI_PCIHP_PROP_BSEL, NULL);
851
- uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
849
+ uint32_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
850
qobject_unref(bsel);
851
852
aml_append(parent_scope, aml_name_decl("BSEL", aml_int(bsel_val)));
hw/arm/virt-acpi-build.c
+4
-1
@@ -1207,6 +1207,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
1207
AcpiTable table = { .sig = "DSDT", .rev = 2, .oem_id = vms->oem_id,
1208
.oem_table_id = vms->oem_table_id };
1209
Aml *pci0_scope;
1210
+ uint32_t bsel;
1211
1212
acpi_table_begin(&table, table_data);
1213
dsdt = init_aml_allocator();
@@ -1269,7 +1270,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
1270
1271
aml_append(pci0_scope, build_pci_bridge_edsm());
1272
build_append_pci_bus_devices(pci0_scope, vms->bus);
1272
- if (object_property_find(OBJECT(vms->bus), ACPI_PCIHP_PROP_BSEL)) {
1273
+ bsel = object_property_get_uint(OBJECT(vms->bus), ACPI_PCIHP_PROP_BSEL,
1274
+ &error_abort);
1275
+ if (bsel != UINT32_MAX) {
1276
build_append_pcihp_slots(pci0_scope, vms->bus);
1277
}
1278
hw/i386/acpi-build.c
+4
-1
@@ -1198,13 +1198,16 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
1198
sb_scope = aml_scope("\\_SB");
1199
{
1200
Object *pci_host = acpi_get_i386_pci_host();
1201
+ uint32_t bsel;
1202
1203
if (pci_host) {
1204
PCIBus *pbus = PCI_HOST_BRIDGE(pci_host)->bus;
1205
Aml *ascope = aml_scope("PCI0");
1206
/* Scan all PCI buses. Generate tables to support hotplug. */
1207
build_append_pci_bus_devices(ascope, pbus);
1207
- if (object_property_find(OBJECT(pbus), ACPI_PCIHP_PROP_BSEL)) {
1208
+ bsel = object_property_get_uint(OBJECT(pbus), ACPI_PCIHP_PROP_BSEL,
1209
+ &error_abort);
1210
+ if (bsel != UINT32_MAX) {
1211
build_append_pcihp_slots(ascope, pbus);
1212
}
1213
aml_append(sb_scope, ascope);
hw/pci/pci.c
+7
@@ -25,6 +25,7 @@
25
#include "qemu/osdep.h"
26
#include "qemu/datadir.h"
27
#include "qemu/units.h"
28
+#include "hw/acpi/pcihp.h"
29
#include "hw/core/irq.h"
30
#include "hw/pci/pci.h"
31
#include "hw/pci/pci_bridge.h"
@@ -187,6 +188,8 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
188
bus->machine_done.notify = pcibus_machine_done;
189
qemu_add_machine_init_done_notifier(&bus->machine_done);
190
191
+ bus->acpi_pcihp_bsel_val = UINT32_MAX;
192
+
193
vmstate_register_any(NULL, &vmstate_pcibus, bus);
194
}
195
@@ -302,6 +305,10 @@ static void pci_bus_class_init(ObjectClass *klass, const void *data)
305
pbc->numa_node = pcibus_numa_node;
306
307
fwgc->get_data = pci_bus_fw_cfg_gen_data;
308
+
309
+ object_class_property_add_uint32_ptr(klass, ACPI_PCIHP_PROP_BSEL,
310
+ offsetof(PCIBus, acpi_pcihp_bsel_val),
311
+ OBJ_PROP_FLAG_READWRITE);
312
}
313
314
static const TypeInfo pci_bus_info = {
include/hw/pci/pci_bus.h
+2
@@ -56,6 +56,8 @@ struct PCIBus {
56
int *irq_count;
57
58
Notifier machine_done;
59
+
60
+ uint32_t acpi_pcihp_bsel_val;
61
};
62
63
static inline bool pci_bus_is_cxl(PCIBus *bus)