Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4107631pxk; Tue, 8 Sep 2020 10:53:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYVATcR5W70lWmulWZ/p1CvsrzaxpE7Tmv3bRZ20zKPRgTsInDgxEm9eRcXa22vP3FVSU2 X-Received: by 2002:a17:906:37c1:: with SMTP id o1mr26907303ejc.279.1599587621158; Tue, 08 Sep 2020 10:53:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599587621; cv=none; d=google.com; s=arc-20160816; b=ajAvmvdm3WOKZqgTmAtEnylEWMfXXR9GSLtW6QbT30zBLzGy6EknjpJgBL1hr120pS huW/xj8mEHVEGET2tV/YsXOucMvfgpd18xKRkVj1JHWdPuxJl/GooQUjyeda6Tmq8yMW j5nnsA+vQi0NkVWqmU4TZro4W8/XRZYDc+inoNTM6kVY2p8de9XxiG1+93VRRhF9q1qF TfLCvQd11of06VRsd5j9HONfWTtUQgmc6BI7x8QRy0+61OS8ifKrO1zl0rQYOyfDz6iQ Klr7/goeSE7akr9rLWz+E1hCTrt1VF8VASw+oTZPOvV5KqXDAocT74ndgLA9HhTKGu0I JWpw== 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:message-id:subject:cc:to:from:date :dkim-signature; bh=idekEFVlR8bF2x2KW4e0wlvyItIA71XWxj/Y+99F3nY=; b=xLY5fasgUgJm2NaEJOltV/h2M88imKw37W+sKtIb1wtrEl0LugAl1Hs8GC8FsLCzbB O8cDuCbDpvAsTjJtFKZeqC44tgmczvd6/nfR1qUssZsy/bSYyilg4cRtmFdXB8PDmFBh d2568WXJ4EkP5LJgPJndnigkgkFRZOsw8hoe1XTp26TirJzr6+n7V5Ly5PXCZqL80q83 FfMui8oVpfYnm5Pk7A0D+C5h3NV+OnsE67jdk3KLTNLWQXGN6n80L96HnZ4SdeJB2e9J FRhYAVzt41/I8kLqsvuarBqwO5MXVIkBr9KmT6tbFTz0PX3w0ocuWCVbVFa3lucWubbG 3dQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=RER59LuX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a5si11921898edx.243.2020.09.08.10.53.18; Tue, 08 Sep 2020 10:53:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=RER59LuX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731816AbgIHRwp (ORCPT + 99 others); Tue, 8 Sep 2020 13:52:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731624AbgIHQNo (ORCPT ); Tue, 8 Sep 2020 12:13:44 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C208CC0612A3 for ; Tue, 8 Sep 2020 06:04:36 -0700 (PDT) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 919001234; Tue, 8 Sep 2020 14:59:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1599569961; bh=GDMaaknSuM/l5R2bNi1lvtcCye+AKH88XR9vhap1/7A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RER59LuXTiblOv2vSyDxvZpT+Ed7gQ+POuX8WyqY88MvZXDj3Y50WMKCNegqg5to5 K0fGTPm/wCJATwzOQEk2vCENEnxIF4UkJNBzKwxKuy+KFqt99DQEKAb/CxaK4reQ4D pGJqx5590eRkfuBSB+fie6ZxVTRbPj7s2eGEE6zk= Date: Tue, 8 Sep 2020 15:58:55 +0300 From: Laurent Pinchart To: Stefan Agner Cc: marex@denx.de, airlied@linux.ie, daniel@ffwll.ch, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, tomi.valkeinen@ti.com, linux-imx@nxp.com, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] drm: mxsfb: check framebuffer pitch Message-ID: <20200908125855.GL6047@pendragon.ideasonboard.com> References: <20200908125558.256843-1-stefan@agner.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200908125558.256843-1-stefan@agner.ch> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Stefan, Thank you for the patch. On Tue, Sep 08, 2020 at 02:55:58PM +0200, Stefan Agner wrote: > The lcdif IP does not support a framebuffer pitch (stride) other than > framebuffer width. Check for equality and reject the framebuffer > otherwise. > > This prevents a distorted picture when using 640x800 and running the > Mesa graphics stack. Mesa tires to use a cache aligned stride, which Still s/tires/tries/ :-) > leads at that particular resolution to width != stride. Currently > Mesa has no fallback behavior, but rejecting this configuration allows > userspace to handle the issue correctly. > > Signed-off-by: Stefan Agner Reviewed-by: Laurent Pinchart > --- > drivers/gpu/drm/mxsfb/mxsfb_drv.c | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c > index 8c549c3931af..fa6798d21029 100644 > --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c > +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c > @@ -21,6 +21,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -81,8 +82,26 @@ void mxsfb_disable_axi_clk(struct mxsfb_drm_private *mxsfb) > clk_disable_unprepare(mxsfb->clk_axi); > } > > +static struct drm_framebuffer * > +mxsfb_fb_create(struct drm_device *dev, struct drm_file *file_priv, > + const struct drm_mode_fb_cmd2 *mode_cmd) > +{ > + const struct drm_format_info *info; > + > + info = drm_get_format_info(dev, mode_cmd); > + if (!info) > + return ERR_PTR(-EINVAL); > + > + if (mode_cmd->width * info->cpp[0] != mode_cmd->pitches[0]) { > + dev_dbg(dev->dev, "Invalid pitch: fb width must match pitch\n"); > + return ERR_PTR(-EINVAL); > + } > + > + return drm_gem_fb_create(dev, file_priv, mode_cmd); > +} > + > static const struct drm_mode_config_funcs mxsfb_mode_config_funcs = { > - .fb_create = drm_gem_fb_create, > + .fb_create = mxsfb_fb_create, > .atomic_check = drm_atomic_helper_check, > .atomic_commit = drm_atomic_helper_commit, > }; -- Regards, Laurent Pinchart