Hi Chunming, On 8/25/21 10:08 AM, chunming wrote: > From: chunming <chunming...@verisilicon.com> > > . 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: 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 81eda46b0b..c3fd30e071 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 9661c46699..d3402a43dd 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; at this stage it is not obvious why you need the smmuv3 DeviceState in the VirtMachineState (there is no user). You may squash this change in subsequent patch instead
Thanks Eric > + const uint16_t *sidmap; > }; > > #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)