Received: by 10.223.185.116 with SMTP id b49csp706937wrg; Tue, 20 Feb 2018 06:37:38 -0800 (PST) X-Google-Smtp-Source: AH8x224Zf+K19h8+UYRRaDYZ9KALc3xE3DtTIb8uVKakXW01uDIr3iJDeK5S//77E7YdQAJ2xXuX X-Received: by 2002:a17:902:4083:: with SMTP id c3-v6mr17070399pld.90.1519137458004; Tue, 20 Feb 2018 06:37:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519137457; cv=none; d=google.com; s=arc-20160816; b=sPhVO5O35yhImz8akjA5g0bLERQc+nIKwR1kvZRfyxmjI8msrF+DmhlZYUTmEsVZwc E4ExUrA+wUAwnVTdPzGzsLyma0x+NizEXWVU8TE9wshHwyv185oSyuMQeXBMHyHMBBEL +HhTZLj1e/IHCT9IoogfgagpwAuuNQpjhZtXsTSI2uNUNLTl0BMPYgtwIBdSx0adRaQB eRKSnEcz+ALeRxpjLFLa7V86DW/+sHI5dBC59aggXKpbtEyObNHK5aorvouXjdRt5ina /hrRkx9BCveetxhlLYz7b5uSGPu6U2MEzDNssQDe2ehqHDCCMQYtqQ+c8nt/rk7RmIyS ceSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=pH2NTgvUmlGfWM6D7NzLVYO6kGaMNzYWzQmvFkUDQ58=; b=h7HO90E+w/5TVBpaMwS9zPASaLeJZXnsjwOOf3oi7lZ2U2KUI4vlfFn5z5O1wofFMp Ghyi3DNtNNbEC6WMeFgaVpnC+C0ViMt5mEyYaQsVHjO8HNvQnHnkAD2FeJvRdZeRAx4V nn61Y7Y2fReqyJ94WZ8IqmjkXhP6bDkIE+pUEtmL4HTpM1rwXZX4ljkQprXrw0PW5Hjw Ak/FRwyY2QaQOHtd9+fjQ5EgEAxZ2JveMtEizuAtHOG576sRlhpFSJ+odL7owbuDFdzi aofBL3NSw99+AATtPYU39Cfq8AuLoRJYYHPok+KXXmBFlQq0I1hmmr7fZo3c0HaY8XGZ nBIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sandisk.com header.s=dkim.sandisk.com header.b=Wu5ZaSx9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 97-v6si1390802pld.599.2018.02.20.06.37.18; Tue, 20 Feb 2018 06:37:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@sandisk.com header.s=dkim.sandisk.com header.b=Wu5ZaSx9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751803AbeBTOgE (ORCPT + 99 others); Tue, 20 Feb 2018 09:36:04 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:31217 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751320AbeBTOgC (ORCPT ); Tue, 20 Feb 2018 09:36:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=sandisk.com; i=@sandisk.com; q=dns/txt; s=dkim.sandisk.com; t=1519137364; x=1550673364; h=from:to:cc:subject:date:message-id; bh=E+4J8vm/e3AkxWnznLaGaFtDW5RWCX8yEf8EAB0KPkw=; b=Wu5ZaSx96T7FEnlO1cvPleg6xBRqNwg4NW80YDmJo4/PMAsZ5s0eLSfn 9f7l8HTOYvFwn+oT5CdDdtvNg3EVmMjrX72lWyB277RPWRo7xuSpwzS3B cIMSieTi1fhweS9eE+IYlziWyh8xbAB2Rreh+489C9b6QRmyAlEM2VdtM Gu5yC9oyo6B66Q+c3gLEHBBxFZe18noUraZsNuxMUIzSZz1D0pKH7uC95 nQeRhIAknagTWeJDGWVNQUIBayK8pKM46SRVA0C4a895ccebxJRjT6Zvi MkbdWJp2oNSmWcatILNmjb9+nNRhuKL1hkbZ1niTHZbpfWi++syDJtX3M A==; X-IronPort-AV: E=Sophos;i="5.46,539,1511798400"; d="scan'208";a="72272641" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Feb 2018 22:36:03 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 20 Feb 2018 06:29:46 -0800 Received: from ile419070.sdcorp.global.sandisk.com ([10.0.230.165]) by uls-op-cesaip02.wdc.com with ESMTP; 20 Feb 2018 06:36:01 -0800 From: Ohad Sharabi To: jejb@linux.vnet.ibm.com, martin.peterson@oracle.com, gregkh@linuxfoundation.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: alex.lemberg@wdc.com, Ohad Sharabi Subject: [PATCH] scsi: ufs: add trace event for ufs upiu Date: Tue, 20 Feb 2018 16:35:47 +0200 Message-Id: <1519137347-30798-1-git-send-email-ohad.sharabi@sandisk.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add UFS Protocol Information Units(upiu) trace events for ufs driver, used to trace various ufs transaction types- command, task-management and device management. The trace-point format is generic and can be easily adapted to trace other upius if needed. Currently tracing ufs transaction of type 'device management', which this patch introduce, cannot be obtained from any other trace. Device management transactions are used for communication with the device such as reading and writing descriptor or attributes etc. Signed-off-by: Ohad Sharabi --- drivers/scsi/ufs/ufshcd.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++ include/trace/events/ufs.h | 28 +++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index a355d98..6d79c99 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -274,6 +274,47 @@ static inline void ufshcd_remove_non_printable(char *val) *val = ' '; } +static void ufshcd_add_upiu_trace(struct ufs_hba *hba, unsigned int tag, + const char *str) +{ + struct utp_task_req_desc *descp; + struct utp_upiu_task_req *task_req; + struct utp_upiu_req *rq; + u8 tx_code, *hdr, *tsf; + int off; + + if (!trace_ufshcd_upiu_enabled()) + return; + + off = (int)tag - hba->nutrs; + if (off < 0) { + rq = hba->lrb[tag].ucd_req_ptr; + hdr = (u8 *)&rq->header; + } else { + descp = &hba->utmrdl_base_addr[off]; + task_req = (struct utp_upiu_task_req *)descp->task_req_upiu; + hdr = (u8 *)&task_req->header; + } + + tx_code = hdr[0] & 0x3f; + switch (hdr[0] & 0x3f) { + case UPIU_TRANSACTION_COMMAND: + tsf = (u8 *)&rq->sc.cdb; + break; + case UPIU_TRANSACTION_TASK_REQ: + tsf = (u8 *)&task_req->input_param1; + break; + case UPIU_TRANSACTION_QUERY_REQ: + tsf = (u8 *)&rq->qr; + break; + default: + return; + } + + /* trace UPIU header and Transaction Specific Fields (TSF) */ + trace_ufshcd_upiu(dev_name(hba->dev), str, hdr, tsf); +} + static void ufshcd_add_command_trace(struct ufs_hba *hba, unsigned int tag, const char *str) { @@ -283,6 +324,9 @@ static void ufshcd_add_command_trace(struct ufs_hba *hba, struct ufshcd_lrb *lrbp; int transfer_len = -1; + /* trace UPIU also */ + ufshcd_add_upiu_trace(hba, tag, str); + if (!trace_ufshcd_command_enabled()) return; @@ -5462,11 +5506,14 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id, spin_unlock_irqrestore(host->host_lock, flags); + ufshcd_add_upiu_trace(hba, task_tag, "tm_send"); + /* wait until the task management command is completed */ err = wait_event_timeout(hba->tm_wq, test_bit(free_slot, &hba->tm_condition), msecs_to_jiffies(TM_CMD_TIMEOUT)); if (!err) { + ufshcd_add_upiu_trace(hba, task_tag, "tm_complete_err"); dev_err(hba->dev, "%s: task management cmd 0x%.2x timed-out\n", __func__, tm_function); if (ufshcd_clear_tm_cmd(hba, free_slot)) @@ -5475,6 +5522,7 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id, err = -ETIMEDOUT; } else { err = ufshcd_task_req_compl(hba, free_slot, tm_response); + ufshcd_add_upiu_trace(hba, task_tag, "tm_complete"); } clear_bit(free_slot, &hba->tm_condition); diff --git a/include/trace/events/ufs.h b/include/trace/events/ufs.h index bf6f826..0b2ff5d 100644 --- a/include/trace/events/ufs.h +++ b/include/trace/events/ufs.h @@ -257,6 +257,34 @@ ) ); +TRACE_EVENT(ufshcd_upiu, + TP_PROTO(const char *dev_name, const char *str, unsigned char *hdr, + unsigned char *tsf), + + TP_ARGS(dev_name, str, hdr, tsf), + + TP_STRUCT__entry( + __string(dev_name, dev_name) + __string(str, str) + __array(unsigned char, hdr, 12) + __array(unsigned char, tsf, 16) + ), + + TP_fast_assign( + __assign_str(dev_name, dev_name); + __assign_str(str, str); + memcpy(__entry->hdr, hdr, sizeof(__entry->hdr)); + memcpy(__entry->tsf, tsf, sizeof(__entry->tsf)); + ), + + TP_printk( + "%s: %s: HDR:%s, CDB:%s", + __get_str(str), __get_str(dev_name), + __print_hex(__entry->hdr, sizeof(__entry->hdr)), + __print_hex(__entry->tsf, sizeof(__entry->tsf)) + ) +); + #endif /* if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ) */ /* This part must be outside protection */ -- 1.9.1