Commit 8ceddda3 authored by Changyuan Lyu's avatar Changyuan Lyu Committed by Martin K. Petersen
Browse files

scsi: pm80xx: Add tracepoints

Tracepoints for tracking controller and ATA commands issued and completed.

Link: https://lore.kernel.org/r/20211115215750.131696-2-changyuanl@google.com


Acked-by: default avatarJack Wang <jinpu.wang@ionos.com>
Co-developed-by: default avatarAkshat Jain <akshatzen@google.com>
Signed-off-by: default avatarAkshat Jain <akshatzen@google.com>
Signed-off-by: default avatarChangyuan Lyu <changyuanl@google.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 85361558
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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
+16 −0
Original line number Diff line number Diff line
@@ -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;
+7 −0
Original line number Diff line number Diff line
@@ -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
@@ -4530,6 +4531,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;
@@ -4749,6 +4751,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;
+10 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/*
 * Trace events in pm8001 driver.
 *
 * Copyright 2020 Google LLC
 * Author: Akshat Jain <akshatzen@google.com>
 */

#define CREATE_TRACE_POINTS
#include "pm80xx_tracepoints.h"
+85 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Trace events in pm8001 driver.
 *
 * Copyright 2020 Google LLC
 * Author: Akshat Jain <akshatzen@google.com>
 */

#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>