From patchwork Thu Apr 28 08:28:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 8966551 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0B486BF29F for ; Thu, 28 Apr 2016 08:31:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E7BCB200D6 for ; Thu, 28 Apr 2016 08:31:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 171692027D for ; Thu, 28 Apr 2016 08:31:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1avhKX-0007g4-LA; Thu, 28 Apr 2016 08:29:49 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1avhKB-0007Rr-Gg for linux-arm-kernel@lists.infradead.org; Thu, 28 Apr 2016 08:29:28 +0000 Received: by mail-wm0-x230.google.com with SMTP id e201so67269938wme.0 for ; Thu, 28 Apr 2016 01:29:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4zWw3QwHuG+y7qVbiTQkH/Fx76jdUZaunVlfhJvpT0o=; b=EIEh9nB6I6YVNaN79B7its9mlKpoND1Zl43AndJ+49pk5PzXXqgW+8rRV/A3NQszpR qnmkkvX0kHLSBPlrAhJsuNgxYuvb96TK1SQCnnaKuTAm+zv+hz5Jb/KChtNH3xojdzFu pvCzcF26clI/oTmRfzZVypDU+0EWPLBJE4dI4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4zWw3QwHuG+y7qVbiTQkH/Fx76jdUZaunVlfhJvpT0o=; b=DgDJsomvF5ms9wj16+xdKCaPA5j0Od/8/b2rUvDPClD5nkjCaA7OYdGEDeMjmbdEe6 C+fK3Vpsvo5EXFSFptmHREL31hHNxjr9MOQxbhZyFGi8oTkZwoy9jx1w7vyiYJzeg5e/ 2HJ6GwO2OkOdz/l/bs7ZUjL3fktQta1mPkD6ms1HQNuAIRC/b0nusii0AP3EiVhNuShC wSvxjDYuFTbn0aVwfsXUa4AtXC/GRqZXW2frfzkxcRY1M4XwyXzaf/2WL0LVwH9pVW5J FwFc1DmeD0EY5SQ6bta0pqLLuX4GaTlnWWLrxF1Zn6G/2PFq55bVyBA71dDl6yqKCoFa GbcQ== X-Gm-Message-State: AOPr4FV+C5p4IeqmaKA07F8Qzkei1A4mV8B8qQk6JdoN4y8fIM0koixXOlYLNI+v/VYH6PvD X-Received: by 10.195.20.66 with SMTP id ha2mr13578115wjd.76.1461832146265; Thu, 28 Apr 2016 01:29:06 -0700 (PDT) Received: from new-host-46.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id j6sm8349121wjb.29.2016.04.28.01.29.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Apr 2016 01:29:04 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, robin.murphy@arm.com, alex.williamson@redhat.com, will.deacon@arm.com, joro@8bytes.org, tglx@linutronix.de, jason@lakedaemon.net, marc.zyngier@arm.com, christoffer.dall@linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v8 3/7] vfio/type1: bypass unmap/unpin and replay for VFIO_IOVA_RESERVED slots Date: Thu, 28 Apr 2016 08:28:34 +0000 Message-Id: <1461832118-5668-4-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461832118-5668-1-git-send-email-eric.auger@linaro.org> References: <1461832118-5668-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160428_012927_705424_423FB97C X-CRM114-Status: GOOD ( 12.81 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: julien.grall@arm.com, patches@linaro.org, Jean-Philippe.Brucker@arm.com, p.fedin@samsung.com, linux-kernel@vger.kernel.org, Bharat.Bhushan@freescale.com, iommu@lists.linux-foundation.org, pranav.sawargaonkar@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Before allowing the end-user to create VFIO_IOVA_RESERVED dma slots, let's implement the expected behavior for removal and replay. As opposed to user dma slots, IOVAs are not systematically bound to PAs and PAs are not pinned. VFIO just initializes the IOVA "aperture". IOVAs are allocated outside of the VFIO framework, typically the MSI layer which is responsible to free and unmap them. The MSI mapping resources are freeed by the IOMMU driver on domain destruction. Signed-off-by: Eric Auger --- v7 -> v8: - do no destroy anything anymore, just bypass unmap/unpin and iommu_map on replay --- drivers/vfio/vfio_iommu_type1.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 2d769d4..94a9916 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -391,7 +391,7 @@ static void vfio_unmap_unpin(struct vfio_iommu *iommu, struct vfio_dma *dma) struct vfio_domain *domain, *d; long unlocked = 0; - if (!dma->size) + if (!dma->size || dma->type != VFIO_IOVA_USER) return; /* * We use the IOMMU to track the physical addresses, otherwise we'd @@ -727,6 +727,9 @@ static int vfio_iommu_replay(struct vfio_iommu *iommu, dma = rb_entry(n, struct vfio_dma, node); iova = dma->iova; + if (dma->type == VFIO_IOVA_RESERVED) + continue; + while (iova < dma->iova + dma->size) { phys_addr_t phys = iommu_iova_to_phys(d->domain, iova); size_t size;