From patchwork Fri Feb 8 03:23:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1038462 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43wgWK4jjKz9sBZ; Fri, 8 Feb 2019 14:23:41 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1grwlO-0004Tx-UY; Fri, 08 Feb 2019 03:23:38 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1grwlN-0004TX-6y for fwts-devel@lists.ubuntu.com; Fri, 08 Feb 2019 03:23:37 +0000 Received: from 1.general.alexhung.us.vpn ([10.172.65.254] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1grwlM-0003f7-KE; Fri, 08 Feb 2019 03:23:37 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH 07/14] acpi/method: add tests for NVDIMM control methods for ACPI 6.3 Date: Thu, 7 Feb 2019 19:23:07 -0800 Message-Id: <20190208032314.15215-8-alex.hung@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190208032314.15215-1-alex.hung@canonical.com> References: <20190208032314.15215-1-alex.hung@canonical.com> X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" Including _NBS, _NCH (mantis 1893), _NIC, _NIH and _NIC (mantis 1913) Signed-off-by: Alex Hung --- src/acpi/method/method.c | 286 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 286 insertions(+) diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c index 654112d9..f117d91d 100644 --- a/src/acpi/method/method.c +++ b/src/acpi/method/method.c @@ -138,6 +138,11 @@ * _MSG Y * _MSM N * _MTL Y + * _NBS Y + * _NCH Y + * _NIC Y + * _NIH Y + * _NIG Y * _NTT Y * _OFF Y * _ON_ Y @@ -3574,6 +3579,280 @@ static int method_test_TIV(fwts_framework *fw) "_TIV", arg, 1, fwts_method_test_integer_return, NULL); } +/* + * Section 9.20 NVDIMM Devices + */ +static void check_nvdimm_status( + fwts_framework *fw, + char *name, + uint16_t status, + bool *failed) +{ + if (status > 6) { + *failed = true; + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "MethodBadStatus", + "%s: Expected Status to be 0..6, got %" PRIx16, + name, status); + } +} + +static void check_nvdimm_extended_status( + fwts_framework *fw, + char *name, + uint16_t ext_status, + uint16_t expected, + bool *failed) +{ + if (ext_status != expected) { + *failed = true; + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "MethodBadExtendedStatus", + "%s: Expected Extended Status to be %" PRIx16 + ", got %" PRIx16, name, expected, ext_status); + } +} + +static void method_test_NBS_return( + fwts_framework *fw, + char *name, + ACPI_BUFFER *buf, + ACPI_OBJECT *obj, + void *private) +{ + bool failed = false; + uint8_t *data; + + FWTS_UNUSED(private); + + if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK) + return; + + if (obj->Buffer.Length != 64) { + failed = true; + fwts_failed(fw, LOG_LEVEL_CRITICAL, + "Method_NBSBadBufferSize", + "%s should return a buffer of 64 bytes, but " + "instead just returned %" PRIu32, + name, obj->Buffer.Length); + } + + data = (uint8_t*)obj->Buffer.Pointer; + check_nvdimm_status(fw, name, (uint16_t) data[0], &failed); + check_nvdimm_extended_status(fw, name, (uint16_t) data[2], 0, &failed); + fwts_acpi_reserved_bits_check(fw, "_NBS", "Validation Flags", (uint16_t) data[4], sizeof(uint16_t), 1, 15, &failed); + + if (!failed) + fwts_method_passed_sane(fw, name, "buffer"); +} + +static int method_test_NBS(fwts_framework *fw) +{ + return method_evaluate_method(fw, METHOD_OPTIONAL, + "_NBS", NULL, 0, method_test_NBS_return, NULL); +} + +static void method_test_NCH_return( + fwts_framework *fw, + char *name, + ACPI_BUFFER *buf, + ACPI_OBJECT *obj, + void *private) +{ + bool failed = false; + uint8_t *data; + + FWTS_UNUSED(private); + + if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK) + return; + + if (obj->Buffer.Length != 64) { + failed = true; + fwts_failed(fw, LOG_LEVEL_CRITICAL, + "Method_NCHBadBufferSize", + "%s should return a buffer of 64 bytes, but " + "instead just returned %" PRIu32, + name, obj->Buffer.Length); + } + + data = (uint8_t*)obj->Buffer.Pointer; + check_nvdimm_status(fw, name, (uint16_t) data[0], &failed); + check_nvdimm_extended_status(fw, name, (uint16_t) data[2], 0, &failed); + fwts_acpi_reserved_bits_check(fw, "_NCH", "Validation Flags", (uint16_t) data[4], sizeof(uint16_t), 2, 15, &failed); + + /* Health Status Flags [2..7], [11.15], [19..31] are reserved */ + fwts_acpi_reserved_bits_check(fw, "_NCH", "Health Status Flags", (uint32_t) data[6], sizeof(uint32_t), 2, 7, &failed); + fwts_acpi_reserved_bits_check(fw, "_NCH", "Health Status Flags", (uint32_t) data[6], sizeof(uint32_t), 11, 15, &failed); + fwts_acpi_reserved_bits_check(fw, "_NCH", "Health Status Flags", (uint32_t) data[6], sizeof(uint32_t), 19, 31, &failed); + + fwts_acpi_reserved_bits_check(fw, "_NCH", "Health Status Attributes", (uint32_t) data[10], sizeof(uint32_t), 1, 31, &failed); + + if (!failed) + fwts_method_passed_sane(fw, name, "buffer"); +} + +static int method_test_NCH(fwts_framework *fw) +{ + return method_evaluate_method(fw, METHOD_OPTIONAL, + "_NCH", NULL, 0, method_test_NCH_return, NULL); +} + +static void method_test_NIC_return( + fwts_framework *fw, + char *name, + ACPI_BUFFER *buf, + ACPI_OBJECT *obj, + void *private) +{ + bool failed = false; + uint8_t *data; + + FWTS_UNUSED(private); + + if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK) + return; + + if (obj->Buffer.Length != 64) { + failed = true; + fwts_failed(fw, LOG_LEVEL_CRITICAL, + "Method_NICBadBufferSize", + "%s should return a buffer of 64 bytes, but " + "instead just returned %" PRIu32, + name, obj->Buffer.Length); + } + + data = (uint8_t*)obj->Buffer.Pointer; + check_nvdimm_status(fw, name, (uint16_t)data[0], &failed); + check_nvdimm_extended_status(fw, name, (uint16_t)data[2], 0, &failed); + + /* Health Error Injection Capabilities [2..7], [11.15], [19..31] are reserved */ + fwts_acpi_reserved_bits_check(fw, "_NIC", "Health Error Injection Capabilities", (uint32_t) data[4], sizeof(uint32_t), 2, 7, &failed); + fwts_acpi_reserved_bits_check(fw, "_NIC", "Health Error Injection Capabilities", (uint32_t) data[4], sizeof(uint32_t), 11, 15, &failed); + fwts_acpi_reserved_bits_check(fw, "_NIC", "Health Error Injection Capabilities", (uint32_t) data[4], sizeof(uint32_t), 19, 31, &failed); + + fwts_acpi_reserved_bits_check(fw, "_NIC", "Health Status Attributes Capabilities", (uint32_t) data[8], sizeof(uint32_t), 1, 31, &failed); + + if (!failed) + fwts_method_passed_sane(fw, name, "buffer"); +} + +static int method_test_NIC(fwts_framework *fw) +{ + return method_evaluate_method(fw, METHOD_OPTIONAL, + "_NIC", NULL, 0, method_test_NIC_return, NULL); +} + +static void method_test_NIH_return( + fwts_framework *fw, + char *name, + ACPI_BUFFER *buf, + ACPI_OBJECT *obj, + void *private) +{ + bool failed = false; + uint8_t *data; + + FWTS_UNUSED(private); + + if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK) + return; + + if (obj->Buffer.Length != 64) { + failed = true; + fwts_failed(fw, LOG_LEVEL_CRITICAL, + "Method_NIHBadBufferSize", + "%s should return a buffer of 64 bytes, but " + "instead just returned %" PRIu32, + name, obj->Buffer.Length); + } + + data = (uint8_t*)obj->Buffer.Pointer; + check_nvdimm_status(fw, name, (uint16_t) data[0], &failed); + check_nvdimm_extended_status(fw, name, (uint16_t) data[2], 1, &failed); + + if (!failed) + fwts_method_passed_sane(fw, name, "buffer"); +} + +static int method_test_NIH(fwts_framework *fw) +{ + ACPI_OBJECT arg0; + char data[64]; + int result; + int i, j; + + memset(data, 0, sizeof(data)); + arg0.Type = ACPI_TYPE_BUFFER; + arg0.Buffer.Length = 64; + arg0.Buffer.Pointer = (void *)data; + + /* not permanent (j = 0) and permanent (j = 1) errors */ + for (j = 0; j <= 1; j++) { + /* inject (i = 1) and clear (i = 2) errors */ + for (i = 1; i <= 2; i++) { + data[0] = i; + data[4] = 3; + data[5] = 7; + data[6] = 7; + data[8] = j; + + result = method_evaluate_method(fw, METHOD_OPTIONAL, + "_NIH", &arg0, 1, method_test_NIH_return, NULL); + + if (result != FWTS_OK) + return result; + } + } + + return FWTS_OK; +} + +static void method_test_NIG_return( + fwts_framework *fw, + char *name, + ACPI_BUFFER *buf, + ACPI_OBJECT *obj, + void *private) +{ + bool failed = false; + uint8_t *data; + + FWTS_UNUSED(private); + + if (fwts_method_check_type(fw, name, buf, ACPI_TYPE_BUFFER) != FWTS_OK) + return; + + if (obj->Buffer.Length != 64) { + failed = true; + fwts_failed(fw, LOG_LEVEL_CRITICAL, + "Method_NIGBadBufferSize", + "%s should return a buffer of 64 bytes, but " + "instead just returned %" PRIu32, + name, obj->Buffer.Length); + } + + data = (uint8_t*)obj->Buffer.Pointer; + check_nvdimm_status(fw, name, (uint16_t)data[0], &failed); + check_nvdimm_extended_status(fw, name, (uint16_t)data[2], 0, &failed); + fwts_acpi_reserved_bits_check(fw, "_NIG", "Validation Flags", (uint16_t) data[4], sizeof(uint16_t), 2, 15, &failed); + + /* Injected Health Status Errors [2..7], [11.15], [19..31] are reserved */ + fwts_acpi_reserved_bits_check(fw, "_NIG", "Injected Health Status Errors", (uint32_t) data[6], sizeof(uint32_t), 2, 7, &failed); + fwts_acpi_reserved_bits_check(fw, "_NIG", "Injected Health Status Errors", (uint32_t) data[6], sizeof(uint32_t), 11, 15, &failed); + fwts_acpi_reserved_bits_check(fw, "_NIG", "Injected Health Status Errors", (uint32_t) data[6], sizeof(uint32_t), 19, 31, &failed); + + fwts_acpi_reserved_bits_check(fw, "_NIG", "Health Status Attributes of Injected Errors", (uint32_t) data[8], sizeof(uint32_t), 1, 31, &failed); + + if (!failed) + fwts_method_passed_sane(fw, name, "buffer"); +} + +static int method_test_NIG(fwts_framework *fw) +{ + return method_evaluate_method(fw, METHOD_OPTIONAL, + "_NIG", NULL, 0, method_test_NIG_return, NULL); +} /* * Section 10.1 Smart Battery @@ -5896,6 +6175,13 @@ static fwts_framework_minor_test method_tests[] = { { method_test_TIP, "Test _TIP (Expired Timer Wake Policy)." }, { method_test_TIV, "Test _TIV (Timer Values)." }, + /* Section 9.20 NVDIMM Devices */ + { method_test_NBS, "Test _NBS (NVDIMM Boot Status)." }, + { method_test_NCH, "Test _NCH (NVDIMM Current Health Information)." }, + { method_test_NIC, "Test _NIC (NVDIMM Health Error Injection Capabilities)." }, + { method_test_NIH, "Test _NIH (NVDIMM Inject/Clear Health Errors)." }, + { method_test_NIG, "Test _NIG (NVDIMM Inject Health Error Status)." }, + /* Section 10.1 Smart Battery */ { method_test_SBS, "Test _SBS (Smart Battery Subsystem)." },