[PATCH v4 29/35] acpi: Support ordering SSDT data by device

Bin Meng bmeng.cn at gmail.com
Mon Jul 13 07:15:06 CEST 2020


Hi Simon,

On Wed, Jul 8, 2020 at 3:13 AM Simon Glass <sjg at chromium.org> wrote:
>
> Add a /chosen property to control the order in which the data appears
> in the SSDT. This allows matching up U-Boot's output from a dump of the
> known-good data obtained from within Linux.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> Reviewed-by: Wolfgang Wallner <wolfgang.wallner at br-automation.com>
> ---
>
> Changes in v4:
> - Explain in sort_acpi_item_type() why ctx->current is not updated
>
> Changes in v3:
> - Make find_item() static and rename to find_acpi_item()
> - Rename build_type() and add a comment
>
> Changes in v1:
> - Generalise the ACPI function recursion with acpi_recurse_method()
>
>  arch/sandbox/dts/test.dts           |  5 +-
>  doc/device-tree-bindings/chosen.txt |  9 ++++
>  drivers/core/acpi.c                 | 84 +++++++++++++++++++++++++++++
>  test/dm/acpi.c                      | 15 +++---
>  4 files changed, 105 insertions(+), 8 deletions(-)
>
> diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
> index ea686f0cb3..6687efe2ae 100644
> --- a/arch/sandbox/dts/test.dts
> +++ b/arch/sandbox/dts/test.dts
> @@ -254,7 +254,7 @@
>                 compatible = "denx,u-boot-devres-test";
>         };
>
> -       acpi-test {
> +       acpi_test1: acpi-test {
>                 compatible = "denx,u-boot-acpi-test";
>                 acpi-ssdt-test-data = "ab";
>                 child {
> @@ -262,7 +262,7 @@
>                 };
>         };
>
> -       acpi-test2 {
> +       acpi_test2: acpi-test2 {
>                 compatible = "denx,u-boot-acpi-test";
>                 acpi-ssdt-test-data = "cd";
>         };
> @@ -904,6 +904,7 @@
>                 setting = "sunrise ohoka";
>                 other-node = "/some-bus/c-test at 5";
>                 int-values = <0x1937 72993>;
> +               u-boot,acpi-ssdt-order = <&acpi_test2 &acpi_test1>;
>                 chosen-test {
>                         compatible = "denx,u-boot-fdt-test";
>                         reg = <9 1>;
> diff --git a/doc/device-tree-bindings/chosen.txt b/doc/device-tree-bindings/chosen.txt
> index 395c9501e3..d4dfc05847 100644
> --- a/doc/device-tree-bindings/chosen.txt
> +++ b/doc/device-tree-bindings/chosen.txt
> @@ -134,3 +134,12 @@ Example
>                 phandlepart = <&mmc 1>;
>         };
>  };
> +
> +u-boot,acpi-ssdt-order
> +----------------------
> +
> +This provides the ordering to use when writing device data to the ACPI SSDT
> +(Secondary System Descriptor Table). Each cell is a phandle pointer to a device
> +node to add. The ACPI information is written in this order.
> +
> +If the ordering does not include all nodes, an error is generated.
> diff --git a/drivers/core/acpi.c b/drivers/core/acpi.c
> index df3d7ba417..a9b7fc1d9a 100644
> --- a/drivers/core/acpi.c
> +++ b/drivers/core/acpi.c
> @@ -108,6 +108,85 @@ static int acpi_add_item(struct acpi_ctx *ctx, struct udevice *dev,
>         return 0;
>  }
>
> +static struct acpi_item *find_acpi_item(const char *devname)
> +{
> +       int i;
> +
> +       for (i = 0; i < item_count; i++) {
> +               struct acpi_item *item = &acpi_item[i];
> +
> +               if (!strcmp(devname, item->dev->name))
> +                       return item;
> +       }
> +
> +       return NULL;
> +}
> +
> +/**
> + * sort_acpi_item_type - Sort the ACPI items into the desired order
> + *
> + * This looks up the ordering in the device tree and then adds each item one by
> + * one into the supplied buffer
> + *
> + * @ctx: ACPI context
> + * @start: Start position to put the sorted items. The items will follow each
> + *     other in sorted order
> + * @type: Type of items to sort
> + * @return 0 if OK, -ve on error
> + */
> +static int sort_acpi_item_type(struct acpi_ctx *ctx, void *start,
> +                              enum gen_type_t type)
> +{
> +       const u32 *order;
> +       int size;
> +       int count;
> +       void *ptr;
> +       void *end = ctx->current;
> +
> +       ptr = start;
> +       order = ofnode_read_chosen_prop("u-boot,acpi-ssdt-order", &size);
> +       if (!order) {
> +               log_warning("Failed to find ordering, leaving as is\n");

This warning is showing 4 times when booting to U-Boot shell on
Minnowmax. I think we should suppress it by default.

If you agree, please send a version of this patch only, so I can apply
it in u-boot-x86.

> +               return 0;
> +       }
> +
> +       /*
> +        * This algorithm rewrites the context buffer without changing its
> +        * length. So there is no need to update ctx-current
> +        */


Regards,
Bin


More information about the U-Boot mailing list