mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] video: lcdif: skip framebuffer registration when no display modes available
@ 2026-06-23 19:20 Johannes Schneider
  0 siblings, 0 replies; only message in thread
From: Johannes Schneider @ 2026-06-23 19:20 UTC (permalink / raw)
  To: barebox; +Cc: Johannes Schneider

When the downstream VPL chain reports no modes (e.g. the panel-lvds
node was runtime-disabled by board code on a unit shipped without a
panel), the driver previously fell back to a 640x480 default,
allocated a framebuffer, registered /dev/fb0, exported a (bogus)
simplefb DT fixup to the kernel, and tried to fb_enable() the
controller.  fb_enable() then bailed because info->mode was NULL,
but only after we'd already exported a non-functional simplefb to
Linux's DRM_SIMPLEDRM and wasted ~1.2 MB on a buffer nothing
scans out.

Return early from lcdif_register_fb when num_modes == 0.  Drop the
640x480 fallback -- if VPL has no panel, there is nothing to scan
out and a default fb is just misleading state.

Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com>
---

A usage example where this becomes relevant and fixes a bug:
we have a "modular" hardware design, where the same base-board can
have either none, one or two displays bolted on - all running the same
bootloader+OS. The barebox boardcode for said base-board reads a
configuration eeprom and would then runtime disable the panels
devicetree node - leaving the framebuffer driver without anything that
has valid modes, leading to a NULL dereference.

---
 drivers/video/lcdif_kms.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/video/lcdif_kms.c b/drivers/video/lcdif_kms.c
index e3d1985dc9..bbdbf4eed3 100644
--- a/drivers/video/lcdif_kms.c
+++ b/drivers/video/lcdif_kms.c
@@ -431,18 +431,18 @@ static int lcdif_register_fb(struct lcdif_drm_private *lcdif)
 		return ret;
 	}
 
-	if (info->modes.num_modes) {
-		for (i = 0; i < info->modes.num_modes; i++) {
-			xmax = max(xmax, info->modes.modes[i].xres);
-			ymax = max(ymax, info->modes.modes[i].yres);
-		}
-		info->xres = info->modes.modes[info->modes.native_mode].xres;
-		info->yres = info->modes.modes[info->modes.native_mode].yres;
-	} else {
-		dev_notice(lcdif->dev, "no modes found on lcdif%d\n", lcdif->id);
-		xmax = info->xres = 640;
-		ymax = info->yres = 480;
+	/* no panel downstream -> nothing to scan out; stay idle */
+	if (!info->modes.num_modes) {
+		dev_info(lcdif->dev, "no display modes from VPL, LCDIF stays idle\n");
+		return 0;
+	}
+
+	for (i = 0; i < info->modes.num_modes; i++) {
+		xmax = max(xmax, info->modes.modes[i].xres);
+		ymax = max(ymax, info->modes.modes[i].yres);
 	}
+	info->xres = info->modes.modes[info->modes.native_mode].xres;
+	info->yres = info->modes.modes[info->modes.native_mode].yres;
 
 	lcdif->line_length = xmax * (info->bits_per_pixel >> 3);
 	lcdif->max_yres = ymax;
-- 
2.43.0




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-23 19:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-23 19:20 [PATCH] video: lcdif: skip framebuffer registration when no display modes available Johannes Schneider

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox