diff mbox series

[v5,3/4] hw/arm/virt: Update SMMU v3 creation to support non PCI/PCIe device connection

Message ID 1629878922-173270-4-git-send-email-chunming_li1234@163.com
State New
Headers show
Series hw/arm/smmuv3: Support non PCI/PCIe devices | expand

Commit Message

chunming Aug. 25, 2021, 8:08 a.m. UTC
From: chunming <chunming.li@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.li@verisilicon.com>
---
 hw/arm/virt.c         | 18 +++++++++++++++++-
 include/hw/arm/virt.h |  2 ++
 2 files changed, 19 insertions(+), 1 deletion(-)

Comments

Eric Auger Aug. 31, 2021, 2:13 p.m. UTC | #1
Hi Chunming,

On 8/25/21 10:08 AM, chunming wrote:
> From: chunming <chunming.li@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.li@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)
Li, Chunming Sept. 1, 2021, 6:51 a.m. UTC | #2
> -----Original Message-----
> From: Eric Auger [mailto:eric.auger@redhat.com]
> Sent: Tuesday, August 31, 2021 10:13 PM
> To: chunming; peter.maydell@linaro.org
> Cc: qemu-arm@nongnu.org; qemu-devel@nongnu.org; Wen, Jianxian; Liu,
> Renwei; Li, Chunming
> Subject: Re: [PATCH v5 3/4] hw/arm/virt: Update SMMU v3 creation to
> support non PCI/PCIe device connection
> 
> Hi Chunming,
> 
> On 8/25/21 10:08 AM, chunming wrote:
> > From: chunming <chunming.li@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.li@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

Got it. Move this change in subsequent patch instead in next version.

> 
> Thanks
> 
> Eric
> > +    const uint16_t *sidmap;
> >  };
> >
> >  #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM :
> VIRT_PCIE_ECAM)
diff mbox series

Patch

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;
+    const uint16_t *sidmap;
 };
 
 #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)