From patchwork Fri Nov 19 09:20:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 1557011 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=WHCNg1On; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HwWNh0h0Mz9sPf for ; Fri, 19 Nov 2021 20:20:35 +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 1mo04N-0005S3-Gt; Fri, 19 Nov 2021 09:20:31 +0000 Received: from smtp-relay-canonical-0.internal ([10.131.114.83] helo=smtp-relay-canonical-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mo04L-0005Rw-Q9 for fwts-devel@lists.ubuntu.com; Fri, 19 Nov 2021 09:20:29 +0000 Received: from canonical.com (unknown [175.182.108.103]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 9870B3F1A4 for ; Fri, 19 Nov 2021 09:20:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1637313629; bh=2L0UjUkl7O04sZKVd1CvXtQBFesy0zM7hswl19W6gFs=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=WHCNg1OnMJqp4FFGZIZB5b4m6FBLEmK5OGAu2pooetQAY+6ufu29opZlDTfAg2Z8G w29Ei2GW9vrx51mJ2JoMqmdBIKlQgnQ8BegnHd09+ND+5jeTJCvcD4z+fR8EByYBTK KZ+LNL8gbmD1xc9Wjwa1J4Wxd8lHwc2NYE2Clf0V6C6XArNy0AZcstu9nKda5wiXFk N/fzwBldXRzRs39aQ3sdRM9Xt2Wn9AEs9Ve11c0wZKsJ2JQa/IBtbIPyvRSIq2XXPd q3k5yrZP4eXMB/X+Has61/o9k+wNLbyqVSigBX8FoISEAWGNZw54rhd8vSoaVvTslV X5qeYpnPB2TEA== From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH] s3: add sleep type setting for testing with s3 or s2idle Date: Fri, 19 Nov 2021 17:20:25 +0800 Message-Id: <20211119092025.11861-1-ivan.hu@canonical.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" Add s3-sleep-type for select test with s3 or s2idle. i.e. fwts s3 --s3-sleep-type=s2idle If sleep type is not specified, test with s3 by default. And it will restore system sleep type settings after testing. Signed-off-by: Ivan Hu Acked-by: Alex Hung --- src/acpi/s3/s3.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/acpi/s3/s3.c b/src/acpi/s3/s3.c index fd47c861..d77108a1 100644 --- a/src/acpi/s3/s3.c +++ b/src/acpi/s3/s3.c @@ -36,6 +36,7 @@ #define PM_S2IDLE_SLP_S0 "/sys/kernel/debug/pmc_core/slp_s0_residency_usec" static char sleep_type[7]; +static char sleep_type_orig[7]; static int s3_multiple = 1; /* number of s3 multiple tests to run */ static int s3_min_delay = 0; /* min time between resume and next suspend */ @@ -50,6 +51,7 @@ static float s3_suspend_time = 15.0; /* Maximum allowed suspend time */ static float s3_resume_time = 15.0; /* Maximum allowed resume time */ static bool s3_hybrid = false; static char *s3_hook = NULL; /* Hook to run after each S3 */ +static char *s3_sleep_type = NULL; /* The sleep type(s3 or s2idle) */ static int s3_init(fwts_framework *fw) { @@ -66,6 +68,22 @@ static int s3_init(fwts_framework *fw) return FWTS_ERROR; } + str = fwts_get(PM_SUSPEND_PATH); + if (str && strstr(str, "[s2idle]")) { + strncpy(sleep_type_orig, "s2idle", strlen("s2idle") + 1); + free(str); + } else { + strncpy(sleep_type_orig, "deep", strlen("deep") + 1); + } + + if (!s3_sleep_type) { + if (fwts_set(PM_SUSPEND_PATH, "deep") != FWTS_OK) + fwts_log_error(fw, "Cannot set the sleep type to S3(deep), test with default type."); + } else { + if (fwts_set(PM_SUSPEND_PATH, s3_sleep_type) != FWTS_OK) + fwts_log_error(fw, "Cannot set the sleep type to %s, test with default type.", s3_sleep_type); + } + str = fwts_get(PM_SUSPEND_PATH); if (str && strstr(str, "[s2idle]")) { strncpy(sleep_type, "s2idle", strlen("s2idle") + 1); @@ -77,6 +95,15 @@ static int s3_init(fwts_framework *fw) return FWTS_OK; } +static int s3_deinit(fwts_framework *fw) +{ + + FWTS_UNUSED(fw); + (void)fwts_set(PM_SUSPEND_PATH, sleep_type_orig); + + return FWTS_OK; +} + /* * s3_hook_exec() * run a given hook script @@ -808,6 +835,9 @@ static int s3_options_handler(fwts_framework *fw, int argc, char * const argv[], case 11: s3_hook = optarg; break; + case 12: + s3_sleep_type = optarg; + break; } } return FWTS_OK; @@ -826,6 +856,7 @@ static fwts_option s3_options[] = { { "s3-resume-time", "", 1, "Maximum expected resume time in seconds, e.g. --s3-resume-time=5.1" }, { "s3-hybrid", "", 0, "Run S3 with hybrid sleep, i.e. saving system states as S4 does." }, { "s3-resume-hook hook","", 1, "Run a hook script after each S3 resume, 0 exit indicates success." }, + { "s3-sleep-type" ,"", 1, "Set the sleep type for testing S3 or s2idle, default S3." }, { NULL, NULL, 0, NULL } }; @@ -837,6 +868,7 @@ static fwts_framework_minor_test s3_tests[] = { static fwts_framework_ops s3_ops = { .description = "Sleep suspend/resume test.", .init = s3_init, + .deinit = s3_deinit, .minor_tests = s3_tests, .options = s3_options, .options_handler = s3_options_handler,