From patchwork Thu Sep 20 16:10:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 147103 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp2188194ljw; Thu, 20 Sep 2018 09:10:42 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaDgcr/ZEty6HpJUOZSTI3Z9BiP/WrBQXAvrAJUwR+igKh7eyv6f1nzRMUl23Phf8rxxRiA X-Received: by 2002:a17:902:7c0a:: with SMTP id x10-v6mr40144891pll.77.1537459842405; Thu, 20 Sep 2018 09:10:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537459842; cv=none; d=google.com; s=arc-20160816; b=DpbbUFslWZjWVl1WETTqJTbppCGnhUDUY5WX+GPsld/dRyZI9dejDBLQg6kGPk+IkR MaBJkSzh6Eq2D5cQmLEBVVLS45L6rMU/cSPlaW4Q7xC6oJLgR1E+1qqZbS8xC2ejEiSf pXf/L1DNw6zKSoKOQw13PXqvGwlWqhEhDVWq5L5srp1zNaHoOXDVPiPDLkQN3lfSE5VH oI5PazAYKsXQ+pAIRZA9rNhxY3gweywKuF+g3flfdJPhHIOeZ2xe1d8aT05Pkk1B+ECJ qRtbN6RrCMZdp5NUNEGbYGJTQsY9l9hb/to8FGfD7G/80sqecrR5mhOYB9Xjfz1ltYB9 R13g== 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=xyPzoIMk+mzXiYzopvY5wr2CW+ewtNQPMXSIbJR6ZKA=; b=TrEqvicmyBN1AnBR8YSLertvcwm+gqslcrbjBTh3+13kUGxuHt/7S/LrXCM+kTbEG8 ChYFuXEE9HjNmov2AluzYbxYs/vygyWZLhmNU+sGrMJhkskmxmmCMzeY6iV+tpYDLCc+ zsJNTZibE5CItDeEsx/CK1uIIjlmyqvoK6YkkKeDS9AbxV4/7X9KFv8NtcOokq3zj+yo At9MlH+2JkmBvAFn+ShGncxiaBuCBQbaMGrH27QV2hHSMFeOa2IHHWDbwcl+6BBDgLIo AfY4ZRTSA9O1vg/F0Z2THCnQMRNJcCjS2zNaB/da2JVZMgC0N8qPxa4pGS3zOw/6RdEK iHBA== 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 x14-v6si1401922pfi.138.2018.09.20.09.10.42; Thu, 20 Sep 2018 09:10:42 -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 S1730905AbeITVyr (ORCPT + 32 others); Thu, 20 Sep 2018 17:54:47 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:48558 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726128AbeITVyr (ORCPT ); Thu, 20 Sep 2018 17:54:47 -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 69C6E1596; Thu, 20 Sep 2018 09:10: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 A03533F557; Thu, 20 Sep 2018 09:10: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 v8 1/7] iommu/arm-smmu-v3: Implement flush_iotlb_all hook Date: Thu, 20 Sep 2018 17:10:21 +0100 Message-Id: <396dac165e343dec0cbe0a1f4d311839ff768f95.1537458163.git.robin.murphy@arm.com> 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: document why it wasn't a bug] 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,