From: Matthias Brugger <mbrugger@suse.com>
To: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>,
Simon Glass <sjg@chromium.org>
Cc: Peter Robinson <pbrobinson@gmail.com>,
Tom Rini <trini@konsulko.com>, Bin Meng <bmeng.cn@gmail.com>,
Patrick Rudolph <patrick.rudolph@9elements.com>,
Maximilian Brune <maximilian.brune@9elements.com>,
Fiona Klute <fiona.klute@gmx.de>,
Martin Stolpe <martinstolpe@gmail.com>,
Rasmus Villemoes <rasmus.villemoes@prevas.dk>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Moritz Fischer <moritzf@google.com>,
u-boot@lists.denx.de
Subject: Re: [PATCH 2/5] acpi: simplify updating header checksum
Date: Tue, 25 Mar 2025 15:55:15 +0100 [thread overview]
Message-ID: <dd76531a-ef74-47e5-a4bd-ce139a4bd86c@suse.com> (raw)
In-Reply-To: <20250321232121.251800-3-heinrich.schuchardt@canonical.com>
On 22/03/2025 00:21, Heinrich Schuchardt wrote:
> Use acpi_update_checksum() for updating ACPI table header checksum.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Matthias Brugger <mbrugger@suse.com>
> ---
> lib/acpi/acpi_table.c | 18 +++++++-----------
> lib/acpi/base.c | 6 ++----
> lib/acpi/csrt.c | 2 +-
> lib/acpi/mcfg.c | 2 +-
> lib/acpi/ssdt.c | 2 +-
> 5 files changed, 12 insertions(+), 18 deletions(-)
>
> diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c
> index c0ed24984af..b5495d48a46 100644
> --- a/lib/acpi/acpi_table.c
> +++ b/lib/acpi/acpi_table.c
> @@ -195,9 +195,7 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table)
> (sizeof(u32) * (i + 1));
>
> /* Re-calculate checksum */
> - rsdt->header.checksum = 0;
> - rsdt->header.checksum = table_compute_checksum((u8 *)rsdt,
> - rsdt->header.length);
> + acpi_update_checksum(&rsdt->header);
> }
>
> if (ctx->xsdt) {
> @@ -228,9 +226,7 @@ int acpi_add_table(struct acpi_ctx *ctx, void *table)
> (sizeof(u64) * (i + 1));
>
> /* Re-calculate checksum */
> - xsdt->header.checksum = 0;
> - xsdt->header.checksum = table_compute_checksum((u8 *)xsdt,
> - xsdt->header.length);
> + acpi_update_checksum(&xsdt->header);
> }
>
> return 0;
> @@ -268,7 +264,7 @@ int acpi_write_fadt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
>
> acpi_fill_fadt(fadt);
>
> - header->checksum = table_compute_checksum(fadt, header->length);
> + acpi_update_checksum(header);
>
> return acpi_add_fadt(ctx, fadt);
> }
> @@ -303,7 +299,7 @@ int acpi_write_madt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
> if (IS_ENABLED(CONFIG_ACPI_PARKING_PROTOCOL))
> acpi_write_park(madt);
>
> - header->checksum = table_compute_checksum((void *)madt, header->length);
> + acpi_update_checksum(header);
> acpi_add_table(ctx, madt);
> ctx->current = (void *)madt + madt->header.length;
>
> @@ -374,7 +370,7 @@ void acpi_create_dbg2(struct acpi_dbg2_header *dbg2,
> /* Update structure lengths and checksum */
> device->length = current - (uintptr_t)device;
> header->length = current - (uintptr_t)dbg2;
> - header->checksum = table_compute_checksum(dbg2, header->length);
> + acpi_update_checksum(header);
> }
>
> int acpi_write_dbg2_pci_uart(struct acpi_ctx *ctx, struct udevice *dev,
> @@ -549,7 +545,7 @@ static int acpi_write_spcr(struct acpi_ctx *ctx, const struct acpi_writer *entry
> spcr->baud_rate = 0;
>
> /* Fix checksum */
> - header->checksum = table_compute_checksum((void *)spcr, header->length);
> + acpi_update_checksum(header);
>
> acpi_add_table(ctx, spcr);
> acpi_inc(ctx, spcr->header.length);
> @@ -759,7 +755,7 @@ static int acpi_write_iort(struct acpi_ctx *ctx, const struct acpi_writer *entry
>
> /* (Re)calculate length and checksum */
> iort->header.length = ctx->current - (void *)iort;
> - iort->header.checksum = table_compute_checksum((void *)iort, iort->header.length);
> + acpi_update_checksum(&iort->header);
> log_debug("IORT at %p, length %x\n", iort, iort->header.length);
>
> /* Drop the table if it is empty */
> diff --git a/lib/acpi/base.c b/lib/acpi/base.c
> index 8b6af2bc43a..5c755b14c16 100644
> --- a/lib/acpi/base.c
> +++ b/lib/acpi/base.c
> @@ -50,8 +50,7 @@ static void acpi_write_rsdt(struct acpi_rsdt *rsdt)
> /* Entries are filled in later, we come with an empty set */
>
> /* Fix checksum */
> - header->checksum = table_compute_checksum(rsdt,
> - sizeof(struct acpi_rsdt));
> + acpi_update_checksum(header);
> }
>
> static void acpi_write_xsdt(struct acpi_xsdt *xsdt)
> @@ -66,8 +65,7 @@ static void acpi_write_xsdt(struct acpi_xsdt *xsdt)
> /* Entries are filled in later, we come with an empty set */
>
> /* Fix checksum */
> - header->checksum = table_compute_checksum(xsdt,
> - sizeof(struct acpi_xsdt));
> + acpi_update_checksum(header);
> }
>
> static int acpi_write_base(struct acpi_ctx *ctx,
> diff --git a/lib/acpi/csrt.c b/lib/acpi/csrt.c
> index 00927e53406..b863c644c07 100644
> --- a/lib/acpi/csrt.c
> +++ b/lib/acpi/csrt.c
> @@ -40,7 +40,7 @@ int acpi_write_csrt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
>
> /* (Re)calculate length and checksum */
> header->length = (ulong)ctx->current - (ulong)csrt;
> - header->checksum = table_compute_checksum(csrt, header->length);
> + acpi_update_checksum(header);
>
> acpi_add_table(ctx, csrt);
>
> diff --git a/lib/acpi/mcfg.c b/lib/acpi/mcfg.c
> index 8b8a5bfafae..e21fe7ce123 100644
> --- a/lib/acpi/mcfg.c
> +++ b/lib/acpi/mcfg.c
> @@ -57,7 +57,7 @@ int acpi_write_mcfg(struct acpi_ctx *ctx, const struct acpi_writer *entry)
>
> /* (Re)calculate length and checksum */
> header->length = (ulong)ctx->current - (ulong)mcfg;
> - header->checksum = table_compute_checksum(mcfg, header->length);
> + acpi_update_checksum(header);
>
> acpi_add_table(ctx, mcfg);
>
> diff --git a/lib/acpi/ssdt.c b/lib/acpi/ssdt.c
> index df1d739d117..41e2d3c2f6c 100644
> --- a/lib/acpi/ssdt.c
> +++ b/lib/acpi/ssdt.c
> @@ -35,7 +35,7 @@ int acpi_write_ssdt(struct acpi_ctx *ctx, const struct acpi_writer *entry)
>
> /* (Re)calculate length and checksum */
> ssdt->length = ctx->current - (void *)ssdt;
> - ssdt->checksum = table_compute_checksum((void *)ssdt, ssdt->length);
> + acpi_update_checksum(ssdt);
> log_debug("SSDT at %p, length %x\n", ssdt, ssdt->length);
>
> /* Drop the table if it is empty */
next prev parent reply other threads:[~2025-03-25 14:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 23:21 [PATCH 0/5] acpi: simplify updating ACPI table header checksum Heinrich Schuchardt
2025-03-21 23:21 ` [PATCH 1/5] acpi: new function acpi_update_checksum() Heinrich Schuchardt
2025-03-25 14:49 ` Matthias Brugger
2025-03-26 7:29 ` Ilias Apalodimas
2025-03-21 23:21 ` [PATCH 2/5] acpi: simplify updating header checksum Heinrich Schuchardt
2025-03-25 14:55 ` Matthias Brugger [this message]
2025-03-26 7:30 ` Ilias Apalodimas
2025-03-21 23:21 ` [PATCH 3/5] x86/acpi: " Heinrich Schuchardt
2025-03-25 14:58 ` Matthias Brugger
2025-03-21 23:21 ` [PATCH 4/5] qemu-sbsa: simplify updating ACPI table " Heinrich Schuchardt
2025-03-25 15:01 ` Matthias Brugger
2025-03-26 7:30 ` Ilias Apalodimas
2025-03-21 23:21 ` [PATCH 5/5] arm: " Heinrich Schuchardt
2025-03-25 15:03 ` Matthias Brugger
2025-03-26 7:31 ` Ilias Apalodimas
2025-04-10 1:46 ` [PATCH 0/5] acpi: " Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dd76531a-ef74-47e5-a4bd-ce139a4bd86c@suse.com \
--to=mbrugger@suse.com \
--cc=bmeng.cn@gmail.com \
--cc=fiona.klute@gmx.de \
--cc=heinrich.schuchardt@canonical.com \
--cc=ilias.apalodimas@linaro.org \
--cc=martinstolpe@gmail.com \
--cc=maximilian.brune@9elements.com \
--cc=moritzf@google.com \
--cc=patrick.rudolph@9elements.com \
--cc=pbrobinson@gmail.com \
--cc=rasmus.villemoes@prevas.dk \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox