[PATCH 1/2] firmware: sysfb: Allow re-creating system framebuffer after init

Mario Limonciello mario.limonciello at amd.com
Thu Dec 22 18:30:10 UTC 2022


When GPU kernel drivers have failed to load for any reason the
current experience is that the screen is frozen.  This is because
one of the first things that these drivers do is to call `sysfb_disable`.

For end users this is quite jarring and hard to recover from.  Allow
drivers to request the framebuffer to be re-created for a failure cleanup.

Signed-off-by: Mario Limonciello <mario.limonciello at amd.com>
---
 drivers/firmware/efi/sysfb_efi.c  |  6 +++---
 drivers/firmware/sysfb.c          | 15 ++++++++++++++-
 drivers/firmware/sysfb_simplefb.c |  4 ++--
 include/linux/sysfb.h             |  5 +++++
 4 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/firmware/efi/sysfb_efi.c b/drivers/firmware/efi/sysfb_efi.c
index 7882d4b3f2be..a890cb6d44fa 100644
--- a/drivers/firmware/efi/sysfb_efi.c
+++ b/drivers/firmware/efi/sysfb_efi.c
@@ -185,7 +185,7 @@ static int __init efifb_set_system(const struct dmi_system_id *id)
 		&efifb_dmi_list[enumid]				\
 	}
 
-static const struct dmi_system_id efifb_dmi_system_table[] __initconst = {
+static const struct dmi_system_id efifb_dmi_system_table[] = {
 	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac4,1", M_I17),
 	/* At least one of these two will be right; maybe both? */
 	EFIFB_DMI_SYSTEM_ID("Apple Computer, Inc.", "iMac5,1", M_I20),
@@ -235,7 +235,7 @@ static const struct dmi_system_id efifb_dmi_system_table[] __initconst = {
  * pitch). We simply swap width and height for these devices so that we can
  * correctly deal with some of them coming with multiple resolutions.
  */
-static const struct dmi_system_id efifb_dmi_swap_width_height[] __initconst = {
+static const struct dmi_system_id efifb_dmi_swap_width_height[] = {
 	{
 		/*
 		 * Lenovo MIIX310-10ICR, only some batches have the troublesome
@@ -333,7 +333,7 @@ static const struct fwnode_operations efifb_fwnode_ops = {
 #ifdef CONFIG_EFI
 static struct fwnode_handle efifb_fwnode;
 
-__init void sysfb_apply_efi_quirks(struct platform_device *pd)
+void sysfb_apply_efi_quirks(struct platform_device *pd)
 {
 	if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI ||
 	    !(screen_info.capabilities & VIDEO_CAPABILITY_SKIP_QUIRKS))
diff --git a/drivers/firmware/sysfb.c b/drivers/firmware/sysfb.c
index 3fd3563d962b..7f2254bd2071 100644
--- a/drivers/firmware/sysfb.c
+++ b/drivers/firmware/sysfb.c
@@ -69,7 +69,7 @@ void sysfb_disable(void)
 }
 EXPORT_SYMBOL_GPL(sysfb_disable);
 
-static __init int sysfb_init(void)
+static int sysfb_init(void)
 {
 	struct screen_info *si = &screen_info;
 	struct simplefb_platform_data mode;
@@ -124,6 +124,19 @@ static __init int sysfb_init(void)
 	mutex_unlock(&disable_lock);
 	return ret;
 }
+/**
+ * sysfb_enable() - re-enable the Generic System Framebuffers support
+ *
+ * This causes the system framebuffer initialization to be re-run.
+ * It is intended to be called by DRM drivers that failed probe for cleanup.
+ *
+ */
+int sysfb_enable(void)
+{
+	disabled = false;
+	return sysfb_init();
+}
+EXPORT_SYMBOL_GPL(sysfb_enable);
 
 /* must execute after PCI subsystem for EFI quirks */
 device_initcall(sysfb_init);
diff --git a/drivers/firmware/sysfb_simplefb.c b/drivers/firmware/sysfb_simplefb.c
index a353e27f83f5..82735ff81191 100644
--- a/drivers/firmware/sysfb_simplefb.c
+++ b/drivers/firmware/sysfb_simplefb.c
@@ -24,7 +24,7 @@ static const char simplefb_resname[] = "BOOTFB";
 static const struct simplefb_format formats[] = SIMPLEFB_FORMATS;
 
 /* try parsing screen_info into a simple-framebuffer mode struct */
-__init bool sysfb_parse_mode(const struct screen_info *si,
+bool sysfb_parse_mode(const struct screen_info *si,
 			     struct simplefb_platform_data *mode)
 {
 	const struct simplefb_format *f;
@@ -57,7 +57,7 @@ __init bool sysfb_parse_mode(const struct screen_info *si,
 	return false;
 }
 
-__init struct platform_device *sysfb_create_simplefb(const struct screen_info *si,
+struct platform_device *sysfb_create_simplefb(const struct screen_info *si,
 						     const struct simplefb_platform_data *mode)
 {
 	struct platform_device *pd;
diff --git a/include/linux/sysfb.h b/include/linux/sysfb.h
index 8ba8b5be5567..14d447576e57 100644
--- a/include/linux/sysfb.h
+++ b/include/linux/sysfb.h
@@ -58,6 +58,7 @@ struct efifb_dmi_info {
 #ifdef CONFIG_SYSFB
 
 void sysfb_disable(void);
+int sysfb_enable(void);
 
 #else /* CONFIG_SYSFB */
 
@@ -65,6 +66,10 @@ static inline void sysfb_disable(void)
 {
 }
 
+static int sysfb_enable(void)
+{
+}
+
 #endif /* CONFIG_SYSFB */
 
 #ifdef CONFIG_EFI
-- 
2.34.1



More information about the amd-gfx mailing list