Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp2003312ybn; Thu, 26 Sep 2019 05:39:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyYQTuSAngahbm5SOwLC6y2shF7k0o39QC2u1qxwBO25Dg9HmLaZ5TphxPPUV0Ce5tZeMA X-Received: by 2002:aa7:dad3:: with SMTP id x19mr3358460eds.59.1569501579235; Thu, 26 Sep 2019 05:39:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569501579; cv=none; d=google.com; s=arc-20160816; b=DdDEfzYprRwHZ1YUfAguj27MdpDBJMNE9DYbB7WsKd2O2wDXzXaJhAWPGVvuTokYmj d4d2gQJGOItlmDoUU/6Ki8hQm7UsETorWqLviqN0QIQDvOiOXLXr1Ltl+zcN22rUiHyj xG4WLwcI1o2Z1cXO+07pBZ//+j4+QgZTN6k9cPWkGAsouopcI82wNvJpBU42If1/8gFV +dphc7OnAwx6aXtdU099MKXXHL0+8ztGVHpOgFq1QsRE+iK+Cibb5cJExvpHf5L3fnp1 CJQFJ+7qan2WrAt1lL4ZE4s3Lcahrrk5l710CorZQHoLad7O7jB8DJESJ58yuZBvRETa FLeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature; bh=F/ph18P8dDBRn8Qlal+A+9M+o9VGG9/gZjxODSiky58=; b=Mch8/BaOwoa0mMY8MjExbrv8gyUaB7aMhp/ZKZ82GrxyMmNV9f1d9D39GEgTdPSFTx XhrcdUWxPznoS4IDLvkP8zLwzM2Nvm20uq1Bh/umtHd4JV+beWNQ6n0wMiwB7Qkuokxl idBlCgFrcEmPqsOYzlmOA97A4h/DWyzWIIdC/BFu2f7ozmPRVvxj1N6NodLOeLkMkDKZ n1ZiI0pW8DmhO4eKmovIc68sn4IDu8fAYgIbwX1ie6XFVlxanKMVicN66NBEG+IidoiH yv4v5joLD+oSLa08IgESgBoxzb+lydFVwGlcpS/e6+KVkSssCQG6DW2HU//FbysVYodb EyqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=QKUGJD6k; dkim=pass header.i=@codeaurora.org header.s=default header.b=VHb6ytHq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a2si1210046edc.321.2019.09.26.05.39.15; Thu, 26 Sep 2019 05:39:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=QKUGJD6k; dkim=pass header.i=@codeaurora.org header.s=default header.b=VHb6ytHq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439489AbfIXR2v (ORCPT + 99 others); Tue, 24 Sep 2019 13:28:51 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:34902 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729883AbfIXR2v (ORCPT ); Tue, 24 Sep 2019 13:28:51 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id A685C6137D; Tue, 24 Sep 2019 17:28:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1569346129; bh=m5nRpCCGsAeJVX0FTjg6i2xbJTPmx0BJPve6hoE/kIo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=QKUGJD6khFRs5aD7ZiXRqG6r6wNlfHC0AyTatEZ2EqNtvpGWeeTFP9HyZBxk5qpQN eRkuETyaNkqJTa5msPsutmeM9Y7o88VVCAOktjhyJHymg+BWcJDS/ii7hSMVjo7j63 aQE5L2KHMzyvsIBAeRtB5+fXc+6wa8COArEgBI3s= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id B673E61214; Tue, 24 Sep 2019 17:28:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1569346128; bh=m5nRpCCGsAeJVX0FTjg6i2xbJTPmx0BJPve6hoE/kIo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VHb6ytHqFfkvnGh/XX/YQdEQJVoueT4RPiEaoUqqv9J98u2ecMdvNsEHCwLqIRDxI UKFLZtrB3AYTpj6ZBNBsHx+SUztKyBuVksO/2cMZivUfKKY2gzX1G2MeLZOfhCsRDK lRW+5dSlmv7JpdOr4fyEKLTi+5I5QFIqbWuTIXNA= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 24 Sep 2019 10:28:48 -0700 From: Jeykumar Sankaran To: Neil Armstrong Cc: Daniel Vetter , Linux ARM , linux-amlogic@lists.infradead.org, Linux Kernel Mailing List , dri-devel Subject: Re: [PATCH] drm/meson: fix max mode_config height/width In-Reply-To: <5dbd6337-7e08-f3f7-6d4a-d6bcaddfd3be@baylibre.com> References: <1538642563-22465-1-git-send-email-narmstrong@baylibre.com> <20181004100958.GI31561@phenom.ffwll.local> <0ef7fa13-ce77-f8a5-f5f3-6568be3d6145@baylibre.com> <8e980de4-5a52-8f3d-fba2-734617e40d1b@baylibre.com> <5dbd6337-7e08-f3f7-6d4a-d6bcaddfd3be@baylibre.com> Message-ID: <91cd8a2aebefd4ea3e9bcee5a4ef796a@codeaurora.org> X-Sender: jsanka@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> 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