From: Jean-Philippe Brucker <jean-philippe@linaro.org> To: iommu@lists.linux-foundation.org, virtualization@lists.linux-foundation.org, linux-pci@vger.kernel.org Cc: joro@8bytes.org, bhelgaas@google.com, mst@redhat.com, jasowang@redhat.com, kevin.tian@intel.com, sebastien.boeuf@intel.com, eric.auger@redhat.com, jacob.jun.pan@intel.com, robin.murphy@arm.com, Jean-Philippe Brucker <jean-philippe@linaro.org> Subject: [PATCH v2 2/3] PCI: Add DMA configuration for virtual platforms Date: Fri, 28 Feb 2020 18:25:37 +0100 [thread overview] Message-ID: <20200228172537.377327-3-jean-philippe@linaro.org> (raw) In-Reply-To: <20200228172537.377327-1-jean-philippe@linaro.org> Hardware platforms usually describe the IOMMU topology using either device-tree pointers or vendor-specific ACPI tables. For virtual platforms that don't provide a device-tree, the virtio-iommu device contains a description of the endpoints it manages. That information allows us to probe endpoints after the IOMMU is probed (possibly as late as userspace modprobe), provided it is discovered early enough. Add a hook to pci_dma_configure(), which returns -EPROBE_DEFER if the endpoint is managed by a vIOMMU that will be loaded later, or 0 in any other case to avoid disturbing the normal DMA configuration methods. When CONFIG_VIRTIO_IOMMU_TOPOLOGY isn't selected, the call to virt_dma_configure() is compiled out. As long as the information is consistent, platforms can provide both a device-tree and a built-in topology, and the IOMMU infrastructure is able to deal with multiple DMA configuration methods. Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> --- drivers/pci/pci-driver.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 0454ca0e4e3f..69303a814f21 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -18,6 +18,7 @@ #include <linux/kexec.h> #include <linux/of_device.h> #include <linux/acpi.h> +#include <linux/virt_iommu.h> #include "pci.h" #include "pcie/portdrv.h" @@ -1602,6 +1603,10 @@ static int pci_dma_configure(struct device *dev) struct device *bridge; int ret = 0; + ret = virt_dma_configure(dev); + if (ret) + return ret; + bridge = pci_get_host_bridge_device(to_pci_dev(dev)); if (IS_ENABLED(CONFIG_OF) && bridge->parent && -- 2.25.0
WARNING: multiple messages have this Message-ID (diff)
From: Jean-Philippe Brucker <jean-philippe@linaro.org> To: iommu@lists.linux-foundation.org, virtualization@lists.linux-foundation.org, linux-pci@vger.kernel.org Cc: Jean-Philippe Brucker <jean-philippe@linaro.org>, kevin.tian@intel.com, mst@redhat.com, sebastien.boeuf@intel.com, jacob.jun.pan@intel.com, bhelgaas@google.com, robin.murphy@arm.com, jasowang@redhat.com Subject: [PATCH v2 2/3] PCI: Add DMA configuration for virtual platforms Date: Fri, 28 Feb 2020 18:25:37 +0100 [thread overview] Message-ID: <20200228172537.377327-3-jean-philippe@linaro.org> (raw) In-Reply-To: <20200228172537.377327-1-jean-philippe@linaro.org> Hardware platforms usually describe the IOMMU topology using either device-tree pointers or vendor-specific ACPI tables. For virtual platforms that don't provide a device-tree, the virtio-iommu device contains a description of the endpoints it manages. That information allows us to probe endpoints after the IOMMU is probed (possibly as late as userspace modprobe), provided it is discovered early enough. Add a hook to pci_dma_configure(), which returns -EPROBE_DEFER if the endpoint is managed by a vIOMMU that will be loaded later, or 0 in any other case to avoid disturbing the normal DMA configuration methods. When CONFIG_VIRTIO_IOMMU_TOPOLOGY isn't selected, the call to virt_dma_configure() is compiled out. As long as the information is consistent, platforms can provide both a device-tree and a built-in topology, and the IOMMU infrastructure is able to deal with multiple DMA configuration methods. Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> --- drivers/pci/pci-driver.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 0454ca0e4e3f..69303a814f21 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -18,6 +18,7 @@ #include <linux/kexec.h> #include <linux/of_device.h> #include <linux/acpi.h> +#include <linux/virt_iommu.h> #include "pci.h" #include "pcie/portdrv.h" @@ -1602,6 +1603,10 @@ static int pci_dma_configure(struct device *dev) struct device *bridge; int ret = 0; + ret = virt_dma_configure(dev); + if (ret) + return ret; + bridge = pci_get_host_bridge_device(to_pci_dev(dev)); if (IS_ENABLED(CONFIG_OF) && bridge->parent && -- 2.25.0 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2020-02-28 17:29 UTC|newest] Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-02-28 17:25 [PATCH v2 0/3] virtio-iommu on x86 and non-devicetree platforms Jean-Philippe Brucker 2020-02-28 17:25 ` Jean-Philippe Brucker 2020-02-28 17:25 ` [PATCH v2 1/3] iommu/virtio: Add topology description to virtio-iommu config space Jean-Philippe Brucker 2020-02-28 17:25 ` Jean-Philippe Brucker 2020-03-01 11:17 ` Michael S. Tsirkin 2020-03-01 11:17 ` Michael S. Tsirkin 2020-03-02 16:16 ` Joerg Roedel 2020-03-02 16:16 ` Joerg Roedel 2020-03-03 10:19 ` Auger Eric 2020-03-03 10:19 ` Auger Eric 2020-03-03 13:01 ` Joerg Roedel 2020-03-03 13:01 ` Joerg Roedel 2020-03-03 14:00 ` Michael S. Tsirkin 2020-03-03 14:00 ` Michael S. Tsirkin 2020-03-03 15:53 ` Joerg Roedel 2020-03-03 15:53 ` Joerg Roedel 2020-03-03 16:09 ` Michael S. Tsirkin 2020-03-03 16:09 ` Michael S. Tsirkin 2020-03-03 16:21 ` Auger Eric 2020-03-03 16:21 ` Auger Eric 2020-03-04 13:37 ` Joerg Roedel 2020-03-04 13:37 ` Joerg Roedel 2020-03-04 15:38 ` Jean-Philippe Brucker 2020-03-04 15:38 ` Jean-Philippe Brucker 2020-03-04 17:40 ` Joerg Roedel 2020-03-04 17:40 ` Joerg Roedel 2020-03-04 21:37 ` Jacob Pan (Jun) 2020-03-04 21:37 ` Jacob Pan (Jun) 2020-03-04 21:37 ` Jacob Pan (Jun) 2020-03-04 21:54 ` Joerg Roedel 2020-03-04 21:54 ` Joerg Roedel 2020-03-05 15:42 ` Michael S. Tsirkin 2020-03-05 15:42 ` Michael S. Tsirkin 2020-03-04 15:48 ` Jacob Pan 2020-03-04 15:48 ` Jacob Pan 2020-03-04 17:34 ` Joerg Roedel 2020-03-04 17:34 ` Joerg Roedel 2020-03-04 19:34 ` Michael S. Tsirkin 2020-03-04 19:34 ` Michael S. Tsirkin 2020-03-04 21:50 ` Joerg Roedel 2020-03-04 21:50 ` Joerg Roedel 2020-03-05 15:39 ` Michael S. Tsirkin 2020-03-05 15:39 ` Michael S. Tsirkin 2020-03-03 14:02 ` Michael S. Tsirkin 2020-03-03 14:02 ` Michael S. Tsirkin 2020-03-03 14:02 ` Michael S. Tsirkin 2020-03-05 8:07 ` Tian, Kevin 2020-03-05 8:07 ` Tian, Kevin 2020-03-05 8:07 ` Tian, Kevin 2020-03-11 17:48 ` Jean-Philippe Brucker 2020-03-11 17:48 ` Jean-Philippe Brucker 2020-03-11 17:48 ` Jean-Philippe Brucker 2020-03-11 21:48 ` Michael S. Tsirkin 2020-03-11 21:48 ` Michael S. Tsirkin 2020-03-11 21:48 ` Michael S. Tsirkin 2020-04-13 13:22 ` Michael S. Tsirkin 2020-04-13 13:22 ` Michael S. Tsirkin 2020-04-21 7:31 ` Tian, Kevin 2020-04-21 7:31 ` Tian, Kevin 2020-04-21 7:31 ` Tian, Kevin 2020-08-21 8:39 ` Jean-Philippe Brucker 2020-08-21 8:39 ` Jean-Philippe Brucker 2020-08-21 8:39 ` Jean-Philippe Brucker 2020-02-28 17:25 ` Jean-Philippe Brucker [this message] 2020-02-28 17:25 ` [PATCH v2 2/3] PCI: Add DMA configuration for virtual platforms Jean-Philippe Brucker 2020-03-18 21:10 ` Bjorn Helgaas 2020-03-18 21:10 ` Bjorn Helgaas 2020-02-28 17:25 ` [PATCH v2 3/3] iommu/virtio: Enable x86 support Jean-Philippe Brucker 2020-02-28 17:25 ` Jean-Philippe Brucker 2020-02-29 14:23 ` kbuild test robot 2020-02-29 14:23 ` kbuild test robot 2020-02-29 14:23 ` kbuild test robot
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200228172537.377327-3-jean-philippe@linaro.org \ --to=jean-philippe@linaro.org \ --cc=bhelgaas@google.com \ --cc=eric.auger@redhat.com \ --cc=iommu@lists.linux-foundation.org \ --cc=jacob.jun.pan@intel.com \ --cc=jasowang@redhat.com \ --cc=joro@8bytes.org \ --cc=kevin.tian@intel.com \ --cc=linux-pci@vger.kernel.org \ --cc=mst@redhat.com \ --cc=robin.murphy@arm.com \ --cc=sebastien.boeuf@intel.com \ --cc=virtualization@lists.linux-foundation.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.