Reland "x86: Move FACP table into separate functions""
Subsystems (3)
PATCH 1/2 Reland "x86: Move FACP table into separate functions""
Each board has its own way of creating this table. Rather than calling the acpi_create_fadt() function for each one from a common acpi_write_fadt() function, just move the writer into the board-specific code.
---
Make another attempt to land this. It apparently breaks Edison but I cannot test that board, nor can I work out what is wrong with the code.
Previous test report is here:
https://lore.kernel.org/all/[email protected]/
Looking at the image, the method is definitely present:
$ nm /tmp/b/edison/u-boot |grep acpi_writer 0115fde0 D _u_boot_list_2_acpi_writer_2_0base 0115fdf0 D _u_boot_list_2_acpi_writer_2_1facs 0115fe00 D _u_boot_list_2_acpi_writer_2_3dsdt 0115fe10 D _u_boot_list_2_acpi_writer_2_4gnvs 0115fe20 D _u_boot_list_2_acpi_writer_2_5csrt 0115fe30 D _u_boot_list_2_acpi_writer_2_5fadt 0115fe40 D _u_boot_list_2_acpi_writer_2_5mcfg 0115fe50 D _u_boot_list_2_acpi_writer_2_5spcr 0115fe60 D _u_boot_list_2_acpi_writer_2_5tcpa 0115fe70 D _u_boot_list_2_acpi_writer_2_5tpm2 0115fe80 D _u_boot_list_2_acpi_writer_2_5x86 0115fe90 D _u_boot_list_2_acpi_writer_2_6ssdt 0115fea0 D _u_boot_list_2_acpi_writer_2_8dev
I wonder if the code in quark_write_fadt() is not being called?
'acpi list' shows what tables are installed. On minnowmax there is no difference with or without this patch. Perhaps someone with sharper eyes than me can figure this out?
The mechanism is that the functions to be called are put in a linker list, each element being declared using ACPI_WRITER(function_name).
Then acpi_write_all() is called to write each one. Debugging could be added to that function, perhaps?
arch/x86/cpu/apollolake/acpi.c | 17 +++++++++++++---- arch/x86/cpu/baytrail/acpi.c | 27 +++++++++++++++++++-------- arch/x86/cpu/quark/acpi.c | 27 +++++++++++++++++++-------- arch/x86/cpu/tangier/acpi.c | 25 +++++++++++++++++-------- arch/x86/include/asm/acpi_table.h | 2 -- arch/x86/lib/acpi_table.c | 15 --------------- 6 files changed, 68 insertions(+), 45 deletions(-)
arch/x86/cpu/apollolake/acpi.c +13 -4
@@ -146,16 +146,25 @@ void fill_fadt(struct acpi_fadt *fadt) fadt->x_pm_tmr_blk.addrl =IOMAP_ACPI_BASE +PM1_TMR ; } -void acpi_create_fadt (struct acpi_fadt *fadt,struct acpi_facs *facs, -void *dsdt) +static int apl_write_fadt (struct acpi_ctx *ctx,const struct acpi_writer *entry) { -struct acpi_table_header *header = &fadt->header; +struct acpi_table_header *header; +struct acpi_fadt *fadt; -acpi_fadt_common (fadt, facs, dsdt); + fadt = ctx->current; +acpi_fadt_common (fadt, ctx->facs, ctx->dsdt);intel_acpi_fill_fadt (fadt);fill_fadt (fadt); + header = &fadt->header; header->checksum =table_compute_checksum (fadt, header->length); + +acpi_add_table (ctx, fadt); + +acpi_inc (ctx,sizeof (struct acpi_fadt )); + +return 0 ; } +ACPI_WRITER(5fadt, "FADT", apl_write_fadt, 0);int apl_acpi_fill_dmar (struct acpi_ctx *ctx) {
arch/x86/cpu/baytrail/acpi.c +19 -8
@@ -15,20 +15,24 @@#include <asm/arch/iomap.h> #include <dm/uclass-internal.h> -void acpi_create_fadt (struct acpi_fadt *fadt,struct acpi_facs *facs, -void *dsdt) +static int baytrail_write_fadt (struct acpi_ctx *ctx, +const struct acpi_writer *entry) { -struct acpi_table_header *header = &(fadt->header); +struct acpi_table_header *header; +struct acpi_fadt *fadt; + + fadt = ctx->current; + header = &fadt->header;u16 pmbase =ACPI_BASE_ADDRESS ; -memset ((void *)fadt,0 ,sizeof (struct acpi_fadt )); +memset (fadt,'\0' ,sizeof (struct acpi_fadt ));acpi_fill_header (header,"FACP" ); header->length =sizeof (struct acpi_fadt ); header->revision =4 ; - fadt->firmware_ctrl = (u32 )facs; - fadt->dsdt = (u32 )dsdt; + fadt->firmware_ctrl = (u32 )ctx->facs; + fadt->dsdt = (u32 )ctx->dsdt; fadt->preferred_pm_profile =ACPI_PM_MOBILE ; fadt->sci_int =9 ; fadt->smi_cmd =0 ;
@@ -75,9 +79,9 @@ void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, fadt->reset_reg.addrh =0 ; fadt->reset_value =SYS_RST |RST_CPU |FULL_RST ; - fadt->x_firmware_ctl_l = (u32 )facs; + fadt->x_firmware_ctl_l = (u32 )ctx->facs; fadt->x_firmware_ctl_h =0 ; - fadt->x_dsdt_l = (u32 )dsdt; + fadt->x_dsdt_l = (u32 )ctx->dsdt; fadt->x_dsdt_h =0 ; fadt->x_pm1a_evt_blk.space_id =ACPI_ADDRESS_SPACE_IO ;
@@ -137,7 +141,14 @@ void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, fadt->x_gpe1_blk.addrh =0x0 ; header->checksum =table_compute_checksum (fadt, header->length); + +acpi_add_table (ctx, fadt); + +acpi_inc (ctx,sizeof (struct acpi_fadt )); + +return 0 ; } +ACPI_WRITER(5fadt, "FADT", baytrail_write_fadt, 0);int acpi_create_gnvs (struct acpi_global_nvs *gnvs) {
arch/x86/cpu/quark/acpi.c +19 -8
@@ -10,20 +10,24 @@#include <asm/arch/global_nvs.h> #include <asm/arch/iomap.h> -void acpi_create_fadt (struct acpi_fadt *fadt,struct acpi_facs *facs, -void *dsdt) +static int quark_write_fadt (struct acpi_ctx *ctx, +const struct acpi_writer *entry) { -struct acpi_table_header *header = &(fadt->header);u16 pmbase =ACPI_PM1_BASE_ADDRESS ; +struct acpi_table_header *header; +struct acpi_fadt *fadt; -memset ((void *)fadt,0 ,sizeof (struct acpi_fadt )); + fadt = ctx->current; + header = &fadt->header; + +memset (fadt,'\0' ,sizeof (struct acpi_fadt ));acpi_fill_header (header,"FACP" ); header->length =sizeof (struct acpi_fadt ); header->revision =4 ; - fadt->firmware_ctrl = (u32 )facs; - fadt->dsdt = (u32 )dsdt; + fadt->firmware_ctrl = (u32 )ctx->facs; + fadt->dsdt = (u32 )ctx->dsdt; fadt->preferred_pm_profile =ACPI_PM_UNSPECIFIED ; fadt->sci_int =9 ; fadt->smi_cmd =0 ;
@@ -70,9 +74,9 @@ void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, fadt->reset_reg.addrh =0 ; fadt->reset_value =SYS_RST |RST_CPU |FULL_RST ; - fadt->x_firmware_ctl_l = (u32 )facs; + fadt->x_firmware_ctl_l = (u32 )ctx->facs; fadt->x_firmware_ctl_h =0 ; - fadt->x_dsdt_l = (u32 )dsdt; + fadt->x_dsdt_l = (u32 )ctx->dsdt; fadt->x_dsdt_h =0 ; fadt->x_pm1a_evt_blk.space_id =ACPI_ADDRESS_SPACE_IO ;
@@ -132,7 +136,14 @@ void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, fadt->x_gpe1_blk.addrh =0x0 ; header->checksum =table_compute_checksum (fadt, header->length); + +acpi_add_table (ctx, fadt); + +acpi_inc (ctx,sizeof (struct acpi_fadt )); + +return 0 ; } +ACPI_WRITER(5fadt, "FADT", quark_write_fadt, 0);int acpi_create_gnvs (struct acpi_global_nvs *gnvs) {
arch/x86/cpu/tangier/acpi.c +17 -8
@@ -16,19 +16,23 @@#include <asm/arch/iomap.h> #include <dm/uclass-internal.h> -void acpi_create_fadt (struct acpi_fadt *fadt,struct acpi_facs *facs, -void *dsdt) +static int tangier_write_fadt (struct acpi_ctx *ctx, +const struct acpi_writer *entry) { -struct acpi_table_header *header = &(fadt->header); +struct acpi_table_header *header; +struct acpi_fadt *fadt; -memset ((void *)fadt,0 ,sizeof (struct acpi_fadt )); + fadt = ctx->current; + header = &fadt->header; + +memset (fadt,'\0' ,sizeof (struct acpi_fadt ));acpi_fill_header (header,"FACP" ); header->length =sizeof (struct acpi_fadt ); header->revision =6 ; - fadt->firmware_ctrl = (u32 )facs; - fadt->dsdt = (u32 )dsdt; + fadt->firmware_ctrl = (u32 )ctx->facs; + fadt->dsdt = (u32 )ctx->dsdt; fadt->preferred_pm_profile =ACPI_PM_UNSPECIFIED ; fadt->iapc_boot_arch = ACPI_FADT_VGA_NOT_PRESENT |
@@ -41,13 +45,18 @@ void acpi_create_fadt(struct acpi_fadt *fadt, struct acpi_facs *facs, fadt->minor_revision =2 ; - fadt->x_firmware_ctl_l = (u32 )facs; + fadt->x_firmware_ctl_l = (u32 )ctx->facs; fadt->x_firmware_ctl_h =0 ; - fadt->x_dsdt_l = (u32 )dsdt; + fadt->x_dsdt_l = (u32 )ctx->dsdt; fadt->x_dsdt_h =0 ; header->checksum =table_compute_checksum (fadt, header->length); + +acpi_inc (ctx,sizeof (struct acpi_fadt )); + +return 0 ; } +ACPI_WRITER(5fadt, "FADT", tangier_write_fadt, 0);u32 acpi_fill_madt (u32 current) {
arch/x86/include/asm/acpi_table.h +0 -2
@@ -24,8 +24,6 @@ struct acpi_table_header;/* These can be used by the target port */ -void acpi_create_fadt (struct acpi_fadt *fadt,struct acpi_facs *facs, -void *dsdt);int acpi_create_madt_lapics (u32 current);int acpi_create_madt_ioapic (struct acpi_madt_ioapic *ioapic,u8 id,u32 addr,u32 gsi_base);
arch/x86/lib/acpi_table.c +0 -15
@@ -458,21 +458,6 @@ int acpi_write_gnvs(struct acpi_ctx *ctx, const struct acpi_writer *entry) } ACPI_WRITER(4gnvs, "GNVS", acpi_write_gnvs, 0); -static int acpi_write_fadt (struct acpi_ctx *ctx, -const struct acpi_writer *entry) -{ -struct acpi_fadt *fadt; - - fadt = ctx->current; -acpi_create_fadt (fadt, ctx->facs, ctx->dsdt); -acpi_add_table (ctx, fadt); - -acpi_inc (ctx,sizeof (struct acpi_fadt )); - -return 0 ; -} -ACPI_WRITER(5fact, "FADT", acpi_write_fadt, 0); -/** * acpi_write_hpet() - Write out a HPET table *
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
PATCH 2/2 RFC: x86: acpi: Add some debugging
Enable some debugging to help see what is going on.
---
arch/x86/lib/tables.c | 1 + lib/acpi/acpi_writer.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-)
arch/x86/lib/tables.c +1 -0
@@ -3,6 +3,7 @@* Copyright (C) 2015, Bin Meng <[email protected]> */ +#define LOG_DEBUG #define LOG_CATEGORY LOGC_ACPI#include <common.h>
lib/acpi/acpi_writer.c +7 -2
@@ -5,6 +5,7 @@* Copyright 2021 Google LLC */ +#define LOG_DEBUG #define LOG_CATEGORY LOGC_ACPI#include <common.h>
@@ -21,8 +22,8 @@ int acpi_write_one(struct acpi_ctx *ctx, const struct acpi_writer *entry) {int ret; -log_debug ("%s: writing table '%s'\n" , entry->name, - entry->table); +log_debug ("%s: writing table '%s' at %p\n" , entry->name, + entry->table, ctx->current); ctx->tab_start = ctx->current; ret = entry->h_write (ctx, entry);if (ret == -ENOENT ) {
@@ -57,11 +58,15 @@ static int acpi_write_all(struct acpi_ctx *ctx)const struct acpi_writer *entry;int ret; +log_debug ("writing acpi tables\n" ); +for (entry = writer; entry != writer + n_ents; entry++) { ret =acpi_write_one (ctx, entry); +log_debug ("- return code %d\n" , ret);if (ret && ret != -ENOENT )return log_msg_ret ("one" , ret); } +log_debug ("writing acpi tables done ok\n" );return 0 ; }
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
Quoted 3 lines · Simon Glass
Each board has its own way of creating this table. Rather than calling the
acpi_create_fadt()function for each one from a commonacpi_write_fadt()function, just move the writer into the board-specific code.
No luck, but I have a bit of time to debug more.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Simon Glass
Each board has its own way of creating this table. Rather than calling the
acpi_create_fadt()function for each one from a commonacpi_write_fadt()function, just move the writer into the board-specific code.No luck, but I have a bit of time to debug more.
U-boot:
Writing tables to e4500:
ACPI: Writing ACPI tables at e4500 writing acpi tables
0base: writing table '<NULL>' at 000e4500
- return code 0
1facs: writing table 'FACS' at 000e4740
- return code 0
3dsdt: writing table 'DSDT' at 000e4780
- return code 0
4gnvs: writing table 'GNVS' at 000e5390
- return code 0
5csrt: writing table 'CSRT' at 000e5490
- return code 0
5fadt: writing table 'FADT' at 000e54f0
- return code 0
5mcfg: writing table 'MCFG' at 000e5610
- return code 0
5spcr: writing table 'SPCR' at 000e5650
- return code 0
5tcpa: writing table 'TCPA' at 000e56a0 5tcpa: Omitted due to being empty
- return code 0
5tpm2: writing table 'TPM2' at 000e56a0 5tpm2: Omitted due to being empty
- return code 0
5x86: writing table '<NULL>' at 000e56a0
- return code 0
6ssdt: writing table 'SSDT' at 000e56f0 6ssdt: Omitted due to being empty
- return code 0
8dev: writing table '<NULL>' at 000e56f0
- return code 0
writing acpi tables done ok
ACPI current = e56f0
- wrote 'acpi' to e4500, end e56f0
- wrote 'smbios' to e56f0, end e584f
- done writing tables
Linux:
[ 0.003034] ACPI: RSDP 0x00000000000E4500 000024 (v02 U-BOOT) [ 0.003090] ACPI: XSDT 0x00000000000E45E0 000044 (v01 U-BOOT U-BOOTBL 20231001 INTL 00000000) [ 0.003158] ACPI: CSRT 0x00000000000E5490 000058 (v00 U-BOOT U-BOOTBL 20231001 INTL 00000000) [ 0.003219] ACPI: MCFG 0x00000000000E5610 00003C (v01 U-BOOT U-BOOTBL 20231001 INTL 00000000) [ 0.003277] ACPI: SPCR 0x00000000000E5650 000050 (v02 U-BOOT U-BOOTBL 20231001 INTL 00000000) [ 0.003332] ACPI: APIC 0x00000000000E56A0 000048 (v02 U-BOOT U-BOOTBL 20231001 INTL 00000000) [ 0.003382] ACPI: Reserving CSRT table memory at [mem 0xe5490-0xe54e7] [ 0.003403] ACPI: Reserving MCFG table memory at [mem 0xe5610-0xe564b] [ 0.003421] ACPI: Reserving SPCR table memory at [mem 0xe5650-0xe569f] [ 0.003437] ACPI: Reserving APIC table memory at [mem 0xe56a0-0xe56e7]
As you can see a few tables are missing:
FACS, DSDT, GNVS, FADT
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 61 lines · Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Simon Glass
Each board has its own way of creating this table. Rather than calling the
acpi_create_fadt()function for each one from a commonacpi_write_fadt()function, just move the writer into the board-specific code.No luck, but I have a bit of time to debug more.
U-boot:
Writing tables to e4500:
ACPI: Writing ACPI tables at e4500 writing acpi tables
0base: writing table '<NULL>' at000e4500
- return code 0
1facs: writing table 'FACS' at000e4740
- return code 0
3dsdt: writing table 'DSDT' at000e4780
- return code 0
4gnvs: writing table 'GNVS' at000e5390
- return code 0
5csrt: writing table 'CSRT' at000e5490
- return code 0
5fadt: writing table 'FADT' at000e54f0
- return code 0
5mcfg: writing table 'MCFG' at000e5610
- return code 0
5spcr: writing table 'SPCR' at000e5650
- return code 0
5tcpa: writing table 'TCPA' at000e56a05tcpa: Omitted due to being empty
- return code 0
5tpm2: writing table 'TPM2' at000e56a05tpm2: Omitted due to being empty
- return code 0
5x86: writing table '<NULL>' at000e56a0
- return code 0
6ssdt: writing table 'SSDT' at000e56f06ssdt: Omitted due to being empty
- return code 0
8dev: writing table '<NULL>' at000e56f0
- return code 0
writing acpi tables done ok
ACPI current = e56f0
- wrote 'acpi' to e4500, end e56f0
- wrote 'smbios' to e56f0, end e584f
- done writing tablesLinux:
[ 0.003034] ACPI: RSDP 0x00000000000E4500 000024 (v02 U-BOOT) [ 0.003090] ACPI: XSDT 0x00000000000E45E0 000044 (v01 U-BOOT U-BOOTBL 20231001 INTL 00000000) [ 0.003158] ACPI: CSRT 0x00000000000E5490 000058 (v00 U-BOOT U-BOOTBL 20231001 INTL 00000000) [ 0.003219] ACPI: MCFG 0x00000000000E5610 00003C (v01 U-BOOT U-BOOTBL 20231001 INTL 00000000) [ 0.003277] ACPI: SPCR 0x00000000000E5650 000050 (v02 U-BOOT U-BOOTBL 20231001 INTL 00000000) [ 0.003332] ACPI: APIC 0x00000000000E56A0 000048 (v02 U-BOOT U-BOOTBL 20231001 INTL 00000000) [ 0.003382] ACPI: Reserving CSRT table memory at [mem 0xe5490-0xe54e7] [ 0.003403] ACPI: Reserving MCFG table memory at [mem 0xe5610-0xe564b] [ 0.003421] ACPI: Reserving SPCR table memory at [mem 0xe5650-0xe569f] [ 0.003437] ACPI: Reserving APIC table memory at [mem 0xe56a0-0xe56e7]
Quoted 2 lines
As you can see a few tables are missing:
FACS, DSDT, GNVS, FADT
I added a debug to the ACPI writer, so with your patch
Writing tables to e4500:
ACPI: Writing ACPI tables at e4500
writing acpi tables
0base: writing table '<NULL>' at 000e4500
* other: Added type 3, 000e4500, size 240
- return code 0
1facs: writing table 'FACS' at 000e4740
* other: Added type 3, 000e4740, size 40
- return code 0
3dsdt: writing table 'DSDT' at 000e4780
Writing DSDT tables
Writing DSDT finished, err=0
Failed to find ordering, leaving as is
* other: Added type 3, 000e4780, size c10
- return code 0
4gnvs: writing table 'GNVS' at 000e5390
* other: Added type 3, 000e5390, size 100
- return code 0
5csrt: writing table 'CSRT' at 000e5490
* other: Added type 3, 000e5490, size 60
- return code 0
5fadt: writing table 'FADT' at 000e54f0
* other: Added type 3, 000e54f0, size 120
- return code 0
5mcfg: writing table 'MCFG' at 000e5610
* other: Added type 3, 000e5610, size 40
- return code 0
5spcr: writing table 'SPCR' at 000e5650
* other: Added type 3, 000e5650, size 50
- return code 0
5tcpa: writing table 'TCPA' at 000e56a0
5tcpa: Omitted due to being empty
- return code 0
5tpm2: writing table 'TPM2' at 000e56a0
5tpm2: Omitted due to being empty
- return code 0
5x86: writing table '<NULL>' at 000e56a0
* other: Added type 3, 000e56a0, size 50
- return code 0
6ssdt: writing table 'SSDT' at 000e56f0
Writing SSDT tables
Writing SSDT finished, err=0
Failed to find ordering, leaving as is
6ssdt: Omitted due to being empty
- return code 0
8dev: writing table '<NULL>' at 000e56f0
Writing device tables
Writing finished, err=0
- return code 0
writing acpi tables done ok
ACPI current = e56f0
- wrote 'acpi' to e4500, end e56f0
- wrote 'smbios' to e56f0, end e584f
- done writing tables
Without your patch (to save your time:
there is no single character difference 100% copy):
Writing tables to e4500:
ACPI: Writing ACPI tables at e4500
writing acpi tables
0base: writing table '<NULL>' at 000e4500
* other: Added type 3, 000e4500, size 240
- return code 0
1facs: writing table 'FACS' at 000e4740
* other: Added type 3, 000e4740, size 40
- return code 0
3dsdt: writing table 'DSDT' at 000e4780
Writing DSDT tables
Writing DSDT finished, err=0
Failed to find ordering, leaving as is
* other: Added type 3, 000e4780, size c10
- return code 0
4gnvs: writing table 'GNVS' at 000e5390
* other: Added type 3, 000e5390, size 100
- return code 0
5csrt: writing table 'CSRT' at 000e5490
* other: Added type 3, 000e5490, size 60
- return code 0
5fact: writing table 'FADT' at 000e54f0
* other: Added type 3, 000e54f0, size 120
- return code 0
5mcfg: writing table 'MCFG' at 000e5610
* other: Added type 3, 000e5610, size 40
- return code 0
5spcr: writing table 'SPCR' at 000e5650
* other: Added type 3, 000e5650, size 50
- return code 0
5tcpa: writing table 'TCPA' at 000e56a0
5tcpa: Omitted due to being empty
- return code 0
5tpm2: writing table 'TPM2' at 000e56a0
5tpm2: Omitted due to being empty
- return code 0
5x86: writing table '<NULL>' at 000e56a0
* other: Added type 3, 000e56a0, size 50
- return code 0
6ssdt: writing table 'SSDT' at 000e56f0
Writing SSDT tables
Writing SSDT finished, err=0
Failed to find ordering, leaving as is
6ssdt: Omitted due to being empty
- return code 0
8dev: writing table '<NULL>' at 000e56f0
Writing device tables
Writing finished, err=0
- return code 0
writing acpi tables done ok
ACPI current = e56f0
- wrote 'acpi' to e4500, end e56f0
- wrote 'smbios' to e56f0, end e584f
- done writing tables
But here you see the difference. So, your patch damages something there. Since we lost a few tables, it might be that list of the table pointers is corrupted with your new approach. And current debug is poor enough to not catch that...
Linux:
[ 0.002557] ACPI: Early table checksum verification disabled [ 0.002582] ACPI: RSDP 0x00000000000E4500 000024 (v02 U-BOOT) [ 0.002637] ACPI: XSDT 0x00000000000E45E0 00004C (v01 U-BOOT U-BOOTBL 20231001 INTL 00000000) [ 0.002704] ACPI: CSRT 0x00000000000E5490 000058 (v00 U-BOOT U-BOOTBL 20231001 INTL 00000000) [ 0.002765] ACPI: FACP 0x00000000000E54F0 000114 (v06 U-BOOT U-BOOTBL 20231001 INTL 00000000) [ 0.002830] ACPI: DSDT 0x00000000000E4780 000C06 (v02 U-BOOT U-BOOTBL 00010000 INTL 20200925) [ 0.002889] ACPI: MCFG 0x00000000000E5610 00003C (v01 U-BOOT U-BOOTBL 20231001 INTL 00000000) [ 0.002945] ACPI: SPCR 0x00000000000E5650 000050 (v02 U-BOOT U-BOOTBL 20231001 INTL 00000000) [ 0.003000] ACPI: APIC 0x00000000000E56A0 000048 (v02 U-BOOT U-BOOTBL 20231001 INTL 00000000) [ 0.003049] ACPI: Reserving CSRT table memory at [mem 0xe5490-0xe54e7] [ 0.003070] ACPI: Reserving FACP table memory at [mem 0xe54f0-0xe5603] [ 0.003087] ACPI: Reserving DSDT table memory at [mem 0xe4780-0xe5385] [ 0.003103] ACPI: Reserving MCFG table memory at [mem 0xe5610-0xe564b] [ 0.003119] ACPI: Reserving SPCR table memory at [mem 0xe5650-0xe569f] [ 0.003135] ACPI: Reserving APIC table memory at [mem 0xe56a0-0xe56e7]
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Simon Glass
Each board has its own way of creating this table. Rather than calling the
acpi_create_fadt()function for each one from a commonacpi_write_fadt()function, just move the writer into the board-specific code.No luck, but I have a bit of time to debug more.
Okay, after your patch even U-Boot can't see those tables
=> acpi list
Name Base Size Detail ---- -------- ----- ------ RSDP 000e4500 24 v02 U-BOOT RSDT 000e4530 34 v01 U-BOOT U-BOOTBL 20231001 INTL 0 XSDT 000e45e0 44 v01 U-BOOT U-BOOTBL 20231001 INTL 0 CSRT 000e5490 58 v00 U-BOOT U-BOOTBL 20231001 INTL 0 MCFG 000e5610 3c v01 U-BOOT U-BOOTBL 20231001 INTL 0 SPCR 000e5650 50 v02 U-BOOT U-BOOTBL 20231001 INTL 0 APIC 000e56a0 48 v02 U-BOOT U-BOOTBL 20231001 INTL 0
Because the base is badly corrupted:
-00000030: 52 53 44 54 38 00 00 00 01 95 55 2d 42 4f 4f 54 RSDT8.....U-BOOT +00000030: 52 53 44 54 34 00 00 00 01 eb 55 2d 42 4f 4f 54 RSDT4.....U-BOOT
-00000050: 00 00 00 00 90 54 0e 00 f0 54 0e 00 10 56 0e 00 .....T...T...V.. +00000050: 00 00 00 00 90 54 0e 00 10 56 0e 00 50 56 0e 00 .....T...V..PV..
-00000060: 50 56 0e 00 a0 56 0e 00 00 00 00 00 00 00 00 00 PV...V.......... +00000060: a0 56 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 .V..............
-000000e0: 58 53 44 54 4c 00 00 00 01 7b 55 2d 42 4f 4f 54 XSDTL....{U-BOOT +000000e0: 58 53 44 54 44 00 00 00 01 d5 55 2d 42 4f 4f 54 XSDTD.....U-BOOT
-00000100: 00 00 00 00 90 54 0e 00 00 00 00 00 f0 54 0e 00 .....T.......T.. +00000100: 00 00 00 00 90 54 0e 00 00 00 00 00 10 56 0e 00 .....T.......V..
-00000110: 00 00 00 00 10 56 0e 00 00 00 00 00 50 56 0e 00 .....V......PV.. +00000110: 00 00 00 00 50 56 0e 00 00 00 00 00 a0 56 0e 00 ....PV.......V..
-00000120: 00 00 00 00 a0 56 0e 00 00 00 00 00 00 00 00 00 .....V.......... +00000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 21 lines · Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Simon Glass
Each board has its own way of creating this table. Rather than calling the
acpi_create_fadt()function for each one from a commonacpi_write_fadt()function, just move the writer into the board-specific code.No luck, but I have a bit of time to debug more.
Okay, after your patch even U-Boot can't see those tables
=> acpi list
Name Base Size Detail ---- -------- ----- ------ RSDP 000e4500 24 v02 U-BOOT RSDT 000e4530 34 v01 U-BOOT U-BOOTBL 20231001 INTL 0 XSDT 000e45e0 44 v01 U-BOOT U-BOOTBL 20231001 INTL 0 CSRT 000e5490 58 v00 U-BOOT U-BOOTBL 20231001 INTL 0 MCFG 000e5610 3c v01 U-BOOT U-BOOTBL 20231001 INTL 0 SPCR 000e5650 50 v02 U-BOOT U-BOOTBL 20231001 INTL 0 APIC 000e56a0 48 v02 U-BOOT U-BOOTBL 20231001 INTL 0
Quoted 4 lines
Because the base is badly corrupted:
-00000030: 52 53 44 54 38 00 00 00 01 95 55 2d 42 4f 4f 54 RSDT8.....U-BOOT +00000030: 52 53 44 54 34 00 00 00 01 eb 55 2d 42 4f 4f 54 RSDT4.....U-BOOT
Length -4 bytes, another checksum as a result.
Quoted 2 lines
-00000050: 00 00 00 00 90 54 0e 00 f0 54 0e 00 10 56 0e 00 .....T...T...V.. +00000050: 00 00 00 00 90 54 0e 00 10 56 0e 00 50 56 0e 00 .....T...V..PV..
Missing pointer to 0x0e54f0 which is... FADT!
Quoted 5 lines
-00000060: 50 56 0e 00 a0 56 0e 00 00 00 00 00 00 00 00 00 PV...V.......... +00000060: a0 56 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 .V..............
-000000e0: 58 53 44 54 4c 00 00 00 01 7b 55 2d 42 4f 4f 54 XSDTL....{U-BOOT +000000e0: 58 53 44 54 44 00 00 00 01 d5 55 2d 42 4f 4f 54 XSDTD.....U-BOOT
Wrong length, another checksum.
Quoted 8 lines
-00000100: 00 00 00 00 90 54 0e 00 00 00 00 00 f0 54 0e 00 .....T.......T.. +00000100: 00 00 00 00 90 54 0e 00 00 00 00 00 10 56 0e 00 .....T.......V..
-00000110: 00 00 00 00 10 56 0e 00 00 00 00 00 50 56 0e 00 .....V......PV.. +00000110: 00 00 00 00 50 56 0e 00 00 00 00 00 a0 56 0e 00 ....PV.......V..
-00000120: 00 00 00 00 a0 56 0e 00 00 00 00 00 00 00 00 00 .....V.......... +00000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Same reason. So, your code forgot to link FADT to the main tables.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 45 lines · Andy Shevchenko
Quoted 21 lines · Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Simon Glass
Each board has its own way of creating this table. Rather than calling the
acpi_create_fadt()function for each one from a commonacpi_write_fadt()function, just move the writer into the board-specific code.No luck, but I have a bit of time to debug more.
Okay, after your patch even U-Boot can't see those tables
=> acpi list
Name Base Size Detail ---- -------- ----- ------ RSDP 000e4500 24 v02 U-BOOT RSDT 000e4530 34 v01 U-BOOT U-BOOTBL 20231001 INTL 0 XSDT 000e45e0 44 v01 U-BOOT U-BOOTBL 20231001 INTL 0 CSRT 000e5490 58 v00 U-BOOT U-BOOTBL 20231001 INTL 0 MCFG 000e5610 3c v01 U-BOOT U-BOOTBL 20231001 INTL 0 SPCR 000e5650 50 v02 U-BOOT U-BOOTBL 20231001 INTL 0 APIC 000e56a0 48 v02 U-BOOT U-BOOTBL 20231001 INTL 0Quoted 4 lines
Because the base is badly corrupted:
-00000030: 52 53 44 54 38 00 00 00 01 95 55 2d 42 4f 4f 54 RSDT8.....U-BOOT +00000030: 52 53 44 54 34 00 00 00 01 eb 55 2d 42 4f 4f 54 RSDT4.....U-BOOT
Length -4 bytes, another checksum as a result.
Quoted 2 lines
-00000050: 00 00 00 00 90 54 0e 00 f0 54 0e 00 10 56 0e 00 .....T...T...V.. +00000050: 00 00 00 00 90 54 0e 00 10 56 0e 00 50 56 0e 00 .....T...V..PV..
Missing pointer to
0x0e54f0which is... FADT!Quoted 5 lines
-00000060: 50 56 0e 00 a0 56 0e 00 00 00 00 00 00 00 00 00 PV...V.......... +00000060: a0 56 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 .V..............
-000000e0: 58 53 44 54 4c 00 00 00 01 7b 55 2d 42 4f 4f 54 XSDTL....{U-BOOT +000000e0: 58 53 44 54 44 00 00 00 01 d5 55 2d 42 4f 4f 54 XSDTD.....U-BOOT
Wrong length, another checksum.
Quoted 3 lines
-00000100: 00 00 00 00 90 54 0e 00 00 00 00 00 f0 54 0e 00 .....T.......T.. +00000100: 00 00 00 00 90 54 0e 00 00 00 00 00 10 56 0e 00 .....T.......V..
Quoted 7 lines
Quoted 5 lines
-00000110: 00 00 00 00 10 56 0e 00 00 00 00 00 50 56 0e 00 .....V......PV.. +00000110: 00 00 00 00 50 56 0e 00 00 00 00 00 a0 56 0e 00 ....PV.......V..
-00000120: 00 00 00 00 a0 56 0e 00 00 00 00 00 00 00 00 00 .....V.......... +00000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Same reason. So, your code forgot to link FADT to the main tables.
By code analysis you simply missed
+ acpi_add_table(ctx, fadt);
I'm going to check this right now... Stay tuned!
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 1/2 TO BE FOLDED: x86: tangier: Add FADT to the chain
The Simon's patch missed the FADT to be added to the chain, hence all the issues on Intel Tangier.
--- arch/x86/cpu/tangier/acpi.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/cpu/tangier/acpi.c +2 -0
@@ -52,6 +52,8 @@ static int tangier_write_fadt(struct acpi_ctx *ctx, header->checksum =table_compute_checksum (fadt, header->length); +acpi_add_table (ctx, fadt); +acpi_inc (ctx,sizeof (struct acpi_fadt ));return 0 ;
Signature · 1 line
2.40.0.1.gaa8946217a0b
PATCH 2/2 x86: Prevent from missing the FADT chaining
Recent approach with FADT writer shows that there is a room for subtle errors. Prevent this from happening again by introducing acpi_add_fadt() helper.
--- arch/x86/cpu/apollolake/acpi.c | 6 +----- arch/x86/cpu/baytrail/acpi.c | 6 +----- arch/x86/cpu/quark/acpi.c | 6 +----- arch/x86/cpu/tangier/acpi.c | 6 +----- include/acpi/acpi_table.h | 7 +++++++ 5 files changed, 11 insertions(+), 20 deletions(-)
arch/x86/cpu/apollolake/acpi.c +1 -5
@@ -158,11 +158,7 @@ static int apl_write_fadt(struct acpi_ctx *ctx, const struct acpi_writer *entry) header = &fadt->header; header->checksum =table_compute_checksum (fadt, header->length); -acpi_add_table (ctx, fadt); - -acpi_inc (ctx,sizeof (struct acpi_fadt )); - -return 0 ; +return acpi_add_fadt (ctx, fadt); } ACPI_WRITER(5fadt, "FADT", apl_write_fadt, 0);
arch/x86/cpu/baytrail/acpi.c +1 -5
@@ -142,11 +142,7 @@ static int baytrail_write_fadt(struct acpi_ctx *ctx, header->checksum =table_compute_checksum (fadt, header->length); -acpi_add_table (ctx, fadt); - -acpi_inc (ctx,sizeof (struct acpi_fadt )); - -return 0 ; +return acpi_add_fadt (ctx, fadt); } ACPI_WRITER(5fadt, "FADT", baytrail_write_fadt, 0);
arch/x86/cpu/quark/acpi.c +1 -5
@@ -137,11 +137,7 @@ static int quark_write_fadt(struct acpi_ctx *ctx, header->checksum =table_compute_checksum (fadt, header->length); -acpi_add_table (ctx, fadt); - -acpi_inc (ctx,sizeof (struct acpi_fadt )); - -return 0 ; +return acpi_add_fadt (ctx, fadt); } ACPI_WRITER(5fadt, "FADT", quark_write_fadt, 0);
arch/x86/cpu/tangier/acpi.c +1 -5
@@ -52,11 +52,7 @@ static int tangier_write_fadt(struct acpi_ctx *ctx, header->checksum =table_compute_checksum (fadt, header->length); -acpi_add_table (ctx, fadt); - -acpi_inc (ctx,sizeof (struct acpi_fadt )); - -return 0 ; +return acpi_add_fadt (ctx, fadt); } ACPI_WRITER(5fadt, "FADT", tangier_write_fadt, 0);
include/acpi/acpi_table.h +7 -0
@@ -883,6 +883,13 @@ void acpi_inc_align(struct acpi_ctx *ctx, uint amount);*/ int acpi_add_table (struct acpi_ctx *ctx,void *table); +static inline int acpi_add_fadt (struct acpi_ctx *ctx,struct acpi_fadt *fadt) +{ +acpi_add_table (ctx, fadt); +acpi_inc (ctx,sizeof (struct acpi_fadt )); +return 0 ; +} +/** * acpi_write_rsdp() - Write out an RSDP indicating where the ACPI tables are *
Signature · 1 line
2.40.0.1.gaa8946217a0b
Re: [PATCH v1 2/2] x86: Prevent from missing the FADT chaining
On Fri, Aug 25, 2023 at 04:51:41PM +0300, Andy Shevchenko wrote:
...
include/acpi/acpi_table.h void acpi_inc_align(struct acpi_ctx *ctx, uint amount); · line 891
Quoted 6 lines
include/acpi/acpi_table.h +6
-0+static inline int acpi_add_fadt (struct acpi_ctx *ctx,struct acpi_fadt *fadt) +{ +acpi_add_table (ctx, fadt); +acpi_inc (ctx,sizeof (struct acpi_fadt )); +return 0 ; +}
Ideally it should be like
int ret; ret = acpi_add_table(ctx, fadt); if (ret) return ret; acpi_inc(ctx, sizeof(struct acpi_fadt)); return 0;
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v1 1/2] TO BE FOLDED: x86: tangier: Add FADT to the chain
In reply to Andy ShevchenkoHi Andy,
Quoted 23 lines · Andy Shevchenko
The Simon's patch missed the FADT to be added to the chain, hence all the issues on Intel Tangier.
Signed-off-by Andy Shevchenko <[email protected]>--- arch/x86/cpu/tangier/acpi.c | 2 ++ 1 file changed, 2 insertions(+)arch/x86/cpu/tangier/acpi.c +2
-1@@ -52,6 +52,8 @@ static int tangier_write_fadt(struct acpi_ctx *ctx, header->checksum =table_compute_checksum (fadt, header->length); +acpi_add_table (ctx, fadt); +acpi_inc (ctx,sizeof (struct acpi_fadt ));return 0 ; --
Quoted 2 lines
2.40.0.1.gaa8946217a0b
Thank you! I really don't know how I missed that, after starting at it all for an hour...
Regards,
Simon
Re: [PATCH v1 1/2] TO BE FOLDED: x86: tangier: Add FADT to the chain
In reply to Andy ShevchenkoHi Andy,
Quoted 14 lines · Andy Shevchenko
The Simon's patch missed the FADT to be added to the chain, hence all the issues on Intel Tangier.
Signed-off-by Andy Shevchenko <[email protected]>--- arch/x86/cpu/tangier/acpi.c | 2 ++ 1 file changed, 2 insertions(+)arch/x86/cpu/tangier/acpi.c +0
-0
arch/x86/cpu/tangier/acpi.c static int tangier_write_fadt(struct acpi_ctx *ctx,
Quoted 9 lines
arch/x86/cpu/tangier/acpi.c +2
-1@@ -52,6 +52,8 @@ static int tangier_write_fadt(struct acpi_ctx *ctx, header->checksum =table_compute_checksum (fadt, header->length); +acpi_add_table (ctx, fadt); +acpi_inc (ctx,sizeof (struct acpi_fadt ));return 0 ; --
Which commit should we squash this patch in?
Regards,
Bin
Re: [PATCH v1 1/2] TO BE FOLDED: x86: tangier: Add FADT to the chain
Quoted 22 lines · Bin Meng
Hi Andy,
Quoted 17 lines · Andy Shevchenko
The Simon's patch missed the FADT to be added to the chain, hence all the issues on Intel Tangier.
Signed-off-by Andy Shevchenko <[email protected]>--- arch/x86/cpu/tangier/acpi.c | 2 ++ 1 file changed, 2 insertions(+)arch/x86/cpu/tangier/acpi.c +0
-0@@ -52,6 +52,8 @@ static int tangier_write_fadt(struct acpi_ctx *ctx, header->checksum =table_compute_checksum (fadt, header->length);
Quoted 9 lines
arch/x86/cpu/tangier/acpi.c static int tangier_write_fadt(struct acpi_ctx *ctx,
Quoted 6 lines
arch/x86/cpu/tangier/acpi.c +2
-1+acpi_add_table (ctx, fadt); +acpi_inc (ctx,sizeof (struct acpi_fadt ));return 0 ; --Which commit should we squash this patch in?
Ah, I see this patch is already included in Simon's patch:
https://patchwork.ozlabs.org/project/uboot/patch/20230901112707.v3.1.I61008e563b1209243a9a7f2b66073b4737ff82d1@changeid/
I am going to apply Simon's patch unless you guys say I am looking at the wrong patch :)
Regards,
Bin
Re: [PATCH v1 1/2] TO BE FOLDED: x86: tangier: Add FADT to the chain
Hi Bin,
Quoted 34 lines · Bin Meng
Quoted 22 lines · Bin Meng
Hi Andy,
Quoted 17 lines · Andy Shevchenko
The Simon's patch missed the FADT to be added to the chain, hence all the issues on Intel Tangier.
Signed-off-by Andy Shevchenko <[email protected]>--- arch/x86/cpu/tangier/acpi.c | 2 ++ 1 file changed, 2 insertions(+)arch/x86/cpu/tangier/acpi.c +0
-0@@ -52,6 +52,8 @@ static int tangier_write_fadt(struct acpi_ctx *ctx, header->checksum =table_compute_checksum (fadt, header->length);Quoted 9 lines
arch/x86/cpu/tangier/acpi.c static int tangier_write_fadt(struct acpi_ctx *ctx,
Quoted 6 lines
arch/x86/cpu/tangier/acpi.c +2
-1+acpi_add_table (ctx, fadt); +acpi_inc (ctx,sizeof (struct acpi_fadt ));return 0 ; --Which commit should we squash this patch in?
Quoted 5 lines
Ah, I see this patch is already included in Simon's patch:
https://patchwork.ozlabs.org/project/uboot/patch/20230901112707.v3.1.I61008e563b1209243a9a7f2b66073b4737ff82d1@changeid/I am going to apply Simon's patch unless you guys say I am looking at the wrong patch :)
Yes, that's it.
Regards,
Simon
Hi Andy,
Quoted 53 lines · Andy Shevchenko
Quoted 51 lines · Andy Shevchenko
Quoted 21 lines · Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines · Simon Glass
Each board has its own way of creating this table. Rather than calling the
acpi_create_fadt()function for each one from a commonacpi_write_fadt()function, just move the writer into the board-specific code.No luck, but I have a bit of time to debug more.
Okay, after your patch even U-Boot can't see those tables
=> acpi list
Name Base Size Detail ---- -------- ----- ------ RSDP 000e4500 24 v02 U-BOOT RSDT 000e4530 34 v01 U-BOOT U-BOOTBL 20231001 INTL 0 XSDT 000e45e0 44 v01 U-BOOT U-BOOTBL 20231001 INTL 0 CSRT 000e5490 58 v00 U-BOOT U-BOOTBL 20231001 INTL 0 MCFG 000e5610 3c v01 U-BOOT U-BOOTBL 20231001 INTL 0 SPCR 000e5650 50 v02 U-BOOT U-BOOTBL 20231001 INTL 0 APIC 000e56a0 48 v02 U-BOOT U-BOOTBL 20231001 INTL 0Quoted 4 lines
Because the base is badly corrupted:
-00000030: 52 53 44 54 38 00 00 00 01 95 55 2d 42 4f 4f 54 RSDT8.....U-BOOT +00000030: 52 53 44 54 34 00 00 00 01 eb 55 2d 42 4f 4f 54 RSDT4.....U-BOOT
Length -4 bytes, another checksum as a result.
Quoted 2 lines
-00000050: 00 00 00 00 90 54 0e 00 f0 54 0e 00 10 56 0e 00 .....T...T...V.. +00000050: 00 00 00 00 90 54 0e 00 10 56 0e 00 50 56 0e 00 .....T...V..PV..
Missing pointer to
0x0e54f0which is... FADT!Quoted 5 lines
-00000060: 50 56 0e 00 a0 56 0e 00 00 00 00 00 00 00 00 00 PV...V.......... +00000060: a0 56 0e 00 00 00 00 00 00 00 00 00 00 00 00 00 .V..............
-000000e0: 58 53 44 54 4c 00 00 00 01 7b 55 2d 42 4f 4f 54 XSDTL....{U-BOOT +000000e0: 58 53 44 54 44 00 00 00 01 d5 55 2d 42 4f 4f 54 XSDTD.....U-BOOT
Wrong length, another checksum.
Quoted 8 lines
-00000100: 00 00 00 00 90 54 0e 00 00 00 00 00 f0 54 0e 00 .....T.......T.. +00000100: 00 00 00 00 90 54 0e 00 00 00 00 00 10 56 0e 00 .....T.......V..
-00000110: 00 00 00 00 10 56 0e 00 00 00 00 00 50 56 0e 00 .....V......PV.. +00000110: 00 00 00 00 50 56 0e 00 00 00 00 00 a0 56 0e 00 ....PV.......V..
-00000120: 00 00 00 00 a0 56 0e 00 00 00 00 00 00 00 00 00 .....V.......... +00000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Quoted 7 lines
Quoted 1 line
Same reason. So, your code forgot to link FADT to the main tables.
By code analysis you simply missed
+
acpi_add_table(ctx, fadt);I'm going to check this right now... Stay tuned!
Thanks for digging into this, I really appreciate it!
- Simon