From patchwork Fri Sep 14 14:30:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 146703 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp780164ljw; Fri, 14 Sep 2018 07:30:37 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZulDxpYWyUqfdraRQxIZt+QUu7CdI1C7ezd2MadQI/mkuydkjgvTeh467VT0h0fajnCSlJ X-Received: by 2002:a17:902:3a2:: with SMTP id d31-v6mr12513234pld.287.1536935437765; Fri, 14 Sep 2018 07:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536935437; cv=none; d=google.com; s=arc-20160816; b=Vj8yBld+RmnqXthnSoZwLdvBEmC+dRveCxRjSMfPwxzB/PYBOYz2uM4zzLEbPlBuTa BMnpmNXFtnoAjPNVMs/gxYmItygL4fUW7PzRhWymQW2j95Gjk84xxL+aEcmSqhBQ7JVq 0NKJAV4mHUeBAxBd2AVuR+UbLmVGzPO4/Dni+RPNDnFV+R0Y0KzxR9UxN62W1HmWhKqh mCFad3VufZXzdR6w2Cq1SUKxkI9Yag5UONIncw9kcClyo+5E1waCak7m0VO4Vs53MlMT V9TUGoel7iLZFxlKID7ksiC71hTtdXrTmCC7txVzz96QZMPCnGjT+macoguRNfteS6v2 fuBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=TxGcoem7bN74tOOynqUeMCYbvFifD3l7WEsIfvxmpXs=; b=RphL7GZIR7HU9QK77at1r8HAP3//rSWfmLsSPKQyf3XLAFM5gv5CQZOYMLZyVwJN0U DwB66Iu8Na86hmj3aKSGKqyBRiwQrlmtrpQfT+Z05fR2wOUMuOp+NBLue3OJCNoPstXc G9TS8JOUjHPA5dZDmaVZYamAePikLAiCUxQBbren1UlUyhZaGdqLq2139cw+tK+Gyhiy PRY8aSQ5TUI//yNC0geNkI9Yc7MIJ25OOYb+qVX3efDZW1MKEGgRJ/vPay8nSrVNW8OA Y7gzeqmLTp4dDziyqCSIXF92OCMzbLAeBu32scoGSXEB8wtrkIWDXvGUtV2UwCxDFUu2 f0IQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2-v6si7448863pfi.351.2018.09.14.07.30.37; Fri, 14 Sep 2018 07:30:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728284AbeINTpV (ORCPT + 32 others); Fri, 14 Sep 2018 15:45:21 -0400 Received: from foss.arm.com ([217.140.101.70]:34202 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726902AbeINTpV (ORCPT ); Fri, 14 Sep 2018 15:45:21 -0400 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 03FF5ED1; Fri, 14 Sep 2018 07:30:35 -0700 (PDT) Received: from e110467-lin.cambridge.arm.com (e110467-lin.emea.arm.com [10.4.12.131]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 39A5F3F575; Fri, 14 Sep 2018 07:30:33 -0700 (PDT) From: Robin Murphy To: joro@8bytes.org, will.deacon@arm.com, thunder.leizhen@huawei.com, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: linuxarm@huawei.com, guohanjun@huawei.com, huawei.libin@huawei.com, john.garry@huawei.com Subject: [PATCH v7 1/6] iommu/arm-smmu-v3: Implement flush_iotlb_all hook Date: Fri, 14 Sep 2018 15:30:19 +0100 Message-Id: X-Mailer: git-send-email 2.19.0.dirty In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhen Lei .flush_iotlb_all is currently stubbed to arm_smmu_iotlb_sync() since the only time it would ever need to actually do anything is for callers doing their own explicit batching, e.g.: iommu_unmap_fast(domain, ...); iommu_unmap_fast(domain, ...); iommu_iotlb_flush_all(domain, ...); where since io-pgtable still issues the TLBI commands implicitly in the unmap instead of implementing .iotlb_range_add, the "flush" only needs to ensure completion of those already-in-flight invalidations. However, we're about to start using it in anger with flush queues, so let's get a proper implementation wired up. Signed-off-by: Zhen Lei Reviewed-by: Robin Murphy [rm: expand commit message] Signed-off-by: Robin Murphy --- drivers/iommu/arm-smmu-v3.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 2.19.0.dirty diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index e395f1ff3f81..f10c852479fc 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iommu/arm-smmu-v3.c @@ -1781,6 +1781,14 @@ arm_smmu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size) return ops->unmap(ops, iova, size); } +static void arm_smmu_flush_iotlb_all(struct iommu_domain *domain) +{ + struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); + + if (smmu_domain->smmu) + arm_smmu_tlb_inv_context(smmu_domain); +} + static void arm_smmu_iotlb_sync(struct iommu_domain *domain) { struct arm_smmu_device *smmu = to_smmu_domain(domain)->smmu; @@ -2008,7 +2016,7 @@ static struct iommu_ops arm_smmu_ops = { .attach_dev = arm_smmu_attach_dev, .map = arm_smmu_map, .unmap = arm_smmu_unmap, - .flush_iotlb_all = arm_smmu_iotlb_sync, + .flush_iotlb_all = arm_smmu_flush_iotlb_all, .iotlb_sync = arm_smmu_iotlb_sync, .iova_to_phys = arm_smmu_iova_to_phys, .add_device = arm_smmu_add_device,