Skip to contentSkip to conversation

ACPI: processor: Print more information when acpi_processor_evaluate_cst() failed

PATCH Applied Chen Yu 2 participants 2 messages Aug 19, 2020 – Sep 21, 2020 ACPI

lore
Share & tools
lore

Chen Yu

author
#0 lore raw

PATCH v2 1/1 ACPI: processor: Print more information when acpi_processor_evaluate_cst() failed

Some platforms have bogus _CST which might cause expectd behavior in the cpu idle driver. Some bogus _CST might be unable to be disassembled by acpica-tools due to broken format. Print extra log if the _CST extraction/verification failed. This can be used to help the user narrow down why the cpu idle driver fails to behave as expected.

---
v2: According to Rafael's suggestion, change the log level
from "warn" to "info"

---
 drivers/acpi/acpi_processor.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)
drivers/acpi/acpi_processor.c +28 -6
index b51ddf3bb616..412a9725cc1e 100644
@@ -798,22 +798,34 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
 		memset(&cx, 0, sizeof(cx));
 
 		element = &cst->package.elements[i];
-		if (element->type != ACPI_TYPE_PACKAGE)
+		if (element->type != ACPI_TYPE_PACKAGE) {
+			acpi_handle_info(handle, "_CST C%d type(%x) is not package, skip...\n",
+					 i, element->type);
 			continue;
+		}
 
-		if (element->package.count != 4)
+		if (element->package.count != 4) {
+			acpi_handle_info(handle, "_CST C%d package count(%d) is not 4, skip...\n",
+					 i, element->package.count);
 			continue;
+		}
 
 		obj = &element->package.elements[0];
 
-		if (obj->type != ACPI_TYPE_BUFFER)
+		if (obj->type != ACPI_TYPE_BUFFER) {
+			acpi_handle_info(handle, "_CST C%d package element[0] type(%x) is not buffer, skip...\n",
+					 i, obj->type);
 			continue;
+		}
 
 		reg = (struct acpi_power_register *)obj->buffer.pointer;
 
 		obj = &element->package.elements[1];
-		if (obj->type != ACPI_TYPE_INTEGER)
+		if (obj->type != ACPI_TYPE_INTEGER) {
+			acpi_handle_info(handle, "_CST C[%d] package element[1] type(%x) is not integer, skip...\n",
+					 i, obj->type);
 			continue;
+		}
 
 		cx.type = obj->integer.value;
 		/*
@@ -850,6 +862,8 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
 				cx.entry_method = ACPI_CSTATE_HALT;
 				snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI HLT");
 			} else {
+				acpi_handle_info(handle, "_CST C%d declares FIXED_HARDWARE C-state but not supported in hardware, skip...\n",
+						 i);
 				continue;
 			}
 		} else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
@@ -857,6 +871,8 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
 			snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI IOPORT 0x%x",
 				 cx.address);
 		} else {
+			acpi_handle_info(handle, "_CST C%d space_id(%x) neither FIXED_HARDWARE nor SYSTEM_IO, skip...\n",
+					 i, reg->space_id);
 			continue;
 		}
 
@@ -864,14 +880,20 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
 			cx.valid = 1;
 
 		obj = &element->package.elements[2];
-		if (obj->type != ACPI_TYPE_INTEGER)
+		if (obj->type != ACPI_TYPE_INTEGER) {
+			acpi_handle_info(handle, "_CST C%d package element[2] type(%x) not integer, skip...\n",
+					 i, obj->type);
 			continue;
+		}
 
 		cx.latency = obj->integer.value;
 
 		obj = &element->package.elements[3];
-		if (obj->type != ACPI_TYPE_INTEGER)
+		if (obj->type != ACPI_TYPE_INTEGER) {
+			acpi_handle_info(handle, "_CST C%d package element[3] type(%x) not integer, skip...\n",
+					 i, obj->type);
 			continue;
+		}
 
 		memcpy(&info->states[++last_index], &cx, sizeof(cx));
 	}
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 8 lines · Chen Yu

Some platforms have bogus _CST which might cause expectd behavior in the cpu idle driver. Some bogus _CST might be unable to be disassembled by acpica-tools due to broken format. Print extra log if the _CST extraction/verification failed. This can be used to help the user narrow down why the cpu idle driver fails to behave as expected.

Quoted 5 lines

---
v2: According to Rafael's suggestion, change the log level
from "warn" to "info"

Applied as 5.10 material with some edits in the subject and changelog, thanks!

Quoted 91 lines
---
 drivers/acpi/acpi_processor.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)
drivers/acpi/acpi_processor.c +28 -7
index b51ddf3bb616..412a9725cc1e 100644
@@ -798,22 +798,34 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
                memset(&cx, 0, sizeof(cx));
 
                element = &cst->package.elements[i];
-               if (element->type != ACPI_TYPE_PACKAGE)
+               if (element->type != ACPI_TYPE_PACKAGE) {
+                       acpi_handle_info(handle, "_CST C%d type(%x) is not package, skip...\n",
+                                        i, element->type);
                        continue;
+               }
 
-               if (element->package.count != 4)
+               if (element->package.count != 4) {
+                       acpi_handle_info(handle, "_CST C%d package count(%d) is not 4, skip...\n",
+                                        i, element->package.count);
                        continue;
+               }
 
                obj = &element->package.elements[0];
 
-               if (obj->type != ACPI_TYPE_BUFFER)
+               if (obj->type != ACPI_TYPE_BUFFER) {
+                       acpi_handle_info(handle, "_CST C%d package element[0] type(%x) is not buffer, skip...\n",
+                                        i, obj->type);
                        continue;
+               }
 
                reg = (struct acpi_power_register *)obj->buffer.pointer;
 
                obj = &element->package.elements[1];
-               if (obj->type != ACPI_TYPE_INTEGER)
+               if (obj->type != ACPI_TYPE_INTEGER) {
+                       acpi_handle_info(handle, "_CST C[%d] package element[1] type(%x) is not integer, skip...\n",
+                                        i, obj->type);
                        continue;
+               }
 
                cx.type = obj->integer.value;
                /*
@@ -850,6 +862,8 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
                                cx.entry_method = ACPI_CSTATE_HALT;
                                snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI HLT");
                        } else {
+                               acpi_handle_info(handle, "_CST C%d declares FIXED_HARDWARE C-state but not supported in hardware, skip...\n",
+                                                i);
                                continue;
                        }
                } else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
@@ -857,6 +871,8 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
                        snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI IOPORT 0x%x",
                                 cx.address);
                } else {
+                       acpi_handle_info(handle, "_CST C%d space_id(%x) neither FIXED_HARDWARE nor SYSTEM_IO, skip...\n",
+                                        i, reg->space_id);
                        continue;
                }
 
@@ -864,14 +880,20 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
                        cx.valid = 1;
 
                obj = &element->package.elements[2];
-               if (obj->type != ACPI_TYPE_INTEGER)
+               if (obj->type != ACPI_TYPE_INTEGER) {
+                       acpi_handle_info(handle, "_CST C%d package element[2] type(%x) not integer, skip...\n",
+                                        i, obj->type);
                        continue;
+               }
 
                cx.latency = obj->integer.value;
 
                obj = &element->package.elements[3];
-               if (obj->type != ACPI_TYPE_INTEGER)
+               if (obj->type != ACPI_TYPE_INTEGER) {
+                       acpi_handle_info(handle, "_CST C%d package element[3] type(%x) not integer, skip...\n",
+                                        i, obj->type);
                        continue;
+               }
 
                memcpy(&info->states[++last_index], &cx, sizeof(cx));
        }
--

2.17.1