diff mbox series

Add support for ACPI 6.5 _UPC return values

Message ID 20231214184244.6969-1-mario.limonciello@amd.com
State Superseded
Headers show
Series Add support for ACPI 6.5 _UPC return values | expand

Commit Message

Mario Limonciello Dec. 14, 2023, 6:42 p.m. UTC
The ACPI 6.5 specification includes `USB-C Port Capabilities` as
part of the possible return values for `_UPC`.

Add checks that match this guidance.

Link: https://uefi.org/specs/ACPI/6.5/09_ACPI_Defined_Devices_and_Device_Specific_Objects.html?highlight=upc#upc-usb-port-capabilities
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 src/acpi/method/method.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

Comments

ivanhu Dec. 20, 2023, 9:55 a.m. UTC | #1
On 12/15/23 02:42, Mario Limonciello wrote:
> The ACPI 6.5 specification includes `USB-C Port Capabilities` as
> part of the possible return values for `_UPC`.
> 
> Add checks that match this guidance.
> 
> Link: https://uefi.org/specs/ACPI/6.5/09_ACPI_Defined_Devices_and_Device_Specific_Objects.html?highlight=upc#upc-usb-port-capabilities
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>   src/acpi/method/method.c | 28 +++++++++++++++++++++++++---
>   1 file changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 27e2410d..32c8d2d4 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -2844,12 +2844,12 @@ static void method_test_UPC_return(
>   	ACPI_OBJECT *obj,
>   	void *private)
>   {
> -	uint32_t i, connector_type;
> +	uint32_t i, connector_type, capabilities;
>   
>   	static const fwts_package_element elements[] = {
>   		{ ACPI_TYPE_INTEGER,	"Connectable" },
>   		{ ACPI_TYPE_INTEGER,	"Type" },
> -		{ ACPI_TYPE_INTEGER,	"Reserved0" },
> +		{ ACPI_TYPE_INTEGER,	"USB-C Port Capabilities" },
>   		{ ACPI_TYPE_INTEGER,	"Reserved1" },
>   	};
>   
> @@ -2868,7 +2868,29 @@ static void method_test_UPC_return(
>   		return;
>   	}
>   
> -	for (i = 2; i < 4; i++) {
> +	capabilities = obj->Package.Elements[2].Integer.Value;
> +	switch (connector_type) {
> +	case 0x08:
> +	case 0x09:
> +	case 0x0a:
> +		if (capabilities & 0xffffffc0) {
> +			fwts_failed(fw, LOG_LEVEL_MEDIUM, "Method_UPCBadReturnType",
> +				"%s %s set reserved bits (%d)",
> +				name, elements[2].name, capabilities);
> +			return;
> +		}
> +		break;
> +	default:
> +		if (capabilities != 0) {
> +			fwts_failed(fw, LOG_LEVEL_MEDIUM, "Method_UPCBadReturnType",
> +				"%s %s returned %d which is incompatible with connector type %d.",
> +				name, elements[2].name, capabilities, connector_type);
> +			return;
> +		}
> +		break;
> +	}
> +
> +	for (i = 3; i < 4; i++) {
>   		if (obj->Package.Elements[i].Integer.Value != 0) {

I think use,
if (obj->Package.Elements[3].Integer.Value != 0) {

then we can get rid of for loop.

Cheers,
Ivan

>   			fwts_failed(fw, LOG_LEVEL_MEDIUM,
>   				"Method_UPCBadReturnType",
diff mbox series

Patch

diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
index 27e2410d..32c8d2d4 100644
--- a/src/acpi/method/method.c
+++ b/src/acpi/method/method.c
@@ -2844,12 +2844,12 @@  static void method_test_UPC_return(
 	ACPI_OBJECT *obj,
 	void *private)
 {
-	uint32_t i, connector_type;
+	uint32_t i, connector_type, capabilities;
 
 	static const fwts_package_element elements[] = {
 		{ ACPI_TYPE_INTEGER,	"Connectable" },
 		{ ACPI_TYPE_INTEGER,	"Type" },
-		{ ACPI_TYPE_INTEGER,	"Reserved0" },
+		{ ACPI_TYPE_INTEGER,	"USB-C Port Capabilities" },
 		{ ACPI_TYPE_INTEGER,	"Reserved1" },
 	};
 
@@ -2868,7 +2868,29 @@  static void method_test_UPC_return(
 		return;
 	}
 
-	for (i = 2; i < 4; i++) {
+	capabilities = obj->Package.Elements[2].Integer.Value;
+	switch (connector_type) {
+	case 0x08:
+	case 0x09:
+	case 0x0a:
+		if (capabilities & 0xffffffc0) {
+			fwts_failed(fw, LOG_LEVEL_MEDIUM, "Method_UPCBadReturnType",
+				"%s %s set reserved bits (%d)",
+				name, elements[2].name, capabilities);
+			return;
+		}
+		break;
+	default:
+		if (capabilities != 0) {
+			fwts_failed(fw, LOG_LEVEL_MEDIUM, "Method_UPCBadReturnType",
+				"%s %s returned %d which is incompatible with connector type %d.",
+				name, elements[2].name, capabilities, connector_type);
+			return;
+		}
+		break;
+	}
+
+	for (i = 3; i < 4; i++) {
 		if (obj->Package.Elements[i].Integer.Value != 0) {
 			fwts_failed(fw, LOG_LEVEL_MEDIUM,
 				"Method_UPCBadReturnType",