Skip to contentSkip to conversation

Add trace events for SD registers.

PATCH In review Raul E Rangel 2 participants 8 messages Apr 16, 2019 – Apr 29, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover Add trace events for SD registers.

I am not able to make a single event class for all these registers. They all have different struct sizes and different printf formats.

Thanks for the reviews!

Changes in v2:
- Made trace_sd_scr print out flags.
- Add BUILD_BUG_ON to make sure tracing stays in sync with structs.
- memcpy using sizeof(__entry->raw)

Raul E Rangel (4):
mmc: core: Add trace event for SD SCR response
mmc: core: Add trace event for SD SSR response
mmc: core: Add trace event for SD OCR response
mmc: core: Add trace event for CSD response

 drivers/mmc/core/mmc.c     |   4 +
 drivers/mmc/core/sd.c      |  10 ++
 drivers/mmc/core/sd_ops.c  |   6 ++
 include/trace/events/mmc.h | 204 +++++++++++++++++++++++++++++++++++++
 4 files changed, 224 insertions(+)
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
#1 lore raw

PATCH v2 1/4 mmc: core: Add trace event for SD SCR response

Example:
sd_scr: mmc0: version: 2, spec3: 1, width: [1-BIT | 4-BIT], cmds: [], raw: {0x2b58000,0x0} */

---

 drivers/mmc/core/sd.c      |  6 +++++
 include/trace/events/mmc.h | 51 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)
drivers/mmc/core/sd.c +6 -0
index 265e1aeeb9d8..f1772972d6a3 100644
@@ -21,6 +21,8 @@
 #include <linux/mmc/mmc.h>
 #include <linux/mmc/sd.h>
 
+#include <trace/events/mmc.h>
+
 #include "core.h"
 #include "card.h"
 #include "host.h"
@@ -200,6 +202,7 @@ static int mmc_decode_scr(struct mmc_card *card)
 	if (scr_struct != 0) {
 		pr_err("%s: unrecognised SCR structure version %d\n",
 			mmc_hostname(card->host), scr_struct);
+		trace_sd_scr(card, NULL);
 		return -EINVAL;
 	}
 
@@ -221,6 +224,9 @@ static int mmc_decode_scr(struct mmc_card *card)
 
 	if (scr->sda_spec3)
 		scr->cmds = UNSTUFF_BITS(resp, 32, 2);
+
+	trace_sd_scr(card, scr);
+
 	return 0;
 }
 
include/trace/events/mmc.h +51 -0

57 lines not on this page · raw message

Signature · 1 line
2.21.0.392.gf8f6787159e-goog
#2 lore raw

PATCH v2 2/4 mmc: core: Add trace event for SD SSR response

In reply to Raul E Rangel

Example:
sd_ssr: mmc0: au: 8192, erase time: 0, erase offset: 0x0, raw: {0x0,0x3000000,0x1019000,0x10000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}

---

 drivers/mmc/core/sd.c      |  2 ++
 include/trace/events/mmc.h | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+)
drivers/mmc/core/sd.c +2 -0
index f1772972d6a3..908c3087cdcd 100644
@@ -292,6 +292,8 @@ static int mmc_read_ssr(struct mmc_card *card)
 	card->erase_arg = (card->scr.sda_specx && discard_support) ?
 			    SD_DISCARD_ARG : SD_ERASE_ARG;
 
+	trace_sd_ssr(card);
+
 	return 0;
 }
 
include/trace/events/mmc.h +32 -0
index 9761d3db16db..463cf318d762 100644
@@ -61,6 +61,38 @@ TRACE_EVENT(sd_scr,
 	)
 );
 
+TRACE_EVENT(sd_ssr,
+
+	TP_PROTO(struct mmc_card *card),
+
+	TP_ARGS(card),
+
+	TP_STRUCT__entry(
+		__array(u32,			raw,	16)
+		__field(unsigned int,		au)
+		__field(unsigned int,		erase_timeout)
+		__field(unsigned int,		erase_offset)
+		__string(name,			mmc_hostname(card->host))
+	),
+
+	TP_fast_assign(
+		BUILD_BUG_ON(sizeof(card->raw_ssr) != sizeof(__entry->raw));
+		memcpy(__entry->raw, card->raw_ssr, sizeof(__entry->raw));
+		__entry->au = card->ssr.au;
+		__entry->erase_timeout = card->ssr.erase_timeout;
+		__entry->erase_offset = card->ssr.erase_offset;
+		__assign_str(name, mmc_hostname(card->host));
+	),
+
+	TP_printk("%s: au: %d, erase time: %d, erase offset: %#x, raw: %s",
+		  __get_str(name),
+		  __entry->au,
+		  __entry->erase_timeout,
+		  __entry->erase_offset,
+		  __print_array(__entry->raw, 16, sizeof(u32))
+	)
+);
+
 TRACE_EVENT(mmc_request_start,
 
 	TP_PROTO(struct mmc_host *host, struct mmc_request *mrq),
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
#3 lore raw

PATCH v2 3/4 mmc: core: Add trace event for SD OCR response

In reply to Raul E Rangel

Example:
sd_ocr_request: mmc0: 0x0 []
sd_ocr_request: mmc0: 0x51200000 [SDHC or SDXC Supported (HCS) | Maximum Performance (XPC) | Switch to 1.8V (S18R) | 3.3 ~ 3.4]
sd_ocr_response: mmc0: 0xff8000 [2.7 ~ 2.8 | 2.8 ~ 2.9 | 2.9 ~ 3.0 | 3.0 ~ 3.1 | 3.1 ~ 3.2 | 3.2 ~ 3.3 | 3.3 ~ 3.4 | 3.4 ~ 3.5 | 3.5 ~ 3.6]

---

 drivers/mmc/core/sd_ops.c  |  6 +++
 include/trace/events/mmc.h | 92 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 98 insertions(+)
drivers/mmc/core/sd_ops.c +6 -0
index 0bb0b8419016..4cf0f040f896 100644
@@ -19,6 +19,8 @@
 #include <linux/mmc/mmc.h>
 #include <linux/mmc/sd.h>
 
+#include <trace/events/mmc.h>
+
 #include "core.h"
 #include "sd_ops.h"
 
@@ -130,11 +132,15 @@ int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
 		cmd.arg = ocr;
 	cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R3 | MMC_CMD_BCR;
 
+	trace_sd_ocr_request(host, ocr);
+
 	for (i = 100; i; i--) {
 		err = mmc_wait_for_app_cmd(host, NULL, &cmd);
 		if (err)
 			break;
 
+		trace_sd_ocr_response(host, cmd.resp[0]);
+
 		/* if we're just probing, do a single pass */
 		if (ocr == 0)
 			break;
include/trace/events/mmc.h +92 -0

98 lines not on this page · raw message

Signature · 1 line
2.21.0.392.gf8f6787159e-goog
#4 lore raw

PATCH v2 4/4 mmc: core: Add trace event for CSD response

In reply to Raul E Rangel

Example:
mmc_csd: mmc0: struct: 0, cmdclass: 0x5b5, raw: {0x400e0032,0x5b590000,0x3b4b7f80,0xa404000}

---

 drivers/mmc/core/mmc.c     |  4 ++++
 drivers/mmc/core/sd.c      |  2 ++
 include/trace/events/mmc.h | 29 +++++++++++++++++++++++++++++
 3 files changed, 35 insertions(+)
drivers/mmc/core/mmc.c +4 -0
index 3e786ba204c3..46ce894f7c03 100644
@@ -20,6 +20,8 @@
 #include <linux/mmc/card.h>
 #include <linux/mmc/mmc.h>
 
+#include <trace/events/mmc.h>
+
 #include "core.h"
 #include "card.h"
 #include "host.h"
@@ -182,6 +184,8 @@ static int mmc_decode_csd(struct mmc_card *card)
 		csd->erase_size <<= csd->write_blkbits - 9;
 	}
 
+	trace_mmc_csd(card);
+
 	return 0;
 }
 
drivers/mmc/core/sd.c +2 -0
index 908c3087cdcd..3b2e09fa72c5 100644
@@ -183,6 +183,8 @@ static int mmc_decode_csd(struct mmc_card *card)
 
 	card->erase_size = csd->erase_size;
 
+	trace_mmc_csd(card);
+
 	return 0;
 }
 
include/trace/events/mmc.h +29 -0
index 8d97810221cd..46fd918bcae3 100644
@@ -185,6 +185,35 @@ TRACE_EVENT(sd_ssr,
 	)
 );
 
+TRACE_EVENT(mmc_csd,
+
+	TP_PROTO(struct mmc_card *card),
+
+	TP_ARGS(card),
+
+	TP_STRUCT__entry(
+		__array(u32,			raw,	4)
+		__field(unsigned char,		structure)
+		__field(unsigned short,		cmdclass)
+		__string(name,			mmc_hostname(card->host))
+	),
+
+	TP_fast_assign(
+		BUILD_BUG_ON(sizeof(card->raw_csd) != sizeof(__entry->raw));
+		memcpy(__entry->raw, card->raw_csd, sizeof(__entry->raw));
+		__entry->structure = card->csd.structure;
+		__entry->cmdclass = card->csd.cmdclass;
+		__assign_str(name, mmc_hostname(card->host));
+	),
+
+	TP_printk("%s: struct: %d, cmdclass: %#x, raw: %s",
+		  __get_str(name),
+		  __entry->structure,
+		  __entry->cmdclass,
+		  __print_array(__entry->raw, 4, sizeof(u32))
+	)
+);
+
 TRACE_EVENT(mmc_request_start,
 
 	TP_PROTO(struct mmc_host *host, struct mmc_request *mrq),
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
#5 lore raw
In reply to Raul E Rangel
Quoted 17 lines · Raul E Rangel

I am not able to make a single event class for all these registers. They all have different struct sizes and different printf formats.

Thanks for the reviews!

Changes in v2:
- Made trace_sd_scr print out flags.
- Add BUILD_BUG_ON to make sure tracing stays in sync with structs.
- memcpy using sizeof(__entry->raw)

Raul E Rangel (4):
mmc: core: Add trace event for SD SCR response
mmc: core: Add trace event for SD SSR response
mmc: core: Add trace event for SD OCR response
mmc: core: Add trace event for CSD response

Quoted 9 lines
 drivers/mmc/core/mmc.c     |   4 +
 drivers/mmc/core/sd.c      |  10 ++
 drivers/mmc/core/sd_ops.c  |   6 ++
 include/trace/events/mmc.h | 204 +++++++++++++++++++++++++++++++++++++
 4 files changed, 224 insertions(+)

--
2.21.0.392.gf8f6787159e-goog

Why do you need this? We already have these card registers reflected though sysfs files, isn't that sufficient?

Kind regards
Uffe

#6 lore raw
Quoted 24 lines · Ulf Hansson
Quoted 23 lines · Raul E Rangel

I am not able to make a single event class for all these registers. They all have different struct sizes and different printf formats.

Thanks for the reviews!

Changes in v2:
- Made trace_sd_scr print out flags.
- Add BUILD_BUG_ON to make sure tracing stays in sync with structs.
- memcpy using sizeof(__entry->raw)

Raul E Rangel (4):
mmc: core: Add trace event for SD SCR response
mmc: core: Add trace event for SD SSR response
mmc: core: Add trace event for SD OCR response
mmc: core: Add trace event for CSD response

 drivers/mmc/core/mmc.c     |   4 +
 drivers/mmc/core/sd.c      |  10 ++
 drivers/mmc/core/sd_ops.c  |   6 ++
 include/trace/events/mmc.h | 204 +++++++++++++++++++++++++++++++++++++
 4 files changed, 224 insertions(+)
Quoted 7 lines
Quoted 3 lines

--
2.21.0.392.gf8f6787159e-goog

Why do you need this? We already have these card registers reflected though sysfs files, isn't that sufficient?

I was not actually aware that the registers were exposed via sysfs. I was debugging a problem where the host controller was returning all zeros when reading from the card. I wasn't aware that it was returning all zeros until I added tracing. It made it quite easy to diagnose the problem by just diffing the two traces.

Also if the card fails to mount because the data is invalid, the registers would not be exposed via sysfs. So tracing makes gives us an easy way to debug these types of failures.

Thanks,
Raul

Quoted 2 lines

Kind regards
Uffe

#7 lore raw
Quoted 30 lines · Raul Rangel
Quoted 28 lines · Ulf Hansson
Quoted 26 lines · Raul E Rangel

I am not able to make a single event class for all these registers. They all have different struct sizes and different printf formats.

Thanks for the reviews!

Changes in v2:
- Made trace_sd_scr print out flags.
- Add BUILD_BUG_ON to make sure tracing stays in sync with structs.
- memcpy using sizeof(__entry->raw)

Raul E Rangel (4):
mmc: core: Add trace event for SD SCR response
mmc: core: Add trace event for SD SSR response
mmc: core: Add trace event for SD OCR response
mmc: core: Add trace event for CSD response

 drivers/mmc/core/mmc.c     |   4 +
 drivers/mmc/core/sd.c      |  10 ++
 drivers/mmc/core/sd_ops.c  |   6 ++
 include/trace/events/mmc.h | 204 +++++++++++++++++++++++++++++++++++++
 4 files changed, 224 insertions(+)

--
2.21.0.392.gf8f6787159e-goog

Quoted 8 lines
Quoted 3 lines

Why do you need this? We already have these card registers reflected though sysfs files, isn't that sufficient?

I was not actually aware that the registers were exposed via sysfs. I was debugging a problem where the host controller was returning all zeros when reading from the card. I wasn't aware that it was returning all zeros until I added tracing. It made it quite easy to diagnose the problem by just diffing the two traces.

This sounds like a quite an unusual problem, and I don't think having the buffers printed via tracing is worth it.

Moreover, we already have tracing per command/request (but don't print the buffers), that should cover most of error cases during init, don't you think?

[...]

Kind regards
Uffe