Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2188135pxb; Mon, 11 Jan 2021 03:24:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDMYSaLO8CGRkD6dPK0ofnGNaRycEQY8EQWa8c0SabqG6sd23CAdVkf5R6yh6UKKk35kTo X-Received: by 2002:a17:906:408f:: with SMTP id u15mr10707540ejj.84.1610364282452; Mon, 11 Jan 2021 03:24:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610364282; cv=none; d=google.com; s=arc-20160816; b=v9j2v+Xonmchc14tm5JalsGPwH1rk93ZpP6btUrD0OY93H+Vmi+xWXObGwW5MjltvQ 0YfIKaD7V0RQd35vJPvEEjka/7nNZboc4YYgorTEW/jeTk5ATO9sPv2dAOBGaE4zYI3y 5vtzp5HPNxDsBtCowDwNYqm/qSg2d9szrkP9eC4pskRj8dwJTNqWPLmgq9VXrR5FX5Cc jM36W9WVN+VIt7+hMNMxlqZcHD7IO8iky5YAXk0yyA6NEV1oJRRwFr/I+ABONxZFueGx Cn2wIK4z2vUvDW70SdhVKiAl0kg0n4OpPayGzPrHQNNqtj/vFG4EyD+LllOOw+Syiv+H 9AvQ== 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=Vrq9dgyBRP+GZIY3KQAR36gGwzkhGOkYNDztI4KaaEc=; b=bs25JNCcGQbwtC1CsnY369R8jjz5oVXom9B0zNymbszrpQCMs1EUdKYzxEtCtzmaM2 Rd8DPKo1xNIGmQ19bGJBEFYI1IaA1gOWB1ZDHlVq+sjubBhVgVnEilXWfB0NTAp600OC Jgs9JxXCPX4tVabCSJl7vsxRzBWWML7pvJJhJhA1vCt+IsRudOxWoUIMnWJWVYSnIOBM MP/Wrv0jLQ3/rTpjvwgE+4j0V22cfqszwGVON/HSpICKaNICginaJ5cPuniCpOyFnPj6 lMl5TtXZXAxH2Sb7fzzTy4Mkn0Ad01stvATiVzcj9Cs+vvbF3QMGtQiCZqjMa8OryKBm j37w== 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 by27si6746829edb.276.2021.01.11.03.24.19; Mon, 11 Jan 2021 03:24:42 -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 S1729820AbhAKLWb (ORCPT + 99 others); Mon, 11 Jan 2021 06:22:31 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:60479 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728305AbhAKLWa (ORCPT ); Mon, 11 Jan 2021 06:22:30 -0500 X-UUID: 55357523d3ec4052bf94261ad9f57538-20210111 X-UUID: 55357523d3ec4052bf94261ad9f57538-20210111 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 168113564; Mon, 11 Jan 2021 19:21:41 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 11 Jan 2021 19:21:40 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 11 Jan 2021 19:21:39 +0800 From: Yong Wu To: Joerg Roedel , Rob Herring , Matthias Brugger , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , Subject: [PATCH v6 13/33] iommu/io-pgtable-arm-v7s: Quad lvl1 pgtable for MediaTek Date: Mon, 11 Jan 2021 19:18:54 +0800 Message-ID: <20210111111914.22211-14-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210111111914.22211-1-yong.wu@mediatek.com> References: <20210111111914.22211-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 243476fdad9e..697dee76f6cb 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