All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yong Wu (吴勇)" <Yong.Wu@mediatek.com>
To: "wenst@chromium.org" <wenst@chromium.org>
Cc: "linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"Jianjiao Zeng (曾健姣)" <Jianjiao.Zeng@mediatek.com>,
	"robin.murphy@arm.com" <robin.murphy@arm.com>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"Chengci Xu (许承赐)" <Chengci.Xu@mediatek.com>,
	"YF Wang (王云飞)" <YF.Wang@mediatek.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	"krzysztof.kozlowski+dt@linaro.org"
	<krzysztof.kozlowski+dt@linaro.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"Mingyuan Ma (马鸣远)" <Mingyuan.Ma@mediatek.com>,
	"angelogioacchino.delregno@collabora.com"
	<angelogioacchino.delregno@collabora.com>,
	"will@kernel.org" <will@kernel.org>
Subject: Re: [PATCH v12 5/7] iommu/mediatek: Add MT8188 IOMMU Support
Date: Thu, 10 Aug 2023 12:22:53 +0000	[thread overview]
Message-ID: <b695962fa3c3baac08f8be5202e6a5697e7826a0.camel@mediatek.com> (raw)
In-Reply-To: <CAGXv+5EKwvn-axETPcuxTpxRkUGLroymeDYL+kr4QW8duAymmQ@mail.gmail.com>

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
> >
> >
> 

WARNING: multiple messages have this Message-ID (diff)
From: "Yong Wu (吴勇)" <Yong.Wu@mediatek.com>
To: "wenst@chromium.org" <wenst@chromium.org>
Cc: "linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"Jianjiao Zeng (曾健姣)" <Jianjiao.Zeng@mediatek.com>,
	"robin.murphy@arm.com" <robin.murphy@arm.com>,
	"joro@8bytes.org" <joro@8bytes.org>,
	"Chengci Xu (许承赐)" <Chengci.Xu@mediatek.com>,
	"YF Wang (王云飞)" <YF.Wang@mediatek.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	"krzysztof.kozlowski+dt@linaro.org"
	<krzysztof.kozlowski+dt@linaro.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"Mingyuan Ma (马鸣远)" <Mingyuan.Ma@mediatek.com>,
	"angelogioacchino.delregno@collabora.com"
	<angelogioacchino.delregno@collabora.com>,
	"will@kernel.org" <will@kernel.org>
Subject: Re: [PATCH v12 5/7] iommu/mediatek: Add MT8188 IOMMU Support
Date: Thu, 10 Aug 2023 12:22:53 +0000	[thread overview]
Message-ID: <b695962fa3c3baac08f8be5202e6a5697e7826a0.camel@mediatek.com> (raw)
In-Reply-To: <CAGXv+5EKwvn-axETPcuxTpxRkUGLroymeDYL+kr4QW8duAymmQ@mail.gmail.com>

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
> >
> >
> 
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-08-10 12:23 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-02  9:02 [PATCH v12 0/7] MT8188 IOMMU SUPPORT Yong Wu
2023-06-02  9:02 ` Yong Wu
2023-06-02  9:02 ` [PATCH v12 1/7] dt-bindings: mediatek: mt8188: Add binding for MM & INFRA IOMMU Yong Wu
2023-06-02  9:02   ` Yong Wu
2023-08-17  8:21   ` Chen-Yu Tsai
2023-08-17  8:21     ` Chen-Yu Tsai
2023-06-02  9:02 ` [PATCH v12 2/7] iommu/mediatek: Fix two IOMMU share pagetable issue Yong Wu
2023-06-02  9:02   ` Yong Wu
2023-06-06 13:59   ` Alexandre Mergnat
2023-06-06 13:59     ` Alexandre Mergnat
2023-08-18 15:41   ` Laura Nao
2023-08-18 15:41     ` Laura Nao
2023-08-19  8:45     ` Yong Wu (吴勇)
2023-08-19  8:45       ` Yong Wu (吴勇)
2023-06-02  9:02 ` [PATCH v12 3/7] iommu/mediatek: Adjust mtk_iommu_config flow Yong Wu
2023-06-02  9:02   ` Yong Wu
2023-06-06 14:00   ` Alexandre Mergnat
2023-06-06 14:00     ` Alexandre Mergnat
2023-06-02  9:02 ` [PATCH v12 4/7] iommu/mediatek: Add enable IOMMU SMC command for INFRA masters Yong Wu
2023-06-02  9:02   ` Yong Wu
2023-06-06 14:04   ` Alexandre Mergnat
2023-06-06 14:04     ` Alexandre Mergnat
2023-06-02  9:02 ` [PATCH v12 5/7] iommu/mediatek: Add MT8188 IOMMU Support Yong Wu
2023-06-02  9:02   ` Yong Wu
2023-06-06 14:16   ` Alexandre Mergnat
2023-06-06 14:16     ` Alexandre Mergnat
2023-08-08  9:53   ` Chen-Yu Tsai
2023-08-08  9:53     ` Chen-Yu Tsai
2023-08-10 12:22     ` Yong Wu (吴勇) [this message]
2023-08-10 12:22       ` Yong Wu (吴勇)
2023-08-11  3:30       ` Chen-Yu Tsai
2023-08-11  3:30         ` Chen-Yu Tsai
2023-08-14  7:14         ` Yong Wu (吴勇)
2023-08-14  7:14           ` Yong Wu (吴勇)
2023-08-14  8:21           ` Chen-Yu Tsai
2023-08-14  8:21             ` Chen-Yu Tsai
2023-08-17  8:01             ` Yong Wu (吴勇)
2023-08-17  8:01               ` Yong Wu (吴勇)
2023-08-17  8:10               ` Chen-Yu Tsai
2023-08-17  8:10                 ` Chen-Yu Tsai
2023-06-02  9:02 ` [PATCH v12 6/7] iommu/mediatek: mt8188: Add iova_region_larb_msk Yong Wu
2023-06-02  9:02   ` Yong Wu
2023-06-06 14:19   ` Alexandre Mergnat
2023-06-06 14:19     ` Alexandre Mergnat
2023-06-02  9:02 ` [PATCH v12 7/7] MAINTAINERS: iommu/mediatek: Update the header file name Yong Wu
2023-06-02  9:02   ` Yong Wu
2023-07-25  7:59 ` [PATCH v12 0/7] MT8188 IOMMU SUPPORT Fei Shao
     [not found]   ` <cc910b5c3ec130f092a37049d71bb35c20b278a6.camel@mediatek.com>
2023-08-07 12:17     ` joro
2023-08-07 12:17       ` joro
2023-08-07 12:17       ` joro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b695962fa3c3baac08f8be5202e6a5697e7826a0.camel@mediatek.com \
    --to=yong.wu@mediatek.com \
    --cc=Chengci.Xu@mediatek.com \
    --cc=Jianjiao.Zeng@mediatek.com \
    --cc=Mingyuan.Ma@mediatek.com \
    --cc=YF.Wang@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=devicetree@vger.kernel.org \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=wenst@chromium.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.