qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 5/5] virtio-iommu: add iommu notifier memory-region
Date: Wed, 27 Sep 2017 12:03:20 +0530	[thread overview]
Message-ID: <1506494000-31982-6-git-send-email-Bharat.Bhushan@nxp.com> (raw)
In-Reply-To: <1506494000-31982-1-git-send-email-Bharat.Bhushan@nxp.com>

Finally add notify_flag_changed() to for memory-region
access flag iommu flag change notifier

Finally add the memory notifier

Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
---
v3->v4:
 - notify_flag_changed functionality moved in separate patch
 - No other changes

 hw/virtio/trace-events   |  2 ++
 hw/virtio/virtio-iommu.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events
index 840d54f..a9de0d4 100644
--- a/hw/virtio/trace-events
+++ b/hw/virtio/trace-events
@@ -52,3 +52,5 @@ virtio_iommu_set_page_size_mask(const char *iommu_mr, uint64_t mask) "mr=%s page
 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""
+virtio_iommu_notify_flag_add(const char *iommu) "Add virtio-iommu notifier node for memory region %s"
+virtio_iommu_notify_flag_del(const char *iommu) "Del virtio-iommu notifier node for memory region %s"
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
index d4d34cf..a9b0d72 100644
--- a/hw/virtio/virtio-iommu.c
+++ b/hw/virtio/virtio-iommu.c
@@ -764,6 +764,36 @@ push:
     }
 }
 
+static void virtio_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu_mr,
+                                             IOMMUNotifierFlag old,
+                                             IOMMUNotifierFlag new)
+{
+    IOMMUDevice *sdev = container_of(iommu_mr, IOMMUDevice, iommu_mr);
+    VirtIOIOMMU *s = sdev->viommu;
+    VirtioIOMMUNotifierNode *node = NULL;
+    VirtioIOMMUNotifierNode *next_node = NULL;
+
+    if (old == IOMMU_NOTIFIER_NONE) {
+        trace_virtio_iommu_notify_flag_add(iommu_mr->parent_obj.name);
+        node = g_malloc0(sizeof(*node));
+        node->iommu_dev = sdev;
+        QLIST_INSERT_HEAD(&s->notifiers_list, node, next);
+        return;
+    }
+
+    /* update notifier node with new flags */
+    QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) {
+        if (node->iommu_dev == sdev) {
+            if (new == IOMMU_NOTIFIER_NONE) {
+                trace_virtio_iommu_notify_flag_del(iommu_mr->parent_obj.name);
+                QLIST_REMOVE(node, next);
+                g_free(node);
+            }
+            return;
+        }
+    }
+}
+
 static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,
                                             IOMMUAccessFlags flag)
 {
@@ -1041,6 +1071,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;
+    imrc->notify_flag_changed = virtio_iommu_notify_flag_changed;
 }
 
 static const TypeInfo virtio_iommu_info = {
-- 
1.9.3

  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 ` [Qemu-devel] [PATCH v4 4/5] virtio-iommu: add iommu replay Bharat Bhushan
2017-09-27  6:33 ` Bharat Bhushan [this message]
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-6-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).