From: Bjorn Mansson <bjorn.mansson@xxxxxxxxxxxxxx> Adding ftrace to the mmc layer facilitates debugging, making it easier to debug commend sequences without rebuilding the kernel. Added support for CMD23 to my previous patch. It is also possible to parse the ftrace output into VCD format and visualize it in GTKWave. If I get permission from our legal department I will publish the parser on SourceForge under the name mmcft2vcd. Patch is for the 3.12-rc1 Kernel. Signed-off-by: Bjorn Mansson <bjorn.mansson@xxxxxxxxxxxxxx> --- diff -U 3 -H -d -r -N -- linux-3.12-rc1-vanilla/drivers/mmc/core/core.c linux-3.12-rc1-patched/drivers/mmc/core/core.c --- linux-3.12-rc1-vanilla/drivers/mmc/core/core.c 2013-09-16 22:17:51.000000000 +0200 +++ linux-3.12-rc1-patched/drivers/mmc/core/core.c 2013-10-10 09:45:03.453365761 +0200 @@ -5,6 +5,7 @@ * SD support Copyright (C) 2004 Ian Molton, All Rights Reserved. * Copyright (C) 2005-2008 Pierre Ossman, All Rights Reserved. * MMCv4 support Copyright (C) 2006 Philip Langdale, All Rights Reserved. + * ftrace support Copyright (C) 2013 Sony Mobile Communications AB, 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 as @@ -43,6 +44,9 @@ #include "sd_ops.h" #include "sdio_ops.h" +#define CREATE_TRACE_POINTS +#include <trace/events/mmc.h> + /* If the device is not responding */ #define MMC_CORE_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */ @@ -169,6 +173,10 @@ cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]); + trace_mmc_req_done( mmc_hostname(host), cmd->opcode, err, + cmd->resp[0], cmd->resp[1], + cmd->resp[2], cmd->resp[3]); + if (mrq->data) { pr_debug("%s: %d bytes transferred: %d\n", mmc_hostname(host), @@ -199,13 +207,26 @@ unsigned int i, sz; struct scatterlist *sg; #endif + unsigned int blksz = 0; + unsigned int blocks = 0; + + if (mrq->data) { + blksz = mrq->data->blksz; + blocks = mrq->data->blocks; + } if (mrq->sbc) { pr_debug("<%s: starting CMD%u arg %08x flags %08x>\n", mmc_hostname(host), mrq->sbc->opcode, mrq->sbc->arg, mrq->sbc->flags); + trace_mmc_start_req_sbc( mmc_hostname(host), mrq->sbc->opcode, + mrq->sbc->arg, mrq->sbc->flags, blksz, blocks); } + trace_mmc_start_req_cmd( mmc_hostname(host), mrq->cmd->opcode, + mrq->cmd->arg, mrq->cmd->flags, blksz, blocks); + + pr_debug("%s: starting CMD%u arg %08x flags %08x\n", mmc_hostname(host), mrq->cmd->opcode, mrq->cmd->arg, mrq->cmd->flags); diff -U 3 -H -d -r -N -- linux-3.12-rc1-vanilla/include/trace/events/mmc.h linux-3.12-rc1-patched/include/trace/events/mmc.h --- linux-3.12-rc1-vanilla/include/trace/events/mmc.h 1970-01-01 01:00:00.000000000 +0100 +++ linux-3.12-rc1-patched/include/trace/events/mmc.h 2013-10-10 11:10:29.752738481 +0200 @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2013, Sony Mobile Communications AB + * Author : Björn MÃ¥nsson (bjorn.mansson@xxxxxxxxxxxxxx) + * + * 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 mmc + +#if !defined(_TRACE_MMC_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_MMC_H + +#include <linux/tracepoint.h> + +DECLARE_EVENT_CLASS(start_req, + TP_PROTO(const char * host, unsigned int cmd, + unsigned int arg, unsigned int flags, + unsigned int blksz, unsigned int blks), + TP_ARGS(host, cmd, arg, flags, blksz, blks), + + TP_STRUCT__entry( + __string(host, host) + __field(unsigned int, cmd ) + __field(unsigned int, arg ) + __field(unsigned int, flags ) + __field(unsigned int, blksz ) + __field(unsigned int, blks ) + ), + + TP_fast_assign( + __assign_str(host, host); + __entry->cmd = cmd; + __entry->arg = arg; + __entry->flags = flags; + __entry->blksz = blksz; + __entry->blks = blks; + ), + + TP_printk("host=%s CMD%u arg=%08x flags=%08x blksz=%05x blks=%03x", + __get_str(host), __entry->cmd, + __entry->arg, __entry->flags, + __entry->blksz, __entry->blks ) +); + +DEFINE_EVENT(start_req, mmc_start_req_cmd, + TP_PROTO(const char *host, unsigned int cmd, + unsigned int arg, unsigned int flags, + unsigned int blksz, unsigned int blks), + TP_ARGS(host, cmd, arg, flags, blksz, blks) +); + +DEFINE_EVENT(start_req, mmc_start_req_sbc, + TP_PROTO(const char *host, unsigned int cmd, + unsigned int arg, unsigned int flags, + unsigned int blksz, unsigned int blks), + TP_ARGS(host, cmd, arg, flags, blksz, blks) +); + + +DECLARE_EVENT_CLASS(req_done, + TP_PROTO(const char *host, unsigned int cmd, + int err, unsigned int resp1, + unsigned int resp2, unsigned int resp3, + unsigned int resp4), + TP_ARGS(host, cmd, err, resp1, resp2, resp3, resp4), + + TP_STRUCT__entry( + __string(host, host) + __field(unsigned int, cmd ) + __field( int, err ) + __field(unsigned int, resp1 ) + __field(unsigned int, resp2 ) + __field(unsigned int, resp3 ) + __field(unsigned int, resp4 ) + ), + + TP_fast_assign( + __assign_str(host, host); + __entry->cmd = cmd; + __entry->err = err; + __entry->resp1 = resp1; + __entry->resp2 = resp2; + __entry->resp3 = resp3; + __entry->resp4 = resp4; + ), + + TP_printk("host=%s CMD%u err=%08x resp1=%08x resp2=%08x resp3=%08x resp4=%08x", + __get_str(host), __entry->cmd, + __entry->err, __entry->resp1, + __entry->resp2, __entry->resp3, + __entry->resp4 ) +); + +DEFINE_EVENT(req_done, mmc_req_done, + TP_PROTO(const char *host, unsigned int cmd, + int err, unsigned int resp1, + unsigned int resp2, unsigned int resp3, + unsigned int resp4), + TP_ARGS(host, cmd, err, resp1, resp2, resp3, resp4) +); + + +#endif /* if !defined(_TRACE_MMC_H) || defined(TRACE_HEADER_MULTI_READ) */ + +/* This part must be outside protection */ +#include <trace/define_trace.h> ��.n��������+%������w��{.n�����{��i��)��jg��������ݢj����G�������j:+v���w�m������w�������h�����٥