Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4348427pxu; Wed, 9 Dec 2020 15:01:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxV2UnZyWaNUX83o5Asgtd4aJUouRt5THhSzLZwOVXRelJGancIUtQsP+xlJXj7yjx55A28 X-Received: by 2002:a17:906:a011:: with SMTP id p17mr3943336ejy.30.1607554901057; Wed, 09 Dec 2020 15:01:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607554901; cv=none; d=google.com; s=arc-20160816; b=rrbE4DSvUo6X5i1ZDHEzwWXCxhq0tCLLAsuVmBr2mB+FtD4gCnpJZwE0oy38x5qUZI c4Uldl/ekCOUwObQjhngzUXP0ylKqaHuptvOcjg38Gs9YiNRz/G+S5BbM4FYPArj4Ro3 8K9REYvidscGv4wWPfdCN9BlCQMJyQH+TAneL0G1AmD/v2uNox2ePGs5Bnfp3FunnLBb 7HaBB6FXosBiZW9qsk7bZbnB4pMwA9vjsSqdrNZLSDNDw6BI3rMuyEEG77fHx2tCAIUr E8AAwChDwOPCjcHtM211yNL8s6QSE1rk4FHTA3sg2gg7ZRQTGjq/eg7062tgYKBoqktj bNbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=myxMxbKzfN1leMNkTkKhnQ9+mQ8RmWP2f+BaDe02zCo=; b=kPFDbVNcOB9EkfiVMInemq8eTWJp3g9sgaHO0OQ1Ya3ffwfkWssXYjOBz/wHl35xhN Hj4arnPe42bJLM2w+AqyR6NTOGHjYsKhQcGgcxRzrqWsY0ETcwwcdlkIbpoErydXd7ez 0oXjZ3SULqrrUg7/CHGnqYueX6XcSd9Xy6ZIi0jivGvbaRUlxilaFe6cKkWIY4+pGaZI lbi9ud9tjE7uzyYydZ7px3Hj43kvYMcWj/pE0Ea+dq05i/VQAx/HCERMxu/bSaLp+zn6 gwsmGRY+fOvspDFg3GBF6UfEssauen1mQFH13SuWSiHdYRkSM1Qx26ek9Ds9OM7FFo+/ 6hgQ== 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=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h8si1519142ejf.491.2020.12.09.15.01.18; Wed, 09 Dec 2020 15:01:41 -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=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728599AbgLIIEJ (ORCPT + 99 others); Wed, 9 Dec 2020 03:04:09 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:50360 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728619AbgLIIEI (ORCPT ); Wed, 9 Dec 2020 03:04:08 -0500 X-UUID: 63a27a26ea324f8aa7f21aef5bd6e102-20201209 X-UUID: 63a27a26ea324f8aa7f21aef5bd6e102-20201209 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 863069981; Wed, 09 Dec 2020 16:03:39 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 9 Dec 2020 16:03:17 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 9 Dec 2020 16:03:16 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Rob Herring , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , Subject: [PATCH v5 12/27] iommu/io-pgtable-arm-v7s: Quad lvl1 pgtable for MediaTek Date: Wed, 9 Dec 2020 16:00:47 +0800 Message-ID: <20201209080102.26626-13-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201209080102.26626-1-yong.wu@mediatek.com> References: <20201209080102.26626-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Yong Wu Reviewed-by: Robin Murphy --- drivers/iommu/io-pgtable-arm-v7s.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 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)) -- 2.18.0