Re: [PATCH] i2c: virtio: add a virtio i2c frontend driver

2020-09-04 Thread Jie Deng


On 2020/9/4 12:06, Jason Wang wrote:



diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 293e7a0..70c8e30 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -21,6 +21,17 @@ config I2C_ALI1535
    This driver can also be built as a module.  If so, the module
    will be called i2c-ali1535.
  +config I2C_VIRTIO
+    tristate "Virtio I2C Adapter"
+    depends on VIRTIO



I guess it should depend on some I2C module here.


The dependency of I2C is included in the Kconfig in its parent directory.
So there is nothing special to add here.






+struct virtio_i2c_msg {
+    struct virtio_i2c_hdr hdr;
+    char *buf;
+    u8 status;



Any reason for separating status out of virtio_i2c_hdr?


The status is not from i2c_msg. So I put it out of virtio_i2c_hdr.




+};
+
+/**
+ * struct virtio_i2c - virtio I2C data
+ * @vdev: virtio device for this controller
+ * @completion: completion of virtio I2C message
+ * @adap: I2C adapter for this controller
+ * @i2c_lock: lock for virtqueue processing
+ * @vq: the virtio virtqueue for communication
+ */
+struct virtio_i2c {
+    struct virtio_device *vdev;
+    struct completion completion;
+    struct i2c_adapter adap;
+    struct mutex i2c_lock;
+    struct virtqueue *vq;
+};
+
+static void virtio_i2c_msg_done(struct virtqueue *vq)
+{
+    struct virtio_i2c *vi = vq->vdev->priv;
+
+    complete(&vi->completion);
+}
+
+static int virtio_i2c_add_msg(struct virtqueue *vq,
+  struct virtio_i2c_msg *vmsg,
+  struct i2c_msg *msg)
+{
+    struct scatterlist *sgs[3], hdr, bout, bin, status;
+    int outcnt = 0, incnt = 0;
+
+    if (!msg->len)
+    return -EINVAL;
+
+    vmsg->hdr.addr = msg->addr;
+    vmsg->hdr.flags = msg->flags;
+    vmsg->hdr.len = msg->len;



Missing endian conversion?


You are right. Need conversion here.



+
+    vmsg->buf = kzalloc(vmsg->hdr.len, GFP_KERNEL);
+    if (!vmsg->buf)
+    return -ENOMEM;
+
+    sg_init_one(&hdr, &vmsg->hdr, sizeof(struct virtio_i2c_hdr));
+    sgs[outcnt++] = &hdr;
+    if (vmsg->hdr.flags & I2C_M_RD) {
+    sg_init_one(&bin, vmsg->buf, msg->len);
+    sgs[outcnt + incnt++] = &bin;
+    } else {
+    memcpy(vmsg->buf, msg->buf, msg->len);
+    sg_init_one(&bout, vmsg->buf, msg->len);
+    sgs[outcnt++] = &bout;
+    }
+    sg_init_one(&status, &vmsg->status, sizeof(vmsg->status));
+    sgs[outcnt + incnt++] = &status;
+
+    return virtqueue_add_sgs(vq, sgs, outcnt, incnt, vmsg, GFP_KERNEL);
+}
+
+static int virtio_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg 
*msgs, int num)

+{
+    struct virtio_i2c *vi = i2c_get_adapdata(adap);
+    struct virtio_i2c_msg *vmsg_o, *vmsg_i;
+    struct virtqueue *vq = vi->vq;
+    unsigned long time_left;
+    int len, i, ret = 0;
+
+    vmsg_o = kzalloc(sizeof(*vmsg_o), GFP_KERNEL);
+    if (!vmsg_o)
+    return -ENOMEM;



It looks to me we can avoid the allocation by embedding virtio_i2c_msg 
into struct virtio_i2c;



Yeah... That's better. Thanks.





+
+    mutex_lock(&vi->i2c_lock);
+    vmsg_o->buf = NULL;
+    for (i = 0; i < num; i++) {
+    ret = virtio_i2c_add_msg(vq, vmsg_o, &msgs[i]);
+    if (ret) {
+    dev_err(&adap->dev, "failed to add msg[%d] to 
virtqueue.\n", i);

+    goto err_unlock_free;
+    }
+
+    virtqueue_kick(vq);
+
+    time_left = wait_for_completion_timeout(&vi->completion, 
adap->timeout);

+    if (!time_left) {
+    dev_err(&adap->dev, "msg[%d]: addr=0x%x timeout.\n", i, 
msgs[i].addr);

+    ret = i;
+    goto err_unlock_free;
+    }
+
+    vmsg_i = (struct virtio_i2c_msg *)virtqueue_get_buf(vq, &len);
+    if (vmsg_i) {
+    /* vmsg_i should point to the same address with vmsg_o */
+    if (vmsg_i != vmsg_o) {
+    dev_err(&adap->dev, "msg[%d]: addr=0x%x virtqueue 
error.\n",

+    i, vmsg_i->hdr.addr);
+    ret = i;
+    goto err_unlock_free;
+    }



Does this imply in order completion of i2c device?  (E.g what happens 
if multiple virtio i2c requests are submitted)


Btw, this always use a single descriptor once a time which makes me 
suspect if a virtqueue(virtio) is really needed. It looks to me we can 
utilize the virtqueue by submit the request in a batch.


I'm afraid not all physical devices support batch. I'd like to keep the 
current design and consider

your suggestion as a possible optimization in the future.

Thanks.




+}
+
+static void virtio_i2c_del_vqs(struct virtio_device *vdev)
+{
+    vdev->config->reset(vdev);



Why need reset here?

Thanks


I'm following what other virtio drivers do.
They reset the devices before they clean up the queues.





+    vdev->config->del_vqs(vdev);
+}
+
+static int virtio_i2c_setup_vqs(struct virtio_i2c *vi)
+{
+    struct virtio_device *vdev = vi->vdev;
+
+    vi->vq = virtio_find_single_vq(vdev, virtio_i2c_msg_do

Re: [PATCH v3 1/6] iommu/virtio: Move to drivers/iommu/virtio/

2020-09-04 Thread Auger Eric
Hi Jean,

On 8/21/20 3:15 PM, Jean-Philippe Brucker wrote:
> Before adding new files to the virtio-iommu driver, move it to its own
> subfolder, similarly to other IOMMU drivers.
> 
> Signed-off-by: Jean-Philippe Brucker 
> ---
>  drivers/iommu/Makefile| 3 +--
>  drivers/iommu/virtio/Makefile | 2 ++
>  drivers/iommu/{ => virtio}/virtio-iommu.c | 0
>  MAINTAINERS   | 2 +-
>  4 files changed, 4 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/iommu/virtio/Makefile
>  rename drivers/iommu/{ => virtio}/virtio-iommu.c (100%)
> 
> diff --git a/drivers/iommu/Makefile b/drivers/iommu/Makefile
> index 11f1771104f3..fc7523042512 100644
> --- a/drivers/iommu/Makefile
> +++ b/drivers/iommu/Makefile
> @@ -1,5 +1,5 @@
>  # SPDX-License-Identifier: GPL-2.0
> -obj-y += amd/ intel/ arm/
> +obj-y += amd/ intel/ arm/ virtio/
>  obj-$(CONFIG_IOMMU_API) += iommu.o
>  obj-$(CONFIG_IOMMU_API) += iommu-traces.o
>  obj-$(CONFIG_IOMMU_API) += iommu-sysfs.o
> @@ -26,4 +26,3 @@ obj-$(CONFIG_EXYNOS_IOMMU) += exynos-iommu.o
>  obj-$(CONFIG_FSL_PAMU) += fsl_pamu.o fsl_pamu_domain.o
>  obj-$(CONFIG_S390_IOMMU) += s390-iommu.o
>  obj-$(CONFIG_HYPERV_IOMMU) += hyperv-iommu.o
> -obj-$(CONFIG_VIRTIO_IOMMU) += virtio-iommu.o
> diff --git a/drivers/iommu/virtio/Makefile b/drivers/iommu/virtio/Makefile
> new file mode 100644
> index ..279368fcc074
> --- /dev/null
> +++ b/drivers/iommu/virtio/Makefile
> @@ -0,0 +1,2 @@
> +# SPDX-License-Identifier: GPL-2.0
> +obj-$(CONFIG_VIRTIO_IOMMU) += virtio-iommu.o
> diff --git a/drivers/iommu/virtio-iommu.c 
> b/drivers/iommu/virtio/virtio-iommu.c
> similarity index 100%
> rename from drivers/iommu/virtio-iommu.c
> rename to drivers/iommu/virtio/virtio-iommu.c
> diff --git a/MAINTAINERS b/MAINTAINERS
> index deaafb617361..3602b223c9b2 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -18451,7 +18451,7 @@ VIRTIO IOMMU DRIVER
>  M:   Jean-Philippe Brucker 
>  L:   virtualization@lists.linux-foundation.org
>  S:   Maintained
> -F:   drivers/iommu/virtio-iommu.c
> +F:   drivers/iommu/virtio/
>  F:   include/uapi/linux/virtio_iommu.h
not related to this patch but you may add an entry for
Documentation/devicetree/bindings/virtio/iommu.txt

Reviewed-by: Eric Auger 

Thanks

Eric
>  
>  VIRTIO MEM DRIVER
> 

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH v3 4/6] iommu/virtio: Add topology definitions

2020-09-04 Thread Auger Eric
Hi Jean,

On 8/21/20 3:15 PM, Jean-Philippe Brucker wrote:
> Add struct definitions for describing endpoints managed by the
> virtio-iommu. When VIRTIO_IOMMU_F_TOPOLOGY is offered, an array of
> virtio_iommu_topo_* structures in config space describes the endpoints,
> identified either by their PCI BDF or their physical MMIO address.
> 
> Signed-off-by: Jean-Philippe Brucker 
Reviewed-by: Eric Auger 

Thanks

Eric

> ---
>  include/uapi/linux/virtio_iommu.h | 44 +++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/include/uapi/linux/virtio_iommu.h 
> b/include/uapi/linux/virtio_iommu.h
> index 237e36a280cb..70cba30644d5 100644
> --- a/include/uapi/linux/virtio_iommu.h
> +++ b/include/uapi/linux/virtio_iommu.h
> @@ -16,6 +16,7 @@
>  #define VIRTIO_IOMMU_F_BYPASS3
>  #define VIRTIO_IOMMU_F_PROBE 4
>  #define VIRTIO_IOMMU_F_MMIO  5
> +#define VIRTIO_IOMMU_F_TOPOLOGY  6
>  
>  struct virtio_iommu_range_64 {
>   __le64  start;
> @@ -27,6 +28,17 @@ struct virtio_iommu_range_32 {
>   __le32  end;
>  };
>  
> +struct virtio_iommu_topo_config {
> + /* Number of topology description structures */
> + __le16  count;
> + /*
> +  * Offset to the first topology description structure
> +  * (virtio_iommu_topo_*) from the start of the virtio_iommu config
> +  * space. Aligned on 8 bytes.
> +  */
> + __le16  offset;
> +};
> +
>  struct virtio_iommu_config {
>   /* Supported page sizes */
>   __le64  page_size_mask;
> @@ -36,6 +48,38 @@ struct virtio_iommu_config {
>   struct virtio_iommu_range_32domain_range;
>   /* Probe buffer size */
>   __le32  probe_size;
> + struct virtio_iommu_topo_config topo_config;
> +};
> +
> +#define VIRTIO_IOMMU_TOPO_PCI_RANGE  0x1
> +#define VIRTIO_IOMMU_TOPO_MMIO   0x2
> +
> +struct virtio_iommu_topo_pci_range {
> + /* VIRTIO_IOMMU_TOPO_PCI_RANGE */
> + __u8type;
> + __u8reserved;
> + /* Length of this structure */
> + __le16  length;
> + /* First endpoint ID in the range */
> + __le32  endpoint_start;
> + /* PCI domain number */
> + __le16  segment;
> + /* PCI Bus:Device.Function range */
> + __le16  bdf_start;
> + __le16  bdf_end;
> + __le16  padding;
> +};
> +
> +struct virtio_iommu_topo_mmio {
> + /* VIRTIO_IOMMU_TOPO_MMIO */
> + __u8type;
> + __u8reserved;
> + /* Length of this structure */
> + __le16  length;
> + /* Endpoint ID */
> + __le32  endpoint;
> + /* Address of the first MMIO region */
> + __le64  address;
>  };
>  
>  /* Request types */
> 

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH v3 5/6] iommu/virtio: Support topology description in config space

2020-09-04 Thread Auger Eric
Hi Jean,

On 8/21/20 3:15 PM, Jean-Philippe Brucker wrote:
> Platforms without device-tree nor ACPI can provide a topology
> description embedded into the virtio config space. Parse it.
> 
> Use PCI FIXUP to probe the config space early, because we need to
> discover the topology before any DMA configuration takes place, and the
> virtio driver may be loaded much later. Since we discover the topology
> description when probing the PCI hierarchy, the virtual IOMMU cannot
> manage other platform devices discovered earlier.
> 
> Signed-off-by: Jean-Philippe Brucker 
> ---
>  drivers/iommu/Kconfig   |  12 ++
>  drivers/iommu/virtio/Makefile   |   1 +
>  drivers/iommu/virtio/topology.c | 259 
>  3 files changed, 272 insertions(+)
>  create mode 100644 drivers/iommu/virtio/topology.c
> 
> diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
> index e29ae50f7100..98d28fdbc19a 100644
> --- a/drivers/iommu/Kconfig
> +++ b/drivers/iommu/Kconfig
> @@ -394,4 +394,16 @@ config VIRTIO_IOMMU
>  config VIRTIO_IOMMU_TOPOLOGY_HELPERS
>   bool
>  
> +config VIRTIO_IOMMU_TOPOLOGY
> + bool "Handle topology properties from the virtio-iommu"
> + depends on VIRTIO_IOMMU
> + depends on PCI
> + default y
> + select VIRTIO_IOMMU_TOPOLOGY_HELPERS
> + help
> +   Enable early probing of virtio-iommu devices to detect the built-in
> +   topology description.
> +
> +   Say Y here if you intend to run this kernel as a guest.
> +
>  endif # IOMMU_SUPPORT
> diff --git a/drivers/iommu/virtio/Makefile b/drivers/iommu/virtio/Makefile
> index b42ad47eac7e..1eda8ca1cbbf 100644
> --- a/drivers/iommu/virtio/Makefile
> +++ b/drivers/iommu/virtio/Makefile
> @@ -1,3 +1,4 @@
>  # SPDX-License-Identifier: GPL-2.0
>  obj-$(CONFIG_VIRTIO_IOMMU) += virtio-iommu.o
> +obj-$(CONFIG_VIRTIO_IOMMU_TOPOLOGY) += topology.o
>  obj-$(CONFIG_VIRTIO_IOMMU_TOPOLOGY_HELPERS) += topology-helpers.o
> diff --git a/drivers/iommu/virtio/topology.c b/drivers/iommu/virtio/topology.c
> new file mode 100644
> index ..4923eec618b9
> --- /dev/null
> +++ b/drivers/iommu/virtio/topology.c
> @@ -0,0 +1,259 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "topology-helpers.h"
> +
> +struct viommu_cap_config {
> + u8 bar;
> + u32 length; /* structure size */
> + u32 offset; /* structure offset within the bar */
> +};
> +
> +struct viommu_topo_header {
> + u8 type;
> + u8 reserved;
> + u16 length;
> +};
> +
> +static struct virt_topo_endpoint *
> +viommu_parse_node(void __iomem *buf, size_t len)
> +{
> + int ret = -EINVAL;
> + union {
> + struct viommu_topo_header hdr;
> + struct virtio_iommu_topo_pci_range pci;
> + struct virtio_iommu_topo_mmio mmio;
> + } __iomem *cfg = buf;
> + struct virt_topo_endpoint *spec;
> +
> + spec = kzalloc(sizeof(*spec), GFP_KERNEL);
> + if (!spec)
> + return ERR_PTR(-ENOMEM);
> +
> + switch (ioread8(&cfg->hdr.type)) {
> + case VIRTIO_IOMMU_TOPO_PCI_RANGE:
> + if (len < sizeof(cfg->pci))
> + goto err_free;
> +
> + spec->dev_id.type = VIRT_TOPO_DEV_TYPE_PCI;
> + spec->dev_id.segment = ioread16(&cfg->pci.segment);
> + spec->dev_id.bdf_start = ioread16(&cfg->pci.bdf_start);
> + spec->dev_id.bdf_end = ioread16(&cfg->pci.bdf_end);
> + spec->endpoint_id = ioread32(&cfg->pci.endpoint_start);
> + break;
> + case VIRTIO_IOMMU_TOPO_MMIO:
> + if (len < sizeof(cfg->mmio))
> + goto err_free;
> +
> + spec->dev_id.type = VIRT_TOPO_DEV_TYPE_MMIO;
> + spec->dev_id.base = ioread64(&cfg->mmio.address);
> + spec->endpoint_id = ioread32(&cfg->mmio.endpoint);
> + break;
> + default:
> + pr_warn("unhandled format 0x%x\n", ioread8(&cfg->hdr.type));
> + ret = 0;
> + goto err_free;
> + }
> + return spec;
> +
> +err_free:
> + kfree(spec);
> + return ERR_PTR(ret);
> +}
> +
> +static int viommu_parse_topology(struct device *dev,
> +  struct virtio_iommu_config __iomem *cfg,
> +  size_t max_len)
> +{
> + int ret;
> + u16 len;
> + size_t i;
> + LIST_HEAD(endpoints);
> + size_t offset, count;
> + struct virt_topo_iommu *viommu;
> + struct virt_topo_endpoint *ep, *next;
> + struct viommu_topo_header __iomem *cur;
> +
> + offset = ioread16(&cfg->topo_config.offset);
> + count = ioread16(&cfg->topo_config.count);
> + if (!offset || !count)
> + return 0;
> +
> + viommu = kzalloc(sizeof(*viommu), GFP_KERNEL);
> + if (!viommu)
> + return -ENOMEM;
> +
> + viommu-

Re: [PATCH v3 2/6] iommu/virtio: Add topology helpers

2020-09-04 Thread Auger Eric
Hi Jean,

On 8/21/20 3:15 PM, Jean-Philippe Brucker wrote:
> To support topology description from ACPI and from the builtin
> description, add helpers to keep track of I/O topology descriptors.
> 
> To ease re-use of the helpers by other drivers and future ACPI
> extensions, use the "virt_" prefix rather than "virtio_" when naming
> structs and functions.
> 
> Signed-off-by: Jean-Philippe Brucker 
> ---
>  drivers/iommu/Kconfig   |   3 +
>  drivers/iommu/virtio/Makefile   |   1 +
>  drivers/iommu/virtio/topology-helpers.h |  50 ++
>  include/linux/virt_iommu.h  |  15 ++
>  drivers/iommu/virtio/topology-helpers.c | 196 
>  drivers/iommu/virtio/virtio-iommu.c |   4 +
>  MAINTAINERS |   1 +
>  7 files changed, 270 insertions(+)
>  create mode 100644 drivers/iommu/virtio/topology-helpers.h
>  create mode 100644 include/linux/virt_iommu.h
>  create mode 100644 drivers/iommu/virtio/topology-helpers.c
> 
> diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
> index bef5d75e306b..e29ae50f7100 100644
> --- a/drivers/iommu/Kconfig
> +++ b/drivers/iommu/Kconfig
> @@ -391,4 +391,7 @@ config VIRTIO_IOMMU
>  
> Say Y here if you intend to run this kernel as a guest.
>  
> +config VIRTIO_IOMMU_TOPOLOGY_HELPERS
> + bool
> +
>  endif # IOMMU_SUPPORT
> diff --git a/drivers/iommu/virtio/Makefile b/drivers/iommu/virtio/Makefile
> index 279368fcc074..b42ad47eac7e 100644
> --- a/drivers/iommu/virtio/Makefile
> +++ b/drivers/iommu/virtio/Makefile
> @@ -1,2 +1,3 @@
>  # SPDX-License-Identifier: GPL-2.0
>  obj-$(CONFIG_VIRTIO_IOMMU) += virtio-iommu.o
> +obj-$(CONFIG_VIRTIO_IOMMU_TOPOLOGY_HELPERS) += topology-helpers.o
> diff --git a/drivers/iommu/virtio/topology-helpers.h 
> b/drivers/iommu/virtio/topology-helpers.h
> new file mode 100644
> index ..436ca6a900c5
> --- /dev/null
> +++ b/drivers/iommu/virtio/topology-helpers.h
> @@ -0,0 +1,50 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef TOPOLOGY_HELPERS_H_
> +#define TOPOLOGY_HELPERS_H_
> +
> +#ifdef CONFIG_VIRTIO_IOMMU_TOPOLOGY_HELPERS
> +
> +/* Identify a device node in the topology */
> +struct virt_topo_dev_id {
> + unsigned inttype;
> +#define VIRT_TOPO_DEV_TYPE_PCI   1
> +#define VIRT_TOPO_DEV_TYPE_MMIO  2
> + union {
> + /* PCI endpoint or range */
> + struct {
> + u16 segment;
> + u16 bdf_start;
> + u16 bdf_end;
> + };
> + /* MMIO region */
> + u64 base;
> + };
> +};
> +
> +/* Specification of an IOMMU */
> +struct virt_topo_iommu {
> + struct virt_topo_dev_id dev_id;
> + struct device   *dev; /* transport device */
> + struct fwnode_handle*fwnode;
> + struct iommu_ops*ops;
> + struct list_headlist;
> +};
> +
> +/* Specification of an endpoint */
> +struct virt_topo_endpoint {
> + struct virt_topo_dev_id dev_id;
> + u32 endpoint_id;
> + struct virt_topo_iommu  *viommu;
> + struct list_headlist;
> +};
> +
> +void virt_topo_add_endpoint(struct virt_topo_endpoint *ep);
> +void virt_topo_add_iommu(struct virt_topo_iommu *viommu);
> +
> +void virt_topo_set_iommu_ops(struct device *dev, struct iommu_ops *ops);
> +
> +#else /* !CONFIG_VIRTIO_IOMMU_TOPOLOGY_HELPERS */
> +static inline void virt_topo_set_iommu_ops(struct device *dev, struct 
> iommu_ops *ops)
> +{ }
> +#endif /* !CONFIG_VIRTIO_IOMMU_TOPOLOGY_HELPERS */
> +#endif /* TOPOLOGY_HELPERS_H_ */
> diff --git a/include/linux/virt_iommu.h b/include/linux/virt_iommu.h
> new file mode 100644
> index ..17d2bd4732e0
> --- /dev/null
> +++ b/include/linux/virt_iommu.h
> @@ -0,0 +1,15 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef VIRT_IOMMU_H_
> +#define VIRT_IOMMU_H_
> +
> +#ifdef CONFIG_VIRTIO_IOMMU_TOPOLOGY_HELPERS
> +int virt_dma_configure(struct device *dev);
> +
> +#else /* !CONFIG_VIRTIO_IOMMU_TOPOLOGY_HELPERS */
> +static inline int virt_dma_configure(struct device *dev)
> +{
> + /* Don't disturb the normal DMA configuration methods */
> + return 0;
> +}
> +#endif /* !CONFIG_VIRTIO_IOMMU_TOPOLOGY_HELPERS */
> +#endif /* VIRT_IOMMU_H_ */
> diff --git a/drivers/iommu/virtio/topology-helpers.c 
> b/drivers/iommu/virtio/topology-helpers.c
> new file mode 100644
> index ..8815e3a5d431
> --- /dev/null
> +++ b/drivers/iommu/virtio/topology-helpers.c
> @@ -0,0 +1,196 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "topology-helpers.h"
> +
> +static LIST_HEAD(viommus);
> +static LIST_HEAD(pci_endpoints);
> +static LIST_HEAD(mmio_endpoints);
> +sta

Re: [PATCH v3 0/6] Add virtio-iommu built-in topology

2020-09-04 Thread Auger Eric
Hi,

On 8/21/20 3:15 PM, Jean-Philippe Brucker wrote:
> Add a topology description to the virtio-iommu driver and enable x86
> platforms.
> 
> Since [v2] we have made some progress on adding ACPI support for
> virtio-iommu, which is the preferred boot method on x86. It will be a
> new vendor-agnostic table describing para-virtual topologies in a
> minimal format. However some platforms don't use either ACPI or DT for
> booting (for example microvm), and will need the alternative topology
> description method proposed here. In addition, since the process to get
> a new ACPI table will take a long time, this provides a boot method even
> to ACPI-based platforms, if only temporarily for testing and
> development.
> 
> v3:
> * Add patch 1 that moves virtio-iommu to a subfolder.
> * Split the rest:
>   * Patch 2 adds topology-helper.c, which will be shared with the ACPI
> support.
>   * Patch 4 adds definitions.
>   * Patch 5 adds parser in topology.c.
> * Address other comments.
> 
> Linux and QEMU patches available at:
> https://jpbrucker.net/git/linux virtio-iommu/devel
> https://jpbrucker.net/git/qemu virtio-iommu/devel
I have tested that series with above QEMU branch on ARM with virtio-net
and virtio-blk translated devices in non DT mode.

It works for me:
Tested-by: Eric Auger 

Thanks

Eric

> 
> [spec] https://lists.oasis-open.org/archives/virtio-dev/202008/msg00067.html
> [v2] 
> https://lore.kernel.org/linux-iommu/20200228172537.377327-1-jean-phili...@linaro.org/
> [v1] 
> https://lore.kernel.org/linux-iommu/20200214160413.1475396-1-jean-phili...@linaro.org/
> [rfc] 
> https://lore.kernel.org/linux-iommu/20191122105000.800410-1-jean-phili...@linaro.org/
> 
> Jean-Philippe Brucker (6):
>   iommu/virtio: Move to drivers/iommu/virtio/
>   iommu/virtio: Add topology helpers
>   PCI: Add DMA configuration for virtual platforms
>   iommu/virtio: Add topology definitions
>   iommu/virtio: Support topology description in config space
>   iommu/virtio: Enable x86 support
> 
>  drivers/iommu/Kconfig |  18 +-
>  drivers/iommu/Makefile|   3 +-
>  drivers/iommu/virtio/Makefile |   4 +
>  drivers/iommu/virtio/topology-helpers.h   |  50 +
>  include/linux/virt_iommu.h|  15 ++
>  include/uapi/linux/virtio_iommu.h |  44 
>  drivers/iommu/virtio/topology-helpers.c   | 196 
>  drivers/iommu/virtio/topology.c   | 259 ++
>  drivers/iommu/{ => virtio}/virtio-iommu.c |   4 +
>  drivers/pci/pci-driver.c  |   5 +
>  MAINTAINERS   |   3 +-
>  11 files changed, 597 insertions(+), 4 deletions(-)
>  create mode 100644 drivers/iommu/virtio/Makefile
>  create mode 100644 drivers/iommu/virtio/topology-helpers.h
>  create mode 100644 include/linux/virt_iommu.h
>  create mode 100644 drivers/iommu/virtio/topology-helpers.c
>  create mode 100644 drivers/iommu/virtio/topology.c
>  rename drivers/iommu/{ => virtio}/virtio-iommu.c (99%)
> 

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization