From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrU1t-0004QP-CO for qemu-devel@nongnu.org; Tue, 25 Jun 2013 10:15:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UrU1s-0002r5-4Z for qemu-devel@nongnu.org; Tue, 25 Jun 2013 10:15:33 -0400 Received: from mail-ee0-x22f.google.com ([2a00:1450:4013:c00::22f]:56077) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UrU1r-0002r1-Pu for qemu-devel@nongnu.org; Tue, 25 Jun 2013 10:15:32 -0400 Received: by mail-ee0-f47.google.com with SMTP id e49so6638959eek.6 for ; Tue, 25 Jun 2013 07:15:31 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 25 Jun 2013 16:14:50 +0200 Message-Id: <1372169705-7645-10-git-send-email-pbonzini@redhat.com> In-Reply-To: <1372169705-7645-1-git-send-email-pbonzini@redhat.com> References: <1372169705-7645-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 09/24] vfio: pass device to vfio_mmap_bar and use it to set owner List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, alex.williamson@redhat.com Cc: Alex Williamson Signed-off-by: Paolo Bonzini --- hw/misc/vfio.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index 675bbfc..58013eb 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -2205,7 +2205,8 @@ static void vfio_unmap_bar(VFIODevice *vdev, int nr) memory_region_destroy(&bar->mem); } -static int vfio_mmap_bar(VFIOBAR *bar, MemoryRegion *mem, MemoryRegion *submem, +static int vfio_mmap_bar(VFIODevice *vdev, VFIOBAR *bar, + MemoryRegion *mem, MemoryRegion *submem, void **map, size_t size, off_t offset, const char *name) { @@ -2230,11 +2231,11 @@ static int vfio_mmap_bar(VFIOBAR *bar, MemoryRegion *mem, MemoryRegion *submem, goto empty_region; } - memory_region_init_ram_ptr(submem, NULL, name, size, *map); + memory_region_init_ram_ptr(submem, OBJECT(vdev), name, size, *map); } else { empty_region: /* Create a zero sized sub-region to make cleanup easy. */ - memory_region_init(submem, NULL, name, 0); + memory_region_init(submem, OBJECT(vdev), name, 0); } memory_region_add_subregion(mem, offset, submem); @@ -2285,7 +2286,7 @@ static void vfio_map_bar(VFIODevice *vdev, int nr) } strncat(name, " mmap", sizeof(name) - strlen(name) - 1); - if (vfio_mmap_bar(bar, &bar->mem, + if (vfio_mmap_bar(vdev, bar, &bar->mem, &bar->mmap_mem, &bar->mmap, size, 0, name)) { error_report("%s unsupported. Performance may be slow", name); } @@ -2299,7 +2300,7 @@ static void vfio_map_bar(VFIODevice *vdev, int nr) size = start < bar->size ? bar->size - start : 0; strncat(name, " msix-hi", sizeof(name) - strlen(name) - 1); /* VFIOMSIXInfo contains another MemoryRegion for this mapping */ - if (vfio_mmap_bar(bar, &bar->mem, &vdev->msix->mmap_mem, + if (vfio_mmap_bar(vdev, bar, &bar->mem, &vdev->msix->mmap_mem, &vdev->msix->mmap, size, start, name)) { error_report("%s unsupported. Performance may be slow", name); } -- 1.8.1.4