From patchwork Mon Feb 12 18:33:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 10214497 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 9F0B460467 for ; Mon, 12 Feb 2018 21:28:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B74428753 for ; Mon, 12 Feb 2018 21:28:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FCAD28D56; Mon, 12 Feb 2018 21:28:34 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CF37B28753 for ; Mon, 12 Feb 2018 21:28:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7l/6axxUtor9R2h2V+EdkXzLSxpgflUxnTpU6BRl7JI=; b=S/ox88+enLR4RW/7OfNgZV0A7z uma/O9XFD17AoLC/Yd8eSUkqafq89LcTzrUfZ9XJJo1t15yz5TyKUG9nOJHDeuXuIxw0pE6ME9EoI OLQTdDLJMlLQOaqH8e55WKmYmOUCZlcgFETezBmG7OG+GzMY2I338Zzu1/P8MdCiyEDfBID3rl9iZ fl4djOoC9yU3zZfmPUcz2RYsfUAg7VhHorm/Uz1nOsNshbvKqdK6a+mr+Y0VVzP2fd2ndf9cRsYA7 nc2kKGNufYKcLLvrQuk7Hboz+AllKbTdx4O8cd0rmQJR/GmO1dsRayPanmVN+nXxymEyCSpjCUSfg joKtCIQQ==; Received: from [198.137.202.133] (helo=bombadil.infradead.org) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1elLeI-0001YQ-Gq; Mon, 12 Feb 2018 21:28:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7l/6axxUtor9R2h2V+EdkXzLSxpgflUxnTpU6BRl7JI=; b=U/nA8FXwLTOdfldDNKj4jDRuZ6 DDhTn4PsicgHIE74KUOqouSascZuZSLJwRtbjOSRKJof17YrfOjuPCxS/Dypdzi7IMYb7b6+QNHXV xM7PSX1gpDRZE0T+aRy6mTBEvLfct9g4iMg9TFJI0xDGy1nbJk0ieQAiKEHUsWC8j0fGqc7fZ9Qc2 KLS0QprVZKffjLJkdM9ihVyXHqfddwBo4xfB8aD+/YYWYntL6qkSvF6HLIRPbce3BrOeMQOSp8ZLJ QtCGu05pOZgx5G2m+5U0m9HX2sgZb2neRuGXq4MWebxFU9k3+aG5rOI2RemlURd1LIarrrptlvrmk 3IadohFA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1elJ3T-0006aj-AM; Mon, 12 Feb 2018 18:42:19 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1elIvX-000613-Cn for linux-arm-kernel@lists.infradead.org; Mon, 12 Feb 2018 18:34:09 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 59651165C; Mon, 12 Feb 2018 10:34:07 -0800 (PST) Received: from e106794-lin.cambridge.arm.com (e106794-lin.cambridge.arm.com [10.1.210.24]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7C6A23F24D; Mon, 12 Feb 2018 10:34:01 -0800 (PST) From: Jean-Philippe Brucker To: linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, devicetree@vger.kernel.org, iommu@lists.linux-foundation.org, kvm@vger.kernel.org Subject: [PATCH 32/37] iommu/arm-smmu-v3: Hook up ATC invalidation to mm ops Date: Mon, 12 Feb 2018 18:33:47 +0000 Message-Id: <20180212183352.22730-33-jean-philippe.brucker@arm.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180212183352.22730-1-jean-philippe.brucker@arm.com> References: <20180212183352.22730-1-jean-philippe.brucker@arm.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, xieyisheng1@huawei.com, ilias.apalodimas@linaro.org, catalin.marinas@arm.com, xuzaibo@huawei.com, jonathan.cameron@huawei.com, will.deacon@arm.com, okaya@codeaurora.org, yi.l.liu@intel.com, lorenzo.pieralisi@arm.com, ashok.raj@intel.com, tn@semihalf.com, joro@8bytes.org, bharatku@xilinx.com, rfranz@cavium.com, lenb@kernel.org, jacob.jun.pan@linux.intel.com, alex.williamson@redhat.com, robh+dt@kernel.org, thunder.leizhen@huawei.com, bhelgaas@google.com, shunyong.yang@hxt-semitech.com, dwmw2@infradead.org, liubo95@huawei.com, rjw@rjwysocki.net, jcrouse@codeaurora.org, robdclark@gmail.com, hanjun.guo@linaro.org, sudeep.holla@arm.com, robin.murphy@arm.com, christian.koenig@amd.com, nwatters@codeaurora.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The core calls us when an mm is modified. Perform the required ATC invalidations. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index 76513135310f..8d09615fab35 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -1805,6 +1805,15 @@ static int arm_smmu_atc_inv_master_all(struct arm_smmu_master_data *master, return arm_smmu_atc_inv_master(master, &cmd); } +static int arm_smmu_atc_inv_master_range(struct arm_smmu_master_data *master, + int ssid, unsigned long iova, size_t size) +{ + struct arm_smmu_cmdq_ent cmd; + + arm_smmu_atc_inv_to_cmd(ssid, iova, size, &cmd); + return arm_smmu_atc_inv_master(master, &cmd); +} + static size_t arm_smmu_atc_inv_domain(struct arm_smmu_domain *smmu_domain, int ssid, unsigned long iova, size_t size) @@ -2450,11 +2459,12 @@ static void arm_smmu_mm_detach(struct iommu_domain *domain, struct device *dev, struct arm_smmu_mm *smmu_mm = to_smmu_mm(io_mm); struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); struct iommu_pasid_table_ops *ops = smmu_domain->s1_cfg.ops; + struct arm_smmu_master_data *master = dev->iommu_fwspec->iommu_priv; if (detach_domain) ops->clear_entry(ops, io_mm->pasid, smmu_mm->cd); - /* TODO: Invalidate ATC. */ + arm_smmu_atc_inv_master_all(master, io_mm->pasid); /* TODO: Invalidate all mappings if last and not DVM. */ } @@ -2462,8 +2472,10 @@ static void arm_smmu_mm_invalidate(struct iommu_domain *domain, struct device *dev, struct io_mm *io_mm, unsigned long iova, size_t size) { + struct arm_smmu_master_data *master = dev->iommu_fwspec->iommu_priv; + + arm_smmu_atc_inv_master_range(master, io_mm->pasid, iova, size); /* - * TODO: Invalidate ATC. * TODO: Invalidate mapping if not DVM */ }