mbox series

[0/2] MediaTek MDP3: use devicetree to retrieve SCP

Message ID 20230919095938.70679-1-angelogioacchino.delregno@collabora.com
Headers show
Series MediaTek MDP3: use devicetree to retrieve SCP | expand

Message

AngeloGioacchino Del Regno Sept. 19, 2023, 9:59 a.m. UTC
Especially now that Multi-Core SCP support has landed, it makes sense to
retrieve the SCP handle by using the "mediatek,scp" property (as already
done in MediaTek VCODEC), both to select one specific SCP core for MDP3
and to avoid walking the parent node to find a SCP node.

AngeloGioacchino Del Regno (2):
  media: dt-bindings: mediatek: Add phandle to mediatek,scp on MDP3 RDMA
  media: platform: mtk-mdp3: Use devicetree phandle to retrieve SCP

 .../bindings/media/mediatek,mdp3-rdma.yaml       |  6 ++++++
 .../media/platform/mediatek/mdp3/mtk-mdp3-core.c | 16 ++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

Comments

Chen-Yu Tsai Sept. 19, 2023, 10:21 a.m. UTC | #1
On Tue, Sep 19, 2023 at 6:00 PM AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com> wrote:
>
> Instead of walking the entire parent node for something that has the
> right compatible, use the scp_get() function provided by the MediaTek
> SCP remoteproc driver to retrieve a handle to mtk_scp through the
> devicetree "mediatek,scp" (phandle) property.
>
> In case of multi-core SCP, this also allows to select a specific core.
>
> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
>  .../media/platform/mediatek/mdp3/mtk-mdp3-core.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
> index 8677e7fd5083..d93d3833633e 100644
> --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
> +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
> @@ -254,13 +254,17 @@ static int mdp_probe(struct platform_device *pdev)
>                 goto err_destroy_job_wq;
>         }
>
> -       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;
> -               goto err_destroy_clock_wq;
> +       mdp->scp = scp_get(pdev);
> +       if (!mdp->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;
> +                       goto err_destroy_clock_wq;
> +               }
> +               mdp->scp = platform_get_drvdata(mm_pdev);

You need to keep the original code as a fallback for old device trees.

ChenYu

>         }
> -       mdp->scp = platform_get_drvdata(mm_pdev);
> +
>         mdp->rproc_handle = scp_get_rproc(mdp->scp);
>         dev_dbg(&pdev->dev, "MDP rproc_handle: %pK", mdp->rproc_handle);
>
> --
> 2.42.0
>
AngeloGioacchino Del Regno Sept. 19, 2023, 10:23 a.m. UTC | #2
Il 19/09/23 12:21, Chen-Yu Tsai ha scritto:
> On Tue, Sep 19, 2023 at 6:00 PM AngeloGioacchino Del Regno
> <angelogioacchino.delregno@collabora.com> wrote:
>>
>> Instead of walking the entire parent node for something that has the
>> right compatible, use the scp_get() function provided by the MediaTek
>> SCP remoteproc driver to retrieve a handle to mtk_scp through the
>> devicetree "mediatek,scp" (phandle) property.
>>
>> In case of multi-core SCP, this also allows to select a specific core.
>>
>> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
>> ---
>>   .../media/platform/mediatek/mdp3/mtk-mdp3-core.c | 16 ++++++++++------
>>   1 file changed, 10 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
>> index 8677e7fd5083..d93d3833633e 100644
>> --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
>> +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
>> @@ -254,13 +254,17 @@ static int mdp_probe(struct platform_device *pdev)
>>                  goto err_destroy_job_wq;
>>          }
>>
>> -       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;
>> -               goto err_destroy_clock_wq;
>> +       mdp->scp = scp_get(pdev);
>> +       if (!mdp->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;
>> +                       goto err_destroy_clock_wq;
>> +               }
>> +               mdp->scp = platform_get_drvdata(mm_pdev);
> 
> You need to keep the original code as a fallback for old device trees.
> 

I haven't removed the original code, it *is* there as a fallback :-)

mdp->scp = scp_get() <--- new
if (!mdp->scp) { fallback }

Regards,
Angelo

> ChenYu
> 
>>          }
>> -       mdp->scp = platform_get_drvdata(mm_pdev);
>> +
>>          mdp->rproc_handle = scp_get_rproc(mdp->scp);
>>          dev_dbg(&pdev->dev, "MDP rproc_handle: %pK", mdp->rproc_handle);
>>
>> --
>> 2.42.0
>>
> _______________________________________________
> Kernel mailing list -- kernel@mailman.collabora.com
> To unsubscribe send an email to kernel-leave@mailman.collabora.com
Chen-Yu Tsai Sept. 19, 2023, 10:26 a.m. UTC | #3
On Tue, Sep 19, 2023 at 6:24 PM AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com> wrote:
>
> Il 19/09/23 12:21, Chen-Yu Tsai ha scritto:
> > On Tue, Sep 19, 2023 at 6:00 PM AngeloGioacchino Del Regno
> > <angelogioacchino.delregno@collabora.com> wrote:
> >>
> >> Instead of walking the entire parent node for something that has the
> >> right compatible, use the scp_get() function provided by the MediaTek
> >> SCP remoteproc driver to retrieve a handle to mtk_scp through the
> >> devicetree "mediatek,scp" (phandle) property.
> >>
> >> In case of multi-core SCP, this also allows to select a specific core.
> >>
> >> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> >> ---
> >>   .../media/platform/mediatek/mdp3/mtk-mdp3-core.c | 16 ++++++++++------
> >>   1 file changed, 10 insertions(+), 6 deletions(-)
> >>
> >> diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
> >> index 8677e7fd5083..d93d3833633e 100644
> >> --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
> >> +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
> >> @@ -254,13 +254,17 @@ static int mdp_probe(struct platform_device *pdev)
> >>                  goto err_destroy_job_wq;
> >>          }
> >>
> >> -       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;
> >> -               goto err_destroy_clock_wq;
> >> +       mdp->scp = scp_get(pdev);
> >> +       if (!mdp->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;
> >> +                       goto err_destroy_clock_wq;
> >> +               }
> >> +               mdp->scp = platform_get_drvdata(mm_pdev);
> >
> > You need to keep the original code as a fallback for old device trees.
> >
>
> I haven't removed the original code, it *is* there as a fallback :-)
>
> mdp->scp = scp_get() <--- new
> if (!mdp->scp) { fallback }

I see it now. I guess it's time to call it a day... I even replied with
the wrong email ...

Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>

> > ChenYu
> >
> >>          }
> >> -       mdp->scp = platform_get_drvdata(mm_pdev);
> >> +
> >>          mdp->rproc_handle = scp_get_rproc(mdp->scp);
> >>          dev_dbg(&pdev->dev, "MDP rproc_handle: %pK", mdp->rproc_handle);
> >>
> >> --
> >> 2.42.0
> >>
> > _______________________________________________
> > Kernel mailing list -- kernel@mailman.collabora.com
> > To unsubscribe send an email to kernel-leave@mailman.collabora.com
>
>
AngeloGioacchino Del Regno Sept. 19, 2023, 10:28 a.m. UTC | #4
Il 19/09/23 12:26, Chen-Yu Tsai ha scritto:
> On Tue, Sep 19, 2023 at 6:24 PM AngeloGioacchino Del Regno
> <angelogioacchino.delregno@collabora.com> wrote:
>>
>> Il 19/09/23 12:21, Chen-Yu Tsai ha scritto:
>>> On Tue, Sep 19, 2023 at 6:00 PM AngeloGioacchino Del Regno
>>> <angelogioacchino.delregno@collabora.com> wrote:
>>>>
>>>> Instead of walking the entire parent node for something that has the
>>>> right compatible, use the scp_get() function provided by the MediaTek
>>>> SCP remoteproc driver to retrieve a handle to mtk_scp through the
>>>> devicetree "mediatek,scp" (phandle) property.
>>>>
>>>> In case of multi-core SCP, this also allows to select a specific core.
>>>>
>>>> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
>>>> ---
>>>>    .../media/platform/mediatek/mdp3/mtk-mdp3-core.c | 16 ++++++++++------
>>>>    1 file changed, 10 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
>>>> index 8677e7fd5083..d93d3833633e 100644
>>>> --- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
>>>> +++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
>>>> @@ -254,13 +254,17 @@ static int mdp_probe(struct platform_device *pdev)
>>>>                   goto err_destroy_job_wq;
>>>>           }
>>>>
>>>> -       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;
>>>> -               goto err_destroy_clock_wq;
>>>> +       mdp->scp = scp_get(pdev);
>>>> +       if (!mdp->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;
>>>> +                       goto err_destroy_clock_wq;
>>>> +               }
>>>> +               mdp->scp = platform_get_drvdata(mm_pdev);
>>>
>>> You need to keep the original code as a fallback for old device trees.
>>>
>>
>> I haven't removed the original code, it *is* there as a fallback :-)
>>
>> mdp->scp = scp_get() <--- new
>> if (!mdp->scp) { fallback }
> 
> I see it now. I guess it's time to call it a day... I even replied with
> the wrong email ...
> 
> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>

hahaha! no worries, it happens :-)

Thanks for the review btw.

Cheers!
Angelo

> 
>>> ChenYu
>>>
>>>>           }
>>>> -       mdp->scp = platform_get_drvdata(mm_pdev);
>>>> +
>>>>           mdp->rproc_handle = scp_get_rproc(mdp->scp);
>>>>           dev_dbg(&pdev->dev, "MDP rproc_handle: %pK", mdp->rproc_handle);
>>>>
>>>> --
>>>> 2.42.0
>>>>
>>> _______________________________________________
>>> Kernel mailing list -- kernel@mailman.collabora.com
>>> To unsubscribe send an email to kernel-leave@mailman.collabora.com
>>
>>
Hans Verkuil Oct. 2, 2023, 8:59 a.m. UTC | #5
On 19/09/2023 11:59, AngeloGioacchino Del Regno wrote:
> Especially now that Multi-Core SCP support has landed, it makes sense to
> retrieve the SCP handle by using the "mediatek,scp" property (as already
> done in MediaTek VCODEC), both to select one specific SCP core for MDP3
> and to avoid walking the parent node to find a SCP node.
> 
> AngeloGioacchino Del Regno (2):
>   media: dt-bindings: mediatek: Add phandle to mediatek,scp on MDP3 RDMA
>   media: platform: mtk-mdp3: Use devicetree phandle to retrieve SCP
> 
>  .../bindings/media/mediatek,mdp3-rdma.yaml       |  6 ++++++
>  .../media/platform/mediatek/mdp3/mtk-mdp3-core.c | 16 ++++++++++------
>  2 files changed, 16 insertions(+), 6 deletions(-)
> 

This series no longer applies to our staging master branch.

Since Krzysztof also asked for a better patch 1/2, I prefer a rebased and
updated v5.

Regards,

	Hans