From patchwork Fri May 21 19:37:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 12273645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CC4BC4707D for ; Fri, 21 May 2021 19:37:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 49FF3613D8 for ; Fri, 21 May 2021 19:37:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 49FF3613D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BC9B06E84D; Fri, 21 May 2021 19:37:22 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6A3526E848 for ; Fri, 21 May 2021 19:37:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621625835; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fa9C0WBJ+BnUNnfdYZgP3Jm6YVcpbeVEclTRzpQPr2o=; b=LMiReuiASnDZOmImSCgnDFioCrDIcQ+JkF5Im3bTSqK3v85q5k/r8KlnBSx6htW6LErKLr 6sewJqpya0IYOD79+lltj2kzgOihh+9zsGAiqxvYLZkocArFa0spELyYFAidRPZgCybKoZ 7bkxP0l4u/PVAU30meTcpGarnHa0DNY= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-586-sIRKzqNCNhij-FbyQnlcUg-1; Fri, 21 May 2021 15:37:13 -0400 X-MC-Unique: sIRKzqNCNhij-FbyQnlcUg-1 Received: by mail-wm1-f70.google.com with SMTP id z1-20020a1c7e010000b0290179806d11d4so2760190wmc.3 for ; Fri, 21 May 2021 12:37:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fa9C0WBJ+BnUNnfdYZgP3Jm6YVcpbeVEclTRzpQPr2o=; b=llsp9QocD8DYgZFReRsG5mGV+xbgRlSpZP3xML9KlJRWgEkFFJVu4zUYKofEaUhLur 7QiJN+iO2TQlsGXAGPxQz7vTcQXw0rCN5Rqhok2f+Qo23HM1Fg/OiOHkslMNKQnUSpuC 38HTAtx0cx8Chrqr2dj/Pttj0xAvMmgkjb/aiE85JnjaRBSASMg8RKS1iP8syR74anqN e6GgjV11Wrv3fT/p/VO1Nw7XoB3wVGN5gyNwBo49U/gs9vhTXvTqqWOMSSsmwx3woF4K J4QDnlRAm3E3KGfrUDRXwhLDsVdYUbve91d1DfHTxXXamtM20useJbDuYU0Z4o72wQNx UneA== X-Gm-Message-State: AOAM533z989vDC1qn60e4CZBvFC0AJ7WFjlZokuDNgteSCYrV0iYxUpa MPMWdDj3MKCFvHXBUnk5ztn3KTvmNW5qqmedm+3zIui4AaVs2jd0EUa8ZNAoZXvdjCqgBOaiuuz jUla5fuusV8ikYG7WOva/uPv9GBXn X-Received: by 2002:adf:db42:: with SMTP id f2mr11191484wrj.5.1621625832004; Fri, 21 May 2021 12:37:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3HfDJ+Myl8DK5jwFpKZQMElYR3LkrRBKtdRai0WCVmyZONtDS/OcsNp1IUI4McOUzKgde9w== X-Received: by 2002:adf:db42:: with SMTP id f2mr11191460wrj.5.1621625831732; Fri, 21 May 2021 12:37:11 -0700 (PDT) Received: from minerva.home ([92.176.231.106]) by smtp.gmail.com with ESMTPSA id s11sm475226wmf.14.2021.05.21.12.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 12:37:11 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Subject: [PATCH 2/2] drivers/firmware: consolidate EFI framebuffer setup for all arches Date: Fri, 21 May 2021 21:37:04 +0200 Message-Id: <20210521193704.3042024-1-javierm@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=javierm@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Albert Ou , Thomas Zimmermann , David Airlie , Catalin Marinas , Russell King , dri-devel@lists.freedesktop.org, Javier Martinez Canillas , Hans de Goede , linux-efi@vger.kernel.org, Palmer Dabbelt , Peter Robinson , Paul Walmsley , linux-riscv@lists.infradead.org, Will Deacon , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The register_gop_device() function registers an "efi-framebuffer" platform device to match against the efifb driver, to have an early framebuffer for EFI platforms. But the Generic System Framebuffers (sysfb) already has support for this. Instead of having duplicated logic for x86 and other architectures using EFI, consolidate the two in sysfb and remove it from the EFI init logic. Signed-off-by: Javier Martinez Canillas --- arch/arm/Kconfig | 1 + arch/arm/include/asm/efi.h | 5 +- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/efi.h | 5 +- arch/riscv/Kconfig | 1 + arch/riscv/include/asm/efi.h | 5 +- drivers/firmware/Kconfig | 7 ++- drivers/firmware/Makefile | 2 +- drivers/firmware/efi/efi-init.c | 90 ------------------------------- drivers/firmware/efi/sysfb_efi.c | 77 +++++++++++++++++++++++++- drivers/firmware/sysfb.c | 40 +++++++++----- drivers/firmware/sysfb_simplefb.c | 29 ++++++---- include/linux/sysfb.h | 28 +++++----- 13 files changed, 145 insertions(+), 146 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 24804f11302..30ba195ca72 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -127,6 +127,7 @@ config ARM select PERF_USE_VMALLOC select RTC_LIB select SET_FS + select SYSFB select SYS_SUPPORTS_APM_EMULATION # Above selects are sorted alphabetically; please add new ones # according to that. Thanks. diff --git a/arch/arm/include/asm/efi.h b/arch/arm/include/asm/efi.h index 9de7ab2ce05..a6f3b179e8a 100644 --- a/arch/arm/include/asm/efi.h +++ b/arch/arm/include/asm/efi.h @@ -17,6 +17,7 @@ #ifdef CONFIG_EFI void efi_init(void); +extern void efifb_setup_from_dmi(struct screen_info *si, const char *opt); int efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md); int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md); @@ -52,10 +53,6 @@ void efi_virtmap_unload(void); struct screen_info *alloc_screen_info(void); void free_screen_info(struct screen_info *si); -static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt) -{ -} - /* * A reasonable upper bound for the uncompressed kernel size is 32 MBytes, * so we will reserve that amount of memory. We have no easy way to tell what diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 9f1d8566bbf..20886eb48ab 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1884,6 +1884,7 @@ config EFI select EFI_RUNTIME_WRAPPERS select EFI_STUB select EFI_GENERIC_STUB + select SYSFB imply IMA_SECURE_AND_OR_TRUSTED_BOOT default y help diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h index 3578aba9c60..42d673a011c 100644 --- a/arch/arm64/include/asm/efi.h +++ b/arch/arm64/include/asm/efi.h @@ -14,6 +14,7 @@ #ifdef CONFIG_EFI extern void efi_init(void); +extern void efifb_setup_from_dmi(struct screen_info *si, const char *opt); #else #define efi_init() #endif @@ -85,10 +86,6 @@ static inline void free_screen_info(struct screen_info *si) { } -static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt) -{ -} - #define EFI_ALLOC_ALIGN SZ_64K /* diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index a8ad8eb7612..f4bc6736c4e 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -474,6 +474,7 @@ config EFI select EFI_GENERIC_STUB select EFI_RUNTIME_WRAPPERS select RISCV_ISA_C + select SYSFB depends on MMU default y help diff --git a/arch/riscv/include/asm/efi.h b/arch/riscv/include/asm/efi.h index 6d98cd99968..7a8f0d45b13 100644 --- a/arch/riscv/include/asm/efi.h +++ b/arch/riscv/include/asm/efi.h @@ -13,6 +13,7 @@ #ifdef CONFIG_EFI extern void efi_init(void); +extern void efifb_setup_from_dmi(struct screen_info *si, const char *opt); #else #define efi_init() #endif @@ -39,10 +40,6 @@ static inline void free_screen_info(struct screen_info *si) { } -static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt) -{ -} - void efi_virtmap_load(void); void efi_virtmap_unload(void); diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig index 396bd1d5cbf..cc1a61f6d57 100644 --- a/drivers/firmware/Kconfig +++ b/drivers/firmware/Kconfig @@ -253,9 +253,8 @@ config QCOM_SCM_DOWNLOAD_MODE_DEFAULT config SYSFB bool - depends on X86 -config X86_SYSFB +config SYSFB_SIMPLEFB bool "Mark VGA/VBE/EFI FB as generic system framebuffer" depends on SYSFB help @@ -263,10 +262,10 @@ config X86_SYSFB bootloader or kernel can show basic video-output during boot for user-guidance and debugging. Historically, x86 used the VESA BIOS Extensions and EFI-framebuffers for this, which are mostly limited - to x86. + to x86 BIOS or EFI systems. This option, if enabled, marks VGA/VBE/EFI framebuffers as generic framebuffers so the new generic system-framebuffer drivers can be - used on x86. If the framebuffer is not compatible with the generic + used instead. If the framebuffer is not compatible with the generic modes, it is advertised as fallback platform framebuffer so legacy drivers like efifb, vesafb and uvesafb can pick it up. If this option is not selected, all system framebuffers are always diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index ad78f78ffa8..6ac637e422b 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -19,7 +19,7 @@ obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o obj-$(CONFIG_QCOM_SCM) += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o obj-$(CONFIG_SYSFB) += sysfb.o -obj-$(CONFIG_X86_SYSFB) += sysfb_simplefb.o +obj-$(CONFIG_SYSFB_SIMPLEFB) += sysfb_simplefb.o obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o obj-$(CONFIG_TRUSTED_FOUNDATIONS) += trusted_foundations.o obj-$(CONFIG_TURRIS_MOX_RWTM) += turris-mox-rwtm.o diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c index a552a08a174..b19ce1a83f9 100644 --- a/drivers/firmware/efi/efi-init.c +++ b/drivers/firmware/efi/efi-init.c @@ -275,93 +275,3 @@ void __init efi_init(void) } #endif } - -static bool efifb_overlaps_pci_range(const struct of_pci_range *range) -{ - u64 fb_base = screen_info.lfb_base; - - if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE) - fb_base |= (u64)(unsigned long)screen_info.ext_lfb_base << 32; - - return fb_base >= range->cpu_addr && - fb_base < (range->cpu_addr + range->size); -} - -static struct device_node *find_pci_overlap_node(void) -{ - struct device_node *np; - - for_each_node_by_type(np, "pci") { - struct of_pci_range_parser parser; - struct of_pci_range range; - int err; - - err = of_pci_range_parser_init(&parser, np); - if (err) { - pr_warn("of_pci_range_parser_init() failed: %d\n", err); - continue; - } - - for_each_of_pci_range(&parser, &range) - if (efifb_overlaps_pci_range(&range)) - return np; - } - return NULL; -} - -/* - * If the efifb framebuffer is backed by a PCI graphics controller, we have - * to ensure that this relation is expressed using a device link when - * running in DT mode, or the probe order may be reversed, resulting in a - * resource reservation conflict on the memory window that the efifb - * framebuffer steals from the PCIe host bridge. - */ -static int efifb_add_links(struct fwnode_handle *fwnode) -{ - struct device_node *sup_np; - - sup_np = find_pci_overlap_node(); - - /* - * If there's no PCI graphics controller backing the efifb, we are - * done here. - */ - if (!sup_np) - return 0; - - fwnode_link_add(fwnode, of_fwnode_handle(sup_np)); - of_node_put(sup_np); - - return 0; -} - -static const struct fwnode_operations efifb_fwnode_ops = { - .add_links = efifb_add_links, -}; - -static struct fwnode_handle efifb_fwnode; - -static int __init register_gop_device(void) -{ - struct platform_device *pd; - int err; - - if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI) - return 0; - - pd = platform_device_alloc("efi-framebuffer", 0); - if (!pd) - return -ENOMEM; - - if (IS_ENABLED(CONFIG_PCI)) { - fwnode_init(&efifb_fwnode, &efifb_fwnode_ops); - pd->dev.fwnode = &efifb_fwnode; - } - - err = platform_device_add_data(pd, &screen_info, sizeof(screen_info)); - if (err) - return err; - - return platform_device_add(pd); -} -subsys_initcall(register_gop_device); diff --git a/drivers/firmware/efi/sysfb_efi.c b/drivers/firmware/efi/sysfb_efi.c index 9f035b15501..2814af6baf1 100644 --- a/drivers/firmware/efi/sysfb_efi.c +++ b/drivers/firmware/efi/sysfb_efi.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * Generic System Framebuffers on x86 + * Generic System Framebuffers * Copyright (c) 2012-2013 David Herrmann * * EFI Quirks Copyright (c) 2006 Edgar Hucek @@ -19,7 +19,9 @@ #include #include #include +#include #include +#include #include #include #include