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

media: drm/mediatek: 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 drm device calls the pm_runtime_get_sync,
the smi-larb's pm_runtime_get_sync also be called automatically.

CC: CK Hu <ck.hu@mediatek.com>
CC: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarYong Wu <yong.wu@mediatek.com>
Reviewed-by: default avatarEvan Green <evgreen@chromium.org>
Acked-by: default avatarChun-Kuang Hu <chunkuang.hu@kernel.org>
Reviewed-by: default avatarDafna Hirschfeld <dafna.hirschfeld@collabora.com>
Tested-by: Frank Wunderlich <frank-w@public-files.de> # BPI-R2/MT7623
Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 5db12f5d
Loading
Loading
Loading
Loading
+0 −10
Original line number Original line Diff line number Diff line
@@ -12,7 +12,6 @@
#include <linux/soc/mediatek/mtk-mutex.h>
#include <linux/soc/mediatek/mtk-mutex.h>


#include <asm/barrier.h>
#include <asm/barrier.h>
#include <soc/mediatek/smi.h>


#include <drm/drm_atomic.h>
#include <drm/drm_atomic.h>
#include <drm/drm_atomic_helper.h>
#include <drm/drm_atomic_helper.h>
@@ -661,22 +660,14 @@ static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc,


	DRM_DEBUG_DRIVER("%s %d\n", __func__, crtc->base.id);
	DRM_DEBUG_DRIVER("%s %d\n", __func__, crtc->base.id);


	ret = mtk_smi_larb_get(comp->larb_dev);
	if (ret) {
		DRM_ERROR("Failed to get larb: %d\n", ret);
		return;
	}

	ret = pm_runtime_resume_and_get(comp->dev);
	ret = pm_runtime_resume_and_get(comp->dev);
	if (ret < 0) {
	if (ret < 0) {
		mtk_smi_larb_put(comp->larb_dev);
		DRM_DEV_ERROR(comp->dev, "Failed to enable power domain: %d\n", ret);
		DRM_DEV_ERROR(comp->dev, "Failed to enable power domain: %d\n", ret);
		return;
		return;
	}
	}


	ret = mtk_crtc_ddp_hw_init(mtk_crtc);
	ret = mtk_crtc_ddp_hw_init(mtk_crtc);
	if (ret) {
	if (ret) {
		mtk_smi_larb_put(comp->larb_dev);
		pm_runtime_put(comp->dev);
		pm_runtime_put(comp->dev);
		return;
		return;
	}
	}
@@ -713,7 +704,6 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc,


	drm_crtc_vblank_off(crtc);
	drm_crtc_vblank_off(crtc);
	mtk_crtc_ddp_hw_fini(mtk_crtc);
	mtk_crtc_ddp_hw_fini(mtk_crtc);
	mtk_smi_larb_put(comp->larb_dev);
	ret = pm_runtime_put(comp->dev);
	ret = pm_runtime_put(comp->dev);
	if (ret < 0)
	if (ret < 0)
		DRM_DEV_ERROR(comp->dev, "Failed to disable power domain: %d\n", ret);
		DRM_DEV_ERROR(comp->dev, "Failed to disable power domain: %d\n", ret);
+2 −34
Original line number Original line Diff line number Diff line
@@ -447,37 +447,15 @@ unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,
	return ret;
	return ret;
}
}


static int mtk_ddp_get_larb_dev(struct device_node *node, struct mtk_ddp_comp *comp,
				struct device *dev)
{
	struct device_node *larb_node;
	struct platform_device *larb_pdev;

	larb_node = of_parse_phandle(node, "mediatek,larb", 0);
	if (!larb_node) {
		dev_err(dev, "Missing mediadek,larb phandle in %pOF node\n", node);
		return -EINVAL;
	}

	larb_pdev = of_find_device_by_node(larb_node);
	if (!larb_pdev) {
		dev_warn(dev, "Waiting for larb device %pOF\n", larb_node);
		of_node_put(larb_node);
		return -EPROBE_DEFER;
	}
	of_node_put(larb_node);
	comp->larb_dev = &larb_pdev->dev;

	return 0;
}

int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp,
int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp,
		      enum mtk_ddp_comp_id comp_id)
		      enum mtk_ddp_comp_id comp_id)
{
{
	struct platform_device *comp_pdev;
	struct platform_device *comp_pdev;
	enum mtk_ddp_comp_type type;
	enum mtk_ddp_comp_type type;
	struct mtk_ddp_comp_dev *priv;
	struct mtk_ddp_comp_dev *priv;
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
	int ret;
	int ret;
#endif


	if (comp_id < 0 || comp_id >= DDP_COMPONENT_ID_MAX)
	if (comp_id < 0 || comp_id >= DDP_COMPONENT_ID_MAX)
		return -EINVAL;
		return -EINVAL;
@@ -493,16 +471,6 @@ int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp,
	}
	}
	comp->dev = &comp_pdev->dev;
	comp->dev = &comp_pdev->dev;


	/* Only DMA capable components need the LARB property */
	if (type == MTK_DISP_OVL ||
	    type == MTK_DISP_OVL_2L ||
	    type == MTK_DISP_RDMA ||
	    type == MTK_DISP_WDMA) {
		ret = mtk_ddp_get_larb_dev(node, comp, comp->dev);
		if (ret)
			return ret;
	}

	if (type == MTK_DISP_AAL ||
	if (type == MTK_DISP_AAL ||
	    type == MTK_DISP_BLS ||
	    type == MTK_DISP_BLS ||
	    type == MTK_DISP_CCORR ||
	    type == MTK_DISP_CCORR ||
+0 −1
Original line number Original line Diff line number Diff line
@@ -71,7 +71,6 @@ struct mtk_ddp_comp_funcs {
struct mtk_ddp_comp {
struct mtk_ddp_comp {
	struct device *dev;
	struct device *dev;
	int irq;
	int irq;
	struct device *larb_dev;
	enum mtk_ddp_comp_id id;
	enum mtk_ddp_comp_id id;
	const struct mtk_ddp_comp_funcs *funcs;
	const struct mtk_ddp_comp_funcs *funcs;
};
};
+1 −4
Original line number Original line Diff line number Diff line
@@ -645,11 +645,8 @@ static int mtk_drm_probe(struct platform_device *pdev)
	pm_runtime_disable(dev);
	pm_runtime_disable(dev);
err_node:
err_node:
	of_node_put(private->mutex_node);
	of_node_put(private->mutex_node);
	for (i = 0; i < DDP_COMPONENT_ID_MAX; i++) {
	for (i = 0; i < DDP_COMPONENT_ID_MAX; i++)
		of_node_put(private->comp_node[i]);
		of_node_put(private->comp_node[i]);
		if (private->ddp_comp[i].larb_dev)
			put_device(private->ddp_comp[i].larb_dev);
	}
	return ret;
	return ret;
}
}