On 2/6/26 3:48 PM, Shameer Kolothum wrote:
> Add an "identifier" property to the SMMUv3 device and use it when
> building the ACPI IORT SMMUv3 node Identifier field.
>
> This avoids relying on enumeration order and provides a stable
> per-device identifier. This is useful when we add support for
> Tegra241 CMDQV DSDT in subsequent patch.
>
> No functional change intended.
>
> Signed-off-by: Shameer Kolothum <[email protected]>
> ---
> hw/arm/smmuv3.c | 1 +
> hw/arm/virt-acpi-build.c | 4 +++-
> hw/arm/virt.c | 3 +++
> include/hw/arm/smmuv3.h | 1 +
> 4 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
> index 7858bf2c33..7f84c87a46 100644
> --- a/hw/arm/smmuv3.c
> +++ b/hw/arm/smmuv3.c
> @@ -2114,6 +2114,7 @@ static const Property smmuv3_properties[] = {
> * Defaults to stage 1
> */
> DEFINE_PROP_STRING("stage", SMMUv3State, stage),
> + DEFINE_PROP_UINT8("identifier", SMMUv3State, identifier, 0),
> DEFINE_PROP_BOOL("accel", SMMUv3State, accel, false),
> /* GPA of MSI doorbell, for SMMUv3 accel use. */
> DEFINE_PROP_UINT64("msi-gpa", SMMUv3State, msi_gpa, 0),
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index ae3b4aac52..046e930ca5 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -342,6 +342,7 @@ static int iort_idmap_compare(gconstpointer a,
> gconstpointer b)
> typedef struct AcpiSMMUv3Dev {
> int irq;
> hwaddr base;
> + uint8_t id;
>
> /*
> * IORT-only fields.
> @@ -407,6 +408,7 @@ static int iort_smmuv3_devices(Object *obj, void *opaque)
> bus = PCI_BUS(object_property_get_link(obj, "primary-bus",
> &error_abort));
> sdev.accel = object_property_get_bool(obj, "accel", &error_abort);
> sdev.ats = object_property_get_bool(obj, "ats", &error_abort);
> + sdev.id = object_property_get_uint(obj, "identifier", &error_abort);
> pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev);
> sbdev = SYS_BUS_DEVICE(obj);
> sdev.base = platform_bus_get_mmio_addr(pbus, sbdev, 0);
> @@ -642,7 +644,7 @@ build_iort(GArray *table_data, BIOSLinker *linker,
> VirtMachineState *vms)
> (ID_MAPPING_ENTRY_SIZE * smmu_mapping_count);
> build_append_int_noprefix(table_data, node_size, 2); /* Length */
> build_append_int_noprefix(table_data, 4, 1); /* Revision */
> - build_append_int_noprefix(table_data, id++, 4); /* Identifier */
> + build_append_int_noprefix(table_data, sdev->id, 4); /* Identifier */
Would that keep the same ordering for existing qtests?
Eric
> /* Number of ID mappings */
> build_append_int_noprefix(table_data, smmu_mapping_count, 4);
> /* Reference to ID Array */
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 390845c503..22ee5c4a41 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -3059,12 +3059,15 @@ static void
> virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
> (vms->legacy_smmuv3_present) ?
> "iommu=smmuv3" : "virtio-iommu");
> } else if (vms->iommu == VIRT_IOMMU_NONE) {
> + static uint8_t id;
> +
> /* The new SMMUv3 device is specific to the PCI bus */
> object_property_set_bool(OBJECT(dev), "smmu_per_bus", true,
> NULL);
> object_property_set_link(OBJECT(dev), "memory",
> OBJECT(vms->sysmem), NULL);
> object_property_set_link(OBJECT(dev), "secure-memory",
> OBJECT(vms->secure_sysmem), NULL);
> + object_property_set_uint(OBJECT(dev), "identifier", id++, NULL);
> }
> if (object_property_get_bool(OBJECT(dev), "accel", &error_abort)) {
> hwaddr db_start = 0;
> diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h
> index 87926f8cb3..39cb43506e 100644
> --- a/include/hw/arm/smmuv3.h
> +++ b/include/hw/arm/smmuv3.h
> @@ -63,6 +63,7 @@ struct SMMUv3State {
> qemu_irq irq[4];
> QemuMutex mutex;
> char *stage;
> + uint8_t identifier;
>
> /* SMMU has HW accelerator support for nested S1 + s2 */
> bool accel;