mbox series

[v2,0/5] Enable decoder for mt8183

Message ID 20230607205714.510012-1-nfraprado@collabora.com
Headers show
Series Enable decoder for mt8183 | expand

Message

Nícolas F. R. A. Prado June 7, 2023, 8:53 p.m. UTC
This series enables the hardware decoder present on mt8183. At first
glance, the only missing piece is the devicetree node for it, however,
simply adding it as is would cause an address collision between the
first register iospace and the clock-controller node, so a rework of the
dt-binding and driver, as well as addition of a clock, were needed
first.

Tested that H264 decoding works with the hardware decoder on
mt8183-kukui-jacuzzi-juniper-sku16, giving a fluster score of 98/135 on
the JVT-AVC_V1 test suite. And ensured other SoCs (MT8192 and MT8195)
still work as usual.

Changes in v2:
- Merged commit 1 (media: dt-bindings: mediatek,vcodec: Allow single
  clock for mt8183) into commit 3 (media: dt-bindings: mediatek,vcodec:
  Remove VDEC_SYS for mt8183)
- Further constrained properties in dt-binding
- Added CLK_IGNORE_UNUSED flag to active clock
- Reformatted reg-names in DT node

Nícolas F. R. A. Prado (4):
  media: dt-bindings: mediatek,vcodec: Don't require assigned-clocks
  media: dt-bindings: mediatek,vcodec: Remove VDEC_SYS for mt8183
  media: mediatek: vcodec: Read HW active status from clock
  clk: mediatek: mt8183: Add CLK_VDEC_ACTIVE to vdec

Yunfei Dong (1):
  arm64: dts: mediatek: mt8183: Add decoder

 .../media/mediatek,vcodec-decoder.yaml        | 65 +++++++++++++++----
 arch/arm64/boot/dts/mediatek/mt8183.dtsi      | 30 +++++++++
 drivers/clk/mediatek/clk-mt8183-vdec.c        |  5 ++
 .../mediatek/vcodec/mtk_vcodec_dec_drv.c      | 59 +++++++++++++----
 .../mediatek/vcodec/mtk_vcodec_dec_hw.c       | 20 ++++--
 .../mediatek/vcodec/mtk_vcodec_dec_pm.c       | 12 +++-
 .../platform/mediatek/vcodec/mtk_vcodec_drv.h |  1 +
 include/dt-bindings/clock/mt8183-clk.h        |  3 +-
 8 files changed, 165 insertions(+), 30 deletions(-)

Comments

AngeloGioacchino Del Regno June 14, 2023, 8:13 a.m. UTC | #1
Il 12/06/23 21:19, Stephen Boyd ha scritto:
> Quoting AngeloGioacchino Del Regno (2023-06-09 00:42:13)
>> Il 09/06/23 01:56, Stephen Boyd ha scritto:
>>> Quoting AngeloGioacchino Del Regno (2023-06-08 02:01:58)
>>>> Il 08/06/23 10:12, Chen-Yu Tsai ha scritto:
>>>>> On Thu, Jun 8, 2023 at 4:57 AM Nícolas F. R. A. Prado
>>>>> <nfraprado@collabora.com> wrote:
>>>>>> diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c
>>>>>> index 9c652beb3f19..8038472fb67b 100644
>>>>>> --- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c
>>>>>> +++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec_drv.c
>>>>>
>>>>> AFAIK this is still around for clk drivers that haven't moved to clk_hw.
>>>>> It shouldn't be used by clock consumers. Would it be better to just pass
>>>>> a syscon?
>>>>>
>>>>
>>>> This is a legit usage of __clk_is_enabled().... because that's what we're really
>>>> doing here, we're checking if a clock got enabled by the underlying MCU (as that
>>>> clock goes up after the VDEC boots).
>>>>
>>>> If this is *not* acceptable as it is, we will have to add a clock API call to
>>>> check if a clock is enabled... but it didn't seem worth doing since we don't
>>>> expect anyone else to have any legit usage of that, or at least, we don't know
>>>> about anyone else needing that...
>>>
>>> The design of the clk.h API has been that no clk consumer should need to
>>> find out if a clk is enabled. Instead, the clk consumer should enable
>>> the clk if they want it enabled. Is there no other way to know that the
>>> vcodec hardware is active?
>>>
>>
>> The firmware gives an indication of "boot done", but that's for the "core" part
>> of the vcodec... then it manages this clock internally to enable/disable the
>> "compute" IP of the decoder.
>>
>> As far as I know (and I've been researching about this) the firmware will not
>> give any "decoder powered, clocked - ready to get data" indication, and the
>> only way that we have to judge whether it is in this specific state or not is
>> to check if the "VDEC_ACTIVE" clock got enabled by the firmware.
> 
> Is Linux ever going to use clk consumer APIs like clk_enable/clk_disable
> on this VDEC_ACTIVE clk? If the answer is no, then there isn't any
> reason to put it in the clk framework, and probably syscon is the way to
> go for now.
> 

Not for the current platform, but that may change in future SoCs... we're not sure.

> Another approach could be to wait for some amount of time after telling
> firmware to power up and assume the hardware is active.
> 

That would be highly error prone though. Expecting that the HW is alive means that
we're 100% sure that both firmware and driver are doing the right thing at every
moment, which is something that we'd like to assume but, realistically, for safety
reasons we just don't.

Should we anyway go for a syscon *now* and then change it to a clock later, if any
new platform needs this as a clock?

I'm in doubt now on how to proceed.

> ----
> 
> I see that the __clk_is_enabled() API is being used in some other
> consumer drivers. I think at one point we were down to one or two users.
> I'll try to remove this function entirely, but it will still be possible
> to get at the clk_hw for a clk with __clk_get_hw() and then call
> clk_hw_is_enabled().
> 

Makes sense.

Regards,
Angelo
AngeloGioacchino Del Regno June 19, 2023, 7:45 a.m. UTC | #2
Il 15/06/23 19:40, Stephen Boyd ha scritto:
> Quoting AngeloGioacchino Del Regno (2023-06-15 00:30:56)
>> Il 15/06/23 02:40, Stephen Boyd ha scritto:
>>> Quoting AngeloGioacchino Del Regno (2023-06-14 01:13:43)
>>>> Il 12/06/23 21:19, Stephen Boyd ha scritto:
>>>>> Quoting AngeloGioacchino Del Regno (2023-06-09 00:42:13)
>>>>>> Il 09/06/23 01:56, Stephen Boyd ha scritto:
>>>>>>> Quoting AngeloGioacchino Del Regno (2023-06-08 02:01:58)
>>>>>>>> Il 08/06/23 10:12, Chen-Yu Tsai ha scritto:
>>>>>>>>> On Thu, Jun 8, 2023 at 4:57 AM Nícolas F. R. A. Prado
>>>>>>>>> <nfraprado@collabora.com> wrote:
>>>>>>
>>>>>> The firmware gives an indication of "boot done", but that's for the "core" part
>>>>>> of the vcodec... then it manages this clock internally to enable/disable the
>>>>>> "compute" IP of the decoder.
>>>>>>
>>>>>> As far as I know (and I've been researching about this) the firmware will not
>>>>>> give any "decoder powered, clocked - ready to get data" indication, and the
>>>>>> only way that we have to judge whether it is in this specific state or not is
>>>>>> to check if the "VDEC_ACTIVE" clock got enabled by the firmware.
>>>>>
>>>>> Is Linux ever going to use clk consumer APIs like clk_enable/clk_disable
>>>>> on this VDEC_ACTIVE clk? If the answer is no, then there isn't any
>>>>> reason to put it in the clk framework, and probably syscon is the way to
>>>>> go for now.
>>>>>
>>>>
>>>> Not for the current platform, but that may change in future SoCs... we're not sure.
>>>
>>> If you're not using the clk consumer APIs then it shouldn't be a clk.
>>>
>>>>
>>>>> Another approach could be to wait for some amount of time after telling
>>>>> firmware to power up and assume the hardware is active.
>>>>>
>>>>
>>>> That would be highly error prone though. Expecting that the HW is alive means that
>>>> we're 100% sure that both firmware and driver are doing the right thing at every
>>>> moment, which is something that we'd like to assume but, realistically, for safety
>>>> reasons we just don't.
>>>>
>>>> Should we anyway go for a syscon *now* and then change it to a clock later, if any
>>>> new platform needs this as a clock?
>>>
>>> Yeah. Or implement this as a power domain and have it read the register
>>> directly waiting to return from the power_on()?
>>
>> A power domain would force us to incorrectly describe the hardware in the bindings
>> though, I think... so, Nícolas, please, let's go for a syscon at this point, as it
> 
> You don't have to add the power domain in DT, do you? You can populate a
> power domain in software directly?
> 

Right. I didn't evaluate that possibility at all. Looks good!

>> really looks like being the only viable option.
>>
>> Stephen, many thanks for the valuable suggestions and the nice conversation.
>>
>