Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp393086ybl; Tue, 7 Jan 2020 07:58:25 -0800 (PST) X-Google-Smtp-Source: APXvYqyPoo9Gg/9ZlFrkLiMbWfI1P0whCvK8XulORZVQccBy/MzzAyz3B0MrbE0KI/B7tumHO9YK X-Received: by 2002:a05:6830:1e2d:: with SMTP id t13mr472336otr.128.1578412705252; Tue, 07 Jan 2020 07:58:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578412705; cv=none; d=google.com; s=arc-20160816; b=fZEiVPW/sgSUGrUeFwuE+5u123lOd+15gb3ipKWuZiRps/xWDv88n6Aa5RRmXNdF9O xxv1xAxyfrBVsX2FNLKIRq7LecJUjza1sP5UPmMj3qDMyaGbXysUKBpdCNr1JCgiRREw JauysMi9gtgxXA22NqYamHDgmO4bxom1/sFjFt4hLPknIAHAnkQz31pDkJ1p2Fcm3wqV XpuGbWiku13g6YIMAlaZ6/vsrxQ7y7OuRsadusi8hEmiFu3OfHUElk6lHDLSZaFQhtRv 1IN/ZGhI81RziYiUkIqPkbyX1aGYBdtTaRhjuRYINZKJezQO+29ZPk8mm20vc10YQ2q9 GCfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:dkim-signature; bh=CvMm05V8g7+0q+Ui42OmT25y1ziIysK8ZY1Hix9SYOk=; b=yMiAII92jaMQO7o/8E4L5oS6nhO9m+LOjFrtABGVSUJCGFBmSARRdsHSpXViNF7bi5 yK5leZJrBM7ZUzbjahIq/hhNvj31cMte7VI/zW61dFEdUJyDL3mQJWHrxff4LrXlTrM8 MOykL9Qqojq616cVvBsAxXI4CK0tvOXKNaxBh2Rocx3VVDTcR2ZK9lAMP4ZTu2Dy6/4x AlrxetThoUyc9xI8Mesbvh+0HYxDKzSJg2ZpUrIDlepfv9fNax/rx/Iwq9yfV0L1AQkN CDeHxsNgPx2THxkVH8wiXe9m7GPrVZVlS/BFffTbPTwvE3/jvxodnkEctl9jie1guw6j +a5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=b5zAbHoL; 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 k9si129129oih.157.2020.01.07.07.58.11; Tue, 07 Jan 2020 07:58:25 -0800 (PST) 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=@ffwll.ch header.s=google header.b=b5zAbHoL; 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 S1728211AbgAGP4P (ORCPT + 99 others); Tue, 7 Jan 2020 10:56:15 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:37963 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727994AbgAGP4O (ORCPT ); Tue, 7 Jan 2020 10:56:14 -0500 Received: by mail-wr1-f67.google.com with SMTP id y17so54552690wrh.5 for ; Tue, 07 Jan 2020 07:56:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=CvMm05V8g7+0q+Ui42OmT25y1ziIysK8ZY1Hix9SYOk=; b=b5zAbHoLeEnnKv5Pe2FO8SXc2DC9kOf7vi90pfVCVrAZTrEqSStlebOBOleTywwlu0 L1b/R2sUnO88QH7MdQfYAwQKY5CQiKyAu450/ywdWpvDC9aV4+qVyu+F0elZsnXKGkGY x40SQaNAwyLjhSWVZzFNqi/j/WpUXI/vYyuEs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=CvMm05V8g7+0q+Ui42OmT25y1ziIysK8ZY1Hix9SYOk=; b=U7sD7ERL2PW/wLozhhy4hP1fc8+bayBiRR42raQuwuZLC3hSwLxWSp7wMmr/4Pz2ZF E8jUBnq4B0AmLldi7/7hpYP6iyPYM7TkoNJlhZb4s0VPqYABpj2sE9yM+QhzsBcTupbR DA6TYObQcUAy86NE+uH+/wN/NlrGmrOik8FwmRQu01dYSx/s1IQGma8jwwKbjdttLA1M SoT1ZFry6GZuNZPiv5+USaKpHCXCJp4rn4D0wSvj0777KSmYw+47uqNelVePwsJ1OX+9 zDKEPsN5a4NO3+hH5T+FEw1CB+K6/NpCyhY2z0Y3A+umFysEKIS+AJBOxXvgGN8Cu6fE cASA== X-Gm-Message-State: APjAAAVcPmkbsWiIjy7Q4UMn9TRmOeKpZpaqu8BR944DhEWNLkKZXJDN qLwGWa7Bw4ym1eZSWlhG737IlQ== X-Received: by 2002:a5d:4a91:: with SMTP id o17mr32868608wrq.232.1578412572311; Tue, 07 Jan 2020 07:56:12 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:564b:0:7567:bb67:3d7f:f863]) by smtp.gmail.com with ESMTPSA id v17sm242529wrt.91.2020.01.07.07.56.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 07:56:11 -0800 (PST) Date: Tue, 7 Jan 2020 16:56:09 +0100 From: Daniel Vetter To: Geert Uytterhoeven Cc: Stefan Agner , Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , Bartlomiej Zolnierkiewicz , Tomi Valkeinen , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/fb-helper: Round up bits_per_pixel if possible Message-ID: <20200107155609.GC43062@phenom.ffwll.local> Mail-Followup-To: Geert Uytterhoeven , Stefan Agner , Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Bartlomiej Zolnierkiewicz , Tomi Valkeinen , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20191230132734.4538-1-geert+renesas@glider.be> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191230132734.4538-1-geert+renesas@glider.be> X-Operating-System: Linux phenom 5.3.0-3-amd64 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 30, 2019 at 02:27:34PM +0100, Geert Uytterhoeven wrote: > When userspace requests a video mode parameter value that is not > supported, frame buffer device drivers should round it up to a supported > value, if possible, instead of just rejecting it. This allows > applications to quickly scan for supported video modes. > > Currently this rule is not followed for the number of bits per pixel, > causing e.g. "fbset -depth N" to fail, if N is smaller than the current > number of bits per pixel. > > Fix this by returning an error only if bits per pixel is too large, and > setting it to the current value otherwise. > > See also Documentation/fb/framebuffer.rst, Section 2 (Programmer's View > of /dev/fb*"). > > Fixes: 865afb11949e5bf4 ("drm/fb-helper: reject any changes to the fbdev") > Signed-off-by: Geert Uytterhoeven Applied to drm-misc-fixes with a cc:stable. Aside, would be really lovely if someone who cares about these fbdev details would start to with some unit tests in the drm testsuite: https://dri.freedesktop.org/docs/drm/gpu/drm-uapi.html?highlight=igt#testing-and-validation The drm version is gearing up to be _the_ fbdev implementation, that way we could make sure it wont break (e.g. intel gfx CI would run this stuff if it's in igt). Thanks, Daniel > --- > Against drm-misc#for-linux-next. > Applies with some fuzz against v5.5-rc4. > --- > drivers/gpu/drm/drm_fb_helper.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c > index f8e9051926083373..cae8fa74781c8db0 100644 > --- a/drivers/gpu/drm/drm_fb_helper.c > +++ b/drivers/gpu/drm/drm_fb_helper.c > @@ -1267,7 +1267,7 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var, > * Changes struct fb_var_screeninfo are currently not pushed back > * to KMS, hence fail if different settings are requested. > */ > - if (var->bits_per_pixel != fb->format->cpp[0] * 8 || > + if (var->bits_per_pixel > fb->format->cpp[0] * 8 || > var->xres > fb->width || var->yres > fb->height || > var->xres_virtual > fb->width || var->yres_virtual > fb->height) { > drm_dbg_kms(dev, "fb requested width/height/bpp can't fit in current fb " > @@ -1292,6 +1292,11 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var, > drm_fb_helper_fill_pixel_fmt(var, fb->format->depth); > } > > + /* > + * Likewise, bits_per_pixel should be rounded up to a supported value. > + */ > + var->bits_per_pixel = fb->format->cpp[0] * 8; > + > /* > * drm fbdev emulation doesn't support changing the pixel format at all, > * so reject all pixel format changing requests. > -- > 2.17.1 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch