diff mbox series

[v6,12/15] media: mtk-vcodec: Support 34bits dma address for vdec

Message ID 20210901083215.25984-13-yunfei.dong@mediatek.com (mailing list archive)
State New, archived
Headers show
Series Using component framework to support multi hardware decode | expand

Commit Message

Yunfei Dong Sept. 1, 2021, 8:32 a.m. UTC
Use the dma_set_mask_and_coherent helper to set vdec
DMA bit mask to support 34bits iova space(16GB) that
the mt8192 iommu HW support.

Whole the iova range separate to 0~4G/4G~8G/8G~12G/12G~16G,
regarding which iova range VDEC actually locate, it
depends on the dma-ranges property of vdec dtsi node.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Benjamin Gaignard Oct. 7, 2021, 11:37 a.m. UTC | #1
Le 01/09/2021 à 10:32, Yunfei Dong a écrit :
> Use the dma_set_mask_and_coherent helper to set vdec
> DMA bit mask to support 34bits iova space(16GB) that
> the mt8192 iommu HW support.
>
> Whole the iova range separate to 0~4G/4G~8G/8G~12G/12G~16G,
> regarding which iova range VDEC actually locate, it
> depends on the dma-ranges property of vdec dtsi node.
>
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> ---
>   drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> index 002352fcf8de..1a8d9308327d 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> @@ -417,6 +417,9 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
>   		}
>   	}
>   
> +	if (of_get_property(pdev->dev.of_node, "dma-ranges", NULL))
> +		dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34));
> +

Hi Yunfei,

Does all SoC support 34bits iova space ?
If not you need to also check SoC version before setting dma mask.

Regards,
Benjamin

>   	for (i = 0; i < MTK_VDEC_HW_MAX; i++)
>   		mutex_init(&dev->dec_mutex[i]);
>   	spin_lock_init(&dev->irqlock);
Yunfei Dong Oct. 11, 2021, 5:42 a.m. UTC | #2
Hi Benjiamin,


On Thu, 2021-10-07 at 13:37 +0200, Benjamin Gaignard wrote:
> Le 01/09/2021 à 10:32, Yunfei Dong a écrit :
> > Use the dma_set_mask_and_coherent helper to set vdec
> > DMA bit mask to support 34bits iova space(16GB) that
> > the mt8192 iommu HW support.
> > 
> > Whole the iova range separate to 0~4G/4G~8G/8G~12G/12G~16G,
> > regarding which iova range VDEC actually locate, it
> > depends on the dma-ranges property of vdec dtsi node.
> > 
> > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> > ---
> >   drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 3 +++
> >   1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
> > b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> > index 002352fcf8de..1a8d9308327d 100644
> > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
> > @@ -417,6 +417,9 @@ static int mtk_vcodec_probe(struct
> > platform_device *pdev)
> >   		}
> >   	}
> >   
> > +	if (of_get_property(pdev->dev.of_node, "dma-ranges", NULL))
> > +		dma_set_mask_and_coherent(&pdev->dev,
> > DMA_BIT_MASK(34));
> > +
> 
> Hi Yunfei,
> 
> Does all SoC support 34bits iova space ?
> If not you need to also check SoC version before setting dma mask.
> 
Not all SoC support 34bits. Will add dma-ranges property in dtsi if the
SoC support 34bits.

like this:
dma-ranges = <>;

Thanks,
Yunfei Dong
> Regards,
> Benjamin
> 
> >   	for (i = 0; i < MTK_VDEC_HW_MAX; i++)
> >   		mutex_init(&dev->dec_mutex[i]);
> >   	spin_lock_init(&dev->irqlock);
diff mbox series

Patch

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 002352fcf8de..1a8d9308327d 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -417,6 +417,9 @@  static int mtk_vcodec_probe(struct platform_device *pdev)
 		}
 	}
 
+	if (of_get_property(pdev->dev.of_node, "dma-ranges", NULL))
+		dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34));
+
 	for (i = 0; i < MTK_VDEC_HW_MAX; i++)
 		mutex_init(&dev->dec_mutex[i]);
 	spin_lock_init(&dev->irqlock);