Hi, While preparing the next version I noticed I forgot to send this reply. Better late than never I suppose... On Tue, Apr 21, 2020 at 07:31:12AM +0000, Tian, Kevin wrote: > > From: Jean-Philippe Brucker > > Sent: Saturday, February 29, 2020 1:26 AM > > > > Platforms without device-tree do not currently have a method for > > describing the vIOMMU topology. Provide a topology description embedded > > into the virtio device. [...] > > diff --git a/drivers/iommu/virtio-iommu-topology.c b/drivers/iommu/virtio- > > iommu-topology.c > > new file mode 100644 > > index 000000000000..2188624ef216 > > --- /dev/null > > +++ b/drivers/iommu/virtio-iommu-topology.c > > @@ -0,0 +1,343 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > > + > > +#include <linux/dma-iommu.h> > > +#include <linux/list.h> > > +#include <linux/pci.h> > > +#include <linux/virt_iommu.h> > > +#include <linux/virtio_ids.h> > > +#include <linux/virtio_pci.h> > > +#include <uapi/linux/virtio_iommu.h> > > + > > +struct viommu_cap_config { > > + u8 bar; > > + u32 length; /* structure size */ > > + u32 offset; /* structure offset within the bar */ > > +}; > > + > > +union viommu_topo_cfg { > > + __le16 type; > > + struct virtio_iommu_topo_pci_range pci; > > + struct virtio_iommu_topo_endpoint ep; > > +}; > > + > > +struct viommu_spec { > > + struct device *dev; /* transport device */ > > + struct fwnode_handle *fwnode; > > + struct iommu_ops *ops; > > + struct list_head list; > > + size_t num_items; > > Intel DMAR allows an IOMMU to claim INCLUDE_ALL thus avoid listing > every endpoint one-by-one. It is especially useful when there is only > one IOMMU device in the system. Do you think whether making sense > to allow such optimization in this spec? The DMAR INCLUDE_PCI_ALL is for a single PCI domain, so I think is equivalent to having a single virtio_iommu_topo_pci_range structure with start=0 and end=0xffff. That only takes 16 bytes of config space and is pretty easy to parse, so a special case doesn't seem necessary to me. If more than one PCI domain is managed by the IOMMU, then INCLUDE_ALL isn't sufficient since we need to describe how endpoint IDs are associated to domain:RID (one of the domains would have its endpoint IDs = RID + 0x10000 for example). Furthermore non-PCI devices don't have an implicit endpoint ID like the RID. Thanks, Jean > It doesn't work for ARM since > you need ID mapping to find the MSI doorbell. But for architectures > where only topology info is required, it makes the enumeration process > much simpler. > > Thanks > Kevin