From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C6DCECC6B08 for ; Tue, 13 Oct 2026 09:33:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3524F10F67D; Tue, 13 Oct 2026 09:33:03 +0000 (UTC) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by gabe.freedesktop.org (Postfix) with ESMTPS id A13F710F678 for ; Tue, 13 Oct 2026 09:32:54 +0000 (UTC) Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-48b001cd92bso1563771f8f.2 for ; Tue, 13 Oct 2026 02:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791883973; x=1792488773; darn=lists.freedesktop.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=z6NPHx9LACWbH6+mzFH89ozzk12nlHrey7ZxWH5hggM=; b=OatAo4tIfJD8GglkW81og2g3coDscOJtrRkKkAZBdyeC+zBUtoHWcWgmuh1grGma27 gKznBdzJP7gDg385TkvafNl8PjGVuNG/I/+kmI8biiEdJwVkZ5yGo2zyVvWr8FAKKW92 /BlZ+ClOUdV8ppvDWIru+PTjP1R2GHMyS6j6rxOSiWfJxIDJddWc2FXHxsLBYGwXBBSP kkK5wkoRiCQZIDCKL9xSv/4qJdXrjT9+tGT3CkstfQvYOJKLds6QPXl9G8QfKoLU9cXA qqmasMc+JVnYqtbAdToopQlrCuN7x/6JCneNdN7w/pAa9FFs+HY304gOFpm/FcGTwpMv NUJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791883973; x=1792488773; 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=z6NPHx9LACWbH6+mzFH89ozzk12nlHrey7ZxWH5hggM=; b=WN+jylBK4LxmiEksik6WV4nqkc560nuN5Xd3jsJnWOSAU0vRCxh0FOkyz5WJMq1I3A iqPfZDOfd0LVKprnpGAbVvefyM1B5x5H/ob7ZfDfRlsuiG3HKrm9nYg8R+QB9XhdGEAU RuGhhhX7wgpIEdHisWtXcmZAWbdJNuZj3iH5DjHcUyMELHaKP/rEic3fybtxlgp4Tah2 YqHCA6Bl7ubSer3+tQBdJeFeq/eJ+f+WBtB7xYRQW2kO9F0z74K9HcfcDwqwSaiZf+IR tSmbIuT5mso9HilWBh+cvEksLtUC0Hkh5kdsP8FAqfzspqW7VFNs/dsEaprhTzyZ5uvN RsYQ== X-Forwarded-Encrypted: i=1; AKwUvBxGf7dV9EdDT5tEWfDYDsLblTkF++DO1EbmAJBrMlPMqFgDwydOSvj2dK9uR+0iGvXu/vXDpIfcbUg=@lists.freedesktop.org X-Gm-Message-State: AFq9FYKIaEO0QpGj1W+zaSUMRU+ysRyIpftAXRg20lTAIJYFG66X4MV6 kV9HGDmLhsoBY1afZ6khwVqpDLPUO657JLQftn76EazPm70DbSmWie0F X-Gm-Gg: AYBFou3nUTgk9llEzbVyadO5IJkOAPDoiwCFjEPCEwXaIf56SN1yVqobwhqq5LSVJZa 65qY3s/uv8rvPOSApvI9jWqqcS4XA6HAqGmPR1Nkwq63uxQnG8c+CVUvJKk8XuEUno6xTlg4Auf bZqjU6k+HI8K3UlyamxwsDPX/YZtvAEt2MnQ0l2xb/in3Kg0rAEqguJiHUjIi5AvMquJcv5I0zB Bv8BKhnxE0EnB5oGFg0PbvgkeS0zrmbgRXJWA6Ld2sSI0NawSnrWQNP9XZeHYOsdk9ur8yRjpsE bjLhUMNPmwP2Em9GXpRpGRUKhpWDqRRiuF01s5AmLRL0xp23o78VKkGVNASdsUg7nZFtNabXdNv iIcHtEHWnH/yFCXbPFcydIDmMybVLQ2iD5SELPuahita7eZcw4zXn7IB85GQ3Hp7rouiLVXrOdt 7xA/kbYXx7a+tLu9cavPKh9AqxX15JJAc2tw9uqod/50ZHHPVJigon7MuQh68j2pu8OxRw/DWZ7 DC66Fd6svcK2Ci/GZBTxK63 X-Received: by 2002:a05:6000:469b:b0:48b:a4b:5a2c with SMTP id ffacd0b85a97d-48dba7893e3mr15115259f8f.3.1791883972704; Tue, 13 Oct 2026 02:32:52 -0700 (PDT) Received: from ingenieria31.oficinasStQ.local ([79.112.15.218]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48de0bc4ec6sm3986774f8f.48.2026.10.13.02.32.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2026 02:32:52 -0700 (PDT) From: =?UTF-8?q?M=C3=A0xim=20Pedraza=20Padilla?= To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Ard Biesheuvel , Jonathan Corbet 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, devicetree@vger.kernel.org, linux-efi@vger.kernel.org, linux-doc@vger.kernel.org, linux-embedded@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 02/13] efi: bgrt: add accessors for the boot graphics Date: Tue, 13 Oct 2026 11:32:32 +0200 Message-Id: <20261013093243.505776-3-maximpedraza@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20261013093243.505776-1-maximpedraza@gmail.com> References: <20261013093243.505776-1-maximpedraza@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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. Reported-by: Mario Limonciello Closes: https://lore.kernel.org/dri-devel/5d7067de-97b7-4232-9cf6-e4b978696482@amd.com/ Suggested-by: Jani Nikula Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Màxim Pedraza Padilla --- drivers/firmware/efi/efi-bgrt.c | 74 ++++++++++++++++++++++++++++++++- include/linux/efi-bgrt.h | 39 ++++++++++++++++- 2 files changed, 110 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/efi/efi-bgrt.c b/drivers/firmware/efi/efi-bgrt.c index 1da451582812..01425c4d2e70 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,73 @@ 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. + */ +bool efi_bgrt_has_image(void) +{ + return bgrt_tab.image_address != 0; +} +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 bgrt_tab.image_address; +} +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 bgrt_image_size; +} +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