From patchwork Wed May 4 11:54:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 9012801 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2AEFC9F39D for ; Wed, 4 May 2016 11:56:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3E05A203A4 for ; Wed, 4 May 2016 11:56:54 +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 5FAAA2039C for ; Wed, 4 May 2016 11:56:53 +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 1axvOk-0004iP-3w; Wed, 04 May 2016 11:55:22 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1axvON-0003Lu-PI for linux-arm-kernel@lists.infradead.org; Wed, 04 May 2016 11:55:00 +0000 Received: by mail-wm0-x231.google.com with SMTP id a17so89581255wme.0 for ; Wed, 04 May 2016 04:54:39 -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=eGCik/jRjSDsUW2XXnewtMkuzGYR0cL52Uq61u15/Z0AW3FeIr+RvJwK8OXRB6p4mG Rxv4tJF3LF5Ly5ftOCJjO4wk4z2XALh8A+gU0vcQUhe6MikCCwfpixSSgitfsTyr2PHZ yInv9RqZ81tdfFr4Hqm8VCSkmYP/wIAQ0oqxc= 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=GvmE7cJ8up6kCeBlZoLuRiREuRx1UPa39ThvQX9uSLRbGinb97xiOguK075BHG9w1H B5PwrfFRjR30yR5mYxfDnAOAnClgZr4mEu2GQ4N8k01yeljx3hFKqmXSFCY/1IZuqJXo Ubj6fPa1W5ehVuz7mHsvWwMvWVH3+XPh9nJuv2GWo7JkJ92JX8/vAzNSyntzLVpsdIiS 3HFOiGOtqLDYzqX2vVHt3mzmqPnflQ5Lj2T9sOolPkRnpnKuwvTbeaZZFCjuc4CYQp0s No6ex/JP0C7tjf8xJXRJjLHf0DyCBBl7WsQgzfHc5XZIn3W02ZsfCpQJnkKKxTKf+GlK /8Bw== X-Gm-Message-State: AOPr4FX/XLMUfWsaNQPEjgsJtPTI0OAAgDGzQb+RCRlstNXrCqMHr+vl654YWMmDIgHtPd3i X-Received: by 10.28.175.143 with SMTP id y137mr16057740wme.21.1462362878476; Wed, 04 May 2016 04:54:38 -0700 (PDT) Received: from new-host-61.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id ck9sm3816623wjc.22.2016.05.04.04.54.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 May 2016 04:54:36 -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 v9 3/7] vfio/type1: bypass unmap/unpin and replay for VFIO_IOVA_RESERVED slots Date: Wed, 4 May 2016 11:54:14 +0000 Message-Id: <1462362858-2925-4-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1462362858-2925-1-git-send-email-eric.auger@linaro.org> References: <1462362858-2925-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160504_045500_032628_EA817F31 X-CRM114-Status: GOOD ( 13.00 ) 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, yehuday@marvell.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=-6.2 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;