Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1623929ybv; Fri, 21 Feb 2020 00:30:04 -0800 (PST) X-Google-Smtp-Source: APXvYqzcT0wI1FTD9EsRy8tOztCnWsWzN5Ar6hdgPBaNOsj+V3Ok6uIJTcMO0zm2GoN2VrHmfNOf X-Received: by 2002:a9d:7842:: with SMTP id c2mr25302882otm.252.1582273804468; Fri, 21 Feb 2020 00:30:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273804; cv=none; d=google.com; s=arc-20160816; b=rSJbHT4JGMFkH4QwrOZ0/V49mpVJKZhdig+LKtvnXSinnhXQIhGWeCbHA99yubLMgA eUyrmnZLLaqhr5Ov85l9Ds19JvVrPcGCfI6j24lMEovCquqHpbGw5rZWckHTlTneIi19 XNnKZpQ9hxaF4okhJluypKTmT/pa7frsRyZ/7gOQyEB9p60Wbx9E9/ceD7ltKOZOc3pX kGNOaRtcO+NpTTDoAV8NbaFG0ZUUbQx1coxHM86iU//Nt7E4T1JJx0sYzipH7/oQAtcQ Zs4UzCrwUEM2aC2iGssNSd6JxTwTUqFeko8WH577Xr5eIbvJQyAbeM2vIdUNQ3cg3K4f 1zBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1YXQnb/VbZ1npczUPbfP0XC/q9Dtbnb6mcK8lk2Z+O0=; b=BvJV74qAGbX5qbhUTtIOo/kGqxYgY6pwjv0AuAGJ5NkGarELIXLjrxQB9LPpqzoyf0 yBNjmM5rkMnGXIKAuUgUufbFdVsnsqRie+UvXbvjNCEx61hOYgQ8mXjHuVD5WldNyzYc /u32YEGLfW0rGri88PulTz4eprApXVhdTcwTGZ6C3otAFSpcWBthQ/+2n6evGoHGU5SJ IoUjzR+32YCLxD76qcXrvLJoyngGJikJe+JYiEZ7f3SaZrhlAWW3HQWh4zFTSDCYebCN 8PAklNCYbtHpW9G2tYD/Jij83PA4hsOwshlkIcXTopKGIHl4QxmBaw4CUImdNITAZeNl Th1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VoY3mrXu; 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 d8si1104610otp.295.2020.02.21.00.29.52; Fri, 21 Feb 2020 00:30:04 -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=@kernel.org header.s=default header.b=VoY3mrXu; 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 S1732970AbgBUI3K (ORCPT + 99 others); Fri, 21 Feb 2020 03:29:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:56122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387802AbgBUISR (ORCPT ); Fri, 21 Feb 2020 03:18:17 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 15E7724692; Fri, 21 Feb 2020 08:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273096; bh=GgRpWvLJvUfADI6jpLR7sdNqSk1r0qN4laNyfzj7NUw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VoY3mrXuf2cot9SFT0nNhU2zZfFjd9IjVHVIlBo8j5iA+fjB6cYHC0F5FMn26OIg0 4MY8CozmpAtAMcIwr5KWgSH3TFTmMs6Y39R+IdKJrNC+7wqXsZdQCMNeVM31ii9Yoj /Jhqh7Ik6Fo/9Wgj5b9j3LUyKcZvultMTimkmbdk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Kocialkowski , Patrik Jakobsson , Sasha Levin Subject: [PATCH 4.19 010/191] drm/gma500: Fixup fbdev stolen size usage evaluation Date: Fri, 21 Feb 2020 08:39:43 +0100 Message-Id: <20200221072252.304048436@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paul Kocialkowski [ Upstream commit fd1a5e521c3c083bb43ea731aae0f8b95f12b9bd ] psbfb_probe performs an evaluation of the required size from the stolen GTT memory, but gets it wrong in two distinct ways: - The resulting size must be page-size-aligned; - The size to allocate is derived from the surface dimensions, not the fb dimensions. When two connectors are connected with different modes, the smallest will be stored in the fb dimensions, but the size that needs to be allocated must match the largest (surface) dimensions. This is what is used in the actual allocation code. Fix this by correcting the evaluation to conform to the two points above. It allows correctly switching to 16bpp when one connector is e.g. 1920x1080 and the other is 1024x768. Signed-off-by: Paul Kocialkowski Signed-off-by: Patrik Jakobsson Link: https://patchwork.freedesktop.org/patch/msgid/20191107153048.843881-1-paul.kocialkowski@bootlin.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/gma500/framebuffer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c index adefae58b5fcd..b4035ef72af8a 100644 --- a/drivers/gpu/drm/gma500/framebuffer.c +++ b/drivers/gpu/drm/gma500/framebuffer.c @@ -480,6 +480,7 @@ static int psbfb_probe(struct drm_fb_helper *helper, container_of(helper, struct psb_fbdev, psb_fb_helper); struct drm_device *dev = psb_fbdev->psb_fb_helper.dev; struct drm_psb_private *dev_priv = dev->dev_private; + unsigned int fb_size; int bytespp; bytespp = sizes->surface_bpp / 8; @@ -489,8 +490,11 @@ static int psbfb_probe(struct drm_fb_helper *helper, /* If the mode will not fit in 32bit then switch to 16bit to get a console on full resolution. The X mode setting server will allocate its own 32bit GEM framebuffer */ - if (ALIGN(sizes->fb_width * bytespp, 64) * sizes->fb_height > - dev_priv->vram_stolen_size) { + fb_size = ALIGN(sizes->surface_width * bytespp, 64) * + sizes->surface_height; + fb_size = ALIGN(fb_size, PAGE_SIZE); + + if (fb_size > dev_priv->vram_stolen_size) { sizes->surface_bpp = 16; sizes->surface_depth = 16; } -- 2.20.1