Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: drm/mediatek: Add pm runtime support for ovl and rdma

Prepare for smi cleaning up "mediatek,larb".

Display use the dispsys device to call pm_rumtime_get_sync before.
This patch add pm_runtime_xx with ovl and rdma device whose nodes has
"iommus" property, then display could help pm_runtime_get for smi via
ovl or rdma device.

(Yong: Use pm_runtime_resume_and_get instead of pm_runtime_get_sync)

CC: CK Hu <ck.hu@mediatek.com>
Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com>
Signed-off-by: Yong Wu <yong.wu@mediatek.com>
Acked-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Tested-by: Frank Wunderlich <frank-w@public-files.de> # BPI-R2/MT7623
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Yongqiang Niu and committed by
Mauro Carvalho Chehab
5db12f5d 682c3cd8

+27 -3
+7 -1
drivers/gpu/drm/mediatek/mtk_disp_ovl.c
··· 11 11 #include <linux/of_device.h> 12 12 #include <linux/of_irq.h> 13 13 #include <linux/platform_device.h> 14 + #include <linux/pm_runtime.h> 14 15 #include <linux/soc/mediatek/mtk-cmdq.h> 15 16 16 17 #include "mtk_disp_drv.h" ··· 415 414 return ret; 416 415 } 417 416 417 + pm_runtime_enable(dev); 418 + 418 419 ret = component_add(dev, &mtk_disp_ovl_component_ops); 419 - if (ret) 420 + if (ret) { 421 + pm_runtime_disable(dev); 420 422 dev_err(dev, "Failed to add component: %d\n", ret); 423 + } 421 424 422 425 return ret; 423 426 } ··· 429 424 static int mtk_disp_ovl_remove(struct platform_device *pdev) 430 425 { 431 426 component_del(&pdev->dev, &mtk_disp_ovl_component_ops); 427 + pm_runtime_disable(&pdev->dev); 432 428 433 429 return 0; 434 430 }
+8 -1
drivers/gpu/drm/mediatek/mtk_disp_rdma.c
··· 9 9 #include <linux/of_device.h> 10 10 #include <linux/of_irq.h> 11 11 #include <linux/platform_device.h> 12 + #include <linux/pm_runtime.h> 12 13 #include <linux/soc/mediatek/mtk-cmdq.h> 13 14 14 15 #include "mtk_disp_drv.h" ··· 328 327 329 328 platform_set_drvdata(pdev, priv); 330 329 330 + pm_runtime_enable(dev); 331 + 331 332 ret = component_add(dev, &mtk_disp_rdma_component_ops); 332 - if (ret) 333 + if (ret) { 334 + pm_runtime_disable(dev); 333 335 dev_err(dev, "Failed to add component: %d\n", ret); 336 + } 334 337 335 338 return ret; 336 339 } ··· 342 337 static int mtk_disp_rdma_remove(struct platform_device *pdev) 343 338 { 344 339 component_del(&pdev->dev, &mtk_disp_rdma_component_ops); 340 + 341 + pm_runtime_disable(&pdev->dev); 345 342 346 343 return 0; 347 344 }
+12 -1
drivers/gpu/drm/mediatek/mtk_drm_crtc.c
··· 667 667 return; 668 668 } 669 669 670 + ret = pm_runtime_resume_and_get(comp->dev); 671 + if (ret < 0) { 672 + mtk_smi_larb_put(comp->larb_dev); 673 + DRM_DEV_ERROR(comp->dev, "Failed to enable power domain: %d\n", ret); 674 + return; 675 + } 676 + 670 677 ret = mtk_crtc_ddp_hw_init(mtk_crtc); 671 678 if (ret) { 672 679 mtk_smi_larb_put(comp->larb_dev); 680 + pm_runtime_put(comp->dev); 673 681 return; 674 682 } 675 683 ··· 690 682 { 691 683 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); 692 684 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; 693 - int i; 685 + int i, ret; 694 686 695 687 DRM_DEBUG_DRIVER("%s %d\n", __func__, crtc->base.id); 696 688 if (!mtk_crtc->enabled) ··· 714 706 drm_crtc_vblank_off(crtc); 715 707 mtk_crtc_ddp_hw_fini(mtk_crtc); 716 708 mtk_smi_larb_put(comp->larb_dev); 709 + ret = pm_runtime_put(comp->dev); 710 + if (ret < 0) 711 + DRM_DEV_ERROR(comp->dev, "Failed to disable power domain: %d\n", ret); 717 712 718 713 mtk_crtc->enabled = false; 719 714 }