Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1153126pxu; Fri, 27 Nov 2020 00:35:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJx40KVpPTS3WtsoREp2B/rwtUKlxvo16f9bFZlHSbnHGPwtosopvrcRHjCaYPY4RVM7X9bB X-Received: by 2002:a17:906:3958:: with SMTP id g24mr6401348eje.360.1606466158420; Fri, 27 Nov 2020 00:35:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606466158; cv=none; d=google.com; s=arc-20160816; b=GRYJ13Jh1CykbupH3Cz4gzojxci2AVTZ4RnNr+IsMqcGLtSSibiRnaehg7pHzVcZuu Xh0fRUhewSjCfrX1kjZcsz8CIO8WMKBA64YKydYFEE9soJ1qlXBYuJLLdwR91ZpPXRZ1 /UbPS0411qvkHN/xSe6rX00zXWtCPDKh4DdTKzqvkCNE5X0J8gAeAPr/6iTI9+UD7sel 4L2BTA7ITl6WoZWbRB3C9lGjqehDPeTiVwvPLCRQGcI5n8fjEazdHv5pkwClzTOXfWYJ gBRjIgGG5E37YxsNqhGM7LZYBXT7OdxIzKwo1ZC1nM3DPZumYMxPnQ4FctFSVo06CjKk Ez/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=oKuNEx3oLWljTkDhf7uRAOtuHS1Z+wsagrmuvwjy5kQ=; b=W8otUbQofxZXeBR5j43/wo2bxRM92vfWfMeaBnvUJfq7nrkNqytket+y9jh41i2qdA s0ScvqA0iaNRIIpYTbHX44C7WTx2OmKt8pxpdFduTKZ+5AdlMAwjeX7bBoBqizXg8GkC x5jxx5wudhCvtMUKMaoEsDnck9ay1Ihz8tQin/E475bHLxpOjgTxUhkTrXYB0kzkWFq0 OvItXBOtGyJEHKQvQgtQ9FxWEfaZt8k+e4oX4Z+OgrZIk4mHDKv71oETUNNMWKASdQFn ETxUzrQSrpgnojJQ8OGDqJwb0j3R8bawQExTwZFu+m/FEkIHHLpVtfepEc/++auuePXC XJ2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m22si4845049edq.478.2020.11.27.00.35.35; Fri, 27 Nov 2020 00:35:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391382AbgKZQQF (ORCPT + 99 others); Thu, 26 Nov 2020 11:16:05 -0500 Received: from foss.arm.com ([217.140.110.172]:38634 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730181AbgKZQQE (ORCPT ); Thu, 26 Nov 2020 11:16:04 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EB5CE31B; Thu, 26 Nov 2020 08:16:03 -0800 (PST) Received: from [10.57.59.159] (unknown [10.57.59.159]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4F9A03F23F; Thu, 26 Nov 2020 08:15:59 -0800 (PST) Subject: Re: [PATCH v4 11/24] iommu/io-pgtable-arm-v7s: Quad lvl1 pgtable for MediaTek To: Yong Wu , Joerg Roedel , Matthias Brugger , Rob Herring , Will Deacon Cc: youlin.pei@mediatek.com, devicetree@vger.kernel.org, Nicolas Boichat , srv_heupstream@mediatek.com, chao.hao@mediatek.com, kernel-team@android.com, linux-kernel@vger.kernel.org, Evan Green , Tomasz Figa , iommu@lists.linux-foundation.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski , anan.sun@mediatek.com, Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org References: <20201111123838.15682-1-yong.wu@mediatek.com> <20201111123838.15682-12-yong.wu@mediatek.com> From: Robin Murphy Message-ID: <54eee2dd-21d5-e796-d5a1-eaf7097a9745@arm.com> Date: Thu, 26 Nov 2020 16:15:58 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20201111123838.15682-12-yong.wu@mediatek.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-11-11 12:38, Yong Wu wrote: > The standard input iova bits is 32. MediaTek quad the lvl1 pagetable > (4 * lvl1). No change for lvl2 pagetable. Then the iova bits can reach > 34bit. Yay, I love how simple the actual change becomes now! Reviewed-by: Robin Murphy > Signed-off-by: Yong Wu > --- > drivers/iommu/io-pgtable-arm-v7s.c | 7 ++++--- > drivers/iommu/mtk_iommu.c | 2 +- > 2 files changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c > index 0b3c5b904ddc..5601dc8bf810 100644 > --- a/drivers/iommu/io-pgtable-arm-v7s.c > +++ b/drivers/iommu/io-pgtable-arm-v7s.c > @@ -45,9 +45,10 @@ > /* > * We have 32 bits total; 12 bits resolved at level 1, 8 bits at level 2, > * and 12 bits in a page. > + * MediaTek extend 2 bits to reach 34bits, 14 bits at lvl1 and 8 bits at lvl2. > */ > #define ARM_V7S_ADDR_BITS 32 > -#define _ARM_V7S_LVL_BITS(lvl, cfg) ((lvl) == 1 ? 12 : 8) > +#define _ARM_V7S_LVL_BITS(lvl, cfg) ((lvl) == 1 ? ((cfg)->ias - 20) : 8) > #define ARM_V7S_LVL_SHIFT(lvl) ((lvl) == 1 ? 20 : 12) > #define ARM_V7S_TABLE_SHIFT 10 > > @@ -61,7 +62,7 @@ > #define _ARM_V7S_IDX_MASK(lvl, cfg) (ARM_V7S_PTES_PER_LVL(lvl, cfg) - 1) > #define ARM_V7S_LVL_IDX(addr, lvl, cfg) ({ \ > int _l = lvl; \ > - ((u32)(addr) >> ARM_V7S_LVL_SHIFT(_l)) & _ARM_V7S_IDX_MASK(_l, cfg); \ > + ((addr) >> ARM_V7S_LVL_SHIFT(_l)) & _ARM_V7S_IDX_MASK(_l, cfg); \ > }) > > /* > @@ -754,7 +755,7 @@ static struct io_pgtable *arm_v7s_alloc_pgtable(struct io_pgtable_cfg *cfg, > { > struct arm_v7s_io_pgtable *data; > > - if (cfg->ias > ARM_V7S_ADDR_BITS) > + if (cfg->ias > (arm_v7s_is_mtk_enabled(cfg) ? 34 : ARM_V7S_ADDR_BITS)) > return NULL; > > if (cfg->oas > (arm_v7s_is_mtk_enabled(cfg) ? 35 : ARM_V7S_ADDR_BITS)) > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c > index ec3c87d4b172..55f9b329e637 100644 > --- a/drivers/iommu/mtk_iommu.c > +++ b/drivers/iommu/mtk_iommu.c > @@ -319,7 +319,7 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom) > IO_PGTABLE_QUIRK_TLBI_ON_MAP | > IO_PGTABLE_QUIRK_ARM_MTK_EXT, > .pgsize_bitmap = mtk_iommu_ops.pgsize_bitmap, > - .ias = 32, > + .ias = 34, > .oas = 35, > .tlb = &mtk_iommu_flush_ops, > .iommu_dev = data->dev, >