mmc: core: Add tracepoints to enhance pm debugging

Instrument the mmc core layer with tracepoints to aid in
debugging issues and identifying latencies in the following
paths:
* System suspend/resume
* Runtime suspend/resume

Change-Id: I1e0fa7d3f8b54c102b4055f910b58a42412748da
Signed-off-by: Konstantin Dorfman <kdorfman@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This commit is contained in:
Konstantin Dorfman 2015-02-12 13:37:56 +02:00 committed by Subhash Jadavani
parent 12c38797ea
commit 26f1875126
2 changed files with 57 additions and 1 deletions

View file

@ -20,6 +20,7 @@
#include <linux/mmc/card.h>
#include <linux/mmc/mmc.h>
#include <linux/reboot.h>
#include <trace/events/mmc.h>
#include "core.h"
#include "host.h"
@ -2123,6 +2124,7 @@ out:
static int mmc_suspend(struct mmc_host *host)
{
int err;
ktime_t start = ktime_get();
err = _mmc_suspend(host, true);
if (!err) {
@ -2130,6 +2132,8 @@ static int mmc_suspend(struct mmc_host *host)
pm_runtime_set_suspended(&host->card->dev);
}
trace_mmc_suspend(mmc_hostname(host), err,
ktime_to_us(ktime_sub(ktime_get(), start)));
return err;
}
@ -2210,6 +2214,7 @@ static int mmc_shutdown(struct mmc_host *host)
static int mmc_resume(struct mmc_host *host)
{
int err = 0;
ktime_t start = ktime_get();
if (!(host->caps & MMC_CAP_RUNTIME_RESUME)) {
err = _mmc_resume(host);
@ -2218,6 +2223,9 @@ static int mmc_resume(struct mmc_host *host)
}
pm_runtime_enable(&host->card->dev);
trace_mmc_resume(mmc_hostname(host), err,
ktime_to_us(ktime_sub(ktime_get(), start)));
return err;
}
@ -2227,6 +2235,7 @@ static int mmc_resume(struct mmc_host *host)
static int mmc_runtime_suspend(struct mmc_host *host)
{
int err;
ktime_t start = ktime_get();
if (!(host->caps & MMC_CAP_AGGRESSIVE_PM))
return 0;
@ -2236,6 +2245,8 @@ static int mmc_runtime_suspend(struct mmc_host *host)
pr_err("%s: error %d doing aggressive suspend\n",
mmc_hostname(host), err);
trace_mmc_runtime_suspend(mmc_hostname(host), err,
ktime_to_us(ktime_sub(ktime_get(), start)));
return err;
}
@ -2245,6 +2256,7 @@ static int mmc_runtime_suspend(struct mmc_host *host)
static int mmc_runtime_resume(struct mmc_host *host)
{
int err;
ktime_t start = ktime_get();
if (!(host->caps & (MMC_CAP_AGGRESSIVE_PM | MMC_CAP_RUNTIME_RESUME)))
return 0;
@ -2256,6 +2268,9 @@ static int mmc_runtime_resume(struct mmc_host *host)
mmc_init_clk_scaling(host);
trace_mmc_runtime_resume(mmc_hostname(host), err,
ktime_to_us(ktime_sub(ktime_get(), start)));
return 0;
}

View file

@ -1,6 +1,6 @@
/*
* Copyright (C) 2013 Google, Inc.
* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
@ -176,6 +176,47 @@ TRACE_EVENT(mmc_clk,
)
);
DECLARE_EVENT_CLASS(mmc_pm_template,
TP_PROTO(const char *dev_name, int err, s64 usecs),
TP_ARGS(dev_name, err, usecs),
TP_STRUCT__entry(
__field(s64, usecs)
__field(int, err)
__string(dev_name, dev_name)
),
TP_fast_assign(
__entry->usecs = usecs;
__entry->err = err;
__assign_str(dev_name, dev_name);
),
TP_printk(
"took %lld usecs, %s err %d",
__entry->usecs,
__get_str(dev_name),
__entry->err
)
);
DEFINE_EVENT(mmc_pm_template, mmc_runtime_suspend,
TP_PROTO(const char *dev_name, int err, s64 usecs),
TP_ARGS(dev_name, err, usecs));
DEFINE_EVENT(mmc_pm_template, mmc_runtime_resume,
TP_PROTO(const char *dev_name, int err, s64 usecs),
TP_ARGS(dev_name, err, usecs));
DEFINE_EVENT(mmc_pm_template, mmc_suspend,
TP_PROTO(const char *dev_name, int err, s64 usecs),
TP_ARGS(dev_name, err, usecs));
DEFINE_EVENT(mmc_pm_template, mmc_resume,
TP_PROTO(const char *dev_name, int err, s64 usecs),
TP_ARGS(dev_name, err, usecs));
#endif /* if !defined(_TRACE_MMC_H) || defined(TRACE_HEADER_MULTI_READ) */
/* This part must be outside protection */