thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-vfio-Create-shared-routine-for-scanning-info-capabil.patch

c687bc
From f53c2c68db7780353a915072f8c953a74149b1f7 Mon Sep 17 00:00:00 2001
c687bc
From: Cornelia Huck <cohuck@redhat.com>
c687bc
Date: Tue, 19 Jan 2021 12:50:42 -0500
c687bc
Subject: [PATCH 3/7] vfio: Create shared routine for scanning info
c687bc
 capabilities
c687bc
MIME-Version: 1.0
c687bc
Content-Type: text/plain; charset=UTF-8
c687bc
Content-Transfer-Encoding: 8bit
c687bc
c687bc
RH-Author: Cornelia Huck <cohuck@redhat.com>
c687bc
Message-id: <20210119125046.472811-4-cohuck@redhat.com>
c687bc
Patchwork-id: 100678
c687bc
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH 3/7] vfio: Create shared routine for scanning info capabilities
c687bc
Bugzilla: 1905391
c687bc
RH-Acked-by: David Hildenbrand <david@redhat.com>
c687bc
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
c687bc
RH-Acked-by: Thomas Huth <thuth@redhat.com>
c687bc
c687bc
From: Matthew Rosato <mjrosato@linux.ibm.com>
c687bc
c687bc
Rather than duplicating the same loop in multiple locations,
c687bc
create a static function to do the work.
c687bc
c687bc
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
c687bc
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
c687bc
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
c687bc
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
c687bc
(cherry picked from commit 3ab7a0b40d4be5ade3b61d4afd1518193b199423)
c687bc
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
c687bc
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
c687bc
---
c687bc
 hw/vfio/common.c | 21 +++++++++++++--------
c687bc
 1 file changed, 13 insertions(+), 8 deletions(-)
c687bc
c687bc
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
c687bc
index 5ca11488d67..77d62d2dcdf 100644
c687bc
--- a/hw/vfio/common.c
c687bc
+++ b/hw/vfio/common.c
c687bc
@@ -826,17 +826,12 @@ static void vfio_listener_release(VFIOContainer *container)
c687bc
     }
c687bc
 }
c687bc
 
c687bc
-struct vfio_info_cap_header *
c687bc
-vfio_get_region_info_cap(struct vfio_region_info *info, uint16_t id)
c687bc
+static struct vfio_info_cap_header *
c687bc
+vfio_get_cap(void *ptr, uint32_t cap_offset, uint16_t id)
c687bc
 {
c687bc
     struct vfio_info_cap_header *hdr;
c687bc
-    void *ptr = info;
c687bc
-
c687bc
-    if (!(info->flags & VFIO_REGION_INFO_FLAG_CAPS)) {
c687bc
-        return NULL;
c687bc
-    }
c687bc
 
c687bc
-    for (hdr = ptr + info->cap_offset; hdr != ptr; hdr = ptr + hdr->next) {
c687bc
+    for (hdr = ptr + cap_offset; hdr != ptr; hdr = ptr + hdr->next) {
c687bc
         if (hdr->id == id) {
c687bc
             return hdr;
c687bc
         }
c687bc
@@ -845,6 +840,16 @@ vfio_get_region_info_cap(struct vfio_region_info *info, uint16_t id)
c687bc
     return NULL;
c687bc
 }
c687bc
 
c687bc
+struct vfio_info_cap_header *
c687bc
+vfio_get_region_info_cap(struct vfio_region_info *info, uint16_t id)
c687bc
+{
c687bc
+    if (!(info->flags & VFIO_REGION_INFO_FLAG_CAPS)) {
c687bc
+        return NULL;
c687bc
+    }
c687bc
+
c687bc
+    return vfio_get_cap((void *)info, info->cap_offset, id);
c687bc
+}
c687bc
+
c687bc
 static int vfio_setup_region_sparse_mmaps(VFIORegion *region,
c687bc
                                           struct vfio_region_info *info)
c687bc
 {
c687bc
-- 
c687bc
2.27.0
c687bc