Re: [PATCH v2 05/12] media: mtk-jpeg: Get rid of mtk_smi_larb_get/put

From: Yong Wu
Date: Fri Jun 21 2019 - 22:42:59 EST


On Thu, 2019-06-20 at 17:20 +0200, Matthias Brugger wrote:
>
> On 10/06/2019 14:55, Yong Wu wrote:
> > MediaTek IOMMU has already added device_link between the consumer
> > and smi-larb device. If the jpg device call the pm_runtime_get_sync,
> > the smi-larb's pm_runtime_get_sync also be called automatically.
>
> Please help me out find this relation. I seem to miss something basic, because I
> can't find any between the jpeg IP and the iommu.

JPEG also is a multimedia consumer. It also access memory via IOMMU. All
the current SoC have the JPG smi ports.

grep -r JPG include/dt-bindings/memory/mt*

>
> Regards,
> Matthias
>
> >
> > CC: Rick Chang <rick.chang@xxxxxxxxxxxx>
> > Signed-off-by: Yong Wu <yong.wu@xxxxxxxxxxxx>
> > Reviewed-by: Evan Green <evgreen@xxxxxxxxxxxx>
> > ---
> > drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | 22 ----------------------
> > drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h | 2 --
> > 2 files changed, 24 deletions(-)
> >
> > diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
> > index f761e4d..2f37538 100644
> > --- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
> > +++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
> > @@ -29,7 +29,6 @@
> > #include <media/v4l2-ioctl.h>
> > #include <media/videobuf2-core.h>
> > #include <media/videobuf2-dma-contig.h>
> > -#include <soc/mediatek/smi.h>
> >
> > #include "mtk_jpeg_hw.h"
> > #include "mtk_jpeg_core.h"
> > @@ -901,11 +900,6 @@ static int mtk_jpeg_queue_init(void *priv, struct vb2_queue *src_vq,
> >
> > static void mtk_jpeg_clk_on(struct mtk_jpeg_dev *jpeg)
> > {
> > - int ret;
> > -
> > - ret = mtk_smi_larb_get(jpeg->larb);
> > - if (ret)
> > - dev_err(jpeg->dev, "mtk_smi_larb_get larbvdec fail %d\n", ret);
> > clk_prepare_enable(jpeg->clk_jdec_smi);
> > clk_prepare_enable(jpeg->clk_jdec);
> > }
> > @@ -914,7 +908,6 @@ static void mtk_jpeg_clk_off(struct mtk_jpeg_dev *jpeg)
> > {
> > clk_disable_unprepare(jpeg->clk_jdec);
> > clk_disable_unprepare(jpeg->clk_jdec_smi);
> > - mtk_smi_larb_put(jpeg->larb);
> > }
> >
> > static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv)
> > @@ -1059,21 +1052,6 @@ static int mtk_jpeg_release(struct file *file)
> >
> > static int mtk_jpeg_clk_init(struct mtk_jpeg_dev *jpeg)
> > {
> > - struct device_node *node;
> > - struct platform_device *pdev;
> > -
> > - node = of_parse_phandle(jpeg->dev->of_node, "mediatek,larb", 0);
> > - if (!node)
> > - return -EINVAL;
> > - pdev = of_find_device_by_node(node);
> > - if (WARN_ON(!pdev)) {
> > - of_node_put(node);
> > - return -EINVAL;
> > - }
> > - of_node_put(node);
> > -
> > - jpeg->larb = &pdev->dev;
> > -
> > jpeg->clk_jdec = devm_clk_get(jpeg->dev, "jpgdec");
> > if (IS_ERR(jpeg->clk_jdec))
> > return PTR_ERR(jpeg->clk_jdec);
> > diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h
> > index 1a6cdfd..e35fb79 100644
> > --- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h
> > +++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h
> > @@ -55,7 +55,6 @@ enum mtk_jpeg_ctx_state {
> > * @dec_reg_base: JPEG registers mapping
> > * @clk_jdec: JPEG hw working clock
> > * @clk_jdec_smi: JPEG SMI bus clock
> > - * @larb: SMI device
> > */
> > struct mtk_jpeg_dev {
> > struct mutex lock;
> > @@ -69,7 +68,6 @@ struct mtk_jpeg_dev {
> > void __iomem *dec_reg_base;
> > struct clk *clk_jdec;
> > struct clk *clk_jdec_smi;
> > - struct device *larb;
> > };
> >
> > /**
> >