Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5245333rwl; Tue, 11 Apr 2023 02:35:29 -0700 (PDT) X-Google-Smtp-Source: AKy350ZYoAbpw4aZ9XlwX8nWeMfsA4oO4bQF64JjcKcKxWD43ZdXtpF0FrvNjrLJbY+Pexjv8qfi X-Received: by 2002:a17:902:fa88:b0:1a6:4fa6:2e88 with SMTP id lc8-20020a170902fa8800b001a64fa62e88mr3709699plb.46.1681205728861; Tue, 11 Apr 2023 02:35:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681205728; cv=none; d=google.com; s=arc-20160816; b=AHYq8AgvqJf4EbI7cDKv4rClqEEMFLRfbk8w718bMf3iuEFOzVynAB9AGQLkzpOJ/d eq43er7usWcfRAb1SjuiR0SKkZBypByiV7iYpwmCk2g4j9DTMcwS/NJnfbuAQDrPHOYZ vFdWdH/MPmlTocrm+Ww712FTEEePc1wvsRU6COie5ctHWADq3S0SwXF/4syHCbl591lW qeUQmq+go62oDCjWx/viqUVQFxB9kr1DXk9i1hUQ8hMeaRNDaq8I6wdJajwfWbDGNj33 LEH5XYfX1qa2lUNfaS+P79s1QStITpmQJWzvT10OFjC/J2yD4oF73BfqjmWmLtYMw1Vw inxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lpfNQKTfP2YyAAu6CpD43JhcPlq1HIOIhM6xNel8+1I=; b=r4xKzVX7jkAMJF/VSeiGTT20kSgSoRZkYG61amIPvsFDB9drOp64TRiuDs/+dqdRNB egcyYQRlg9HMYrMqxh8yKHFaTWISyNrIe+kkAoYD3yrgyd9VC1sDVS1E5VmHizpeXhz9 PZptS+ZpCLtEh1iv1EbyWyWTU0Bsdtf1t8eYOJA51mIiV/d3s1SbnfX1GptT9cyl40Bh vN38IQi2jLP8kSdAAdx/npyzdOwp1LHm9FmCqPRnAcmBua0rTJYoPNOQxh8FF0tSKUTy tL0U/mR5qVyzNmu9hj22/PmNCvPz05uykGbha8p5ROsvxw5EXdmNTA/wa2v8gnS5NSr4 +slQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="cdyQ/dgv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t10-20020a170902b20a00b001a2a9bfdfb4si13268372plr.297.2023.04.11.02.35.13; Tue, 11 Apr 2023 02:35:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="cdyQ/dgv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230099AbjDKJdo (ORCPT + 99 others); Tue, 11 Apr 2023 05:33:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229911AbjDKJd3 (ORCPT ); Tue, 11 Apr 2023 05:33:29 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A939940C6; Tue, 11 Apr 2023 02:33:02 -0700 (PDT) X-UUID: d88200e6d84b11eda9a90f0bb45854f4-20230411 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=lpfNQKTfP2YyAAu6CpD43JhcPlq1HIOIhM6xNel8+1I=; b=cdyQ/dgvhWVB021hzk0NMf/sn0lJlPzaCDb2JoMXed0wQ3RNcsIqH4fNhBW+M4JoWQOEOCdExHUfLAN4SQi3luit8K8QKu9TyneCGyQtLUpp6/nBn5UYeOLsP03wSlfYQe5qav55MC7LDcIn7vm+SawoTziKJvX/xAwm2pTcAPM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:4d02fddd-7c48-4277-bea3-e1c48385d2d0,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:120426c,CLOUDID:b80695ea-db6f-41fe-8b83-13fe7ed1ef52,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-UUID: d88200e6d84b11eda9a90f0bb45854f4-20230411 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 422454516; Tue, 11 Apr 2023 17:32:58 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Tue, 11 Apr 2023 17:32:57 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Tue, 11 Apr 2023 17:32:56 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Mauro Carvalho Chehab , Rob Herring CC: Will Deacon , Robin Murphy , Krzysztof Kozlowski , Hans Verkuil , , , , , , , , AngeloGioacchino Del Regno , , , , Yunfei Dong , kyrie wu , , , , Yong Wu Subject: [PATCH v7 05/14] iommu/mediatek: mt8192: Add iova_region_larb_msk Date: Tue, 11 Apr 2023 17:31:35 +0800 Message-ID: <20230411093144.2690-6-yong.wu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230411093144.2690-1-yong.wu@mediatek.com> References: <20230411093144.2690-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add iova_region_larb_msk for mt8192. We separate the 16GB iova regions by each device's larbid/portid. Note: larb3/6/8/10/12/15 connect nothing in this SoC. Refer to the comment in include/dt-bindings/memory/mt8192-larb-port.h Define a new macro MT8192_MULTI_REGION_NR_MAX to indicate the index of mt8xxx_larb_region_msk and "struct mtk_iommu_iova_region mt8192_multi_dom" are the same. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index bc936709fbe6..672059f9e0b7 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -336,7 +336,12 @@ static const struct mtk_iommu_iova_region single_domain[] = { {.iova_base = 0, .size = SZ_4G}, }; -static const struct mtk_iommu_iova_region mt8192_multi_dom[] = { +#define MT8192_MULTI_REGION_NR_MAX 6 + +#define MT8192_MULTI_REGION_NR (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) ? \ + MT8192_MULTI_REGION_NR_MAX : 1) + +static const struct mtk_iommu_iova_region mt8192_multi_dom[MT8192_MULTI_REGION_NR] = { { .iova_base = 0x0, .size = SZ_4G}, /* 0 ~ 4G */ #if IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) { .iova_base = SZ_4G, .size = SZ_4G}, /* 4G ~ 8G */ @@ -1534,6 +1539,17 @@ static const struct mtk_iommu_plat_data mt8186_data_mm = { .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), }; +static const unsigned int mt8192_larb_region_msk[MT8192_MULTI_REGION_NR_MAX][MTK_LARB_NR_MAX] = { + [0] = {~0, ~0}, /* Region0: larb0/1 */ + [1] = {0, 0, 0, 0, ~0, ~0, 0, ~0}, /* Region1: larb4/5/7 */ + [2] = {0, 0, ~0, 0, 0, 0, 0, 0, /* Region2: larb2/9/11/13/14/16/17/18/19/20 */ + 0, ~0, 0, ~0, 0, ~(u32)(BIT(9) | BIT(10)), ~(u32)(BIT(4) | BIT(5)), 0, + ~0, ~0, ~0, ~0, ~0}, + [3] = {0}, + [4] = {[13] = BIT(9) | BIT(10)}, /* larb13 port9/10 */ + [5] = {[14] = BIT(4) | BIT(5)}, /* larb14 port4/5 */ +}; + static const struct mtk_iommu_plat_data mt8192_data = { .m4u_plat = M4U_MT8192, .flags = HAS_BCLK | HAS_SUB_COMM_2BITS | OUT_ORDER_WR_EN | @@ -1543,6 +1559,7 @@ static const struct mtk_iommu_plat_data mt8192_data = { .banks_enable = {true}, .iova_region = mt8192_multi_dom, .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), + .iova_region_larb_msk = mt8192_larb_region_msk, .larbid_remap = {{0}, {1}, {4, 5}, {7}, {2}, {9, 11, 19, 20}, {0, 14, 16}, {0, 13, 18, 17}}, }; -- 2.25.1