Commit bf827570 authored by Yong Wu's avatar Yong Wu Committed by Mauro Carvalho Chehab
Browse files

media: mtk-vcodec: Get rid of mtk_smi_larb_get/put



MediaTek IOMMU has already added the device_link between the consumer
and smi-larb device. If the vcodec devices call the pm_runtime_get_sync,
the smi-larb's pm_runtime_get_sync also be called automatically.

CC: Irui Wang <irui.wang@mediatek.com>
Signed-off-by: default avatarYong Wu <yong.wu@mediatek.com>
Reviewed-by: default avatarEvan Green <evgreen@chromium.org>
Acked-by: default avatarTiffany Lin <tiffany.lin@mediatek.com>
Reviewed-by: default avatarDafna Hirschfeld <dafna.hirschfeld@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent ce6c24ba
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -450,7 +450,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
		destroy_workqueue(dev->core_workqueue);
err_res:
	pm_runtime_disable(dev->pm.dev);
	put_device(dev->pm.larbvdec);
err_dec_pm:
	mtk_vcodec_fw_release(dev->fw_handler);
	return ret;
@@ -494,7 +493,6 @@ static int mtk_vcodec_dec_remove(struct platform_device *pdev)

	v4l2_device_unregister(&dev->v4l2_dev);
	pm_runtime_disable(dev->pm.dev);
	put_device(dev->pm.larbvdec);
	mtk_vcodec_fw_release(dev->fw_handler);
	return 0;
}
+0 −1
Original line number Diff line number Diff line
@@ -184,7 +184,6 @@ static int mtk_vdec_hw_probe(struct platform_device *pdev)
	return 0;
err:
	pm_runtime_disable(subdev_dev->pm.dev);
	put_device(subdev_dev->pm.larbvdec);
	return ret;
}

+6 −35
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@
#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <linux/pm_runtime.h>
#include <soc/mediatek/smi.h>

#include "mtk_vcodec_dec_hw.h"
#include "mtk_vcodec_dec_pm.h"
@@ -17,25 +16,11 @@

int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct mtk_vcodec_pm *pm)
{
	struct device_node *node;
	struct platform_device *larb_pdev;
	struct mtk_vcodec_clk *dec_clk;
	struct mtk_vcodec_clk_info *clk_info;
	int i = 0, ret = 0;
	int i = 0, ret;

	dec_clk = &pm->vdec_clk;
	node = of_parse_phandle(pdev->dev.of_node, "mediatek,larb", 0);
	if (!node) {
		mtk_v4l2_err("of_parse_phandle mediatek,larb fail!");
		return -1;
	}

	larb_pdev = of_find_device_by_node(node);
	of_node_put(node);
	if (WARN_ON(!larb_pdev))
		return -1;

	pm->larbvdec = &larb_pdev->dev;
	pm->dev = &pdev->dev;

	dec_clk->clk_num =
@@ -44,14 +29,11 @@ int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct mtk_vcodec_pm *
		dec_clk->clk_info = devm_kcalloc(&pdev->dev,
			dec_clk->clk_num, sizeof(*clk_info),
			GFP_KERNEL);
		if (!dec_clk->clk_info) {
			ret = -ENOMEM;
			goto put_device;
		}
		if (!dec_clk->clk_info)
			return -ENOMEM;
	} else {
		mtk_v4l2_err("Failed to get vdec clock count");
		ret = -EINVAL;
		goto put_device;
		return -EINVAL;
	}

	for (i = 0; i < dec_clk->clk_num; i++) {
@@ -60,22 +42,18 @@ int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct mtk_vcodec_pm *
			"clock-names", i, &clk_info->clk_name);
		if (ret) {
			mtk_v4l2_err("Failed to get clock name id = %d", i);
			goto put_device;
			return ret;
		}
		clk_info->vcodec_clk = devm_clk_get(&pdev->dev,
			clk_info->clk_name);
		if (IS_ERR(clk_info->vcodec_clk)) {
			mtk_v4l2_err("devm_clk_get (%d)%s fail", i,
				clk_info->clk_name);
			ret = PTR_ERR(clk_info->vcodec_clk);
			goto put_device;
			return PTR_ERR(clk_info->vcodec_clk);
		}
	}

	return 0;
put_device:
	put_device(pm->larbvdec);
	return ret;
}
EXPORT_SYMBOL_GPL(mtk_vcodec_init_dec_clk);

@@ -157,13 +135,7 @@ void mtk_vcodec_dec_clock_on(struct mtk_vcodec_dev *vdec_dev, int hw_idx)
		}
	}

	ret = mtk_smi_larb_get(pm->larbvdec);
	if (ret) {
		mtk_v4l2_err("mtk_smi_larb_get larbvdec fail %d", ret);
		goto error;
	}
	return;

error:
	for (i -= 1; i >= 0; i--)
		clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk);
@@ -191,7 +163,6 @@ void mtk_vcodec_dec_clock_off(struct mtk_vcodec_dev *vdec_dev, int hw_idx)
	}

	dec_clk = &pm->vdec_clk;
	mtk_smi_larb_put(pm->larbvdec);
	for (i = dec_clk->clk_num - 1; i >= 0; i--)
		clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk);
}
+0 −3
Original line number Diff line number Diff line
@@ -214,10 +214,7 @@ struct mtk_vcodec_clk {
 */
struct mtk_vcodec_pm {
	struct mtk_vcodec_clk	vdec_clk;
	struct device	*larbvdec;

	struct mtk_vcodec_clk	venc_clk;
	struct device	*larbvenc;
	struct device	*dev;
};

+0 −1
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@
#include <media/v4l2-event.h>
#include <media/v4l2-mem2mem.h>
#include <media/videobuf2-dma-contig.h>
#include <soc/mediatek/smi.h>
#include <linux/pm_runtime.h>

#include "mtk_vcodec_drv.h"
Loading