Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66d5686f authored by Konstantin Dorfman's avatar Konstantin Dorfman Committed by Matt Wagantall
Browse files

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: default avatarKonstantin Dorfman <kdorfman@codeaurora.org>
parent d8d83e71
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <linux/mmc/card.h>
#include <linux/mmc/mmc.h>
#include <linux/reboot.h>
#include <trace/events/mmc.h>

#include "core.h"
#include "bus.h"
@@ -1989,6 +1990,7 @@ out:
static int mmc_suspend(struct mmc_host *host)
{
	int err;
	ktime_t start = ktime_get();

	err = _mmc_suspend(host, true);
	if (!err) {
@@ -1996,6 +1998,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;
}

@@ -2076,6 +2080,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);
@@ -2084,6 +2089,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;
}

@@ -2093,6 +2101,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;
@@ -2102,6 +2111,8 @@ static int mmc_runtime_suspend(struct mmc_host *host)
		pr_err("%s: error %d doing aggessive suspend\n",
			mmc_hostname(host), err);

	trace_mmc_runtime_suspend(mmc_hostname(host), err,
			ktime_to_us(ktime_sub(ktime_get(), start)));
	return err;
}

@@ -2111,6 +2122,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;
@@ -2120,6 +2132,9 @@ static int mmc_runtime_resume(struct mmc_host *host)
		pr_err("%s: error %d doing aggessive resume\n",
			mmc_hostname(host), err);

	trace_mmc_runtime_resume(mmc_hostname(host), err,
			ktime_to_us(ktime_sub(ktime_get(), start)));

	return 0;
}

+42 −1
Original line number Diff line number Diff line
/*
 * 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 */