linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/4] mmc: core: Add trace event for SD SCR response
@ 2019-04-15 22:52 Raul E Rangel
  2019-04-15 22:52 ` [PATCH v1 2/4] mmc: core: Add trace event for SD SSR response Raul E Rangel
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Raul E Rangel @ 2019-04-15 22:52 UTC (permalink / raw)
  To: linux-mmc, linux-trace-devel
  Cc: djkurtz, zwisler, Raul E Rangel, Steven Rostedt, hongjiefang,
	Ingo Molnar, linux-kernel, Shawn Lin, Kyle Roeschley,
	Avri Altman, Ulf Hansson

Example:
sd_scr: mmc0: version: 2, spec3: 1, width: 5, cmds: 0, raw: {0x2b58000,0x0}

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---

 drivers/mmc/core/sd.c      |  4 ++++
 include/trace/events/mmc.h | 42 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 265e1aeeb9d8..3bed7c4b6d75 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -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,7 @@ 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;
 }
 
diff --git a/include/trace/events/mmc.h b/include/trace/events/mmc.h
index 7b706ff21335..e45258e8a6cb 100644
--- a/include/trace/events/mmc.h
+++ b/include/trace/events/mmc.h
@@ -10,6 +10,48 @@
 #include <linux/mmc/host.h>
 #include <linux/tracepoint.h>
 
+TRACE_EVENT(sd_scr,
+
+	TP_PROTO(struct mmc_card *card, struct sd_scr *scr),
+
+	TP_ARGS(card, scr),
+
+	TP_STRUCT__entry(
+		__array(u32,			raw,	2)
+		__field(unsigned char,		sda_vsn)
+		__field(unsigned char,		sda_spec3)
+		__field(unsigned char,		bus_widths)
+		__field(unsigned char,		cmds)
+		__string(name,			mmc_hostname(card->host))
+	),
+
+	TP_fast_assign(
+		memcpy(__entry->raw, card->raw_scr, sizeof(card->raw_scr));
+		if (scr) {
+			__entry->sda_vsn = scr->sda_vsn;
+			__entry->sda_spec3 = scr->sda_spec3;
+			__entry->bus_widths = scr->bus_widths;
+			__entry->cmds = scr->cmds;
+		} else {
+			__entry->sda_vsn = 0;
+			__entry->sda_spec3 = 0;
+			__entry->bus_widths = 0;
+			__entry->cmds = 0;
+		}
+		__assign_str(name, mmc_hostname(card->host));
+	),
+
+	TP_printk("%s: version: %d, spec3: %d, width: %d, cmds: %d, "
+		"raw: %s",
+		  __get_str(name),
+		  __entry->sda_vsn,
+		  __entry->sda_spec3,
+		  __entry->bus_widths,
+		  __entry->cmds,
+		  __print_array(__entry->raw, 2, sizeof(u32))
+	)
+);
+
 TRACE_EVENT(mmc_request_start,
 
 	TP_PROTO(struct mmc_host *host, struct mmc_request *mrq),
-- 
2.21.0.392.gf8f6787159e-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v1 2/4] mmc: core: Add trace event for SD SSR response
  2019-04-15 22:52 [PATCH v1 1/4] mmc: core: Add trace event for SD SCR response Raul E Rangel
@ 2019-04-15 22:52 ` Raul E Rangel
  2019-04-15 23:34   ` Steven Rostedt
  2019-04-15 22:52 ` [PATCH v1 3/4] mmc: core: Add trace event for SD OCR response Raul E Rangel
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Raul E Rangel @ 2019-04-15 22:52 UTC (permalink / raw)
  To: linux-mmc, linux-trace-devel
  Cc: djkurtz, zwisler, Raul E Rangel, Steven Rostedt, hongjiefang,
	Ingo Molnar, linux-kernel, Kyle Roeschley, Avri Altman,
	Ulf Hansson

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}

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---

 drivers/mmc/core/sd.c      |  2 ++
 include/trace/events/mmc.h | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 3bed7c4b6d75..cc33a4f96c6a 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -282,6 +282,8 @@ static int mmc_read_ssr(struct mmc_card *card)
 		}
 	}
 
+	trace_sd_ssr(card);
+
 	/*
 	 * starting SD5.1 discard is supported if DISCARD_SUPPORT (b313) is set
 	 */
diff --git a/include/trace/events/mmc.h b/include/trace/events/mmc.h
index e45258e8a6cb..cad604ee800f 100644
--- a/include/trace/events/mmc.h
+++ b/include/trace/events/mmc.h
@@ -52,6 +52,37 @@ 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(
+		memcpy(__entry->raw, card->raw_ssr, sizeof(card->raw_ssr));
+		__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),
-- 
2.21.0.392.gf8f6787159e-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v1 3/4] mmc: core: Add trace event for SD OCR response
  2019-04-15 22:52 [PATCH v1 1/4] mmc: core: Add trace event for SD SCR response Raul E Rangel
  2019-04-15 22:52 ` [PATCH v1 2/4] mmc: core: Add trace event for SD SSR response Raul E Rangel
@ 2019-04-15 22:52 ` Raul E Rangel
  2019-04-15 22:52 ` [PATCH v1 4/4] mmc: core: Add trace event for CSD response Raul E Rangel
  2019-04-15 23:31 ` [PATCH v1 1/4] mmc: core: Add trace event for SD SCR response Steven Rostedt
  3 siblings, 0 replies; 7+ messages in thread
From: Raul E Rangel @ 2019-04-15 22:52 UTC (permalink / raw)
  To: linux-mmc, linux-trace-devel
  Cc: djkurtz, zwisler, Raul E Rangel, Steven Rostedt, Ingo Molnar,
	linux-kernel, Ulf Hansson

Example:
ocr_request: mmc0: 0x51200000 SDHC or SDXC Supported (HCS) | Maximum Performance (XPC) | Switch to 1.8V (S18R) | 3.3 ~ 3.4
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

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---

 drivers/mmc/core/sd_ops.c  |  6 +++
 include/trace/events/mmc.h | 91 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 97 insertions(+)

diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c
index 0bb0b8419016..4cf0f040f896 100644
--- a/drivers/mmc/core/sd_ops.c
+++ b/drivers/mmc/core/sd_ops.c
@@ -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;
diff --git a/include/trace/events/mmc.h b/include/trace/events/mmc.h
index cad604ee800f..fa82c010ae4e 100644
--- a/include/trace/events/mmc.h
+++ b/include/trace/events/mmc.h
@@ -10,6 +10,97 @@
 #include <linux/mmc/host.h>
 #include <linux/tracepoint.h>
 
+#define SD_OCR_REQUEST \
+	{SD_OCR_CCS, "SDHC or SDXC Supported (HCS)"}, \
+	{SD_OCR_XPC, "Maximum Performance (XPC)"}, \
+	{SD_ROCR_S18A, "Switch to 1.8V (S18R)"}, \
+	{MMC_VDD_165_195, "1.65 - 1.95"}, \
+	{MMC_VDD_20_21, "2.0 ~ 2.1"}, \
+	{MMC_VDD_21_22, "2.1 ~ 2.2"}, \
+	{MMC_VDD_22_23, "2.2 ~ 2.3"}, \
+	{MMC_VDD_23_24, "2.3 ~ 2.4"}, \
+	{MMC_VDD_24_25, "2.4 ~ 2.5"}, \
+	{MMC_VDD_25_26, "2.5 ~ 2.6"}, \
+	{MMC_VDD_26_27, "2.6 ~ 2.7"}, \
+	{MMC_VDD_27_28, "2.7 ~ 2.8"}, \
+	{MMC_VDD_28_29, "2.8 ~ 2.9"}, \
+	{MMC_VDD_29_30, "2.9 ~ 3.0"}, \
+	{MMC_VDD_30_31, "3.0 ~ 3.1"}, \
+	{MMC_VDD_31_32, "3.1 ~ 3.2"}, \
+	{MMC_VDD_32_33, "3.2 ~ 3.3"}, \
+	{MMC_VDD_33_34, "3.3 ~ 3.4"}, \
+	{MMC_VDD_34_35, "3.4 ~ 3.5"}, \
+	{MMC_VDD_35_36, "3.5 ~ 3.6"} \
+
+TRACE_EVENT(sd_ocr_request,
+
+	TP_PROTO(struct mmc_host *host, u32 ocr),
+
+	TP_ARGS(host, ocr),
+
+	TP_STRUCT__entry(
+		__field(u32,			ocr)
+		__string(name,			mmc_hostname(host))
+	),
+
+	TP_fast_assign(
+		__entry->ocr = ocr;
+		__assign_str(name, mmc_hostname(host));
+	),
+
+	TP_printk("%s: %#x %s",
+		  __get_str(name),
+		  __entry->ocr,
+		  __print_flags(__entry->ocr, " | ", SD_OCR_REQUEST)
+	)
+);
+
+#define SD_OCR_RESPONSE \
+	{MMC_CARD_BUSY, "Ready"}, \
+	{SD_OCR_CCS, "SDHC or SDXC (CCS)"}, \
+	{(1<<29), "UHS-II Card"}, \
+	{SD_ROCR_S18A, "1.8V Accepted (S18A)"}, \
+	{MMC_VDD_165_195, "1.65 - 1.95"}, \
+	{MMC_VDD_20_21, "2.0 ~ 2.1"}, \
+	{MMC_VDD_21_22, "2.1 ~ 2.2"}, \
+	{MMC_VDD_22_23, "2.2 ~ 2.3"}, \
+	{MMC_VDD_23_24, "2.3 ~ 2.4"}, \
+	{MMC_VDD_24_25, "2.4 ~ 2.5"}, \
+	{MMC_VDD_25_26, "2.5 ~ 2.6"}, \
+	{MMC_VDD_26_27, "2.6 ~ 2.7"}, \
+	{MMC_VDD_27_28, "2.7 ~ 2.8"}, \
+	{MMC_VDD_28_29, "2.8 ~ 2.9"}, \
+	{MMC_VDD_29_30, "2.9 ~ 3.0"}, \
+	{MMC_VDD_30_31, "3.0 ~ 3.1"}, \
+	{MMC_VDD_31_32, "3.1 ~ 3.2"}, \
+	{MMC_VDD_32_33, "3.2 ~ 3.3"}, \
+	{MMC_VDD_33_34, "3.3 ~ 3.4"}, \
+	{MMC_VDD_34_35, "3.4 ~ 3.5"}, \
+	{MMC_VDD_35_36, "3.5 ~ 3.6"}
+
+TRACE_EVENT(sd_ocr_response,
+
+	TP_PROTO(struct mmc_host *host, u32 ocr),
+
+	TP_ARGS(host, ocr),
+
+	TP_STRUCT__entry(
+		__field(u32,			ocr)
+		__string(name,			mmc_hostname(host))
+	),
+
+	TP_fast_assign(
+		__entry->ocr = ocr;
+		__assign_str(name, mmc_hostname(host));
+	),
+
+	TP_printk("%s: %#x %s",
+		  __get_str(name),
+		  __entry->ocr,
+		  __print_flags(__entry->ocr, " | ", SD_OCR_RESPONSE)
+	)
+);
+
 TRACE_EVENT(sd_scr,
 
 	TP_PROTO(struct mmc_card *card, struct sd_scr *scr),
-- 
2.21.0.392.gf8f6787159e-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v1 4/4] mmc: core: Add trace event for CSD response
  2019-04-15 22:52 [PATCH v1 1/4] mmc: core: Add trace event for SD SCR response Raul E Rangel
  2019-04-15 22:52 ` [PATCH v1 2/4] mmc: core: Add trace event for SD SSR response Raul E Rangel
  2019-04-15 22:52 ` [PATCH v1 3/4] mmc: core: Add trace event for SD OCR response Raul E Rangel
@ 2019-04-15 22:52 ` Raul E Rangel
  2019-04-15 23:31 ` [PATCH v1 1/4] mmc: core: Add trace event for SD SCR response Steven Rostedt
  3 siblings, 0 replies; 7+ messages in thread
From: Raul E Rangel @ 2019-04-15 22:52 UTC (permalink / raw)
  To: linux-mmc, linux-trace-devel
  Cc: djkurtz, zwisler, Raul E Rangel, Steven Rostedt, hongjiefang,
	Jennifer Dahm, linux-kernel, Shawn Lin, Kyle Roeschley,
	Ingo Molnar, Avri Altman, Ulf Hansson, Simon Horman

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

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---

 drivers/mmc/core/mmc.c     |  4 ++++
 drivers/mmc/core/sd.c      |  2 ++
 include/trace/events/mmc.h | 28 ++++++++++++++++++++++++++++
 3 files changed, 34 insertions(+)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 3e786ba204c3..46ce894f7c03 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -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;
 }
 
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index cc33a4f96c6a..4e704a7280ba 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -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;
 }
 
diff --git a/include/trace/events/mmc.h b/include/trace/events/mmc.h
index fa82c010ae4e..58f6f7808974 100644
--- a/include/trace/events/mmc.h
+++ b/include/trace/events/mmc.h
@@ -174,6 +174,34 @@ 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(
+		__entry->structure = card->csd.structure;
+		__entry->cmdclass = card->csd.cmdclass;
+		memcpy(__entry->raw, card->raw_csd, sizeof(card->raw_csd));
+		__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),
-- 
2.21.0.392.gf8f6787159e-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 1/4] mmc: core: Add trace event for SD SCR response
  2019-04-15 22:52 [PATCH v1 1/4] mmc: core: Add trace event for SD SCR response Raul E Rangel
                   ` (2 preceding siblings ...)
  2019-04-15 22:52 ` [PATCH v1 4/4] mmc: core: Add trace event for CSD response Raul E Rangel
@ 2019-04-15 23:31 ` Steven Rostedt
  2019-04-16 12:36   ` Avri Altman
  3 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2019-04-15 23:31 UTC (permalink / raw)
  To: Raul E Rangel
  Cc: linux-mmc, linux-trace-devel, djkurtz, zwisler, hongjiefang,
	Ingo Molnar, linux-kernel, Shawn Lin, Kyle Roeschley,
	Avri Altman, Ulf Hansson

On Mon, 15 Apr 2019 16:52:38 -0600
Raul E Rangel <rrangel@chromium.org> wrote:

> Example:
> sd_scr: mmc0: version: 2, spec3: 1, width: 5, cmds: 0, raw: {0x2b58000,0x0}
> 
> Signed-off-by: Raul E Rangel <rrangel@chromium.org>
> ---
> 
>  drivers/mmc/core/sd.c      |  4 ++++
>  include/trace/events/mmc.h | 42 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 46 insertions(+)
> 
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index 265e1aeeb9d8..3bed7c4b6d75 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -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,7 @@ 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;
>  }
>  
> diff --git a/include/trace/events/mmc.h b/include/trace/events/mmc.h
> index 7b706ff21335..e45258e8a6cb 100644
> --- a/include/trace/events/mmc.h
> +++ b/include/trace/events/mmc.h
> @@ -10,6 +10,48 @@
>  #include <linux/mmc/host.h>
>  #include <linux/tracepoint.h>
>  
> +TRACE_EVENT(sd_scr,
> +
> +	TP_PROTO(struct mmc_card *card, struct sd_scr *scr),
> +
> +	TP_ARGS(card, scr),
> +
> +	TP_STRUCT__entry(
> +		__array(u32,			raw,	2)
> +		__field(unsigned char,		sda_vsn)
> +		__field(unsigned char,		sda_spec3)
> +		__field(unsigned char,		bus_widths)
> +		__field(unsigned char,		cmds)
> +		__string(name,			mmc_hostname(card->host))
> +	),
> +
> +	TP_fast_assign(
> +		memcpy(__entry->raw, card->raw_scr, sizeof(card->raw_scr));

Having the memcpy() size be that of the source is dangerous. Not that
the destination will every be smaller, but I would highly suggest
either trying to see if "sizeof(__entry->raw)" works or at worse,
sizeof(u32)*2.

-- Steve

> +		if (scr) {
> +			__entry->sda_vsn = scr->sda_vsn;
> +			__entry->sda_spec3 = scr->sda_spec3;
> +			__entry->bus_widths = scr->bus_widths;
> +			__entry->cmds = scr->cmds;
> +		} else {
> +			__entry->sda_vsn = 0;
> +			__entry->sda_spec3 = 0;
> +			__entry->bus_widths = 0;
> +			__entry->cmds = 0;
> +		}
> +		__assign_str(name, mmc_hostname(card->host));
> +	),
> +
> +	TP_printk("%s: version: %d, spec3: %d, width: %d, cmds: %d, "
> +		"raw: %s",
> +		  __get_str(name),
> +		  __entry->sda_vsn,
> +		  __entry->sda_spec3,
> +		  __entry->bus_widths,
> +		  __entry->cmds,
> +		  __print_array(__entry->raw, 2, sizeof(u32))
> +	)
> +);
> +
>  TRACE_EVENT(mmc_request_start,
>  
>  	TP_PROTO(struct mmc_host *host, struct mmc_request *mrq),


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 2/4] mmc: core: Add trace event for SD SSR response
  2019-04-15 22:52 ` [PATCH v1 2/4] mmc: core: Add trace event for SD SSR response Raul E Rangel
@ 2019-04-15 23:34   ` Steven Rostedt
  0 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2019-04-15 23:34 UTC (permalink / raw)
  To: Raul E Rangel
  Cc: linux-mmc, linux-trace-devel, djkurtz, zwisler, hongjiefang,
	Ingo Molnar, linux-kernel, Kyle Roeschley, Avri Altman,
	Ulf Hansson

On Mon, 15 Apr 2019 16:52:39 -0600
Raul E Rangel <rrangel@chromium.org> wrote:

> 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}
> 
> Signed-off-by: Raul E Rangel <rrangel@chromium.org>
> ---
> 
>  drivers/mmc/core/sd.c      |  2 ++
>  include/trace/events/mmc.h | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 33 insertions(+)
> 
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index 3bed7c4b6d75..cc33a4f96c6a 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -282,6 +282,8 @@ static int mmc_read_ssr(struct mmc_card *card)
>  		}
>  	}
>  
> +	trace_sd_ssr(card);
> +
>  	/*
>  	 * starting SD5.1 discard is supported if DISCARD_SUPPORT (b313) is set
>  	 */
> diff --git a/include/trace/events/mmc.h b/include/trace/events/mmc.h
> index e45258e8a6cb..cad604ee800f 100644
> --- a/include/trace/events/mmc.h
> +++ b/include/trace/events/mmc.h
> @@ -52,6 +52,37 @@ 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(
> +		memcpy(__entry->raw, card->raw_ssr, sizeof(card->raw_ssr));

Again, memcpy() with the size of the source is dangerous.

Hmm, I wonder if a BUILD_BUG_ON(sizeof(u32)*16 < sizeof(card->raw_ssr))
would work here too. If it does, then that would be another approach.

-- Steve

> +		__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),


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH v1 1/4] mmc: core: Add trace event for SD SCR response
  2019-04-15 23:31 ` [PATCH v1 1/4] mmc: core: Add trace event for SD SCR response Steven Rostedt
@ 2019-04-16 12:36   ` Avri Altman
  0 siblings, 0 replies; 7+ messages in thread
From: Avri Altman @ 2019-04-16 12:36 UTC (permalink / raw)
  To: Steven Rostedt, Raul E Rangel
  Cc: linux-mmc, linux-trace-devel, djkurtz, zwisler, hongjiefang,
	Ingo Molnar, linux-kernel, Shawn Lin, Kyle Roeschley,
	Ulf Hansson

> 
> On Mon, 15 Apr 2019 16:52:38 -0600
> Raul E Rangel <rrangel@chromium.org> wrote:
> 
> > Example:
> > sd_scr: mmc0: version: 2, spec3: 1, width: 5, cmds: 0, raw: {0x2b58000,0x0}
> >
> > Signed-off-by: Raul E Rangel <rrangel@chromium.org>
> > ---
> >
> >  drivers/mmc/core/sd.c      |  4 ++++
> >  include/trace/events/mmc.h | 42
> ++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 46 insertions(+)
> >
> > diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> > index 265e1aeeb9d8..3bed7c4b6d75 100644
> > --- a/drivers/mmc/core/sd.c
> > +++ b/drivers/mmc/core/sd.c
> > @@ -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,7 @@ 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;
> >  }
> >
> > diff --git a/include/trace/events/mmc.h b/include/trace/events/mmc.h
> > index 7b706ff21335..e45258e8a6cb 100644
> > --- a/include/trace/events/mmc.h
> > +++ b/include/trace/events/mmc.h
> > @@ -10,6 +10,48 @@
> >  #include <linux/mmc/host.h>
> >  #include <linux/tracepoint.h>
> >
> > +TRACE_EVENT(sd_scr,
As all 3 new trace events (csd, scr, and ssr) are pretty close,
You might want to find a common ground and declare an event class.

Thanks,
Avri

> > +
> > +	TP_PROTO(struct mmc_card *card, struct sd_scr *scr),
> > +
> > +	TP_ARGS(card, scr),
> > +
> > +	TP_STRUCT__entry(
> > +		__array(u32,			raw,	2)
> > +		__field(unsigned char,		sda_vsn)
> > +		__field(unsigned char,		sda_spec3)
> > +		__field(unsigned char,		bus_widths)
> > +		__field(unsigned char,		cmds)
> > +		__string(name,			mmc_hostname(card->host))
> > +	),
> > +
> > +	TP_fast_assign(
> > +		memcpy(__entry->raw, card->raw_scr, sizeof(card-
> >raw_scr));
> 
> Having the memcpy() size be that of the source is dangerous. Not that
> the destination will every be smaller, but I would highly suggest
> either trying to see if "sizeof(__entry->raw)" works or at worse,
> sizeof(u32)*2.
> 
> -- Steve
> 
> > +		if (scr) {
> > +			__entry->sda_vsn = scr->sda_vsn;
> > +			__entry->sda_spec3 = scr->sda_spec3;
> > +			__entry->bus_widths = scr->bus_widths;
> > +			__entry->cmds = scr->cmds;
> > +		} else {
> > +			__entry->sda_vsn = 0;
> > +			__entry->sda_spec3 = 0;
> > +			__entry->bus_widths = 0;
> > +			__entry->cmds = 0;
> > +		}
> > +		__assign_str(name, mmc_hostname(card->host));
> > +	),
> > +
> > +	TP_printk("%s: version: %d, spec3: %d, width: %d, cmds: %d, "
> > +		"raw: %s",
> > +		  __get_str(name),
> > +		  __entry->sda_vsn,
> > +		  __entry->sda_spec3,
> > +		  __entry->bus_widths,
> > +		  __entry->cmds,
> > +		  __print_array(__entry->raw, 2, sizeof(u32))
> > +	)
> > +);
> > +
> >  TRACE_EVENT(mmc_request_start,
> >
> >  	TP_PROTO(struct mmc_host *host, struct mmc_request *mrq),


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-04-16 12:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-15 22:52 [PATCH v1 1/4] mmc: core: Add trace event for SD SCR response Raul E Rangel
2019-04-15 22:52 ` [PATCH v1 2/4] mmc: core: Add trace event for SD SSR response Raul E Rangel
2019-04-15 23:34   ` Steven Rostedt
2019-04-15 22:52 ` [PATCH v1 3/4] mmc: core: Add trace event for SD OCR response Raul E Rangel
2019-04-15 22:52 ` [PATCH v1 4/4] mmc: core: Add trace event for CSD response Raul E Rangel
2019-04-15 23:31 ` [PATCH v1 1/4] mmc: core: Add trace event for SD SCR response Steven Rostedt
2019-04-16 12:36   ` Avri Altman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).