]> Gentwo Git Trees - linux/.git/commitdiff
efi/libstub: gop: Find GOP handle instead of GOP data
authorThomas Zimmermann <tzimmermann@suse.de>
Wed, 15 Oct 2025 15:56:31 +0000 (17:56 +0200)
committerArd Biesheuvel <ardb@kernel.org>
Tue, 18 Nov 2025 19:39:55 +0000 (20:39 +0100)
The device handle of the GOP device is required to retrieve the
correct EDID data. Find the handle instead of the GOP data. Still
return the GOP data in the function arguments, as we already looked
it up.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/libstub/gop.c

index 3785fb4986b4390ae44a34465ee26db9ee8adc1f..fd32be8dd146f038898a80bfa66f1e5cd74518d9 100644 (file)
@@ -402,12 +402,13 @@ setup_pixel_info(struct screen_info *si, u32 pixels_per_scan_line,
        }
 }
 
-static efi_graphics_output_protocol_t *find_gop(unsigned long num,
-                                               const efi_handle_t handles[])
+static efi_handle_t find_handle_with_primary_gop(unsigned long num, const efi_handle_t handles[],
+                                                efi_graphics_output_protocol_t **found_gop)
 {
        efi_graphics_output_protocol_t *first_gop;
-       efi_handle_t h;
+       efi_handle_t h, first_gop_handle;
 
+       first_gop_handle = NULL;
        first_gop = NULL;
 
        for_each_efi_handle(h, handles, num) {
@@ -442,19 +443,25 @@ static efi_graphics_output_protocol_t *find_gop(unsigned long num,
                 */
                status = efi_bs_call(handle_protocol, h,
                                     &EFI_CONSOLE_OUT_DEVICE_GUID, &dummy);
-               if (status == EFI_SUCCESS)
-                       return gop;
-
-               if (!first_gop)
+               if (status == EFI_SUCCESS) {
+                       if (found_gop)
+                               *found_gop = gop;
+                       return h;
+               } else if (!first_gop_handle) {
+                       first_gop_handle = h;
                        first_gop = gop;
+               }
        }
 
-       return first_gop;
+       if (found_gop)
+               *found_gop = first_gop;
+       return first_gop_handle;
 }
 
 efi_status_t efi_setup_gop(struct screen_info *si)
 {
        efi_handle_t *handles __free(efi_pool) = NULL;
+       efi_handle_t handle;
        efi_graphics_output_protocol_mode_t *mode;
        efi_graphics_output_mode_info_t *info;
        efi_graphics_output_protocol_t *gop;
@@ -467,8 +474,8 @@ efi_status_t efi_setup_gop(struct screen_info *si)
        if (status != EFI_SUCCESS)
                return status;
 
-       gop = find_gop(num, handles);
-       if (!gop)
+       handle = find_handle_with_primary_gop(num, handles, &gop);
+       if (!handle)
                return EFI_NOT_FOUND;
 
        /* Change mode if requested */