Skip to contentSkip to conversation

This patchset adds tracepoints to pm80xx

PATCH Applied Changyuan Lyu 3 participants 7 messages Nov 15, 2021 – Nov 23, 2021

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

v2 cover This patchset adds tracepoints to pm80xx

v2: added le32_to_cpu() when calling trace_pm80xx_mpi_build_cmd() to eliminate the incorrect type error in patch scsi: pm80xx: Add pm80xx_mpi_build_cmd tracepoint.

Changyuan Lyu (2):
scsi: pm80xx: Add tracepoints
scsi: pm80xx: Add pm80xx_mpi_build_cmd tracepoint

 drivers/scsi/pm8001/Makefile             |   7 +-
 drivers/scsi/pm8001/pm8001_hwi.c         |   5 +
 drivers/scsi/pm8001/pm8001_sas.c         |  16 ++++
 drivers/scsi/pm8001/pm80xx_hwi.c         |   7 ++
 drivers/scsi/pm8001/pm80xx_tracepoints.c |  10 ++
 drivers/scsi/pm8001/pm80xx_tracepoints.h | 113 +++++++++++++++++++++++
 6 files changed, 156 insertions(+), 2 deletions(-)
 create mode 100644 drivers/scsi/pm8001/pm80xx_tracepoints.c
 create mode 100644 drivers/scsi/pm8001/pm80xx_tracepoints.h
Signature · 1 line
2.34.0.rc1.387.gb447b232ab-goog
#1 lore raw

PATCH v2 1/2 scsi: pm80xx: Add tracepoints

Tracepoints for tracking controller and ATA commands issued and completed.

---
 drivers/scsi/pm8001/Makefile             |  7 +-
 drivers/scsi/pm8001/pm8001_sas.c         | 16 +++++
 drivers/scsi/pm8001/pm80xx_hwi.c         |  7 ++
 drivers/scsi/pm8001/pm80xx_tracepoints.c | 10 +++
 drivers/scsi/pm8001/pm80xx_tracepoints.h | 85 ++++++++++++++++++++++++
 5 files changed, 123 insertions(+), 2 deletions(-)
 create mode 100644 drivers/scsi/pm8001/pm80xx_tracepoints.c
 create mode 100644 drivers/scsi/pm8001/pm80xx_tracepoints.h
drivers/scsi/pm8001/Makefile +5 -2
index 02b7338999cc..bbb51b7312f1 100644
@@ -6,9 +6,12 @@
 
 
 obj-$(CONFIG_SCSI_PM8001) += pm80xx.o
+
+CFLAGS_pm80xx_tracepoints.o := -I$(src)
+
 pm80xx-y += pm8001_init.o \
 		pm8001_sas.o  \
 		pm8001_ctl.o  \
 		pm8001_hwi.o  \
-		pm80xx_hwi.o
-
+		pm80xx_hwi.o  \
+		pm80xx_tracepoints.o
drivers/scsi/pm8001/pm8001_sas.c +16 -0
index 83e73009db5c..c9a16eef38c1 100644
@@ -40,6 +40,7 @@
 
 #include <linux/slab.h>
 #include "pm8001_sas.h"
+#include "pm80xx_tracepoints.h"
 
 /**
  * pm8001_find_tag - from sas task to find out  tag that belongs to this task
@@ -527,6 +528,9 @@ int pm8001_queue_command(struct sas_task *task, gfp_t gfp_flags)
 void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha,
 	struct sas_task *task, struct pm8001_ccb_info *ccb, u32 ccb_idx)
 {
+	struct ata_queued_cmd *qc;
+	struct pm8001_device *pm8001_dev;
+
 	if (!ccb->task)
 		return;
 	if (!sas_protocol_ata(task->task_proto))
@@ -549,6 +553,18 @@ void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha,
 		/* do nothing */
 		break;
 	}
+
+	if (sas_protocol_ata(task->task_proto)) {
+		// For SCSI/ATA commands uldd_task points to ata_queued_cmd
+		qc = task->uldd_task;
+		pm8001_dev = ccb->device;
+		trace_pm80xx_request_complete(pm8001_ha->id,
+			pm8001_dev ? pm8001_dev->attached_phy : PM8001_MAX_PHYS,
+			ccb_idx, 0 /* ctlr_opcode not known */,
+			qc ? qc->tf.command : 0, // ata opcode
+			pm8001_dev ? atomic_read(&pm8001_dev->running_req) : -1);
+	}
+
 	task->lldd_task = NULL;
 	ccb->task = NULL;
 	ccb->ccb_tag = 0xFFFFFFFF;
drivers/scsi/pm8001/pm80xx_hwi.c +7 -0
index b9f6d83ff380..5e6ab7a3b996 100644
@@ -42,6 +42,7 @@
  #include "pm80xx_hwi.h"
  #include "pm8001_chips.h"
  #include "pm8001_ctl.h"
+#include "pm80xx_tracepoints.h"
 
 #define SMP_DIRECT 1
 #define SMP_INDIRECT 2
@@ -4543,6 +4544,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
 	struct sas_task *task = ccb->task;
 	struct domain_device *dev = task->dev;
 	struct pm8001_device *pm8001_ha_dev = dev->lldd_dev;
+	struct ata_queued_cmd *qc = task->uldd_task;
 	u32 tag = ccb->ccb_tag;
 	int ret;
 	u32 q_index, cpu_id;
@@ -4762,6 +4764,11 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
 			}
 		}
 	}
+	trace_pm80xx_request_issue(pm8001_ha->id,
+				ccb->device ? ccb->device->attached_phy : PM8001_MAX_PHYS,
+				ccb->ccb_tag, opc,
+				qc ? qc->tf.command : 0, // ata opcode
+				ccb->device ? atomic_read(&ccb->device->running_req) : 0);
 	ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc,
 			&sata_cmd, sizeof(sata_cmd), q_index);
 	return ret;
drivers/scsi/pm8001/pm80xx_tracepoints.c new file +10 -0
new file mode 100644
index 000000000000..344aface9cdb
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Trace events in pm8001 driver.
+ *
+ * Copyright 2020 Google LLC
+ * Author: Akshat Jain <[email protected]>
+ */
+
+#define CREATE_TRACE_POINTS
+#include "pm80xx_tracepoints.h"
drivers/scsi/pm8001/pm80xx_tracepoints.h new file +85 -0

85 lines not on this page · raw message

Signature · 1 line
2.34.0.rc1.387.gb447b232ab-goog
Acked-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] scsi: pm80xx: Add tracepoints

Quoted 6 lines · Changyuan Lyu

Tracepoints for tracking controller and ATA commands issued and completed.

looks ok, thx.

Quoted 212 lines
---
 drivers/scsi/pm8001/Makefile             |  7 +-
 drivers/scsi/pm8001/pm8001_sas.c         | 16 +++++
 drivers/scsi/pm8001/pm80xx_hwi.c         |  7 ++
 drivers/scsi/pm8001/pm80xx_tracepoints.c | 10 +++
 drivers/scsi/pm8001/pm80xx_tracepoints.h | 85 ++++++++++++++++++++++++
 5 files changed, 123 insertions(+), 2 deletions(-)
 create mode 100644 drivers/scsi/pm8001/pm80xx_tracepoints.c
 create mode 100644 drivers/scsi/pm8001/pm80xx_tracepoints.h
drivers/scsi/pm8001/Makefile +5 -2
index 02b7338999cc..bbb51b7312f1 100644
@@ -6,9 +6,12 @@
 
 
 obj-$(CONFIG_SCSI_PM8001) += pm80xx.o
+
+CFLAGS_pm80xx_tracepoints.o := -I$(src)
+
 pm80xx-y += pm8001_init.o \
                pm8001_sas.o  \
                pm8001_ctl.o  \
                pm8001_hwi.o  \
-               pm80xx_hwi.o
-
+               pm80xx_hwi.o  \
+               pm80xx_tracepoints.o
drivers/scsi/pm8001/pm8001_sas.c +16 -0
index 83e73009db5c..c9a16eef38c1 100644
@@ -40,6 +40,7 @@
 
 #include <linux/slab.h>
 #include "pm8001_sas.h"
+#include "pm80xx_tracepoints.h"
 
 /**
  * pm8001_find_tag - from sas task to find out  tag that belongs to this task
@@ -527,6 +528,9 @@ int pm8001_queue_command(struct sas_task *task, gfp_t gfp_flags)
 void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha,
        struct sas_task *task, struct pm8001_ccb_info *ccb, u32 ccb_idx)
 {
+       struct ata_queued_cmd *qc;
+       struct pm8001_device *pm8001_dev;
+
        if (!ccb->task)
                return;
        if (!sas_protocol_ata(task->task_proto))
@@ -549,6 +553,18 @@ void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha,
                /* do nothing */
                break;
        }
+
+       if (sas_protocol_ata(task->task_proto)) {
+               // For SCSI/ATA commands uldd_task points to ata_queued_cmd
+               qc = task->uldd_task;
+               pm8001_dev = ccb->device;
+               trace_pm80xx_request_complete(pm8001_ha->id,
+                       pm8001_dev ? pm8001_dev->attached_phy : PM8001_MAX_PHYS,
+                       ccb_idx, 0 /* ctlr_opcode not known */,
+                       qc ? qc->tf.command : 0, // ata opcode
+                       pm8001_dev ? atomic_read(&pm8001_dev->running_req) : -1);
+       }
+
        task->lldd_task = NULL;
        ccb->task = NULL;
        ccb->ccb_tag = 0xFFFFFFFF;
drivers/scsi/pm8001/pm80xx_hwi.c +7 -0
index b9f6d83ff380..5e6ab7a3b996 100644
@@ -42,6 +42,7 @@
  #include "pm80xx_hwi.h"
  #include "pm8001_chips.h"
  #include "pm8001_ctl.h"
+#include "pm80xx_tracepoints.h"
 
 #define SMP_DIRECT 1
 #define SMP_INDIRECT 2
@@ -4543,6 +4544,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
        struct sas_task *task = ccb->task;
        struct domain_device *dev = task->dev;
        struct pm8001_device *pm8001_ha_dev = dev->lldd_dev;
+       struct ata_queued_cmd *qc = task->uldd_task;
        u32 tag = ccb->ccb_tag;
        int ret;
        u32 q_index, cpu_id;
@@ -4762,6 +4764,11 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha,
                        }
                }
        }
+       trace_pm80xx_request_issue(pm8001_ha->id,
+                               ccb->device ? ccb->device->attached_phy : PM8001_MAX_PHYS,
+                               ccb->ccb_tag, opc,
+                               qc ? qc->tf.command : 0, // ata opcode
+                               ccb->device ? atomic_read(&ccb->device->running_req) : 0);
        ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc,
                        &sata_cmd, sizeof(sata_cmd), q_index);
        return ret;
drivers/scsi/pm8001/pm80xx_tracepoints.c new file +10 -0
new file mode 100644
index 000000000000..344aface9cdb
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Trace events in pm8001 driver.
+ *
+ * Copyright 2020 Google LLC
+ * Author: Akshat Jain <[email protected]>
+ */
+
+#define CREATE_TRACE_POINTS
+#include "pm80xx_tracepoints.h"
drivers/scsi/pm8001/pm80xx_tracepoints.h new file +85 -1
new file mode 100644
index 000000000000..84fcfecfd624
@@ -0,0 +1,85 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Trace events in pm8001 driver.
+ *
+ * Copyright 2020 Google LLC
+ * Author: Akshat Jain <[email protected]>
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM pm80xx
+
+#if !defined(_TRACE_PM80XX_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_PM80XX_H
+
+#include <linux/tracepoint.h>
+#include "pm8001_sas.h"
+
+TRACE_EVENT(pm80xx_request_issue,
+           TP_PROTO(u32 id, u32 phy_id, u32 htag, u32 ctlr_opcode,
+                    u16 ata_opcode, int running_req),
+
+           TP_ARGS(id, phy_id, htag, ctlr_opcode, ata_opcode, running_req),
+
+           TP_STRUCT__entry(
+                   __field(u32, id)
+                   __field(u32, phy_id)
+                   __field(u32, htag)
+                   __field(u32, ctlr_opcode)
+                   __field(u16,  ata_opcode)
+                   __field(int, running_req)
+                   ),
+
+           TP_fast_assign(
+                   __entry->id = id;
+                   __entry->phy_id = phy_id;
+                   __entry->htag = htag;
+                   __entry->ctlr_opcode = ctlr_opcode;
+                   __entry->ata_opcode = ata_opcode;
+                   __entry->running_req = running_req;
+                   ),
+
+           TP_printk("ctlr_id = %u phy_id = %u htag = %#x, ctlr_opcode = %#x ata_opcode = %#x running_req = %d",
+                   __entry->id, __entry->phy_id, __entry->htag,
+                   __entry->ctlr_opcode, __entry->ata_opcode,
+                   __entry->running_req)
+);
+
+TRACE_EVENT(pm80xx_request_complete,
+           TP_PROTO(u32 id, u32 phy_id, u32 htag, u32 ctlr_opcode,
+                    u16 ata_opcode, int running_req),
+
+           TP_ARGS(id, phy_id, htag, ctlr_opcode, ata_opcode, running_req),
+
+           TP_STRUCT__entry(
+                   __field(u32, id)
+                   __field(u32, phy_id)
+                   __field(u32, htag)
+                   __field(u32, ctlr_opcode)
+                   __field(u16,  ata_opcode)
+                   __field(int, running_req)
+                   ),
+
+           TP_fast_assign(
+                   __entry->id = id;
+                   __entry->phy_id = phy_id;
+                   __entry->htag = htag;
+                   __entry->ctlr_opcode = ctlr_opcode;
+                   __entry->ata_opcode = ata_opcode;
+                   __entry->running_req = running_req;
+                   ),
+
+           TP_printk("ctlr_id = %u phy_id = %u htag = %#x, ctlr_opcode = %#x ata_opcode = %#x running_req = %d",
+                   __entry->id, __entry->phy_id, __entry->htag,
+                   __entry->ctlr_opcode, __entry->ata_opcode,
+                   __entry->running_req)
+);
+
+#endif /* _TRACE_PM80XX_H_ */
+
+#undef TRACE_INCLUDE_PATH
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_PATH .
+#define TRACE_INCLUDE_FILE pm80xx_tracepoints
+
+#include <trace/define_trace.h>
--

2.34.0.rc1.387.gb447b232ab-goog

#3 lore raw

PATCH v2 2/2 scsi: pm80xx: Add pm80xx_mpi_build_cmd tracepoint

In reply to Changyuan Lyu

pm8001_mpi_build_cmd() prepares and sends all commands to a controller. Having pm80xx_mpi_build_cmd tracepoint can help us with latency issues.

this patch depends on patch "scsi: pm80xx: Add tracepoints".

---
 drivers/scsi/pm8001/pm8001_hwi.c         |  5 +++++
 drivers/scsi/pm8001/pm80xx_tracepoints.h | 28 ++++++++++++++++++++++++
 2 files changed, 33 insertions(+)
drivers/scsi/pm8001/pm8001_hwi.c +5 -0
index 124cb69740c6..a63362bdd884 100644
@@ -42,6 +42,7 @@
  #include "pm8001_hwi.h"
  #include "pm8001_chips.h"
  #include "pm8001_ctl.h"
+ #include "pm80xx_tracepoints.h"
 
 /**
  * read_main_config_table - read the configure table and save it.
@@ -1324,6 +1325,10 @@ int pm8001_mpi_build_cmd(struct pm8001_hba_info *pm8001_ha,
 	unsigned long flags;
 	int q_index = circularQ - pm8001_ha->inbnd_q_tbl;
 	int rv;
+	u32 htag = le32_to_cpu(*(__le32 *)payload);
+
+	trace_pm80xx_mpi_build_cmd(pm8001_ha->id, opCode, htag, q_index,
+		circularQ->producer_idx, le32_to_cpu(circularQ->consumer_index));
 
 	WARN_ON(q_index >= PM8001_MAX_INB_NUM);
 	spin_lock_irqsave(&circularQ->iq_lock, flags);
drivers/scsi/pm8001/pm80xx_tracepoints.h +28 -0
index 84fcfecfd624..5e669a8a9344 100644
@@ -75,6 +75,34 @@ TRACE_EVENT(pm80xx_request_complete,
 		    __entry->running_req)
 );
 
+TRACE_EVENT(pm80xx_mpi_build_cmd,
+	    TP_PROTO(u32 id, u32 opc, u32 htag, u32 qi, u32 pi, u32 ci),
+
+	    TP_ARGS(id, opc, htag, qi, pi, ci),
+
+	    TP_STRUCT__entry(
+		    __field(u32, id)
+		    __field(u32, opc)
+		    __field(u32, htag)
+		    __field(u32, qi)
+		    __field(u32, pi)
+		    __field(u32, ci)
+		    ),
+
+	    TP_fast_assign(
+		    __entry->id = id;
+		    __entry->opc = opc;
+		    __entry->htag = htag;
+		    __entry->qi = qi;
+		    __entry->pi = pi;
+		    __entry->ci = ci;
+		    ),
+
+	    TP_printk("ctlr_id = %u opc = %#x htag = %#x QI = %u PI = %u CI = %u",
+		    __entry->id, __entry->opc, __entry->htag, __entry->qi,
+		    __entry->pi, __entry->ci)
+);
+
 #endif /* _TRACE_PM80XX_H_ */
 
 #undef TRACE_INCLUDE_PATH
Signature · 1 line
2.34.0.rc1.387.gb447b232ab-goog
Acked-by on v2 2/2
#4 lore raw

Re: [PATCH v2 2/2] scsi: pm80xx: Add pm80xx_mpi_build_cmd tracepoint

Quoted 8 lines · Changyuan Lyu

pm8001_mpi_build_cmd() prepares and sends all commands to a controller. Having pm80xx_mpi_build_cmd tracepoint can help us with latency issues.

this patch depends on patch "scsi: pm80xx: Add tracepoints".

looks ok, thx.

Quoted 70 lines
---
 drivers/scsi/pm8001/pm8001_hwi.c         |  5 +++++
 drivers/scsi/pm8001/pm80xx_tracepoints.h | 28 ++++++++++++++++++++++++
 2 files changed, 33 insertions(+)
drivers/scsi/pm8001/pm8001_hwi.c +5 -0
index 124cb69740c6..a63362bdd884 100644
@@ -42,6 +42,7 @@
  #include "pm8001_hwi.h"
  #include "pm8001_chips.h"
  #include "pm8001_ctl.h"
+ #include "pm80xx_tracepoints.h"
 
 /**
  * read_main_config_table - read the configure table and save it.
@@ -1324,6 +1325,10 @@ int pm8001_mpi_build_cmd(struct pm8001_hba_info *pm8001_ha,
        unsigned long flags;
        int q_index = circularQ - pm8001_ha->inbnd_q_tbl;
        int rv;
+       u32 htag = le32_to_cpu(*(__le32 *)payload);
+
+       trace_pm80xx_mpi_build_cmd(pm8001_ha->id, opCode, htag, q_index,
+               circularQ->producer_idx, le32_to_cpu(circularQ->consumer_index));
 
        WARN_ON(q_index >= PM8001_MAX_INB_NUM);
        spin_lock_irqsave(&circularQ->iq_lock, flags);
drivers/scsi/pm8001/pm80xx_tracepoints.h +28 -1
index 84fcfecfd624..5e669a8a9344 100644
@@ -75,6 +75,34 @@ TRACE_EVENT(pm80xx_request_complete,
                    __entry->running_req)
 );
 
+TRACE_EVENT(pm80xx_mpi_build_cmd,
+           TP_PROTO(u32 id, u32 opc, u32 htag, u32 qi, u32 pi, u32 ci),
+
+           TP_ARGS(id, opc, htag, qi, pi, ci),
+
+           TP_STRUCT__entry(
+                   __field(u32, id)
+                   __field(u32, opc)
+                   __field(u32, htag)
+                   __field(u32, qi)
+                   __field(u32, pi)
+                   __field(u32, ci)
+                   ),
+
+           TP_fast_assign(
+                   __entry->id = id;
+                   __entry->opc = opc;
+                   __entry->htag = htag;
+                   __entry->qi = qi;
+                   __entry->pi = pi;
+                   __entry->ci = ci;
+                   ),
+
+           TP_printk("ctlr_id = %u opc = %#x htag = %#x QI = %u PI = %u CI = %u",
+                   __entry->id, __entry->opc, __entry->htag, __entry->qi,
+                   __entry->pi, __entry->ci)
+);
+
 #endif /* _TRACE_PM80XX_H_ */
 
 #undef TRACE_INCLUDE_PATH
--

2.34.0.rc1.387.gb447b232ab-goog

#5 lore raw
In reply to Changyuan Lyu

Changyuan,

Quoted 3 lines

Changyuan Lyu (2):
scsi: pm80xx: Add tracepoints
scsi: pm80xx: Add pm80xx_mpi_build_cmd tracepoint

Applied to 5.17/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#6 lore raw
In reply to Changyuan Lyu
Quoted 10 lines · Changyuan Lyu

v2: added le32_to_cpu() when calling trace_pm80xx_mpi_build_cmd() to eliminate the incorrect type error in patch scsi: pm80xx: Add pm80xx_mpi_build_cmd tracepoint.

Changyuan Lyu (2):
scsi: pm80xx: Add tracepoints
scsi: pm80xx: Add pm80xx_mpi_build_cmd tracepoint

[...]

Applied to 5.17/scsi-queue, thanks!

[1/2] scsi: pm80xx: Add tracepoints

      https://git.kernel.org/mkp/scsi/c/8ceddda38d42
[2/2] scsi: pm80xx: Add pm80xx_mpi_build_cmd tracepoint
      https://git.kernel.org/mkp/scsi/c/0137b129f215
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering