scsi: ufs: Add exception event tracepoint
authorAdrian Hunter <adrian.hunter@intel.com>
Tue, 9 Feb 2021 06:24:34 +0000 (08:24 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 4 Mar 2021 22:36:58 +0000 (17:36 -0500)
Currently, exception event status can be read from wExceptionEventStatus
attribute (sysfs file attributes/exception_event_status under the UFS host
controller device directory). Polling that attribute to track UFS exception
events is impractical, so add a tracepoint to track exception events for
testing and debugging purposes.

Note, by the time the exception event status is read, the exception event
may have cleared, so the value can be zero - see example below.

Note also, only enabled exception events can be reported. A subsequent
patch adds the ability for users to enable selected exception events via
debugfs.

Example with driver instrumented to enable all exception events:

  # echo 1 > /sys/kernel/debug/tracing/events/ufs/ufshcd_exception_event/enable

  ... do some I/O ...

  # cat /sys/kernel/debug/tracing/trace
  # tracer: nop
  #
  # entries-in-buffer/entries-written: 3/3   #P:5
  #
  #                                _-----=> irqs-off
  #                               / _----=> need-resched
  #                              | / _---=> hardirq/softirq
  #                              || / _--=> preempt-depth
  #                              ||| /     delay
  #           TASK-PID     CPU#  ||||   TIMESTAMP  FUNCTION
  #              | |         |   ||||      |         |
       kworker/2:2-173     [002] ....   731.486419: ufshcd_exception_event: 0000:00:12.5: status 0x0
       kworker/2:2-173     [002] ....   732.608918: ufshcd_exception_event: 0000:00:12.5: status 0x4
       kworker/2:2-173     [002] ....   732.609312: ufshcd_exception_event: 0000:00:12.5: status 0x4

Link: https://lore.kernel.org/r/20210209062437.6954-2-adrian.hunter@intel.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ufs/ufshcd.c
include/trace/events/ufs.h

index 77161750c9fb34df04e48caf6548600f7b16bac6..98b4cc085e1e916c853aa4b63cd984cb0f19f0b2 100644 (file)
@@ -5618,6 +5618,8 @@ static void ufshcd_exception_event_handler(struct work_struct *work)
                goto out;
        }
 
+       trace_ufshcd_exception_event(dev_name(hba->dev), status);
+
        status &= hba->ee_ctrl_mask;
 
        if (status & MASK_EE_URGENT_BKOPS)
index e151477d645c1ff156f843bd74be426ffa2e7c5c..1cb6f1afba0ea422402e3d0dec0626d6af498acc 100644 (file)
@@ -349,6 +349,27 @@ TRACE_EVENT(ufshcd_upiu,
        )
 );
 
+TRACE_EVENT(ufshcd_exception_event,
+
+       TP_PROTO(const char *dev_name, u16 status),
+
+       TP_ARGS(dev_name, status),
+
+       TP_STRUCT__entry(
+               __string(dev_name, dev_name)
+               __field(u16, status)
+       ),
+
+       TP_fast_assign(
+               __assign_str(dev_name, dev_name);
+               __entry->status = status;
+       ),
+
+       TP_printk("%s: status 0x%x",
+               __get_str(dev_name), __entry->status
+       )
+);
+
 #endif /* if !defined(_TRACE_UFS_H) || defined(TRACE_HEADER_MULTI_READ) */
 
 /* This part must be outside protection */