From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PATCH 1/3] vfio: make some of VFIO API public
Date: Mon, 22 Apr 2013 18:02:35 +1000 [thread overview]
Message-ID: <1366617757-6604-2-git-send-email-aik@ozlabs.ru> (raw)
In-Reply-To: <1366617757-6604-1-git-send-email-aik@ozlabs.ru>
The patch makes vfio_dma_map/vfio_dma_unmap functions public
for explicit use by VFIO clients rather that just being
called from MemoryListener.
The patch also adds a "connect" parameter to the vfio_get_group() function
to allow control over group and container creation and connection before
any device from the group is actially created in QEMU.
Cc: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
hw/misc/vfio.c | 15 ++++++++-------
include/hw/misc/vfio.h | 17 +++++++++++++++++
2 files changed, 25 insertions(+), 7 deletions(-)
create mode 100644 include/hw/misc/vfio.h
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
index 693a9ff..503125e 100644
--- a/hw/misc/vfio.c
+++ b/hw/misc/vfio.c
@@ -39,6 +39,7 @@
#include "qemu/range.h"
#include "sysemu/kvm.h"
#include "sysemu/sysemu.h"
+#include "hw/misc/vfio.h"
/* #define DEBUG_VFIO */
#ifdef DEBUG_VFIO
@@ -1877,8 +1878,8 @@ static void vfio_pci_write_config(PCIDevice *pdev, uint32_t addr,
/*
* DMA - Mapping and unmapping for the "type1" IOMMU interface used on x86
*/
-static int vfio_dma_unmap(VFIOContainer *container,
- hwaddr iova, ram_addr_t size)
+int vfio_dma_unmap(VFIOContainer *container,
+ hwaddr iova, ram_addr_t size)
{
struct vfio_iommu_type1_dma_unmap unmap = {
.argsz = sizeof(unmap),
@@ -1895,8 +1896,8 @@ static int vfio_dma_unmap(VFIOContainer *container,
return 0;
}
-static int vfio_dma_map(VFIOContainer *container, hwaddr iova,
- ram_addr_t size, void *vaddr, bool readonly)
+int vfio_dma_map(VFIOContainer *container, hwaddr iova,
+ ram_addr_t size, void *vaddr, bool readonly)
{
struct vfio_iommu_type1_dma_map map = {
.argsz = sizeof(map),
@@ -2706,7 +2707,7 @@ static void vfio_disconnect_container(VFIOGroup *group)
}
}
-static VFIOGroup *vfio_get_group(int groupid)
+VFIOGroup *vfio_get_group(int groupid, bool connect)
{
VFIOGroup *group;
char path[32];
@@ -2747,7 +2748,7 @@ static VFIOGroup *vfio_get_group(int groupid)
group->groupid = groupid;
QLIST_INIT(&group->device_list);
- if (vfio_connect_container(group)) {
+ if (connect && vfio_connect_container(group)) {
error_report("vfio: failed to setup container for group %d", groupid);
close(group->fd);
g_free(group);
@@ -2980,7 +2981,7 @@ static int vfio_initfn(PCIDevice *pdev)
DPRINTF("%s(%04x:%02x:%02x.%x) group %d\n", __func__, vdev->host.domain,
vdev->host.bus, vdev->host.slot, vdev->host.function, groupid);
- group = vfio_get_group(groupid);
+ group = vfio_get_group(groupid, true);
if (!group) {
error_report("vfio: failed to get group %d", groupid);
return -ENOENT;
diff --git a/include/hw/misc/vfio.h b/include/hw/misc/vfio.h
new file mode 100644
index 0000000..f39aef8
--- /dev/null
+++ b/include/hw/misc/vfio.h
@@ -0,0 +1,17 @@
+#ifndef VFIO_API_H
+#define VFIO_API_H
+
+#include <linux/vfio.h>
+
+struct VFIOContainer;
+struct VFIOGroup;
+
+extern int vfio_dma_unmap(struct VFIOContainer *container,
+ hwaddr iova, ram_addr_t size);
+
+extern int vfio_dma_map(struct VFIOContainer *container, hwaddr iova,
+ ram_addr_t size, void *vaddr, bool readonly);
+
+extern struct VFIOGroup *vfio_get_group(int groupid, bool connect);
+
+#endif
--
1.7.10.4
next prev parent reply other threads:[~2013-04-22 8:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-22 8:02 [Qemu-devel] [PATCH 0/3 QEMU v4] vfio on ppc64 Alexey Kardashevskiy
2013-04-22 8:02 ` Alexey Kardashevskiy [this message]
2013-04-22 8:02 ` [Qemu-devel] [PATCH 2/3] vfio: add support for spapr platform (powerpc64 server) Alexey Kardashevskiy
2013-04-22 8:02 ` [Qemu-devel] [PATCH 3/3] spapr vfio: add spapr-pci-vfio-host-bridge to support vfio Alexey Kardashevskiy
2013-04-22 18:39 ` [Qemu-devel] [PATCH 0/3 QEMU v4] vfio on ppc64 Alex Williamson
2013-04-22 23:44 ` [Qemu-devel] [Qemu-ppc] " David Gibson
2013-04-23 1:58 ` Alex Williamson
2013-04-23 3:14 ` David Gibson
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=1366617757-6604-2-git-send-email-aik@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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).