[PATCH] mmc: Adding (more) ftrace event logging to the mmc layer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
It is also possible to parse the ftrace output into VCD format and visualize it in GTKWave.

Patch is for the 3.7.5 Kernel.


Signed-off-by: Bjorn Mansson <bjorn.mansson@xxxxxxxxxxxxxx>
Acked-by: 
"---"

diff -uprN -X linux-3.7.5-vanilla/Documentation/dontdiff linux-3.7.5-vanilla/drivers/mmc/core/core.c linux-3.7.5-patched/drivers/mmc/core/core.c
--- linux-3.7.5-vanilla/drivers/mmc/core/core.c	2013-01-28 05:50:55.000000000 +0100
+++ linux-3.7.5-patched/drivers/mmc/core/core.c	2013-04-05 11:54:29.306273808 +0200
@@ -42,6 +42,9 @@
 #include "sd_ops.h"
 #include "sdio_ops.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/mmc.h>
+
 /*
  * Background operations can take a long time, depending on the housekeeping
  * operations the card has to perform.
@@ -165,6 +168,10 @@ void mmc_request_done(struct mmc_host *h
 			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),
@@ -195,6 +202,8 @@ mmc_start_request(struct mmc_host *host,
 	unsigned int i, sz;
 	struct scatterlist *sg;
 #endif
+	unsigned int blksz = 0;
+	unsigned int blocks = 0;
 
 	if (mrq->sbc) {
 		pr_debug("<%s: starting CMD%u arg %08x flags %08x>\n",
@@ -213,8 +222,13 @@ mmc_start_request(struct mmc_host *host,
 			mrq->data->blocks, mrq->data->flags,
 			mrq->data->timeout_ns / 1000000,
 			mrq->data->timeout_clks);
+		blksz = mrq->data->blksz;
+		blocks = mrq->data->blocks;
 	}
 
+	trace_mmc_start_req( mmc_hostname(host), mrq->cmd->opcode,
+			     mrq->cmd->arg, mrq->cmd->flags, blksz, blocks);
+
 	if (mrq->stop) {
 		pr_debug("%s:     CMD%u arg %08x flags %08x\n",
 			 mmc_hostname(host), mrq->stop->opcode,
diff -uprN -X linux-3.7.5-vanilla/Documentation/dontdiff linux-3.7.5-vanilla/include/trace/events/mmc.h linux-3.7.5-patched/include/trace/events/mmc.h
--- linux-3.7.5-vanilla/include/trace/events/mmc.h	1970-01-01 01:00:00.000000000 +0100
+++ linux-3.7.5-patched/include/trace/events/mmc.h	2013-04-05 09:51:31.776608013 +0200
@@ -0,0 +1,93 @@
+#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 blocks),
+	TP_ARGS(host, cmd, arg, flags, blksz, blocks),
+
+	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, blocks )
+	   ),
+
+	TP_fast_assign(
+	    __assign_str(host, host);
+	    __entry->cmd = cmd;
+	    __entry->arg = arg;
+	    __entry->flags = flags;
+	    __entry->blksz = blksz;
+	    __entry->blocks = blocks;
+	),
+
+	TP_printk("host=%s CMD%u arg=%08x flags=%08x blksz=%08x blocks=%08x",
+	      __get_str(host), __entry->cmd,
+	      __entry->arg, __entry->flags,
+	      __entry->blksz, __entry->blocks)
+);
+
+DEFINE_EVENT(start_req, mmc_start_req,
+	TP_PROTO(const char *host, unsigned int cmd,
+	     unsigned int arg, unsigned int flags,
+	     unsigned int blksz, unsigned int blocks),
+	TP_ARGS(host, cmd, arg, flags, blksz, blocks)
+);
+
+
+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 /* _TRACE_MMC_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>



��.n��������+%������w��{.n�����{��i��)��jg��������ݢj����G�������j:+v���w�m������w�������h�����٥





[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux