Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1928486ybv; Fri, 14 Feb 2020 08:23:12 -0800 (PST) X-Google-Smtp-Source: APXvYqzn0dsLcuofzv54QnGepfcl5Yomo0sAZP636w5hZTUiiMcvUofFDYF1I5bYb8hhil5Bs2hd X-Received: by 2002:a54:4791:: with SMTP id o17mr2317826oic.70.1581697392750; Fri, 14 Feb 2020 08:23:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581697392; cv=none; d=google.com; s=arc-20160816; b=tDF48M+Wf+Z1tNdK9PYQ3CW/aS3jSiRtx1rJz1cM2c83wtxZaCFg2VM+HqILLfBJAR DHwfvcC2vvdE/IYrq9+T6QlXiEY6gZ8nxyhfM1dieMivhyoFsMPk3owp7p0WgEMv6uW6 WgvzYmr6snMz0XBOu3B2xm3o/FTdMY6Q6RCKAQir829jyOJIrG4lFSITRnZ8TPrBehpu ghzcpGehkwGcMEHzzrAWetBm61U5UiwR7x/khJCFlRnLr+MlhifbWeAmTh2W6A3+RK2A GUcRkWGRsaDsym8BHrj2bWylm1tuzNEEP/CVOIo71CvXFfxSW6uE01eMf4O96vBhE2Yh Gb9Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=qIUu127+AMWPz8izc0St32q6c40vb4I6wJ9MeBrdoJw=; b=yAhiImPaszB3Axxl/5knsZl+S9K1M7Z0gna/aB9+DeYtWQj5jyASiBbcWptObhQ5re uL+Oi6cxVN4Z9rsRB9HbMlt3T+cEPw8QQaUMhn6EK1qOg6/WqN+GFyOrOCHdLcUVfeal K6rzGDQopuORsri9OaqaeVjJHpFMDF4GJeabgvv7fKl4oxIPWuezqCrBK+NIlPHUKkK1 JBMBqhkkHEDseI2orsyg143ok9r6EfXO5Scykk4tPd9Od6NRN5jxHi7DmMiSgHAAkuRm aFqWmwy/uofLoSIa5O7U5kewJmJl7WIQUsFIasLzqziHWiJ+ugTqUPlK9qrI+/J6htFH 1cXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tSochnqa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si2816642otn.150.2020.02.14.08.23.01; Fri, 14 Feb 2020 08:23:12 -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=tSochnqa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405448AbgBNQW1 (ORCPT + 99 others); Fri, 14 Feb 2020 11:22:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:55860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405373AbgBNQVY (ORCPT ); Fri, 14 Feb 2020 11:21:24 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 44CD72469F; Fri, 14 Feb 2020 16:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697284; bh=Txxg0CwDxgoAcCHfdSwCfVEMIB5RTNNnMROmmxv2NIQ=; h=From:To:Cc:Subject:Date:From; b=tSochnqaQk9HZ+V+pfQLu7f2M7Y/DXB+uD54lrtvDZg5SrlHzfJ4qYFiUUN8UB+Tu e0O73K2Wcg2NioF2L5gK3b6GOSvq6sjoURlO5ssppGXwOdBitalpOJ/xoecfRfg1Uc 0K+L2rciZrL9tv7k9ZU4CLgdEFgzZw1a/dUkbepM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Paul Kocialkowski , Patrik Jakobsson , Sasha Levin , dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 4.9 001/141] drm/gma500: Fixup fbdev stolen size usage evaluation Date: Fri, 14 Feb 2020 11:19:01 -0500 Message-Id: <20200214162122.19794-1-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 3a44e705db538..d224fc12b7571 100644 --- a/drivers/gpu/drm/gma500/framebuffer.c +++ b/drivers/gpu/drm/gma500/framebuffer.c @@ -516,6 +516,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; @@ -525,8 +526,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