ACK: [PATCH][V3] acpi: method: check one element in _TSD only for acpi 6.2+

Colin Ian King colin.king at canonical.com
Wed Feb 21 09:19:03 UTC 2018


On 20/02/18 23:49, Alex Hung wrote:
> ACPI 6.1 and before allow more element in _TSD method
> 
> Signed-off-by: Alex Hung <alex.hung at canonical.com>
> ---
>  src/acpi/method/method.c           |  6 ++++--
>  src/lib/include/fwts_acpi.h        | 11 +++++++++++
>  src/lib/include/fwts_acpi_tables.h |  2 ++
>  src/lib/src/fwts_acpi_tables.c     | 34 ++++++++++++++++++++++++++++++++++
>  4 files changed, 51 insertions(+), 2 deletions(-)
> 
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 6839c3f..0df3526 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -2896,8 +2896,10 @@ static void method_test_TSD_return(
>  	if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK)
>  		return;
>  
> -	if (fwts_method_package_count_equal(fw, name, "_TSD", obj, 1) != FWTS_OK)
> -		return;
> +	if (fwts_get_acpi_version(fw) >= FWTS_ACPI_VERSION_62) {
> +		if (fwts_method_package_count_equal(fw, name, "_TSD", obj, 1) != FWTS_OK)
> +			return;
> +	}
>  
>  	/* Could be one or more packages */
>  	for (i = 0; i < obj->Package.Count; i++) {
> diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h
> index 3151b90..e550cd7 100644
> --- a/src/lib/include/fwts_acpi.h
> +++ b/src/lib/include/fwts_acpi.h
> @@ -84,6 +84,17 @@
>  #define FWTS_GAS_ADDR_SPACE_ID_PCC		(0x0a)
>  #define FWTS_GAS_ADDR_SPACE_ID_FFH		(0x7f)
>  
> +#define FWTS_ACPI_VERSION_NEXT	(0x700)
> +#define FWTS_ACPI_VERSION_62 	(0x620)
> +#define FWTS_ACPI_VERSION_61	(0x610)
> +#define FWTS_ACPI_VERSION_60	(0x600)
> +#define FWTS_ACPI_VERSION_51	(0x510)
> +#define FWTS_ACPI_VERSION_50	(0x500)
> +#define FWTS_ACPI_VERSION_40	(0x400)
> +#define FWTS_ACPI_VERSION_30	(0x300)
> +#define FWTS_ACPI_VERSION_20	(0x200)
> +#define FWTS_ACPI_VERSION_10	(0x100)
> +
>  #include "fwts_types.h"
>  #include "fwts_framework.h"
>  #include "fwts_log.h"
> diff --git a/src/lib/include/fwts_acpi_tables.h b/src/lib/include/fwts_acpi_tables.h
> index 11b870c..d307af8 100644
> --- a/src/lib/include/fwts_acpi_tables.h
> +++ b/src/lib/include/fwts_acpi_tables.h
> @@ -58,6 +58,8 @@ void fwts_acpi_reserved_bits_check(fwts_framework *fw, const char *table, const
>  void fwts_acpi_reserved_type_check(fwts_framework *fw, const char *table, uint8_t value, uint8_t min, uint8_t reserved, bool *passed);
>  bool fwts_acpi_subtable_length_check(fwts_framework *fw, const char *table, uint8_t subtable_type, uint32_t subtable_length, uint32_t size);
>  
> +uint32_t fwts_get_acpi_version(fwts_framework *fw);
> +
>  #endif
>  
>  #endif
> diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
> index 2aa30f8..c7ba59b 100644
> --- a/src/lib/src/fwts_acpi_tables.c
> +++ b/src/lib/src/fwts_acpi_tables.c
> @@ -1532,4 +1532,38 @@ bool fwts_acpi_subtable_length_check(
>  	return true;
>  }
>  
> +static uint32_t acpi_version;
> +/*
> + *  fwts_get_acpi_version()
> + * 	get acpi version from facp
> + */
> +uint32_t fwts_get_acpi_version(fwts_framework *fw)
> +{
> +	fwts_acpi_table_fadt *fadt;
> +	fwts_acpi_table_info *table;
> +
> +	if (acpi_version != 0)
> +		return acpi_version;
> +
> +	if (fwts_acpi_find_table(fw, "FACP", 0, &table) != FWTS_OK) {
> +		fwts_log_error(fw, "Cannot read ACPI table FACP.");
> +		return 0;
> +	}
> +
> +	if (table == NULL) {
> +		fwts_log_error(fw, "ACPI table FACP does not exist!");
> +		return 0;
> +	}
> +
> +	fadt = (fwts_acpi_table_fadt *) table->data;
> +	acpi_version = (fadt->header.revision << 8) + fadt->minor_version;
> +
> +	/* check FACP returns an invalid value */
> +	if (acpi_version > FWTS_ACPI_VERSION_NEXT ||
> +	    acpi_version < FWTS_ACPI_VERSION_10)
> +		return 0;
> +
> +	return acpi_version;
> +}
> +
>  #endif
> 
Thanks Alex,

Acked-by: Colin Ian King <colin.king at canonical.com>



More information about the fwts-devel mailing list