[PATCH 0/2] smbios: riscv: set correct SMBIOS processor family value

Many value of processor type exceed 0xff and have to be stored as u16 value. In the type 4 table set processor_family = 0xfe signaling that field processor_family2 is used and write the actual value into the processor_family2 field.
The values for RISC-V are:
* 0x200 for 32-bit * 0x201 for 64-bit
With this series dmidecode shows
Handle 0x0004, DMI type 4, 48 bytes Processor Information Socket Designation: Not Specified Type: Central Processor Family: RV64
for qemu-riscv64_smode_defconfig.
Heinrich Schuchardt (2): smbios: enable setting processor family > 0xff cpu: riscv: set correct SMBIOS processor family value
drivers/cpu/riscv_cpu.c | 4 ++++ lib/smbios.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-)

Many value of processor type exceed 0xff and have to be stored as u16 value. In the type 4 table set processor_family = 0xfe signaling that field processor_family2 is used and write the actual value into the processor_family2 field.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com --- lib/smbios.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/smbios.c b/lib/smbios.c index 45480b01af..550b2471f9 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -467,7 +467,8 @@ static void smbios_write_type4_dm(struct smbios_type4 *t, } #endif
- t->processor_family = processor_family; + t->processor_family = 0xfe; + t->processor_family2 = processor_family; t->processor_manufacturer = smbios_add_prop(ctx, NULL, vendor); t->processor_version = smbios_add_prop(ctx, NULL, name); } @@ -489,7 +490,6 @@ static int smbios_write_type4(ulong *current, int handle, t->l1_cache_handle = 0xffff; t->l2_cache_handle = 0xffff; t->l3_cache_handle = 0xffff; - t->processor_family2 = t->processor_family;
len = t->length + smbios_string_table_len(ctx); *current += len;

Hi Heinrich,
On Thu, Dec 28, 2023 at 7:30 AM Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
Many value of processor type exceed 0xff and have to be stored as u16 value. In the type 4 table set processor_family = 0xfe signaling that field processor_family2 is used and write the actual value into the processor_family2 field.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
lib/smbios.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
diff --git a/lib/smbios.c b/lib/smbios.c index 45480b01af..550b2471f9 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -467,7 +467,8 @@ static void smbios_write_type4_dm(struct smbios_type4 *t, } #endif
t->processor_family = processor_family;
t->processor_family = 0xfe;
t->processor_family2 = processor_family;
Why not use 'family' if it fits?
t->processor_manufacturer = smbios_add_prop(ctx, NULL, vendor); t->processor_version = smbios_add_prop(ctx, NULL, name);
} @@ -489,7 +490,6 @@ static int smbios_write_type4(ulong *current, int handle, t->l1_cache_handle = 0xffff; t->l2_cache_handle = 0xffff; t->l3_cache_handle = 0xffff;
t->processor_family2 = t->processor_family; len = t->length + smbios_string_table_len(ctx); *current += len;
-- 2.43.0
Regards, Simon

On 12/28/23 14:37, Simon Glass wrote:
Hi Heinrich,
On Thu, Dec 28, 2023 at 7:30 AM Heinrich Schuchardt heinrich.schuchardt@canonical.com wrote:
Many value of processor type exceed 0xff and have to be stored as u16 value. In the type 4 table set processor_family = 0xfe signaling that field processor_family2 is used and write the actual value into the processor_family2 field.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com
lib/smbios.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
diff --git a/lib/smbios.c b/lib/smbios.c index 45480b01af..550b2471f9 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -467,7 +467,8 @@ static void smbios_write_type4_dm(struct smbios_type4 *t, } #endif
t->processor_family = processor_family;
t->processor_family = 0xfe;
t->processor_family2 = processor_family;
Why not use 'family' if it fits?
Using family for values less then 0x100 is allowable. But there would be no benefit in making our code more complicated.
Best regards
Heinrich
t->processor_manufacturer = smbios_add_prop(ctx, NULL, vendor); t->processor_version = smbios_add_prop(ctx, NULL, name);
} @@ -489,7 +490,6 @@ static int smbios_write_type4(ulong *current, int handle, t->l1_cache_handle = 0xffff; t->l2_cache_handle = 0xffff; t->l3_cache_handle = 0xffff;
t->processor_family2 = t->processor_family; len = t->length + smbios_string_table_len(ctx); *current += len;
-- 2.43.0
Regards, Simon

The SMBIOS specification requires to set the processor family in the type 4 (Processor Information) table to specific values depending only on the bitness of the system (0x200 for RV32 and 0x201 for RV64).
With this patch dmidecode shows
Handle 0x0004, DMI type 4, 48 bytes Processor Information Socket Designation: Not Specified Type: Central Processor Family: RV64
for qemu-riscv64_smode_defconfig.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com --- drivers/cpu/riscv_cpu.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/drivers/cpu/riscv_cpu.c b/drivers/cpu/riscv_cpu.c index d6484d7f4b..034b9b49c0 100644 --- a/drivers/cpu/riscv_cpu.c +++ b/drivers/cpu/riscv_cpu.c @@ -98,6 +98,10 @@ static int riscv_cpu_bind(struct udevice *dev)
/* save the hart id */ plat->cpu_id = dev_read_addr(dev); + if (IS_ENABLED(CONFIG_64BIT)) + plat->family = 0x201; + else + plat->family = 0x200; /* first examine the property in current cpu node */ ret = dev_read_u32(dev, "timebase-frequency", &plat->timebase_freq); /* if not found, then look at the parent /cpus node */
participants (2)
-
Heinrich Schuchardt
-
Simon Glass