linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Jeykumar Sankaran <jsanka@codeaurora.org>
To: Neil Armstrong <narmstrong@baylibre.com>
Cc: linux-amlogic@lists.infradead.org,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Daniel Vetter <daniel@ffwll.ch>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm/meson: fix max mode_config height/width
Date: Tue, 24 Sep 2019 10:28:48 -0700	[thread overview]
Message-ID: <91cd8a2aebefd4ea3e9bcee5a4ef796a@codeaurora.org> (raw)
In-Reply-To: <5dbd6337-7e08-f3f7-6d4a-d6bcaddfd3be@baylibre.com>

Reviving this thread from the context of the below conversion:

https://lore.kernel.org/linux-arm-msm/db26145b-3f64-a334-f698-76f972332881@baylibre.com/T/#u

On 2018-10-05 01:19, Neil Armstrong wrote:
> On 05/10/2018 09:58, Daniel Vetter wrote:
>> On Fri, Oct 5, 2018 at 9:39 AM Neil Armstrong 
>> <narmstrong@baylibre.com> wrote:
>>> 
> 
> [...]
> 
>>> OK, won't this be enough ?
>>> --- a/include/drm/drm_mode_config.h
>>> +++ b/include/drm/drm_mode_config.h
>>> @@ -333,6 +333,8 @@ struct drm_mode_config_funcs {
>>>   * @min_height: minimum fb pixel height on this device
>>>   * @max_width: maximum fb pixel width on this device
>>>   * @max_height: maximum fb pixel height on this device
>>> + * @max_fb_width: maximum fb buffer width if differs from max_width
>>> + * @max_fb_height: maximum fb buffer height if differs from 
>>> max_height
>>>   * @funcs: core driver provided mode setting functions
>>>   * @fb_base: base address of the framebuffer
>>>   * @poll_enabled: track polling support for this device
>>> @@ -508,6 +510,7 @@ struct drm_mode_config {
>>> 
>>>         int min_width, min_height;
>>>         int max_width, max_height;
>>> +       int max_fb_width, max_fb_height;
>>>         const struct drm_mode_config_funcs *funcs;
>>>         resource_size_t fb_base;
>>> 
>>> --- a/drivers/gpu/drm/drm_framebuffer.c
>>> +++ b/drivers/gpu/drm/drm_framebuffer.c
>>> @@ -283,14 +283,20 @@ drm_internal_framebuffer_create(struct 
>>> drm_device *dev,
>>>                 return ERR_PTR(-EINVAL);
>>>         }
>>> 
>>> -       if ((config->min_width > r->width) || (r->width > 
>>> config->max_width)) {
>>> +       if ((config->min_width > r->width) ||
>>> +           (!config->max_fb_width && r->width > config->max_width) 
>>> ||
>>> +           (config->max_fb_width && r->width > 
>>> config->max_fb_width)) {
>>>                 DRM_DEBUG_KMS("bad framebuffer width %d, should be >= 
>>> %d && <= %d\n",
>>> -                         r->width, config->min_width, 
>>> config->max_width);
>>> +                         r->width, config->min_width, 
>>> config->max_fb_width ?
>>> +                         config->max_fb_width : config->max_width);
>>>                 return ERR_PTR(-EINVAL);
>>>         }
>>> -       if ((config->min_height > r->height) || (r->height > 
>>> config->max_height)) {
>>> +       if ((config->min_height > r->height) ||
>>> +           (!config->max_fb_height && r->height > 
>>> config->max_height) ||
>>> +           (config->max_fb_height && r->height > 
>>> config->max_fb_height)) {
>>>                 DRM_DEBUG_KMS("bad framebuffer height %d, should be 
>>> >= %d && <= %d\n",
>>> -                         r->height, config->min_height, 
>>> config->max_height);
>>> +                         r->height, config->min_height, 
>>> config->max_fb_height ?
>>> +                         config->max_fb_height : 
>>> config->max_height);
>>>                 return ERR_PTR(-EINVAL);
>>>         }
>>> 
>>> and in the driver :
>>> 
>>> +       drm->mode_config.max_width = 4096;
>>> +       drm->mode_config.max_height = 3840;
>>> +       drm->mode_config.max_fb_width = 16384;
>>> +       drm->mode_config.max_fb_height = 8192;
>>> 
>>> With this I leave the mode filtering intact.
>> 
>> Not enough. See
>> https://dri.freedesktop.org/docs/drm/gpu/drm-kms-helpers.html#c.drm_connector_helper_funcs
>> and scroll down to mode_valid. You need to filter modes both in the
>> detect paths, and the atomic_check paths.
>> 
>> Detect is explicitly filtered out, but atomic_check was only
>> implicitly filtered, through the max fb size checks. Ok, you could
>> light up a mode that's bigger than max fb, but in practice, no
>> userspace ever did that.

Daniel, MSM and few other vendor hardware have upscale blocks where the 
driver can expose fb sizes smaller than
the mode resolution and use h/w upscaling to fill the screen. This would 
optimize the fetch bandwidth.

But with your code we're missing crucial
>> validation now, and userspace could fall over that. What I think we
>> need is to add mode filter against mode_config.max_width/height in
>> drm_atomic_helper_check_modeset(). Probably best to stuff that into
>> the mode_valid() function.
> 
Agreed! Since the above patch from Niel is taking care of cases where 
max/min fb values
are not set, by checking against the original max/min values, can we 
separate out this
core change from the driver level mode_valid changes? If Niel couldn't 
find the time, I can
repost the above change.

Thanks and Regards,
Jeykumar S.

> Ok I understood now, thanks for pointer, I'll try to add this.
> 
> Neil
> 
>> 
>> Cheers, Daniel
>>> 
>>> Neil
>>> 
>>> 
>>>> -Daniel
>>>> 
>>>>> 
>>>>> Neil
>>>>> 
>>>>>> 
>>>>>> Bunch of igt to make sure we're not missing anything would be 
>>>>>> sweet on
>>>>>> top, e.g. e.g. trying to set a mode over the limit and making sure 
>>>>>> it
>>>>>> fails.
>>>>>> 
>>>>>> Cheers, Daniel
>>>>>> 
>>>>>>> ---
>>>>>>>  drivers/gpu/drm/meson/meson_drv.c | 4 ++--
>>>>>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>>>>>> 
>>>>>>> diff --git a/drivers/gpu/drm/meson/meson_drv.c 
>>>>>>> b/drivers/gpu/drm/meson/meson_drv.c
>>>>>>> index d344312..2e29968 100644
>>>>>>> --- a/drivers/gpu/drm/meson/meson_drv.c
>>>>>>> +++ b/drivers/gpu/drm/meson/meson_drv.c
>>>>>>> @@ -243,8 +243,8 @@ static int meson_drv_bind_master(struct 
>>>>>>> device *dev, bool has_components)
>>>>>>>              goto free_drm;
>>>>>>> 
>>>>>>>      drm_mode_config_init(drm);
>>>>>>> -    drm->mode_config.max_width = 3840;
>>>>>>> -    drm->mode_config.max_height = 2160;
>>>>>>> +    drm->mode_config.max_width = 16384;
>>>>>>> +    drm->mode_config.max_height = 8192;
>>>>>>>      drm->mode_config.funcs = &meson_mode_config_funcs;
>>>>>>> 
>>>>>>>      /* Hardware Initialization */
>>>>>>> --
>>>>>>> 2.7.4
>>>>>>> 
>>>>>>> _______________________________________________
>>>>>>> dri-devel mailing list
>>>>>>> dri-devel@lists.freedesktop.org
>>>>>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>>>>> 
>>>>> 
>>>>> _______________________________________________
>>>>> dri-devel mailing list
>>>>> dri-devel@lists.freedesktop.org
>>>>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>>> 
>>>> 
>>>> 
>>> 
>> 
>> 
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Jeykumar S

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-09-24 17:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-04  8:42 [PATCH] drm/meson: fix max mode_config height/width Neil Armstrong
2018-10-04 10:09 ` Daniel Vetter
2018-10-04 15:04   ` Neil Armstrong
2018-10-04 18:10     ` Daniel Vetter
2018-10-05  7:39       ` Neil Armstrong
2018-10-05  7:58         ` Daniel Vetter
2018-10-05  8:19           ` Neil Armstrong
2019-09-24 17:28             ` Jeykumar Sankaran [this message]
2019-10-09 10:47               ` Daniel Vetter
2019-10-11 17:59                 ` Jeykumar Sankaran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=91cd8a2aebefd4ea3e9bcee5a4ef796a@codeaurora.org \
    --to=jsanka@codeaurora.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=narmstrong@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).