On 5/18/26 7:55 PM, Eliot Courtney wrote:
> Currently, PCI-AT takes the final image if multiple exist. For FWSEC, it
> takes the first one and the last one. Align both of these to nouveau
> behavior by taking the first ones.

Let's do even better, and use Open RM for guidance instead of
nouveau, for this case.

Open RM tracks one offset where the FWSEC region starts and reads
everything past it as one buffer (see s_locateExpansionRoms() in
kernel_gsp_vbios_tu102.c). Matching that in nova-core drops the
first-vs-second-FWSEC dispatch and the second checked_sub in
FwSecBiosImage::new.

This saves about 40 LOC.

I think it's worth doing.

thanks,
-- 
John Hubbard


> 
> Signed-off-by: Eliot Courtney <[email protected]>
> ---
>  drivers/gpu/nova-core/vbios.rs | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/nova-core/vbios.rs b/drivers/gpu/nova-core/vbios.rs
> index c5dad9e065da..ff21f85fdfb6 100644
> --- a/drivers/gpu/nova-core/vbios.rs
> +++ b/drivers/gpu/nova-core/vbios.rs
> @@ -333,12 +333,16 @@ pub(crate) fn new(dev: &device::Device, bar0: &Bar0) -> 
> Result<Vbios> {
>              // Convert to a specific image type
>              match BiosImageType::try_from(image.pcir.code_type) {
>                  Ok(BiosImageType::PciAt) => {
> -                    pci_at_image = Some(PciAtBiosImage::try_from(image)?);
> +                    // Silently ignore any extra PCI-AT images.
> +                    if pci_at_image.is_none() {
> +                        pci_at_image = 
> Some(PciAtBiosImage::try_from(image)?);
> +                    }
>                  }
>                  Ok(BiosImageType::FwSec) => {
> +                    // Silently ignore any extra FwSec images beyond the 
> first two.
>                      if first_fwsec_image.is_none() {
>                          first_fwsec_image = Some(image);
> -                    } else {
> +                    } else if second_fwsec_image.is_none() {
>                          second_fwsec_image = Some(image);
>                      }
>                  }
> 

Reply via email to