linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2 2/3] iommu/mediatek: Add enable IOMMU SMC command for INFRA master
       [not found] ` <20220831125502.7818-3-chengci.xu@mediatek.com>
@ 2022-09-02  9:00   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-09-02  9:00 UTC (permalink / raw)
  To: Chengci.Xu, Yong Wu, Joerg Roedel, Will Deacon, Robin Murphy,
	Rob Herring, Krzysztof Kozlowski, Matthias Brugger
  Cc: iommu, linux-mediatek, devicetree, linux-kernel,
	linux-arm-kernel, Project_Global_Chrome_Upstream_Group

Il 31/08/22 14:55, Chengci.Xu ha scritto:
> The register which can enable IOMMU for INFRA master should be setted
> in secure world for security concerns. Therefore, we add a SMC command
> for INFRA master to enable/disable INFRA IOMMU in ATF. This function is
> prepared for MT8188.
> 
> Signed-off-by: Chengci.Xu <chengci.xu@mediatek.com>
> ---
>   drivers/iommu/mtk_iommu.c  | 34 ++++++++++++++++++++++++++--------
>   include/soc/mediatek/smi.h |  1 +
>   2 files changed, 27 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> index 7e363b1f24df..6fe780783ec8 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -3,6 +3,7 @@
>    * Copyright (c) 2015-2016 MediaTek Inc.
>    * Author: Yong Wu <yong.wu@mediatek.com>
>    */
> +#include <linux/arm-smccc.h>
>   #include <linux/bitfield.h>
>   #include <linux/bug.h>
>   #include <linux/clk.h>
> @@ -28,6 +29,7 @@
>   #include <linux/slab.h>
>   #include <linux/spinlock.h>
>   #include <linux/soc/mediatek/infracfg.h>
> +#include <linux/soc/mediatek/mtk_sip_svc.h>
>   #include <asm/barrier.h>
>   #include <soc/mediatek/smi.h>
>   
> @@ -138,6 +140,7 @@
>   #define PM_CLK_AO			BIT(15)
>   #define IFA_IOMMU_PCIE_SUPPORT		BIT(16)
>   #define PGTABLE_PA_35_EN		BIT(17)
> +#define CFG_IFA_MASTER_IN_ATF		BIT(18)
>   
>   #define MTK_IOMMU_HAS_FLAG_MASK(pdata, _x, mask)	\
>   				((((pdata)->flags) & (mask)) == (_x))
> @@ -554,14 +557,29 @@ static int mtk_iommu_config(struct mtk_iommu_data *data, struct device *dev,
>   			else
>   				larb_mmu->mmu &= ~MTK_SMI_MMU_EN(portid);
>   		} else if (MTK_IOMMU_IS_TYPE(data->plat_data, MTK_IOMMU_TYPE_INFRA)) {
> -			peri_mmuen_msk = BIT(portid);
> -			/* PCI dev has only one output id, enable the next writing bit for PCIe */
> -			if (dev_is_pci(dev))
> -				peri_mmuen_msk |= BIT(portid + 1);
> -
> -			peri_mmuen = enable ? peri_mmuen_msk : 0;
> -			ret = regmap_update_bits(data->pericfg, PERICFG_IOMMU_1,
> -						 peri_mmuen_msk, peri_mmuen);
> +			if (MTK_IOMMU_HAS_FLAG(data->plat_data, CFG_IFA_MASTER_IN_ATF)) {
> +				struct arm_smccc_res res;
> +
> +				portid = MTK_M4U_TO_PORT(fwspec->ids[i]);

This assignment is redundant, as portid is initialized to the same value
just a few lines before. Please drop it.

Everything else looks good.

Regards,
Angelo

> +				arm_smccc_smc(MTK_SIP_KERNEL_IOMMU_CONTROL,
> +					      IOMMU_ATF_CMD_CONFIG_INFRA_IOMMU,
> +					      portid, enable, 0, 0, 0, 0, &res);
> +				ret = (int)res.a0;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 3/3] iommu/mediatek: Add MT8188 IOMMU Support
       [not found] ` <20220831125502.7818-4-chengci.xu@mediatek.com>
@ 2022-09-02  9:04   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2022-09-02  9:04 UTC (permalink / raw)
  To: Chengci.Xu, Yong Wu, Joerg Roedel, Will Deacon, Robin Murphy,
	Rob Herring, Krzysztof Kozlowski, Matthias Brugger
  Cc: iommu, linux-mediatek, devicetree, linux-kernel,
	linux-arm-kernel, Project_Global_Chrome_Upstream_Group

Il 31/08/22 14:55, Chengci.Xu ha scritto:
> 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>
> ---
>   drivers/iommu/mtk_iommu.c | 48 +++++++++++++++++++++++++++++++++++++++
>   1 file changed, 48 insertions(+)
> 
> diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> index 6fe780783ec8..98c2eae5229e 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -164,6 +164,7 @@ enum mtk_iommu_plat {
>   	M4U_MT8173,
>   	M4U_MT8183,
>   	M4U_MT8186,
> +	M4U_MT8188,
>   	M4U_MT8192,
>   	M4U_MT8195,
>   };
> @@ -1479,6 +1480,50 @@ static const struct mtk_iommu_plat_data mt8186_data_mm = {
>   	.iova_region_nr = ARRAY_SIZE(mt8192_multi_dom),
>   };
>   
> +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 |
> +			    CFG_IFA_MASTER_IN_ATF,
> +	.pericfg_comp_str = "mediatek,mt8188-pericfg_ao",

pericfg_comp_str is used only for IOMMU enable from Linux, but MT8188 enables it
with a SMC command, so this is unused.

Please drop it.

> +	.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),
> +};
> +

Regards,
Angelo


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/3] dt-bindings: mediatek: mt8188: Add binding for MM & INFRA IOMMU
       [not found] ` <20220831125502.7818-2-chengci.xu@mediatek.com>
@ 2022-09-08 10:49   ` Krzysztof Kozlowski
       [not found]     ` <c09f262422dd6cd0bf2147870a109bd2ede36d4f.camel@mediatek.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Kozlowski @ 2022-09-08 10:49 UTC (permalink / raw)
  To: Chengci.Xu, Yong Wu, Joerg Roedel, Will Deacon, Robin Murphy,
	Rob Herring, Krzysztof Kozlowski, Matthias Brugger
  Cc: iommu, linux-mediatek, devicetree, linux-kernel,
	linux-arm-kernel, Project_Global_Chrome_Upstream_Group

On 31/08/2022 14:55, Chengci.Xu wrote:
> This patch adds descriptions for mt8188 IOMMU which also use ARM
> Short-Descriptor translation table format.

Do not use "This commit/patch".
https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95

>  
>      then:
>        required:
> diff --git a/include/dt-bindings/memory/mediatek,mt8188-memory-port.h b/include/dt-bindings/memory/mediatek,mt8188-memory-port.h
> new file mode 100644
> index 000000000000..9363e132c43a
> --- /dev/null
> +++ b/include/dt-bindings/memory/mediatek,mt8188-memory-port.h
> @@ -0,0 +1,482 @@
> +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */

Why do you license it under BSD-3 clause?

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/3] dt-bindings: mediatek: mt8188: Add binding for MM & INFRA IOMMU
       [not found]     ` <c09f262422dd6cd0bf2147870a109bd2ede36d4f.camel@mediatek.com>
@ 2022-09-09  7:11       ` Krzysztof Kozlowski
  0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2022-09-09  7:11 UTC (permalink / raw)
  To: Chengci.Xu, Yong Wu, Joerg Roedel, Will Deacon, Robin Murphy,
	Rob Herring, Krzysztof Kozlowski, Matthias Brugger
  Cc: iommu, linux-mediatek, devicetree, linux-kernel,
	linux-arm-kernel, Project_Global_Chrome_Upstream_Group

On 09/09/2022 05:20, Chengci.Xu wrote:
>>> +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
>>
>> Why do you license it under BSD-3 clause?
>>
> 
> A mediatek internal wiki suggest me use "BSD-3-Clause" without detial
> reason. May be it is not suitable for this file.
> 
> If you don't approve of this, I can change this license to "GPL-2.0-
> only OR BSD-2-Clause", which is perferred by DT bindings file according
> to "submitting-patches.rst". 
> 
> Do you think "BSD-2-Clause" is OK? Or could you kindly share me another
> proper license?

Please switch to "GPL-2.0-only OR BSD-2-Clause", which is preferred for
bindings.


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-09  7:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20220831125502.7818-1-chengci.xu@mediatek.com>
     [not found] ` <20220831125502.7818-3-chengci.xu@mediatek.com>
2022-09-02  9:00   ` [PATCH v2 2/3] iommu/mediatek: Add enable IOMMU SMC command for INFRA master AngeloGioacchino Del Regno
     [not found] ` <20220831125502.7818-4-chengci.xu@mediatek.com>
2022-09-02  9:04   ` [PATCH v2 3/3] iommu/mediatek: Add MT8188 IOMMU Support AngeloGioacchino Del Regno
     [not found] ` <20220831125502.7818-2-chengci.xu@mediatek.com>
2022-09-08 10:49   ` [PATCH v2 1/3] dt-bindings: mediatek: mt8188: Add binding for MM & INFRA IOMMU Krzysztof Kozlowski
     [not found]     ` <c09f262422dd6cd0bf2147870a109bd2ede36d4f.camel@mediatek.com>
2022-09-09  7:11       ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).