mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Johannes Schneider <johannes.schneider@leica-geosystems.com>
To: barebox@lists.infradead.org
Cc: Johannes Schneider <johannes.schneider@leica-geosystems.com>
Subject: [PATCH] video: lcdif: skip framebuffer registration when no display modes available
Date: Tue, 23 Jun 2026 19:20:17 +0000	[thread overview]
Message-ID: <20260623192017.3338905-1-johannes.schneider@leica-geosystems.com> (raw)

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




                 reply	other threads:[~2026-06-23 19:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260623192017.3338905-1-johannes.schneider@leica-geosystems.com \
    --to=johannes.schneider@leica-geosystems.com \
    --cc=barebox@lists.infradead.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