2023-10-30 10:18:06

by Moudy Ho (何宗原)

[permalink] [raw]
Subject: [PATCH v8 06/12] media: platform: mtk-mdp3: avoid multiple driver registrations

The amount of MDP3 driver probes is determined by the registered
clocks of MMSYS.
Since MT8195 MDP3 utilizes VPPSYS0 and VPPSYS1, it's necessary to
prevent multiple driver registrations.

Signed-off-by: Moudy Ho <[email protected]>
---
drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c | 1 +
drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c | 8 ++++++++
drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h | 1 +
3 files changed, 10 insertions(+)

diff --git a/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c b/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
index fe92c0474bfa..6f77c33074ec 100644
--- a/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
+++ b/drivers/media/platform/mediatek/mdp3/mdp_cfg_data.c
@@ -410,6 +410,7 @@ static const struct mdp_pipe_info mt8183_pipe_info[] = {

const struct mtk_mdp_driver_data mt8183_mdp_driver_data = {
.mdp_plat_id = MT8183,
+ .mdp_con_res = 0x14001000,
.mdp_probe_infra = mt8183_mdp_probe_infra,
.mdp_cfg = &mt8183_plat_cfg,
.mdp_mutex_table_idx = mt8183_mutex_idx,
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
index 8959f83eb5b5..b214510ac42d 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
@@ -211,6 +211,7 @@ static int mdp_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct mdp_dev *mdp;
struct platform_device *mm_pdev;
+ struct resource *res;
int ret, i, mutex_id;

mdp = kzalloc(sizeof(*mdp), GFP_KERNEL);
@@ -222,6 +223,12 @@ static int mdp_probe(struct platform_device *pdev)
mdp->pdev = pdev;
mdp->mdp_data = of_device_get_match_data(&pdev->dev);

+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (res->start != mdp->mdp_data->mdp_con_res) {
+ platform_set_drvdata(pdev, mdp);
+ goto success_return;
+ }
+
ret = mdp_mm_subsys_deploy(mdp, MDP_INFRA_MMSYS);
if (ret)
goto err_destroy_device;
@@ -307,6 +314,7 @@ static int mdp_probe(struct platform_device *pdev)
goto err_unregister_device;
}

+success_return:
dev_dbg(dev, "mdp-%d registered successfully\n", pdev->id);
return 0;

diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
index ece6509666fd..22d1b17ef2fc 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
@@ -71,6 +71,7 @@ enum mdp_pipe_id {

struct mtk_mdp_driver_data {
const int mdp_plat_id;
+ const resource_size_t mdp_con_res;
const struct of_device_id *mdp_probe_infra;
const struct mdp_platform_config *mdp_cfg;
const u32 *mdp_mutex_table_idx;
--
2.18.0


Subject: Re: [PATCH v8 06/12] media: platform: mtk-mdp3: avoid multiple driver registrations

Il 30/10/23 11:06, Moudy Ho ha scritto:
> The amount of MDP3 driver probes is determined by the registered
> clocks of MMSYS.
> Since MT8195 MDP3 utilizes VPPSYS0 and VPPSYS1, it's necessary to
> prevent multiple driver registrations.
>
> Signed-off-by: Moudy Ho <[email protected]>

Reviewed-by: AngeloGioacchino Del Regno <[email protected]>