msm: tracing: Add ftrace support for LPM driver

Add trace event support to capture various parameters
of low power modes like power collapse, standalone power
collapse, retention and wfi during its entry and exit.

Change-Id: I0f8b918702ae47b354aa193aa7ef20b48110fb0f
Signed-off-by: Priyanka Mathur <pmathur@codeaurora.org>
This commit is contained in:
Priyanka Mathur 2012-11-05 13:45:45 -08:00 committed by Stephen Boyd
parent fba7f7b998
commit 454c036f67
3 changed files with 234 additions and 4 deletions

View File

@ -0,0 +1,45 @@
Subsystem Trace Points: msm_low_power
The msm_low_power tracing system captures the events during the entry
and exit of various low power modes like power collapse, standalone
power collapse, retention and wfi. The tracing system adds the following
events to capture the state of the low power mode.
1) msm_pm_enter
===================
msm_pm_enter: cpu: %u latency: %uus sleep: %uus
msm_pm_enter_pc: cpu: %u latency: %uus sleep: %uus wake_up: %u
msm_pm_enter_ret: cpu: %u latency: %uus sleep: %uus wake_up: %u
msm_pm_enter_spc: cpu: %u latency: %uus sleep: %uus wake_up: %u
msm_pm_enter_wfi: cpu: %u latency: %uus sleep: %uus wake_up: %u
The event captures various parameters during the entry into low power
modes.
The 'cpu' parameter represents the cpu on which the low power mode is
chosen.
The 'latency_us' parameter represents the system latency at the time of
choosing the low power mode.
The 'sleep_us' parameter tells the maximum amount of time the kernel can
sleep in this low power mode.
The 'wake_up' parameter tells if there was any immediate wakeup required
before entering low power mode.
2) msm_pm_exit
=================
msm_pm_exit: cpu:%u success:%d
msm_pm_exit_pc: cpu:%u success:%d
msm_pm_exit_ret: cpu:%u success:%d
msm_pm_exit_spc: cpu:%u success:%d
msm_pm_exit_wfi: cpu:%u success:%d
The event captures parameters during the exit of the low power modes.
The 'cpu' parameter represents the cpu on which the low power mode is chosen.
The 'success' parameter shows the state of power collapse/standalone power
collapse. It will be set if power collapse/standalone power collapse were
successful. For the rest of the low power modes it is set to one.

View File

@ -50,7 +50,8 @@
#include "timer.h"
#include "pm-boot.h"
#include <mach/event_timer.h>
#define CREATE_TRACE_POINTS
#include "trace_msm_low_power.h"
/******************************************************************************
* Debug Definitions
*****************************************************************************/
@ -723,6 +724,51 @@ void arch_idle(void)
return;
}
static inline void msm_pm_ftrace_lpm_enter(unsigned int cpu,
uint32_t latency, uint32_t sleep_us,
uint32_t wake_up,
enum msm_pm_sleep_mode mode)
{
switch (mode) {
case MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT:
trace_msm_pm_enter_wfi(cpu, latency, sleep_us, wake_up);
break;
case MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE:
trace_msm_pm_enter_spc(cpu, latency, sleep_us, wake_up);
break;
case MSM_PM_SLEEP_MODE_POWER_COLLAPSE:
trace_msm_pm_enter_pc(cpu, latency, sleep_us, wake_up);
break;
case MSM_PM_SLEEP_MODE_RETENTION:
trace_msm_pm_enter_ret(cpu, latency, sleep_us, wake_up);
break;
default:
break;
}
}
static inline void msm_pm_ftrace_lpm_exit(unsigned int cpu,
enum msm_pm_sleep_mode mode,
bool success)
{
switch (mode) {
case MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT:
trace_msm_pm_exit_wfi(cpu, success);
break;
case MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE:
trace_msm_pm_exit_spc(cpu, success);
break;
case MSM_PM_SLEEP_MODE_POWER_COLLAPSE:
trace_msm_pm_exit_pc(cpu, success);
break;
case MSM_PM_SLEEP_MODE_RETENTION:
trace_msm_pm_exit_ret(cpu, success);
break;
default:
break;
}
}
int msm_pm_idle_prepare(struct cpuidle_device *dev,
struct cpuidle_driver *drv, int index)
{
@ -827,6 +873,11 @@ int msm_pm_idle_prepare(struct cpuidle_device *dev,
if (modified_time_us && !dev->cpu)
msm_pm_set_timer(modified_time_us);
msm_pm_ftrace_lpm_enter(dev->cpu, time_param.latency_us,
time_param.sleep_us, time_param.next_event_us,
ret);
return ret;
}
@ -834,6 +885,7 @@ int msm_pm_idle_enter(enum msm_pm_sleep_mode sleep_mode)
{
int64_t time;
int exit_stat;
bool collapsed = 1;
if (MSM_PM_DEBUG_IDLE & msm_pm_debug_mask)
pr_info("CPU%u: %s: mode %d\n",
@ -853,7 +905,7 @@ int msm_pm_idle_enter(enum msm_pm_sleep_mode sleep_mode)
break;
case MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE:
msm_pm_power_collapse_standalone(true);
collapsed = msm_pm_power_collapse_standalone(true);
exit_stat = MSM_PM_STAT_IDLE_STANDALONE_POWER_COLLAPSE;
break;
@ -864,8 +916,6 @@ int msm_pm_idle_enter(enum msm_pm_sleep_mode sleep_mode)
int ret = -ENODEV;
int notify_rpm =
(sleep_mode == MSM_PM_SLEEP_MODE_POWER_COLLAPSE);
int collapsed;
timer_expiration = msm_pm_timer_enter_idle();
sleep_delay = (uint32_t) msm_pm_convert_and_cap_time(
@ -900,6 +950,8 @@ int msm_pm_idle_enter(enum msm_pm_sleep_mode sleep_mode)
time = ktime_to_ns(ktime_get()) - time;
msm_pm_add_stat(exit_stat, time);
msm_pm_ftrace_lpm_exit(smp_processor_id(), sleep_mode,
collapsed);
do_div(time, 1000);
return (int) time;

View File

@ -0,0 +1,133 @@
/* Copyright (c) 2012, 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
* only version 2 as published by the Free Software Foundation.
*
* 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.
*/
#undef TRACE_SYSTEM
#define TRACE_SYSTEM msm_low_power
#if !defined(_TRACE_MSM_LOW_POWER_H_) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_MSM_LOW_POWER_H_
#include <linux/tracepoint.h>
DECLARE_EVENT_CLASS(msm_pm_enter,
TP_PROTO(unsigned int cpu, uint32_t latency,
uint32_t sleep_us, uint32_t wake_up),
TP_ARGS(cpu, latency, sleep_us, wake_up),
TP_STRUCT__entry(
__field(unsigned int, cpu)
__field(uint32_t, latency)
__field(uint32_t, sleep_us)
__field(uint32_t, wake_up)
),
TP_fast_assign(
__entry->cpu = cpu;
__entry->latency = latency;
__entry->sleep_us = sleep_us;
__entry->wake_up = wake_up;
),
TP_printk("cpu: %u latency: %uus sleep: %uus wake_up: %u",
__entry->cpu,
__entry->latency,
__entry->sleep_us,
__entry->wake_up)
);
DEFINE_EVENT(msm_pm_enter, msm_pm_enter_pc,
TP_PROTO(unsigned int cpu, uint32_t latency,
uint32_t sleep_us, uint32_t wake_up),
TP_ARGS(cpu, latency, sleep_us, wake_up)
);
DEFINE_EVENT(msm_pm_enter, msm_pm_enter_ret,
TP_PROTO(unsigned int cpu, uint32_t latency,
uint32_t sleep_us, uint32_t wake_up),
TP_ARGS(cpu, latency, sleep_us, wake_up)
);
DEFINE_EVENT(msm_pm_enter, msm_pm_enter_spc,
TP_PROTO(unsigned int cpu, uint32_t latency,
uint32_t sleep_us, uint32_t wake_up),
TP_ARGS(cpu, latency, sleep_us, wake_up)
);
DEFINE_EVENT(msm_pm_enter, msm_pm_enter_wfi,
TP_PROTO(unsigned int cpu, uint32_t latency,
uint32_t sleep_us, uint32_t wake_up),
TP_ARGS(cpu, latency, sleep_us, wake_up)
);
DECLARE_EVENT_CLASS(msm_pm_exit,
TP_PROTO(unsigned int cpu, bool success),
TP_ARGS(cpu, success),
TP_STRUCT__entry(
__field(unsigned int , cpu)
__field(int, success)
),
TP_fast_assign(
__entry->cpu = cpu;
__entry->success = success;
),
TP_printk("cpu:%u success:%d",
__entry->cpu,
__entry->success)
);
DEFINE_EVENT(msm_pm_exit, msm_pm_exit_pc,
TP_PROTO(unsigned int cpu, bool success),
TP_ARGS(cpu, success)
);
DEFINE_EVENT(msm_pm_exit, msm_pm_exit_ret,
TP_PROTO(unsigned int cpu, bool success),
TP_ARGS(cpu, success)
);
DEFINE_EVENT(msm_pm_exit, msm_pm_exit_spc,
TP_PROTO(unsigned int cpu, bool success),
TP_ARGS(cpu, success)
);
DEFINE_EVENT(msm_pm_exit, msm_pm_exit_wfi,
TP_PROTO(unsigned int cpu, bool success),
TP_ARGS(cpu, success)
);
#endif
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#define TRACE_INCLUDE_FILE trace_msm_low_power
#include <trace/define_trace.h>