From patchwork Tue Jul 19 13:11:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 9237263 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 097AD60574 for ; Tue, 19 Jul 2016 13:12:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF2C126A4D for ; Tue, 19 Jul 2016 13:12:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E389E26E64; Tue, 19 Jul 2016 13:12:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69DE726A4D for ; Tue, 19 Jul 2016 13:12:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753591AbcGSNLx (ORCPT ); Tue, 19 Jul 2016 09:11:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49237 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753215AbcGSNLt (ORCPT ); Tue, 19 Jul 2016 09:11:49 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (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 0502FC05AA60; Tue, 19 Jul 2016 13:11:49 +0000 (UTC) Received: from localhost.redhat.com (vpn1-4-201.ams2.redhat.com [10.36.4.201]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6JDBbhH032501; Tue, 19 Jul 2016 09:11:43 -0400 From: Eric Auger To: eric.auger@redhat.com, eric.auger.pro@gmail.com, marc.zyngier@arm.com, christoffer.dall@linaro.org, andre.przywara@arm.com, robin.murphy@arm.com, alex.williamson@redhat.com, will.deacon@arm.com, joro@8bytes.org, tglx@linutronix.de, jason@lakedaemon.net, linux-arm-kernel@lists.infradead.org Cc: drjones@redhat.com, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, pbonzini@redhat.com, linux-kernel@vger.kernel.org, Bharat.Bhushan@freescale.com, pranav.sawargaonkar@gmail.com, p.fedin@samsung.com, iommu@lists.linux-foundation.org, Jean-Philippe.Brucker@arm.com, yehuday@marvell.com, Manish.Jaggi@caviumnetworks.com, robert.richter@caviumnetworks.com Subject: [PATCH v11 1/8] vfio: introduce a vfio_dma type field Date: Tue, 19 Jul 2016 13:11:27 +0000 Message-Id: <1468933894-23250-2-git-send-email-eric.auger@redhat.com> In-Reply-To: <1468933894-23250-1-git-send-email-eric.auger@redhat.com> References: <1468933894-23250-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 19 Jul 2016 13:11:49 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We introduce a vfio_dma type since we will need to discriminate different types of dma slots: - VFIO_IOVA_USER: IOVA region used to map user vaddr - VFIO_IOVA_RESERVED_MSI: IOVA region reserved to map MSI doorbells Signed-off-by: Eric Auger --- v9 -> v10: - renamed VFIO_IOVA_RESERVED into VFIO_IOVA_RESERVED_MSI - explicitly set type to VFIO_IOVA_USER on dma_map v6 -> v7: - add VFIO_IOVA_ANY - do not introduce yet any VFIO_IOVA_RESERVED handling --- drivers/vfio/vfio_iommu_type1.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 2ba1942..a9f8b93 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -53,6 +53,12 @@ module_param_named(disable_hugepages, MODULE_PARM_DESC(disable_hugepages, "Disable VFIO IOMMU support for IOMMU hugepages."); +enum vfio_iova_type { + VFIO_IOVA_USER = 0, /* standard IOVA used to map user vaddr */ + VFIO_IOVA_RESERVED_MSI, /* reserved to map MSI doorbells */ + VFIO_IOVA_ANY, /* matches any IOVA type */ +}; + struct vfio_iommu { struct list_head domain_list; struct mutex lock; @@ -75,6 +81,7 @@ struct vfio_dma { unsigned long vaddr; /* Process virtual addr */ size_t size; /* Map size (bytes) */ int prot; /* IOMMU_READ/WRITE */ + enum vfio_iova_type type; /* type of IOVA */ }; struct vfio_group { @@ -607,6 +614,7 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu, dma->iova = iova; dma->vaddr = vaddr; dma->prot = prot; + dma->type = VFIO_IOVA_USER; /* Insert zero-sized and grow as we map chunks of it */ vfio_link_dma(iommu, dma);