diff mbox series

[v2,1/2] x86: acpi: Fix calculation of DSDT length

Message ID 20200916145753.684377-1-wolfgang.wallner@br-automation.com
State Accepted
Commit 3f6966ab2b9a2264c05d699353e61b276b1a85bd
Delegated to: Bin Meng
Headers show
Series [v2,1/2] x86: acpi: Fix calculation of DSDT length | expand

Commit Message

Wolfgang Wallner Sept. 16, 2020, 2:57 p.m. UTC
Currently, the calculation for the length of the DSDT table includes any
bytes that are added for alignment, but those bytes are not initialized.

This is because the DSDT length is calculated after a call to
acpi_inc_align(). Split this up into the following sequence:

  * acpi_inc()
  * Calculate DSDT length
  * acpi_align()

Signed-off-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

---

Changes in v2:
 - Added Reviewed-by tags

 arch/x86/lib/acpi_table.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Bin Meng Sept. 21, 2020, 1:42 a.m. UTC | #1
On Wed, Sep 16, 2020 at 10:57 PM Wolfgang Wallner
<wolfgang.wallner@br-automation.com> wrote:
>
> Currently, the calculation for the length of the DSDT table includes any
> bytes that are added for alignment, but those bytes are not initialized.
>
> This is because the DSDT length is calculated after a call to
> acpi_inc_align(). Split this up into the following sequence:
>
>   * acpi_inc()
>   * Calculate DSDT length
>   * acpi_align()
>
> Signed-off-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> ---
>
> Changes in v2:
>  - Added Reviewed-by tags
>
>  arch/x86/lib/acpi_table.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Bin Meng Sept. 21, 2020, 1:46 a.m. UTC | #2
On Mon, Sep 21, 2020 at 9:42 AM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> On Wed, Sep 16, 2020 at 10:57 PM Wolfgang Wallner
> <wolfgang.wallner@br-automation.com> wrote:
> >
> > Currently, the calculation for the length of the DSDT table includes any
> > bytes that are added for alignment, but those bytes are not initialized.
> >
> > This is because the DSDT length is calculated after a call to
> > acpi_inc_align(). Split this up into the following sequence:
> >
> >   * acpi_inc()
> >   * Calculate DSDT length
> >   * acpi_align()
> >
> > Signed-off-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Reviewed-by: Simon Glass <sjg@chromium.org>
> >
> > ---
> >
> > Changes in v2:
> >  - Added Reviewed-by tags
> >
> >  arch/x86/lib/acpi_table.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

applied to u-boot-x86, thanks!
diff mbox series

Patch

diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c
index 3a93fedfc3..6b827bfa3f 100644
--- a/arch/x86/lib/acpi_table.c
+++ b/arch/x86/lib/acpi_table.c
@@ -427,7 +427,7 @@  ulong write_acpi_tables(ulong start_addr)
 	       (char *)&AmlCode + sizeof(struct acpi_table_header),
 	       dsdt->length - sizeof(struct acpi_table_header));
 
-	acpi_inc_align(ctx, dsdt->length - sizeof(struct acpi_table_header));
+	acpi_inc(ctx, dsdt->length - sizeof(struct acpi_table_header));
 
 	/* Pack GNVS into the ACPI table area */
 	for (i = 0; i < dsdt->length; i++) {
@@ -450,6 +450,8 @@  ulong write_acpi_tables(ulong start_addr)
 	dsdt->checksum = 0;
 	dsdt->checksum = table_compute_checksum((void *)dsdt, dsdt->length);
 
+	acpi_align(ctx);
+
 	/*
 	 * Fill in platform-specific global NVS variables. If this fails we
 	 * cannot return the error but this should only happen while debugging.