Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Jack Wang <jinpu.wang@ionos.com>
Co-developed-by: Akshat Jain <akshatzen@google.com>
Signed-off-by: Akshat Jain <akshatzen@google.com>
Signed-off-by: Changyuan Lyu <changyuanl@google.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Changyuan Lyu and committed by
Martin K. Petersen
8ceddda3 85361558

+123 -2
+5 -2
drivers/scsi/pm8001/Makefile
··· 6 6 7 7 8 8 obj-$(CONFIG_SCSI_PM8001) += pm80xx.o 9 + 10 + CFLAGS_pm80xx_tracepoints.o := -I$(src) 11 + 9 12 pm80xx-y += pm8001_init.o \ 10 13 pm8001_sas.o \ 11 14 pm8001_ctl.o \ 12 15 pm8001_hwi.o \ 13 - pm80xx_hwi.o 14 - 16 + pm80xx_hwi.o \ 17 + pm80xx_tracepoints.o
+16
drivers/scsi/pm8001/pm8001_sas.c
··· 40 40 41 41 #include <linux/slab.h> 42 42 #include "pm8001_sas.h" 43 + #include "pm80xx_tracepoints.h" 43 44 44 45 /** 45 46 * pm8001_find_tag - from sas task to find out tag that belongs to this task ··· 528 527 void pm8001_ccb_task_free(struct pm8001_hba_info *pm8001_ha, 529 528 struct sas_task *task, struct pm8001_ccb_info *ccb, u32 ccb_idx) 530 529 { 530 + struct ata_queued_cmd *qc; 531 + struct pm8001_device *pm8001_dev; 532 + 531 533 if (!ccb->task) 532 534 return; 533 535 if (!sas_protocol_ata(task->task_proto)) ··· 553 549 /* do nothing */ 554 550 break; 555 551 } 552 + 553 + if (sas_protocol_ata(task->task_proto)) { 554 + // For SCSI/ATA commands uldd_task points to ata_queued_cmd 555 + qc = task->uldd_task; 556 + pm8001_dev = ccb->device; 557 + trace_pm80xx_request_complete(pm8001_ha->id, 558 + pm8001_dev ? pm8001_dev->attached_phy : PM8001_MAX_PHYS, 559 + ccb_idx, 0 /* ctlr_opcode not known */, 560 + qc ? qc->tf.command : 0, // ata opcode 561 + pm8001_dev ? atomic_read(&pm8001_dev->running_req) : -1); 562 + } 563 + 556 564 task->lldd_task = NULL; 557 565 ccb->task = NULL; 558 566 ccb->ccb_tag = 0xFFFFFFFF;
+7
drivers/scsi/pm8001/pm80xx_hwi.c
··· 42 42 #include "pm80xx_hwi.h" 43 43 #include "pm8001_chips.h" 44 44 #include "pm8001_ctl.h" 45 + #include "pm80xx_tracepoints.h" 45 46 46 47 #define SMP_DIRECT 1 47 48 #define SMP_INDIRECT 2 ··· 4531 4530 struct sas_task *task = ccb->task; 4532 4531 struct domain_device *dev = task->dev; 4533 4532 struct pm8001_device *pm8001_ha_dev = dev->lldd_dev; 4533 + struct ata_queued_cmd *qc = task->uldd_task; 4534 4534 u32 tag = ccb->ccb_tag; 4535 4535 int ret; 4536 4536 u32 q_index, cpu_id; ··· 4751 4749 } 4752 4750 } 4753 4751 } 4752 + trace_pm80xx_request_issue(pm8001_ha->id, 4753 + ccb->device ? ccb->device->attached_phy : PM8001_MAX_PHYS, 4754 + ccb->ccb_tag, opc, 4755 + qc ? qc->tf.command : 0, // ata opcode 4756 + ccb->device ? atomic_read(&ccb->device->running_req) : 0); 4754 4757 ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, 4755 4758 &sata_cmd, sizeof(sata_cmd), q_index); 4756 4759 return ret;
+10
drivers/scsi/pm8001/pm80xx_tracepoints.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Trace events in pm8001 driver. 4 + * 5 + * Copyright 2020 Google LLC 6 + * Author: Akshat Jain <akshatzen@google.com> 7 + */ 8 + 9 + #define CREATE_TRACE_POINTS 10 + #include "pm80xx_tracepoints.h"
+85
drivers/scsi/pm8001/pm80xx_tracepoints.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Trace events in pm8001 driver. 4 + * 5 + * Copyright 2020 Google LLC 6 + * Author: Akshat Jain <akshatzen@google.com> 7 + */ 8 + 9 + #undef TRACE_SYSTEM 10 + #define TRACE_SYSTEM pm80xx 11 + 12 + #if !defined(_TRACE_PM80XX_H) || defined(TRACE_HEADER_MULTI_READ) 13 + #define _TRACE_PM80XX_H 14 + 15 + #include <linux/tracepoint.h> 16 + #include "pm8001_sas.h" 17 + 18 + TRACE_EVENT(pm80xx_request_issue, 19 + TP_PROTO(u32 id, u32 phy_id, u32 htag, u32 ctlr_opcode, 20 + u16 ata_opcode, int running_req), 21 + 22 + TP_ARGS(id, phy_id, htag, ctlr_opcode, ata_opcode, running_req), 23 + 24 + TP_STRUCT__entry( 25 + __field(u32, id) 26 + __field(u32, phy_id) 27 + __field(u32, htag) 28 + __field(u32, ctlr_opcode) 29 + __field(u16, ata_opcode) 30 + __field(int, running_req) 31 + ), 32 + 33 + TP_fast_assign( 34 + __entry->id = id; 35 + __entry->phy_id = phy_id; 36 + __entry->htag = htag; 37 + __entry->ctlr_opcode = ctlr_opcode; 38 + __entry->ata_opcode = ata_opcode; 39 + __entry->running_req = running_req; 40 + ), 41 + 42 + TP_printk("ctlr_id = %u phy_id = %u htag = %#x, ctlr_opcode = %#x ata_opcode = %#x running_req = %d", 43 + __entry->id, __entry->phy_id, __entry->htag, 44 + __entry->ctlr_opcode, __entry->ata_opcode, 45 + __entry->running_req) 46 + ); 47 + 48 + TRACE_EVENT(pm80xx_request_complete, 49 + TP_PROTO(u32 id, u32 phy_id, u32 htag, u32 ctlr_opcode, 50 + u16 ata_opcode, int running_req), 51 + 52 + TP_ARGS(id, phy_id, htag, ctlr_opcode, ata_opcode, running_req), 53 + 54 + TP_STRUCT__entry( 55 + __field(u32, id) 56 + __field(u32, phy_id) 57 + __field(u32, htag) 58 + __field(u32, ctlr_opcode) 59 + __field(u16, ata_opcode) 60 + __field(int, running_req) 61 + ), 62 + 63 + TP_fast_assign( 64 + __entry->id = id; 65 + __entry->phy_id = phy_id; 66 + __entry->htag = htag; 67 + __entry->ctlr_opcode = ctlr_opcode; 68 + __entry->ata_opcode = ata_opcode; 69 + __entry->running_req = running_req; 70 + ), 71 + 72 + TP_printk("ctlr_id = %u phy_id = %u htag = %#x, ctlr_opcode = %#x ata_opcode = %#x running_req = %d", 73 + __entry->id, __entry->phy_id, __entry->htag, 74 + __entry->ctlr_opcode, __entry->ata_opcode, 75 + __entry->running_req) 76 + ); 77 + 78 + #endif /* _TRACE_PM80XX_H_ */ 79 + 80 + #undef TRACE_INCLUDE_PATH 81 + #undef TRACE_INCLUDE_FILE 82 + #define TRACE_INCLUDE_PATH . 83 + #define TRACE_INCLUDE_FILE pm80xx_tracepoints 84 + 85 + #include <trace/define_trace.h>