linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/mediatek: Fix share pgtable for iova over 4GB
@ 2023-08-19  8:14 Yong Wu
  2023-08-21 14:42 ` Laura Nao
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Yong Wu @ 2023-08-19  8:14 UTC (permalink / raw)
  To: Joerg Roedel, Will Deacon, Matthias Brugger
  Cc: Robin Murphy, AngeloGioacchino Del Regno, Yong Wu, iommu,
	linux-mediatek, linux-kernel, linux-arm-kernel, Laura Nao

In mt8192/mt8186, there is only one MM IOMMU that supports 16GB iova
space, which is shared by display, vcodec and camera. These two SoC use
one pgtable and have not the flag SHARE_PGTABLE, we should also keep
share pgtable for this case.

In mtk_iommu_domain_finalise, MM IOMMU always share pgtable, thus remove
the flag SHARE_PGTABLE checking. Infra IOMMU always uses independent
pgtable.

Fixes: cf69ef46dbd9 ("iommu/mediatek: Fix two IOMMU share pagetable issue")
Reported-by: Laura Nao <laura.nao@collabora.com>
Closes: https://lore.kernel.org/linux-iommu/20230818154156.314742-1-laura.nao@collabora.com/
Signed-off-by: Yong Wu <yong.wu@mediatek.com>
---
Base on next-20230818.
---
 drivers/iommu/mtk_iommu.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index b17d3e7288a7..b5fcba305d2a 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -262,7 +262,7 @@ struct mtk_iommu_data {
 	struct device			*smicomm_dev;
 
 	struct mtk_iommu_bank_data	*bank;
-	struct mtk_iommu_domain		*share_dom; /* For 2 HWs share pgtable */
+	struct mtk_iommu_domain		*share_dom;
 
 	struct regmap			*pericfg;
 	struct mutex			mutex; /* Protect m4u_group/m4u_dom above */
@@ -643,8 +643,8 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom,
 	struct mtk_iommu_domain	*share_dom = data->share_dom;
 	const struct mtk_iommu_iova_region *region;
 
-	/* Always use share domain in sharing pgtable case */
-	if (MTK_IOMMU_HAS_FLAG(data->plat_data, SHARE_PGTABLE) && share_dom) {
+	/* Share pgtable when 2 MM IOMMU share the pgtable or one IOMMU use multiple iova ranges */
+	if (share_dom) {
 		dom->iop = share_dom->iop;
 		dom->cfg = share_dom->cfg;
 		dom->domain.pgsize_bitmap = share_dom->cfg.pgsize_bitmap;
@@ -677,8 +677,7 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom,
 	/* Update our support page sizes bitmap */
 	dom->domain.pgsize_bitmap = dom->cfg.pgsize_bitmap;
 
-	if (MTK_IOMMU_HAS_FLAG(data->plat_data, SHARE_PGTABLE))
-		data->share_dom = dom;
+	data->share_dom = dom;
 
 update_iova_region:
 	/* Update the iova region for this domain */
-- 
2.25.1



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

* Re: [PATCH] iommu/mediatek: Fix share pgtable for iova over 4GB
  2023-08-19  8:14 [PATCH] iommu/mediatek: Fix share pgtable for iova over 4GB Yong Wu
@ 2023-08-21 14:42 ` Laura Nao
  2023-09-07  8:22 ` AngeloGioacchino Del Regno
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Laura Nao @ 2023-08-21 14:42 UTC (permalink / raw)
  To: yong.wu
  Cc: angelogioacchino.delregno, iommu, joro, laura.nao,
	linux-arm-kernel, linux-kernel, linux-mediatek, matthias.bgg,
	robin.murphy, will, kernel

Hello,

I confirm this fixes decoding on MT8192 and fluster tests are passing again (tested on spherion with next-20230821).

Please note that I was only able to test this patch on MT8192 at the moment.

The regression was originally reported by KernelCI, so:

Reported-by: "kernelci.org bot" <bot@kernelci.org>
Tested-by: Laura Nao <laura.nao@collabora.com>

Thank you!

Laura



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

* Re: [PATCH] iommu/mediatek: Fix share pgtable for iova over 4GB
  2023-08-19  8:14 [PATCH] iommu/mediatek: Fix share pgtable for iova over 4GB Yong Wu
  2023-08-21 14:42 ` Laura Nao
@ 2023-09-07  8:22 ` AngeloGioacchino Del Regno
  2023-09-22  8:11 ` AngeloGioacchino Del Regno
  2023-09-25  9:34 ` Joerg Roedel
  3 siblings, 0 replies; 5+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-09-07  8:22 UTC (permalink / raw)
  To: Yong Wu, Joerg Roedel, Will Deacon, Matthias Brugger
  Cc: Robin Murphy, iommu, linux-mediatek, linux-kernel,
	linux-arm-kernel, Laura Nao

Il 19/08/23 10:14, Yong Wu ha scritto:
> In mt8192/mt8186, there is only one MM IOMMU that supports 16GB iova
> space, which is shared by display, vcodec and camera. These two SoC use
> one pgtable and have not the flag SHARE_PGTABLE, we should also keep
> share pgtable for this case.
> 
> In mtk_iommu_domain_finalise, MM IOMMU always share pgtable, thus remove
> the flag SHARE_PGTABLE checking. Infra IOMMU always uses independent
> pgtable.
> 
> Fixes: cf69ef46dbd9 ("iommu/mediatek: Fix two IOMMU share pagetable issue")
> Reported-by: Laura Nao <laura.nao@collabora.com>
> Closes: https://lore.kernel.org/linux-iommu/20230818154156.314742-1-laura.nao@collabora.com/
> Signed-off-by: Yong Wu <yong.wu@mediatek.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

This is urgent. Fixes multiple machines.

> ---
> Base on next-20230818.
> ---
>   drivers/iommu/mtk_iommu.c | 9 ++++-----
>   1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> index b17d3e7288a7..b5fcba305d2a 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -262,7 +262,7 @@ struct mtk_iommu_data {
>   	struct device			*smicomm_dev;
>   
>   	struct mtk_iommu_bank_data	*bank;
> -	struct mtk_iommu_domain		*share_dom; /* For 2 HWs share pgtable */
> +	struct mtk_iommu_domain		*share_dom;
>   
>   	struct regmap			*pericfg;
>   	struct mutex			mutex; /* Protect m4u_group/m4u_dom above */
> @@ -643,8 +643,8 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom,
>   	struct mtk_iommu_domain	*share_dom = data->share_dom;
>   	const struct mtk_iommu_iova_region *region;
>   
> -	/* Always use share domain in sharing pgtable case */
> -	if (MTK_IOMMU_HAS_FLAG(data->plat_data, SHARE_PGTABLE) && share_dom) {
> +	/* Share pgtable when 2 MM IOMMU share the pgtable or one IOMMU use multiple iova ranges */
> +	if (share_dom) {
>   		dom->iop = share_dom->iop;
>   		dom->cfg = share_dom->cfg;
>   		dom->domain.pgsize_bitmap = share_dom->cfg.pgsize_bitmap;
> @@ -677,8 +677,7 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom,
>   	/* Update our support page sizes bitmap */
>   	dom->domain.pgsize_bitmap = dom->cfg.pgsize_bitmap;
>   
> -	if (MTK_IOMMU_HAS_FLAG(data->plat_data, SHARE_PGTABLE))
> -		data->share_dom = dom;
> +	data->share_dom = dom;
>   
>   update_iova_region:
>   	/* Update the iova region for this domain */




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

* Re: [PATCH] iommu/mediatek: Fix share pgtable for iova over 4GB
  2023-08-19  8:14 [PATCH] iommu/mediatek: Fix share pgtable for iova over 4GB Yong Wu
  2023-08-21 14:42 ` Laura Nao
  2023-09-07  8:22 ` AngeloGioacchino Del Regno
@ 2023-09-22  8:11 ` AngeloGioacchino Del Regno
  2023-09-25  9:34 ` Joerg Roedel
  3 siblings, 0 replies; 5+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-09-22  8:11 UTC (permalink / raw)
  To: Yong Wu, Joerg Roedel, Will Deacon, Matthias Brugger
  Cc: Robin Murphy, iommu, linux-mediatek, linux-kernel,
	linux-arm-kernel, Laura Nao

Il 19/08/23 10:14, Yong Wu ha scritto:
> In mt8192/mt8186, there is only one MM IOMMU that supports 16GB iova
> space, which is shared by display, vcodec and camera. These two SoC use
> one pgtable and have not the flag SHARE_PGTABLE, we should also keep
> share pgtable for this case.
> 
> In mtk_iommu_domain_finalise, MM IOMMU always share pgtable, thus remove
> the flag SHARE_PGTABLE checking. Infra IOMMU always uses independent
> pgtable.
> 
> Fixes: cf69ef46dbd9 ("iommu/mediatek: Fix two IOMMU share pagetable issue")
> Reported-by: Laura Nao <laura.nao@collabora.com>
> Closes: https://lore.kernel.org/linux-iommu/20230818154156.314742-1-laura.nao@collabora.com/
> Signed-off-by: Yong Wu <yong.wu@mediatek.com>
> ---
> Base on next-20230818.
> ---
>   drivers/iommu/mtk_iommu.c | 9 ++++-----
>   1 file changed, 4 insertions(+), 5 deletions(-)

Gentle ping for an important fix.

Thanks,
Angelo



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

* Re: [PATCH] iommu/mediatek: Fix share pgtable for iova over 4GB
  2023-08-19  8:14 [PATCH] iommu/mediatek: Fix share pgtable for iova over 4GB Yong Wu
                   ` (2 preceding siblings ...)
  2023-09-22  8:11 ` AngeloGioacchino Del Regno
@ 2023-09-25  9:34 ` Joerg Roedel
  3 siblings, 0 replies; 5+ messages in thread
From: Joerg Roedel @ 2023-09-25  9:34 UTC (permalink / raw)
  To: Yong Wu
  Cc: Will Deacon, Matthias Brugger, Robin Murphy,
	AngeloGioacchino Del Regno, iommu, linux-mediatek, linux-kernel,
	linux-arm-kernel, Laura Nao

On Sat, Aug 19, 2023 at 04:14:43PM +0800, Yong Wu wrote:
> Fixes: cf69ef46dbd9 ("iommu/mediatek: Fix two IOMMU share pagetable issue")
> Reported-by: Laura Nao <laura.nao@collabora.com>
> Closes: https://lore.kernel.org/linux-iommu/20230818154156.314742-1-laura.nao@collabora.com/
> Signed-off-by: Yong Wu <yong.wu@mediatek.com>
> ---
> Base on next-20230818.
> ---

Applied for v6.6, thanks.


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

end of thread, other threads:[~2023-09-25  9:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-19  8:14 [PATCH] iommu/mediatek: Fix share pgtable for iova over 4GB Yong Wu
2023-08-21 14:42 ` Laura Nao
2023-09-07  8:22 ` AngeloGioacchino Del Regno
2023-09-22  8:11 ` AngeloGioacchino Del Regno
2023-09-25  9:34 ` Joerg Roedel

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