. Add "smmuv3_sidmap" to set non PCI/PCIe devices SID value . Pass non PCI/PCIe devices SID value to SMMU v3 model creation . Store SMMU v3 device in virtual machine then non PCI/PCIe can get its memory region later
Signed-off-by: Li, Chunming <chunming...@verisilicon.com> --- hw/arm/virt.c | 18 +++++++++++++++++- include/hw/arm/virt.h | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 81eda46b0..c3fd30e07 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -204,6 +204,10 @@ static const char *valid_cpus[] = { ARM_CPU_TYPE_NAME("max"), }; +static const uint16_t smmuv3_sidmap[] = { + +}; + static bool cpu_type_valid(const char *cpu) { int i; @@ -1223,7 +1227,7 @@ static void create_pcie_irq_map(const MachineState *ms, 0x7 /* PCI irq */); } -static void create_smmu(const VirtMachineState *vms, +static void create_smmu(VirtMachineState *vms, PCIBus *bus) { char *node; @@ -1244,6 +1248,16 @@ static void create_smmu(const VirtMachineState *vms, object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus), &error_abort); + + vms->smmuv3 = dev; + + qdev_prop_set_uint32(dev, "len-sid-map", ARRAY_SIZE(smmuv3_sidmap)); + + for (i = 0; i < ARRAY_SIZE(smmuv3_sidmap); i++) { + g_autofree char *propname = g_strdup_printf("sid-map[%d]", i); + qdev_prop_set_uint16(dev, propname, smmuv3_sidmap[i]); + } + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); for (i = 0; i < NUM_SMMU_IRQS; i++) { @@ -2762,6 +2776,8 @@ static void virt_instance_init(Object *obj) vms->irqmap = a15irqmap; + vms->sidmap = smmuv3_sidmap; + virt_flash_create(vms); vms->oem_id = g_strndup(ACPI_BUILD_APPNAME6, 6); diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 9661c4669..d3402a43d 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -167,6 +167,8 @@ struct VirtMachineState { PCIBus *bus; char *oem_id; char *oem_table_id; + DeviceState *smmuv3; + const uint16_t *sidmap; }; #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) --