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