diff mbox

acpi: method: dump out _PSS states in a tabular format

Message ID 1355339303-1751-1-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King Dec. 12, 2012, 7:08 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

The _PSS states that were being dumped out were messy. This patch
dumps out the interesting _PSS states if the elements have passed
the parsing checks.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/method/method.c | 45 ++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 38 insertions(+), 7 deletions(-)

Comments

Keng-Yu Lin Dec. 18, 2012, 2:41 a.m. UTC | #1
On Thu, Dec 13, 2012 at 3:08 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The _PSS states that were being dumped out were messy. This patch
> dumps out the interesting _PSS states if the elements have passed
> the parsing checks.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/method/method.c | 45 ++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 38 insertions(+), 7 deletions(-)
>
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 52b0e18..2dcbee0 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -1715,6 +1715,8 @@ static void method_test_PSS_return(
>         uint32_t max_freq = 0;
>         uint32_t prev_power = 0;
>         bool max_freq_valid = false;
> +       bool dump_elements = false;
> +       bool *element_ok;
>
>         FWTS_UNUSED(private);
>
> @@ -1731,6 +1733,12 @@ static void method_test_PSS_return(
>                 return;
>         }
>
> +       element_ok = calloc(obj->Package.Count, sizeof(bool));
> +       if (element_ok == NULL) {
> +               fwts_log_error(fw, "Cannot allocate an array. Test aborted.");
> +               return;
> +       }
> +
>         for (i = 0; i < obj->Package.Count; i++) {
>                 ACPI_OBJECT *pstate;
>
> @@ -1772,13 +1780,11 @@ static void method_test_PSS_return(
>                         continue;
>                 }
>
> -               fwts_log_info(fw, "P-State %d: CPU %" PRIu64 " Mhz, %" PRIu64 " mW, "
> -                       "latency %" PRIu64 " us, bus master latency %" PRIu64 " us.",
> -                       i,
> -                       pstate->Package.Elements[0].Integer.Value,
> -                       pstate->Package.Elements[1].Integer.Value,
> -                       pstate->Package.Elements[2].Integer.Value,
> -                       pstate->Package.Elements[3].Integer.Value);
> +               /*
> +                *  Parses OK, so this element can be dumped out
> +                */
> +               element_ok[i] = true;
> +               dump_elements = true;
>
>                 /*
>                  * Collect maximum frequency.  The sub-packages are sorted in
> @@ -1813,6 +1819,31 @@ static void method_test_PSS_return(
>         }
>
>         /*
> +        *  If we have some valid data then dump it out, it is useful to see
> +        */
> +       if (dump_elements) {
> +               fwts_log_info_verbatum(fw, "P-State  Freq     Power  Latency   Bus Master");
> +               fwts_log_info_verbatum(fw, "         (MHz)    (mW)    (us)    Latency (us)");
> +               for (i = 0; i < obj->Package.Count; i++) {
> +                       ACPI_OBJECT *pstate = &obj->Package.Elements[i];
> +                       if (element_ok[i]) {
> +                               fwts_log_info_verbatum(fw, " %3d   %7" PRIu64 " %8" PRIu64
> +                                       " %5" PRIu64 "     %5" PRIu64,
> +                                       i,
> +                                       pstate->Package.Elements[0].Integer.Value,
> +                                       pstate->Package.Elements[1].Integer.Value,
> +                                       pstate->Package.Elements[2].Integer.Value,
> +                                       pstate->Package.Elements[3].Integer.Value);
> +                       } else {
> +                               fwts_log_info_verbatum(fw,
> +                                       " %3d      ----    -----    --        -- (invalid)", i);
> +                       }
> +               }
> +       }
> +
> +       free(element_ok);
> +
> +       /*
>          * Sanity check maximum frequency.  We could also check the DMI data
>          * for a BIOS date (but this can be wrong) or check the CPU identity
>          * (which requires adding in new CPU identity checks) to make a decision
> --
> 1.8.0
>
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Ivan Hu Dec. 20, 2012, 2:29 a.m. UTC | #2
On 12/13/2012 03:08 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The _PSS states that were being dumped out were messy. This patch
> dumps out the interesting _PSS states if the elements have passed
> the parsing checks.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/method/method.c | 45 ++++++++++++++++++++++++++++++++++++++-------
>   1 file changed, 38 insertions(+), 7 deletions(-)
>
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index 52b0e18..2dcbee0 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -1715,6 +1715,8 @@ static void method_test_PSS_return(
>   	uint32_t max_freq = 0;
>   	uint32_t prev_power = 0;
>   	bool max_freq_valid = false;
> +	bool dump_elements = false;
> +	bool *element_ok;
>
>   	FWTS_UNUSED(private);
>
> @@ -1731,6 +1733,12 @@ static void method_test_PSS_return(
>   		return;
>   	}
>
> +	element_ok = calloc(obj->Package.Count, sizeof(bool));
> +	if (element_ok == NULL) {
> +		fwts_log_error(fw, "Cannot allocate an array. Test aborted.");
> +		return;
> +	}
> +
>   	for (i = 0; i < obj->Package.Count; i++) {
>   		ACPI_OBJECT *pstate;
>
> @@ -1772,13 +1780,11 @@ static void method_test_PSS_return(
>   			continue;
>   		}
>
> -		fwts_log_info(fw, "P-State %d: CPU %" PRIu64 " Mhz, %" PRIu64 " mW, "
> -			"latency %" PRIu64 " us, bus master latency %" PRIu64 " us.",
> -			i,
> -			pstate->Package.Elements[0].Integer.Value,
> -			pstate->Package.Elements[1].Integer.Value,
> -			pstate->Package.Elements[2].Integer.Value,
> -			pstate->Package.Elements[3].Integer.Value);
> +		/*
> +	 	 *  Parses OK, so this element can be dumped out
> +		 */
> +		element_ok[i] = true;
> +		dump_elements = true;
>
>   		/*
>   		 * Collect maximum frequency.  The sub-packages are sorted in
> @@ -1813,6 +1819,31 @@ static void method_test_PSS_return(
>   	}
>
>   	/*
> +	 *  If we have some valid data then dump it out, it is useful to see
> +	 */
> +	if (dump_elements) {
> +		fwts_log_info_verbatum(fw, "P-State  Freq     Power  Latency   Bus Master");
> +		fwts_log_info_verbatum(fw, "         (MHz)    (mW)    (us)    Latency (us)");
> +		for (i = 0; i < obj->Package.Count; i++) {
> +			ACPI_OBJECT *pstate = &obj->Package.Elements[i];
> +			if (element_ok[i]) {
> +				fwts_log_info_verbatum(fw, " %3d   %7" PRIu64 " %8" PRIu64
> +					" %5" PRIu64 "     %5" PRIu64,
> +					i,
> +					pstate->Package.Elements[0].Integer.Value,
> +					pstate->Package.Elements[1].Integer.Value,
> +					pstate->Package.Elements[2].Integer.Value,
> +					pstate->Package.Elements[3].Integer.Value);
> +			} else {
> +				fwts_log_info_verbatum(fw,
> +					" %3d      ----    -----    --        -- (invalid)", i);
> +			}
> +		}
> +	}
> +
> +	free(element_ok);
> +
> +	/*
>   	 * Sanity check maximum frequency.  We could also check the DMI data
>   	 * for a BIOS date (but this can be wrong) or check the CPU identity
>   	 * (which requires adding in new CPU identity checks) to make a decision
>
Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox

Patch

diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
index 52b0e18..2dcbee0 100644
--- a/src/acpi/method/method.c
+++ b/src/acpi/method/method.c
@@ -1715,6 +1715,8 @@  static void method_test_PSS_return(
 	uint32_t max_freq = 0;
 	uint32_t prev_power = 0;
 	bool max_freq_valid = false;
+	bool dump_elements = false;
+	bool *element_ok;
 
 	FWTS_UNUSED(private);
 
@@ -1731,6 +1733,12 @@  static void method_test_PSS_return(
 		return;
 	}
 
+	element_ok = calloc(obj->Package.Count, sizeof(bool));
+	if (element_ok == NULL) {
+		fwts_log_error(fw, "Cannot allocate an array. Test aborted.");
+		return;
+	}
+
 	for (i = 0; i < obj->Package.Count; i++) {
 		ACPI_OBJECT *pstate;
 
@@ -1772,13 +1780,11 @@  static void method_test_PSS_return(
 			continue;
 		}
 
-		fwts_log_info(fw, "P-State %d: CPU %" PRIu64 " Mhz, %" PRIu64 " mW, "
-			"latency %" PRIu64 " us, bus master latency %" PRIu64 " us.",
-			i,
-			pstate->Package.Elements[0].Integer.Value,
-			pstate->Package.Elements[1].Integer.Value,
-			pstate->Package.Elements[2].Integer.Value,
-			pstate->Package.Elements[3].Integer.Value);
+		/*
+	 	 *  Parses OK, so this element can be dumped out
+		 */
+		element_ok[i] = true;
+		dump_elements = true;
 
 		/*
 		 * Collect maximum frequency.  The sub-packages are sorted in
@@ -1813,6 +1819,31 @@  static void method_test_PSS_return(
 	}
 
 	/*
+	 *  If we have some valid data then dump it out, it is useful to see
+	 */
+	if (dump_elements) {
+		fwts_log_info_verbatum(fw, "P-State  Freq     Power  Latency   Bus Master");
+		fwts_log_info_verbatum(fw, "         (MHz)    (mW)    (us)    Latency (us)");
+		for (i = 0; i < obj->Package.Count; i++) {
+			ACPI_OBJECT *pstate = &obj->Package.Elements[i];
+			if (element_ok[i]) {
+				fwts_log_info_verbatum(fw, " %3d   %7" PRIu64 " %8" PRIu64
+					" %5" PRIu64 "     %5" PRIu64,
+					i,
+					pstate->Package.Elements[0].Integer.Value,
+					pstate->Package.Elements[1].Integer.Value,
+					pstate->Package.Elements[2].Integer.Value,
+					pstate->Package.Elements[3].Integer.Value);
+			} else {
+				fwts_log_info_verbatum(fw,
+					" %3d      ----    -----    --        -- (invalid)", i);
+			}
+		}
+	}
+
+	free(element_ok);
+
+	/*
 	 * Sanity check maximum frequency.  We could also check the DMI data
 	 * for a BIOS date (but this can be wrong) or check the CPU identity
 	 * (which requires adding in new CPU identity checks) to make a decision