Skip to contentSkip to conversation

scsi: ufs: Add trace event for UIC commands

PATCH Superseded Stanley Chu 3 participants 7 messages Jun 12, 2020 – Jun 14, 2020

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 scsi: ufs: Remove unused field in struct uic_command

In reply to Stanley Chu

Remove unused field "cmd_active" in struct ufs_command.

---
 drivers/scsi/ufs/ufshcd.h | 2 --
 1 file changed, 2 deletions(-)
drivers/scsi/ufs/ufshcd.h +0 -2
index bf97d616e597..814e44871ff0 100644
@@ -88,7 +88,6 @@ enum dev_cmd_type {
  * @argument1: UIC command argument 1
  * @argument2: UIC command argument 2
  * @argument3: UIC command argument 3
- * @cmd_active: Indicate if UIC command is outstanding
  * @result: UIC command result
  * @done: UIC command completion
  */
@@ -97,7 +96,6 @@ struct uic_command {
 	u32 argument1;
 	u32 argument2;
 	u32 argument3;
-	int cmd_active;
 	int result;
 	struct completion done;
 };
Signature · 1 line
2.18.0
#3 lore raw

PATCH 2/2 scsi: ufs: Add trace event for UIC commands

In reply to Stanley Chu

Use the ftrace infrastructure to conditionally trace UFS UIC command events.

New trace event "ufshcd_uic_command" is created, which samples the following UFS UIC command data:
- Device name
- Optional identification string
- UIC command opcode
- UIC command argument1
- UIC command argument2
- UIC command argement3
- UIC command execution result

Usage:
echo 1 > /sys/kernel/debug/tracing/events/ufs/enable cat /sys/kernel/debug/tracing/trace_pipe

---
 drivers/scsi/ufs/ufshcd.c  | 29 +++++++++++++++++++++++++++++
 include/trace/events/ufs.h | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)
drivers/scsi/ufs/ufshcd.c +29 -0
index c197a3315d21..181617966658 100644
@@ -339,6 +339,27 @@ static void ufshcd_add_tm_upiu_trace(struct ufs_hba *hba, unsigned int tag,
 			&descp->input_param1);
 }
 
+static void ufshcd_add_uic_command_trace(struct ufs_hba *hba,
+					 struct uic_command *ucmd,
+					 const char *str)
+{
+	u32 cmd;
+
+	if (!trace_ufshcd_uic_command_enabled())
+		return;
+
+	if (!strcmp(str, "uic_send"))
+		cmd = ucmd->command;
+	else
+		cmd = ufshcd_readl(hba, REG_UIC_COMMAND);
+
+	trace_ufshcd_uic_command(dev_name(hba->dev), str, cmd,
+				 ucmd->result,
+				 ufshcd_readl(hba, REG_UIC_COMMAND_ARG_1),
+				 ufshcd_readl(hba, REG_UIC_COMMAND_ARG_2),
+				 ufshcd_readl(hba, REG_UIC_COMMAND_ARG_3));
+}
+
 static void ufshcd_add_command_trace(struct ufs_hba *hba,
 		unsigned int tag, const char *str)
 {
@@ -2054,6 +2075,8 @@ ufshcd_dispatch_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
 	/* Write UIC Cmd */
 	ufshcd_writel(hba, uic_cmd->command & COMMAND_OPCODE_MASK,
 		      REG_UIC_COMMAND);
+
+	ufshcd_add_uic_command_trace(hba, uic_cmd, "uic_send");
 }
 
 /**
@@ -2080,6 +2103,9 @@ ufshcd_wait_for_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
 	hba->active_uic_cmd = NULL;
 	spin_unlock_irqrestore(hba->host->host_lock, flags);
 
+	uic_cmd->result = ret;
+	ufshcd_add_uic_command_trace(hba, uic_cmd, "uic_complete");
+
 	return ret;
 }
 
@@ -3760,6 +3786,9 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
 		ret = (status != PWR_OK) ? status : -1;
 	}
 out:
+	cmd->result = ret;
+	ufshcd_add_uic_command_trace(hba, cmd, "uic_complete");
+
 	if (ret) {
 		ufshcd_print_host_state(hba);
 		ufshcd_print_pwr_info(hba);
include/trace/events/ufs.h +33 -0
index 5f300739240d..cf8d568d5a13 100644
@@ -249,6 +249,39 @@ TRACE_EVENT(ufshcd_command,
 	)
 );
 
+TRACE_EVENT(ufshcd_uic_command,
+	TP_PROTO(const char *dev_name, const char *str, u32 cmd, int result,
+		 u32 arg1, u32 arg2, u32 arg3),
+
+	TP_ARGS(dev_name, str, cmd, result, arg1, arg2, arg3),
+
+	TP_STRUCT__entry(
+		__string(dev_name, dev_name)
+		__string(str, str)
+		__field(u32, cmd)
+		__field(int, result)
+		__field(u32, arg1)
+		__field(u32, arg2)
+		__field(u32, arg3)
+	),
+
+	TP_fast_assign(
+		__assign_str(dev_name, dev_name);
+		__assign_str(str, str);
+		__entry->cmd = cmd;
+		__entry->result = result;
+		__entry->arg1 = arg1;
+		__entry->arg2 = arg2;
+		__entry->arg3 = arg3;
+	),
+
+	TP_printk(
+		"%s: %s: cmd: 0x%x, arg1: 0x%x, arg2: 0x%x, arg3: 0x%x, result: %d",
+		__get_str(str), __get_str(dev_name), __entry->cmd,
+		__entry->arg1, __entry->arg2, __entry->arg3, __entry->result
+	)
+);
+
 TRACE_EVENT(ufshcd_upiu,
 	TP_PROTO(const char *dev_name, const char *str, void *hdr, void *tsf),
 
Signature · 1 line
2.18.0
#0 lore raw

cover scsi: ufs: Add trace event for UIC commands

Hi,
This series adds trace event for UIC commands and do a small cleanup in struct uic_command.

Stanley Chu (2):
scsi: ufs: Remove unused field in struct uic_command
scsi: ufs: Add trace event for UIC commands

 drivers/scsi/ufs/ufshcd.c  | 29 +++++++++++++++++++++++++++++
 drivers/scsi/ufs/ufshcd.h  |  2 --
 include/trace/events/ufs.h | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+), 2 deletions(-)
Signature · 1 line
2.18.0
Reviewed-by on v1 1/2
#2 lore raw

RE: [PATCH v1 1/2] scsi: ufs: Remove unused field in struct uic_command

In reply to Stanley Chu

Hi Stanley

Quoted 6 lines

-----Original Message-----
From: Stanley Chu <[email protected]>
Sent: 12 June 2020 20:40
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]

Quoted 8 lines

Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; [email protected]; [email protected]; [email protected]; chun- [email protected]; [email protected]; [email protected]; [email protected]; Stanley Chu <[email protected]>
Subject: [PATCH v1 1/2] scsi: ufs: Remove unused field in struct

uic_command

Quoted 5 lines

Remove unused field "cmd_active" in struct ufs_command.

---

Quoted 25 lines
 drivers/scsi/ufs/ufshcd.h | 2 --
 1 file changed, 2 deletions(-)
drivers/scsi/ufs/ufshcd.h index renamed from drivers/scsi/ufs/ufshcd.h +0 -0

bf97d616e597..814e44871ff0 100644

drivers/scsi/ufs/ufshcd.h +0 -3
@@ -88,7 +88,6 @@ enum dev_cmd_type {
  * @argument1: UIC command argument 1
  * @argument2: UIC command argument 2
  * @argument3: UIC command argument 3
- * @cmd_active: Indicate if UIC command is outstanding
  * @result: UIC command result
  * @done: UIC command completion
  */
@@ -97,7 +96,6 @@ struct uic_command {
 	u32 argument1;
 	u32 argument2;
 	u32 argument3;
-	int cmd_active;
 	int result;
 	struct completion done;
 };
--

2.18.0

#4 lore raw
In reply to Stanley Chu

drivers/scsi/ufs/ufshcd.c static void ufshcd_add_tm_upiu_trace(struct ufs_hba *hba, unsigned int tag, · line 354

Quoted 13 lines
drivers/scsi/ufs/ufshcd.c +13 -0
+static void ufshcd_add_uic_command_trace(struct ufs_hba *hba,
+                                        struct uic_command *ucmd,
+                                        const char *str)
+{
+       u32 cmd;
+
+       if (!trace_ufshcd_uic_command_enabled())
+               return;
+
+       if (!strcmp(str, "uic_send"))
+               cmd = ucmd->command;
+       else
+               cmd = ufshcd_readl(hba, REG_UIC_COMMAND);

Why on complete you can't just use ucmd->command as well?

drivers/scsi/ufs/ufshcd.c static void ufshcd_add_tm_upiu_trace(struct ufs_hba *hba, unsigned int tag, · line 360

Quoted 6 lines
drivers/scsi/ufs/ufshcd.c +6 -0
+
+       trace_ufshcd_uic_command(dev_name(hba->dev), str, cmd,
+                                ucmd->result,
+                                ufshcd_readl(hba, REG_UIC_COMMAND_ARG_1),
+                                ufshcd_readl(hba, REG_UIC_COMMAND_ARG_2),
+                                ufshcd_readl(hba, REG_UIC_COMMAND_ARG_3));

Why can't you just use the ucmd members?
Why need to read those?

Quoted 18 lines
drivers/scsi/ufs/ufshcd.c +4 -0
+}
 
 
+
 static void ufshcd_add_command_trace(struct ufs_hba *hba,
                unsigned int tag, const char *str)
 {
@@ -2054,6 +2075,8 @@ ufshcd_dispatch_uic_cmd(struct ufs_hba *hba,
 struct uic_command *uic_cmd)
        /* Write UIC Cmd */
        ufshcd_writel(hba, uic_cmd->command & COMMAND_OPCODE_MASK,
                      REG_UIC_COMMAND);
+
+       ufshcd_add_uic_command_trace(hba, uic_cmd, "uic_send");
 }
 

/**

drivers/scsi/ufs/ufshcd.c ufshcd_wait_for_uic_cmd(struct ufs_hba *hba, · line 2111

Quoted 9 lines
drivers/scsi/ufs/ufshcd.c +3 -0
@@ -2080,6 +2103,9 @@ ufshcd_wait_for_uic_cmd(struct ufs_hba *hba,
 struct uic_command *uic_cmd)
        hba->active_uic_cmd = NULL;
        spin_unlock_irqrestore(hba->host->host_lock, flags);
 
+       uic_cmd->result = ret;
+       ufshcd_add_uic_command_trace(hba, uic_cmd, "uic_complete");
+
        return ret;
 }

Can't you just call the "send" and "complete" from ufshcd_send_uic_cmd?

Quoted 41 lines
drivers/scsi/ufs/ufshcd.c +3 -0
@@ -3760,6 +3786,9 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba,
 struct uic_command *cmd)
                ret = (status != PWR_OK) ? status : -1;
        }
 out:
+       cmd->result = ret;
+       ufshcd_add_uic_command_trace(hba, cmd, "uic_complete");
+
        if (ret) {
                ufshcd_print_host_state(hba);
                ufshcd_print_pwr_info(hba);
include/trace/events/ufs.h +21 -0
index 5f300739240d..cf8d568d5a13 100644
@@ -249,6 +249,39 @@ TRACE_EVENT(ufshcd_command,
        )
 );
 
+TRACE_EVENT(ufshcd_uic_command,
+       TP_PROTO(const char *dev_name, const char *str, u32 cmd, int result,
+                u32 arg1, u32 arg2, u32 arg3),
+
+       TP_ARGS(dev_name, str, cmd, result, arg1, arg2, arg3),
+
+       TP_STRUCT__entry(
+               __string(dev_name, dev_name)
+               __string(str, str)
+               __field(u32, cmd)
+               __field(int, result)
+               __field(u32, arg1)
+               __field(u32, arg2)
+               __field(u32, arg3)
+       ),
+
+       TP_fast_assign(
+               __assign_str(dev_name, dev_name);
+               __assign_str(str, str);
+               __entry->cmd = cmd;
+               __entry->result = result;

include/trace/events/ufs.h TRACE_EVENT(ufshcd_command, · line 282

Quoted 10 lines
include/trace/events/ufs.h +10 -0
+               __entry->arg1 = arg1;
+               __entry->arg2 = arg2;
+               __entry->arg3 = arg3;
+       ),
+
+       TP_printk(
+               "%s: %s: cmd: 0x%x, arg1: 0x%x, arg2: 0x%x, arg3: 0x%x, result: %d",
+               __get_str(str), __get_str(dev_name), __entry->cmd,
+               __entry->arg1, __entry->arg2, __entry->arg3, __entry->result
+       )

Personally, as those trace events aren't very human readable anyway, I would just dump the uic command, And let the parsers do their job.
And if this is the case, result is redundant as it is part of arg2

Thanks,
Avri

Quoted 7 lines
include/trace/events/ufs.h +2 -1
+);
+
 TRACE_EVENT(ufshcd_upiu,
        TP_PROTO(const char *dev_name, const char *str, void *hdr, void *tsf),
 
--

2.18.0

#5 lore raw

Hi Avri,

Quoted 6 lines · Avri Altman
Quoted 6 lines
drivers/scsi/ufs/ufshcd.c +6 -0
+static void ufshcd_add_uic_command_trace(struct ufs_hba *hba,
+                                        struct uic_command *ucmd,
+                                        const char *str)
+{
+       u32 cmd;
+
Quoted 8 lines

drivers/scsi/ufs/ufshcd.c static void ufshcd_add_tm_upiu_trace(struct ufs_hba *hba, unsigned int tag, · line 354

Quoted 7 lines
drivers/scsi/ufs/ufshcd.c +7 -0
+       if (!trace_ufshcd_uic_command_enabled())
+               return;
+
+       if (!strcmp(str, "uic_send"))
+               cmd = ucmd->command;
+       else
+               cmd = ufshcd_readl(hba, REG_UIC_COMMAND);

Why on complete you can't just use ucmd->command as well?

Reading registers is really helpful for debugging to check if host UIC command register really received the command before.

But the original requesting UIC command shall be logged in trace so ucmd->command is logged during "send", and the command in register is read and logged during "completed". Then we could simply check them to know if something wrong while sending the command.

This concept is similar as current UTP command trace events that doorbell register is read and dumped in the trace.

Quoted 9 lines

drivers/scsi/ufs/ufshcd.c static void ufshcd_add_tm_upiu_trace(struct ufs_hba *hba, unsigned int tag, · line 360

Quoted 7 lines
drivers/scsi/ufs/ufshcd.c +6 -0
+
+       trace_ufshcd_uic_command(dev_name(hba->dev), str, cmd,
+                                ucmd->result,
+                                ufshcd_readl(hba, REG_UIC_COMMAND_ARG_1),
+                                ufshcd_readl(hba, REG_UIC_COMMAND_ARG_2),
+                                ufshcd_readl(hba, REG_UIC_COMMAND_ARG_3));

Why can't you just use the ucmd members?
Why need to read those?

As above same reason, reading registers can know which arguments are exactly sent to the device.

This is very helpful for fast issue breakdown if UIC command is not responded under expectation.

Here, we also really want to keep the original requesting arguments from "ucmd", just like UIC command. However, arguments in register will be changed after UIC command is done so we can not do the same way as UIC command. So a compromise is here that we logged the arguments which host register exactly received in trace.

Quoted 23 lines
Quoted 23 lines
drivers/scsi/ufs/ufshcd.c +4 -0
+}
 
 
+
 static void ufshcd_add_command_trace(struct ufs_hba *hba,
                unsigned int tag, const char *str)
 {
@@ -2054,6 +2075,8 @@ ufshcd_dispatch_uic_cmd(struct ufs_hba *hba,
 struct uic_command *uic_cmd)
        /* Write UIC Cmd */
        ufshcd_writel(hba, uic_cmd->command & COMMAND_OPCODE_MASK,
                      REG_UIC_COMMAND);
+
+       ufshcd_add_uic_command_trace(hba, uic_cmd, "uic_send");
 }
 

/**

drivers/scsi/ufs/ufshcd.c +0 -0
@@ -2080,6 +2103,9 @@ ufshcd_wait_for_uic_cmd(struct ufs_hba *hba,
 struct uic_command *uic_cmd)
        hba->active_uic_cmd = NULL;
        spin_unlock_irqrestore(hba->host->host_lock, flags);
 
Quoted 6 lines

drivers/scsi/ufs/ufshcd.c ufshcd_wait_for_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) · line 2110

Quoted 5 lines
drivers/scsi/ufs/ufshcd.c +3 -0
+       uic_cmd->result = ret;
+       ufshcd_add_uic_command_trace(hba, uic_cmd, "uic_complete");
+
        return ret;
 }

Can't you just call the "send" and "complete" from ufshcd_send_uic_cmd?

For "send", we would like to log the time as precise as possible so "send" event is logged while UIC command is sent.

Thanks so much! Your question reminds me that "send" trace shall be moved before UIC command is sent otherwise register value may be changed before logging "send" trace. I will fix this in next version.

For "completed", to make logging time as closed to UIC command completion as possible, maybe I need to change the logging timing to ufshcd_uic_cmd_compl(), just like UTP command completion trace which is logged in __ufshcd_transfer_reg_compl().

If you have no objection, I will try to fix this in next version.

Quoted 48 lines
Quoted 48 lines
drivers/scsi/ufs/ufshcd.c +3 -0
@@ -3760,6 +3786,9 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba,
 struct uic_command *cmd)
                ret = (status != PWR_OK) ? status : -1;
        }
 out:
+       cmd->result = ret;
+       ufshcd_add_uic_command_trace(hba, cmd, "uic_complete");
+
        if (ret) {
                ufshcd_print_host_state(hba);
                ufshcd_print_pwr_info(hba);
include/trace/events/ufs.h +26 -0
index 5f300739240d..cf8d568d5a13 100644
@@ -249,6 +249,39 @@ TRACE_EVENT(ufshcd_command,
        )
 );
 
+TRACE_EVENT(ufshcd_uic_command,
+       TP_PROTO(const char *dev_name, const char *str, u32 cmd, int result,
+                u32 arg1, u32 arg2, u32 arg3),
+
+       TP_ARGS(dev_name, str, cmd, result, arg1, arg2, arg3),
+
+       TP_STRUCT__entry(
+               __string(dev_name, dev_name)
+               __string(str, str)
+               __field(u32, cmd)
+               __field(int, result)
+               __field(u32, arg1)
+               __field(u32, arg2)
+               __field(u32, arg3)
+       ),
+
+       TP_fast_assign(
+               __assign_str(dev_name, dev_name);
+               __assign_str(str, str);
+               __entry->cmd = cmd;
+               __entry->result = result;
+               __entry->arg1 = arg1;
+               __entry->arg2 = arg2;
+               __entry->arg3 = arg3;
+       ),
+
Quoted 8 lines

include/trace/events/ufs.h TRACE_EVENT(ufshcd_command, · line 282

Quoted 5 lines
include/trace/events/ufs.h +5 -0
+       TP_printk(
+               "%s: %s: cmd: 0x%x, arg1: 0x%x, arg2: 0x%x, arg3: 0x%x, result: %d",
+               __get_str(str), __get_str(dev_name), __entry->cmd,
+               __entry->arg1, __entry->arg2, __entry->arg3, __entry->result
+       )

Personally, as those trace events aren't very human readable anyway, I would just dump the uic command, And let the parsers do their job.
And if this is the case, result is redundant as it is part of arg2

My original thought is to log some exceptions, like "-ETIMEDOUT" in "result". But if I changed "completion" trace handling to interrupt handler, there will be no chance to log those exceptions. This is OK because UTP trace is exactly behave this way: No completion event in trace if request is not back. And if this way is implemented, "result" is definitely redundant and shall be removed.

Thanks,
Stanley Chu

Acked-by
#6 lore raw
Quoted 168 lines

Hi Avri,

Quoted 6 lines · Avri Altman
Quoted 6 lines
drivers/scsi/ufs/ufshcd.c +6 -0
+static void ufshcd_add_uic_command_trace(struct ufs_hba *hba,
+                                        struct uic_command *ucmd,
+                                        const char *str)
+{
+       u32 cmd;
+
Quoted 8 lines

drivers/scsi/ufs/ufshcd.c static void ufshcd_add_tm_upiu_trace(struct ufs_hba *hba, unsigned int tag, · line 354

Quoted 7 lines
drivers/scsi/ufs/ufshcd.c +7 -0
+       if (!trace_ufshcd_uic_command_enabled())
+               return;
+
+       if (!strcmp(str, "uic_send"))
+               cmd = ucmd->command;
+       else
+               cmd = ufshcd_readl(hba, REG_UIC_COMMAND);

Why on complete you can't just use ucmd->command as well?

Reading registers is really helpful for debugging to check if host UIC command register really received the command before.

But the original requesting UIC command shall be logged in trace so ucmd->command is logged during "send", and the command in register is read and logged during "completed". Then we could simply check them to know if something wrong while sending the command.

This concept is similar as current UTP command trace events that doorbell register is read and dumped in the trace.

Quoted 9 lines

drivers/scsi/ufs/ufshcd.c static void ufshcd_add_tm_upiu_trace(struct ufs_hba *hba, unsigned int tag, · line 360

Quoted 7 lines
drivers/scsi/ufs/ufshcd.c +6 -0
+
+       trace_ufshcd_uic_command(dev_name(hba->dev), str, cmd,
+                                ucmd->result,
+                                ufshcd_readl(hba, REG_UIC_COMMAND_ARG_1),
+                                ufshcd_readl(hba, REG_UIC_COMMAND_ARG_2),
+                                ufshcd_readl(hba, REG_UIC_COMMAND_ARG_3));

Why can't you just use the ucmd members?
Why need to read those?

As above same reason, reading registers can know which arguments are exactly sent to the device.

This is very helpful for fast issue breakdown if UIC command is not responded under expectation.

Here, we also really want to keep the original requesting arguments from "ucmd", just like UIC command. However, arguments in register will be changed after UIC command is done so we can not do the same way as UIC command. So a compromise is here that we logged the arguments which host register exactly received in trace.

Quoted 4 lines
Quoted 2 lines

+}

Quoted 8 lines

drivers/scsi/ufs/ufshcd.c ufshcd_dispatch_uic_cmd(struct ufs_hba *hba, · line 2077

Quoted 8 lines
drivers/scsi/ufs/ufshcd.c +1 -0
+
 static void ufshcd_add_command_trace(struct ufs_hba *hba,
                unsigned int tag, const char *str)
 {
@@ -2054,6 +2075,8 @@ ufshcd_dispatch_uic_cmd(struct ufs_hba *hba,
 struct uic_command *uic_cmd)
        /* Write UIC Cmd */
        ufshcd_writel(hba, uic_cmd->command &

COMMAND_OPCODE_MASK,

Quoted 11 lines
Quoted 11 lines
drivers/scsi/ufs/ufshcd.c +2 -0
                      REG_UIC_COMMAND);
+
+       ufshcd_add_uic_command_trace(hba, uic_cmd, "uic_send");
 }
 

/**

drivers/scsi/ufs/ufshcd.c +0 -0
@@ -2080,6 +2103,9 @@ ufshcd_wait_for_uic_cmd(struct ufs_hba *hba,
 struct uic_command *uic_cmd)
        hba->active_uic_cmd = NULL;
        spin_unlock_irqrestore(hba->host->host_lock, flags);
 
Quoted 6 lines

drivers/scsi/ufs/ufshcd.c ufshcd_wait_for_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) · line 2110

Quoted 5 lines
drivers/scsi/ufs/ufshcd.c +3 -0
+       uic_cmd->result = ret;
+       ufshcd_add_uic_command_trace(hba, uic_cmd, "uic_complete");
+
        return ret;
 }

Can't you just call the "send" and "complete" from ufshcd_send_uic_cmd?

For "send", we would like to log the time as precise as possible so "send" event is logged while UIC command is sent.

Thanks so much! Your question reminds me that "send" trace shall be moved before UIC command is sent otherwise register value may be changed before logging "send" trace. I will fix this in next version.

For "completed", to make logging time as closed to UIC command completion as possible, maybe I need to change the logging timing to ufshcd_uic_cmd_compl(), just like UTP command completion trace which is logged in __ufshcd_transfer_reg_compl().

If you have no objection, I will try to fix this in next version.

Quoted 4 lines

Review static int ufshcd_uic_pwr_ctrl(struct ufs_hba

Quoted 4 lines
(quoted diff) +0 -0
@@ -3760,6 +3786,9 @@ static int ufshcd_uic_pwr_ctrl(struct ufs_hba

*hba,

Quoted 18 lines
Quoted 18 lines
drivers/scsi/ufs/ufshcd.c +3 -0
 struct uic_command *cmd)
                ret = (status != PWR_OK) ? status : -1;
        }
 out:
+       cmd->result = ret;
+       ufshcd_add_uic_command_trace(hba, cmd, "uic_complete");
+
        if (ret) {
                ufshcd_print_host_state(hba);
                ufshcd_print_pwr_info(hba);
include/trace/events/ufs.h +0 -0
index 5f300739240d..cf8d568d5a13 100644
@@ -249,6 +249,39 @@ TRACE_EVENT(ufshcd_command,
        )
 );
 
Quoted 2 lines

include/trace/events/ufs.h TRACE_EVENT(ufshcd_command, · line 253

Quoted 2 lines
include/trace/events/ufs.h +2 -0
+TRACE_EVENT(ufshcd_uic_command,
+       TP_PROTO(const char *dev_name, const char *str, u32 cmd, int

result,

Quoted 18 lines
Quoted 18 lines
include/trace/events/ufs.h +18 -0
+                u32 arg1, u32 arg2, u32 arg3),
+
+       TP_ARGS(dev_name, str, cmd, result, arg1, arg2, arg3),
+
+       TP_STRUCT__entry(
+               __string(dev_name, dev_name)
+               __string(str, str)
+               __field(u32, cmd)
+               __field(int, result)
+               __field(u32, arg1)
+               __field(u32, arg2)
+               __field(u32, arg3)
+       ),
+
+       TP_fast_assign(
+               __assign_str(dev_name, dev_name);
+               __assign_str(str, str);
+               __entry->cmd = cmd;
Quoted 8 lines

include/trace/events/ufs.h TRACE_EVENT(ufshcd_command,

Quoted 8 lines
include/trace/events/ufs.h +8 -0
+               __entry->result = result;
+               __entry->arg1 = arg1;
+               __entry->arg2 = arg2;
+               __entry->arg3 = arg3;
+       ),
+
+       TP_printk(
+               "%s: %s: cmd: 0x%x, arg1: 0x%x, arg2: 0x%x, arg3: 0x%x, result:

%d",

Quoted 4 lines

include/trace/events/ufs.h TRACE_EVENT(ufshcd_command, · line 282

Quoted 3 lines
include/trace/events/ufs.h +3 -0
+               __get_str(str), __get_str(dev_name), __entry->cmd,
+               __entry->arg1, __entry->arg2, __entry->arg3, __entry->result
+       )

Personally, as those trace events aren't very human readable anyway, I

would just dump the uic command,

Quoted 2 lines

And let the parsers do their job.
And if this is the case, result is redundant as it is part of arg2

My original thought is to log some exceptions, like "-ETIMEDOUT" in "result". But if I changed "completion" trace handling to interrupt handler, there will be no chance to log those exceptions. This is OK because UTP trace is exactly behave this way: No completion event in trace if request is not back. And if this way is implemented, "result" is definitely redundant and shall be removed.

Thanks,
Stanley Chu