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

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
...@@ -450,7 +450,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev) ...@@ -450,7 +450,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
destroy_workqueue(dev->core_workqueue); destroy_workqueue(dev->core_workqueue);
err_res: err_res:
pm_runtime_disable(dev->pm.dev); pm_runtime_disable(dev->pm.dev);
put_device(dev->pm.larbvdec);
err_dec_pm: err_dec_pm:
mtk_vcodec_fw_release(dev->fw_handler); mtk_vcodec_fw_release(dev->fw_handler);
return ret; return ret;
...@@ -494,7 +493,6 @@ static int mtk_vcodec_dec_remove(struct platform_device *pdev) ...@@ -494,7 +493,6 @@ static int mtk_vcodec_dec_remove(struct platform_device *pdev)
v4l2_device_unregister(&dev->v4l2_dev); v4l2_device_unregister(&dev->v4l2_dev);
pm_runtime_disable(dev->pm.dev); pm_runtime_disable(dev->pm.dev);
put_device(dev->pm.larbvdec);
mtk_vcodec_fw_release(dev->fw_handler); mtk_vcodec_fw_release(dev->fw_handler);
return 0; return 0;
} }
......
...@@ -184,7 +184,6 @@ static int mtk_vdec_hw_probe(struct platform_device *pdev) ...@@ -184,7 +184,6 @@ static int mtk_vdec_hw_probe(struct platform_device *pdev)
return 0; return 0;
err: err:
pm_runtime_disable(subdev_dev->pm.dev); pm_runtime_disable(subdev_dev->pm.dev);
put_device(subdev_dev->pm.larbvdec);
return ret; return ret;
} }
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <soc/mediatek/smi.h>
#include "mtk_vcodec_dec_hw.h" #include "mtk_vcodec_dec_hw.h"
#include "mtk_vcodec_dec_pm.h" #include "mtk_vcodec_dec_pm.h"
...@@ -17,25 +16,11 @@ ...@@ -17,25 +16,11 @@
int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct mtk_vcodec_pm *pm) 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 *dec_clk;
struct mtk_vcodec_clk_info *clk_info; struct mtk_vcodec_clk_info *clk_info;
int i = 0, ret = 0; int i = 0, ret;
dec_clk = &pm->vdec_clk; 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; pm->dev = &pdev->dev;
dec_clk->clk_num = dec_clk->clk_num =
...@@ -44,14 +29,11 @@ int mtk_vcodec_init_dec_clk(struct platform_device *pdev, struct mtk_vcodec_pm * ...@@ -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_info = devm_kcalloc(&pdev->dev,
dec_clk->clk_num, sizeof(*clk_info), dec_clk->clk_num, sizeof(*clk_info),
GFP_KERNEL); GFP_KERNEL);
if (!dec_clk->clk_info) { if (!dec_clk->clk_info)
ret = -ENOMEM; return -ENOMEM;
goto put_device;
}
} else { } else {
mtk_v4l2_err("Failed to get vdec clock count"); mtk_v4l2_err("Failed to get vdec clock count");
ret = -EINVAL; return -EINVAL;
goto put_device;
} }
for (i = 0; i < dec_clk->clk_num; i++) { 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 * ...@@ -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); "clock-names", i, &clk_info->clk_name);
if (ret) { if (ret) {
mtk_v4l2_err("Failed to get clock name id = %d", i); 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->vcodec_clk = devm_clk_get(&pdev->dev,
clk_info->clk_name); clk_info->clk_name);
if (IS_ERR(clk_info->vcodec_clk)) { if (IS_ERR(clk_info->vcodec_clk)) {
mtk_v4l2_err("devm_clk_get (%d)%s fail", i, mtk_v4l2_err("devm_clk_get (%d)%s fail", i,
clk_info->clk_name); clk_info->clk_name);
ret = PTR_ERR(clk_info->vcodec_clk); return PTR_ERR(clk_info->vcodec_clk);
goto put_device;
} }
} }
return 0; return 0;
put_device:
put_device(pm->larbvdec);
return ret;
} }
EXPORT_SYMBOL_GPL(mtk_vcodec_init_dec_clk); 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) ...@@ -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; return;
error: error:
for (i -= 1; i >= 0; i--) for (i -= 1; i >= 0; i--)
clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk); 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) ...@@ -191,7 +163,6 @@ void mtk_vcodec_dec_clock_off(struct mtk_vcodec_dev *vdec_dev, int hw_idx)
} }
dec_clk = &pm->vdec_clk; dec_clk = &pm->vdec_clk;
mtk_smi_larb_put(pm->larbvdec);
for (i = dec_clk->clk_num - 1; i >= 0; i--) for (i = dec_clk->clk_num - 1; i >= 0; i--)
clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk); clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk);
} }
......
...@@ -214,10 +214,7 @@ struct mtk_vcodec_clk { ...@@ -214,10 +214,7 @@ struct mtk_vcodec_clk {
*/ */
struct mtk_vcodec_pm { struct mtk_vcodec_pm {
struct mtk_vcodec_clk vdec_clk; struct mtk_vcodec_clk vdec_clk;
struct device *larbvdec;
struct mtk_vcodec_clk venc_clk; struct mtk_vcodec_clk venc_clk;
struct device *larbvenc;
struct device *dev; struct device *dev;
}; };
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <media/v4l2-event.h> #include <media/v4l2-event.h>
#include <media/v4l2-mem2mem.h> #include <media/v4l2-mem2mem.h>
#include <media/videobuf2-dma-contig.h> #include <media/videobuf2-dma-contig.h>
#include <soc/mediatek/smi.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include "mtk_vcodec_drv.h" #include "mtk_vcodec_drv.h"
......
...@@ -371,7 +371,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev) ...@@ -371,7 +371,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
v4l2_device_unregister(&dev->v4l2_dev); v4l2_device_unregister(&dev->v4l2_dev);
err_res: err_res:
pm_runtime_disable(dev->pm.dev); pm_runtime_disable(dev->pm.dev);
put_device(dev->pm.larbvenc);
err_enc_pm: err_enc_pm:
mtk_vcodec_fw_release(dev->fw_handler); mtk_vcodec_fw_release(dev->fw_handler);
return ret; return ret;
...@@ -461,7 +460,6 @@ static int mtk_vcodec_enc_remove(struct platform_device *pdev) ...@@ -461,7 +460,6 @@ static int mtk_vcodec_enc_remove(struct platform_device *pdev)
v4l2_device_unregister(&dev->v4l2_dev); v4l2_device_unregister(&dev->v4l2_dev);
pm_runtime_disable(dev->pm.dev); pm_runtime_disable(dev->pm.dev);
put_device(dev->pm.larbvenc);
mtk_vcodec_fw_release(dev->fw_handler); mtk_vcodec_fw_release(dev->fw_handler);
return 0; return 0;
} }
......
...@@ -8,57 +8,35 @@ ...@@ -8,57 +8,35 @@
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <soc/mediatek/smi.h>
#include "mtk_vcodec_enc_pm.h" #include "mtk_vcodec_enc_pm.h"
#include "mtk_vcodec_util.h" #include "mtk_vcodec_util.h"
int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *mtkdev) int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *mtkdev)
{ {
struct device_node *node;
struct platform_device *pdev; struct platform_device *pdev;
struct mtk_vcodec_pm *pm; struct mtk_vcodec_pm *pm;
struct mtk_vcodec_clk *enc_clk; struct mtk_vcodec_clk *enc_clk;
struct mtk_vcodec_clk_info *clk_info; struct mtk_vcodec_clk_info *clk_info;
int ret = 0, i = 0; int ret, i;
struct device *dev;
pdev = mtkdev->plat_dev; pdev = mtkdev->plat_dev;
pm = &mtkdev->pm; pm = &mtkdev->pm;
memset(pm, 0, sizeof(struct mtk_vcodec_pm)); memset(pm, 0, sizeof(struct mtk_vcodec_pm));
pm->dev = &pdev->dev; pm->dev = &pdev->dev;
dev = &pdev->dev;
enc_clk = &pm->venc_clk; enc_clk = &pm->venc_clk;
node = of_parse_phandle(dev->of_node, "mediatek,larb", 0);
if (!node) {
mtk_v4l2_err("no mediatek,larb found");
return -ENODEV;
}
pdev = of_find_device_by_node(node);
of_node_put(node);
if (!pdev) {
mtk_v4l2_err("no mediatek,larb device found");
return -ENODEV;
}
pm->larbvenc = &pdev->dev;
pdev = mtkdev->plat_dev;
pm->dev = &pdev->dev;
enc_clk->clk_num = of_property_count_strings(pdev->dev.of_node, enc_clk->clk_num = of_property_count_strings(pdev->dev.of_node,
"clock-names"); "clock-names");
if (enc_clk->clk_num > 0) { if (enc_clk->clk_num > 0) {
enc_clk->clk_info = devm_kcalloc(&pdev->dev, enc_clk->clk_info = devm_kcalloc(&pdev->dev,
enc_clk->clk_num, sizeof(*clk_info), enc_clk->clk_num, sizeof(*clk_info),
GFP_KERNEL); GFP_KERNEL);
if (!enc_clk->clk_info) { if (!enc_clk->clk_info)
ret = -ENOMEM; return -ENOMEM;
goto put_larbvenc;
}
} else { } else {
mtk_v4l2_err("Failed to get venc clock count"); mtk_v4l2_err("Failed to get venc clock count");
ret = -EINVAL; return -EINVAL;
goto put_larbvenc;
} }
for (i = 0; i < enc_clk->clk_num; i++) { for (i = 0; i < enc_clk->clk_num; i++) {
...@@ -67,23 +45,18 @@ int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *mtkdev) ...@@ -67,23 +45,18 @@ int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *mtkdev)
"clock-names", i, &clk_info->clk_name); "clock-names", i, &clk_info->clk_name);
if (ret) { if (ret) {
mtk_v4l2_err("venc failed to get clk name %d", i); mtk_v4l2_err("venc failed to get clk name %d", i);
goto put_larbvenc; return ret;
} }
clk_info->vcodec_clk = devm_clk_get(&pdev->dev, clk_info->vcodec_clk = devm_clk_get(&pdev->dev,
clk_info->clk_name); clk_info->clk_name);
if (IS_ERR(clk_info->vcodec_clk)) { if (IS_ERR(clk_info->vcodec_clk)) {
mtk_v4l2_err("venc devm_clk_get (%d)%s fail", i, mtk_v4l2_err("venc devm_clk_get (%d)%s fail", i,
clk_info->clk_name); clk_info->clk_name);
ret = PTR_ERR(clk_info->vcodec_clk); return PTR_ERR(clk_info->vcodec_clk);
goto put_larbvenc;
} }
} }
return 0; return 0;
put_larbvenc:
put_device(pm->larbvenc);
return ret;
} }
void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm) void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm)
...@@ -100,11 +73,6 @@ void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm) ...@@ -100,11 +73,6 @@ void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm)
} }
} }
ret = mtk_smi_larb_get(pm->larbvenc);
if (ret) {
mtk_v4l2_err("mtk_smi_larb_get larb3 fail %d", ret);
goto clkerr;
}
return; return;
clkerr: clkerr:
...@@ -117,7 +85,6 @@ void mtk_vcodec_enc_clock_off(struct mtk_vcodec_pm *pm) ...@@ -117,7 +85,6 @@ void mtk_vcodec_enc_clock_off(struct mtk_vcodec_pm *pm)
struct mtk_vcodec_clk *enc_clk = &pm->venc_clk; struct mtk_vcodec_clk *enc_clk = &pm->venc_clk;
int i = 0; int i = 0;
mtk_smi_larb_put(pm->larbvenc);
for (i = enc_clk->clk_num - 1; i >= 0; i--) for (i = enc_clk->clk_num - 1; i >= 0; i--)
clk_disable_unprepare(enc_clk->clk_info[i].vcodec_clk); clk_disable_unprepare(enc_clk->clk_info[i].vcodec_clk);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment