Loading drivers/soc/qcom/boot_marker.c +53 −0 Original line number Diff line number Diff line Loading @@ -26,10 +26,12 @@ #include <linux/types.h> #include <linux/mutex.h> #include <linux/mm.h> #include <asm/arch_timer.h> #include <soc/qcom/boot_stats.h> #define MAX_STRING_LEN 256 #define BOOT_MARKER_MAX_LEN 40 #define MSM_ARCH_TIMER_FREQ 19200000 struct boot_marker { char marker_name[BOOT_MARKER_MAX_LEN]; Loading @@ -41,6 +43,23 @@ struct boot_marker { static struct dentry *dent_bkpi, *dent_bkpi_status, *dent_mpm_timer; static struct boot_marker boot_marker_list; static void _destroy_boot_marker(const char *name) { struct boot_marker *marker; struct boot_marker *temp_addr; mutex_lock(&boot_marker_list.lock); list_for_each_entry_safe(marker, temp_addr, &boot_marker_list.list, list) { if (strnstr(marker->marker_name, name, strlen(marker->marker_name))) { list_del(&marker->list); kfree(marker); } } mutex_unlock(&boot_marker_list.lock); } static void _create_boot_marker(const char *name, unsigned long long int timer_value) { Loading Loading @@ -78,6 +97,40 @@ void place_marker(const char *name) } EXPORT_SYMBOL(place_marker); void destroy_marker(const char *name) { _destroy_boot_marker((char *) name); } EXPORT_SYMBOL(destroy_marker); static inline u64 get_time_in_msec(u64 counter) { counter *= MSEC_PER_SEC; do_div(counter, MSM_ARCH_TIMER_FREQ); return counter; } void measure_wake_up_time(void) { u64 wake_up_time, deep_sleep_exit_time, current_time; char wakeup_marker[50] = {0,}; current_time = arch_counter_get_cntvct(); deep_sleep_exit_time = get_sleep_exit_time(); if (deep_sleep_exit_time) { wake_up_time = current_time - deep_sleep_exit_time; wake_up_time = get_time_in_msec(wake_up_time); pr_debug("Current= %llu, wakeup=%llu, kpi=%llu msec\n", current_time, deep_sleep_exit_time, wake_up_time); snprintf(wakeup_marker, sizeof(wakeup_marker), "M - STR Wakeup : %llu ms", wake_up_time); destroy_marker("M - STR Wakeup"); place_marker(wakeup_marker); } else destroy_marker("M - STR Wakeup"); } EXPORT_SYMBOL(measure_wake_up_time); static ssize_t bootkpi_reader(struct file *fp, char __user *user_buffer, size_t count, loff_t *position) { Loading drivers/soc/qcom/rpm_stats.c +49 −3 Original line number Diff line number Diff line /* Copyright (c) 2011-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2011-2019, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading @@ -12,7 +12,7 @@ */ #define pr_fmt(fmt) "%s: " fmt, __func__ #include <linux/string.h> #include <linux/init.h> #include <linux/io.h> #include <linux/kernel.h> Loading @@ -22,7 +22,7 @@ #include <linux/of.h> #include <linux/uaccess.h> #include <asm/arch_timer.h> #include <soc/qcom/boot_stats.h> #define RPM_STATS_NUM_REC 2 #define MSM_ARCH_TIMER_FREQ 19200000 Loading Loading @@ -62,6 +62,8 @@ struct msm_rpm_stats_data { #endif }; static struct msm_rpmstats_platform_data *gpdata; static u64 deep_sleep_last_exited_time; struct msm_rpmstats_kobj_attr { struct kobject *kobj; Loading Loading @@ -91,6 +93,7 @@ static inline int msm_rpmstats_append_data_to_buf(char *buf, u64 time_in_last_mode; u64 time_since_last_mode; u64 actual_last_sleep; static u32 saved_deep_sleep_count; stat_type[4] = 0; memcpy(stat_type, &data->stat_type, sizeof(u32)); Loading @@ -101,6 +104,15 @@ static inline int msm_rpmstats_append_data_to_buf(char *buf, time_since_last_mode = get_time_in_sec(time_since_last_mode); actual_last_sleep = get_time_in_msec(data->accumulated); if (!memcmp((const void *)stat_type, (const void *)"aosd", 4)) { if (saved_deep_sleep_count == data->count) deep_sleep_last_exited_time = 0; else { saved_deep_sleep_count = data->count; deep_sleep_last_exited_time = data->last_exited_at; } } #if defined(CONFIG_MSM_RPM_SMD) return snprintf(buf, buflength, "RPM Mode:%s\n\t count:%d\ntime in last mode(msec):%llu\n" Loading Loading @@ -173,6 +185,39 @@ static inline int msm_rpmstats_copy_stats( return length; } static ssize_t msm_rpmstats_populate_stats(void) { struct msm_rpmstats_private_data prvdata; if (!gpdata) { pr_err("ERROR could not get rpm data memory\n"); return -ENOMEM; } prvdata.reg_base = ioremap_nocache(gpdata->phys_addr_base, gpdata->phys_size); if (!prvdata.reg_base) { pr_err("ERROR could not ioremap start=%pa, len=%u\n", gpdata->phys_addr_base, gpdata->phys_size); return -EBUSY; } prvdata.read_idx = prvdata.len = 0; prvdata.platform_data = gpdata; prvdata.num_records = gpdata->num_records; if (prvdata.read_idx < prvdata.num_records) prvdata.len = msm_rpmstats_copy_stats(&prvdata); iounmap(prvdata.reg_base); return prvdata.len; } uint64_t get_sleep_exit_time(void) { if (msm_rpmstats_populate_stats() < 0) return 0; else return deep_sleep_last_exited_time; } EXPORT_SYMBOL(get_sleep_exit_time); static ssize_t rpmstats_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) Loading Loading @@ -278,6 +323,7 @@ static int msm_rpmstats_probe(struct platform_device *pdev) pdata->num_records = RPM_STATS_NUM_REC; msm_rpmstats_create_sysfs(pdev, pdata); gpdata = pdata; return 0; } Loading include/soc/qcom/boot_stats.h +9 −0 Original line number Diff line number Diff line Loading @@ -44,7 +44,16 @@ static inline phys_addr_t msm_timer_get_pa(void) { return 0; } #ifdef CONFIG_MSM_BOOT_TIME_MARKER static inline int boot_marker_enabled(void) { return 1; } void place_marker(const char *name); void destroy_marker(const char *name); void measure_wake_up_time(void); #else static inline void place_marker(char *name) { }; static inline void destroy_marker(const char *name) { }; static inline int boot_marker_enabled(void) { return 0; } static inline void measure_wake_up_time(void) { }; #endif #ifdef CONFIG_QTI_RPM_STATS_LOG uint64_t get_sleep_exit_time(void); #else static inline uint64_t get_sleep_exit_time(void) { return 0; } #endif kernel/power/suspend.c +2 −1 Original line number Diff line number Diff line Loading @@ -33,8 +33,8 @@ #include <linux/compiler.h> #include <linux/moduleparam.h> #include <linux/wakeup_reason.h> #include "power.h" #include <soc/qcom/boot_stats.h> const char * const pm_labels[] = { [PM_SUSPEND_TO_IDLE] = "freeze", Loading Loading @@ -643,6 +643,7 @@ int pm_suspend(suspend_state_t state) } pm_suspend_marker("exit"); pr_info("suspend exit\n"); measure_wake_up_time(); return error; } EXPORT_SYMBOL(pm_suspend); Loading
drivers/soc/qcom/boot_marker.c +53 −0 Original line number Diff line number Diff line Loading @@ -26,10 +26,12 @@ #include <linux/types.h> #include <linux/mutex.h> #include <linux/mm.h> #include <asm/arch_timer.h> #include <soc/qcom/boot_stats.h> #define MAX_STRING_LEN 256 #define BOOT_MARKER_MAX_LEN 40 #define MSM_ARCH_TIMER_FREQ 19200000 struct boot_marker { char marker_name[BOOT_MARKER_MAX_LEN]; Loading @@ -41,6 +43,23 @@ struct boot_marker { static struct dentry *dent_bkpi, *dent_bkpi_status, *dent_mpm_timer; static struct boot_marker boot_marker_list; static void _destroy_boot_marker(const char *name) { struct boot_marker *marker; struct boot_marker *temp_addr; mutex_lock(&boot_marker_list.lock); list_for_each_entry_safe(marker, temp_addr, &boot_marker_list.list, list) { if (strnstr(marker->marker_name, name, strlen(marker->marker_name))) { list_del(&marker->list); kfree(marker); } } mutex_unlock(&boot_marker_list.lock); } static void _create_boot_marker(const char *name, unsigned long long int timer_value) { Loading Loading @@ -78,6 +97,40 @@ void place_marker(const char *name) } EXPORT_SYMBOL(place_marker); void destroy_marker(const char *name) { _destroy_boot_marker((char *) name); } EXPORT_SYMBOL(destroy_marker); static inline u64 get_time_in_msec(u64 counter) { counter *= MSEC_PER_SEC; do_div(counter, MSM_ARCH_TIMER_FREQ); return counter; } void measure_wake_up_time(void) { u64 wake_up_time, deep_sleep_exit_time, current_time; char wakeup_marker[50] = {0,}; current_time = arch_counter_get_cntvct(); deep_sleep_exit_time = get_sleep_exit_time(); if (deep_sleep_exit_time) { wake_up_time = current_time - deep_sleep_exit_time; wake_up_time = get_time_in_msec(wake_up_time); pr_debug("Current= %llu, wakeup=%llu, kpi=%llu msec\n", current_time, deep_sleep_exit_time, wake_up_time); snprintf(wakeup_marker, sizeof(wakeup_marker), "M - STR Wakeup : %llu ms", wake_up_time); destroy_marker("M - STR Wakeup"); place_marker(wakeup_marker); } else destroy_marker("M - STR Wakeup"); } EXPORT_SYMBOL(measure_wake_up_time); static ssize_t bootkpi_reader(struct file *fp, char __user *user_buffer, size_t count, loff_t *position) { Loading
drivers/soc/qcom/rpm_stats.c +49 −3 Original line number Diff line number Diff line /* Copyright (c) 2011-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2011-2019, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading @@ -12,7 +12,7 @@ */ #define pr_fmt(fmt) "%s: " fmt, __func__ #include <linux/string.h> #include <linux/init.h> #include <linux/io.h> #include <linux/kernel.h> Loading @@ -22,7 +22,7 @@ #include <linux/of.h> #include <linux/uaccess.h> #include <asm/arch_timer.h> #include <soc/qcom/boot_stats.h> #define RPM_STATS_NUM_REC 2 #define MSM_ARCH_TIMER_FREQ 19200000 Loading Loading @@ -62,6 +62,8 @@ struct msm_rpm_stats_data { #endif }; static struct msm_rpmstats_platform_data *gpdata; static u64 deep_sleep_last_exited_time; struct msm_rpmstats_kobj_attr { struct kobject *kobj; Loading Loading @@ -91,6 +93,7 @@ static inline int msm_rpmstats_append_data_to_buf(char *buf, u64 time_in_last_mode; u64 time_since_last_mode; u64 actual_last_sleep; static u32 saved_deep_sleep_count; stat_type[4] = 0; memcpy(stat_type, &data->stat_type, sizeof(u32)); Loading @@ -101,6 +104,15 @@ static inline int msm_rpmstats_append_data_to_buf(char *buf, time_since_last_mode = get_time_in_sec(time_since_last_mode); actual_last_sleep = get_time_in_msec(data->accumulated); if (!memcmp((const void *)stat_type, (const void *)"aosd", 4)) { if (saved_deep_sleep_count == data->count) deep_sleep_last_exited_time = 0; else { saved_deep_sleep_count = data->count; deep_sleep_last_exited_time = data->last_exited_at; } } #if defined(CONFIG_MSM_RPM_SMD) return snprintf(buf, buflength, "RPM Mode:%s\n\t count:%d\ntime in last mode(msec):%llu\n" Loading Loading @@ -173,6 +185,39 @@ static inline int msm_rpmstats_copy_stats( return length; } static ssize_t msm_rpmstats_populate_stats(void) { struct msm_rpmstats_private_data prvdata; if (!gpdata) { pr_err("ERROR could not get rpm data memory\n"); return -ENOMEM; } prvdata.reg_base = ioremap_nocache(gpdata->phys_addr_base, gpdata->phys_size); if (!prvdata.reg_base) { pr_err("ERROR could not ioremap start=%pa, len=%u\n", gpdata->phys_addr_base, gpdata->phys_size); return -EBUSY; } prvdata.read_idx = prvdata.len = 0; prvdata.platform_data = gpdata; prvdata.num_records = gpdata->num_records; if (prvdata.read_idx < prvdata.num_records) prvdata.len = msm_rpmstats_copy_stats(&prvdata); iounmap(prvdata.reg_base); return prvdata.len; } uint64_t get_sleep_exit_time(void) { if (msm_rpmstats_populate_stats() < 0) return 0; else return deep_sleep_last_exited_time; } EXPORT_SYMBOL(get_sleep_exit_time); static ssize_t rpmstats_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) Loading Loading @@ -278,6 +323,7 @@ static int msm_rpmstats_probe(struct platform_device *pdev) pdata->num_records = RPM_STATS_NUM_REC; msm_rpmstats_create_sysfs(pdev, pdata); gpdata = pdata; return 0; } Loading
include/soc/qcom/boot_stats.h +9 −0 Original line number Diff line number Diff line Loading @@ -44,7 +44,16 @@ static inline phys_addr_t msm_timer_get_pa(void) { return 0; } #ifdef CONFIG_MSM_BOOT_TIME_MARKER static inline int boot_marker_enabled(void) { return 1; } void place_marker(const char *name); void destroy_marker(const char *name); void measure_wake_up_time(void); #else static inline void place_marker(char *name) { }; static inline void destroy_marker(const char *name) { }; static inline int boot_marker_enabled(void) { return 0; } static inline void measure_wake_up_time(void) { }; #endif #ifdef CONFIG_QTI_RPM_STATS_LOG uint64_t get_sleep_exit_time(void); #else static inline uint64_t get_sleep_exit_time(void) { return 0; } #endif
kernel/power/suspend.c +2 −1 Original line number Diff line number Diff line Loading @@ -33,8 +33,8 @@ #include <linux/compiler.h> #include <linux/moduleparam.h> #include <linux/wakeup_reason.h> #include "power.h" #include <soc/qcom/boot_stats.h> const char * const pm_labels[] = { [PM_SUSPEND_TO_IDLE] = "freeze", Loading Loading @@ -643,6 +643,7 @@ int pm_suspend(suspend_state_t state) } pm_suspend_marker("exit"); pr_info("suspend exit\n"); measure_wake_up_time(); return error; } EXPORT_SYMBOL(pm_suspend);