From patchwork Thu May 31 07:42:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen \(ThunderTown\)" X-Patchwork-Id: 137336 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp6278344lji; Thu, 31 May 2018 00:44:16 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJbh0fN1663YLRV4ZDBcouKwVb/aLqdavOjgArmrC80r3kRx0c9acYd5KxUok27OL5UAzpe X-Received: by 2002:a62:f5da:: with SMTP id b87-v6mr2025316pfm.113.1527752655994; Thu, 31 May 2018 00:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527752655; cv=none; d=google.com; s=arc-20160816; b=KkKhDs+O2B7Fh/6gr0xqBowDaCoC6ZytrtXteDL4BFZEVfZeGIHzKbJXYzWisSg+QC KCcNrvlGfB7migJ0dIHzJpn3IyD5KvMpbXxHW4ytAd3HQxhdVEjwQIGxtqWngeTRko0R 35krwivIKVrBsUlzh5Y2KVJa4BVq6I0ByJ7M8KxzOF6c4d3FYyrsSxRF+hcLowFHNb8y I/bnZpCh3sHg9JUNvdjrV3ie7It5GfNWyZehBvrYfnNh9GUqCtdyI9CZJC0mBfHxdTP0 nvPWOoctdazgR6PuC713ARkhakWqDGZBp3hIgxxQPh6JpcDMi1oOpWUlem4pC2o390Nb 4YBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=Tm0ss8UIDBPWxeADwEuvJz1008Q0BI4rUIiYniD1Ylg=; b=xj/316aEiYFSP+jATfhjjmcM7fj+NlDM+ePvNNCe5p1QEtD9m1rS/KAEuV/Od1bkIA gYyMyZ1A2qiVOh2FXBGLSVYDSGx0XPS7k3Ftdle4sMyyDhjYk05kmv18lS0EHhdgw+Q1 1J4jyeu2kCn5PC+tvvGqZDTZtXJlAL6Sgn/rTZ6U5TVFUTjbtLnwOnVLa1SHDeDu3U3z 1+QgHK/Jr4FM8Al9+kKXa0SUjOYFlkjz/fzqVfkq44+Q/YwjPXEbZyKGxVC4uJcErvRP FMs+JOdHFv4mkAr7gdJUGn0sUeA9G5gVhjWcUK5WjlOEresDPOdNtPMcLqkaCV57NUW0 Xy5Q== 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 8-v6si37259303plc.444.2018.05.31.00.44.15; Thu, 31 May 2018 00:44:15 -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 S1754154AbeEaHoO (ORCPT + 30 others); Thu, 31 May 2018 03:44:14 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8213 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754126AbeEaHn7 (ORCPT ); Thu, 31 May 2018 03:43:59 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E533B396C8E89; Thu, 31 May 2018 15:43:44 +0800 (CST) Received: from localhost (10.177.23.164) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.382.0; Thu, 31 May 2018 15:43:36 +0800 From: Zhen Lei To: Robin Murphy , Will Deacon , Matthias Brugger , Rob Clark , Joerg Roedel , linux-mediatek , linux-arm-msm , linux-arm-kernel , iommu , linux-kernel CC: Zhen Lei , Hanjun Guo , Libin , Guozhu Li , "Xinwei Hu" Subject: [PATCH 6/7] iommu/io-pgtable-arm: add support for non-strict mode Date: Thu, 31 May 2018 15:42:48 +0800 Message-ID: <1527752569-18020-7-git-send-email-thunder.leizhen@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.0 In-Reply-To: <1527752569-18020-1-git-send-email-thunder.leizhen@huawei.com> References: <1527752569-18020-1-git-send-email-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To support the non-strict mode, now we only tlbi and sync for the strict mode. But for the non-leaf case, always follow strict mode. Signed-off-by: Zhen Lei --- drivers/iommu/io-pgtable-arm.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) -- 1.8.3 diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index e0f52db..1a65b7b 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -287,7 +287,7 @@ static void __arm_lpae_set_pte(arm_lpae_iopte *ptep, arm_lpae_iopte pte, static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data, unsigned long iova, size_t size, int lvl, - arm_lpae_iopte *ptep); + arm_lpae_iopte *ptep, int strict); static void __arm_lpae_init_pte(struct arm_lpae_io_pgtable *data, phys_addr_t paddr, arm_lpae_iopte prot, @@ -329,7 +329,7 @@ static int arm_lpae_init_pte(struct arm_lpae_io_pgtable *data, size_t sz = ARM_LPAE_BLOCK_SIZE(lvl, data); tblp = ptep - ARM_LPAE_LVL_IDX(iova, lvl, data); - if (WARN_ON(__arm_lpae_unmap(data, iova, sz, lvl, tblp) != sz)) + if (WARN_ON(__arm_lpae_unmap(data, iova, sz, lvl, tblp, IOMMU_STRICT) != sz)) return -EINVAL; } @@ -526,7 +526,7 @@ static void arm_lpae_free_pgtable(struct io_pgtable *iop) static size_t arm_lpae_split_blk_unmap(struct arm_lpae_io_pgtable *data, unsigned long iova, size_t size, arm_lpae_iopte blk_pte, int lvl, - arm_lpae_iopte *ptep) + arm_lpae_iopte *ptep, int strict) { struct io_pgtable_cfg *cfg = &data->iop.cfg; arm_lpae_iopte pte, *tablep; @@ -571,15 +571,17 @@ static size_t arm_lpae_split_blk_unmap(struct arm_lpae_io_pgtable *data, } if (unmap_idx < 0) - return __arm_lpae_unmap(data, iova, size, lvl, tablep); + return __arm_lpae_unmap(data, iova, size, lvl, tablep, strict); + + if (strict) + io_pgtable_tlb_add_flush(&data->iop, iova, size, size, true); - io_pgtable_tlb_add_flush(&data->iop, iova, size, size, true); return size; } static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data, unsigned long iova, size_t size, int lvl, - arm_lpae_iopte *ptep) + arm_lpae_iopte *ptep, int strict) { arm_lpae_iopte pte; struct io_pgtable *iop = &data->iop; @@ -604,7 +606,7 @@ static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data, io_pgtable_tlb_sync(iop); ptep = iopte_deref(pte, data); __arm_lpae_free_pgtable(data, lvl + 1, ptep); - } else { + } else if (strict) { io_pgtable_tlb_add_flush(iop, iova, size, size, true); } @@ -615,12 +617,12 @@ static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data, * minus the part we want to unmap */ return arm_lpae_split_blk_unmap(data, iova, size, pte, - lvl + 1, ptep); + lvl + 1, ptep, strict); } /* Keep on walkin' */ ptep = iopte_deref(pte, data); - return __arm_lpae_unmap(data, iova, size, lvl + 1, ptep); + return __arm_lpae_unmap(data, iova, size, lvl + 1, ptep, strict); } static size_t arm_lpae_unmap(struct io_pgtable_ops *ops, unsigned long iova, @@ -633,7 +635,7 @@ static size_t arm_lpae_unmap(struct io_pgtable_ops *ops, unsigned long iova, if (WARN_ON(iova >= (1ULL << data->iop.cfg.ias))) return 0; - return __arm_lpae_unmap(data, iova, size, lvl, ptep); + return __arm_lpae_unmap(data, iova, size, lvl, ptep, strict); } static phys_addr_t arm_lpae_iova_to_phys(struct io_pgtable_ops *ops,