Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp71791ybp; Thu, 3 Oct 2019 10:19:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqygHp/EWNI1dD0XS1P7BEdtQamkIThbVh3x5TqLXsZYzv3KKCKzpEjvHgiitPLQ4tkpao18 X-Received: by 2002:a17:907:441d:: with SMTP id om21mr8961042ejb.188.1570123161599; Thu, 03 Oct 2019 10:19:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570123161; cv=none; d=google.com; s=arc-20160816; b=eYHNdRJwYw2vOBzGi7kA6foWdvN8n9Ny3W/ZjLt2gVu7xj26sozaAD8A20IiloWw7K SQMe5T9j0xWX6YMnmmDrw8GTzuu5jFn3USC81hXHGupz2L+1WgYXo4O6qn3d2jima9gr nKMBQQlhKslD25o9KCG9dmQxz3FipAiuXmzhZ/MNJ2poHoyYsFv40kTMXIQEk2kvt+Ci HyyVi1E1i8ZAO+JBQNjvhD1wJQ84bXDm1GVvFIX5AJgJeNlXrVGDCnaRfTUKd7+yCF21 K8kFCpZm+SB0nzZNYKX6aQbM0kVc7gsyhRqAix5LvpWhemhN1ZnRltB46JZ0kIbFaHvn yXpg== 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=jEmRi/Zc4ctba7CHimPS3Jx9yCNuWxUCdLfyQJai7HW1R4S6V4PYmPB7lSkLaDqtz9 xZhAG/j+TWy9KM5nKufLOXR1qcwNcpDIMNvZbn67wBI3VCFosKkOZqwxPXdd+PhUAv5E mpNw20zOy/LThhra5gCy0l8IkVsGgQYoPoJEHgNGUoC1fod6btqARAhLcD7FgsbjalIc 1SSCvKjg/ZEU5T8hv0xaKdpXAwvGvaUeHBLdUzqQr8RHMaHmeap5B/HWhHX13bQ6hxNw KY+Fr74js6ukWbSIOH2oyyDDhfrN0pz/oNwyNCWdZa7PVfjS01kq+4eifjR6OHQv9B/S 2TXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TzXbGme0; 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 g1si1583603ejo.82.2019.10.03.10.18.56; Thu, 03 Oct 2019 10:19:21 -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=TzXbGme0; 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 S2391496AbfJCRR3 (ORCPT + 99 others); Thu, 3 Oct 2019 13:17:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:51326 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390340AbfJCQWg (ORCPT ); Thu, 3 Oct 2019 12:22:36 -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 9C55C20659; Thu, 3 Oct 2019 16:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570119756; bh=OSDbZ+qnZK1aTfBoQCDkx4FU7CwedCYXzK82/thGqPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TzXbGme0g1mLg+Clcwpwt4WEMTrlccZ6P614o5aUO5xHfEN0wHXly+B8PBiT1PCgv 8Hrr+0AGaPJR/g1WvNxEz7dJCSxTH97Bp0pm2shxUb4kxYBPrpqOIIhW7TdHH02K1r TtPvVFUp7icKue+nIwcvC8EUdZ1oeBHTV8iuDHwQ= 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 4.19 181/211] efifb: BGRT: Improve efifb_bgrt_sanity_check Date: Thu, 3 Oct 2019 17:54:07 +0200 Message-Id: <20191003154527.420265838@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154447.010950442@linuxfoundation.org> References: <20191003154447.010950442@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)