mbox series

[v3,00/10] SMBIOS improvements

Message ID 20241206225438.13866-1-raymond.mao@linaro.org
Headers show
Series SMBIOS improvements | expand

Message

Raymond Mao Dec. 6, 2024, 10:54 p.m. UTC
Motivations for changes:
Current SMBIOS library and command-line tool is not fully matching with
the requirements:
1. Missing support for other mandatory types (#7, #9, #16, #17, #19).
2. Only a few platforms support SMBIOS node from the device tree.
3. Values of some fields are hardcoded in the library other than fetching
   from the device hardware.
4. Embedded data with dynamic length is not supported (E.g. Contained
   Object Handles in Type #2 and Contained Elements in Type #3)

Changes:
1. Refactor the SMBIOS library and command-line tool to better align with
   the SMBIOS spec.
2. Create an arch-specific driver for all aarch64-based platforms to fetch
   SMBIOS private data from the device hardware (processor and cache).
3. Create a sysinfo driver to poppulate platform SMBIOS private data.
4. Add generic SMBIOS DTS file for arm64 platforms for those common strings
   and values which cannot be retrieved from the system registers.
   Vendors can create their own SMBIOS node using this as an example.
   For those boards without SMBIOS nodes, this DTS file can be included to
   have a generic SMBIOS information of the system.
5. Add support for Type #7 (Cache Information) and link its handles to
   Type #4.
6. To minimize size-growth for those platforms which have not sufficient
   ROM spaces or the platforms which don't need detailed SMBIOS
   information, new added fields are only being built when kconfig
   GENERATE_SMBIOS_TABLE_VERBOSE is selected.
   
Once this patch is acceptted, subsequent patch sets will add other missing
types (#9, #16, #17, #19).

Tests:
To test this with QEMU arm64, please follow the guide on dt_qemu.rst to
get a merged DT to run with.
```
qemu-system-aarch64 -machine virt -machine dumpdtb=qemu.dtb
cat  <(dtc -I dtb qemu.dtb) <(dtc -I dtb ./dts/dt.dtb | grep -v /dts-v1/) \
  | dtc - -o merged.dtb
qemu-system-aarch64 -machine virt -nographic -bios u-boot.bin \
  -dtb merged.dtb
```

Raymond Mao (10):
  smbios: Refactor the smbios headfile
  sysinfo: Add sysinfo API for accessing data area
  test/dm: add sandbox test for sysinfo_get_data
  sysinfo: Add sysinfo driver and data structure for smbios
  smbios: Refactor smbios library
  smbios: add detailed smbios information
  armv8: Add arch-specific sysinfo platform driver
  armv8: Add generic smbios information into the device tree
  cmd: update smbios cmd
  configs: Enable sysinfo for QEMU Arm64

 arch/arm/cpu/armv8/Makefile      |   2 +
 arch/arm/cpu/armv8/sysinfo.c     | 292 ++++++++++++++++++++
 arch/arm/dts/qemu-arm64.dts      |   4 +
 arch/arm/dts/smbios_generic.dtsi |  82 ++++++
 cmd/smbios.c                     | 348 +++++++++++++++++++++---
 configs/qemu_arm64_defconfig     |   3 +
 drivers/misc/Kconfig             |   2 +-
 drivers/sysinfo/sandbox.c        |  19 ++
 drivers/sysinfo/sandbox.h        |   1 +
 drivers/sysinfo/smbios.c         | 228 ++++++++++++++++
 drivers/sysinfo/sysinfo-uclass.c |  20 ++
 include/smbios.h                 | 158 ++++++-----
 include/smbios_def.h             | 194 ++++++++++++++
 include/smbios_plat.h            |  79 ++++++
 include/sysinfo.h                | 125 ++++++++-
 lib/Kconfig                      |   6 +
 lib/smbios.c                     | 445 ++++++++++++++++++++++++++-----
 test/dm/sysinfo.c                |   6 +
 test/py/tests/test_smbios.py     |  18 +-
 19 files changed, 1863 insertions(+), 169 deletions(-)
 create mode 100644 arch/arm/cpu/armv8/sysinfo.c
 create mode 100644 arch/arm/dts/smbios_generic.dtsi
 create mode 100644 include/smbios_def.h
 create mode 100644 include/smbios_plat.h

Comments

Simon Glass Dec. 16, 2024, 3:16 p.m. UTC | #1
Hi Raymond,

On Fri, 6 Dec 2024 at 15:54, Raymond Mao <raymond.mao@linaro.org> wrote:
>
> Motivations for changes:
> Current SMBIOS library and command-line tool is not fully matching with
> the requirements:
> 1. Missing support for other mandatory types (#7, #9, #16, #17, #19).
> 2. Only a few platforms support SMBIOS node from the device tree.
> 3. Values of some fields are hardcoded in the library other than fetching
>    from the device hardware.
> 4. Embedded data with dynamic length is not supported (E.g. Contained
>    Object Handles in Type #2 and Contained Elements in Type #3)
>
> Changes:
> 1. Refactor the SMBIOS library and command-line tool to better align with
>    the SMBIOS spec.
> 2. Create an arch-specific driver for all aarch64-based platforms to fetch
>    SMBIOS private data from the device hardware (processor and cache).
> 3. Create a sysinfo driver to poppulate platform SMBIOS private data.
> 4. Add generic SMBIOS DTS file for arm64 platforms for those common strings
>    and values which cannot be retrieved from the system registers.
>    Vendors can create their own SMBIOS node using this as an example.
>    For those boards without SMBIOS nodes, this DTS file can be included to
>    have a generic SMBIOS information of the system.
> 5. Add support for Type #7 (Cache Information) and link its handles to
>    Type #4.
> 6. To minimize size-growth for those platforms which have not sufficient
>    ROM spaces or the platforms which don't need detailed SMBIOS
>    information, new added fields are only being built when kconfig
>    GENERATE_SMBIOS_TABLE_VERBOSE is selected.
>
> Once this patch is acceptted, subsequent patch sets will add other missing
> types (#9, #16, #17, #19).
>
> Tests:
> To test this with QEMU arm64, please follow the guide on dt_qemu.rst to
> get a merged DT to run with.
> ```
> qemu-system-aarch64 -machine virt -machine dumpdtb=qemu.dtb
> cat  <(dtc -I dtb qemu.dtb) <(dtc -I dtb ./dts/dt.dtb | grep -v /dts-v1/) \
>   | dtc - -o merged.dtb
> qemu-system-aarch64 -machine virt -nographic -bios u-boot.bin \
>   -dtb merged.dtb
> ```
>
> Raymond Mao (10):
>   smbios: Refactor the smbios headfile
>   sysinfo: Add sysinfo API for accessing data area
>   test/dm: add sandbox test for sysinfo_get_data
>   sysinfo: Add sysinfo driver and data structure for smbios
>   smbios: Refactor smbios library
>   smbios: add detailed smbios information
>   armv8: Add arch-specific sysinfo platform driver
>   armv8: Add generic smbios information into the device tree
>   cmd: update smbios cmd
>   configs: Enable sysinfo for QEMU Arm64
>
>  arch/arm/cpu/armv8/Makefile      |   2 +
>  arch/arm/cpu/armv8/sysinfo.c     | 292 ++++++++++++++++++++
>  arch/arm/dts/qemu-arm64.dts      |   4 +
>  arch/arm/dts/smbios_generic.dtsi |  82 ++++++
>  cmd/smbios.c                     | 348 +++++++++++++++++++++---
>  configs/qemu_arm64_defconfig     |   3 +
>  drivers/misc/Kconfig             |   2 +-
>  drivers/sysinfo/sandbox.c        |  19 ++
>  drivers/sysinfo/sandbox.h        |   1 +
>  drivers/sysinfo/smbios.c         | 228 ++++++++++++++++
>  drivers/sysinfo/sysinfo-uclass.c |  20 ++
>  include/smbios.h                 | 158 ++++++-----
>  include/smbios_def.h             | 194 ++++++++++++++
>  include/smbios_plat.h            |  79 ++++++
>  include/sysinfo.h                | 125 ++++++++-
>  lib/Kconfig                      |   6 +
>  lib/smbios.c                     | 445 ++++++++++++++++++++++++++-----
>  test/dm/sysinfo.c                |   6 +
>  test/py/tests/test_smbios.py     |  18 +-
>  19 files changed, 1863 insertions(+), 169 deletions(-)
>  create mode 100644 arch/arm/cpu/armv8/sysinfo.c
>  create mode 100644 arch/arm/dts/smbios_generic.dtsi
>  create mode 100644 include/smbios_def.h
>  create mode 100644 include/smbios_plat.h
>
> --
> 2.25.1
>

I'm going to leave this series to you and Ilias as I don't really
support bringing all this SMBIOS info in, just so we can run ACPI on
ARM. Please just avoid code-size increase and breaking any x86
platforms.

Regards

Simon
Ilias Apalodimas Dec. 16, 2024, 3:43 p.m. UTC | #2
Hi Simon,

On Mon, 16 Dec 2024 at 17:16, Simon Glass <sjg@chromium.org> wrote:
>
> Hi Raymond,
>
> On Fri, 6 Dec 2024 at 15:54, Raymond Mao <raymond.mao@linaro.org> wrote:
> >
> > Motivations for changes:
> > Current SMBIOS library and command-line tool is not fully matching with
> > the requirements:
> > 1. Missing support for other mandatory types (#7, #9, #16, #17, #19).
> > 2. Only a few platforms support SMBIOS node from the device tree.
> > 3. Values of some fields are hardcoded in the library other than fetching
> >    from the device hardware.
> > 4. Embedded data with dynamic length is not supported (E.g. Contained
> >    Object Handles in Type #2 and Contained Elements in Type #3)
> >
> > Changes:
> > 1. Refactor the SMBIOS library and command-line tool to better align with
> >    the SMBIOS spec.
> > 2. Create an arch-specific driver for all aarch64-based platforms to fetch
> >    SMBIOS private data from the device hardware (processor and cache).
> > 3. Create a sysinfo driver to poppulate platform SMBIOS private data.
> > 4. Add generic SMBIOS DTS file for arm64 platforms for those common strings
> >    and values which cannot be retrieved from the system registers.
> >    Vendors can create their own SMBIOS node using this as an example.
> >    For those boards without SMBIOS nodes, this DTS file can be included to
> >    have a generic SMBIOS information of the system.
> > 5. Add support for Type #7 (Cache Information) and link its handles to
> >    Type #4.
> > 6. To minimize size-growth for those platforms which have not sufficient
> >    ROM spaces or the platforms which don't need detailed SMBIOS
> >    information, new added fields are only being built when kconfig
> >    GENERATE_SMBIOS_TABLE_VERBOSE is selected.
> >
> > Once this patch is acceptted, subsequent patch sets will add other missing
> > types (#9, #16, #17, #19).
> >
> > Tests:
> > To test this with QEMU arm64, please follow the guide on dt_qemu.rst to
> > get a merged DT to run with.
> > ```
> > qemu-system-aarch64 -machine virt -machine dumpdtb=qemu.dtb
> > cat  <(dtc -I dtb qemu.dtb) <(dtc -I dtb ./dts/dt.dtb | grep -v /dts-v1/) \
> >   | dtc - -o merged.dtb
> > qemu-system-aarch64 -machine virt -nographic -bios u-boot.bin \
> >   -dtb merged.dtb
> > ```
> >
> > Raymond Mao (10):
> >   smbios: Refactor the smbios headfile
> >   sysinfo: Add sysinfo API for accessing data area
> >   test/dm: add sandbox test for sysinfo_get_data
> >   sysinfo: Add sysinfo driver and data structure for smbios
> >   smbios: Refactor smbios library
> >   smbios: add detailed smbios information
> >   armv8: Add arch-specific sysinfo platform driver
> >   armv8: Add generic smbios information into the device tree
> >   cmd: update smbios cmd
> >   configs: Enable sysinfo for QEMU Arm64
> >
> >  arch/arm/cpu/armv8/Makefile      |   2 +
> >  arch/arm/cpu/armv8/sysinfo.c     | 292 ++++++++++++++++++++
> >  arch/arm/dts/qemu-arm64.dts      |   4 +
> >  arch/arm/dts/smbios_generic.dtsi |  82 ++++++
> >  cmd/smbios.c                     | 348 +++++++++++++++++++++---
> >  configs/qemu_arm64_defconfig     |   3 +
> >  drivers/misc/Kconfig             |   2 +-
> >  drivers/sysinfo/sandbox.c        |  19 ++
> >  drivers/sysinfo/sandbox.h        |   1 +
> >  drivers/sysinfo/smbios.c         | 228 ++++++++++++++++
> >  drivers/sysinfo/sysinfo-uclass.c |  20 ++
> >  include/smbios.h                 | 158 ++++++-----
> >  include/smbios_def.h             | 194 ++++++++++++++
> >  include/smbios_plat.h            |  79 ++++++
> >  include/sysinfo.h                | 125 ++++++++-
> >  lib/Kconfig                      |   6 +
> >  lib/smbios.c                     | 445 ++++++++++++++++++++++++++-----
> >  test/dm/sysinfo.c                |   6 +
> >  test/py/tests/test_smbios.py     |  18 +-
> >  19 files changed, 1863 insertions(+), 169 deletions(-)
> >  create mode 100644 arch/arm/cpu/armv8/sysinfo.c
> >  create mode 100644 arch/arm/dts/smbios_generic.dtsi
> >  create mode 100644 include/smbios_def.h
> >  create mode 100644 include/smbios_plat.h
> >
> > --
> > 2.25.1
> >
>
> I'm going to leave this series to you and Ilias as I don't really
> support bringing all this SMBIOS info in, just so we can run ACPI on
> ARM.

I don't think the current patchset has anything to do with ACPI. I do
not like revising SMBIOS any more than you do but....
With systemready etc, we are now easily booting distros. Distros rely
on smbios tooling for some of their bug reports, so we are just trying
to make their lives easier. I hope that we can completely disable it
when distros move forward

Since Peter used to work for a distro, he can fill up anything I've missed


Thanks
/Ilias

> Please just avoid code-size increase and breaking any x86
> platforms.
>
> Regards
>
> Simon
Simon Glass Dec. 19, 2024, 3:08 p.m. UTC | #3
Hi Ilias,

On Mon, 16 Dec 2024 at 08:43, Ilias Apalodimas
<ilias.apalodimas@linaro.org> wrote:
>
> Hi Simon,
>
> On Mon, 16 Dec 2024 at 17:16, Simon Glass <sjg@chromium.org> wrote:
> >
> > Hi Raymond,
> >
> > On Fri, 6 Dec 2024 at 15:54, Raymond Mao <raymond.mao@linaro.org> wrote:
> > >
> > > Motivations for changes:
> > > Current SMBIOS library and command-line tool is not fully matching with
> > > the requirements:
> > > 1. Missing support for other mandatory types (#7, #9, #16, #17, #19).
> > > 2. Only a few platforms support SMBIOS node from the device tree.
> > > 3. Values of some fields are hardcoded in the library other than fetching
> > >    from the device hardware.
> > > 4. Embedded data with dynamic length is not supported (E.g. Contained
> > >    Object Handles in Type #2 and Contained Elements in Type #3)
> > >
> > > Changes:
> > > 1. Refactor the SMBIOS library and command-line tool to better align with
> > >    the SMBIOS spec.
> > > 2. Create an arch-specific driver for all aarch64-based platforms to fetch
> > >    SMBIOS private data from the device hardware (processor and cache).
> > > 3. Create a sysinfo driver to poppulate platform SMBIOS private data.
> > > 4. Add generic SMBIOS DTS file for arm64 platforms for those common strings
> > >    and values which cannot be retrieved from the system registers.
> > >    Vendors can create their own SMBIOS node using this as an example.
> > >    For those boards without SMBIOS nodes, this DTS file can be included to
> > >    have a generic SMBIOS information of the system.
> > > 5. Add support for Type #7 (Cache Information) and link its handles to
> > >    Type #4.
> > > 6. To minimize size-growth for those platforms which have not sufficient
> > >    ROM spaces or the platforms which don't need detailed SMBIOS
> > >    information, new added fields are only being built when kconfig
> > >    GENERATE_SMBIOS_TABLE_VERBOSE is selected.
> > >
> > > Once this patch is acceptted, subsequent patch sets will add other missing
> > > types (#9, #16, #17, #19).
> > >
> > > Tests:
> > > To test this with QEMU arm64, please follow the guide on dt_qemu.rst to
> > > get a merged DT to run with.
> > > ```
> > > qemu-system-aarch64 -machine virt -machine dumpdtb=qemu.dtb
> > > cat  <(dtc -I dtb qemu.dtb) <(dtc -I dtb ./dts/dt.dtb | grep -v /dts-v1/) \
> > >   | dtc - -o merged.dtb
> > > qemu-system-aarch64 -machine virt -nographic -bios u-boot.bin \
> > >   -dtb merged.dtb
> > > ```
> > >
> > > Raymond Mao (10):
> > >   smbios: Refactor the smbios headfile
> > >   sysinfo: Add sysinfo API for accessing data area
> > >   test/dm: add sandbox test for sysinfo_get_data
> > >   sysinfo: Add sysinfo driver and data structure for smbios
> > >   smbios: Refactor smbios library
> > >   smbios: add detailed smbios information
> > >   armv8: Add arch-specific sysinfo platform driver
> > >   armv8: Add generic smbios information into the device tree
> > >   cmd: update smbios cmd
> > >   configs: Enable sysinfo for QEMU Arm64
> > >
> > >  arch/arm/cpu/armv8/Makefile      |   2 +
> > >  arch/arm/cpu/armv8/sysinfo.c     | 292 ++++++++++++++++++++
> > >  arch/arm/dts/qemu-arm64.dts      |   4 +
> > >  arch/arm/dts/smbios_generic.dtsi |  82 ++++++
> > >  cmd/smbios.c                     | 348 +++++++++++++++++++++---
> > >  configs/qemu_arm64_defconfig     |   3 +
> > >  drivers/misc/Kconfig             |   2 +-
> > >  drivers/sysinfo/sandbox.c        |  19 ++
> > >  drivers/sysinfo/sandbox.h        |   1 +
> > >  drivers/sysinfo/smbios.c         | 228 ++++++++++++++++
> > >  drivers/sysinfo/sysinfo-uclass.c |  20 ++
> > >  include/smbios.h                 | 158 ++++++-----
> > >  include/smbios_def.h             | 194 ++++++++++++++
> > >  include/smbios_plat.h            |  79 ++++++
> > >  include/sysinfo.h                | 125 ++++++++-
> > >  lib/Kconfig                      |   6 +
> > >  lib/smbios.c                     | 445 ++++++++++++++++++++++++++-----
> > >  test/dm/sysinfo.c                |   6 +
> > >  test/py/tests/test_smbios.py     |  18 +-
> > >  19 files changed, 1863 insertions(+), 169 deletions(-)
> > >  create mode 100644 arch/arm/cpu/armv8/sysinfo.c
> > >  create mode 100644 arch/arm/dts/smbios_generic.dtsi
> > >  create mode 100644 include/smbios_def.h
> > >  create mode 100644 include/smbios_plat.h
> > >
> > > --
> > > 2.25.1
> > >
> >
> > I'm going to leave this series to you and Ilias as I don't really
> > support bringing all this SMBIOS info in, just so we can run ACPI on
> > ARM.
>
> I don't think the current patchset has anything to do with ACPI. I do
> not like revising SMBIOS any more than you do but....
> With systemready etc, we are now easily booting distros. Distros rely
> on smbios tooling for some of their bug reports, so we are just trying
> to make their lives easier. I hope that we can completely disable it
> when distros move forward
>
> Since Peter used to work for a distro, he can fill up anything I've missed

If you would like to move on from legacy stuff, I advise you to do it
in baby steps. A good time to break free is when you find yourself
implementing something to 'just make things easier for the existing
programs, etc.' Failing that, $10 says SMBIOS becomes entrenched on
ARM.

> > Please just avoid code-size increase and breaking any x86
> > platforms.

Regards,
Simon
Tom Rini Jan. 14, 2025, 9:29 p.m. UTC | #4
On Fri, 06 Dec 2024 14:54:17 -0800, Raymond Mao wrote:

> Motivations for changes:
> Current SMBIOS library and command-line tool is not fully matching with
> the requirements:
> 1. Missing support for other mandatory types (#7, #9, #16, #17, #19).
> 2. Only a few platforms support SMBIOS node from the device tree.
> 3. Values of some fields are hardcoded in the library other than fetching
>    from the device hardware.
> 4. Embedded data with dynamic length is not supported (E.g. Contained
>    Object Handles in Type #2 and Contained Elements in Type #3)
> 
> [...]

Applied to u-boot/master, thanks!