diff mbox series

[v4,03/11] hw/arm/virt: Remove device tree restriction for virtio-iommu

Message ID 20211001173358.863017-4-jean-philippe@linaro.org
State Superseded
Headers show
Series virtio-iommu: Add ACPI support | expand

Commit Message

Jean-Philippe Brucker Oct. 1, 2021, 5:33 p.m. UTC
virtio-iommu is now supported with ACPI VIOT as well as device tree.
Remove the restriction that prevents from instantiating a virtio-iommu
device under ACPI.

Reviewed-by: Eric Auger <eric.auger@redhat.com>

Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

---
 hw/arm/virt.c                | 10 ++--------
 hw/virtio/virtio-iommu-pci.c |  7 -------
 2 files changed, 2 insertions(+), 15 deletions(-)

-- 
2.33.0

Comments

Eric Auger Oct. 5, 2021, 11:57 a.m. UTC | #1
Hi Jean,

On 10/1/21 7:33 PM, Jean-Philippe Brucker wrote:
> virtio-iommu is now supported with ACPI VIOT as well as device tree.

> Remove the restriction that prevents from instantiating a virtio-iommu

> device under ACPI.

>

> Reviewed-by: Eric Auger <eric.auger@redhat.com>

> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

> ---

>  hw/arm/virt.c                | 10 ++--------

>  hw/virtio/virtio-iommu-pci.c |  7 -------

>  2 files changed, 2 insertions(+), 15 deletions(-)

>

> diff --git a/hw/arm/virt.c b/hw/arm/virt.c

> index 1d59f0e59f..56e8fc7059 100644

> --- a/hw/arm/virt.c

> +++ b/hw/arm/virt.c

> @@ -2561,16 +2561,10 @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine,

>      MachineClass *mc = MACHINE_GET_CLASS(machine);

>  

>      if (device_is_dynamic_sysbus(mc, dev) ||

> -       (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) {

> +        object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) ||

> +        object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) {

>          return HOTPLUG_HANDLER(machine);

>      }

> -    if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) {

> -        VirtMachineState *vms = VIRT_MACHINE(machine);

> -

> -        if (!vms->bootinfo.firmware_loaded || !virt_is_acpi_enabled(vms)) {

> -            return HOTPLUG_HANDLER(machine);

> -        }

> -    }

>      return NULL;

>  }

>  

> diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c

> index 770c286be7..f30eb16cbf 100644

> --- a/hw/virtio/virtio-iommu-pci.c

> +++ b/hw/virtio/virtio-iommu-pci.c

> @@ -48,16 +48,9 @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)

>      VirtIOIOMMU *s = VIRTIO_IOMMU(vdev);

>  

>      if (!qdev_get_machine_hotplug_handler(DEVICE(vpci_dev))) {

> -        MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());

> -

> -        error_setg(errp,

> -                   "%s machine fails to create iommu-map device tree bindings",

> -                   mc->name);

actually this does not work. To add a hint you need the *errp to be set.
Otherwise when running through this path you will get

emu-system-x86_64: ../util/error.c:158: error_append_hint: Assertion
`err && errp != &error_abort && errp != &error_fatal' failed.

replace the error_append_hint with an error_setg (without the \n)

Thanks

Eric
>          error_append_hint(errp,

>                            "Check your machine implements a hotplug handler "

>                            "for the virtio-iommu-pci device\n");

> -        error_append_hint(errp, "Check the guest is booted without FW or with "

> -                          "-no-acpi\n");

>          return;

>      }

>      for (int i = 0; i < s->nb_reserved_regions; i++) {
Jean-Philippe Brucker Oct. 8, 2021, 3:20 p.m. UTC | #2
On Tue, Oct 05, 2021 at 01:57:35PM +0200, Eric Auger wrote:
> > diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c

> > index 770c286be7..f30eb16cbf 100644

> > --- a/hw/virtio/virtio-iommu-pci.c

> > +++ b/hw/virtio/virtio-iommu-pci.c

> > @@ -48,16 +48,9 @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)

> >      VirtIOIOMMU *s = VIRTIO_IOMMU(vdev);

> >  

> >      if (!qdev_get_machine_hotplug_handler(DEVICE(vpci_dev))) {

> > -        MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());

> > -

> > -        error_setg(errp,

> > -                   "%s machine fails to create iommu-map device tree bindings",

> > -                   mc->name);

> actually this does not work. To add a hint you need the *errp to be set.

> Otherwise when running through this path you will get

> 

> emu-system-x86_64: ../util/error.c:158: error_append_hint: Assertion

> `err && errp != &error_abort && errp != &error_fatal' failed.

> 

> replace the error_append_hint with an error_setg (without the \n)


Woops sorry, will fix

Thanks,
Jean
diff mbox series

Patch

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 1d59f0e59f..56e8fc7059 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2561,16 +2561,10 @@  static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine,
     MachineClass *mc = MACHINE_GET_CLASS(machine);
 
     if (device_is_dynamic_sysbus(mc, dev) ||
-       (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) {
+        object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) ||
+        object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) {
         return HOTPLUG_HANDLER(machine);
     }
-    if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) {
-        VirtMachineState *vms = VIRT_MACHINE(machine);
-
-        if (!vms->bootinfo.firmware_loaded || !virt_is_acpi_enabled(vms)) {
-            return HOTPLUG_HANDLER(machine);
-        }
-    }
     return NULL;
 }
 
diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c
index 770c286be7..f30eb16cbf 100644
--- a/hw/virtio/virtio-iommu-pci.c
+++ b/hw/virtio/virtio-iommu-pci.c
@@ -48,16 +48,9 @@  static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
     VirtIOIOMMU *s = VIRTIO_IOMMU(vdev);
 
     if (!qdev_get_machine_hotplug_handler(DEVICE(vpci_dev))) {
-        MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
-
-        error_setg(errp,
-                   "%s machine fails to create iommu-map device tree bindings",
-                   mc->name);
         error_append_hint(errp,
                           "Check your machine implements a hotplug handler "
                           "for the virtio-iommu-pci device\n");
-        error_append_hint(errp, "Check the guest is booted without FW or with "
-                          "-no-acpi\n");
         return;
     }
     for (int i = 0; i < s->nb_reserved_regions; i++) {