All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][RFC] ACPI: processor: Print more information when acpi_processor_evaluate_cst() failed
@ 2020-08-16 15:12 Chen Yu
  2020-08-18 10:46 ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Chen Yu @ 2020-08-16 15:12 UTC (permalink / raw)
  To: Rafael J. Wysocki, Len Brown; +Cc: linux-acpi, rui.zhang, linux-kernel, 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.

Suggested-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
---
 drivers/acpi/acpi_processor.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index b51ddf3bb616..c1d34c448edb 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -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_warn(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_warn(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_warn(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_warn(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_warn(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_warn(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_warn(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_warn(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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][RFC] ACPI: processor: Print more information when acpi_processor_evaluate_cst() failed
  2020-08-16 15:12 [PATCH][RFC] ACPI: processor: Print more information when acpi_processor_evaluate_cst() failed Chen Yu
@ 2020-08-18 10:46 ` Rafael J. Wysocki
  2020-08-19  2:48   ` Chen Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2020-08-18 10:46 UTC (permalink / raw)
  To: Chen Yu
  Cc: Rafael J. Wysocki, Len Brown, ACPI Devel Maling List, Zhang, Rui,
	Linux Kernel Mailing List

On Sun, Aug 16, 2020 at 5:12 PM Chen Yu <yu.c.chen@intel.com> wrote:
>
> 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.
>
> Suggested-by: Zhang Rui <rui.zhang@intel.com>
> Signed-off-by: Chen Yu <yu.c.chen@intel.com>

This is fine by me as a general idea, but please change the log level to "info".

> ---
>  drivers/acpi/acpi_processor.c | 34 ++++++++++++++++++++++++++++------
>  1 file changed, 28 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
> index b51ddf3bb616..c1d34c448edb 100644
> --- a/drivers/acpi/acpi_processor.c
> +++ b/drivers/acpi/acpi_processor.c
> @@ -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_warn(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_warn(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_warn(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_warn(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_warn(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_warn(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_warn(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_warn(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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][RFC] ACPI: processor: Print more information when acpi_processor_evaluate_cst() failed
  2020-08-18 10:46 ` Rafael J. Wysocki
@ 2020-08-19  2:48   ` Chen Yu
  0 siblings, 0 replies; 3+ messages in thread
From: Chen Yu @ 2020-08-19  2:48 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Rafael J. Wysocki, Len Brown, ACPI Devel Maling List, Zhang, Rui,
	Linux Kernel Mailing List

On Tue, Aug 18, 2020 at 12:46:12PM +0200, Rafael J. Wysocki wrote:
> On Sun, Aug 16, 2020 at 5:12 PM Chen Yu <yu.c.chen@intel.com> wrote:
> >
> > 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.
> >
> > Suggested-by: Zhang Rui <rui.zhang@intel.com>
> > Signed-off-by: Chen Yu <yu.c.chen@intel.com>
> 
> This is fine by me as a general idea, but please change the log level to "info".
>
Okay, I will send a new version. Thanks!

thanks,
Chenyu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-19  2:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-16 15:12 [PATCH][RFC] ACPI: processor: Print more information when acpi_processor_evaluate_cst() failed Chen Yu
2020-08-18 10:46 ` Rafael J. Wysocki
2020-08-19  2:48   ` Chen Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.