Re: [PATCH v5 03/14] media: platform: mtk-mdp3: add support second sets of MMSYS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Angelo,

On Tue, 2023-09-12 at 11:18 +0200, AngeloGioacchino Del Regno wrote:
> Il 12/09/23 09:57, Moudy Ho ha scritto:
> > MT8195 has two MMSYS sets, VPPSYS0 and VPPSYS1.
> > These sets coordinate and control the clock, power, and
> > register settings needed for the components of MDP3.
> > 
> > Signed-off-by: Moudy Ho <moudy.ho@xxxxxxxxxxxx>
> > ---
> >   .../platform/mediatek/mdp3/mdp_cfg_data.c     | 44 +++++++++-----
> > -----
> >   .../platform/mediatek/mdp3/mtk-mdp3-comp.h    |  1 +
> >   .../platform/mediatek/mdp3/mtk-mdp3-core.c    | 40 +++++++++++---
> > ---
> >   .../platform/mediatek/mdp3/mtk-mdp3-core.h    |  3 ++
> >   4 files changed, 53 insertions(+), 35 deletions(-)

(snip)

> > diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
> > b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
> > index cc44be10fdb7..9c33d3aaf9cd 100644
> > --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
> > +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
> > @@ -26,39 +26,45 @@ static const struct of_device_id mdp_of_ids[] =
> > {
> >   MODULE_DEVICE_TABLE(of, mdp_of_ids);
> >   
> >   static struct platform_device *__get_pdev_by_id(struct
> > platform_device *pdev,
> > +						struct platform_device
> > *from,
> >   						enum mdp_infra_id id)
> >   {
> > -	struct device_node *node;
> > +	struct device_node *node, *f = NULL;
> >   	struct platform_device *mdp_pdev = NULL;
> >   	const struct mtk_mdp_driver_data *mdp_data;
> >   	const char *compat;
> >   
> >   	if (!pdev)
> > -		return NULL;
> > +		return ERR_PTR(-ENODEV);
> >   
> 
> Fixing the error handling shall be done in a different commit, which
> shall also
> have a Fixes tag: this is both for backporting purposes and because
> those fixes
> are not relevant to adding support for secondary sets of MMSYS (so,
> those are
> not relevant for this specific commit).
> 
Thanks forreminding me. I will address this error handing separately in
a dedicated fix patch.

> >   	if (id < MDP_INFRA_MMSYS || id >= MDP_INFRA_MAX) {
> >   		dev_err(&pdev->dev, "Illegal infra id %d\n", id);
> > -		return NULL;
> > +		return ERR_PTR(-ENODEV);
> >   	}
> >   
> >   	mdp_data = of_device_get_match_data(&pdev->dev);
> >   	if (!mdp_data) {
> >   		dev_err(&pdev->dev, "have no driver data to find
> > node\n");
> > -		return NULL;
> > +		return ERR_PTR(-ENODEV);
> >   	}
> > +
> >   	compat = mdp_data->mdp_probe_infra[id].compatible;
> > +	if (strlen(compat) == 0)
> > +		return NULL;
> >   
> > -	node = of_find_compatible_node(NULL, NULL, compat);
> > +	if (from)
> > +		f = from->dev.of_node;
> > +	node = of_find_compatible_node(f, NULL, compat);
> >   	if (WARN_ON(!node)) {
> >   		dev_err(&pdev->dev, "find node from id %d failed\n",
> > id);
> > -		return NULL;
> > +		return ERR_PTR(-ENODEV);
> >   	}
> >   
> >   	mdp_pdev = of_find_device_by_node(node);
> >   	of_node_put(node);
> >   	if (WARN_ON(!mdp_pdev)) {
> >   		dev_err(&pdev->dev, "find pdev from id %d failed\n",
> > id);
> > -		return NULL;
> > +		return ERR_PTR(-ENODEV);
> >   	}
> >   
> >   	return mdp_pdev;
> > @@ -152,7 +158,7 @@ static int mdp_probe(struct platform_device
> > *pdev)
> >   {
> >   	struct device *dev = &pdev->dev;
> >   	struct mdp_dev *mdp;
> > -	struct platform_device *mm_pdev;
> > +	struct platform_device *mm_pdev, *mm2_pdev;
> >   	int ret, i, mutex_id;
> >   
> >   	mdp = kzalloc(sizeof(*mdp), GFP_KERNEL);
> > @@ -164,15 +170,23 @@ static int mdp_probe(struct platform_device
> > *pdev)
> >   	mdp->pdev = pdev;
> >   	mdp->mdp_data = of_device_get_match_data(&pdev->dev);
> >   
> > -	mm_pdev = __get_pdev_by_id(pdev, MDP_INFRA_MMSYS);
> > -	if (!mm_pdev) {
> > +	mm_pdev = __get_pdev_by_id(pdev, NULL, MDP_INFRA_MMSYS);
> > +	if (IS_ERR_OR_NULL(mm_pdev)) {
> >   		ret = -ENODEV;
> >   		goto err_destroy_device;
> >   	}
> >   	mdp->mdp_mmsys = &mm_pdev->dev;
> >   
> > -	mm_pdev = __get_pdev_by_id(pdev, MDP_INFRA_MUTEX);
> > -	if (WARN_ON(!mm_pdev)) {
> > +	/* MMSYS2 is not available on all chips, so the config may be
> > null. */
> > +	mm2_pdev = __get_pdev_by_id(pdev, mm_pdev, MDP_INFRA_MMSYS2);
> > +	if (IS_ERR(mm2_pdev)) {
> > +		ret = PTR_ERR(mm2_pdev);
> > +		goto err_destroy_device;
> > +	}
> > +	mdp->mdp_mmsys2 = &mm2_pdev->dev;
> > +
> > +	mm_pdev = __get_pdev_by_id(pdev, NULL, MDP_INFRA_MUTEX);
> > +	if (IS_ERR_OR_NULL(mm_pdev)) {
> >   		ret = -ENODEV;
> >   		goto err_destroy_device;
> >   	}
> > @@ -208,7 +222,7 @@ static int mdp_probe(struct platform_device
> > *pdev)
> >   		goto err_destroy_job_wq;
> >   	}
> >   
> > -	mm_pdev = __get_pdev_by_id(pdev, MDP_INFRA_SCP);
> > +	mm_pdev = __get_pdev_by_id(pdev, NULL, MDP_INFRA_SCP);
> >   	if (WARN_ON(!mm_pdev)) {
> >   		dev_err(&pdev->dev, "Could not get scp device\n");
> >   		ret = -ENODEV;
> > diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
> > b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
> > index 7e21d226ceb8..0434b70e1fc9 100644
> > --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
> > +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
> > @@ -20,6 +20,7 @@
> >   
> >   enum mdp_infra_id {
> >   	MDP_INFRA_MMSYS,
> > +	MDP_INFRA_MMSYS2,
> >   	MDP_INFRA_MUTEX,
> >   	MDP_INFRA_SCP,
> >   	MDP_INFRA_MAX
> > @@ -68,6 +69,7 @@ struct mtk_mdp_driver_data {
> >   struct mdp_dev {
> >   	struct platform_device			*pdev;
> >   	struct device				*mdp_mmsys;
> > +	struct device				*mdp_mmsys2;
> 
> I'm wondering if this would become more readable by doing it like so:
> 
> 	struct mdp_dev_infra {
> 		struct device *mmsys;
> 		struct mtk_mutex *mtk_mutex[MDP_PIPE_MAX];
> 	}
> 
> 	struct mdp_dev {
> 		struct platform_device *pdev;
> 		struct mdp_dev_infra mdp_infra;
> 		.....
> 	}
> 
> so that you can add the secondary MMSYS (that goes along with the
> secondary
> MUTEX anyway) by then changing mdp_infra to
> 
> 		struct mtk_dev_infra mdp_infra[NUM_MMSYS];
> 
> and then referencing that like
> 
> mdp->mdp_infra[MDP_INFRA_MMSYS0]->mmsys
> mdp->mdp_infra[MDP_INFRA_MMSYS0]->mtk_mutex
> mdp->mdp_infra[MDP_INFRA_MMSYS1]->mmsys
> mdp->mdp_infra[MDP_INFRA_MMSYS1]->mtk_mutex
> 
> What do you think?
> 
> Regards,
> Angelo
> 

Thanks for the advice. I will follow your suggestion to simplify the
settings.

Sincerely,
Moudy

> >   	struct mtk_mutex			*mdp_mutex[MDP_PIPE_MAX];
> >   	struct mdp_comp				*comp[MDP_MAX_COMP_
> > COUNT];
> >   	const struct mtk_mdp_driver_data	*mdp_data;
> > @@ -96,6 +98,7 @@ struct mdp_dev {
> >   
> >   struct mdp_pipe_info {
> >   	enum mdp_pipe_id pipe_id;
> > +	u32 mmsys_id;
> >   	u32 mutex_id;
> >   };
> >   
> 
> 




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux