Skip to contentSkip to conversation

efi: sysfb_efi: Fix DMI quirks not working for simpledrm

PATCH In review Hans de Goede 3 participants 5 messages Mar 14, 2023 – Mar 17, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 efi: sysfb_efi: Fix DMI quirks not working for simpledrm

Commit 8633ef82f101 ("drivers/firmware: consolidate EFI framebuffer setup for all arches") moved the sysfb_apply_efi_quirks() call in sysfb_init() from before the [sysfb_]parse_mode() call to after it.
But sysfb_apply_efi_quirks() modifies the global screen_info struct which [sysfb_]parse_mode() parses, so doing it later is too late.

This has broken all DMI based quirks for correcting wrong firmware efifb settings when simpledrm is used.

To fix this move the sysfb_apply_efi_quirks() call back to its old place and split the new setup of the efifb_fwnode (which requires the platform_device) into its own function and call that at the place of the moved sysfb_apply_efi_quirks(pd) calls.

Fixes 8633ef82f101 ("drivers/firmware: consolidate EFI framebuffer setup for all arches")
Cc Javier Martinez Canillas <[email protected]>
Cc Thomas Zimmermann <[email protected]>
---
 drivers/firmware/efi/sysfb_efi.c  | 5 ++++-
 drivers/firmware/sysfb.c          | 4 +++-
 drivers/firmware/sysfb_simplefb.c | 2 +-
 include/linux/sysfb.h             | 9 +++++++--
 4 files changed, 15 insertions(+), 5 deletions(-)
drivers/firmware/efi/sysfb_efi.c +4 -1
index f06fdacc9bc8..e76d6803bdd0 100644
@@ -341,7 +341,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)
+__init void sysfb_apply_efi_quirks(void)
 {
 	if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI ||
 	    !(screen_info.capabilities & VIDEO_CAPABILITY_SKIP_QUIRKS))
@@ -355,7 +355,10 @@ __init void sysfb_apply_efi_quirks(struct platform_device *pd)
 		screen_info.lfb_height = temp;
 		screen_info.lfb_linelength = 4 * screen_info.lfb_width;
 	}
+}
 
+__init void sysfb_set_efifb_fwnode(struct platform_device *pd)
+{
 	if (screen_info.orig_video_isVGA == VIDEO_TYPE_EFI && IS_ENABLED(CONFIG_PCI)) {
 		fwnode_init(&efifb_fwnode, &efifb_fwnode_ops);
 		pd->dev.fwnode = &efifb_fwnode;
drivers/firmware/sysfb.c +3 -1
index 3fd3563d962b..3c197db42c9d 100644
@@ -81,6 +81,8 @@ static __init int sysfb_init(void)
 	if (disabled)
 		goto unlock_mutex;
 
+	sysfb_apply_efi_quirks();
+
 	/* try to create a simple-framebuffer device */
 	compatible = sysfb_parse_mode(si, &mode);
 	if (compatible) {
@@ -107,7 +109,7 @@ static __init int sysfb_init(void)
 		goto unlock_mutex;
 	}
 
-	sysfb_apply_efi_quirks(pd);
+	sysfb_set_efifb_fwnode(pd);
 
 	ret = platform_device_add_data(pd, si, sizeof(*si));
 	if (ret)
drivers/firmware/sysfb_simplefb.c +1 -1
index ce9c007ed66f..82c64cb9f531 100644
@@ -141,7 +141,7 @@ __init struct platform_device *sysfb_create_simplefb(const struct screen_info *s
 	if (!pd)
 		return ERR_PTR(-ENOMEM);
 
-	sysfb_apply_efi_quirks(pd);
+	sysfb_set_efifb_fwnode(pd);
 
 	ret = platform_device_add_resources(pd, &res, 1);
 	if (ret)
include/linux/sysfb.h +7 -2
index 8ba8b5be5567..c1ef5fc60a3c 100644
@@ -70,11 +70,16 @@ static inline void sysfb_disable(void)
 #ifdef CONFIG_EFI
 
 extern struct efifb_dmi_info efifb_dmi_list[];
-void sysfb_apply_efi_quirks(struct platform_device *pd);
+void sysfb_apply_efi_quirks(void);
+void sysfb_set_efifb_fwnode(struct platform_device *pd);
 
 #else /* CONFIG_EFI */
 
-static inline void sysfb_apply_efi_quirks(struct platform_device *pd)
+static inline void sysfb_apply_efi_quirks(void)
+{
+}
+
+static inline void sysfb_set_efifb_fwnode(struct platform_device *pd)
 {
 }
 
Signature · 1 line
2.39.1
#1 lore raw

PATCH 2/2 efi: sysfb_efi: Add quirk for Lenovo Yoga Book X91F/L

Another Lenovo convertable which reports a landscape resolution of 1920x1200 with a pitch of (1920 * 4) bytes, while the actual framebuffer has a resolution of 1200x1920 with a pitch of (1200 * 4) bytes.

---
 drivers/firmware/efi/sysfb_efi.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/firmware/efi/sysfb_efi.c +8 -0
index e76d6803bdd0..456d0e5eaf78 100644
@@ -272,6 +272,14 @@ static const struct dmi_system_id efifb_dmi_swap_width_height[] __initconst = {
 					"IdeaPad Duet 3 10IGL5"),
 		},
 	},
+	{
+		/* Lenovo Yoga Book X91F / X91L */
+		.matches = {
+			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			/* Non exact match to match F + L versions */
+			DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X91"),
+		},
+	},
 	{},
 };
 
Signature · 1 line
2.39.1
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] efi: sysfb_efi: Add quirk for Lenovo Yoga Book X91F/L

Quoted 6 lines · Hans de Goede

Another Lenovo convertable which reports a landscape resolution of 1920x1200 with a pitch of (1920 * 4) bytes, while the actual framebuffer has a resolution of 1200x1920 with a pitch of (1200 * 4) bytes.

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
maintainer Reviewed-by on v1 1/2
#3 lore raw
In reply to Hans de Goede

Hans de Goede <[email protected]> writes:

Hello Hans,

Quoted 9 lines

Commit 8633ef82f101 ("drivers/firmware: consolidate EFI framebuffer setup for all arches") moved the sysfb_apply_efi_quirks() call in sysfb_init() from before the [sysfb_]parse_mode() call to after it.
But sysfb_apply_efi_quirks() modifies the global screen_info struct which [sysfb_]parse_mode() parses, so doing it later is too late.

This has broken all DMI based quirks for correcting wrong firmware efifb settings when simpledrm is used.

Indeed... sorry for missing this.

Quoted 11 lines

To fix this move the sysfb_apply_efi_quirks() call back to its old place and split the new setup of the efifb_fwnode (which requires the platform_device) into its own function and call that at the place of the moved sysfb_apply_efi_quirks(pd) calls.

Fixes 8633ef82f101 ("drivers/firmware: consolidate EFI framebuffer setup for all arches")
Cc Javier Martinez Canillas <[email protected]>
Cc Thomas Zimmermann <[email protected]>

---

Signature · 5 lines
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
maintainer
#4 lore raw
Quoted 22 lines · Javier Martinez Canillas

Hans de Goede <[email protected]> writes:

Hello Hans,

Quoted 9 lines

Commit 8633ef82f101 ("drivers/firmware: consolidate EFI framebuffer setup for all arches") moved the sysfb_apply_efi_quirks() call in sysfb_init() from before the [sysfb_]parse_mode() call to after it.
But sysfb_apply_efi_quirks() modifies the global screen_info struct which [sysfb_]parse_mode() parses, so doing it later is too late.

This has broken all DMI based quirks for correcting wrong firmware efifb settings when simpledrm is used.

Indeed... sorry for missing this.

Quoted 5 lines

To fix this move the sysfb_apply_efi_quirks() call back to its old place and split the new setup of the efifb_fwnode (which requires the platform_device) into its own function and call that at the place of the moved sysfb_apply_efi_quirks(pd) calls.

Quoted 9 lines
Quoted 6 lines
Fixes 8633ef82f101 ("drivers/firmware: consolidate EFI framebuffer setup for all arches")
Cc Javier Martinez Canillas <[email protected]>
Cc Thomas Zimmermann <[email protected]>

---

Thanks - I've queued these up now