Reland "x86: Move FACP table into separate functions""
Subsystems (3)
PATCH v2 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.
---
(Now fixed - thank you Andy!)
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?
Changes in v2:
- Squash in the fix from Andy Shevchenko
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 | 27 +++++++++++++++++++-------- arch/x86/include/asm/acpi_table.h | 2 -- arch/x86/lib/acpi_table.c | 15 --------------- 6 files changed, 70 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 +19 -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,20 @@ 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_add_table (ctx, fadt); + +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.rc2.253.gd59a3bf2b4-goog
PATCH v2 2/2 x86: Prevent from missing the FADT chaining
From: Andy Shevchenko <[email protected]>
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.
---
(no changes since v1)
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.42.0.rc2.253.gd59a3bf2b4-goog
Quoted 6 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.Signed-off-by Simon Glass <[email protected]>Signed-off-by Andy Shevchenko <[email protected]>
Not sure this is correct SoB chain. In kernel project we would do
Quoted 2 lines
---
(Now fixed - thank you Andy!)
Right,
Signature · 2 lines
With Best Regards, Andy Shevchenko