From patchwork Thu Sep 13 16:42:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 146631 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp812410ljw; Thu, 13 Sep 2018 09:42:39 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZWUo7EGrQteDiIZoE69VcwRVAjSA32P5wp7zhQIykISGZZgg5Eh2jK1G0AMU43Z0Zv3z8j X-Received: by 2002:a17:902:b70f:: with SMTP id d15-v6mr8262486pls.53.1536856959667; Thu, 13 Sep 2018 09:42:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536856959; cv=none; d=google.com; s=arc-20160816; b=vTb8+6AXgFQa95bLWQrxjPHOBGGAGmlJUyi73MnDCk2nZdON/gjGcw+FJ0rfRDbyGS MSp7wPkHbEmlodRs+fuvkMHAZqRqVupqKUoh6SloVEcpiQ2hsm+ONZbjs4AfWT2aSUN2 iOQWCoSd5mLoNyxI1Pxz2YDl8z9Ljt/VqUSgTuNgnP163Fg/I9SLg1eG2ifVUQ4hKzqq 2AnIy6cbQsZgTNsXw9t/0Sn10aGfI4jJts2FKnJ5HDj5ReoYHEpNMy8OPUy4BL9pNY5e YKhSInDf4VNrRpTMB6zRk1oqmo2CHWtbFM+Eadbyi87zzMhrXcIWIemBxDRFIjn/NSPw ogaQ== 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=nf4DzqEKP4DmJ/Sfz7ssPduhkKF3YaEqKZOE7QhE2QpJGvAQwWYDxJ/v0foG9ioi0Z wq+u5zXWS8NWLUCoySToBXwhOYcD4snBKGsuRNGksYUXtWnWrE201cM6NHcN+VOXv3FB uw6fUT/ayIgNluPqKkL91bQIxvdP5PM6Oe0RLYcfLXfIxWZYSHnRmysDkIsdvNwhOEC1 RmpQE2tW31ZYyIb5LZnVrizOefYOWA/Rf9qbQAzNIB6BkYYYwcayYfIcsqQShX6YuaWR YWKCInShLQ9XTM7s5jzVorGQLj9jdZEi+K0g3M62PACOxk05QlZxgvdKDfijfVTKvjop I5zQ== 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 14-v6si4726138plb.230.2018.09.13.09.42.39; Thu, 13 Sep 2018 09:42:39 -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 S1728138AbeIMVwx (ORCPT + 32 others); Thu, 13 Sep 2018 17:52:53 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:51100 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbeIMVwx (ORCPT ); Thu, 13 Sep 2018 17:52:53 -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 CCD511596; Thu, 13 Sep 2018 09:42:36 -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 0E2483F703; Thu, 13 Sep 2018 09:42:34 -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 v6 1/7] iommu/arm-smmu-v3: Implement flush_iotlb_all hook Date: Thu, 13 Sep 2018 17:42:18 +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,