From: Ard Biesheuvel <ardb+git@google.com>
To: linux-efi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel <ardb@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
Javier Martinez Canillas <javierm@redhat.com>
Subject: [PATCH 2/3] video/edid: Use getter function for edid_info
Date: Wed, 19 Nov 2025 13:30:14 +0100 [thread overview]
Message-ID: <20251119123011.1187249-7-ardb+git@google.com> (raw)
In-Reply-To: <20251119123011.1187249-5-ardb+git@google.com>
From: Ard Biesheuvel <ardb@kernel.org>
Avoid accessing a global writable buffer directly for edid_info, and
instead, define a getter function returning a pointer to it. And
considering that all callers access only the 'dummy' field, just
return a const u8* directly.
This will be used by non-x86 EFI systems that pass edid_info via a EFI
configuration table.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/x86/kernel/setup.c | 8 ++++++--
drivers/gpu/drm/sysfb/efidrm.c | 4 ++--
drivers/gpu/drm/sysfb/vesadrm.c | 4 ++--
drivers/video/fbdev/core/fbmon.c | 4 ++--
include/video/edid.h | 2 +-
5 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 1b2edd07a3e1..526c9c4553c1 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -214,8 +214,12 @@ arch_initcall(init_x86_sysctl);
struct screen_info screen_info;
EXPORT_SYMBOL(screen_info);
#if defined(CONFIG_FIRMWARE_EDID)
-struct edid_info edid_info;
-EXPORT_SYMBOL_GPL(edid_info);
+static struct edid_info edid_info __ro_after_init;
+const u8 *get_edid_info(void)
+{
+ return edid_info.dummy;
+}
+EXPORT_SYMBOL_GPL(get_edid_info);
#endif
extern int root_mountflags;
diff --git a/drivers/gpu/drm/sysfb/efidrm.c b/drivers/gpu/drm/sysfb/efidrm.c
index 1883c4a8604c..e30b93ed4264 100644
--- a/drivers/gpu/drm/sysfb/efidrm.c
+++ b/drivers/gpu/drm/sysfb/efidrm.c
@@ -203,8 +203,8 @@ static struct efidrm_device *efidrm_device_create(struct drm_driver *drv,
&format->format, width, height, stride);
#if defined(CONFIG_FIRMWARE_EDID)
- if (drm_edid_header_is_valid(edid_info.dummy) == 8)
- sysfb->edid = edid_info.dummy;
+ if (drm_edid_header_is_valid(get_edid_info()) == 8)
+ sysfb->edid = get_edid_info();
#endif
sysfb->fb_mode = drm_sysfb_mode(width, height, 0, 0);
sysfb->fb_format = format;
diff --git a/drivers/gpu/drm/sysfb/vesadrm.c b/drivers/gpu/drm/sysfb/vesadrm.c
index 16a4b52d45c6..a4ff78fddc0c 100644
--- a/drivers/gpu/drm/sysfb/vesadrm.c
+++ b/drivers/gpu/drm/sysfb/vesadrm.c
@@ -469,8 +469,8 @@ static struct vesadrm_device *vesadrm_device_create(struct drm_driver *drv,
}
#if defined(CONFIG_FIRMWARE_EDID)
- if (drm_edid_header_is_valid(edid_info.dummy) == 8)
- sysfb->edid = edid_info.dummy;
+ if (drm_edid_header_is_valid(get_edid_info()) == 8)
+ sysfb->edid = get_edid_info();
#endif
sysfb->fb_mode = drm_sysfb_mode(width, height, 0, 0);
sysfb->fb_format = format;
diff --git a/drivers/video/fbdev/core/fbmon.c b/drivers/video/fbdev/core/fbmon.c
index 0a65bef01e3c..caa057c76a88 100644
--- a/drivers/video/fbdev/core/fbmon.c
+++ b/drivers/video/fbdev/core/fbmon.c
@@ -1495,7 +1495,7 @@ const unsigned char *fb_firmware_edid(struct device *device)
{
struct pci_dev *dev = NULL;
struct resource *res = NULL;
- unsigned char *edid = NULL;
+ const unsigned char *edid = NULL;
if (device)
dev = to_pci_dev(device);
@@ -1504,7 +1504,7 @@ const unsigned char *fb_firmware_edid(struct device *device)
res = &dev->resource[PCI_ROM_RESOURCE];
if (res && res->flags & IORESOURCE_ROM_SHADOW)
- edid = edid_info.dummy;
+ edid = get_edid_info();
return edid;
}
diff --git a/include/video/edid.h b/include/video/edid.h
index c2b186b1933a..b8f24c4b2829 100644
--- a/include/video/edid.h
+++ b/include/video/edid.h
@@ -5,7 +5,7 @@
#include <uapi/video/edid.h>
#if defined(CONFIG_FIRMWARE_EDID)
-extern struct edid_info edid_info;
+const u8 *get_edid_info(void) __attribute_const__;
#endif
#endif /* __linux_video_edid_h__ */
--
2.52.0.rc1.455.g30608eb744-goog
next prev parent reply other threads:[~2025-11-19 12:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 12:30 [PATCH 0/3] video/efi: Support FIRMWARE_EDID on non-x86 Ard Biesheuvel
2025-11-19 12:30 ` [PATCH 1/3] efi: Wrap screen_info in efi_screen_info so edid_info can be added later Ard Biesheuvel
2025-11-19 12:30 ` Ard Biesheuvel [this message]
2025-11-19 12:30 ` [PATCH 3/3] efi: Add FIRMWARE_EDID support Ard Biesheuvel
2025-11-20 7:56 ` [PATCH 0/3] video/efi: Support FIRMWARE_EDID on non-x86 Thomas Zimmermann
2025-11-20 8:19 ` Thomas Zimmermann
2025-11-20 8:25 ` Ard Biesheuvel
2025-11-21 14:03 ` Thomas Zimmermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251119123011.1187249-7-ardb+git@google.com \
--to=ardb+git@google.com \
--cc=ardb@kernel.org \
--cc=javierm@redhat.com \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox