Re: [PATCH 1/1] smbios: add extended Extended BIOS ROM Size

2024-07-23 Thread Ilias Apalodimas
Hi Heinrich,

On Tue, 23 Jul 2024 at 13:46, Heinrich Schuchardt
 wrote:
>
> U-Boot claims to create SMBIOS 3.7 tables. The type 0 table has
> a field Extended BIOS ROM Size since version 3.1.
>
> BIOS ROM sizes of 16 MiB or above must be written to this field.
>
> Add and fill the missing field.
>
> This patch does not cover the case of a ROM >= 8 GiB which cannot
> be configured in U-Boot.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  include/smbios.h | 1 +
>  lib/smbios.c | 9 -
>  2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/include/smbios.h b/include/smbios.h
> index a4fda9df7bd..00119d7a60c 100644
> --- a/include/smbios.h
> +++ b/include/smbios.h
> @@ -105,6 +105,7 @@ struct __packed smbios_type0 {
> u8 bios_minor_release;
> u8 ec_major_release;
> u8 ec_minor_release;
> +   u16 extended_bios_rom_size;
> char eos[SMBIOS_STRUCT_EOS_BYTES];
>  };
>
> diff --git a/lib/smbios.c b/lib/smbios.c
> index 4126466e34a..e2a2f873a94 100644
> --- a/lib/smbios.c
> +++ b/lib/smbios.c
> @@ -348,7 +348,14 @@ static int smbios_write_type0(ulong *current, int handle,
>  #endif
> t->bios_release_date = smbios_add_prop(ctx, NULL, U_BOOT_DMI_DATE);
>  #ifdef CONFIG_ROM_SIZE
> -   t->bios_rom_size = (CONFIG_ROM_SIZE / 65536) - 1;
> +   if (CONFIG_ROM_SIZE < 0x100) {

nit, but can we use SZ_16M instead? Then the comment below goes away

> +   /* CONFIG_ROM_SIZE < 16 MiB */
> +   t->bios_rom_size = (CONFIG_ROM_SIZE / 65536) - 1;
> +   } else {
> +   /* CONFIG_ROM_SIZE < 8 GiB */
> +   t->bios_rom_size = 0xff;

If the size is above 1gb we should also change bits 15:14. I guess
being above 1GB will never happen, but can we add a comment?

Thanks
/IIlias
> +   t->extended_bios_rom_size = CONFIG_ROM_SIZE >> 20;
> +   }
>  #endif
> t->bios_characteristics = BIOS_CHARACTERISTICS_PCI_SUPPORTED |
>   BIOS_CHARACTERISTICS_SELECTABLE_BOOT |
> --
> 2.45.2
>


Re: [PATCH 1/1] smbios: add extended Extended BIOS ROM Size

2024-07-23 Thread Ilias Apalodimas
On Tue, 23 Jul 2024 at 17:12, Ilias Apalodimas
 wrote:
>
> Hi Heinrich,
>
> On Tue, 23 Jul 2024 at 13:46, Heinrich Schuchardt
>  wrote:
> >
> > U-Boot claims to create SMBIOS 3.7 tables. The type 0 table has
> > a field Extended BIOS ROM Size since version 3.1.
> >
> > BIOS ROM sizes of 16 MiB or above must be written to this field.
> >
> > Add and fill the missing field.
> >
> > This patch does not cover the case of a ROM >= 8 GiB which cannot
> > be configured in U-Boot.
> >
> > Signed-off-by: Heinrich Schuchardt 
> > ---
> >  include/smbios.h | 1 +
> >  lib/smbios.c | 9 -
> >  2 files changed, 9 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/smbios.h b/include/smbios.h
> > index a4fda9df7bd..00119d7a60c 100644
> > --- a/include/smbios.h
> > +++ b/include/smbios.h
> > @@ -105,6 +105,7 @@ struct __packed smbios_type0 {
> > u8 bios_minor_release;
> > u8 ec_major_release;
> > u8 ec_minor_release;
> > +   u16 extended_bios_rom_size;
> > char eos[SMBIOS_STRUCT_EOS_BYTES];
> >  };
> >
> > diff --git a/lib/smbios.c b/lib/smbios.c
> > index 4126466e34a..e2a2f873a94 100644
> > --- a/lib/smbios.c
> > +++ b/lib/smbios.c
> > @@ -348,7 +348,14 @@ static int smbios_write_type0(ulong *current, int 
> > handle,
> >  #endif
> > t->bios_release_date = smbios_add_prop(ctx, NULL, U_BOOT_DMI_DATE);
> >  #ifdef CONFIG_ROM_SIZE
> > -   t->bios_rom_size = (CONFIG_ROM_SIZE / 65536) - 1;
> > +   if (CONFIG_ROM_SIZE < 0x100) {
>
> nit, but can we use SZ_16M instead? Then the comment below goes away
>
> > +   /* CONFIG_ROM_SIZE < 16 MiB */
> > +   t->bios_rom_size = (CONFIG_ROM_SIZE / 65536) - 1;
> > +   } else {
> > +   /* CONFIG_ROM_SIZE < 8 GiB */
> > +   t->bios_rom_size = 0xff;
>
> If the size is above 1gb we should also change bits 15:14. I guess
> being above 1GB will never happen, but can we add a comment?

Ah scratch that, you only convert and report mbytes, so that's fine

With or without the nit above

Reviewed-by: Ilias Apalodimas 

>
> Thanks
> /IIlias
> > +   t->extended_bios_rom_size = CONFIG_ROM_SIZE >> 20;
> > +   }
> >  #endif
> > t->bios_characteristics = BIOS_CHARACTERISTICS_PCI_SUPPORTED |
> >   BIOS_CHARACTERISTICS_SELECTABLE_BOOT |
> > --
> > 2.45.2
> >


Re: [PATCH 1/1] smbios: add extended Extended BIOS ROM Size

2024-07-23 Thread Heinrich Schuchardt

On 23.07.24 16:12, Ilias Apalodimas wrote:

Hi Heinrich,

On Tue, 23 Jul 2024 at 13:46, Heinrich Schuchardt
 wrote:


U-Boot claims to create SMBIOS 3.7 tables. The type 0 table has
a field Extended BIOS ROM Size since version 3.1.

BIOS ROM sizes of 16 MiB or above must be written to this field.

Add and fill the missing field.

This patch does not cover the case of a ROM >= 8 GiB which cannot
be configured in U-Boot.

Signed-off-by: Heinrich Schuchardt 
---
  include/smbios.h | 1 +
  lib/smbios.c | 9 -
  2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/include/smbios.h b/include/smbios.h
index a4fda9df7bd..00119d7a60c 100644
--- a/include/smbios.h
+++ b/include/smbios.h
@@ -105,6 +105,7 @@ struct __packed smbios_type0 {
 u8 bios_minor_release;
 u8 ec_major_release;
 u8 ec_minor_release;
+   u16 extended_bios_rom_size;
 char eos[SMBIOS_STRUCT_EOS_BYTES];
  };

diff --git a/lib/smbios.c b/lib/smbios.c
index 4126466e34a..e2a2f873a94 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -348,7 +348,14 @@ static int smbios_write_type0(ulong *current, int handle,
  #endif
 t->bios_release_date = smbios_add_prop(ctx, NULL, U_BOOT_DMI_DATE);
  #ifdef CONFIG_ROM_SIZE
-   t->bios_rom_size = (CONFIG_ROM_SIZE / 65536) - 1;
+   if (CONFIG_ROM_SIZE < 0x100) {


nit, but can we use SZ_16M instead? Then the comment below goes away


Sure.




+   /* CONFIG_ROM_SIZE < 16 MiB */
+   t->bios_rom_size = (CONFIG_ROM_SIZE / 65536) - 1;
+   } else {
+   /* CONFIG_ROM_SIZE < 8 GiB */
+   t->bios_rom_size = 0xff;


If the size is above 1gb we should also change bits 15:14. I guess
being above 1GB will never happen, but can we add a comment?


There is a comment mentioning the 8 GiB limit.

As there are 13 bits for the number, we can encode sizes up to 8091 MiB 
in MiB. We should not try to encode a 1536 MiB flash as 1 GiB.


Best regards

Heinrich



Thanks
/IIlias

+   t->extended_bios_rom_size = CONFIG_ROM_SIZE >> 20;
+   }
  #endif
 t->bios_characteristics = BIOS_CHARACTERISTICS_PCI_SUPPORTED |
   BIOS_CHARACTERISTICS_SELECTABLE_BOOT |
--
2.45.2





Re: [PATCH 1/1] smbios: add extended Extended BIOS ROM Size

2024-07-23 Thread Mark Kettenis
> From: Heinrich Schuchardt 
> Date: Tue, 23 Jul 2024 12:46:34 +0200
> 
> U-Boot claims to create SMBIOS 3.7 tables. The type 0 table has
> a field Extended BIOS ROM Size since version 3.1.
> 
> BIOS ROM sizes of 16 MiB or above must be written to this field.
> 
> Add and fill the missing field.
> 
> This patch does not cover the case of a ROM >= 8 GiB which cannot
> be configured in U-Boot.
> 
> Signed-off-by: Heinrich Schuchardt 
> ---
>  include/smbios.h | 1 +
>  lib/smbios.c | 9 -
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/include/smbios.h b/include/smbios.h
> index a4fda9df7bd..00119d7a60c 100644
> --- a/include/smbios.h
> +++ b/include/smbios.h
> @@ -105,6 +105,7 @@ struct __packed smbios_type0 {
>   u8 bios_minor_release;
>   u8 ec_major_release;
>   u8 ec_minor_release;
> + u16 extended_bios_rom_size;
>   char eos[SMBIOS_STRUCT_EOS_BYTES];
>  };
>  
> diff --git a/lib/smbios.c b/lib/smbios.c
> index 4126466e34a..e2a2f873a94 100644
> --- a/lib/smbios.c
> +++ b/lib/smbios.c
> @@ -348,7 +348,14 @@ static int smbios_write_type0(ulong *current, int handle,
>  #endif
>   t->bios_release_date = smbios_add_prop(ctx, NULL, U_BOOT_DMI_DATE);
>  #ifdef CONFIG_ROM_SIZE
> - t->bios_rom_size = (CONFIG_ROM_SIZE / 65536) - 1;
> + if (CONFIG_ROM_SIZE < 0x100) {
> + /* CONFIG_ROM_SIZE < 16 MiB */
> + t->bios_rom_size = (CONFIG_ROM_SIZE / 65536) - 1;
> + } else {
> + /* CONFIG_ROM_SIZE < 8 GiB */

I don't think that comment is true ;).

> + t->bios_rom_size = 0xff;
> + t->extended_bios_rom_size = CONFIG_ROM_SIZE >> 20;
> + }
>  #endif
>   t->bios_characteristics = BIOS_CHARACTERISTICS_PCI_SUPPORTED |
> BIOS_CHARACTERISTICS_SELECTABLE_BOOT |
> -- 
> 2.45.2
> 
> 


Re: [PATCH 1/1] smbios: add extended Extended BIOS ROM Size

2024-07-23 Thread Mark Kettenis
> Date: Tue, 23 Jul 2024 22:12:57 +0200
> From: Mark Kettenis 
> 
> > From: Heinrich Schuchardt 
> > Date: Tue, 23 Jul 2024 12:46:34 +0200
> > 
> > U-Boot claims to create SMBIOS 3.7 tables. The type 0 table has
> > a field Extended BIOS ROM Size since version 3.1.
> > 
> > BIOS ROM sizes of 16 MiB or above must be written to this field.
> > 
> > Add and fill the missing field.
> > 
> > This patch does not cover the case of a ROM >= 8 GiB which cannot
> > be configured in U-Boot.
> > 
> > Signed-off-by: Heinrich Schuchardt 
> > ---
> >  include/smbios.h | 1 +
> >  lib/smbios.c | 9 -
> >  2 files changed, 9 insertions(+), 1 deletion(-)
> > 
> > diff --git a/include/smbios.h b/include/smbios.h
> > index a4fda9df7bd..00119d7a60c 100644
> > --- a/include/smbios.h
> > +++ b/include/smbios.h
> > @@ -105,6 +105,7 @@ struct __packed smbios_type0 {
> > u8 bios_minor_release;
> > u8 ec_major_release;
> > u8 ec_minor_release;
> > +   u16 extended_bios_rom_size;
> > char eos[SMBIOS_STRUCT_EOS_BYTES];
> >  };
> >  
> > diff --git a/lib/smbios.c b/lib/smbios.c
> > index 4126466e34a..e2a2f873a94 100644
> > --- a/lib/smbios.c
> > +++ b/lib/smbios.c
> > @@ -348,7 +348,14 @@ static int smbios_write_type0(ulong *current, int 
> > handle,
> >  #endif
> > t->bios_release_date = smbios_add_prop(ctx, NULL, U_BOOT_DMI_DATE);
> >  #ifdef CONFIG_ROM_SIZE
> > -   t->bios_rom_size = (CONFIG_ROM_SIZE / 65536) - 1;
> > +   if (CONFIG_ROM_SIZE < 0x100) {
> > +   /* CONFIG_ROM_SIZE < 16 MiB */
> > +   t->bios_rom_size = (CONFIG_ROM_SIZE / 65536) - 1;
> > +   } else {
> > +   /* CONFIG_ROM_SIZE < 8 GiB */
> 
> I don't think that comment is true ;).

Uh, never mind, MiB vs. GiB.  Sorry for the noise.

> > +   t->bios_rom_size = 0xff;
> > +   t->extended_bios_rom_size = CONFIG_ROM_SIZE >> 20;
> > +   }
> >  #endif
> > t->bios_characteristics = BIOS_CHARACTERISTICS_PCI_SUPPORTED |
> >   BIOS_CHARACTERISTICS_SELECTABLE_BOOT |
> > -- 
> > 2.45.2
> > 
> > 
>