From be18c0b0e8cb2d2012c905e73c8dd159e950f5b3 Mon Sep 17 00:00:00 2001 From: Mary Ruthven Date: Thu, 11 Nov 2021 11:32:48 -0600 Subject: Revert "common: Add uptime host command" This reverts commit af51b9ea19c0ba4c6d57cdc4c5f3380647be3034. BUG=b:200823466 TEST=make buildall -j Change-Id: Ib620967f239dd2ee3fdd0f4749d08bd544509fcb Signed-off-by: Mary Ruthven Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3285747 Reviewed-by: Vadim Sukhomlinov --- common/build.mk | 1 - common/chipset.c | 38 +++++++++++++++++++-------- common/uptime.c | 42 ------------------------------ include/chipset.h | 21 --------------- include/common.h | 2 -- include/config.h | 3 --- test/build.mk | 2 -- test/uptime.c | 73 ---------------------------------------------------- test/uptime.tasklist | 10 ------- 9 files changed, 27 insertions(+), 165 deletions(-) delete mode 100644 common/uptime.c delete mode 100644 test/uptime.c delete mode 100644 test/uptime.tasklist diff --git a/common/build.mk b/common/build.mk index 8f40ef963b..cd244b3bab 100644 --- a/common/build.mk +++ b/common/build.mk @@ -69,7 +69,6 @@ common-$(CONFIG_FLASH_NVMEM_VARS)+=nvmem_vars.o common-$(CONFIG_FMAP)+=fmap.o common-$(CONFIG_GESTURE_SW_DETECTION)+=gesture.o common-$(CONFIG_HOSTCMD_EVENTS)+=host_event_commands.o -common-$(CONFIG_HOSTCMD_GET_UPTIME_INFO)+=uptime.o common-$(CONFIG_HOSTCMD_RTC)+=rtc.o common-$(CONFIG_I2C_DEBUG)+=i2c_trace.o common-$(CONFIG_I2C_CONTROLLER)+=i2c_controller.o diff --git a/common/chipset.c b/common/chipset.c index 22f7c31b79..9791aeb93b 100644 --- a/common/chipset.c +++ b/common/chipset.c @@ -78,28 +78,44 @@ void report_ap_reset(enum chipset_shutdown_reason reason) mutex_unlock(&reset_log_mutex); } -test_mockable enum ec_error_list -get_ap_reset_stats(struct ap_reset_log_entry *reset_log_entries, - size_t num_reset_log_entries, uint32_t *resets_since_ec_boot) +static int host_command_get_uptime_info(struct host_cmd_handler_args *args) { - size_t log_address; - size_t i; + /* + * In the current implementation, not all terms are preserved across a + * sysjump. Future implementations may preserve additional information. + * + * time_since_ec_boot_ms: preserved, but wraps at ~50 days + * ec_reset_flags: preserved, with 'sysjump' added + * ap_resets_since_ec_boot: Not preserved + * recent_ap_reset[*]: Not preserved + */ + struct ec_response_uptime_info *r = args->response; + timestamp_t now = get_time(); + uint32_t now_ms = (uint32_t)(now.val / MSEC); + size_t log_address = 0; + size_t i = 0; + + r->time_since_ec_boot_ms = now_ms; + r->ec_reset_flags = system_get_reset_flags(); - if (reset_log_entries == NULL || resets_since_ec_boot == NULL) - return EC_ERROR_INVAL; + memset(r->recent_ap_reset, 0, sizeof(r->recent_ap_reset)); mutex_lock(&reset_log_mutex); - *resets_since_ec_boot = ap_resets_since_ec_boot; + r->ap_resets_since_ec_boot = ap_resets_since_ec_boot; for (i = 0; - i != ARRAY_SIZE(reset_logs) && i != num_reset_log_entries; + i != ARRAY_SIZE(reset_logs) && i != ARRAY_SIZE(r->recent_ap_reset); ++i) { log_address = (next_reset_log + i) & (ARRAY_SIZE(reset_logs) - 1); - reset_log_entries[i] = reset_logs[log_address]; + r->recent_ap_reset[i] = reset_logs[log_address]; } mutex_unlock(&reset_log_mutex); - return EC_SUCCESS; + args->response_size = sizeof(*r); + return EC_RES_SUCCESS; } +DECLARE_HOST_COMMAND(EC_CMD_GET_UPTIME_INFO, + host_command_get_uptime_info, + EC_VER_MASK(0)); #endif /* !CONFIG_AP_RESET_LOG */ diff --git a/common/uptime.c b/common/uptime.c deleted file mode 100644 index 2fdd8bdb19..0000000000 --- a/common/uptime.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include - -#include "chipset.h" -#include "system.h" -#include "host_command.h" -#include "util.h" - -static enum ec_status -host_command_get_uptime_info(struct host_cmd_handler_args *args) -{ - /* - * In the current implementation, not all terms are preserved across a - * sysjump. Future implementations may preserve additional information. - * - * time_since_ec_boot_ms: preserved, but wraps at ~50 days - * ec_reset_flags: preserved, with 'sysjump' added - * ap_resets_since_ec_boot: Not preserved - * recent_ap_reset[*]: Not preserved - */ - struct ec_response_uptime_info *r = args->response; - timestamp_t now = get_time(); - uint32_t now_ms = (uint32_t)(now.val / MSEC); - enum ec_error_list rc; - - r->time_since_ec_boot_ms = now_ms; - r->ec_reset_flags = system_get_reset_flags(); - - memset(r->recent_ap_reset, 0, sizeof(r->recent_ap_reset)); - rc = get_ap_reset_stats(r->recent_ap_reset, - ARRAY_SIZE(r->recent_ap_reset), - &r->ap_resets_since_ec_boot); - - args->response_size = sizeof(*r); - return rc == EC_SUCCESS ? EC_RES_SUCCESS : EC_RES_ERROR; -} -DECLARE_HOST_COMMAND(EC_CMD_GET_UPTIME_INFO, - host_command_get_uptime_info, - EC_VER_MASK(0)); diff --git a/include/chipset.h b/include/chipset.h index 90f0e6661d..bd9f2f2471 100644 --- a/include/chipset.h +++ b/include/chipset.h @@ -15,9 +15,7 @@ #include "common.h" #include "compile_time_macros.h" -#include "ec_commands.h" #include "gpio.h" -#include "stddef.h" /* * Chipset state mask @@ -235,29 +233,10 @@ void chipset_watchdog_interrupt(enum gpio_signal signal); */ void report_ap_reset(enum chipset_shutdown_reason reason); -/** - * Get statistics about AP resets. - * - * @param reset_log_entries Pointer to array of log entries. - * @param num_reset_log_entries Number of items in reset_log_entries. - * @param resets_since_ec_boot Number of AP resets since EC boot. - */ -test_mockable enum ec_error_list -get_ap_reset_stats(struct ap_reset_log_entry *reset_log_entries, - size_t num_reset_log_entries, - uint32_t *resets_since_ec_boot); - #else static inline void report_ap_reset(enum chipset_shutdown_reason reason) { } -test_mockable_static_inline enum ec_error_list -get_ap_reset_stats(struct ap_reset_log_entry *reset_log_entries, - size_t num_reset_log_entries, uint32_t *resets_since_ec_boot) -{ - return EC_SUCCESS; -} - #endif /* !CONFIG_CMD_AP_RESET_LOG */ #endif /* __CROS_EC_CHIPSET_H */ diff --git a/include/common.h b/include/common.h index 9e16f9c462..cd6aec2fa8 100644 --- a/include/common.h +++ b/include/common.h @@ -273,12 +273,10 @@ enum ec_error_list { #ifdef TEST_BUILD #define test_mockable __attribute__((weak)) #define test_mockable_static __attribute__((weak)) -#define test_mockable_static_inline __attribute__((weak)) #define test_export_static #else #define test_mockable #define test_mockable_static static -#define test_mockable_static_inline static inline #define test_export_static static #endif diff --git a/include/config.h b/include/config.h index ffcb183ab9..3ec133bd58 100644 --- a/include/config.h +++ b/include/config.h @@ -1982,9 +1982,6 @@ /* Set entry in PD MCU's device rw_hash table */ #define CONFIG_HOSTCMD_RWHASHPD -/* Command to get the EC uptime (and optionally AP reset stats) */ -#define CONFIG_HOSTCMD_GET_UPTIME_INFO - /* List of host commands whose debug output will be suppressed */ #undef CONFIG_SUPPRESSED_HOST_COMMANDS diff --git a/test/build.mk b/test/build.mk index 84e3b9f2f1..4072459707 100644 --- a/test/build.mk +++ b/test/build.mk @@ -50,7 +50,6 @@ test-list-host += system test-list-host += thermal test-list-host += timer_dos test-list-host += u2f -test-list-host += uptime test-list-host += utils test-list-host += utils_str test-list-host += vboot @@ -96,7 +95,6 @@ timer_calib-y=timer_calib.o timer_dos-y=timer_dos.o u2f-y=u2f.o u2f-y+=../board/cr50/dcrypto/u2f.o -uptime-y=uptime.o utils-y=utils.o utils_str-y=utils_str.o vboot-y=vboot.o diff --git a/test/uptime.c b/test/uptime.c deleted file mode 100644 index 7ff39f98db..0000000000 --- a/test/uptime.c +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "common.h" -#include "ec_commands.h" -#include "host_command.h" -#include "test_util.h" -#include "timer.h" -#include "util.h" - -static bool get_ap_reset_stats_should_succeed = true; - -/* Mocks */ - -enum ec_error_list -get_ap_reset_stats(struct ap_reset_log_entry *reset_log_entries, - size_t num_reset_log_entries, uint32_t *resets_since_ec_boot) -{ - return get_ap_reset_stats_should_succeed ? EC_SUCCESS : EC_ERROR_INVAL; -} - -timestamp_t get_time(void) -{ - timestamp_t fake_time = { .val = 42 * MSEC }; - return fake_time; -} - -/* Tests */ - -test_static int test_host_uptime_info_command_success(void) -{ - int rv; - struct ec_response_uptime_info resp = { 0 }; - - get_ap_reset_stats_should_succeed = true; - - rv = test_send_host_command(EC_CMD_GET_UPTIME_INFO, 0, NULL, 0, &resp, - sizeof(resp)); - - TEST_ASSERT(rv == EC_RES_SUCCESS); - TEST_ASSERT(resp.time_since_ec_boot_ms == 42); - - return EC_RES_SUCCESS; -} - -test_static int test_host_uptime_info_command_failure(void) -{ - int rv; - struct ec_response_uptime_info resp = { 0 }; - - get_ap_reset_stats_should_succeed = false; - - rv = test_send_host_command(EC_CMD_GET_UPTIME_INFO, 0, NULL, 0, &resp, - sizeof(resp)); - - TEST_ASSERT(rv == EC_RES_ERROR); - - return EC_RES_SUCCESS; -} - -void run_test(void) -{ - test_reset(); - - RUN_TEST(test_host_uptime_info_command_success); - RUN_TEST(test_host_uptime_info_command_failure); - - test_print_result(); -} diff --git a/test/uptime.tasklist b/test/uptime.tasklist deleted file mode 100644 index 9bf1c80c20..0000000000 --- a/test/uptime.tasklist +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST - -- cgit v1.2.1