From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: qemu-devel@nongnu.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
qemu-ppc@nongnu.org, David Gibson <david@gibson.dropbear.id.au>,
Alex Williamson <alex.williamson@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH qemu v5 1/2] memory/iommu/vfio: Define add_vfio_group() callback
Date: Thu, 5 Oct 2017 16:50:36 +1100 [thread overview]
Message-ID: <20171005055037.7767-2-aik@ozlabs.ru> (raw)
In-Reply-To: <20171005055037.7767-1-aik@ozlabs.ru>
The new callback will be called when a new VFIO IOMMU group is added.
This should cause no behavioral change, the next patch will.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
This could be at the higher level - in MemoryRegionOps, makes sense?
---
include/exec/memory.h | 4 ++++
hw/vfio/common.c | 15 +++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 5ed4042f87..64e0b4fc96 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -210,6 +210,10 @@ typedef struct IOMMUMemoryRegionClass {
IOMMUNotifierFlag new_flags);
/* Set this up to provide customized IOMMU replay function */
void (*replay)(IOMMUMemoryRegion *iommu, IOMMUNotifier *notifier);
+
+ /* Notifies IOMMUMR about attached VFIO IOMMU group */
+ void (*add_vfio_group)(IOMMUMemoryRegion *iommu_mr, int vfio_kvm_fd,
+ int groupfd);
} IOMMUMemoryRegionClass;
typedef struct CoalescedMemoryRange CoalescedMemoryRange;
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 7b2924c0ef..9e861e0393 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -481,6 +481,21 @@ static void vfio_listener_region_add(MemoryListener *listener,
VFIOGuestIOMMU *giommu;
IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr);
+#ifdef CONFIG_KVM
+ if (kvm_enabled()) {
+ VFIOGroup *group;
+ IOMMUMemoryRegionClass *imrc =
+ IOMMU_MEMORY_REGION_GET_CLASS(iommu_mr);
+
+ QLIST_FOREACH(group, &container->group_list, container_next) {
+ if (imrc->add_vfio_group) {
+ imrc->add_vfio_group(iommu_mr, vfio_kvm_device_fd,
+ group->fd);
+ }
+ }
+ }
+#endif
+
trace_vfio_listener_region_add_iommu(iova, end);
/*
* FIXME: For VFIO iommu types which have KVM acceleration to
--
2.11.0
next prev parent reply other threads:[~2017-10-05 5:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-05 5:50 [Qemu-devel] [PATCH qemu v5 0/2] vfio-pci, spapr: Allow in-kernel TCE ops acceleration Alexey Kardashevskiy
2017-10-05 5:50 ` Alexey Kardashevskiy [this message]
2017-11-30 21:56 ` [Qemu-devel] [PATCH qemu v5 1/2] memory/iommu/vfio: Define add_vfio_group() callback Alexey Kardashevskiy
2017-11-30 23:09 ` Alex Williamson
2017-12-01 0:04 ` Alexey Kardashevskiy
2017-10-05 5:50 ` [Qemu-devel] [PATCH qemu v5 2/2] spapr/iommu: Enable in-kernel TCE acceleration via VFIO KVM device Alexey Kardashevskiy
2017-10-05 6:01 ` [Qemu-devel] [PATCH qemu v5 0/2] vfio-pci, spapr: Allow in-kernel TCE ops acceleration no-reply
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=20171005055037.7767-2-aik@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=pbonzini@redhat.com \
--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).