From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793109232; b=wjaeelay3DMqKvMYdWel/roFIzqerTcPTsy3PFPUsOMg7De+bheSwiPDDw1WgwW0TFV0 RI3piyVaBLC3F/dR6k+z/dLOfrQ6DOnKkdpek72CGj97HvmejJgmNeFVvoL8ijbPybfGW FHBx2YxEqHzjvNLJKWqucxbIPRe1ai+ThfQ3o/2Ghwl9fJbrCIfEnbl8UvuBH/e681zWh SVyigxTwJJTEXS3BBEVUY2SMoKPC1DRU//aYAvJT+yykgkYfMBfugPAWTsRmL9EOPJQDe qN4eY6OcoAyD/4tPNleY9wcurvy2HnQZ2plLzUMvSS4esg1waEx21ChWJROy6ZFqXnw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793109232; 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=G1+nfUJ+NP0zqKdPIyJvkG8NMwha03wen6k4s/kDOuc=; b=YEja+jMGDGAl6GFxclw6BqYC2nQOYPW7gB6ETC8pz2K2GlPl4E/iQ82Eax9YnqZ33blG ywunl+P5wTlHMdxSiY8v8olrltWRZTrfGzbuWykXMqG1tf25how7vDU7kgKCLiAQnwK/L H3Ipy73MGBrK5uXVA8eP8AAB6zogCJOqQVnA9qos1viuCwF4P9ZtlLTyjyijYiC/6nKr8 MjCSs46C++A2TZIb6r6Nsyz9vrmbqNo3jxY61RopVcHLzXS2Ra2LknT5OnwnhdwMcdxeR zwhOP+HltLOC1n7gI3nEZKin4SfClfw/G50hJQ7K52HedIt9VJRNm7ZuFpr4g0VXetg== 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=S2JE7Nd8; arc=none smtp.remote-ip=209.85.221.52 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 474A7606A32C for ; Tue, 27 Oct 2026 13:53:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 474A7606A32C 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, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=S2JE7Nd8 Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-48dfdd0678dso3034032f8f.0 for ; Tue, 27 Oct 2026 06:53:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793109230; x=1793714030; 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=G1+nfUJ+NP0zqKdPIyJvkG8NMwha03wen6k4s/kDOuc=; b=S2JE7Nd8OTAHxoXX6BZLIyrug9lS3aM+fOmCTHlOH5CAIMWvEng6vFztONyEQONBdy 6U0nsYeDQ35b6WSek1fAgeHdpeTYBo+D5PJK/A53gJmbPG6B2KWi4kSxAjhis7z63lHa VTwhOjKb0TUkye6vfPvbocaNrgfU5fOrcE9M84tEkkhZli/4vBmfKp75SaCv+h4FwTN/ EtgzNbV7aphJrZ8dCgJJ0YE/R+1IiRFOPdV1D6GOSd7mCp7UjrZEIzeX9wntDPWIqBRW MCObtUrCuy1+OjRKttCmH5cUl6o9wgpDTzpxhx+fVzWDHAMjD2IUkMA1kAucOEcxqznm wcJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793109230; x=1793714030; 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=G1+nfUJ+NP0zqKdPIyJvkG8NMwha03wen6k4s/kDOuc=; b=0fOrHeGP4tiCyBcH+CL8SjYc56be6gIrBM2HA+XuTyj8INOSLRMs7Iw/zKtPmbtfpF k+f5e9kFcki0O913TLvkqeakkx44rlym6RLzabyL5OCIHmCyisvIhlWsbHv9hLjfxM6f Yj9EQK1YqDoCpX4JxKsZdFHZmVPnq4b/5EPtHdoSIUxWdwFJir0l2EpdSXqzt8RX+nW6 PayIaX0i91JuXlCMdc+ThVOCRsxGjzOzcRpyXXSLIOxF6EaTeSqtktddEqi13G3aQ3zP I1mAonEwgPpdk9CRF7L+/cKrirUkxGM++55fR9mLKFEtnhunMNl0DGLznquBidGaPJ77 zjZQ== X-Forwarded-Encrypted: i=1; AKwUvBzQmsrXANMrCe8RMboGI3Uu7+Bt4GAGNVHFZ+PNrZNO8XlNbsAhp6jlqKIv3DpXLXHyNCMEzkxGBXs=@vger.kernel.org X-Gm-Message-State: AFq9FYIlC0kTMe5VSzdW/zcswdv11Pyb8OJxClZiYd8kvcp2SMsBmwnc sBSh/zUuP9FM+KhAG8ZcNOZa/K7vLOTDL3gj8ufmmchzQGk5NIjgIJVv X-Gm-Gg: AYBFou2LoaWu6aojQgMO7kETrDjqa5/hlYDlh9+aAz+OQcGOErsHLPzVtOyHEedcSy6 jWV4KSZMoF/LGR2X+drzkPaSI4CJ6RS5VYakv9ZlYCsoSNqrZRM83QUxaSXPDVSMDsu5FpNTELm K8YPP+lmG6pJHkDhdfKSuqA48ZjYxEB7e9etkZlkPpTKvgDbgKEsxZjriGJV10dvPABXxU1naQC CF4X6WtnMxe7K9xJPeKX3n4aN+dlmUsdDwBkYMoBOuTjUMo6mzsee3hft7GdZim/XKifl6+yC9d V8h9pKUr4usqiDgnhpazfwv2HEFktsLf+u9RHXYczPl3y2vwgQiJjQufigiF0Ou0AgoQ7NKwbC1 7L9ePzFbaI8Sr/S82YW4kRPfQ5f91035HdQu7213gSU0Vp8h0dQ9zC3W5eyXsF62cTfNAj0Rm7C Sknm5Paolm7SKgLS9FAeaBsTqxE+z9WmHZbFySTWO0wjWg7hAyOr8K7L1WWHaErfa+KNMB24rJE BGbIFiUUCjxlG/Ct/JeRt9gCpJCPEbKFxnoraBpg14jxQfb4RAq3qm7Q9thFS01AT+4eZY//jlJ OIfFl8Y= X-Received: by 2002:a05:6000:29d5:b0:48e:f47:273c with SMTP id ffacd0b85a97d-48e3eb45747mr11349441f8f.8.1793109229602; Tue, 27 Oct 2026 06:53:49 -0700 (PDT) Received: from ingenieria31.oficinasStQ.local ([79.117.46.175]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e3ebcb846sm23128058f8f.25.2026.10.27.06.53.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2026 06:53:48 -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 , 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, devicetree@vger.kernel.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 v6 02/15] efi: bgrt: add accessors for the boot graphics Date: Tue, 27 Oct 2026 14:53:29 +0100 Message-Id: <20261027135342.2003632-3-maximpedraza@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20261027135342.2003632-1-maximpedraza@gmail.com> References: <20261027135342.2003632-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, so that it never disagrees with efi_bgrt_image_address() 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 Assisted-by: Claude:claude-opus-5-5 Reviewed-by: Thomas Zimmermann Signed-off-by: Màxim Pedraza Padilla --- drivers/firmware/efi/efi-bgrt.c | 75 ++++++++++++++++++++++++++++++++- include/linux/efi-bgrt.h | 39 ++++++++++++++++- 2 files changed, 111 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/efi/efi-bgrt.c b/drivers/firmware/efi/efi-bgrt.c index 1da451582812..1affe5528139 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,74 @@ 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. + */ +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 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