Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4820390ybl; Wed, 22 Jan 2020 05:22:46 -0800 (PST) X-Google-Smtp-Source: APXvYqx7L8JkW+sg8zn4447Wu8uZBQazqIy5CnRNyPINaNqs0DqoxeWGjP7k4jkcfrMyS5F2K8gj X-Received: by 2002:a05:6808:3d0:: with SMTP id o16mr6816915oie.79.1579699365984; Wed, 22 Jan 2020 05:22:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579699365; cv=none; d=google.com; s=arc-20160816; b=nEjpJTufllKp34y0g0ajx8EAUEkacmIqjsOCh6uqQ4bWNQzTWArP9EHt7j4XCs03IB tvUQyrSDH0pBIwotMB2RGitpYp6pVsnPKxrX2W+odDpU6XU5pcPWKxiOSCuyjbAfFj1b g4bhBNbqUcAIR8FxZ9K2IgERdu+XEi3ijF37aYCF1+ebcKknD/2CPANNLB+THfwtK/p/ 3JpKZRx5DaEH284rkbGPkSuUsKQ51niG3szzosOCZOvW3oW2vnvVKOt30qPy7CXj6aRR Mly0uLjfn5TPpWuhbd+RGDdHE0LDeUtiWhNZZRVyNllo46fDCgg7JLjOCEIWXM6crVtB CY9Q== 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=iKxO/GI34xeGt9/XoJiz3VAVEabZeEWn+AcDuSJS0mk=; b=bcymIOujJfPN5oDWsmjB5E/sJFClkjSJtAnmMADg4DiExKKsI7svbHBwnbHhJ5pXjq fg6zlIXJ/0bRJOMLo9A5ppyQuCLn4I/6tBfLg+qJchCm3/XmQSpK6nJJuYJ2DUBDHI4Z LuSQSFGmFY82d2RuzMm5lVLbTC4ExG2gAsGttQhYsY3FYB1q6lX4HsU2M4OIPJlbeLbb GKXT+bYN9LgyAbPw5pGOyl0soVlRxy7qOI3G1RN+IyusevtjUUsDIktbFuf8jLt9jBE3 Zin6rcUALrUEVatwSid2gTqCtuCWzxuYwbPr9SLoq6sDPa6uBAS68J5C5PmVuf2Xuq5I I74g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yCUxls7o; 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 w2si22415126oib.252.2020.01.22.05.22.33; Wed, 22 Jan 2020 05:22:45 -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=yCUxls7o; 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 S1730150AbgAVNVD (ORCPT + 99 others); Wed, 22 Jan 2020 08:21:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:37536 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730122AbgAVNU7 (ORCPT ); Wed, 22 Jan 2020 08:20:59 -0500 Received: from localhost (unknown [84.241.205.26]) (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 B59E82468A; Wed, 22 Jan 2020 13:20:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579699258; bh=nWWiD5jEnlALudvtWMS1vnhl0X6ByubruA79LrLt6CE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yCUxls7otRVqCnXdPA7STuOCsALDQ2O4NxZgQlE7QqsByCgrgwHhdAH6uEz3dL6Gq R7j2yIZwmohmfqPGZmo6AGdvyoGveYZJJmifD0Gx6ABtbG3S67XDVhFsoRC6HQ+I06 38M+sobVnd8h/32w10wIlmKXBjzVN4+/phpuYfpk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arvind Sankar , Ard Biesheuvel , Hans de Goede , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , linux-efi@vger.kernel.org, Ingo Molnar Subject: [PATCH 5.4 072/222] efi/earlycon: Fix write-combine mapping on x86 Date: Wed, 22 Jan 2020 10:27:38 +0100 Message-Id: <20200122092838.874517870@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092833.339495161@linuxfoundation.org> References: <20200122092833.339495161@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: Arvind Sankar commit d92b54570d24d017d2630e314b525ed792f5aa6c upstream. On x86, until PAT is initialized, WC translates into UC-. Since we calculate and store pgprot_writecombine(PAGE_KERNEL) when earlycon is initialized, this means we actually use UC- mappings instead of WC mappings, which makes scrolling very slow. Instead store a boolean flag to indicate whether we want to use writeback or write-combine mappings, and recalculate the actual pgprot_t we need on every mapping. Once PAT is initialized, we will start using write-combine mappings, which speeds up the scrolling considerably. Signed-off-by: Arvind Sankar Signed-off-by: Ard Biesheuvel Cc: Hans de Goede Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Fixes: 69c1f396f25b ("efi/x86: Convert x86 EFI earlyprintk into generic earlycon implementation") Link: https://lkml.kernel.org/r/20191224132909.102540-2-ardb@kernel.org Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efi/earlycon.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) --- a/drivers/firmware/efi/earlycon.c +++ b/drivers/firmware/efi/earlycon.c @@ -17,7 +17,7 @@ static const struct console *earlycon_co static const struct font_desc *font; static u32 efi_x, efi_y; static u64 fb_base; -static pgprot_t fb_prot; +static bool fb_wb; static void *efi_fb; /* @@ -33,10 +33,8 @@ static int __init efi_earlycon_remap_fb( if (!earlycon_console || !(earlycon_console->flags & CON_ENABLED)) return 0; - if (pgprot_val(fb_prot) == pgprot_val(PAGE_KERNEL)) - efi_fb = memremap(fb_base, screen_info.lfb_size, MEMREMAP_WB); - else - efi_fb = memremap(fb_base, screen_info.lfb_size, MEMREMAP_WC); + efi_fb = memremap(fb_base, screen_info.lfb_size, + fb_wb ? MEMREMAP_WB : MEMREMAP_WC); return efi_fb ? 0 : -ENOMEM; } @@ -53,9 +51,12 @@ late_initcall(efi_earlycon_unmap_fb); static __ref void *efi_earlycon_map(unsigned long start, unsigned long len) { + pgprot_t fb_prot; + if (efi_fb) return efi_fb + start; + fb_prot = fb_wb ? PAGE_KERNEL : pgprot_writecombine(PAGE_KERNEL); return early_memremap_prot(fb_base + start, len, pgprot_val(fb_prot)); } @@ -215,10 +216,7 @@ static int __init efi_earlycon_setup(str if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE) fb_base |= (u64)screen_info.ext_lfb_base << 32; - if (opt && !strcmp(opt, "ram")) - fb_prot = PAGE_KERNEL; - else - fb_prot = pgprot_writecombine(PAGE_KERNEL); + fb_wb = opt && !strcmp(opt, "ram"); si = &screen_info; xres = si->lfb_width;