[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 07/11] pc: Allow instantiating a virtio-iommu device
From: |
Jean-Philippe Brucker |
Subject: |
Re: [PATCH v4 07/11] pc: Allow instantiating a virtio-iommu device |
Date: |
Fri, 8 Oct 2021 16:24:50 +0100 |
On Wed, Oct 06, 2021 at 09:19:54AM +0200, Igor Mammedov wrote:
> > @@ -1367,8 +1368,11 @@ static void pc_virtio_md_pci_unplug(HotplugHandler
> > *hotplug_dev,
> > static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
> > DeviceState *dev, Error **errp)
> > {
> > - if (object_dynamic_cast(OBJECT(dev), TYPE_X86_IOMMU_DEVICE) &&
> > - x86_iommu_get_default()) {
> > + PCMachineState *pcms = PC_MACHINE(hotplug_dev);
> > +
> > + if ((object_dynamic_cast(OBJECT(dev), TYPE_X86_IOMMU_DEVICE) ||
> > + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) &&
> > + (x86_iommu_get_default() || pcms->virtio_iommu)) {
>
> this check is getting uglier,
> may be instead of introducing pcms->virtio_iommu boolean, better approach
> would be adding 'Device* PCMachineState::iommu' and setting it to IOMMU
> so the check would reduce to:
> if ((object_dynamic_cast(OBJECT(dev), TYPE_X86_IOMMU_DEVICE) ||
> object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)))
> {
> if (pcms->iommu)
> err
> else set pcms->iommu in plug handler or here
> }
>
> that also will let to cleanup/get rid of x86_iommu_[s|g]et_default()
> and x86_iommu_default 'global'.
> Maybe replace previous patch with one that would remove
> x86_iommu_[s|g]et_default().
Ok, I can't figure out a nice way to do this at the moment, will think
more about it. Callers of x86_iommu_get_default() still need a helper, and
most but not all assume that the returned object is for IRQ remapping. At
least adding Device *iommu to pcms should be nicer, but not sure about
removing the x86_iommu_get/set_default helpers.
Thanks,
Jean
- Re: [PATCH v4 03/11] hw/arm/virt: Remove device tree restriction for virtio-iommu, (continued)
- [PATCH v4 05/11] hw/arm/virt: Use object_property_set instead of qdev_prop_set, Jean-Philippe Brucker, 2021/10/01
- [PATCH v4 04/11] hw/arm/virt: Reject instantiation of multiple IOMMUs, Jean-Philippe Brucker, 2021/10/01
- [PATCH v4 07/11] pc: Allow instantiating a virtio-iommu device, Jean-Philippe Brucker, 2021/10/01
- [PATCH v4 06/11] hw/i386: Move vIOMMU uniqueness check into pc.c, Jean-Philippe Brucker, 2021/10/01
- [PATCH v4 02/11] hw/arm/virt-acpi-build: Add VIOT table for virtio-iommu, Jean-Philippe Brucker, 2021/10/01
- [PATCH v4 09/11] tests/acpi: add test cases for VIOT, Jean-Philippe Brucker, 2021/10/01
- [PATCH v4 08/11] tests/acpi: allow updates of VIOT expected data files, Jean-Philippe Brucker, 2021/10/01