From b4cb4dbce403eecae8765d1b6bcf13fdf361cec3 Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Mon, 24 Apr 2017 02:52:46 +0200 Subject: [PATCH 07/23] memory: provide IOMMU_NOTIFIER_FOREACH macro RH-Author: Peter Xu Message-id: <1493002373-13010-3-git-send-email-peterx@redhat.com> Patchwork-id: 74850 O-Subject: [RHEL7.4 qemu-kvm-rhev PATCH v2 2/9] memory: provide IOMMU_NOTIFIER_FOREACH macro Bugzilla: 1335808 RH-Acked-by: Marcel Apfelbaum RH-Acked-by: Michael S. Tsirkin RH-Acked-by: Xiao Wang A new macro is provided to iterate all the IOMMU notifiers hooked under specific IOMMU memory region. Reviewed-by: David Gibson Reviewed-by: Eric Auger Reviewed-by: \"Michael S. Tsirkin\" Signed-off-by: Peter Xu Message-Id: <1491562755-23867-3-git-send-email-peterx@redhat.com> Signed-off-by: Eduardo Habkost (cherry picked from commit 512fa40867e6118568756a81ddaf476a0fef0f32) Signed-off-by: Peter Xu Signed-off-by: Miroslav Rezanina --- include/exec/memory.h | 3 +++ memory.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index 0840c89..07e43da 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -239,6 +239,9 @@ struct MemoryRegion { IOMMUNotifierFlag iommu_notify_flags; }; +#define IOMMU_NOTIFIER_FOREACH(n, mr) \ + QLIST_FOREACH((n), &(mr)->iommu_notify, node) + /** * MemoryListener: callbacks structure for updates to the physical memory map * diff --git a/memory.c b/memory.c index 75ac595..7496b3d 100644 --- a/memory.c +++ b/memory.c @@ -1583,7 +1583,7 @@ static void memory_region_update_iommu_notify_flags(MemoryRegion *mr) IOMMUNotifierFlag flags = IOMMU_NOTIFIER_NONE; IOMMUNotifier *iommu_notifier; - QLIST_FOREACH(iommu_notifier, &mr->iommu_notify, node) { + IOMMU_NOTIFIER_FOREACH(iommu_notifier, mr) { flags |= iommu_notifier->notifier_flags; } @@ -1667,7 +1667,7 @@ void memory_region_notify_iommu(MemoryRegion *mr, request_flags = IOMMU_NOTIFIER_UNMAP; } - QLIST_FOREACH(iommu_notifier, &mr->iommu_notify, node) { + IOMMU_NOTIFIER_FOREACH(iommu_notifier, mr) { /* * Skip the notification if the notification does not overlap * with registered range. -- 1.8.3.1