Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp62580ybp; Thu, 3 Oct 2019 10:11:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwhmt7XAi3qQwyRbvpGO762oSE+Jyv9Gan16yh051bK2aT/V12wySY2/57Ew1l4ibX4bs6g X-Received: by 2002:a50:f04e:: with SMTP id u14mr10682002edl.247.1570122718326; Thu, 03 Oct 2019 10:11:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570122718; cv=none; d=google.com; s=arc-20160816; b=HcyC+7olC6GpcrHfAklJo2yXKC/lMdqKOReasV9Qeo1j8h+3luVz/5KVgb9tm6uthc nQXaqoDzzomoXJl8I262YmP7NOTZIPA6LE8zv/j8378Nt38NKiYdIf75TfelGTWoVy0Z T9YeibUcha81WX3p0FaMc4sCrPD6oCx00k1sQiPH3GomyrqjIqr7AStdFEDVgoOjL8lf mZ3CWeS+hHqQO42km0EGgG6lCpIxbz7OvOKmtACAP9BP7sVllcg08T+pkoibtWBVpZ+Y wt2WH4Jl4oHt8GPKstqT2+eLhEef8y39hN2sYR++BiAYpR4AldiaaKsDbK9pvPdcP+fh gNxw== 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=fNDhqdv81ZpM3F9PcwPhN/gQ6il3LN1qoKlks0iqPSw=; b=EgMRO82qCRC3bYXepZaD23P8u8pGVSj72bysRgW4IUEYwSHGcTM8O1u5Q32KBBNBd0 j9rTxdLg4WwCFsOLabtDV09aJ0FOqeCL1yDnJE5i48+SPQfp85jIbi1XnMgGs9LgDr6H 1nl0YTuwGfkK8oojhO8prWX3iFWJy1WGPPRUa3VXGGnhxCI39cuHE9XU0FitqrJUaxWX kkS/ZARfxqg2qsKZUsfkmQpAlXidWToc+TbvlbHm+rsE28a3lcdDoc31jbGMn6hMMGnN cULxnWdpuOpc0gDqftT2TSaWYJs1yd0rDlow7A1YjApMj4fKkEtZSrvADPDT6QVntCRL +y2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JVckwURk; 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 v20si1819881edq.195.2019.10.03.10.11.34; Thu, 03 Oct 2019 10:11:58 -0700 (PDT) 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=JVckwURk; 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 S2404338AbfJCQft (ORCPT + 99 others); Thu, 3 Oct 2019 12:35:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:44784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404317AbfJCQfq (ORCPT ); Thu, 3 Oct 2019 12:35:46 -0400 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 7A16D2070B; Thu, 3 Oct 2019 16:35:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120546; bh=OSDbZ+qnZK1aTfBoQCDkx4FU7CwedCYXzK82/thGqPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JVckwURk/YxqZoOPnM9aLww+siUUDwPYHOLqz1duzvIO+8IPNbI/52qLn6geNaUhS oXB1Uvu1XbQrxKkR3sXfKS+6PpJ2uA6RlfAaBjtsAMxMe8kOXwlIeuxXBIc9/qg3NI kN8/tJgF1lz4EsGvV0P33uCOauuE4s4o6NJ67tVo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Bartlomiej Zolnierkiewicz , Peter Jones Subject: [PATCH 5.2 262/313] efifb: BGRT: Improve efifb_bgrt_sanity_check Date: Thu, 3 Oct 2019 17:54:00 +0200 Message-Id: <20191003154558.839409242@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154533.590915454@linuxfoundation.org> References: <20191003154533.590915454@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: Hans de Goede commit 51677dfcc17f88ed754143df670ff064eae67f84 upstream. For various reasons, at least with x86 EFI firmwares, the xoffset and yoffset in the BGRT info are not always reliable. Extensive testing has shown that when the info is correct, the BGRT image is always exactly centered horizontally (the yoffset variable is more variable and not always predictable). This commit simplifies / improves the bgrt_sanity_check to simply check that the BGRT image is exactly centered horizontally and skips (re)drawing it when it is not. This fixes the BGRT image sometimes being drawn in the wrong place. Cc: stable@vger.kernel.org Fixes: 88fe4ceb2447 ("efifb: BGRT: Do not copy the boot graphics for non native resolutions") Signed-off-by: Hans de Goede Cc: Peter Jones , Signed-off-by: Bartlomiej Zolnierkiewicz Link: https://patchwork.freedesktop.org/patch/msgid/20190721131918.10115-1-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/video/fbdev/efifb.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) --- a/drivers/video/fbdev/efifb.c +++ b/drivers/video/fbdev/efifb.c @@ -122,28 +122,13 @@ static void efifb_copy_bmp(u8 *src, u32 */ static bool efifb_bgrt_sanity_check(struct screen_info *si, u32 bmp_width) { - static const int default_resolutions[][2] = { - { 800, 600 }, - { 1024, 768 }, - { 1280, 1024 }, - }; - u32 i, right_margin; + /* + * All x86 firmwares horizontally center the image (the yoffset + * calculations differ between boards, but xoffset is predictable). + */ + u32 expected_xoffset = (si->lfb_width - bmp_width) / 2; - for (i = 0; i < ARRAY_SIZE(default_resolutions); i++) { - if (default_resolutions[i][0] == si->lfb_width && - default_resolutions[i][1] == si->lfb_height) - break; - } - /* If not a default resolution used for textmode, this should be fine */ - if (i >= ARRAY_SIZE(default_resolutions)) - return true; - - /* If the right margin is 5 times smaller then the left one, reject */ - right_margin = si->lfb_width - (bgrt_tab.image_offset_x + bmp_width); - if (right_margin < (bgrt_tab.image_offset_x / 5)) - return false; - - return true; + return bgrt_tab.image_offset_x == expected_xoffset; } #else static bool efifb_bgrt_sanity_check(struct screen_info *si, u32 bmp_width)