From patchwork Tue Feb 14 03:11:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Wu X-Patchwork-Id: 56639 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2729972wrn; Mon, 13 Feb 2023 19:14:04 -0800 (PST) X-Google-Smtp-Source: AK7set/FnnOOXvcJyXgjJg450AceWhaqfpPs0e3fgY6uAs5/9kZb8D6QUn9gEQYOjeU1fNwIik1y X-Received: by 2002:a17:90b:4c86:b0:234:234c:72d9 with SMTP id my6-20020a17090b4c8600b00234234c72d9mr789391pjb.14.1676344443994; Mon, 13 Feb 2023 19:14:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676344443; cv=none; d=google.com; s=arc-20160816; b=YOq4lnO/1opE4/ppKIJpVjFoV1VSr34FietdOHSxL0ZL9B2Bp3ls2Jp2v+rIW+jU2/ b1/JlqrB7hvKXItRYBJWio3Fka95RTw++XVZajYKguzBeufvZ6TZIYGQkryCdcv05MA8 EZEYUvmk1gjRLBKG4u2mpxzxJOb54Jyi6vxhe2G5m10uuq1zB3CtHIJECU8m2cAVQHTB 1dkbqo25hGmyq4qokXIHycL47r8yBZnHZzycDhdUuOj2w0qtq/jed0MEVnC0nURncyKi JMsuIquxWcbPSa2/j8RYHWAdm85+Khl0pF/h3tRMw2+k2GPxQKHTR6ems0RlYXjZ0hSv 5YKg== 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=6YwMpyviGTSbxvBRVJIYFE9YPlevofbZZf0V7oAR34o=; b=YYX0Q5LDarT4J9kyyUl5OEivnn70FhBkflcWuYPW0K1jriuCIF57Xk1dl/jYlrc33H s7F0Lgp3m+72FOTEJASBka0T8ldmIfa6lTfIjgE605wyFiXiWX+HWl83bDV6qijAH+Bs hBzaSSsEOVnpe9LhUp3QcXWuGp3MhhaD1LPsagOrfvOvtxIV/kdwKV7Ccp2F3Gde8rtI 8hbcKqqReFQlldgnCTwst6o7Wb5f7QT6cn+rIU9lFKoB4ScTLrkDqk7x+RauRX7gDxaf dV2TxX/W8J71GJHkCLGcCNSPVn3+UWlyTwZn3FsTtjUGhz1fXRAco152nSC73hSuEKKy aN8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=kKV5f4Ls; 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 n2-20020a637202000000b004fbb45b9019si3895989pgc.627.2023.02.13.19.13.51; Mon, 13 Feb 2023 19:14:03 -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=kKV5f4Ls; 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 S230259AbjBNDNE (ORCPT + 99 others); Mon, 13 Feb 2023 22:13:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230412AbjBNDNC (ORCPT ); Mon, 13 Feb 2023 22:13:02 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE46A1B309; Mon, 13 Feb 2023 19:12:38 -0800 (PST) X-UUID: 6ab5877aac1511eda06fc9ecc4dadd91-20230214 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=6YwMpyviGTSbxvBRVJIYFE9YPlevofbZZf0V7oAR34o=; b=kKV5f4LsIehkYG+8euKRfAe6NnS668FEUh32yLA5bBudMsqOknWWD06zGh3sl5vCaDFZIgB6Re/YguPOiR1fKhxrVeeSGkelSlvclCaVlyW2iitEfxNC0bbNpzQ5oSZsGwPIAYukyxML+HWEMp26MULtQ7aDBStu+16FTvoMHvk=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.19,REQID:6162fb71-5c45-46ca-bfc4-7d13e1f1ddc7,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:885ddb2,CLOUDID:c0aecc8e-8530-4eff-9f77-222cf6e2895b,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,NGT X-UUID: 6ab5877aac1511eda06fc9ecc4dadd91-20230214 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 888487452; Tue, 14 Feb 2023 11:12:30 +0800 Received: from mtkmbs13n2.mediatek.inc (172.21.101.108) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Tue, 14 Feb 2023 11:12: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.792.15 via Frontend Transport; Tue, 14 Feb 2023 11:12:27 +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 v3 05/11] iommu/mediatek: mt8195: Add iova_region_larb_msk Date: Tue, 14 Feb 2023 11:11:08 +0800 Message-ID: <20230214031114.926-6-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230214031114.926-1-yong.wu@mediatek.com> References: <20230214031114.926-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 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?1757774552028882334?= X-GMAIL-MSGID: =?utf-8?q?1757774552028882334?= 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 Define a new macro MT8192_MULTI_REGION_MAX_NR 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 --- drivers/iommu/mtk_iommu.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 7e2cb3b8cac8..3d9986fb49a5 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -332,7 +332,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_MAX_NR 6 + +#define MT8192_MULTI_REGION_NR (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) ? \ + MT8192_MULTI_REGION_MAX_NR : 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 */ @@ -1562,6 +1567,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_MAX_NR][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 | @@ -1572,6 +1592,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}}, }; @@ -1586,6 +1607,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},