public inbox for linux-efi@vger.kernel.org
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: Javier Martinez Canillas <javierm@redhat.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	Ard Biesheuvel <ardb@kernel.org>
Cc: Carlos Soriano Sanchez <csoriano@redhat.com>,
	<amd-gfx@lists.freedesktop.org>,
	<dri-devel@lists.freedesktop.org>,
	"David Airlie" <airlied@gmail.com>,
	Daniel Vetter <daniel@ffwll.ch>, <christian.koenig@amd.com>,
	Mario Limonciello <mario.limonciello@amd.com>,
	<linux-efi@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/2] firmware: sysfb: Allow re-creating system framebuffer after init
Date: Thu, 22 Dec 2022 12:30:10 -0600	[thread overview]
Message-ID: <20221222183012.1046-2-mario.limonciello@amd.com> (raw)
In-Reply-To: <20221222183012.1046-1-mario.limonciello@amd.com>

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@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


  reply	other threads:[~2022-12-22 18:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-22 18:30 [PATCH 0/2] Recover from failure to probe GPU Mario Limonciello
2022-12-22 18:30 ` Mario Limonciello [this message]
2022-12-22 19:41 ` Javier Martinez Canillas
2022-12-23 15:51   ` Mario Limonciello
2022-12-24  9:34 ` Thomas Zimmermann
2022-12-25 15:30   ` Christian König
2022-12-27 15:40     ` Alex Deucher
2022-12-27 17:04       ` Alex Deucher
2022-12-27 19:23         ` Javier Martinez Canillas

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=20221222183012.1046-2-mario.limonciello@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=ardb@kernel.org \
    --cc=christian.koenig@amd.com \
    --cc=csoriano@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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