From patchwork Mon Apr 3 09:13:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Wu X-Patchwork-Id: 78425 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2164742vqo; Mon, 3 Apr 2023 02:17:46 -0700 (PDT) X-Google-Smtp-Source: AKy350Y8/MnAztYIFBCc4y9cIuq43fKT+6FGg4XdTSyL8qFk/Oiq3ssGazlFhU3VqRD9XILCfY7Z X-Received: by 2002:a17:906:7197:b0:92f:9fee:522 with SMTP id h23-20020a170906719700b0092f9fee0522mr31586894ejk.27.1680513466570; Mon, 03 Apr 2023 02:17:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680513466; cv=none; d=google.com; s=arc-20160816; b=KrqwOoIZ5WbRhbogSsqj3/XlTvDYnRO3d/bAOa7+d4uH3okgSOOgh1R2Lb3BAg1NcM cy2nGtqeYZB05AIb5BsAXpdwf+lF7vG8jggsCSBDN0lw1Sc/FUDo9Luvzk6EyrAKbh5H a0dQtuWZRW07Rt9pGozZfO4pPXnDaSevd//bMFJnvvtq1Ff4OEsDpmQe8MD7BwElPiuN a78OKZ+aun+iF38urmUJ8k55b+FW0/s0Dq0OyK0Tn3tdXcASoJ+KB8wJ9X13i+CBJm8g aC8aHwvLLV7urxCsMsS35kxGQ3XKuKaXsJ3KoSJlAHCE0DwFs+rsEXSX7Rob9Oy7rwfZ J2pw== 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=Gbacnh4qt5DCcPUzPDRzUSmOnmUijCnl8GTEcmOfwW0=; b=FVc+S5mQcrpSjizwlLjrr5aNdx7ZvObRN4yCxt8ezQD4FkoHASV+4n0Lt0Sulc19oN PNwDoR1jqBxh/c7EhLv2iswpeHidKae8pmEKShczGS+ENEp+2JTx3LdBbgbo5aLimQSI ibZ8iUWtGAnYMmakF3F54I5JEJM59MsiYvjckRfEkasSEs2R+eSrpGRM/B+UvwJPVNNX j9UotREROi55dPUnGW/Y/LdRKQej3uHThmoo7xUlUBzRSjgnph/x1wTxlyUXdGnOdgPj dV53rh8qWy7oejv9P3LtDtMNHbRALWnQLZc0GkMxcV/vxDGVaDmG+rrjevg2A0tkH80z IG1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="f2N/eXjw"; 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 i18-20020a1709061e5200b008e1cbdcd3d1si3809457ejj.97.2023.04.03.02.17.22; Mon, 03 Apr 2023 02:17:46 -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="f2N/eXjw"; 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 S231790AbjDCJPk (ORCPT + 99 others); Mon, 3 Apr 2023 05:15:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231871AbjDCJPe (ORCPT ); Mon, 3 Apr 2023 05:15:34 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF3531025F; Mon, 3 Apr 2023 02:15:21 -0700 (PDT) X-UUID: 0c77a92ad20011edb6b9f13eb10bd0fe-20230403 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=Gbacnh4qt5DCcPUzPDRzUSmOnmUijCnl8GTEcmOfwW0=; b=f2N/eXjwVaR96AKcZU8DUWg8mmXe0QAFr8rN+zhRu2fSCG9u5dAz553a9kUxtb09GlL9myCrtGoBWgFtn4k5gbWZAWWCm5w2ca+DYUbBv7l4lPlHpVkY0+U05B9I2qvH7dbY21YC0Wl9ODp51NRK2QJZZiA39ZvRdZ6BeyIz1TM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:8135812b-2d58-45b5-bf79-0b0318c1583a,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:bcd923b5-beed-4dfc-bd9c-e1b22fa6ccc4,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: 0c77a92ad20011edb6b9f13eb10bd0fe-20230403 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 628179337; Mon, 03 Apr 2023 17:15:16 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Mon, 3 Apr 2023 17:15:12 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Mon, 3 Apr 2023 17:15:11 +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 v6 06/14] iommu/mediatek: mt8195: Add iova_region_larb_msk Date: Mon, 3 Apr 2023 17:13:29 +0800 Message-ID: <20230403091337.26745-7-yong.wu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230403091337.26745-1-yong.wu@mediatek.com> References: <20230403091337.26745-1-yong.wu@mediatek.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762146089002329000?= X-GMAIL-MSGID: =?utf-8?q?1762146089002329000?= 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 672059f9e0b7..bb3734378934 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -1579,6 +1579,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 | @@ -1589,6 +1604,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}}, }; @@ -1603,6 +1619,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},