Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp321077pxb; Wed, 11 Nov 2020 04:43:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXc5VBxwoMQeUuQ+c4WymvPJsEepwpGIfQh1nm6YScIBeK/mNegwb4cgRwBdpMrA3t6TmL X-Received: by 2002:a17:906:1e45:: with SMTP id i5mr24454769ejj.203.1605098593982; Wed, 11 Nov 2020 04:43:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605098593; cv=none; d=google.com; s=arc-20160816; b=0VNizye/iq/8d+X4MFV6MwOkg5TQoefl3im/630623Ly8zNrlexwWBiMtjfVo3ROjY pm6GQhrTSxlsyElyY05yAuOjJVvCBZ5b4rJqE5dZYleWR3O3iWYc3Sopz9e5kGw65fj7 LJzTndQRIT4ox0IQoyFn47yLXzGqftrA+Lyk12pmQ4LrHyN6+nN0y83NSVU2MQLNtvH7 YhWr+0VFoZs2Xk7QeerbVfqwR5vTYNURw0K169PcZ1ltrT6ugI2/PkvW1wFSsGzGXM3z DvVy2O1oGxQOkDH4+UMbqxyRu8aOMA4YrkCcWpG1SJRtrVAUpJ+L8mf6SGL4YVt/N2jH HZCQ== 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=odsbfwSsgSn5UrraXv8hyYfeGXBMAVi+SsRCcyskDc0=; b=PFWLaO7l8+Dk7ZufA04ryvjmuwqNE1BMBjF11pjSiSY8xAjqLBFjQg4SS1VpBCO3Ld 7+/g9i9PRAYcZcURl83Stal0VNDM8eVJ3qOgosRsybS8xbmMLw9cTiT4R/096PKt638y lUX+MJlaQaICRpKmpodgqcR4m9dNw95ydioxXPtMis3OL9P05jSLRJL7RafJOWEiHo4x RmvGnYgCiXlUiMBZ/prW2vi/Zx5C2ndqtkOlehJ4UBm2dKn9Xq9mJJoGIibMDUY61ACD qJ0KQu1BB4zZwF71uTU4e+2FqpasLCsNMDcFUwFcKkqKbPlKHDaDZNZ3LJVoggfJBbLJ TCVQ== 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 t17si1427353ejs.13.2020.11.11.04.42.49; Wed, 11 Nov 2020 04:43:13 -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 S1726851AbgKKMkd (ORCPT + 99 others); Wed, 11 Nov 2020 07:40:33 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:34126 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726204AbgKKMkc (ORCPT ); Wed, 11 Nov 2020 07:40:32 -0500 X-UUID: f816b645fbfc46df86619362abedf0f1-20201111 X-UUID: f816b645fbfc46df86619362abedf0f1-20201111 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] 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 1121937495; Wed, 11 Nov 2020 20:40:28 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 11 Nov 2020 20:40:25 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 11 Nov 2020 20:40:24 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Rob Herring , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , , Greg Kroah-Hartman , Subject: [PATCH v4 11/24] iommu/io-pgtable-arm-v7s: Quad lvl1 pgtable for MediaTek Date: Wed, 11 Nov 2020 20:38:25 +0800 Message-ID: <20201111123838.15682-12-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201111123838.15682-1-yong.wu@mediatek.com> References: <20201111123838.15682-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 --- 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, -- 2.18.0