qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Auger <eric.auger@redhat.com>
To: eric.auger@redhat.com, eric.auger.pro@gmail.com,
	peter.maydell@linaro.org, qemu-arm@nongnu.org,
	qemu-devel@nongnu.org, alex.williamson@redhat.com,
	pranav.sawargaonkar@gmail.com
Cc: diana.craciun@freescale.com, christoffer.dall@linaro.org,
	drjones@redhat.com, Bharat.Bhushan@freescale.com
Subject: [Qemu-devel] [RFC v3 3/8] hw: vfio: common: Introduce vfio_register_msi_iova
Date: Thu,  6 Oct 2016 09:50:39 +0000	[thread overview]
Message-ID: <1475747444-12552-4-git-send-email-eric.auger@redhat.com> (raw)
In-Reply-To: <1475747444-12552-1-git-send-email-eric.auger@redhat.com>

vfio_register_msi_iova allows to register the MSI IOVA region.
This IOVA window will be used by the kernel to map MSI doorbells.

The function will become static in subsequent patches. However, since
there is no user yet, the compiler argues; the function is currently
not static and a dummy declaration needs to be added.

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

---

v2 -> v3:
- rename vfio_register_reserved_iova into vfio_register_msi_iova
- VFIO_DMA_MAP_FLAG_MSI_RESERVED_IOVA renamed into
  VFIO_DMA_MAP_FLAG_RESERVED_MSI_IOVA
---
 hw/vfio/common.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 4f4014e..fe8a855 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -212,6 +212,34 @@ static int vfio_dma_unmap(VFIOContainer *container,
     return 0;
 }
 
+/**
+ * vfio_register_msi_iova: registers the MSI iova region
+ *
+ * @container: container handle
+ * @iova: base IOVA of the MSI region
+ * @size: size of the MSI IOVA region
+ */
+int vfio_register_msi_iova(VFIOContainer *container, hwaddr iova,
+                           ram_addr_t size);
+int vfio_register_msi_iova(VFIOContainer *container, hwaddr iova,
+                           ram_addr_t size)
+{
+    int ret;
+    struct vfio_iommu_type1_dma_map map = {
+        .argsz = sizeof(map),
+        .flags = VFIO_DMA_MAP_FLAG_RESERVED_MSI_IOVA,
+        .iova = iova,
+        .size = size,
+    };
+
+    ret = ioctl(container->fd, VFIO_IOMMU_MAP_DMA, &map);
+
+    if (ret) {
+        error_report("VFIO_MAP_DMA/RESERVED_MSI_IOVA: %m");
+    }
+    return ret;
+}
+
 static int vfio_dma_map(VFIOContainer *container, hwaddr iova,
                         ram_addr_t size, void *vaddr, bool readonly)
 {
-- 
1.9.1

  parent reply	other threads:[~2016-10-06  9:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-06  9:50 [Qemu-devel] [RFC v3 0/8] KVM PCI/MSI passthrough with mach-virt Eric Auger
2016-10-06  9:50 ` [Qemu-devel] [RFC v3 1/8] linux-headers: Partial update for MSI IOVA handling Eric Auger
2016-10-06  9:50 ` [Qemu-devel] [RFC v3 2/8] hw: vfio: common: vfio_get_iommu_type1_info Eric Auger
2016-10-06  9:50 ` Eric Auger [this message]
2016-10-06  9:50 ` [Qemu-devel] [RFC v3 4/8] memory: Add reserved_iova region type Eric Auger
2016-10-06  9:50 ` [Qemu-devel] [RFC v3 5/8] memory: memory_region_find_by_name Eric Auger
2016-10-06  9:50 ` [Qemu-devel] [RFC v3 6/8] hw: platform-bus: Enable to map any memory region onto the platform-bus Eric Auger
2016-10-06  9:50 ` [Qemu-devel] [RFC v3 7/8] hw: vfio: common: vfio_prepare_msi_mapping Eric Auger
2016-10-06 10:51   ` Auger Eric
2016-10-06  9:50 ` [Qemu-devel] [RFC v3 8/8] hw: vfio: common: Adapt vfio_listeners for reserved_iova region Eric Auger

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=1475747444-12552-4-git-send-email-eric.auger@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=Bharat.Bhushan@freescale.com \
    --cc=alex.williamson@redhat.com \
    --cc=christoffer.dall@linaro.org \
    --cc=diana.craciun@freescale.com \
    --cc=drjones@redhat.com \
    --cc=eric.auger.pro@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=pranav.sawargaonkar@gmail.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).