diff -Nru fwts-16.03.00/debian/changelog fwts-16.03.00/debian/changelog --- fwts-16.03.00/debian/changelog 2016-10-24 16:43:13.000000000 +0000 +++ fwts-16.03.00/debian/changelog 2018-08-10 09:06:12.000000000 +0000 @@ -1,3 +1,11 @@ +fwts (16.03.00-0ubuntu1.2) xenial; urgency=low + + * enable PM debug messages for S3 + S4 (LP: #1772563) + - kernels may have pm debug disabled, so force this on during S3/S4 + tests. Patches from upstream fwts + + -- Colin King Fri, 10 Aug 2018 10:06:12 +0100 + fwts (16.03.00-0ubuntu1.1) xenial; urgency=low * fix segment fault when running fwts method test (LP: #1635502) diff -Nru fwts-16.03.00/debian/patches/0010-lib-fwts_set-fix-API-for-fwts_set-add-fwts_set_int.patch fwts-16.03.00/debian/patches/0010-lib-fwts_set-fix-API-for-fwts_set-add-fwts_set_int.patch --- fwts-16.03.00/debian/patches/0010-lib-fwts_set-fix-API-for-fwts_set-add-fwts_set_int.patch 1970-01-01 00:00:00.000000000 +0000 +++ fwts-16.03.00/debian/patches/0010-lib-fwts_set-fix-API-for-fwts_set-add-fwts_set_int.patch 2018-08-10 08:35:53.000000000 +0000 @@ -0,0 +1,77 @@ +From 5c782e1abfca296d14a112629ebff35a162da132 Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Thu, 7 Jun 2018 15:05:51 +0100 +Subject: [PATCH] lib: fwts_set: fix API for fwts_set, add fwts_set_int +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +The fwts_set API has the args the wrong way around compared to +fwts_get, so swap these; fortunately it is not being used yet +in fwts, so this won't break anything. Also add fwts_set_int +to set integer values in /sys or /proc files. Finally, add +error checking in case the writes to the file fails. + +Signed-off-by: Colin Ian King +Acked-by: Alex Hung +Acked-by: Ivan Hu +--- + src/lib/include/fwts_set.h | 3 ++- + 1 files changed, 25 insertions(+), 4 deletions(-) + +Index: fwts-16.03.00/src/lib/include/fwts_set.h +=================================================================== +--- fwts-16.03.00.orig/src/lib/include/fwts_set.h ++++ fwts-16.03.00/src/lib/include/fwts_set.h +@@ -22,6 +22,7 @@ + + #include + +-int fwts_set(const char *text, const char *file); ++int fwts_set(const char *file, const char *text); ++int fwts_set_int(const char *file, const int value); + + #endif +Index: fwts-16.03.00/src/lib/src/fwts_set.c +=================================================================== +--- fwts-16.03.00.orig/src/lib/src/fwts_set.c ++++ fwts-16.03.00/src/lib/src/fwts_set.c +@@ -27,15 +27,35 @@ + * write text to a given file, used to set + * values in /sys or /proc + */ +-int fwts_set(const char *text, const char *file) ++int fwts_set(const char *file, const char *text) + { + FILE *fp; ++ int ret; + + if ((fp = fopen(file, "w")) == NULL) + return FWTS_ERROR; + +- fprintf(fp, "%s\n", text); +- fclose(fp); ++ ret = fprintf(fp, "%s\n", text); ++ (void)fclose(fp); + +- return FWTS_OK; ++ return (ret < 0) ? FWTS_ERROR : FWTS_OK; ++} ++ ++/* ++ * fwts_set_int() ++ * write an int to a given file, used to set ++ * values in /sys or /proc ++ */ ++int fwts_set_int(const char *file, const int value) ++{ ++ FILE *fp; ++ int ret; ++ ++ if ((fp = fopen(file, "w")) == NULL) ++ return FWTS_ERROR; ++ ++ ret = fprintf(fp, "%d\n", value); ++ (void)fclose(fp); ++ ++ return (ret < 0) ? FWTS_ERROR : FWTS_OK; + } diff -Nru fwts-16.03.00/debian/patches/0011-lib-add-small-helpers-top-get-set-sys-power-pm_debug.patch fwts-16.03.00/debian/patches/0011-lib-add-small-helpers-top-get-set-sys-power-pm_debug.patch --- fwts-16.03.00/debian/patches/0011-lib-add-small-helpers-top-get-set-sys-power-pm_debug.patch 1970-01-01 00:00:00.000000000 +0000 +++ fwts-16.03.00/debian/patches/0011-lib-add-small-helpers-top-get-set-sys-power-pm_debug.patch 2018-08-10 08:40:19.000000000 +0000 @@ -0,0 +1,125 @@ +From 196bbab2ca6bb1fa25cbb9865a425222162657a9 Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Thu, 7 Jun 2018 15:05:52 +0100 +Subject: [PATCH] lib: add small helpers top get/set + /sys/power/pm_debug_messages +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +This is required to twiddle this control sys entry for PM debugging +messages when going into S3 and S4. + +Signed-off-by: Colin Ian King +Acked-by: Alex Hung +Acked-by: Ivan Hu +--- + src/lib/include/fwts_pm_debug.h | 25 ++++++++++++++++++ + src/lib/src/fwts_pm_debug.c | 47 +++++++++++++++++++++++++++++++++ + 4 files changed, 74 insertions(+) + create mode 100644 src/lib/include/fwts_pm_debug.h + create mode 100644 src/lib/src/fwts_pm_debug.c + +Index: fwts-16.03.00/src/lib/include/fwts_pm_debug.h +=================================================================== +--- /dev/null ++++ fwts-16.03.00/src/lib/include/fwts_pm_debug.h +@@ -0,0 +1,25 @@ ++/* ++ * Copyright (C) 2013-2018 Canonical ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2 ++ * of the License, or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ * ++ */ ++#ifndef __FWTS_PM_DEBUG_H__ ++#define __FWTS_PM_DEBUG_H__ ++ ++int fwts_pm_debug_get(int *value); ++int fwts_pm_debug_set(const int value); ++ ++#endif +Index: fwts-16.03.00/src/lib/src/fwts_pm_debug.c +=================================================================== +--- /dev/null ++++ fwts-16.03.00/src/lib/src/fwts_pm_debug.c +@@ -0,0 +1,47 @@ ++/* ++ * Copyright (C) 2018 Canonical ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2 ++ * of the License, or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ * ++ */ ++ ++#include "fwts.h" ++ ++static const char pm_debug[] = "/sys/power/pm_debug_messages"; ++ ++/* ++ * fwts_pm_debug_get ++ * get the current pm_debug_messages setting, value ++ * is also set to -1 if there is an error ++ */ ++int fwts_pm_debug_get(int *value) ++{ ++ int ret; ++ ++ ret = fwts_get_int(pm_debug, value); ++ if (ret != FWTS_OK) ++ *value = -1; ++ ++ return ret; ++} ++ ++/* ++ * fwts_pm_debug_set ++ * set the pm_debug_messages setting ++ */ ++int fwts_pm_debug_set(const int value) ++{ ++ return fwts_set_int(pm_debug, value); ++} +Index: fwts-16.03.00/src/lib/include/fwts.h +=================================================================== +--- fwts-16.03.00.orig/src/lib/include/fwts.h ++++ fwts-16.03.00/src/lib/include/fwts.h +@@ -96,5 +96,6 @@ + #include "fwts_release.h" + #include "fwts_pci.h" + #include "fwts_safe_mem.h" ++#include "fwts_pm_debug.h" + + #endif +Index: fwts-16.03.00/src/lib/src/Makefile.am +=================================================================== +--- fwts-16.03.00.orig/src/lib/src/Makefile.am ++++ fwts-16.03.00/src/lib/src/Makefile.am +@@ -78,4 +78,5 @@ libfwts_la_SOURCES = \ + fwts_uefi.c \ + fwts_wakealarm.c \ + fwts_pm_method.c \ +- fwts_safe_mem.c ++ fwts_safe_mem.c \ ++ fwts_pm_debug.c diff -Nru fwts-16.03.00/debian/patches/0012-acpi-s3-force-enable-sys-power-pm_debug_messages-LP-.patch fwts-16.03.00/debian/patches/0012-acpi-s3-force-enable-sys-power-pm_debug_messages-LP-.patch --- fwts-16.03.00/debian/patches/0012-acpi-s3-force-enable-sys-power-pm_debug_messages-LP-.patch 1970-01-01 00:00:00.000000000 +0000 +++ fwts-16.03.00/debian/patches/0012-acpi-s3-force-enable-sys-power-pm_debug_messages-LP-.patch 2018-08-10 08:55:05.000000000 +0000 @@ -0,0 +1,52 @@ +From 58ab1c36048e53465e327950e0fc13d7025be3d4 Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Thu, 7 Jun 2018 15:05:53 +0100 +Subject: [PATCH] acpi: s3: force enable /sys/power/pm_debug_messages (LP: + #1772563) +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Some kernels may not have this set to 1 to get PM debug messages +for the S3 cycle, so force enable it on and then restore it back +after the test. + +Signed-off-by: Colin Ian King +Acked-by: Alex Hung +Acked-by: Ivan Hu +--- + src/acpi/s3/s3.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +Index: fwts-16.03.00/src/acpi/s3/s3.c +=================================================================== +--- fwts-16.03.00.orig/src/acpi/s3/s3.c ++++ fwts-16.03.00/src/acpi/s3/s3.c +@@ -438,6 +438,7 @@ static int s3_test_multiple(fwts_framewo + int resume_too_long = 0; + int awake_delay = s3_min_delay * 1000; + int delta = (int)(s3_delay_delta * 1000.0); ++ int pm_debug; + + #if FWTS_ENABLE_LOGIND + #if !GLIB_CHECK_VERSION(2,35,0) +@@ -446,6 +447,9 @@ static int s3_test_multiple(fwts_framewo + #endif + #endif + ++ (void)fwts_pm_debug_get(&pm_debug); ++ (void)fwts_pm_debug_set(1); ++ + if (s3_multiple == 1) + fwts_log_info(fw, "Defaulted to 1 test, use --s3-multiple=N to run more S3 cycles\n"); + +@@ -497,6 +501,10 @@ static int s3_test_multiple(fwts_framewo + } + } + ++ /* Restore pm debug value */ ++ if (pm_debug != -1) ++ (void)fwts_pm_debug_set(pm_debug); ++ + fwts_log_info(fw, "Completed %d S3 cycle(s)\n", s3_multiple); + + if (klog_errors > 0) diff -Nru fwts-16.03.00/debian/patches/0013-acpi-s4-also-check-for-file-based-swap-files.patch fwts-16.03.00/debian/patches/0013-acpi-s4-also-check-for-file-based-swap-files.patch --- fwts-16.03.00/debian/patches/0013-acpi-s4-also-check-for-file-based-swap-files.patch 1970-01-01 00:00:00.000000000 +0000 +++ fwts-16.03.00/debian/patches/0013-acpi-s4-also-check-for-file-based-swap-files.patch 2018-08-10 08:28:25.000000000 +0000 @@ -0,0 +1,34 @@ +From 69bf6c24fc947c03a6b2f80609e32e0440f37277 Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Thu, 7 Jun 2018 15:05:54 +0100 +Subject: [PATCH] acpi: s4: also check for file based swap files +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +The latest release of Ubuntu may be using file based swap +rather than raw device based swap, so check for this too. + +Signed-off-by: Colin Ian King +Acked-by: Alex Hung +Acked-by: Ivan Hu +--- + src/acpi/s4/s4.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/acpi/s4/s4.c b/src/acpi/s4/s4.c +index ec4a6f98..cf72851a 100644 +--- a/src/acpi/s4/s4.c ++++ b/src/acpi/s4/s4.c +@@ -46,7 +46,8 @@ static int s4_init(fwts_framework *fw) + fwts_list* swap_devs; + + swap_devs = fwts_file_open_and_read("/proc/swaps"); +- if (fwts_text_list_strstr(swap_devs, "/dev/") == NULL) { ++ if ((fwts_text_list_strstr(swap_devs, "/dev/") == NULL) && ++ (fwts_text_list_strstr(swap_devs, "file") == NULL)) { + fwts_list_free(swap_devs, free); + fwts_failed(fw, LOG_LEVEL_MEDIUM, "NoSwap", + "Cannot run hibernate test - machine appears to have NO swap."); +-- +2.17.1 + diff -Nru fwts-16.03.00/debian/patches/0014-acpi-s4-force-enable-sys-power-pm_debug_messages-LP-.patch fwts-16.03.00/debian/patches/0014-acpi-s4-force-enable-sys-power-pm_debug_messages-LP-.patch --- fwts-16.03.00/debian/patches/0014-acpi-s4-force-enable-sys-power-pm_debug_messages-LP-.patch 1970-01-01 00:00:00.000000000 +0000 +++ fwts-16.03.00/debian/patches/0014-acpi-s4-force-enable-sys-power-pm_debug_messages-LP-.patch 2018-08-10 08:28:25.000000000 +0000 @@ -0,0 +1,55 @@ +From 1307f3ff404e1b7c373d2751426278e68f8b4f44 Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Thu, 7 Jun 2018 15:05:55 +0100 +Subject: [PATCH] acpi: s4: force enable /sys/power/pm_debug_messages (LP: + #1772563) +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Some kernels may not have this set to 1 to get PM debug messages +for the S4 cycle, so force enable it on and then restore it back +after the test. + +Signed-off-by: Colin Ian King +Acked-by: Alex Hung +Acked-by: Ivan Hu +--- + src/acpi/s4/s4.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/src/acpi/s4/s4.c b/src/acpi/s4/s4.c +index cf72851a..2e458d3e 100644 +--- a/src/acpi/s4/s4.c ++++ b/src/acpi/s4/s4.c +@@ -365,6 +365,7 @@ static int s4_test_multiple(fwts_framework *fw) + int delta = (int)(s4_delay_delta * 1000.0); + int tracing_buffer_size = -1; + int ret = FWTS_OK; ++ int pm_debug; + bool retried = false; + + #if FWTS_ENABLE_LOGIND +@@ -374,6 +375,9 @@ static int s4_test_multiple(fwts_framework *fw) + #endif + #endif + ++ (void)fwts_pm_debug_get(&pm_debug); ++ (void)fwts_pm_debug_set(1); ++ + if (s4_multiple == 1) + fwts_log_info(fw, "Defaulted to run 1 test, run --s4-multiple=N to run more S4 cycles\n"); + +@@ -450,6 +454,10 @@ static int s4_test_multiple(fwts_framework *fw) + } + } + ++ /* Restore pm debug value */ ++ if (pm_debug != -1) ++ (void)fwts_pm_debug_set(pm_debug); ++ + if (tracing_buffer_size > 0) { + char tmp[32]; + +-- +2.17.1 + diff -Nru fwts-16.03.00/debian/patches/0015-acpi-s3power-force-enable-sys-power-pm_debug_message.patch fwts-16.03.00/debian/patches/0015-acpi-s3power-force-enable-sys-power-pm_debug_message.patch --- fwts-16.03.00/debian/patches/0015-acpi-s3power-force-enable-sys-power-pm_debug_message.patch 1970-01-01 00:00:00.000000000 +0000 +++ fwts-16.03.00/debian/patches/0015-acpi-s3power-force-enable-sys-power-pm_debug_message.patch 2018-08-10 08:28:25.000000000 +0000 @@ -0,0 +1,51 @@ +From 312e5e8c922323676659f6ef541b78af5ed6e615 Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Thu, 7 Jun 2018 15:05:56 +0100 +Subject: [PATCH] acpi: s3power: force enable /sys/power/pm_debug_messages (LP: + #1772563) +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Some kernels may not have this set to 1 to get PM debug messages +for the S3 cycle, so force enable it on and then restore it back +after the test. + +Signed-off-by: Colin Ian King +Acked-by: Alex Hung +Acked-by: Ivan Hu +--- + src/acpi/s3power/s3power.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/src/acpi/s3power/s3power.c b/src/acpi/s3power/s3power.c +index b63c8d28..c20b3b8f 100644 +--- a/src/acpi/s3power/s3power.c ++++ b/src/acpi/s3power/s3power.c +@@ -243,6 +243,7 @@ static int s3power_test(fwts_framework *fw) + int status; + int duration; + int rc = FWTS_OK; ++ int pm_debug; + + bool offline; + +@@ -315,9 +316,16 @@ static int s3power_test(fwts_framework *fw) + + fwts_wakealarm_trigger(fw, s3power_sleep_delay); + ++ (void)fwts_pm_debug_get(&pm_debug); ++ (void)fwts_pm_debug_set(1); ++ + /* Do S3 here */ + status = do_suspend(fwts_settings, 100, &duration, PM_SUSPEND); + ++ /* Restore pm debug value */ ++ if (pm_debug != -1) ++ (void)fwts_pm_debug_set(pm_debug); ++ + s3power_get_remaining_capacity(fw, &capacity_after_mAh, &capacity_after_mWh); + + s3power_difference(fw, capacity_before_mAh, capacity_after_mAh, battery_capacity_mAh, "mAh"); +-- +2.17.1 + diff -Nru fwts-16.03.00/debian/patches/0016-cpufreq-fix-fwts_set-paths.patch fwts-16.03.00/debian/patches/0016-cpufreq-fix-fwts_set-paths.patch --- fwts-16.03.00/debian/patches/0016-cpufreq-fix-fwts_set-paths.patch 1970-01-01 00:00:00.000000000 +0000 +++ fwts-16.03.00/debian/patches/0016-cpufreq-fix-fwts_set-paths.patch 2018-08-10 08:28:25.000000000 +0000 @@ -0,0 +1,47 @@ +From b1593c337b44056d9202b6fb34aef5b72f8f1ded Mon Sep 17 00:00:00 2001 +From: Robert Elliott +Date: Fri, 6 Jul 2018 09:41:06 -0500 +Subject: [PATCH] cpufreq: fix fwts_set paths +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Commit 5c782e1abfca ("lib: fwts_set: fix API for fwts_set, add fwts_set_int") +swapped the fwts_set() path and data arguments, resulting in the +cpufreq test creating these weird filenames, each containing the path +to the file it intended to write: +-rw-r--r--. 1 root root 55 Jul 3 15:14 'performance'$'\n' +-rw-r--r--. 1 root root 54 Jul 3 15:14 userspace + +Fixes: 5c782e1abfca ("lib: fwts_set: fix API for fwts_set, add fwts_set_int") +Signed-off-by: Robert Elliott +Acked-by: Alex Hung +Acked-by: Colin Ian King +--- + src/cpu/cpufreq/cpufreq.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c +index a65b9d08..ac8ce864 100644 +--- a/src/cpu/cpufreq/cpufreq.c ++++ b/src/cpu/cpufreq/cpufreq.c +@@ -95,7 +95,7 @@ static int cpu_set_governor(fwts_framework *fw, struct cpu *cpu, + int rc; + + cpu_mkpath(path, sizeof(path), cpu, "scaling_governor"); +- rc = fwts_set(governor, path); ++ rc = fwts_set(path, governor); + if (rc != FWTS_OK) + goto out; + +@@ -120,7 +120,7 @@ static int cpu_set_frequency(fwts_framework *fw, struct cpu *cpu, + + cpu_mkpath(path, sizeof(path), cpu, "scaling_setspeed"); + snprintf(buffer, sizeof(buffer), "%" PRIu64 , freq_hz); +- rc = fwts_set(buffer, path); ++ rc = fwts_set(path, buffer); + if (rc != FWTS_OK) + goto out; + +-- +2.17.1 + diff -Nru fwts-16.03.00/debian/patches/series fwts-16.03.00/debian/patches/series --- fwts-16.03.00/debian/patches/series 2016-10-24 16:29:17.000000000 +0000 +++ fwts-16.03.00/debian/patches/series 2018-08-10 08:56:59.000000000 +0000 @@ -1 +1,8 @@ 0001-fwts_acpica-fix-segmentation-fault-by-unlock-mutex-t.patch +0010-lib-fwts_set-fix-API-for-fwts_set-add-fwts_set_int.patch +0011-lib-add-small-helpers-top-get-set-sys-power-pm_debug.patch +0012-acpi-s3-force-enable-sys-power-pm_debug_messages-LP-.patch +0013-acpi-s4-also-check-for-file-based-swap-files.patch +0014-acpi-s4-force-enable-sys-power-pm_debug_messages-LP-.patch +0015-acpi-s3power-force-enable-sys-power-pm_debug_message.patch +0016-cpufreq-fix-fwts_set-paths.patch