Message ID | 20230602090227.7264-6-yong.wu@mediatek.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp897447vqr; Fri, 2 Jun 2023 02:25:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4nlRn16+jLiriEpVDe+HUHWt6dTIXJeQiNU+EmhNRQjkGOvhHHbeLu9OMj2cXIf4J+u44n X-Received: by 2002:a05:6871:410:b0:19e:e968:e7e5 with SMTP id d16-20020a056871041000b0019ee968e7e5mr1381901oag.5.1685697951143; Fri, 02 Jun 2023 02:25:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685697951; cv=none; d=google.com; s=arc-20160816; b=H725rC7GhUXMqVgJu2VdIgXzulSOYzqTsQidQMgWG047e1LKNtkLC60VHEaXsMLrV7 Rt/ma0f/yEs7F6YYCOzsIiBrLWbMSvPynxnRzZ3VUi1Z9NA02Kv4ePHh/eliuSXmtsu0 cMjdUK8XxyZKRvAI8YkTOXhTzMujRRbqGJbFG4UL7r3kLkPH7dKY+hhusXB6bRE/YbqV 6Ws1SpwiF4otMZslu6cp0TMIcIVlF1XWQTbB+S1lmoudbdFC4RCP9URvzNpoGwn3vUAn si6cdUmhJWLxcBlEKhLkSVxPCPUJ08T2gkhfj52u+o7XDJELP7jEDPx8hKD1K1Kx+1Rl x9YA== 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=KlonPEHaL5hW+egl6HkPGACSHVt3397EgMV9NrpZd8g=; b=HElceEgT4ERi+3mj4oLn8P+1ftRKmUj9UZbDJwetwDGnEm54OqjuZQVoGOHvlRJE1G LSxdxBYKc2uANGE9/LEg1ZV3/8BeMIgLkw84fpwkjCjBLdBvVhB/yzXAD0SZ3D6jueZS P4IP67CTB/QxLHI8Q3KTCz+0Z1DYqGVOTDmqGwZ+DnDBM8zfyzV1NxNLD+J5Te7JeQDb o6YuixaXsoYuGgRhNfmYTeJUjt+BJQzcAheRism/s44J/ecwcbbFfU0SoYJDpuLB0Q+Y 8HqToCxC03BH28yGdga57Y9AGBt/ggnWBCxL0tQw1yNLkqgflZVaVbIKXdYf14LYT8fd qI4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=vH7U8YGK; 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 bs126-20020a632884000000b0053f2810a30bsi723712pgb.127.2023.06.02.02.25.36; Fri, 02 Jun 2023 02:25:51 -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=vH7U8YGK; 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 S235073AbjFBJGx (ORCPT <rfc822;limurcpp@gmail.com> + 99 others); Fri, 2 Jun 2023 05:06:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234996AbjFBJEI (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 2 Jun 2023 05:04:08 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5967D10C4; Fri, 2 Jun 2023 02:03:47 -0700 (PDT) X-UUID: 5f30ea70012411ee9cb5633481061a41-20230602 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=KlonPEHaL5hW+egl6HkPGACSHVt3397EgMV9NrpZd8g=; b=vH7U8YGKMCKmfMYT4S5xtPO/9GQ08TCxNWWNLXuqnoJY7RoTWlIMvKQ44wbLyAGSM00lpHyJT21pCzbwcRjXs9O/c7cKycsAWyzaZFjOGmh6ubsMwKUPNSE8xP0L7SNdRWuxsREtWpZzH+CMJQDlSqnUi/13gIGYizvYe916WWc=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.25,REQID:4a8f3e4a-3017-4f39-8cec-f358385bab6c,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:95 X-CID-INFO: VERSION:1.1.25,REQID:4a8f3e4a-3017-4f39-8cec-f358385bab6c,IP:0,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:100,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:95 X-CID-META: VersionHash:d5b0ae3,CLOUDID:a7f32e3d-de1e-4348-bc35-c96f92f1dcbb,B ulkID:230602170344Q3GZY88O,BulkQuantity:0,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:-3,IP:nil,URL: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: 5f30ea70012411ee9cb5633481061a41-20230602 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from <yong.wu@mediatek.com>) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1880723219; Fri, 02 Jun 2023 17:03:42 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) 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.26; Fri, 2 Jun 2023 17:03:41 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 2 Jun 2023 17:03:40 +0800 From: Yong Wu <yong.wu@mediatek.com> To: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>, Rob Herring <robh+dt@kernel.org>, Matthias Brugger <matthias.bgg@gmail.com> CC: Robin Murphy <robin.murphy@arm.com>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Yong Wu <yong.wu@mediatek.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, <iommu@lists.linux.dev>, <linux-mediatek@lists.infradead.org>, <devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <mingyuan.ma@mediatek.com>, <yf.wang@mediatek.com>, <jianjiao.zeng@mediatek.com>, <chengci.xu@mediatek.com> Subject: [PATCH v12 5/7] iommu/mediatek: Add MT8188 IOMMU Support Date: Fri, 2 Jun 2023 17:02:25 +0800 Message-ID: <20230602090227.7264-6-yong.wu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230602090227.7264-1-yong.wu@mediatek.com> References: <20230602090227.7264-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,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767582414449821615?= X-GMAIL-MSGID: =?utf-8?q?1767582414449821615?= |
Series |
MT8188 IOMMU SUPPORT
|
|
Commit Message
Yong Wu
June 2, 2023, 9:02 a.m. UTC
From: "Chengci.Xu" <chengci.xu@mediatek.com> MT8188 has 3 IOMMU, containing 2 MM IOMMUs, one is for vdo, the other is for vpp. and 1 INFRA IOMMU. Signed-off-by: Chengci.Xu <chengci.xu@mediatek.com> Signed-off-by: Yong Wu <yong.wu@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> --- drivers/iommu/mtk_iommu.c | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
Comments
On 02/06/2023 11:02, Yong Wu wrote: > MT8188 has 3 IOMMU, containing 2 MM IOMMUs, one is for vdo, the other > is for vpp. and 1 INFRA IOMMU. Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
On Fri, Jun 2, 2023 at 5:04 PM Yong Wu <yong.wu@mediatek.com> wrote: > > From: "Chengci.Xu" <chengci.xu@mediatek.com> > > MT8188 has 3 IOMMU, containing 2 MM IOMMUs, one is for vdo, the other > is for vpp. and 1 INFRA IOMMU. > > Signed-off-by: Chengci.Xu <chengci.xu@mediatek.com> > Signed-off-by: Yong Wu <yong.wu@mediatek.com> > Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> > --- > drivers/iommu/mtk_iommu.c | 49 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 49 insertions(+) > > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c > index 9c89cf894a4d..5c66af0c45a8 100644 > --- a/drivers/iommu/mtk_iommu.c > +++ b/drivers/iommu/mtk_iommu.c > @@ -170,6 +170,7 @@ enum mtk_iommu_plat { > M4U_MT8173, > M4U_MT8183, > M4U_MT8186, > + M4U_MT8188, > M4U_MT8192, > M4U_MT8195, > M4U_MT8365, > @@ -1593,6 +1594,51 @@ static const struct mtk_iommu_plat_data mt8186_data_mm = { > .iova_region_larb_msk = mt8186_larb_region_msk, > }; > > +static const struct mtk_iommu_plat_data mt8188_data_infra = { > + .m4u_plat = M4U_MT8188, > + .flags = WR_THROT_EN | DCM_DISABLE | STD_AXI_MODE | PM_CLK_AO | > + MTK_IOMMU_TYPE_INFRA | IFA_IOMMU_PCIE_SUPPORT | > + PGTABLE_PA_35_EN | CFG_IFA_MASTER_IN_ATF, FWIW, CFG_IFA_MASTER_IN_ATF should not be tied to the compatible string, but set via a DT property. The IOMMU controls are secured by firmware. It is not a property intrinsically tied to the hardware. If on some other project there is no such security requirement and the IOMMU is opened up to non-secure world, and ATF not even having support for the SMC call, this becomes unusable and hard to rectify without introducing a new compatible string. ChenYu > + .inv_sel_reg = REG_MMU_INV_SEL_GEN2, > + .banks_num = 1, > + .banks_enable = {true}, > + .iova_region = single_domain, > + .iova_region_nr = ARRAY_SIZE(single_domain), > +}; > + > +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 | > + WR_THROT_EN | IOVA_34_EN | SHARE_PGTABLE | > + PGTABLE_PA_35_EN | MTK_IOMMU_TYPE_MM, > + .hw_list = &m4ulist, > + .inv_sel_reg = REG_MMU_INV_SEL_GEN2, > + .banks_num = 1, > + .banks_enable = {true}, > + .iova_region = mt8192_multi_dom, > + .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), > + .larbid_remap = {{2}, {0}, {21}, {0}, {19}, {9, 10, > + 11 /* 11a */, 25 /* 11c */}, > + {13, 0, 29 /* 16b */, 30 /* 17b */, 0}, {5}}, > +}; > + > +static const struct mtk_iommu_plat_data mt8188_data_vpp = { > + .m4u_plat = M4U_MT8188, > + .flags = HAS_BCLK | HAS_SUB_COMM_3BITS | OUT_ORDER_WR_EN | > + WR_THROT_EN | IOVA_34_EN | SHARE_PGTABLE | > + PGTABLE_PA_35_EN | MTK_IOMMU_TYPE_MM, > + .hw_list = &m4ulist, > + .inv_sel_reg = REG_MMU_INV_SEL_GEN2, > + .banks_num = 1, > + .banks_enable = {true}, > + .iova_region = mt8192_multi_dom, > + .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), > + .larbid_remap = {{1}, {3}, {23}, {7}, {MTK_INVALID_LARBID}, > + {12, 15, 24 /* 11b */}, {14, MTK_INVALID_LARBID, > + 16 /* 16a */, 17 /* 17a */, MTK_INVALID_LARBID, > + 27, 28 /* ccu0 */, MTK_INVALID_LARBID}, {4, 6}}, > +}; > + > static const unsigned int mt8192_larb_region_msk[MT8192_MULTI_REGION_NR_MAX][MTK_LARB_NR_MAX] = { > [0] = {~0, ~0}, /* Region0: larb0/1 */ > [1] = {0, 0, 0, 0, ~0, ~0, 0, ~0}, /* Region1: larb4/5/7 */ > @@ -1701,6 +1747,9 @@ static const struct of_device_id mtk_iommu_of_ids[] = { > { .compatible = "mediatek,mt8173-m4u", .data = &mt8173_data}, > { .compatible = "mediatek,mt8183-m4u", .data = &mt8183_data}, > { .compatible = "mediatek,mt8186-iommu-mm", .data = &mt8186_data_mm}, /* mm: m4u */ > + { .compatible = "mediatek,mt8188-iommu-infra", .data = &mt8188_data_infra}, > + { .compatible = "mediatek,mt8188-iommu-vdo", .data = &mt8188_data_vdo}, > + { .compatible = "mediatek,mt8188-iommu-vpp", .data = &mt8188_data_vpp}, > { .compatible = "mediatek,mt8192-m4u", .data = &mt8192_data}, > { .compatible = "mediatek,mt8195-iommu-infra", .data = &mt8195_data_infra}, > { .compatible = "mediatek,mt8195-iommu-vdo", .data = &mt8195_data_vdo}, > -- > 2.25.1 > >
On Tue, 2023-08-08 at 17:53 +0800, Chen-Yu Tsai wrote: > > External email : Please do not click links or open attachments until > you have verified the sender or the content. > On Fri, Jun 2, 2023 at 5:04 PM Yong Wu <yong.wu@mediatek.com> wrote: > > > > From: "Chengci.Xu" <chengci.xu@mediatek.com> > > > > MT8188 has 3 IOMMU, containing 2 MM IOMMUs, one is for vdo, the > other > > is for vpp. and 1 INFRA IOMMU. > > > > Signed-off-by: Chengci.Xu <chengci.xu@mediatek.com> > > Signed-off-by: Yong Wu <yong.wu@mediatek.com> > > Reviewed-by: AngeloGioacchino Del Regno < > angelogioacchino.delregno@collabora.com> > > --- > > drivers/iommu/mtk_iommu.c | 49 > +++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 49 insertions(+) > > > > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c > > index 9c89cf894a4d..5c66af0c45a8 100644 > > --- a/drivers/iommu/mtk_iommu.c > > +++ b/drivers/iommu/mtk_iommu.c > > @@ -170,6 +170,7 @@ enum mtk_iommu_plat { > > M4U_MT8173, > > M4U_MT8183, > > M4U_MT8186, > > + M4U_MT8188, > > M4U_MT8192, > > M4U_MT8195, > > M4U_MT8365, > > @@ -1593,6 +1594,51 @@ static const struct mtk_iommu_plat_data > mt8186_data_mm = { > > .iova_region_larb_msk = mt8186_larb_region_msk, > > }; > > > > +static const struct mtk_iommu_plat_data mt8188_data_infra = { > > + .m4u_plat = M4U_MT8188, > > + .flags = WR_THROT_EN | DCM_DISABLE | > STD_AXI_MODE | PM_CLK_AO | > > + MTK_IOMMU_TYPE_INFRA | > IFA_IOMMU_PCIE_SUPPORT | > > + PGTABLE_PA_35_EN | > CFG_IFA_MASTER_IN_ATF, > > FWIW, CFG_IFA_MASTER_IN_ATF should not be tied to the compatible > string, > but set via a DT property. The IOMMU controls are secured by > firmware. > It is not a property intrinsically tied to the hardware. The flag CFG_IFA_MASTER_IN_ATF means the registers which enable/disable iommu are in the secure world. If the master like pcie want to enable iommu, we have to enter secure world to configure it. It should be HW intrinsical, right? > > If on some other project there is no such security requirement and > the > IOMMU is opened up to non-secure world, and ATF not even having > support > for the SMC call, this becomes unusable and hard to rectify without > introducing a new compatible string. > > ChenYu > > > + .inv_sel_reg = REG_MMU_INV_SEL_GEN2, > > + .banks_num = 1, > > + .banks_enable = {true}, > > + .iova_region = single_domain, > > + .iova_region_nr = ARRAY_SIZE(single_domain), > > +}; > > + > > +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 | > > + WR_THROT_EN | IOVA_34_EN | SHARE_PGTABLE > | > > + PGTABLE_PA_35_EN | MTK_IOMMU_TYPE_MM, > > + .hw_list = &m4ulist, > > + .inv_sel_reg = REG_MMU_INV_SEL_GEN2, > > + .banks_num = 1, > > + .banks_enable = {true}, > > + .iova_region = mt8192_multi_dom, > > + .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), > > + .larbid_remap = {{2}, {0}, {21}, {0}, {19}, {9, 10, > > + 11 /* 11a */, 25 /* 11c */}, > > + {13, 0, 29 /* 16b */, 30 /* 17b */, 0}, > {5}}, > > +}; > > + > > +static const struct mtk_iommu_plat_data mt8188_data_vpp = { > > + .m4u_plat = M4U_MT8188, > > + .flags = HAS_BCLK | HAS_SUB_COMM_3BITS | > OUT_ORDER_WR_EN | > > + WR_THROT_EN | IOVA_34_EN | SHARE_PGTABLE > | > > + PGTABLE_PA_35_EN | MTK_IOMMU_TYPE_MM, > > + .hw_list = &m4ulist, > > + .inv_sel_reg = REG_MMU_INV_SEL_GEN2, > > + .banks_num = 1, > > + .banks_enable = {true}, > > + .iova_region = mt8192_multi_dom, > > + .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), > > + .larbid_remap = {{1}, {3}, {23}, {7}, > {MTK_INVALID_LARBID}, > > + {12, 15, 24 /* 11b */}, {14, > MTK_INVALID_LARBID, > > + 16 /* 16a */, 17 /* 17a */, > MTK_INVALID_LARBID, > > + 27, 28 /* ccu0 */, MTK_INVALID_LARBID}, > {4, 6}}, > > +}; > > + > > static const unsigned int > mt8192_larb_region_msk[MT8192_MULTI_REGION_NR_MAX][MTK_LARB_NR_MAX] = > { > > [0] = {~0, ~0}, /* Region0: larb0/1 > */ > > [1] = {0, 0, 0, 0, ~0, ~0, 0, ~0}, /* Region1: > larb4/5/7 */ > > @@ -1701,6 +1747,9 @@ static const struct of_device_id > mtk_iommu_of_ids[] = { > > { .compatible = "mediatek,mt8173-m4u", .data = > &mt8173_data}, > > { .compatible = "mediatek,mt8183-m4u", .data = > &mt8183_data}, > > { .compatible = "mediatek,mt8186-iommu-mm", .data = > &mt8186_data_mm}, /* mm: m4u */ > > + { .compatible = "mediatek,mt8188-iommu-infra", .data = > &mt8188_data_infra}, > > + { .compatible = "mediatek,mt8188-iommu-vdo", .data = > &mt8188_data_vdo}, > > + { .compatible = "mediatek,mt8188-iommu-vpp", .data = > &mt8188_data_vpp}, > > { .compatible = "mediatek,mt8192-m4u", .data = > &mt8192_data}, > > { .compatible = "mediatek,mt8195-iommu-infra", .data = > &mt8195_data_infra}, > > { .compatible = "mediatek,mt8195-iommu-vdo", .data = > &mt8195_data_vdo}, > > -- > > 2.25.1 > > > > >
On Thu, Aug 10, 2023 at 8:23 PM Yong Wu (吴勇) <Yong.Wu@mediatek.com> wrote: > > On Tue, 2023-08-08 at 17:53 +0800, Chen-Yu Tsai wrote: > > > > External email : Please do not click links or open attachments until > > you have verified the sender or the content. > > On Fri, Jun 2, 2023 at 5:04 PM Yong Wu <yong.wu@mediatek.com> wrote: > > > > > > From: "Chengci.Xu" <chengci.xu@mediatek.com> > > > > > > MT8188 has 3 IOMMU, containing 2 MM IOMMUs, one is for vdo, the > > other > > > is for vpp. and 1 INFRA IOMMU. > > > > > > Signed-off-by: Chengci.Xu <chengci.xu@mediatek.com> > > > Signed-off-by: Yong Wu <yong.wu@mediatek.com> > > > Reviewed-by: AngeloGioacchino Del Regno < > > angelogioacchino.delregno@collabora.com> > > > --- > > > drivers/iommu/mtk_iommu.c | 49 > > +++++++++++++++++++++++++++++++++++++++ > > > 1 file changed, 49 insertions(+) > > > > > > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c > > > index 9c89cf894a4d..5c66af0c45a8 100644 > > > --- a/drivers/iommu/mtk_iommu.c > > > +++ b/drivers/iommu/mtk_iommu.c > > > @@ -170,6 +170,7 @@ enum mtk_iommu_plat { > > > M4U_MT8173, > > > M4U_MT8183, > > > M4U_MT8186, > > > + M4U_MT8188, > > > M4U_MT8192, > > > M4U_MT8195, > > > M4U_MT8365, > > > @@ -1593,6 +1594,51 @@ static const struct mtk_iommu_plat_data > > mt8186_data_mm = { > > > .iova_region_larb_msk = mt8186_larb_region_msk, > > > }; > > > > > > +static const struct mtk_iommu_plat_data mt8188_data_infra = { > > > + .m4u_plat = M4U_MT8188, > > > + .flags = WR_THROT_EN | DCM_DISABLE | > > STD_AXI_MODE | PM_CLK_AO | > > > + MTK_IOMMU_TYPE_INFRA | > > IFA_IOMMU_PCIE_SUPPORT | > > > + PGTABLE_PA_35_EN | > > CFG_IFA_MASTER_IN_ATF, > > > > FWIW, CFG_IFA_MASTER_IN_ATF should not be tied to the compatible > > string, > > but set via a DT property. The IOMMU controls are secured by > > firmware. > > It is not a property intrinsically tied to the hardware. > > The flag CFG_IFA_MASTER_IN_ATF means the registers which enable/disable > iommu are in the secure world. If the master like pcie want to enable > iommu, we have to enter secure world to configure it. It should be HW > intrinsical, right? If I understand correctly, this is forced by setting some registers. The registers are set by the firmware at boot time. So if a different firmware that doesn't set the registers is used, then the IOMMU is available to non-secure kernel, correct? That's why I said that it should not be tied to a particular hardware platform, but set using a boolean device tree property. > > > > If on some other project there is no such security requirement and > > the > > IOMMU is opened up to non-secure world, and ATF not even having > > support > > for the SMC call, this becomes unusable and hard to rectify without > > introducing a new compatible string. > > > > ChenYu > > > > > + .inv_sel_reg = REG_MMU_INV_SEL_GEN2, > > > + .banks_num = 1, > > > + .banks_enable = {true}, > > > + .iova_region = single_domain, > > > + .iova_region_nr = ARRAY_SIZE(single_domain), > > > +}; > > > + > > > +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 | > > > + WR_THROT_EN | IOVA_34_EN | SHARE_PGTABLE > > | > > > + PGTABLE_PA_35_EN | MTK_IOMMU_TYPE_MM, > > > + .hw_list = &m4ulist, > > > + .inv_sel_reg = REG_MMU_INV_SEL_GEN2, > > > + .banks_num = 1, > > > + .banks_enable = {true}, > > > + .iova_region = mt8192_multi_dom, > > > + .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), > > > + .larbid_remap = {{2}, {0}, {21}, {0}, {19}, {9, 10, > > > + 11 /* 11a */, 25 /* 11c */}, > > > + {13, 0, 29 /* 16b */, 30 /* 17b */, 0}, > > {5}}, > > > +}; > > > + > > > +static const struct mtk_iommu_plat_data mt8188_data_vpp = { > > > + .m4u_plat = M4U_MT8188, > > > + .flags = HAS_BCLK | HAS_SUB_COMM_3BITS | > > OUT_ORDER_WR_EN | > > > + WR_THROT_EN | IOVA_34_EN | SHARE_PGTABLE > > | > > > + PGTABLE_PA_35_EN | MTK_IOMMU_TYPE_MM, > > > + .hw_list = &m4ulist, > > > + .inv_sel_reg = REG_MMU_INV_SEL_GEN2, > > > + .banks_num = 1, > > > + .banks_enable = {true}, > > > + .iova_region = mt8192_multi_dom, > > > + .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), > > > + .larbid_remap = {{1}, {3}, {23}, {7}, > > {MTK_INVALID_LARBID}, > > > + {12, 15, 24 /* 11b */}, {14, > > MTK_INVALID_LARBID, > > > + 16 /* 16a */, 17 /* 17a */, > > MTK_INVALID_LARBID, > > > + 27, 28 /* ccu0 */, MTK_INVALID_LARBID}, > > {4, 6}}, > > > +}; > > > + > > > static const unsigned int > > mt8192_larb_region_msk[MT8192_MULTI_REGION_NR_MAX][MTK_LARB_NR_MAX] = > > { > > > [0] = {~0, ~0}, /* Region0: larb0/1 > > */ > > > [1] = {0, 0, 0, 0, ~0, ~0, 0, ~0}, /* Region1: > > larb4/5/7 */ > > > @@ -1701,6 +1747,9 @@ static const struct of_device_id > > mtk_iommu_of_ids[] = { > > > { .compatible = "mediatek,mt8173-m4u", .data = > > &mt8173_data}, > > > { .compatible = "mediatek,mt8183-m4u", .data = > > &mt8183_data}, > > > { .compatible = "mediatek,mt8186-iommu-mm", .data = > > &mt8186_data_mm}, /* mm: m4u */ > > > + { .compatible = "mediatek,mt8188-iommu-infra", .data = > > &mt8188_data_infra}, > > > + { .compatible = "mediatek,mt8188-iommu-vdo", .data = > > &mt8188_data_vdo}, > > > + { .compatible = "mediatek,mt8188-iommu-vpp", .data = > > &mt8188_data_vpp}, > > > { .compatible = "mediatek,mt8192-m4u", .data = > > &mt8192_data}, > > > { .compatible = "mediatek,mt8195-iommu-infra", .data = > > &mt8195_data_infra}, > > > { .compatible = "mediatek,mt8195-iommu-vdo", .data = > > &mt8195_data_vdo}, > > > -- > > > 2.25.1 > > > > > > > >
On Fri, 2023-08-11 at 11:30 +0800, Chen-Yu Tsai wrote: > > External email : Please do not click links or open attachments until > you have verified the sender or the content. > On Thu, Aug 10, 2023 at 8:23 PM Yong Wu (吴勇) <Yong.Wu@mediatek.com> > wrote: > > > > On Tue, 2023-08-08 at 17:53 +0800, Chen-Yu Tsai wrote: > > > > > > External email : Please do not click links or open attachments > until > > > you have verified the sender or the content. > > > On Fri, Jun 2, 2023 at 5:04 PM Yong Wu <yong.wu@mediatek.com> > wrote: > > > > > > > > From: "Chengci.Xu" <chengci.xu@mediatek.com> > > > > > > > > MT8188 has 3 IOMMU, containing 2 MM IOMMUs, one is for vdo, the > > > other > > > > is for vpp. and 1 INFRA IOMMU. > > > > > > > > Signed-off-by: Chengci.Xu <chengci.xu@mediatek.com> > > > > Signed-off-by: Yong Wu <yong.wu@mediatek.com> > > > > Reviewed-by: AngeloGioacchino Del Regno < > > > angelogioacchino.delregno@collabora.com> > > > > --- > > > > drivers/iommu/mtk_iommu.c | 49 > > > +++++++++++++++++++++++++++++++++++++++ > > > > 1 file changed, 49 insertions(+) > > > > > > > > diff --git a/drivers/iommu/mtk_iommu.c > b/drivers/iommu/mtk_iommu.c > > > > index 9c89cf894a4d..5c66af0c45a8 100644 > > > > --- a/drivers/iommu/mtk_iommu.c > > > > +++ b/drivers/iommu/mtk_iommu.c > > > > @@ -170,6 +170,7 @@ enum mtk_iommu_plat { > > > > M4U_MT8173, > > > > M4U_MT8183, > > > > M4U_MT8186, > > > > + M4U_MT8188, > > > > M4U_MT8192, > > > > M4U_MT8195, > > > > M4U_MT8365, > > > > @@ -1593,6 +1594,51 @@ static const struct mtk_iommu_plat_data > > > mt8186_data_mm = { > > > > .iova_region_larb_msk = mt8186_larb_region_msk, > > > > }; > > > > > > > > +static const struct mtk_iommu_plat_data mt8188_data_infra = { > > > > + .m4u_plat = M4U_MT8188, > > > > + .flags = WR_THROT_EN | DCM_DISABLE | > > > STD_AXI_MODE | PM_CLK_AO | > > > > + MTK_IOMMU_TYPE_INFRA | > > > IFA_IOMMU_PCIE_SUPPORT | > > > > + PGTABLE_PA_35_EN | > > > CFG_IFA_MASTER_IN_ATF, > > > > > > FWIW, CFG_IFA_MASTER_IN_ATF should not be tied to the compatible > > > string, > > > but set via a DT property. The IOMMU controls are secured by > > > firmware. > > > It is not a property intrinsically tied to the hardware. > > > > The flag CFG_IFA_MASTER_IN_ATF means the registers which > enable/disable > > iommu are in the secure world. If the master like pcie want to > enable > > iommu, we have to enter secure world to configure it. It should be > HW > > intrinsical, right? > > If I understand correctly, this is forced by setting some registers. > The registers are set by the firmware at boot time. The register will be set before the masters that have the "iommus=" property probe. If the master doesn't have "iommus=" property in its dtsi node, this register won't be set, then its iommu will be disabled and it has to access continuous buffer. > > So if a different firmware that doesn't set the registers is used, > then the IOMMU is available to non-secure kernel, correct? No. The meaning of this register is whether to enable iommu. If the register are not set, the IOMMU for that master is disabled. > > That's why I said that it should not be tied to a particular hardware > platform, but set using a boolean device tree property. > > > > > > > If on some other project there is no such security requirement > and > > > the > > > IOMMU is opened up to non-secure world, and ATF not even having > > > support > > > for the SMC call, this becomes unusable and hard to rectify > without > > > introducing a new compatible string. > > > > > > ChenYu > > >
On Mon, Aug 14, 2023 at 3:14 PM Yong Wu (吴勇) <Yong.Wu@mediatek.com> wrote: > > On Fri, 2023-08-11 at 11:30 +0800, Chen-Yu Tsai wrote: > > > > External email : Please do not click links or open attachments until > > you have verified the sender or the content. > > On Thu, Aug 10, 2023 at 8:23 PM Yong Wu (吴勇) <Yong.Wu@mediatek.com> > > wrote: > > > > > > On Tue, 2023-08-08 at 17:53 +0800, Chen-Yu Tsai wrote: > > > > > > > > External email : Please do not click links or open attachments > > until > > > > you have verified the sender or the content. > > > > On Fri, Jun 2, 2023 at 5:04 PM Yong Wu <yong.wu@mediatek.com> > > wrote: > > > > > > > > > > From: "Chengci.Xu" <chengci.xu@mediatek.com> > > > > > > > > > > MT8188 has 3 IOMMU, containing 2 MM IOMMUs, one is for vdo, the > > > > other > > > > > is for vpp. and 1 INFRA IOMMU. > > > > > > > > > > Signed-off-by: Chengci.Xu <chengci.xu@mediatek.com> > > > > > Signed-off-by: Yong Wu <yong.wu@mediatek.com> > > > > > Reviewed-by: AngeloGioacchino Del Regno < > > > > angelogioacchino.delregno@collabora.com> > > > > > --- > > > > > drivers/iommu/mtk_iommu.c | 49 > > > > +++++++++++++++++++++++++++++++++++++++ > > > > > 1 file changed, 49 insertions(+) > > > > > > > > > > diff --git a/drivers/iommu/mtk_iommu.c > > b/drivers/iommu/mtk_iommu.c > > > > > index 9c89cf894a4d..5c66af0c45a8 100644 > > > > > --- a/drivers/iommu/mtk_iommu.c > > > > > +++ b/drivers/iommu/mtk_iommu.c > > > > > @@ -170,6 +170,7 @@ enum mtk_iommu_plat { > > > > > M4U_MT8173, > > > > > M4U_MT8183, > > > > > M4U_MT8186, > > > > > + M4U_MT8188, > > > > > M4U_MT8192, > > > > > M4U_MT8195, > > > > > M4U_MT8365, > > > > > @@ -1593,6 +1594,51 @@ static const struct mtk_iommu_plat_data > > > > mt8186_data_mm = { > > > > > .iova_region_larb_msk = mt8186_larb_region_msk, > > > > > }; > > > > > > > > > > +static const struct mtk_iommu_plat_data mt8188_data_infra = { > > > > > + .m4u_plat = M4U_MT8188, > > > > > + .flags = WR_THROT_EN | DCM_DISABLE | > > > > STD_AXI_MODE | PM_CLK_AO | > > > > > + MTK_IOMMU_TYPE_INFRA | > > > > IFA_IOMMU_PCIE_SUPPORT | > > > > > + PGTABLE_PA_35_EN | > > > > CFG_IFA_MASTER_IN_ATF, > > > > > > > > FWIW, CFG_IFA_MASTER_IN_ATF should not be tied to the compatible > > > > string, > > > > but set via a DT property. The IOMMU controls are secured by > > > > firmware. > > > > It is not a property intrinsically tied to the hardware. > > > > > > The flag CFG_IFA_MASTER_IN_ATF means the registers which > > enable/disable > > > iommu are in the secure world. If the master like pcie want to > > enable > > > iommu, we have to enter secure world to configure it. It should be > > HW > > > intrinsical, right? > > > > If I understand correctly, this is forced by setting some registers. > > The registers are set by the firmware at boot time. > > The register will be set before the masters that have the "iommus=" > property probe. If the master doesn't have "iommus=" property in its > dtsi node, this register won't be set, then its iommu will be disabled > and it has to access continuous buffer. > > > > > So if a different firmware that doesn't set the registers is used, > > then the IOMMU is available to non-secure kernel, correct? > > No. The meaning of this register is whether to enable iommu. If the > register are not set, the IOMMU for that master is disabled. For clarity, I'm referring to PERI_MST_PROT [1], not the registers in the IOMMU or LARBs. So not any of the registers used in this patch. If that register doesn't restrict access to IOMMU register space to secure only, then I assume it is controlled by fuses? [1] https://review.trustedfirmware.org/plugins/gitiles/TF-A/trusted-firmware-a/+/be457248c6b0a7f3c61bd95af58372938d13decd/plat/mediatek/drivers/iommu/mt8188/mtk_iommu_plat.c#93 > > > > That's why I said that it should not be tied to a particular hardware > > platform, but set using a boolean device tree property. > > > > > > > > > > If on some other project there is no such security requirement > > and > > > > the > > > > IOMMU is opened up to non-secure world, and ATF not even having > > > > support > > > > for the SMC call, this becomes unusable and hard to rectify > > without > > > > introducing a new compatible string. > > > > > > > > ChenYu > > > >
diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 9c89cf894a4d..5c66af0c45a8 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -170,6 +170,7 @@ enum mtk_iommu_plat { M4U_MT8173, M4U_MT8183, M4U_MT8186, + M4U_MT8188, M4U_MT8192, M4U_MT8195, M4U_MT8365, @@ -1593,6 +1594,51 @@ static const struct mtk_iommu_plat_data mt8186_data_mm = { .iova_region_larb_msk = mt8186_larb_region_msk, }; +static const struct mtk_iommu_plat_data mt8188_data_infra = { + .m4u_plat = M4U_MT8188, + .flags = WR_THROT_EN | DCM_DISABLE | STD_AXI_MODE | PM_CLK_AO | + MTK_IOMMU_TYPE_INFRA | IFA_IOMMU_PCIE_SUPPORT | + PGTABLE_PA_35_EN | CFG_IFA_MASTER_IN_ATF, + .inv_sel_reg = REG_MMU_INV_SEL_GEN2, + .banks_num = 1, + .banks_enable = {true}, + .iova_region = single_domain, + .iova_region_nr = ARRAY_SIZE(single_domain), +}; + +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 | + WR_THROT_EN | IOVA_34_EN | SHARE_PGTABLE | + PGTABLE_PA_35_EN | MTK_IOMMU_TYPE_MM, + .hw_list = &m4ulist, + .inv_sel_reg = REG_MMU_INV_SEL_GEN2, + .banks_num = 1, + .banks_enable = {true}, + .iova_region = mt8192_multi_dom, + .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), + .larbid_remap = {{2}, {0}, {21}, {0}, {19}, {9, 10, + 11 /* 11a */, 25 /* 11c */}, + {13, 0, 29 /* 16b */, 30 /* 17b */, 0}, {5}}, +}; + +static const struct mtk_iommu_plat_data mt8188_data_vpp = { + .m4u_plat = M4U_MT8188, + .flags = HAS_BCLK | HAS_SUB_COMM_3BITS | OUT_ORDER_WR_EN | + WR_THROT_EN | IOVA_34_EN | SHARE_PGTABLE | + PGTABLE_PA_35_EN | MTK_IOMMU_TYPE_MM, + .hw_list = &m4ulist, + .inv_sel_reg = REG_MMU_INV_SEL_GEN2, + .banks_num = 1, + .banks_enable = {true}, + .iova_region = mt8192_multi_dom, + .iova_region_nr = ARRAY_SIZE(mt8192_multi_dom), + .larbid_remap = {{1}, {3}, {23}, {7}, {MTK_INVALID_LARBID}, + {12, 15, 24 /* 11b */}, {14, MTK_INVALID_LARBID, + 16 /* 16a */, 17 /* 17a */, MTK_INVALID_LARBID, + 27, 28 /* ccu0 */, MTK_INVALID_LARBID}, {4, 6}}, +}; + static const unsigned int mt8192_larb_region_msk[MT8192_MULTI_REGION_NR_MAX][MTK_LARB_NR_MAX] = { [0] = {~0, ~0}, /* Region0: larb0/1 */ [1] = {0, 0, 0, 0, ~0, ~0, 0, ~0}, /* Region1: larb4/5/7 */ @@ -1701,6 +1747,9 @@ static const struct of_device_id mtk_iommu_of_ids[] = { { .compatible = "mediatek,mt8173-m4u", .data = &mt8173_data}, { .compatible = "mediatek,mt8183-m4u", .data = &mt8183_data}, { .compatible = "mediatek,mt8186-iommu-mm", .data = &mt8186_data_mm}, /* mm: m4u */ + { .compatible = "mediatek,mt8188-iommu-infra", .data = &mt8188_data_infra}, + { .compatible = "mediatek,mt8188-iommu-vdo", .data = &mt8188_data_vdo}, + { .compatible = "mediatek,mt8188-iommu-vpp", .data = &mt8188_data_vpp}, { .compatible = "mediatek,mt8192-m4u", .data = &mt8192_data}, { .compatible = "mediatek,mt8195-iommu-infra", .data = &mt8195_data_infra}, { .compatible = "mediatek,mt8195-iommu-vdo", .data = &mt8195_data_vdo},