From patchwork Wed Apr 18 11:41:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 153480 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 2878DB6F9A for ; Wed, 18 Apr 2012 21:41:21 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SKTGC-0000Yt-0e for incoming@patchwork.ozlabs.org; Wed, 18 Apr 2012 11:41:20 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SKTG4-0000YY-Gs for fwts-devel@lists.ubuntu.com; Wed, 18 Apr 2012 11:41:12 +0000 Received: from cpc19-craw6-2-0-cust5.croy.cable.virginmedia.com ([77.102.228.6] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1SKTG4-0000AM-0c for fwts-devel@lists.ubuntu.com; Wed, 18 Apr 2012 11:41:12 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 2/2] acpi: method: add _PSS test Date: Wed, 18 Apr 2012 12:41:09 +0100 Message-Id: <1334749269-31162-3-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1334749269-31162-1-git-send-email-colin.king@canonical.com> References: <1334749269-31162-1-git-send-email-colin.king@canonical.com> X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: fwts-devel-bounces@lists.ubuntu.com Errors-To: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King Signed-off-by: Colin Ian King Acked-by: Alex Hung --- src/acpi/method/method.c | 106 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 2 deletions(-) diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c index 6797868..fae4b31 100644 --- a/src/acpi/method/method.c +++ b/src/acpi/method/method.c @@ -102,7 +102,7 @@ * _PSD 8.4.4.5 N * _PSL 11.4.8 N * _PSR 10.3.1 Y - * _PSS 8.4.4.2 N + * _PSS 8.4.4.2 Y * _PSV 11.4.9 Y * _PSW 7.2.12 Y * _PTC 8.4.3.1 N @@ -307,7 +307,7 @@ static int method_name_check(fwts_framework *fw) int failed = 0; if ((methods = fwts_method_get_names()) != NULL) { - fwts_log_info(fw, "Found %d Methods\n", methods->len); + fwts_log_info(fw, "Found %d Objects\n", methods->len); fwts_list_foreach(item, methods) { char *ptr; @@ -1846,6 +1846,105 @@ static int method_test_UID(fwts_framework *fw) } +/* Section 8.4 */ + +static void method_test_PSS_return(fwts_framework *fw, char *name, ACPI_BUFFER *buf, ACPI_OBJECT *obj, void *private) +{ + int i; + bool failed = false; + uint32_t max_freq = 0; + uint32_t prev_power = 0; + + if (method_check_type(fw, name, buf, ACPI_TYPE_PACKAGE) != FWTS_OK) + return; + + /* Something is really wrong if we don't have any elements in _PSS */ + if (obj->Package.Count < 1) { + fwts_failed(fw, LOG_LEVEL_MEDIUM, "Method_PSSElementCount", + "_PSS should return package of at least 1 element, " + "got %d elements instead.", + obj->Package.Count); + fwts_tag_failed(fw, FWTS_TAG_ACPI_METHOD_RETURN); + return; + } + + for (i=0; i < obj->Package.Count; i++) { + ACPI_OBJECT *pstate; + + if (obj->Package.Elements[i].Type != ACPI_TYPE_PACKAGE) { + fwts_failed(fw, LOG_LEVEL_MEDIUM, "Method_PSSElementType", + "_PSS package element %d was not a package.", i); + fwts_tag_failed(fw, FWTS_TAG_ACPI_METHOD_RETURN); + failed = true; + continue; /* Skip processing sub-package */ + } + + pstate = &obj->Package.Elements[i]; + if (pstate->Package.Count != 6) { + fwts_failed(fw, LOG_LEVEL_MEDIUM, "Method_PSSSubPackageElementCount", + "_PSS P-State sub-package %d was expected to have " + "6 elements, got %d elements instead.", + i, obj->Package.Count); + fwts_tag_failed(fw, FWTS_TAG_ACPI_METHOD_RETURN); + failed = true; + continue; /* Skip processing sub-package */ + } + + /* Elements need to be all ACPI integer types */ + if ((pstate->Package.Elements[0].Type != ACPI_TYPE_INTEGER) || + (pstate->Package.Elements[1].Type != ACPI_TYPE_INTEGER) || + (pstate->Package.Elements[2].Type != ACPI_TYPE_INTEGER) || + (pstate->Package.Elements[3].Type != ACPI_TYPE_INTEGER) || + (pstate->Package.Elements[4].Type != ACPI_TYPE_INTEGER) || + (pstate->Package.Elements[5].Type != ACPI_TYPE_INTEGER)) { + fwts_failed(fw, LOG_LEVEL_MEDIUM, "Method_PSSSubPackageElementType", + "_PSS P-State sub-package %d was expected to have " + "6 Integer elements but didn't", i); + failed = true; + continue; + } + + fwts_log_info(fw, "PState %d: CPU %ld Mhz, %lu mW, latency %lu us, bus master latency %lu us.", + i, + (unsigned long)pstate->Package.Elements[0].Integer.Value, + (unsigned long)pstate->Package.Elements[1].Integer.Value, + (unsigned long)pstate->Package.Elements[2].Integer.Value, + (unsigned long)pstate->Package.Elements[3].Integer.Value); + + if (max_freq < pstate->Package.Elements[0].Integer.Value) + max_freq = pstate->Package.Elements[0].Integer.Value; + + /* Sanity check descending power dissipation levels */ + if ((i > 0) && (prev_power != 0) && + (pstate->Package.Elements[1].Integer.Value >= prev_power)) { + fwts_failed(fw, LOG_LEVEL_MEDIUM, "Method_PSSSubPackagePowerNotDecending", + "_PSS P-State sub-package %d has a larger power dissipation " + "setting than the previous sub-package.", i); + fwts_advice(fw, "_PSS P-States must be ordered in decending order of " + "power dissipation, so that the zero'th entry has the highest " + "power dissipation level and the Nth has the lowest."); + failed = true; + } + prev_power = pstate->Package.Elements[1].Integer.Value; + } + + if (max_freq < 1000) { + fwts_warning(fw, + "Maximum CPU frequency is %dHz and this is low for " + "a modern processor. This may indicate the _PSS PStates " + "are incorrect\n", max_freq); + failed = true; + } + + if (!failed) + fwts_passed(fw, "_PSS correctly returned sane looking package."); +} + +static int method_test_PSS(fwts_framework *fw) +{ + return method_evaluate_method(fw, METHOD_OPTIONAL, "_PSS", NULL, 0, method_test_PSS_return, NULL); +} + /* Tests */ static fwts_framework_minor_test method_tests[] = { @@ -1973,6 +2072,9 @@ static fwts_framework_minor_test method_tests[] = { { method_test_ON, "Check _ON (Set resource on)." }, { method_test_OFF, "Check _OFF (Set resource off)." }, + /* Section 8.4 */ + { method_test_PSS, "Check _PSS (Performance Supported States)." }, + /* Appendix B, ACPI Extensions for Display Adapters */ { method_test_DOS, "Check _DOS (Enable/Disable Output Switching)." },