Received: by 10.213.65.68 with SMTP id h4csp607063imn; Thu, 22 Mar 2018 04:53:41 -0700 (PDT) X-Google-Smtp-Source: AG47ELsuExtqBxvK8vkPUhWgrwmfBgEI6LfOyHwqVk9NKTsdbQ/Y5TYACXMTYVfrNxAqI8INyObh X-Received: by 10.101.98.205 with SMTP id m13mr17628120pgv.100.1521719621665; Thu, 22 Mar 2018 04:53:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521719621; cv=none; d=google.com; s=arc-20160816; b=0qNT1Ju9n6lR23GM+Oj7FRTqAqQQ0oO3muFAau1zEeMo/ezXQxYPhlmyZHZbHfbMnc Ko8mv2cQXmJImyuxwSIGvdvBynfK1hJUQOvgJd/bQMnyLGuu1UtNqUIFSeX0Lz30yWcg 62d9m/I4ym9ABforgYytyiiVSlsKFEtEgQep7WrgHO6MGademg91cVKDUSB9tB1IlyBT THGLvZO3aO38rO+2qgL3Q8Yr46z5B4XxUrscmRkKqp5D5bc0mv90WKmefhCAxaQNIJRy er/ea78bhQZgdhEi9cG1K9Zfr6g3i59WNd7EwKxsywFSQHSZ6Wu2E5sf7kXOPsaZTAkF R48g== 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=ehxkQpnDXZZQyi3wNsxApUWlbuddzxne1XK4VGqX8yA=; b=Q9k364AIvBZq+jsEMoRYPR+3Z86vbZGLR2k5OldBFhWJTiqMYSsOwyGpLf++fLKyCQ rb8ve8eOehPBLb1YABRKNKYZq2O0GLVF3myUldhqWubDyY6k+pf5sZtPddBymoNxwwY7 qLLK7FncLbuiTxH268NbOwEZM7gsiuUqtuPIxJkt7DU3zxJnx9jwWFfbZoVBadiXLCEK 0W56DWHQ884qdgSIpkug7r8Mu7fC1VSxvzuJcv0ofTQYV+nwDt5UgSoKB83my8xCr+st MsKOjJCm8HtEtjgjBJtWX4crmgU5t6E2hA6CnfZUYku1T9qOv9UbFXBgPgmQpuUL1W5p U7gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sandisk.com header.s=dkim.sandisk.com header.b=At4en4NM; 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 k5si4376181pgr.143.2018.03.22.04.53.26; Thu, 22 Mar 2018 04:53:41 -0700 (PDT) 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=At4en4NM; 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 S1754375AbeCVLu6 (ORCPT + 99 others); Thu, 22 Mar 2018 07:50:58 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:11498 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754261AbeCVLuq (ORCPT ); Thu, 22 Mar 2018 07:50:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=sandisk.com; i=@sandisk.com; q=dns/txt; s=dkim.sandisk.com; t=1521719446; x=1553255446; h=from:to:cc:subject:date:message-id; bh=1A04/bk5AHM9KsU82x45E2kjzO4rlYBtp/9pA9i0vSA=; b=At4en4NMz32Zu+4J7o9VZ+RaDNlGG0/s0bBy087TcaXkUSfBvBcZ85H7 M7+6YS0FqqUzjVfgWGwvT8kb7NtM+NYEqDM8OAiQycEQzWs8hP0YZ/lFB nTyQy6ruhllvYzYqKm6VqJQ2G9NEuUB++/wS0ZhDFQ+9h7U8ThBXHQ1t5 Kt0jAsQrpZ5Hb2KfUGAxpmKs/waN5Y/JHzlE91ubunVWvW2QlUiQNBXq6 sWXKf6/l4iSufKgzXDXGS/kCAHVXMgw4z0KW8I0qNivDf1Zz4T/J615nd VE+3FbsPPoo8GxKOg/UKJfhQAYm5pPtrThkKwUZ+trgycVHNetdgITZ17 Q==; X-IronPort-AV: E=Sophos;i="5.48,344,1517846400"; d="scan'208";a="74818098" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 22 Mar 2018 19:50:46 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 22 Mar 2018 04:43:30 -0700 Received: from ile419070.sdcorp.global.sandisk.com ([10.0.230.165]) by uls-op-cesaip01.wdc.com with ESMTP; 22 Mar 2018 04:50:45 -0700 From: Ohad Sharabi To: stanislav.nijnikov@wdc.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, gregkh@linuxfoundation.org Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, alex.lemberg@wdc.com, Ohad Sharabi Subject: [PATCH v2] scsi: ufs: add trace event for ufs upiu Date: Thu, 22 Mar 2018 13:50:39 +0200 Message-Id: <1521719439-2251-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. v1->v2: - split to transaction specific functions (fix warnings and simplifies code) - adding traces when sending query command Signed-off-by: Ohad Sharabi --- drivers/scsi/ufs/ufshcd.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/trace/events/ufs.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index c7da2c1..6f68d5c 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -274,6 +274,37 @@ static inline void ufshcd_remove_non_printable(char *val) *val = ' '; } +static void ufshcd_add_cmd_upiu_trace(struct ufs_hba *hba, unsigned int tag, + const char *str) +{ + struct utp_upiu_req *rq = hba->lrb[tag].ucd_req_ptr; + + trace_ufshcd_upiu(dev_name(hba->dev), str, (u8 *)&rq->header, + (u8 *)&rq->sc.cdb); +} + +static void ufshcd_add_query_upiu_trace(struct ufs_hba *hba, unsigned int tag, + const char *str) +{ + struct utp_upiu_req *rq = hba->lrb[tag].ucd_req_ptr; + + trace_ufshcd_upiu(dev_name(hba->dev), str, (u8 *)&rq->header, + (u8 *)&rq->qr); +} + +static void ufshcd_add_tm_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; + int off = (int)tag - hba->nutrs; + + descp = &hba->utmrdl_base_addr[off]; + task_req = (struct utp_upiu_task_req *)descp->task_req_upiu; + trace_ufshcd_upiu(dev_name(hba->dev), str, (u8 *)&task_req->header, + (u8 *)&task_req->input_param1); +} + static void ufshcd_add_command_trace(struct ufs_hba *hba, unsigned int tag, const char *str) { @@ -283,6 +314,9 @@ static void ufshcd_add_command_trace(struct ufs_hba *hba, struct ufshcd_lrb *lrbp; int transfer_len = -1; + /* trace UPIU also */ + ufshcd_add_cmd_upiu_trace(hba, tag, str); + if (!trace_ufshcd_command_enabled()) return; @@ -2584,6 +2618,7 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba, hba->dev_cmd.complete = &wait; + ufshcd_add_query_upiu_trace(hba, tag, "query_send"); /* Make sure descriptors are ready before ringing the doorbell */ wmb(); spin_lock_irqsave(hba->host->host_lock, flags); @@ -2593,6 +2628,9 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba, err = ufshcd_wait_for_dev_cmd(hba, lrbp, timeout); + ufshcd_add_query_upiu_trace(hba, tag, + err ? "query_complete_err" : "query_complete"); + out_put_tag: ufshcd_put_dev_cmd_tag(hba, tag); wake_up(&hba->dev_cmd.tag_wq); @@ -5464,11 +5502,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_tm_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_tm_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)) @@ -5477,6 +5518,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_tm_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