From patchwork Thu Oct 6 11:41:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 678843 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 3sqWBy5KX6z9ryZ for ; Thu, 6 Oct 2016 22:48:58 +1100 (AEDT) Received: from localhost ([::1]:55022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs7AV-0008Ez-BE for incoming@patchwork.ozlabs.org; Thu, 06 Oct 2016 07:48:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs73d-00026m-H6 for qemu-devel@nongnu.org; Thu, 06 Oct 2016 07:41:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bs73c-0001rV-Hd for qemu-devel@nongnu.org; Thu, 06 Oct 2016 07:41:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs73X-0001qK-NW; Thu, 06 Oct 2016 07:41:43 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (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 0C29231B315; Thu, 6 Oct 2016 11:41:43 +0000 (UTC) Received: from localhost.redhat.com (vpn1-6-233.ams2.redhat.com [10.36.6.233]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u96BfVNW005464; Thu, 6 Oct 2016 07:41:40 -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 11:41:25 +0000 Message-Id: <1475754090-22681-4-git-send-email-eric.auger@redhat.com> In-Reply-To: <1475754090-22681-1-git-send-email-eric.auger@redhat.com> References: <1475754090-22681-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 06 Oct 2016 11:41:43 +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 v4 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) {