mmc: core: Add trace event for SD SCR response
Subsystems (2)
PATCH 1/4 mmc: core: Add trace event for SD SCR response
Example:sd_scr: mmc0: version: 2, spec3: 1, width: 5, cmds: 0, raw: {0x2b58000,0x0}
---
drivers/mmc/core/sd.c | 4 ++++ include/trace/events/mmc.h | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)
drivers/mmc/core/sd.c +4 -0
@@ -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 ; }
include/trace/events/mmc.h +42 -0
48 lines not on this page · raw message
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
PATCH 2/4 mmc: core: Add trace event for SD SSR response
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 | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)
drivers/mmc/core/sd.c +2 -0
@@ -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 */
include/trace/events/mmc.h +31 -0
@@ -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),
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
Steven Rostedt
maintainerRe: [PATCH v1 2/4] mmc: core: Add trace event for SD SSR response
Quoted 37 lines · On Mon, 15 Apr 2019 16:52:39 -0600 Raul E Rangel <[email protected]> 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 <[email protected]>---
drivers/mmc/core/sd.c | 2 ++ include/trace/events/mmc.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)drivers/mmc/core/sd.c +2
-0@@ -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 */ include/trace/events/mmc.h +6
-0@@ -52,6 +52,37 @@ TRACE_EVENT(sd_scr, ) ); +TRACE_EVENT(sd_ssr, + + TP_PROTO(struct mmc_card *card), + + TP_ARGS(card), +
include/trace/events/mmc.h TRACE_EVENT(sd_scr, · line 70
Quoted 10 lines
include/trace/events/mmc.h +10
-0+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
Quoted 18 lines
include/trace/events/mmc.h +15
-0+ __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),
PATCH 3/4 mmc: core: Add trace event for SD OCR response
In reply to Raul E RangelExample:ocr_request: mmc0: 0x51200000 SDHC or SDXC Supported (HCS) | Maximum Performance (XPC) | Switch to 1.8V (S18R) | 3.3 ~ 3.4ocr_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 | 91 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+)
drivers/mmc/core/sd_ops.c +6 -0
@@ -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 +91 -0
97 lines not on this page · raw message
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
PATCH 4/4 mmc: core: Add trace event for CSD response
In reply to Raul E RangelExample: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 | 28 ++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+)
drivers/mmc/core/mmc.c +4 -0
@@ -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
@@ -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 +28 -0
@@ -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),
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
Steven Rostedt
maintainerQuoted 54 lines · On Mon, 15 Apr 2019 16:52:38 -0600 Raul E Rangel <[email protected]> wrote:
Example:
sd_scr: mmc0: version: 2, spec3: 1, width: 5, cmds: 0, raw: {0x2b58000,0x0}Signed-off-by Raul E Rangel <[email protected]>---
drivers/mmc/core/sd.c | 4 ++++ include/trace/events/mmc.h | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)drivers/mmc/core/sd.c +4
-0@@ -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 ; }include/trace/events/mmc.h +7
-0@@ -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(
include/trace/events/mmc.h line 29
Quoted 10 lines
include/trace/events/mmc.h +10
-0+ __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
Quoted 28 lines
include/trace/events/mmc.h +25
-0+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),
Quoted 52 lines
Quoted 8 lines · On Mon, 15 Apr 2019 16:52:38 -0600 Raul E Rangel <[email protected]> wrote:
Example:
sd_scr: mmc0: version: 2, spec3: 1, width: 5, cmds: 0, raw: {0x2b58000,0x0}Signed-off-by Raul E Rangel <[email protected]>---
drivers/mmc/core/sd.c | 4 ++++ include/trace/events/mmc.h | 42++++++++++++++++++++++++++++++++++++++
Quoted 39 lines
2 files changed, 46 insertions(+)drivers/mmc/core/sd.c +4
-0@@ -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 ; }include/trace/events/mmc.h +0
-0@@ -10,6 +10,48 @@#include <linux/mmc/host.h> #include <linux/tracepoint.h>
Quoted 1 line
include/trace/events/mmc.h line 13
Quoted 1 line
include/trace/events/mmc.h +1
-0+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
Quoted 53 lines
Quoted 7 lines
include/trace/events/mmc.h +7
-0+ + TP_PROTO(struct mmc_card *card, struct sd_scr *scr), + + TP_ARGS(card, scr), + + TP_STRUCT__entry( + __array(u32, raw, 2)include/trace/events/mmc.h
Quoted 10 lines
include/trace/events/mmc.h +9
-0+ __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
Quoted 28 lines
include/trace/events/mmc.h +25
-0+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),