[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v3 14/31] virtio-iommu: Store memory region in endpoint struct
From: |
Michael S. Tsirkin |
Subject: |
[PULL v3 14/31] virtio-iommu: Store memory region in endpoint struct |
Date: |
Wed, 4 Nov 2020 13:41:57 -0500 |
From: Jean-Philippe Brucker <jean-philippe@linaro.org>
Store the memory region associated to each endpoint into the endpoint
structure, to allow efficient memory notification on map/unmap.
Acked-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Message-Id: <20201030180510.747225-3-jean-philippe@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/virtio-iommu.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
index 4c8f3909b7..a5c2d69aad 100644
--- a/hw/virtio/virtio-iommu.c
+++ b/hw/virtio/virtio-iommu.c
@@ -49,6 +49,7 @@ typedef struct VirtIOIOMMUDomain {
typedef struct VirtIOIOMMUEndpoint {
uint32_t id;
VirtIOIOMMUDomain *domain;
+ IOMMUMemoryRegion *iommu_mr;
QLIST_ENTRY(VirtIOIOMMUEndpoint) next;
} VirtIOIOMMUEndpoint;
@@ -137,16 +138,19 @@ static VirtIOIOMMUEndpoint
*virtio_iommu_get_endpoint(VirtIOIOMMU *s,
uint32_t ep_id)
{
VirtIOIOMMUEndpoint *ep;
+ IOMMUMemoryRegion *mr;
ep = g_tree_lookup(s->endpoints, GUINT_TO_POINTER(ep_id));
if (ep) {
return ep;
}
- if (!virtio_iommu_mr(s, ep_id)) {
+ mr = virtio_iommu_mr(s, ep_id);
+ if (!mr) {
return NULL;
}
ep = g_malloc0(sizeof(*ep));
ep->id = ep_id;
+ ep->iommu_mr = mr;
trace_virtio_iommu_get_endpoint(ep_id);
g_tree_insert(s->endpoints, GUINT_TO_POINTER(ep_id), ep);
return ep;
@@ -910,9 +914,14 @@ static gboolean reconstruct_endpoints(gpointer key,
gpointer value,
VirtIOIOMMU *s = (VirtIOIOMMU *)data;
VirtIOIOMMUDomain *d = (VirtIOIOMMUDomain *)value;
VirtIOIOMMUEndpoint *iter;
+ IOMMUMemoryRegion *mr;
QLIST_FOREACH(iter, &d->endpoint_list, next) {
+ mr = virtio_iommu_mr(s, iter->id);
+ assert(mr);
+
iter->domain = d;
+ iter->iommu_mr = mr;
g_tree_insert(s->endpoints, GUINT_TO_POINTER(iter->id), iter);
}
return false; /* continue the domain traversal */
--
MST
- [PULL v3 03/31] virtio-mem: Make sure "usable_region_size" is always multiples of the block size, (continued)
- [PULL v3 03/31] virtio-mem: Make sure "usable_region_size" is always multiples of the block size, Michael S. Tsirkin, 2020/11/04
- [PULL v3 04/31] virtio-mem: Probe THP size to determine default block size, Michael S. Tsirkin, 2020/11/04
- [PULL v3 05/31] memory-device: Support big alignment requirements, Michael S. Tsirkin, 2020/11/04
- [PULL v3 06/31] memory-device: Add get_min_alignment() callback, Michael S. Tsirkin, 2020/11/04
- [PULL v3 08/31] hw/acpi : Don't use '#' flag of printf format, Michael S. Tsirkin, 2020/11/04
- [PULL v3 07/31] virito-mem: Implement get_min_alignment(), Michael S. Tsirkin, 2020/11/04
- [PULL v3 09/31] hw/acpi : add space before the open parenthesis '(', Michael S. Tsirkin, 2020/11/04
- [PULL v3 11/31] hw/virtio/vhost-backend: Fix Coverity CID 1432871, Michael S. Tsirkin, 2020/11/04
- [PULL v3 12/31] hw/smbios: Fix leaked fd in save_opt_one() error path, Michael S. Tsirkin, 2020/11/04
- [PULL v3 13/31] virtio-iommu: Fix virtio_iommu_mr(), Michael S. Tsirkin, 2020/11/04
- [PULL v3 14/31] virtio-iommu: Store memory region in endpoint struct,
Michael S. Tsirkin <=
- [PULL v3 15/31] virtio-iommu: Add memory notifiers for map/unmap, Michael S. Tsirkin, 2020/11/04
- [PULL v3 16/31] virtio-iommu: Call memory notifiers in attach/detach, Michael S. Tsirkin, 2020/11/04
- [PULL v3 17/31] virtio-iommu: Add replay() memory region callback, Michael S. Tsirkin, 2020/11/04
- [PULL v3 19/31] memory: Add interface to set iommu page size mask, Michael S. Tsirkin, 2020/11/04
- [PULL v3 20/31] vfio: Set IOMMU page size as per host supported page size, Michael S. Tsirkin, 2020/11/04
- [PULL v3 21/31] virtio-iommu: Set supported page size mask, Michael S. Tsirkin, 2020/11/04
- [PULL v3 22/31] vfio: Don't issue full 2^64 unmap, Michael S. Tsirkin, 2020/11/04
- [PULL v3 23/31] vhost-vdpa: Add qemu_close in vhost_vdpa_cleanup, Michael S. Tsirkin, 2020/11/04
- [PULL v3 24/31] net: Add vhost-vdpa in show_netdevs(), Michael S. Tsirkin, 2020/11/04
- [PULL v3 25/31] Revert "vhost-blk: set features before setting inflight feature", Michael S. Tsirkin, 2020/11/04