From: Bharat Bhushan <Bharat.Bhushan@nxp.com>
To: eric.auger@redhat.com, eric.auger.pro@gmail.com,
peter.maydell@linaro.org, alex.williamson@redhat.com,
mst@redhat.com, qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: wei@redhat.com, kevin.tian@intel.com, marc.zyngier@arm.com,
tn@semihalf.com, will.deacon@arm.com, drjones@redhat.com,
robin.murphy@arm.com, christoffer.dall@linaro.org,
bharatb.yadav@gmail.com, Bharat Bhushan <Bharat.Bhushan@nxp.com>
Subject: [Qemu-devel] [PATCH v4 4/5] virtio-iommu: add iommu replay
Date: Wed, 27 Sep 2017 12:03:19 +0530 [thread overview]
Message-ID: <1506494000-31982-5-git-send-email-Bharat.Bhushan@nxp.com> (raw)
In-Reply-To: <1506494000-31982-1-git-send-email-Bharat.Bhushan@nxp.com>
Default replay does not work with virtio-iommu,
so this patch provide virtio-iommu replay functionality.
Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
---
v3->v4:
- Replay functionality moved in separate patch
- No other changes
hw/virtio/trace-events | 1 +
hw/virtio/virtio-iommu.c | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
index 251b595..840d54f 100644
--- a/hw/virtio/trace-events
+++ b/hw/virtio/trace-events
@@ -51,3 +51,4 @@ virtio_iommu_fill_none_property(uint32_t devid) "devid=%d"
virtio_iommu_set_page_size_mask(const char *iommu_mr, uint64_t mask) "mr=%s page_size_mask=0x%"PRIx64
virtio_iommu_notify_map(const char *name, hwaddr iova, hwaddr paddr, hwaddr map_size) "mr=%s iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64""
virtio_iommu_notify_unmap(const char *name, hwaddr iova, hwaddr map_size) "mr=%s iova=0x%"PRIx64" size=0x%"PRIx64""
+virtio_iommu_remap(hwaddr iova, hwaddr pa, hwaddr size) "iova=0x%"PRIx64" pa=0x%" PRIx64" size=0x%"PRIx64""
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
index ff91bce..d4d34cf 100644
--- a/hw/virtio/virtio-iommu.c
+++ b/hw/virtio/virtio-iommu.c
@@ -906,6 +906,43 @@ static gint int_cmp(gconstpointer a, gconstpointer b, gpointer user_data)
return (ua > ub) - (ua < ub);
}
+static gboolean virtio_iommu_remap(gpointer key, gpointer value, gpointer data)
+{
+ viommu_mapping *mapping = (viommu_mapping *) value;
+ IOMMUMemoryRegion *mr = (IOMMUMemoryRegion *) data;
+
+ trace_virtio_iommu_remap(mapping->virt_addr, mapping->phys_addr,
+ mapping->size);
+ /* unmap previous entry and map again */
+ virtio_iommu_notify_unmap(mr, mapping->virt_addr, mapping->size);
+
+ virtio_iommu_notify_map(mr, mapping->virt_addr, mapping->phys_addr,
+ mapping->size);
+ return false;
+}
+
+static void virtio_iommu_replay(IOMMUMemoryRegion *mr, IOMMUNotifier *n)
+{
+ IOMMUDevice *sdev = container_of(mr, IOMMUDevice, iommu_mr);
+ VirtIOIOMMU *s = sdev->viommu;
+ uint32_t sid;
+ viommu_dev *dev;
+
+ sid = virtio_iommu_get_sid(sdev);
+
+ qemu_mutex_lock(&s->mutex);
+
+ dev = g_tree_lookup(s->devices, GUINT_TO_POINTER(sid));
+ if (!dev || !dev->as) {
+ goto unlock;
+ }
+
+ g_tree_foreach(dev->as->mappings, virtio_iommu_remap, mr);
+
+unlock:
+ qemu_mutex_unlock(&s->mutex);
+}
+
static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
@@ -1003,6 +1040,7 @@ static void virtio_iommu_memory_region_class_init(ObjectClass *klass,
imrc->translate = virtio_iommu_translate;
imrc->set_page_size_mask = virtio_iommu_set_page_size_mask;
+ imrc->replay = virtio_iommu_replay;
}
static const TypeInfo virtio_iommu_info = {
--
1.9.3
next prev parent reply other threads:[~2017-09-27 6:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-27 6:33 [Qemu-devel] [PATCH v4 0/5] virtio-iommu: VFIO integration Bharat Bhushan
2017-09-27 6:33 ` [Qemu-devel] [PATCH v4 1/5] target/arm/kvm: Translate the MSI doorbell in kvm_arch_fixup_msi_route Bharat Bhushan
2017-09-27 6:33 ` [Qemu-devel] [PATCH v4 2/5] virtio-iommu: Add iommu notifier for map/unmap Bharat Bhushan
2017-09-27 6:33 ` [Qemu-devel] [PATCH v4 3/5] virtio-iommu: Call iommu notifier for attach/detach Bharat Bhushan
2017-09-27 6:33 ` Bharat Bhushan [this message]
2017-09-27 6:33 ` [Qemu-devel] [PATCH v4 5/5] virtio-iommu: add iommu notifier memory-region Bharat Bhushan
2017-09-27 6:46 ` [Qemu-devel] [PATCH v4 0/5] virtio-iommu: VFIO integration Bharat Bhushan
2017-09-27 7:01 ` Peter Xu
2017-09-27 8:32 ` Bharat Bhushan
2017-09-27 7:41 ` [Qemu-devel] [Qemu-arm] " Linu Cherian
2017-09-27 8:30 ` Bharat Bhushan
2017-09-27 8:55 ` Auger Eric
2017-09-27 9:05 ` Linu Cherian
2017-09-27 9:21 ` Linu Cherian
2017-09-27 9:24 ` Auger Eric
2017-10-04 11:49 ` Linu Cherian
2017-10-05 10:46 ` Auger Eric
2017-10-05 11:54 ` Auger Eric
2017-10-05 12:13 ` Auger Eric
2017-10-05 17:02 ` Auger Eric
2017-10-06 3:46 ` Bharat Bhushan
2017-10-06 7:24 ` Auger Eric
2017-10-06 8:41 ` Linu Cherian
2017-10-10 6:42 ` Bharat Bhushan
2017-10-11 9:42 ` Auger Eric
2017-09-27 8:58 ` Linu Cherian
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=1506494000-31982-5-git-send-email-Bharat.Bhushan@nxp.com \
--to=bharat.bhushan@nxp.com \
--cc=alex.williamson@redhat.com \
--cc=bharatb.yadav@gmail.com \
--cc=christoffer.dall@linaro.org \
--cc=drjones@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=eric.auger@redhat.com \
--cc=kevin.tian@intel.com \
--cc=marc.zyngier@arm.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=robin.murphy@arm.com \
--cc=tn@semihalf.com \
--cc=wei@redhat.com \
--cc=will.deacon@arm.com \
/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).