From: Thomas Zimmermann <tzimmermann@suse.de>
To: Javier Martinez Canillas <javierm@redhat.com>,
ardb@kernel.org, jonathan@marek.ca
Cc: linux-efi@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] efi/libstub: gop: Find GOP handle instead of GOP data
Date: Fri, 24 Oct 2025 14:06:06 +0200 [thread overview]
Message-ID: <acadd898-73a0-41fc-8b3b-ce2d0438a173@suse.de> (raw)
In-Reply-To: <87wm4k8wcz.fsf@ocarina.mail-host-address-is-not-set>
Hi Javier,
thanks for reviewing.
Am 24.10.25 um 11:47 schrieb Javier Martinez Canillas:
> Thomas Zimmermann <tzimmermann@suse.de> writes:
>
>> 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>
>> ---
>> drivers/firmware/efi/libstub/gop.c | 27 +++++++++++++++++----------
>> 1 file changed, 17 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/firmware/efi/libstub/gop.c b/drivers/firmware/efi/libstub/gop.c
>> index 3785fb4986b4..fd32be8dd146 100644
>> --- a/drivers/firmware/efi/libstub/gop.c
>> +++ b/drivers/firmware/efi/libstub/gop.c
>> @@ -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;
>>
> I think the logic of this function could be simplified if you remove some
> of the variables. For example, I don't think you need a fist_gop variable
> anymore now that you are passing a found_gop variable as a function param.
>
>> 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;
> You can just assign *found_gop = gop here...
>
>> + }
>> }
>>
>> - return first_gop;
>> + if (found_gop)
>> + *found_gop = first_gop;
> ...and then this assignment won't be needed anynmore.
TBH I choose that style on purpose. It's easily parseable by the eye.
found_gop is allowed be NULL and we'd have to test within the loop. I
found this uneasy to read. And assigning *found_gop early leaks state to
the outside before it's ready. That's probably not a problem here, but I
find that questionable.
>
>> + return first_gop_handle;
> Also, given that you are calling first_gop_handle to the variable to
> store the first gop handle, I would for consistency name the parameter
> fist_gop and just drop the local variable with the same name.
The found_gop is not necessarily the first_gop. We want to return the
primary device's handle and GOP state. The first one is only returned if
there's no clear primary one. See [1] as for how the primary is being
detected.
[1]
https://elixir.bootlin.com/linux/v6.17.4/source/drivers/firmware/efi/libstub/gop.c#L433
Best regards
Thomas
>
> But I agree with the general logic of the patch, so regardless of what
> you prefer to do:
>
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
>
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
next prev parent reply other threads:[~2025-10-24 12:06 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 15:56 [PATCH 0/5] efi: x86: Provide EDID from GOP device Thomas Zimmermann
2025-10-15 15:56 ` [PATCH 1/5] efi: Fix trailing whitespace in header file Thomas Zimmermann
2025-10-24 9:19 ` Javier Martinez Canillas
2025-10-15 15:56 ` [PATCH 2/5] efi/libstub: gop: Find GOP handle instead of GOP data Thomas Zimmermann
2025-10-24 9:47 ` Javier Martinez Canillas
2025-10-24 12:06 ` Thomas Zimmermann [this message]
2025-10-15 15:56 ` [PATCH 3/5] efi/libstub: gop: Initialize screen_info in helper function Thomas Zimmermann
2025-10-24 9:53 ` Javier Martinez Canillas
2025-11-17 7:37 ` Thomas Zimmermann
2025-10-15 15:56 ` [PATCH 4/5] efi/libstub: gop: Add support for reading EDID Thomas Zimmermann
2025-10-24 9:56 ` Javier Martinez Canillas
2025-11-17 7:40 ` Thomas Zimmermann
2025-10-15 15:56 ` [PATCH 5/5] efi/libstub: x86: Store EDID in boot_params Thomas Zimmermann
2025-10-24 9:57 ` Javier Martinez Canillas
2025-11-14 8:31 ` [PATCH 0/5] efi: x86: Provide EDID from GOP device Ard Biesheuvel
2025-11-17 8:01 ` Thomas Zimmermann
2025-11-18 16:52 ` Ard Biesheuvel
2025-11-18 19:41 ` Ard Biesheuvel
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=acadd898-73a0-41fc-8b3b-ce2d0438a173@suse.de \
--to=tzimmermann@suse.de \
--cc=ardb@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=jonathan@marek.ca \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®