Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp221547pxx; Wed, 28 Oct 2020 03:15:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxF0bO7uK9Hf895Hoq4GunI0lvrTa0QjwwH75xwaJZS2iqcB+j5+bmjIkWeJfIJNFTLc7On X-Received: by 2002:a50:cbc7:: with SMTP id l7mr6826127edi.148.1603880106162; Wed, 28 Oct 2020 03:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603880106; cv=none; d=google.com; s=arc-20160816; b=qCen5E+EEaiC1n8X9RsrOMP/0Wr5DWN0zZd9278uPghJRJWWpMgJCSdxv8j0JKjW1i jqXa390LkD6Twd3sZGjLJe4AHcLEIO2/YukYzekOwoq78M4hYAAXAKPtFD12zMW43gwT OCpyeOasRiz37Zpd1wE0c3jYrTLAGlAQkn4IsregGoNwt3RRpXrw3cjRQGmAkvpN8a0X T2tPCRjaPdLAX29R7u7i4wCmzFiHEgkTMA9i2qQEMmvIbPlHK+7Marm0INscA7M1exuS 5PpIzyrv+2JksvDclO3j6rfLg9r4C4LvcAcS5K4Fa0cwONDHEIm9eBhcqHXhTFmjA1en a3Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wBPzEySEeotEld9oMP7hN+88/Rll7z7zzLd7+aBlM3U=; b=pKBExw9CMtKmy57WHs5Ytunlk+HDfGhG7saMuee7J3k9fitG7Q6IsPg3EwVTxUpC8d Gf7z/sxaigQCY/nWPqbBoUr8zpD2TyRE0rS5waBLbGgn9rokVsdLp0Nk9uUbt+mWTaVo dGaKRmOMrg0WRvtW457uBeGMk69d9/czFllQrJYQYd3yc4LQDVu0Ri0gw3vScwJ2VNEr V/nY/SDTJOJU7yWelaX08xo8dK2YIV4owgYp18G8zkZcLEV6XfCJoOalb7erk6jh0FLD pxBVzElqXMkclcg3nKWBHiTgJVvdqfBacsHXCKTk5WyoBT11nNMQmLOt0F1d6d8jk9zG Bvxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U3fYV6NN; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p19si2741759edu.169.2020.10.28.03.14.44; Wed, 28 Oct 2020 03:15:06 -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 header.i=@kernel.org header.s=default header.b=U3fYV6NN; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1743846AbgJ0Ogv (ORCPT + 99 others); Tue, 27 Oct 2020 10:36:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:35252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760774AbgJ0OgZ (ORCPT ); Tue, 27 Oct 2020 10:36:25 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 838E622202; Tue, 27 Oct 2020 14:36:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809384; bh=Ecf0yql+zoT0pyv047KGBEdCZlzEQhf5i6DcdzlRRcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U3fYV6NNXwUEjsCSiyiXUyOL5JnLi/jQaTGB0lDUfz1AeiRG3Z9tPdBE87OAA0isi jsXeEIGl05+S6hqtUurQ3n9HM9imyN7vpsDpHmJx/PkYUUeaB1HiZXUlo+VWZpnpRI 6FZeOvdNpHdTjDzMA5rD9TkO3qmy+/J4kie5Ciek= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan Agner , Laurent Pinchart , Sasha Levin Subject: [PATCH 5.4 149/408] drm: mxsfb: check framebuffer pitch Date: Tue, 27 Oct 2020 14:51:27 +0100 Message-Id: <20201027135502.006469538@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Agner [ Upstream commit d5a0c816900419105a12e7471bf074319dfa34be ] 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 tries to use a cache aligned stride, which 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. Fixes: 45d59d704080 ("drm: Add new driver for MXSFB controller") Signed-off-by: Stefan Agner Reviewed-by: Laurent Pinchart Link: https://patchwork.freedesktop.org/patch/msgid/20200908141654.266836-1-stefan@agner.ch Signed-off-by: Sasha Levin --- 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 e8506335cd155..1694a7deb9133 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -87,8 +88,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, }; -- 2.25.1