Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp404151rwb; Thu, 12 Jan 2023 22:18:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXvO3FHCn+CY+ILJ2iVZY20/nKfVZdV9DXlEXj7tMb/sap30Y0mwWVmvRR8fy5HVTIPqVxDm X-Received: by 2002:aa7:947b:0:b0:575:2337:17bf with SMTP id t27-20020aa7947b000000b00575233717bfmr10100369pfq.12.1673590684625; Thu, 12 Jan 2023 22:18:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673590684; cv=none; d=google.com; s=arc-20160816; b=bmIkQ/V020KNGNxwwj9s1Yhw6xcmY36tElBqJgUpti8LGC9WpPcLIR6MIt1f1b5QKj gOBgmzVT3f7H5mf8oCahfnoYSy1W8wD2ApXglp8YJBvCXVbZXCtz3mHg7mOgHwuBH7oC L0pqWK3V2KxirUTsly5bMR34lP+jbPB7w9XI8q4R6pKMLluDWQWaY1veJau2wNG1kdsC WcRHy2QB4389fezKR3NfnJBFFb/fl1chRiWWWUYtYxNYrZrk6oW214iiOQ4IyRAf7BYo /nwJn6aLLQyKmG9MxSMgr4pemYM4nZbZx9krIlJgeXUcuquunLpsYVx63nvHVPRWbMAF y6Qg== 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:dkim-signature; bh=PeWoAYdW8lwRPXxLK/28TSOR0/KLH3G+p7agx16Ns2w=; b=HhP1YPNPog9R+vO1A/d5N6gEkAizJa+UbITpABS9XKWPvQPLzfI5wTGSrbrpYhe1/H PDqZebUdswchpZDhPFrRvqt9J+iIoYovX6pDT6eGq3G7C31JfZmB2IdJKc9vYGR+RKDQ dKyGJ2RzpRImRaa+aKY3NTkfxKmaSyzEB8OBG5WBqP4eJnCTGoLtwsrsiG0mcKu2hIEw 8l8KXkvFBfeOt3iVS95F4dKK83BX+G3uePVOcj97q0FVDceYHBhgXr6NCDLUHexus3hF ScTptFDXUBt97nBbBYkAPU4fvrX/FYKta/8tiMyKzbLfkXaL2/rGOFcafJki3KPTq4x2 S3lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=ftbgSPtX; 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 192-20020a6214c9000000b0058b3a0a8308si8109883pfu.60.2023.01.12.22.17.58; Thu, 12 Jan 2023 22:18:04 -0800 (PST) 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=ftbgSPtX; 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 S231345AbjAMGHD (ORCPT + 50 others); Fri, 13 Jan 2023 01:07:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232506AbjAMGGL (ORCPT ); Fri, 13 Jan 2023 01:06:11 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BD451B9D1; Thu, 12 Jan 2023 22:02:46 -0800 (PST) X-UUID: e3b017e8930711eda06fc9ecc4dadd91-20230113 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=PeWoAYdW8lwRPXxLK/28TSOR0/KLH3G+p7agx16Ns2w=; b=ftbgSPtX5jk9WF7t19Zry2larLYDkb2tQjXwjy+l/jR4WcJXPHAtcAjkpfPE9UOgxe7VjHmbNU153uJP81AeM9sh9X0MSE5czvlgQP6JopE2gFSEcdSOLO7+EoWLetdT1/ma1N3tNsg00LFLNnMVZe1zeTN+u9KKt/t9YqKLbq8=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.17,REQID:39300a6f-ef6a-46ac-a991-12968d21822c,IP:0,U RL:0,TC:0,Content:-20,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:75 X-CID-INFO: VERSION:1.1.17,REQID:39300a6f-ef6a-46ac-a991-12968d21822c,IP:0,URL :0,TC:0,Content:-20,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:75 X-CID-META: VersionHash:543e81c,CLOUDID:46f28a54-dd49-462e-a4be-2143a3ddc739,B ulkID:230113140242PD5AHBU7,BulkQuantity:0,Recheck:0,SF:38|28|17|19|48,TC:n il,Content:1,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OS I:0,OSA:0 X-CID-APTURL: Status:success,Category:nil,Trust:0,Unknown:0,Malicious:0 X-CID-BVR: 0,NGT X-UUID: e3b017e8930711eda06fc9ecc4dadd91-20230113 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 944863875; Fri, 13 Jan 2023 14:02:41 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Fri, 13 Jan 2023 14:02:40 +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.792.15 via Frontend Transport; Fri, 13 Jan 2023 14:02:38 +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 04/10] iommu/mediatek: mt8195: Add larb_region_msk Date: Fri, 13 Jan 2023 14:01:27 +0800 Message-ID: <20230113060133.9394-5-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230113060133.9394-1-yong.wu@mediatek.com> References: <20230113060133.9394-1-yong.wu@mediatek.com> MIME-Version: 1.0 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,UNPARSEABLE_RELAY 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 larb_region_msk for mt8195. we separate the 16GB iova regions by each device's larbid/portid. Refer to include/dt-bindings/memory/mt8195-memory-port.h Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index d30020d0a190..d8be7584702f 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1546,6 +1546,21 @@ static const struct mtk_iommu_plat_data mt8195_data_infra = { .iova_region_nr = ARRAY_SIZE(single_domain), }; +static const unsigned int mt8195_larb_region_msk[][32] = { + [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/20/21/22/23/24 */ + ~0}, + [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, ~0, ~0, ~0}, + [3] = {0}, + [4] = {[18] = BIT(0) | BIT(1)}, /* Only larb18 port0/1 */ + [5] = {[18] = BIT(2) | BIT(3)}, /* Only larb18 port2/3 */ +}; + static const struct mtk_iommu_plat_data mt8195_data_vdo = { .m4u_plat = M4U_MT8195, .flags = HAS_BCLK | HAS_SUB_COMM_2BITS | OUT_ORDER_WR_EN | @@ -1556,6 +1571,7 @@ static const struct mtk_iommu_plat_data mt8195_data_vdo = { .banks_enable = {true}, .iova_region = mt8192_multi_dom, .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), + .larb_region_msk = mt8195_larb_region_msk, .larbid_remap = {{2, 0}, {21}, {24}, {7}, {19}, {9, 10, 11}, {13, 17, 15/* 17b */, 25}, {5}}, }; @@ -1570,6 +1586,7 @@ static const struct mtk_iommu_plat_data mt8195_data_vpp = { .banks_enable = {true}, .iova_region = mt8192_multi_dom, .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), + .larb_region_msk = mt8195_larb_region_msk, .larbid_remap = {{1}, {3}, {22, MTK_INVALID_LARBID, MTK_INVALID_LARBID, MTK_INVALID_LARBID, 23}, {8}, {20}, {12}, -- 2.18.0