[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 5/8] xen/arm: efi: Avoid duplicating the addition of a new bank



On Wed, 15 Feb 2017, Stefano Stabellini wrote:
> On Fri, 3 Feb 2017, Julien Grall wrote:
> > The code to add a new bank is duplicated twice. Add a new helper that
> > checks if the maximum of bank has not reached and adds the bank.
> > 
> > Signed-off-by: Julien Grall <julien.grall@xxxxxxx>
> 
> Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> 
> 
> > ---
> >  xen/arch/arm/efi/efi-boot.h | 34 ++++++++++++++++++----------------
> >  1 file changed, 18 insertions(+), 16 deletions(-)
> > 
> > diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
> > index 045d6ce..757d9c6 100644
> > --- a/xen/arch/arm/efi/efi-boot.h
> > +++ b/xen/arch/arm/efi/efi-boot.h
> > @@ -124,15 +124,27 @@ static void __init 
> > *lookup_fdt_config_table(EFI_SYSTEM_TABLE *sys_table)
> >      return fdt;
> >  }
> >  
> > +static bool meminfo_add_bank(struct meminfo *mem, EFI_MEMORY_DESCRIPTOR 
> > *desc)

actually this function should be __init, right?


> > +{
> > +    struct membank *bank;
> > +
> > +    if ( mem->nr_banks > NR_MEM_BANKS )
> > +        return false;
> > +
> > +    bank = &mem->bank[mem->nr_banks];
> > +    bank->start = desc->PhysicalStart;
> > +    bank->size = desc->NumberOfPages * EFI_PAGE_SIZE;
> > +
> > +    mem->nr_banks++;
> > +
> > +    return true;
> > +}
> > +
> >  static EFI_STATUS __init 
> > efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *map,
> >                                                  UINTN mmap_size,
> >                                                  UINTN desc_size)
> >  {
> >      int Index;
> > -    int i = 0;
> > -#ifdef CONFIG_ACPI
> > -    int j = 0;
> > -#endif
> >      EFI_MEMORY_DESCRIPTOR *desc_ptr = map;
> >  
> >      for ( Index = 0; Index < (mmap_size / desc_size); Index++ )
> > @@ -142,37 +154,27 @@ static EFI_STATUS __init 
> > efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
> >                (desc_ptr->Type == EfiBootServicesCode ||
> >                 desc_ptr->Type == EfiBootServicesData)) )
> >          {
> > -            if ( i >= NR_MEM_BANKS )
> > +            if ( !meminfo_add_bank(&bootinfo.mem, desc_ptr) )
> >              {
> >                  PrintStr(L"Warning: All " __stringify(NR_MEM_BANKS)
> >                            " bootinfo mem banks exhausted.\r\n");
> >                  break;
> >              }
> > -            bootinfo.mem.bank[i].start = desc_ptr->PhysicalStart;
> > -            bootinfo.mem.bank[i].size = desc_ptr->NumberOfPages * 
> > EFI_PAGE_SIZE;
> > -            ++i;
> >          }
> >  #ifdef CONFIG_ACPI
> >          else if ( desc_ptr->Type == EfiACPIReclaimMemory )
> >          {
> > -            if ( j >= NR_MEM_BANKS )
> > +            if ( !meminfo_add_bank(&acpi_mem, desc_ptr) )
> >              {
> >                  PrintStr(L"Error: All " __stringify(NR_MEM_BANKS)
> >                            " acpi meminfo mem banks exhausted.\r\n");
> >                  return EFI_LOAD_ERROR;
> >              }
> > -            acpi_mem.bank[j].start = desc_ptr->PhysicalStart;
> > -            acpi_mem.bank[j].size  = desc_ptr->NumberOfPages * 
> > EFI_PAGE_SIZE;
> > -            ++j;
> >          }
> >  #endif
> >          desc_ptr = NextMemoryDescriptor(desc_ptr, desc_size);
> >      }
> >  
> > -    bootinfo.mem.nr_banks = i;
> > -#ifdef CONFIG_ACPI
> > -    acpi_mem.nr_banks = j;
> > -#endif
> >      return EFI_SUCCESS;
> >  }
> >  
> > -- 
> > 1.9.1
> > 
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.