linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] scsi: ufs: Add trace event for UIC commands and cleanup UIC struct
@ 2020-06-15  6:47 Stanley Chu
  2020-06-15  6:47 ` [PATCH v2 1/2] scsi: ufs: Remove unused field in struct uic_command Stanley Chu
  2020-06-15  6:47 ` [PATCH v2 2/2] scsi: ufs: Add trace event for UIC commands Stanley Chu
  0 siblings, 2 replies; 5+ messages in thread
From: Stanley Chu @ 2020-06-15  6:47 UTC (permalink / raw)
  To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb, asutoshd
  Cc: beanhuo, cang, matthias.bgg, bvanassche, linux-mediatek,
	linux-arm-kernel, linux-kernel, kuohong.wang, peter.wang,
	chun-hung.wu, andy.teng, cc.chou, chaotian.jing, Stanley Chu

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

v1 -> v2:
  - Rename "uic_send" to "send" and "uic_complete" to "complete"
  - Move "send" trace before UIC command is sent otherwise "send" trace may log incorrect arguments
  - Move "complete" trace to UIC interrupt handler to make logging time precise

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  | 26 ++++++++++++++++++++++++++
 drivers/scsi/ufs/ufshcd.h  |  4 ----
 include/trace/events/ufs.h | 31 +++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+), 4 deletions(-)

-- 
2.18.0

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

* [PATCH v2 1/2] scsi: ufs: Remove unused field in struct uic_command
  2020-06-15  6:47 [PATCH v2 0/2] scsi: ufs: Add trace event for UIC commands and cleanup UIC struct Stanley Chu
@ 2020-06-15  6:47 ` Stanley Chu
  2020-06-15  6:47 ` [PATCH v2 2/2] scsi: ufs: Add trace event for UIC commands Stanley Chu
  1 sibling, 0 replies; 5+ messages in thread
From: Stanley Chu @ 2020-06-15  6:47 UTC (permalink / raw)
  To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb, asutoshd
  Cc: beanhuo, cang, matthias.bgg, bvanassche, linux-mediatek,
	linux-arm-kernel, linux-kernel, kuohong.wang, peter.wang,
	chun-hung.wu, andy.teng, cc.chou, chaotian.jing, Stanley Chu

Remove unused field "cmd_active" and "result" in struct ufs_command.

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
---
 drivers/scsi/ufs/ufshcd.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index bf97d616e597..7fa35c78342b 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -88,8 +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
  */
 struct uic_command {
@@ -97,8 +95,6 @@ struct uic_command {
 	u32 argument1;
 	u32 argument2;
 	u32 argument3;
-	int cmd_active;
-	int result;
 	struct completion done;
 };
 
-- 
2.18.0

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

* [PATCH v2 2/2] scsi: ufs: Add trace event for UIC commands
  2020-06-15  6:47 [PATCH v2 0/2] scsi: ufs: Add trace event for UIC commands and cleanup UIC struct Stanley Chu
  2020-06-15  6:47 ` [PATCH v2 1/2] scsi: ufs: Remove unused field in struct uic_command Stanley Chu
@ 2020-06-15  6:47 ` Stanley Chu
  2020-06-15  7:13   ` Avri Altman
  1 sibling, 1 reply; 5+ messages in thread
From: Stanley Chu @ 2020-06-15  6:47 UTC (permalink / raw)
  To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb, asutoshd
  Cc: beanhuo, cang, matthias.bgg, bvanassche, linux-mediatek,
	linux-arm-kernel, linux-kernel, kuohong.wang, peter.wang,
	chun-hung.wu, andy.teng, cc.chou, chaotian.jing, 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

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

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Acked-by: Avri Altman <avri.altman@wdc.com>
---
 drivers/scsi/ufs/ufshcd.c  | 26 ++++++++++++++++++++++++++
 include/trace/events/ufs.h | 31 +++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index ad4fc829cbb2..1fd2fd526c68 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -340,6 +340,26 @@ 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, "send"))
+		cmd = ucmd->command;
+	else
+		cmd = ufshcd_readl(hba, REG_UIC_COMMAND);
+
+	trace_ufshcd_uic_command(dev_name(hba->dev), str, cmd,
+				 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)
 {
@@ -2052,6 +2072,8 @@ ufshcd_dispatch_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd)
 	ufshcd_writel(hba, uic_cmd->argument2, REG_UIC_COMMAND_ARG_2);
 	ufshcd_writel(hba, uic_cmd->argument3, REG_UIC_COMMAND_ARG_3);
 
+	ufshcd_add_uic_command_trace(hba, uic_cmd, "send");
+
 	/* Write UIC Cmd */
 	ufshcd_writel(hba, uic_cmd->command & COMMAND_OPCODE_MASK,
 		      REG_UIC_COMMAND);
@@ -4825,11 +4847,15 @@ static irqreturn_t ufshcd_uic_cmd_compl(struct ufs_hba *hba, u32 intr_status)
 			ufshcd_get_uic_cmd_result(hba);
 		hba->active_uic_cmd->argument3 =
 			ufshcd_get_dme_attr_val(hba);
+		ufshcd_add_uic_command_trace(hba, hba->active_uic_cmd,
+					     "complete");
 		complete(&hba->active_uic_cmd->done);
 		retval = IRQ_HANDLED;
 	}
 
 	if ((intr_status & UFSHCD_UIC_PWR_MASK) && hba->uic_async_done) {
+		ufshcd_add_uic_command_trace(hba, hba->active_uic_cmd,
+					     "complete");
 		complete(hba->uic_async_done);
 		retval = IRQ_HANDLED;
 	}
diff --git a/include/trace/events/ufs.h b/include/trace/events/ufs.h
index 5f300739240d..84841b3a7ffd 100644
--- a/include/trace/events/ufs.h
+++ b/include/trace/events/ufs.h
@@ -249,6 +249,37 @@ TRACE_EVENT(ufshcd_command,
 	)
 );
 
+TRACE_EVENT(ufshcd_uic_command,
+	TP_PROTO(const char *dev_name, const char *str, u32 cmd,
+		 u32 arg1, u32 arg2, u32 arg3),
+
+	TP_ARGS(dev_name, str, cmd, arg1, arg2, arg3),
+
+	TP_STRUCT__entry(
+		__string(dev_name, dev_name)
+		__string(str, str)
+		__field(u32, cmd)
+		__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->arg1 = arg1;
+		__entry->arg2 = arg2;
+		__entry->arg3 = arg3;
+	),
+
+	TP_printk(
+		"%s: %s: cmd: 0x%x, arg1: 0x%x, arg2: 0x%x, arg3: 0x%x",
+		__get_str(str), __get_str(dev_name), __entry->cmd,
+		__entry->arg1, __entry->arg2, __entry->arg3
+	)
+);
+
 TRACE_EVENT(ufshcd_upiu,
 	TP_PROTO(const char *dev_name, const char *str, void *hdr, void *tsf),
 
-- 
2.18.0

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

* RE: [PATCH v2 2/2] scsi: ufs: Add trace event for UIC commands
  2020-06-15  6:47 ` [PATCH v2 2/2] scsi: ufs: Add trace event for UIC commands Stanley Chu
@ 2020-06-15  7:13   ` Avri Altman
  2020-06-15  7:24     ` Stanley Chu
  0 siblings, 1 reply; 5+ messages in thread
From: Avri Altman @ 2020-06-15  7:13 UTC (permalink / raw)
  To: Stanley Chu, linux-scsi, martin.petersen, alim.akhtar, jejb, asutoshd
  Cc: beanhuo, cang, matthias.bgg, bvanassche, linux-mediatek,
	linux-arm-kernel, linux-kernel, kuohong.wang, peter.wang,
	chun-hung.wu, andy.teng, cc.chou, chaotian.jing

>         /* Write UIC Cmd */
>         ufshcd_writel(hba, uic_cmd->command & COMMAND_OPCODE_MASK,
>                       REG_UIC_COMMAND);
> @@ -4825,11 +4847,15 @@ static irqreturn_t ufshcd_uic_cmd_compl(struct
> ufs_hba *hba, u32 intr_status)
>                         ufshcd_get_uic_cmd_result(hba);
>                 hba->active_uic_cmd->argument3 =
>                         ufshcd_get_dme_attr_val(hba);
> +               ufshcd_add_uic_command_trace(hba, hba->active_uic_cmd,
> +                                            "complete");
>                 complete(&hba->active_uic_cmd->done);
>                 retval = IRQ_HANDLED;
>         }
> 
>         if ((intr_status & UFSHCD_UIC_PWR_MASK) && hba->uic_async_done) {
> +               ufshcd_add_uic_command_trace(hba, hba->active_uic_cmd,
> +                                            "complete");
>                 complete(hba->uic_async_done);
>                 retval = IRQ_HANDLED;


Why not call ufshcd_add_uic_command_trace once if retval == IRQ_HANDLED?
Is it that the exact timestamp?

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

* RE: [PATCH v2 2/2] scsi: ufs: Add trace event for UIC commands
  2020-06-15  7:13   ` Avri Altman
@ 2020-06-15  7:24     ` Stanley Chu
  0 siblings, 0 replies; 5+ messages in thread
From: Stanley Chu @ 2020-06-15  7:24 UTC (permalink / raw)
  To: Avri Altman
  Cc: linux-scsi, martin.petersen, alim.akhtar, jejb, asutoshd,
	beanhuo, cang, matthias.bgg, bvanassche, linux-mediatek,
	linux-arm-kernel, linux-kernel, kuohong.wang, peter.wang,
	chun-hung.wu, andy.teng, cc.chou, chaotian.jing

Hi Avri,

On Mon, 2020-06-15 at 07:13 +0000, Avri Altman wrote:
> >         /* Write UIC Cmd */
> >         ufshcd_writel(hba, uic_cmd->command & COMMAND_OPCODE_MASK,
> >                       REG_UIC_COMMAND);
> > @@ -4825,11 +4847,15 @@ static irqreturn_t ufshcd_uic_cmd_compl(struct
> > ufs_hba *hba, u32 intr_status)
> >                         ufshcd_get_uic_cmd_result(hba);
> >                 hba->active_uic_cmd->argument3 =
> >                         ufshcd_get_dme_attr_val(hba);
> > +               ufshcd_add_uic_command_trace(hba, hba->active_uic_cmd,
> > +                                            "complete");
> >                 complete(&hba->active_uic_cmd->done);
> >                 retval = IRQ_HANDLED;
> >         }
> > 
> >         if ((intr_status & UFSHCD_UIC_PWR_MASK) && hba->uic_async_done) {
> > +               ufshcd_add_uic_command_trace(hba, hba->active_uic_cmd,
> > +                                            "complete");
> >                 complete(hba->uic_async_done);
> >                 retval = IRQ_HANDLED;
> 
> 
> Why not call ufshcd_add_uic_command_trace once if retval == IRQ_HANDLED?
> Is it that the exact timestamp?

Thanks! This makes the code cleaner.
Fixed in v3.

Stanley Chu

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

end of thread, other threads:[~2020-06-15  7:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15  6:47 [PATCH v2 0/2] scsi: ufs: Add trace event for UIC commands and cleanup UIC struct Stanley Chu
2020-06-15  6:47 ` [PATCH v2 1/2] scsi: ufs: Remove unused field in struct uic_command Stanley Chu
2020-06-15  6:47 ` [PATCH v2 2/2] scsi: ufs: Add trace event for UIC commands Stanley Chu
2020-06-15  7:13   ` Avri Altman
2020-06-15  7:24     ` Stanley Chu

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).