From patchwork Thu Oct 6 09:50:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 678803 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sqSmn6lfqz9rxw for ; Thu, 6 Oct 2016 20:59:37 +1100 (AEDT) Received: from localhost ([::1]:54371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs5Sg-0005Nv-TB for incoming@patchwork.ozlabs.org; Thu, 06 Oct 2016 05:59:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs5KT-0006wo-LD for qemu-devel@nongnu.org; Thu, 06 Oct 2016 05:51:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bs5KS-0007Dx-M6 for qemu-devel@nongnu.org; Thu, 06 Oct 2016 05:51:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs5KN-0007B8-4l; Thu, 06 Oct 2016 05:50:59 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 857E13F755; Thu, 6 Oct 2016 09:50:58 +0000 (UTC) Received: from localhost.redhat.com (vpn1-6-233.ams2.redhat.com [10.36.6.233]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u969okS2016130; Thu, 6 Oct 2016 05:50:56 -0400 From: Eric Auger To: eric.auger@redhat.com, eric.auger.pro@gmail.com, peter.maydell@linaro.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org, alex.williamson@redhat.com, pranav.sawargaonkar@gmail.com Date: Thu, 6 Oct 2016 09:50:39 +0000 Message-Id: <1475747444-12552-4-git-send-email-eric.auger@redhat.com> In-Reply-To: <1475747444-12552-1-git-send-email-eric.auger@redhat.com> References: <1475747444-12552-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 06 Oct 2016 09:50:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC v3 3/8] hw: vfio: common: Introduce vfio_register_msi_iova X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: diana.craciun@freescale.com, Bharat.Bhushan@freescale.com, drjones@redhat.com, christoffer.dall@linaro.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" vfio_register_msi_iova allows to register the MSI IOVA region. This IOVA window will be used by the kernel to map MSI doorbells. The function will become static in subsequent patches. However, since there is no user yet, the compiler argues; the function is currently not static and a dummy declaration needs to be added. Signed-off-by: Eric Auger --- v2 -> v3: - rename vfio_register_reserved_iova into vfio_register_msi_iova - VFIO_DMA_MAP_FLAG_MSI_RESERVED_IOVA renamed into VFIO_DMA_MAP_FLAG_RESERVED_MSI_IOVA --- hw/vfio/common.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 4f4014e..fe8a855 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -212,6 +212,34 @@ static int vfio_dma_unmap(VFIOContainer *container, return 0; } +/** + * vfio_register_msi_iova: registers the MSI iova region + * + * @container: container handle + * @iova: base IOVA of the MSI region + * @size: size of the MSI IOVA region + */ +int vfio_register_msi_iova(VFIOContainer *container, hwaddr iova, + ram_addr_t size); +int vfio_register_msi_iova(VFIOContainer *container, hwaddr iova, + ram_addr_t size) +{ + int ret; + struct vfio_iommu_type1_dma_map map = { + .argsz = sizeof(map), + .flags = VFIO_DMA_MAP_FLAG_RESERVED_MSI_IOVA, + .iova = iova, + .size = size, + }; + + ret = ioctl(container->fd, VFIO_IOMMU_MAP_DMA, &map); + + if (ret) { + error_report("VFIO_MAP_DMA/RESERVED_MSI_IOVA: %m"); + } + return ret; +} + static int vfio_dma_map(VFIOContainer *container, hwaddr iova, ram_addr_t size, void *vaddr, bool readonly) {