Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5082400rwe; Tue, 18 Apr 2023 01:37:42 -0700 (PDT) X-Google-Smtp-Source: AKy350bxD+7pnxF2PgXbDRVJukwxBgCi5coTCa/sWofQgzIIc5E2CMvk84FdMWohwEnoLsby75QS X-Received: by 2002:a05:6a00:2401:b0:626:2ce1:263c with SMTP id z1-20020a056a00240100b006262ce1263cmr23197679pfh.5.1681807061773; Tue, 18 Apr 2023 01:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681807061; cv=none; d=google.com; s=arc-20160816; b=hpHe0ylvJ2zvd3Ht5BfiEwmx6Eg8PS85/LRubPVe9RRf7zrfIurJG4WT9GN0Rx5fqy 2qzBZhWGnZaTyHqSbJS00Ijawxaf3D3g2eoXFJM5f6KchdyJfURpv07KzM6q77Sd8hBl rNi77L87eKG6n7htfn3tt8THEN/oiPZlFawgJHJHzJ3Oieuw5dr/YcpDfSl2r3XDf2mG b7R8XlC7Pa1LNAeDDiz5MVu6UGTpGBCe2mxmz76ehx0digTeCezce/xFxeJn+T8Lt2PV QF1mCMprsy4+t+4+fD866M49+fAN4gAKkjfSrOmMlg6YXrKi6+uosQXNEL/Hsqg9jw7q mLQA== 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=DQv2qOPx5dYPZdNgHn6YjWMVC72EGZL4V7OLMRx5WoA=; b=UoV5CSBRwJB8uLyH3hCdLFeJLSmSzbnbojMtoVRCcYNJUsmchSvza7s0Bf/+Gpsmbq TliBK4ENamVGOyVwQapFdtMbq5x2NdCI0gjwUXiuEzh6oCe1uvNL2EpWOwvmxZ58kdEy 1mCY7SuFUoNq+aQdML/F/i4tn3X2sN6h81BFP8z48YIsz4fGTyli4welAAvqwqNKi9/Q GoltA7nalKbZjItHvAy1cidh9RvFuJivMMgLBbFqnCfCF7EdeVfhCE3s2kNnuo8Y8wT2 0qXnS7LN1OCqcxCSUL9LqqtHW0MlpUPReuYhFbg7pj/TOonA+d5sokoBha9iNFmzh1oH ziDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="B/TybyX0"; 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 u126-20020a627984000000b006303ebae0eesi14044511pfc.378.2023.04.18.01.37.30; Tue, 18 Apr 2023 01:37:41 -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="B/TybyX0"; 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 S229669AbjDRIhE (ORCPT + 99 others); Tue, 18 Apr 2023 04:37:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231311AbjDRIhC (ORCPT ); Tue, 18 Apr 2023 04:37:02 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34CA8902A; Tue, 18 Apr 2023 01:36:34 -0700 (PDT) X-UUID: 1dc15df0ddc411eda9a90f0bb45854f4-20230418 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=DQv2qOPx5dYPZdNgHn6YjWMVC72EGZL4V7OLMRx5WoA=; b=B/TybyX0GcHgJXv74nekOtrSlyAsD3znkB2iHR2PF357MSnMvx5BPCeIg7pHtSVirU+mr6Z3wnhkQIQmR/D7FPHk9Vvme8nFKbhKgqWg/RTEl86xPSi4x6IZXbrSKhidMPHlWyqWyjVt+HN+76C0Ove8dLDyOcABSSeY4apXUx0=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:97c9f635-d5e9-481e-b5a2-5ba109c7c117,IP:0,U RL:0,TC:0,Content:-20,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-20 X-CID-META: VersionHash:120426c,CLOUDID:4b4f7184-cd9c-45f5-8134-710979e3df0e,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:1,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: 1dc15df0ddc411eda9a90f0bb45854f4-20230418 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 2011420845; Tue, 18 Apr 2023 16:36:30 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) 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, 18 Apr 2023 16:36:28 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Tue, 18 Apr 2023 16:36:28 +0800 From: Yong Wu To: Joerg Roedel , Will Deacon , Rob Herring , Matthias Brugger CC: Robin Murphy , Krzysztof Kozlowski , Yong Wu , AngeloGioacchino Del Regno , , , , , , , , , Subject: [PATCH v11 6/7] iommu/mediatek: mt8188: Add iova_region_larb_msk Date: Tue, 18 Apr 2023 16:35:13 +0800 Message-ID: <20230418083514.4379-7-yong.wu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230418083514.4379-1-yong.wu@mediatek.com> References: <20230418083514.4379-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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham 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 mt8188. We separate the 16GB iova regions by each device's larbid/portid. Refer to include/dt-bindings/memory/mediatek,mt8188-memory-port.h As commented in the code, larb19(21) means it's larb19 while its SW index is 21. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index fa46c4309f35..876624f807d6 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1599,6 +1599,20 @@ static const struct mtk_iommu_plat_data mt8188_data_infra = { .iova_region_nr = ARRAY_SIZE(single_domain), }; +static const u32 mt8188_larb_region_msk[MT8192_MULTI_REGION_NR_MAX][MTK_LARB_NR_MAX] = { + [0] = {~0, ~0, ~0, ~0}, /* Region0: all ports for larb0/1/2/3 */ + [1] = {0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, ~0, ~0, ~0}, /* Region1: larb19(21)/21(22)/23 */ + [2] = {0, 0, 0, 0, ~0, ~0, ~0, ~0, /* Region2: the other larbs. */ + ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0, + ~0, ~0, ~0, ~0, ~0, 0, 0, 0, + 0, ~0}, + [3] = {0}, + [4] = {[24] = BIT(0) | BIT(1)}, /* Only larb27(24) port0/1 */ + [5] = {[24] = BIT(2) | BIT(3)}, /* Only larb27(24) port2/3 */ +}; + static const struct mtk_iommu_plat_data mt8188_data_vdo = { .m4u_plat = M4U_MT8188, .flags = HAS_BCLK | HAS_SUB_COMM_3BITS | OUT_ORDER_WR_EN | @@ -1610,6 +1624,7 @@ static const struct mtk_iommu_plat_data mt8188_data_vdo = { .banks_enable = {true}, .iova_region = mt8192_multi_dom, .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), + .iova_region_larb_msk = mt8188_larb_region_msk, .larbid_remap = {{2}, {0}, {21}, {0}, {19}, {9, 10, 11 /* 11a */, 25 /* 11c */}, {13, 0, 29 /* 16b */, 30 /* 17b */, 0}, {5}}, @@ -1626,6 +1641,7 @@ static const struct mtk_iommu_plat_data mt8188_data_vpp = { .banks_enable = {true}, .iova_region = mt8192_multi_dom, .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), + .iova_region_larb_msk = mt8188_larb_region_msk, .larbid_remap = {{1}, {3}, {23}, {7}, {MTK_INVALID_LARBID}, {12, 15, 24 /* 11b */}, {14, MTK_INVALID_LARBID, 16 /* 16a */, 17 /* 17a */, MTK_INVALID_LARBID, -- 2.25.1