Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1690158 > unrolled thread

Re: [RFC][PATCH v2] drm: kirin: Add mode_valid logic to avoid mode clocks we can't generate

Started byJose Abreu <Jose.Abreu@synopsys.com>
First post2017-07-18 13:20 +0200
Last post2017-07-19 12:20 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [RFC][PATCH v2] drm: kirin: Add mode_valid logic to avoid mode  clocks we can't generate Jose Abreu <Jose.Abreu@synopsys.com> - 2017-07-18 13:20 +0200
    Re: [RFC][PATCH v2] drm: kirin: Add mode_valid logic to avoid mode  clocks we can't generate John Stultz <john.stultz@linaro.org> - 2017-07-18 19:00 +0200
      Re: [RFC][PATCH v2] drm: kirin: Add mode_valid logic to avoid mode  clocks we can't generate Jose Abreu <Jose.Abreu@synopsys.com> - 2017-07-19 12:20 +0200

#1690158 — Re: [RFC][PATCH v2] drm: kirin: Add mode_valid logic to avoid mode clocks we can't generate

FromJose Abreu <Jose.Abreu@synopsys.com>
Date2017-07-18 13:20 +0200
SubjectRe: [RFC][PATCH v2] drm: kirin: Add mode_valid logic to avoid mode clocks we can't generate
Message-ID<u4yHM-1HH-9@gated-at.bofh.it>
Hi John,


On 18-07-2017 05:22, John Stultz wrote:
> Currently the hikey dsi logic cannot generate accurate byte
> clocks values for all pixel clock values. Thus if a mode clock
> is selected that cannot match the calculated byte clock, the
> device will boot with a blank screen.
>
> This patch uses the new mode_valid callback (many thanks to
> Jose Abreu for upstreaming it!) to ensure we don't select
> modes we cannot generate.
>
> NOTE: Stylistically I suspect there are better ways to do what
> I'm trying to do here. The encoder -> crtc bit is terrible, and
> getting the crtc adjusted mode from the encoder logic feels
> less then ideal. So feedback would be greatly appreciated!
>
> Cc: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Sean Paul <seanpaul@chromium.org>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Rob Clark <robdclark@gmail.com>
> Cc: Xinliang Liu <xinliang.liu@linaro.org>
> Cc: Xinliang Liu <z.liuxinliang@hisilicon.com>
> Cc: Rongrong Zou <zourongrong@gmail.com>
> Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>
> Cc: Chen Feng <puck.chen@hisilicon.com>
> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
> Cc: Archit Taneja <architt@codeaurora.org>
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: John Stultz <john.stultz@linaro.org>
> ---
> v2: Reworked to calculate if modeclock matches the phy's byteclock,
>     rather then using a whitelist of known modes.

Something like Daniel suggested would be simpler maybe:

encoder_mode_valid_aux()
{
    ...
}

dsi_encoder_mode_valid(...)
{
    drm_for_each_crtc(crtc, dev) {
        crtc->mode_fixup(crtc, mode, adjusted_mode);
        ret = encoder_mode_valid_aux(adjusted_mode);
        if (ret != MODE_OK)
            return ret;
    }
}

BTW, I think at commit stage you have encoder->crtc populated,
not sure though. But at probbing stage it will not be bound. And
also if you have more than one crtc this may be wrong. (How will
you know which crtc will be bound to the encoder so that you can
get the right clock?).

Best regards,
Jose Miguel Abreu

[toc] | [next] | [standalone]


#1690443

FromJohn Stultz <john.stultz@linaro.org>
Date2017-07-18 19:00 +0200
Message-ID<u4E0N-4S6-3@gated-at.bofh.it>
In reply to#1690158
On Tue, Jul 18, 2017 at 4:10 AM, Jose Abreu <Jose.Abreu@synopsys.com> wrote:
> Hi John,
>
>
> On 18-07-2017 05:22, John Stultz wrote:
>> Currently the hikey dsi logic cannot generate accurate byte
>> clocks values for all pixel clock values. Thus if a mode clock
>> is selected that cannot match the calculated byte clock, the
>> device will boot with a blank screen.
>>
>> This patch uses the new mode_valid callback (many thanks to
>> Jose Abreu for upstreaming it!) to ensure we don't select
>> modes we cannot generate.
>>
>> NOTE: Stylistically I suspect there are better ways to do what
>> I'm trying to do here. The encoder -> crtc bit is terrible, and
>> getting the crtc adjusted mode from the encoder logic feels
>> less then ideal. So feedback would be greatly appreciated!
>>
>> Cc: Daniel Vetter <daniel.vetter@intel.com>
>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>> Cc: Sean Paul <seanpaul@chromium.org>
>> Cc: David Airlie <airlied@linux.ie>
>> Cc: Rob Clark <robdclark@gmail.com>
>> Cc: Xinliang Liu <xinliang.liu@linaro.org>
>> Cc: Xinliang Liu <z.liuxinliang@hisilicon.com>
>> Cc: Rongrong Zou <zourongrong@gmail.com>
>> Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>
>> Cc: Chen Feng <puck.chen@hisilicon.com>
>> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
>> Cc: Archit Taneja <architt@codeaurora.org>
>> Cc: dri-devel@lists.freedesktop.org
>> Signed-off-by: John Stultz <john.stultz@linaro.org>
>> ---
>> v2: Reworked to calculate if modeclock matches the phy's byteclock,
>>     rather then using a whitelist of known modes.
>
> Something like Daniel suggested would be simpler maybe:
>
> encoder_mode_valid_aux()
> {
>     ...
> }
>
> dsi_encoder_mode_valid(...)
> {
>     drm_for_each_crtc(crtc, dev) {
>         crtc->mode_fixup(crtc, mode, adjusted_mode);
>         ret = encoder_mode_valid_aux(adjusted_mode);
>         if (ret != MODE_OK)
>             return ret;
>     }
> }
>
> BTW, I think at commit stage you have encoder->crtc populated,
> not sure though. But at probbing stage it will not be bound. And
> also if you have more than one crtc this may be wrong. (How will
> you know which crtc will be bound to the encoder so that you can
> get the right clock?).


Thanks so much for the suggestion above and the explanation. I only
have a rough sense of the components and not as much sense of an
overview on how they are all initialized, so this is very helpful!

And yes, my case is fairly limited since the encoder and crtc are used
together for this driver, but I know it can be more complex with
others, so I'll re-implement as you've suggested!

One thing that does worry me with trying to validate modes without
knowing which path is to be used, is that if there were two crtcs (and
again, on my hardware, thankfully there isn't), and for a given mode,
one adjusted the mode and one didn't.  So then for that given mode the
encoder could only generate a valid mode for one of the crtcs, its not
clear if that is MODE_OK or MODE_BAD.  We don't want to prune modes
that could possibly work with other crtcs, but we don't want a mode
that cannot be generated be selected either.  To me it seems we should
have the path figured out before we go pruning modes. Obviously there
needs to be a probe step that checks if any mode works with a given
pipeline (so that we can validate the pipeline), but it seems like
there should be a second step to ensure once we have a pipeline bound
we don't try to use modes it cannot support. Am I further
misunderstanding something here?

Thanks again!
-john

[toc] | [prev] | [next] | [standalone]


#1691341

FromJose Abreu <Jose.Abreu@synopsys.com>
Date2017-07-19 12:20 +0200
Message-ID<u4Ufi-79T-75@gated-at.bofh.it>
In reply to#1690443
On 18-07-2017 17:56, John Stultz wrote:
> On Tue, Jul 18, 2017 at 4:10 AM, Jose Abreu <Jose.Abreu@synopsys.com> wrote:
>> Hi John,
>>
>>
>> On 18-07-2017 05:22, John Stultz wrote:
>>> Currently the hikey dsi logic cannot generate accurate byte
>>> clocks values for all pixel clock values. Thus if a mode clock
>>> is selected that cannot match the calculated byte clock, the
>>> device will boot with a blank screen.
>>>
>>> This patch uses the new mode_valid callback (many thanks to
>>> Jose Abreu for upstreaming it!) to ensure we don't select
>>> modes we cannot generate.
>>>
>>> NOTE: Stylistically I suspect there are better ways to do what
>>> I'm trying to do here. The encoder -> crtc bit is terrible, and
>>> getting the crtc adjusted mode from the encoder logic feels
>>> less then ideal. So feedback would be greatly appreciated!
>>>
>>> Cc: Daniel Vetter <daniel.vetter@intel.com>
>>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>>> Cc: Sean Paul <seanpaul@chromium.org>
>>> Cc: David Airlie <airlied@linux.ie>
>>> Cc: Rob Clark <robdclark@gmail.com>
>>> Cc: Xinliang Liu <xinliang.liu@linaro.org>
>>> Cc: Xinliang Liu <z.liuxinliang@hisilicon.com>
>>> Cc: Rongrong Zou <zourongrong@gmail.com>
>>> Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>
>>> Cc: Chen Feng <puck.chen@hisilicon.com>
>>> Cc: Jose Abreu <Jose.Abreu@synopsys.com>
>>> Cc: Archit Taneja <architt@codeaurora.org>
>>> Cc: dri-devel@lists.freedesktop.org
>>> Signed-off-by: John Stultz <john.stultz@linaro.org>
>>> ---
>>> v2: Reworked to calculate if modeclock matches the phy's byteclock,
>>>     rather then using a whitelist of known modes.
>> Something like Daniel suggested would be simpler maybe:
>>
>> encoder_mode_valid_aux()
>> {
>>     ...
>> }
>>
>> dsi_encoder_mode_valid(...)
>> {
>>     drm_for_each_crtc(crtc, dev) {
>>         crtc->mode_fixup(crtc, mode, adjusted_mode);
>>         ret = encoder_mode_valid_aux(adjusted_mode);
>>         if (ret != MODE_OK)
>>             return ret;
>>     }
>> }
>>
>> BTW, I think at commit stage you have encoder->crtc populated,
>> not sure though. But at probbing stage it will not be bound. And
>> also if you have more than one crtc this may be wrong. (How will
>> you know which crtc will be bound to the encoder so that you can
>> get the right clock?).
>
> Thanks so much for the suggestion above and the explanation. I only
> have a rough sense of the components and not as much sense of an
> overview on how they are all initialized, so this is very helpful!
>
> And yes, my case is fairly limited since the encoder and crtc are used
> together for this driver, but I know it can be more complex with
> others, so I'll re-implement as you've suggested!
>
> One thing that does worry me with trying to validate modes without
> knowing which path is to be used, is that if there were two crtcs (and
> again, on my hardware, thankfully there isn't), and for a given mode,
> one adjusted the mode and one didn't.  So then for that given mode the
> encoder could only generate a valid mode for one of the crtcs, its not
> clear if that is MODE_OK or MODE_BAD.  We don't want to prune modes
> that could possibly work with other crtcs, but we don't want a mode
> that cannot be generated be selected either.  To me it seems we should
> have the path figured out before we go pruning modes. Obviously there
> needs to be a probe step that checks if any mode works with a given
> pipeline (so that we can validate the pipeline), but it seems like
> there should be a second step to ensure once we have a pipeline bound
> we don't try to use modes it cannot support. Am I further
> misunderstanding something here?

Well, we can't know at probbing stage the path that will be
chosen. If you check drm_mode_validate_pipeline() at
drm_probe_helper.c you will see that we start from the connector,
then check which encoders can belong to the connector and which
crtc's can belong to the encoder. So, for any possible pipeline
we validate the mode and if at least one is accepted then the
mode is probbed. I only tested this in arcpgu, which only has 1
pipeline. Maybe when there is a more complex driver using this we
can find if this is the right approach :)

Best regards,
Jose Miguel Abreu

>
> Thanks again!
> -john

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web