From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794784929; b=envnwi+/R9HLr9uaVemaGULNsuzoA4H6whwRLUjeUgs+yurOo48qWrhdGeRiI8Zcw5JR YFtkPAgpKoN1czTZQ/zxc4/1foT7VmVluMBguG3an9RkbwBRaRd+DHOSvX7skHl7765bW kqt0ryGNS0fknxkd2R3lj0+2RAhod6f/Lu1y7fXFSPy5JuANYIHHxSMHQ+CeMtUHApDGo iKrpl2UNNtgo+JACWrIyoCVrzXk/gWmczAZEns7ZYHIZwlNWWlzr2ERWLUNYdP0mM1sxf jbF3YFQlBhn7BEtNQl9mmNG7SDG4mKmav7MrQstW4CjIZHgekGm1tRSjs6V9nlVPq+A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794784929; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=QRwRXLM89UnoOEjo9EGn9AE3PBFxJ1gHBO963ekwGoI=; b=AcZ+lQaw+i+Zu6FmOYSfHxx+YAtYbpMXk8VkamZUALM0Qa87Z81IPniJXdGVs4xo2I9N 371eDCO5NYFeVnl5imQsHZLMctrvPLcYU8vMrWHpIM0OTachRGAc9O2xQQ8kKwVvP7WUW CObtY1IQVQjNLiRwoTffhFjDPHtKzouO6HiM9BuOwzQ9DdgkqURvL/mY2iAQALS+vyYRW QlPqAa3vWhPAUCyR0mw+j9H2lQ7E/ne3SUgai0bPbh9qBZDgnWGx/2K3M/EnCXnHOsUFI BCJj/cRJM9PjmyZS6nshI/M34Nd/Ga+ZHhlmgaO/BuxG2kW/shB1r/D8vKve/RtbHCg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="o/6V3BP7"; arc=none smtp.remote-ip=209.85.128.50 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C660606A891 for ; Sun, 15 Nov 2026 23:22:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2C660606A891 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=o/6V3BP7 Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4a140e7405dso30652055e9.3 for ; Sun, 15 Nov 2026 15:22:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794784926; x=1795389726; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=QRwRXLM89UnoOEjo9EGn9AE3PBFxJ1gHBO963ekwGoI=; b=o/6V3BP7v5SqnH1VMrlr9rDsiLCgYQkmDJYbwXeHupyhuyuO8FxJKs4J4oRBJTuahd 8yR24EZfPEELwq0Bq0FO8AYs3S0G+l6VCrCt5h4xOQxnWTYBwLZJPTuS9HgZs9qwESLc P/Fj6Z2c3eK7sQHAS4znS6iquVAba4meny19Lx+usXHCVRbMMoHBoPz+pZ6RtTdcd52n brs9VdafYl1dr+gkdU/jzM8i8eZtfTCFWTEUTvP+rgnygfCm7YEmlP1RURSsmxiJ8Xhc kKkA7LZe/uHCaEMA/JaLARIehM5x97zazZ5XzwIHl3kDoista8BIOTFwyCWI4BtXOVGD 6s9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794784926; x=1795389726; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=QRwRXLM89UnoOEjo9EGn9AE3PBFxJ1gHBO963ekwGoI=; b=EU3mgKQlKWzRaSc1+1ZtNS5HcWgrgIiHQjf36VNHbWbMBnJDZJdN4un0Iws7/7y827 Ukd5vCb6nCfj330z7EsCDmzaEKw75kdjFwZTsUq+QhsNaAUzYmbW/ujMxchEZGSmtsUu HA6l0UQbvW7Uo6fy1TlIvbSwFGyBNTTVnNMx55EDNv2XcXm2jqNfzRHlEOTVxOWumxoj c2GZnpuON/ZR1uRDroBr3ec/MKbIc/Q5rZD5o33ajNkaRNAIFRB2y0YLBdv3HdEKLAKa ebkOmcqRCN7nI4k97Z1QvXBjvBgfc5Np7zgoKNxFottau+PkA+ogok4HdurmtZZh7apJ 6RAQ== X-Forwarded-Encrypted: i=1; AL+hErG7/d4n0SvUQ5B+DLRHfvo/x+N+JTHnQmGYTYap7RMKaMcA5u8/kK6idvDRcqxHoQdaUyHIz2vhX/0=@vger.kernel.org X-Gm-Message-State: APuU4Z+vYdLQ7auwYEmQagthe5VvdPAmQT8mZd2A9LD7PqgI3ETBEl5R 4jIbY09U+0n4t7nVGkrr8yHjMiGZr9oY5tr/1vjJJ7dS+BLagM/6EH51 X-Gm-Gg: AYBFou0hBxpob1N64OWoG51WZN2WyB8huDJPW65wxQIvSkLyVQ2h/YdF4kvP4+bTPZm 1U/pDczLBZiblnVsQ1A1QmkHBPvwWuGy6TWYB2NiYKDWHkYz2m05RRFS1PmT08d57m+doO+sOKg coXTiEXdM/jVLsjpKVo9xBC3AjENQH3F1gAqeRRdguCh747WQ6jatkZ52vdZC/XiIIyK/F7uFtt 52ORsIZ5/NpoaBbEBn8HJmZfcMA65/XjDotc4oY1PmVC3JeoOQXk+wMwdS5oHZCdMwqYGRuhcIk bY5PZFcGXReOiqaQrFTj9anm/Hs9BYvUKX9NUhyhr3PgiPGMsXEQhozP0VQ0yuos2KCjg+7pq6e GE1HQs+D//GzNDJx5O/NJTUfGDqTkIC9usSap057C03KbSCZOY+0Yn/ydxWUJrWP7HJ7VwBU/oF EJg2ZMoViYzsCaZtnV1qx/TZ9JmGyLlvEwuJIqsVfW/HlFk1xKQFHDSnoaJN7yGwBfN5EbhuyzV 8xugm//5gGt7pAyaQqb+Oc8T4y9laiuw0MaJ8gVGLFe8C4qwMiOIjNjHg+FKPenyRw8OyCYVigP 9U4pp4I1AwvPNYyVDjznUq9RE1HwKHmL82aDD3UwxBxrszFe095MTXA= X-Received: by 2002:a05:600c:19d2:b0:4bb:60bd:53b2 with SMTP id 5b1f17b1804b1-4bb60bd55eamr134252235e9.6.1794784926397; Sun, 15 Nov 2026 15:22:06 -0800 (PST) Received: from ingenieria31.oficinasStQ.local ([79.117.0.220]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb571f976esm127920955e9.3.2026.11.15.15.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Nov 2026 15:22:06 -0800 (PST) From: =?UTF-8?q?M=C3=A0xim=20Pedraza=20Padilla?= To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Ard Biesheuvel , Jonathan Corbet , Helge Deller , Peter Jones Cc: Francesco Valla , Jani Nikula , Mario Limonciello , Javier Martinez Canillas , Jocelyn Falempe , Sam Ravnborg , Ilias Apalodimas , Shuah Khan , Randy Dunlap , dri-devel@lists.freedesktop.org, linux-efi@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-embedded@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 2/6] efi: bgrt: add accessors for the boot graphics Date: Mon, 16 Nov 2026 01:21:52 +0100 Message-Id: <20261116002156.1027726-3-maximpedraza@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20261116002156.1027726-1-maximpedraza@gmail.com> References: <20261116002156.1027726-1-maximpedraza@gmail.com> X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The DRM splash client shows the boot graphics the firmware left behind, and needs the image address and size, its offsets and the status bits. Reading them from bgrt_tab and bgrt_image_size works with drm_client_lib built in, but it can be a module, and neither is exported: ERROR: modpost: drivers/gpu/drm/clients/drm_client_lib.ko: symbol 'bgrt_tab' undefined! ERROR: modpost: drivers/gpu/drm/clients/drm_client_lib.ko: symbol 'bgrt_image_size' undefined! Rather than export the data, add an accessor for each of them, exported GPL only, with stubs in efi-bgrt.h for CONFIG_ACPI_BGRT=n so that users need no #ifdef of their own. The variables stay global for drivers/acpi/bgrt.c, and are only written by efi_bgrt_init(): mark them __ro_after_init. The table gives the image address as a u64. efi_bgrt_has_image() only says yes when phys_addr_t can hold it, and the address and size are 0 when it says no, so that they never disagree on kernels with 32-bit physical addresses. Reported-by: Mario Limonciello Closes: https://lore.kernel.org/dri-devel/5d7067de-97b7-4232-9cf6-e4b978696482@amd.com/ Suggested-by: Jani Nikula Reviewed-by: Thomas Zimmermann Signed-off-by: Màxim Pedraza Padilla --- drivers/firmware/efi/efi-bgrt.c | 76 ++++++++++++++++++++++++++++++++- include/linux/efi-bgrt.h | 39 ++++++++++++++++- 2 files changed, 112 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/efi/efi-bgrt.c b/drivers/firmware/efi/efi-bgrt.c index 1da451582812..8f5f5edf5ede 100644 --- a/drivers/firmware/efi/efi-bgrt.c +++ b/drivers/firmware/efi/efi-bgrt.c @@ -16,8 +16,8 @@ #include #include -struct acpi_table_bgrt bgrt_tab; -size_t bgrt_image_size; +struct acpi_table_bgrt bgrt_tab __ro_after_init; +size_t bgrt_image_size __ro_after_init; struct bmp_header { u16 id; @@ -89,3 +89,75 @@ void __init efi_bgrt_init(struct acpi_table_header *table) out: memset(bgrt, 0, sizeof(bgrt_tab)); } + +/** + * efi_bgrt_has_image() - Whether the firmware left a boot graphic + * + * Return: true if the BGRT points at a BMP image, which efi_bgrt_init() + * checked and reserved, at an address that phys_addr_t can hold. The + * other accessors only mean something when it returns true. + */ +bool efi_bgrt_has_image(void) +{ + return bgrt_tab.image_address && + bgrt_tab.image_address == (phys_addr_t)bgrt_tab.image_address; +} +EXPORT_SYMBOL_GPL(efi_bgrt_has_image); + +/** + * efi_bgrt_image_address() - Physical address of the boot graphic + * + * Return: the address of the BMP image, or 0 if there is none. + */ +phys_addr_t efi_bgrt_image_address(void) +{ + return efi_bgrt_has_image() ? bgrt_tab.image_address : 0; +} +EXPORT_SYMBOL_GPL(efi_bgrt_image_address); + +/** + * efi_bgrt_image_size() - Size of the boot graphic + * + * Return: the size of the BMP image, as its header gives it, or 0 if there + * is none. + */ +size_t efi_bgrt_image_size(void) +{ + return efi_bgrt_has_image() ? bgrt_image_size : 0; +} +EXPORT_SYMBOL_GPL(efi_bgrt_image_size); + +/** + * efi_bgrt_status() - Status field of the BGRT + * + * Return: the status byte. Bit 0 tells whether the image is still on + * screen and, since ACPI 6.2, bits 1-2 how far it has to be turned to show + * upright (ACPI_BGRT_ORIENTATION_OFFSET). + */ +u8 efi_bgrt_status(void) +{ + return bgrt_tab.status; +} +EXPORT_SYMBOL_GPL(efi_bgrt_status); + +/** + * efi_bgrt_image_offset_x() - Horizontal position of the boot graphic + * + * Return: the X offset, in pixels, at which the firmware drew the image. + */ +u32 efi_bgrt_image_offset_x(void) +{ + return bgrt_tab.image_offset_x; +} +EXPORT_SYMBOL_GPL(efi_bgrt_image_offset_x); + +/** + * efi_bgrt_image_offset_y() - Vertical position of the boot graphic + * + * Return: the Y offset, in pixels, at which the firmware drew the image. + */ +u32 efi_bgrt_image_offset_y(void) +{ + return bgrt_tab.image_offset_y; +} +EXPORT_SYMBOL_GPL(efi_bgrt_image_offset_y); diff --git a/include/linux/efi-bgrt.h b/include/linux/efi-bgrt.h index e6cd51005633..1c287e5fd388 100644 --- a/include/linux/efi-bgrt.h +++ b/include/linux/efi-bgrt.h @@ -9,7 +9,14 @@ void efi_bgrt_init(struct acpi_table_header *table); int __init acpi_parse_bgrt(struct acpi_table_header *table); -/* The BGRT data itself; only valid if bgrt_image != NULL. */ +bool efi_bgrt_has_image(void); +phys_addr_t efi_bgrt_image_address(void); +size_t efi_bgrt_image_size(void); +u8 efi_bgrt_status(void); +u32 efi_bgrt_image_offset_x(void); +u32 efi_bgrt_image_offset_y(void); + +/* The BGRT data itself; only valid if efi_bgrt_has_image(). */ extern size_t bgrt_image_size; extern struct acpi_table_bgrt bgrt_tab; @@ -21,6 +28,36 @@ static inline int __init acpi_parse_bgrt(struct acpi_table_header *table) return 0; } +static inline bool efi_bgrt_has_image(void) +{ + return false; +} + +static inline phys_addr_t efi_bgrt_image_address(void) +{ + return 0; +} + +static inline size_t efi_bgrt_image_size(void) +{ + return 0; +} + +static inline u8 efi_bgrt_status(void) +{ + return 0; +} + +static inline u32 efi_bgrt_image_offset_x(void) +{ + return 0; +} + +static inline u32 efi_bgrt_image_offset_y(void) +{ + return 0; +} + #endif /* !CONFIG_ACPI_BGRT */ #endif /* _LINUX_EFI_BGRT_H */ -- 2.39.5