git: f4e56d1bda03 - stable/13 - loader.efi: probe for UGA if GOP isn't found

From: Ahmad Khalifa <vexeduxr_at_FreeBSD.org>
Date: Mon, 12 Jan 2026 17:33:06 UTC
The branch stable/13 has been updated by vexeduxr:

URL: https://cgit.FreeBSD.org/src/commit/?id=f4e56d1bda03982c9624e9d098a47bbbe2b834d5

commit f4e56d1bda03982c9624e9d098a47bbbe2b834d5
Author:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
AuthorDate: 2026-01-04 13:15:02 +0000
Commit:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
CommitDate: 2026-01-12 17:28:02 +0000

    loader.efi: probe for UGA if GOP isn't found
    
    Probe for UGA instead of returning early if we can't find GOP.
    
    Reviewed by:    tsoome
    PR:             291935
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D54431
    
    (cherry picked from commit 5d85dde27b4769604fc108b89328607e70e767ed)
---
 stand/efi/loader/framebuffer.c | 74 ++++++++++++++++++++++--------------------
 1 file changed, 38 insertions(+), 36 deletions(-)

diff --git a/stand/efi/loader/framebuffer.c b/stand/efi/loader/framebuffer.c
index 56693187b576..abd99910f42a 100644
--- a/stand/efi/loader/framebuffer.c
+++ b/stand/efi/loader/framebuffer.c
@@ -576,53 +576,55 @@ efi_find_framebuffer(teken_gfx_t *gfx_state)
 		if (EFI_ERROR(status))
 			free(hlist);
 	}
-	if (EFI_ERROR(status))
-		return (efi_status_to_errno(status));
-
-	nhandles = hsize / sizeof(*hlist);
 
-	/*
-	 * Search for ConOut protocol, if not found, use first handle.
-	 */
-	gop_handle = NULL;
-	for (i = 0; i < nhandles; i++) {
-		EFI_GRAPHICS_OUTPUT *tgop;
-		void *dummy;
+	if (EFI_ERROR(status)) {
+		status = BS->LocateProtocol(&uga_guid, NULL, (VOID **)&uga);
+		if (status == EFI_SUCCESS) {
+			gfx_state->tg_fb_type = FB_UGA;
+			gfx_state->tg_private = uga;
+		} else {
+			return (1);
+		}
+	} else {
+		nhandles = hsize / sizeof(*hlist);
 
-		status = OpenProtocolByHandle(hlist[i], &gop_guid, (void **)&tgop);
-		if (status != EFI_SUCCESS)
-			continue;
+		/*
+		 * Search for ConOut protocol, if not found, use first handle.
+		 */
+		gop_handle = NULL;
+		for (i = 0; i < nhandles; i++) {
+			EFI_GRAPHICS_OUTPUT *tgop;
+			void *dummy;
+
+			status = OpenProtocolByHandle(hlist[i], &gop_guid,
+			    (void **)&tgop);
+			if (status != EFI_SUCCESS)
+				continue;
 
-		if (tgop->Mode->Info->PixelFormat == PixelBltOnly ||
-		    tgop->Mode->Info->PixelFormat >= PixelFormatMax)
-			continue;
+			if (tgop->Mode->Info->PixelFormat == PixelBltOnly ||
+			    tgop->Mode->Info->PixelFormat >= PixelFormatMax)
+				continue;
 
-		status = OpenProtocolByHandle(hlist[i], &conout_guid, &dummy);
-		if (status == EFI_SUCCESS) {
-			gop_handle = hlist[i];
-			gop = tgop;
-			break;
-		} else if (gop_handle == NULL) {
-			gop_handle = hlist[i];
-			gop = tgop;
+			status = OpenProtocolByHandle(hlist[i], &conout_guid,
+			    &dummy);
+			if (status == EFI_SUCCESS) {
+				gop_handle = hlist[i];
+				gop = tgop;
+				break;
+			} else if (gop_handle == NULL) {
+				gop_handle = hlist[i];
+				gop = tgop;
+			}
 		}
-	}
 
-	free(hlist);
+		free(hlist);
+		if (gop_handle == NULL)
+			return (ENXIO);
 
-	if (gop_handle != NULL) {
 		gfx_state->tg_fb_type = FB_GOP;
 		gfx_state->tg_private = gop;
 		if (edid_info == NULL)
 			edid_info = efifb_gop_get_edid(gop_handle);
-	} else {
-		status = BS->LocateProtocol(&uga_guid, NULL, (VOID **)&uga);
-		if (status == EFI_SUCCESS) {
-			gfx_state->tg_fb_type = FB_UGA;
-			gfx_state->tg_private = uga;
-		} else {
-			return (1);
-		}
 	}
 
 	switch (gfx_state->tg_fb_type) {