From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Mark Cave-Ayland <mark.caveayland@nutanix.com>
Cc: mst@redhat.com, imammedo@redhat.com, anisinha@redhat.com,
philmd@mailo.com, aurelien@aurel32.net, peter.maydell@linaro.org,
richard.henderson@linaro.org, marcandre.lureau@redhat.com,
qemu-devel@nongnu.org, qemu-arm@nongnu.org
Subject: Re: [PATCH v4 14/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop
Date: Mon, 24 Aug 2026 14:04:55 +0100 [thread overview]
Message-ID: <aoxBd0tGArc8rwdf@redhat.com> (raw)
In-Reply-To: <20260821111550.276011-15-mark.caveayland@nutanix.com>
On Fri, Aug 21, 2026 at 12:14:26PM +0100, Mark Cave-Ayland wrote:
> 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>
> ---
> include/hw/pci/pci_bus.h | 2 ++
> hw/acpi/pci-bridge.c | 9 ++++++++-
> hw/acpi/pcihp.c | 30 ++++++++++++++----------------
> hw/arm/virt-acpi-build.c | 7 ++++++-
> hw/i386/acpi-build.c | 7 ++++++-
> hw/pci/pci.c | 7 +++++++
> 6 files changed, 43 insertions(+), 19 deletions(-)
>
> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
> index c738446788..7ecb23d13c 100644
> --- a/include/hw/pci/pci_bus.h
> +++ b/include/hw/pci/pci_bus.h
> @@ -56,6 +56,8 @@ struct PCIBus {
> int *irq_count;
>
> Notifier machine_done;
> +
> + uint32_t acpi_pcihp_bsel_val;
> };
>
> static inline bool pci_bus_is_cxl(PCIBus *bus)
> diff --git a/hw/acpi/pci-bridge.c b/hw/acpi/pci-bridge.c
> index 394a919479..1bfc5431f2 100644
> --- a/hw/acpi/pci-bridge.c
> +++ b/hw/acpi/pci-bridge.c
> @@ -23,6 +23,8 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
>
> if (!DEVICE(br)->hotplugged) {
> PCIBus *sec_bus = pci_bridge_get_sec_bus(br);
> + Error *local_err = NULL;
> + uint32_t bsel;
>
> build_append_pci_bus_devices(scope, sec_bus);
>
> @@ -30,9 +32,14 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope)
> * generate hotplug slots descriptors if
> * bridge has ACPI PCI hotplug attached,
> */
> - if (object_property_find(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL)) {
> + bsel = object_property_get_uint(OBJECT(sec_bus), ACPI_PCIHP_PROP_BSEL,
> + &local_err);
> +
> + if (local_err == NULL && bsel != UINT32_MAX) {
> build_append_pcihp_slots(scope, sec_bus);
> }
> +
> + error_free(local_err);
IIUC, in this new approach the property should always exist and so I'd
expect object_property_get_uint to always succeed.
IOW, is something stopping us using &error_abort and merely checking
if (bsel != UINT32_MAX)
?
> }
> }
>
> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> index a91f523c93..b26ddf0a26 100644
> --- a/hw/acpi/pcihp.c
> +++ b/hw/acpi/pcihp.c
> @@ -58,7 +58,7 @@ typedef struct AcpiPciHpFind {
> static int acpi_pcihp_get_bsel(PCIBus *bus)
> {
> Error *local_err = NULL;
> - uint64_t bsel = object_property_get_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
> + uint32_t bsel = object_property_get_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
> &local_err);
>
> if (local_err || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) {
> @@ -78,18 +78,14 @@ typedef struct {
> static void *acpi_set_bsel(PCIBus *bus, void *opaque)
> {
> BSELInfo *info = opaque;
> - unsigned *bus_bsel;
> DeviceState *br = bus->qbus.parent;
> bool is_bridge = IS_PCI_BRIDGE(br);
>
> /* hotplugged bridges can't be described in ACPI ignore them */
> if (qbus_is_hotpluggable(BUS(bus))) {
> if (!is_bridge || (!br->hotplugged && info->has_bridge_hotplug)) {
> - bus_bsel = g_malloc(sizeof *bus_bsel);
> -
> - *bus_bsel = info->bsel_alloc++;
> - object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
> - bus_bsel, OBJ_PROP_FLAG_READ);
> + object_property_set_uint(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
> + info->bsel_alloc++, NULL);
> }
> }
>
> @@ -730,14 +726,16 @@ bool build_append_notification_callback(Aml *parent_scope, const PCIBus *bus)
> /* If bus supports hotplug select it and notify about local events */
> bsel = object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, NULL);
> if (bsel) {
> - uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
> -
> - aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
> - aml_append(method, aml_call2("DVNT", aml_name("PCIU"),
> - aml_int(1))); /* Device Check */
> - aml_append(method, aml_call2("DVNT", aml_name("PCID"),
> - aml_int(3))); /* Eject Request */
> - nr_notifiers++;
> + uint32_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
> +
> + if (bsel_val != UINT32_MAX) {
> + aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
> + aml_append(method, aml_call2("DVNT", aml_name("PCIU"),
> + aml_int(1))); /* Device Check */
> + aml_append(method, aml_call2("DVNT", aml_name("PCID"),
> + aml_int(3))); /* Eject Request */
> + nr_notifiers++;
> + }
> }
>
> /* Notify about child bus events in any case */
> @@ -848,7 +846,7 @@ void build_append_pcihp_slots(Aml *parent_scope, PCIBus *bus)
> 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));
> + uint32_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)));
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index f6386088b6..7ba7b38773 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -1207,6 +1207,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
> AcpiTable table = { .sig = "DSDT", .rev = 2, .oem_id = vms->oem_id,
> .oem_table_id = vms->oem_table_id };
> Aml *pci0_scope;
> + Error *local_err = NULL;
> + uint32_t bsel;
>
> acpi_table_begin(&table, table_data);
> dsdt = init_aml_allocator();
> @@ -1269,9 +1271,12 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>
> aml_append(pci0_scope, build_pci_bridge_edsm());
> build_append_pci_bus_devices(pci0_scope, vms->bus);
> - if (object_property_find(OBJECT(vms->bus), ACPI_PCIHP_PROP_BSEL)) {
> + bsel = object_property_get_uint(OBJECT(vms->bus), ACPI_PCIHP_PROP_BSEL,
> + &local_err);
> + if (local_err == NULL && bsel != UINT32_MAX) {
> build_append_pcihp_slots(pci0_scope, vms->bus);
> }
> + error_free(local_err);
>
> if (vms->acpi_dev) {
> bool acpi_pcihp;
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 8837b69687..cc0b6e5633 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1198,15 +1198,20 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> sb_scope = aml_scope("\\_SB");
> {
> Object *pci_host = acpi_get_i386_pci_host();
> + Error *local_err = NULL;
> + uint32_t bsel;
>
> if (pci_host) {
> PCIBus *pbus = PCI_HOST_BRIDGE(pci_host)->bus;
> Aml *ascope = aml_scope("PCI0");
> /* Scan all PCI buses. Generate tables to support hotplug. */
> build_append_pci_bus_devices(ascope, pbus);
> - if (object_property_find(OBJECT(pbus), ACPI_PCIHP_PROP_BSEL)) {
> + bsel = object_property_get_uint(OBJECT(pbus), ACPI_PCIHP_PROP_BSEL,
> + &local_err);
> + if (local_err == NULL && bsel != UINT32_MAX) {
> build_append_pcihp_slots(ascope, pbus);
> }
> + error_free(local_err);
> aml_append(sb_scope, ascope);
> }
> }
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index d3191609e2..e8e8a3b767 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -25,6 +25,7 @@
> #include "qemu/osdep.h"
> #include "qemu/datadir.h"
> #include "qemu/units.h"
> +#include "hw/acpi/pcihp.h"
> #include "hw/core/irq.h"
> #include "hw/pci/pci.h"
> #include "hw/pci/pci_bridge.h"
> @@ -187,6 +188,8 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
> bus->machine_done.notify = pcibus_machine_done;
> qemu_add_machine_init_done_notifier(&bus->machine_done);
>
> + bus->acpi_pcihp_bsel_val = UINT32_MAX;
> +
> vmstate_register_any(NULL, &vmstate_pcibus, bus);
> }
>
> @@ -302,6 +305,10 @@ static void pci_bus_class_init(ObjectClass *klass, const void *data)
> pbc->numa_node = pcibus_numa_node;
>
> fwgc->get_data = pci_bus_fw_cfg_gen_data;
> +
> + object_class_property_add_uint32_ptr(klass, ACPI_PCIHP_PROP_BSEL,
> + offsetof(PCIBus, acpi_pcihp_bsel_val),
> + OBJ_PROP_FLAG_READWRITE);
> }
>
> static const TypeInfo pci_bus_info = {
> --
> 2.43.0
>
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
next prev parent reply other threads:[~2026-08-24 13:05 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 11:14 [PATCH v4 00/16] hw/acpi: convert object props to class props Mark Cave-Ayland
2026-08-21 11:14 ` [PATCH v4 01/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) macro Mark Cave-Ayland
2026-08-24 12:43 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 02/16] qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) macro Mark Cave-Ayland
2026-08-24 12:44 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 03/16] qom/object.c: introduce DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS() macro Mark Cave-Ayland
2026-08-24 12:44 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 04/16] qom/object.c: add object_class_property_add_uint8_ptr() Mark Cave-Ayland
2026-08-24 12:45 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 05/16] qom/object.c: add object_class_property_add_uint64_ptr() Mark Cave-Ayland
2026-08-24 12:46 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 06/16] hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class props Mark Cave-Ayland
2026-08-24 12:47 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 07/16] hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop Mark Cave-Ayland
2026-08-24 12:48 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 08/16] qom/object.c: add object_class_property_add_uint32_ptr() Mark Cave-Ayland
2026-08-24 12:48 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 09/16] hw/acpi/ich9.c: convert ACPI_PM_PROP_GPE0_BLK_LEN to a static class property Mark Cave-Ayland
2026-08-24 12:50 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 10/16] qom/object.c: add object_class_property_add_bool_ptr() Mark Cave-Ayland
2026-08-24 12:53 ` Daniel P. Berrangé
2026-08-24 13:39 ` Mark Cave-Ayland
2026-08-24 13:57 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 11/16] hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props Mark Cave-Ayland
2026-08-24 12:59 ` Daniel P. Berrangé
2026-08-24 13:41 ` Mark Cave-Ayland
2026-08-21 11:14 ` [PATCH v4 12/16] qom/object.c: add object_class_property_add_uint16_ptr() Mark Cave-Ayland
2026-08-24 13:00 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 13/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP to class props Mark Cave-Ayland
2026-08-24 13:01 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 14/16] hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop Mark Cave-Ayland
2026-08-24 13:04 ` Daniel P. Berrangé [this message]
2026-08-24 13:47 ` Mark Cave-Ayland
2026-08-25 7:17 ` Markus Armbruster
2026-08-25 12:53 ` Mark Cave-Ayland
2026-08-25 13:29 ` Markus Armbruster
2026-08-21 11:14 ` [PATCH v4 15/16] hw/acpi/piix4.c: convert static variables to static class properties Mark Cave-Ayland
2026-08-24 13:05 ` Daniel P. Berrangé
2026-08-21 11:14 ` [PATCH v4 16/16] hw/acpi/piix4.c: convert ACPI_PM_PROP_PM_IO_BASE to a class prop Mark Cave-Ayland
2026-08-24 13:06 ` Daniel P. Berrangé
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=aoxBd0tGArc8rwdf@redhat.com \
--to=berrange@redhat.com \
--cc=anisinha@redhat.com \
--cc=aurelien@aurel32.net \
--cc=imammedo@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mark.caveayland@nutanix.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@mailo.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.