From patchwork Tue Mar 7 02:35:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Wu X-Patchwork-Id: 65199 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2200180wrd; Mon, 6 Mar 2023 18:38:53 -0800 (PST) X-Google-Smtp-Source: AK7set9vK4JA998qt4sZtmERwG5SA6XHwpGVuUistee/ZmzVquQCbm04Y5IXBEnBHd11WoZrTqW7 X-Received: by 2002:a17:90b:3e8d:b0:233:ca14:6afb with SMTP id rj13-20020a17090b3e8d00b00233ca146afbmr13977202pjb.37.1678156732792; Mon, 06 Mar 2023 18:38:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678156732; cv=none; d=google.com; s=arc-20160816; b=AgNat/+pBVp4r6ZACcIVagf2Myg/ND+wbwKcojkRYG/3Ej5GEHBsIyirYdyuDvYn8r Jz8wgO/f3bqFoT7K0/wEec4WB9VwURqe9mpWz/NzJG1UnzLVx78ulwNbn1ZYjMaCD2RS Cjlhn1P4DbzM5NyVzMpBs5DtuhHjDa0vMACD66yVQTmiahIXDDTOgH0veIIwvr28zWyR IO4xqPfCQIPtXKbcJbvYLVyHYxrSfL2PHZj5+QzqWDoOaf9KOLRAnGeT7YpA+lF1PfG3 aqmhVoBrzL5HZgmduRzWxiUIbBQ8LxDft5bTKg6ZKfgDbHuuNQQhTo1rhyj61HBC9wmV h8Dg== 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=J+LXFciiS5DwAI74xJjdw77cbB8VWd8r6zJwG/j2qg8=; b=X+7vzD3A88PteIsVHT0Jl+rcahsETLeTg/8aqEVAWqHX6l80I+GtGujXPyioVNrpDx 13j3Kci/6gTMN9vVJbd1bCXryK4eWTxrOeTQMBkAn8gJ4Z4V6pq0V/8eTlZXDqoqJYeg Y2TpSue7NJ7R6kBm8IclTg1IjT4fDYgwMJQUadjHg+otzJQOjB5rMyuI9Trlrd0L2jJk JxCfHJOCbPOUetl6sJraKHp3XZ5yO5JOH3DuGVV+e09XC8fbi66/3iIHYPp0/nOi01S+ 7EV3KKC6tkv2JxYqFh7sqZ8YsKfEWIRzJTJsve81MKsR9GRKyyzFu80Sj1l+TylQzo7C ewSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=N5hYa07F; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q13-20020a17090a68cd00b0022bb87f2dfdsi10801571pjj.129.2023.03.06.18.38.40; Mon, 06 Mar 2023 18:38:52 -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=N5hYa07F; 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 S229972AbjCGChd (ORCPT + 99 others); Mon, 6 Mar 2023 21:37:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229687AbjCGChb (ORCPT ); Mon, 6 Mar 2023 21:37:31 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7FC56A1FA; Mon, 6 Mar 2023 18:36:55 -0800 (PST) X-UUID: e9ef675abc9011eda06fc9ecc4dadd91-20230307 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=J+LXFciiS5DwAI74xJjdw77cbB8VWd8r6zJwG/j2qg8=; b=N5hYa07FZ4u2EDnWwnvCv6sQmbFf3LShQ4QNuLW+OUek5/Gle/oIhJTLu/SNIDx4kIS0V8ajXOxz00YAQ69j+pyIrsHqlPZc2PjTb+MdLWpcOtq3l+SxnXNeiU99DH/ETsvhKWBWfoDZw1oCd8Mp26C6NMgQMtx3JMg4jb5CwbE=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.20,REQID:ad3d03fa-380b-4c89-978b-f25544c68713,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:25b5999,CLOUDID:fdd68827-564d-42d9-9875-7c868ee415ec,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-UUID: e9ef675abc9011eda06fc9ecc4dadd91-20230307 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 931985464; Tue, 07 Mar 2023 10:36:50 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Tue, 7 Mar 2023 10:36:49 +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, 7 Mar 2023 10:36:47 +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 v5 06/11] iommu/mediatek: mt8195: Add iova_region_larb_msk Date: Tue, 7 Mar 2023 10:35:02 +0800 Message-ID: <20230307023507.13306-7-yong.wu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230307023507.13306-1-yong.wu@mediatek.com> References: <20230307023507.13306-1-yong.wu@mediatek.com> MIME-Version: 1.0 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,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759674874378019100?= X-GMAIL-MSGID: =?utf-8?q?1759674874378019100?= Add iova_region_larb_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 Reviewed-by: AngeloGioacchino Del Regno --- 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 710a3239fd3d..0e387345e1c3 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1583,6 +1583,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[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/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 | @@ -1593,6 +1608,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), + .iova_region_larb_msk = mt8195_larb_region_msk, .larbid_remap = {{2, 0}, {21}, {24}, {7}, {19}, {9, 10, 11}, {13, 17, 15/* 17b */, 25}, {5}}, }; @@ -1607,6 +1623,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), + .iova_region_larb_msk = mt8195_larb_region_msk, .larbid_remap = {{1}, {3}, {22, MTK_INVALID_LARBID, MTK_INVALID_LARBID, MTK_INVALID_LARBID, 23}, {8}, {20}, {12},