linux-stable/include/trace/events/rtc.h
Baolin Wang 29a1f599c0 rtc: Add tracepoints for RTC system
It will be more helpful to add some tracepoints to track RTC actions when
debugging RTC driver. Below sample is that we set/read the RTC time, then
set 2 alarms, so we can see the trace logs:

set/read RTC time:
kworker/0:1-67 [000] 21.814245: rtc_set_time: UTC (1510301580) (0)
kworker/0:1-67 [000] 21.814312: rtc_read_time: UTC (1510301580) (0)

set the first alarm timer:
kworker/0:1-67 [000] 21.829238: rtc_timer_enqueue: RTC timer:(ffffffc15eb49bc8) expires:1510301700000000000 period:0
kworker/0:1-67 [000] 22.018279: rtc_set_alarm: UTC (1510301700) (0)

set the second alarm timer:
kworker/0:1-67 [000] 22.230284: rtc_timer_enqueue: RTC timer:(ffffff80088e6430) expires:1510301820000000000 period:0

the first alarm timer was expired:
kworker/0:1-67 [000] 145.155584: rtc_timer_dequeue: RTC timer:(ffffffc15eb49bc8) expires:1510301700000000000 period:0
kworker/0:1-67 [000] 145.155593: rtc_timer_fired: RTC timer:(ffffffc15eb49bc8) expires:1510301700000000000 period:0
kworker/0:1-67 [000] 145.172504: rtc_set_alarm: UTC (1510301820) (0)

the second alarm timer was expired:
kworker/0:1-67 [000] 269.102353: rtc_timer_dequeue: RTC timer:(ffffff80088e6430) expires:1510301820000000000 period:0
kworker/0:1-67 [000] 269.102360: rtc_timer_fired: RTC timer:(ffffff80088e6430) expires:1510301820000000000 period:0

disable alarm irq:
kworker/0:1-67 [000] 269.102469: rtc_alarm_irq_enable: disable RTC alarm IRQ (0)

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-02-13 21:30:22 +01:00

206 lines
3.3 KiB
C

#undef TRACE_SYSTEM
#define TRACE_SYSTEM rtc
#if !defined(_TRACE_RTC_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_RTC_H
#include <linux/rtc.h>
#include <linux/tracepoint.h>
DECLARE_EVENT_CLASS(rtc_time_alarm_class,
TP_PROTO(time64_t secs, int err),
TP_ARGS(secs, err),
TP_STRUCT__entry(
__field(time64_t, secs)
__field(int, err)
),
TP_fast_assign(
__entry->secs = secs;
__entry->err = err;
),
TP_printk("UTC (%lld) (%d)",
__entry->secs, __entry->err
)
);
DEFINE_EVENT(rtc_time_alarm_class, rtc_set_time,
TP_PROTO(time64_t secs, int err),
TP_ARGS(secs, err)
);
DEFINE_EVENT(rtc_time_alarm_class, rtc_read_time,
TP_PROTO(time64_t secs, int err),
TP_ARGS(secs, err)
);
DEFINE_EVENT(rtc_time_alarm_class, rtc_set_alarm,
TP_PROTO(time64_t secs, int err),
TP_ARGS(secs, err)
);
DEFINE_EVENT(rtc_time_alarm_class, rtc_read_alarm,
TP_PROTO(time64_t secs, int err),
TP_ARGS(secs, err)
);
TRACE_EVENT(rtc_irq_set_freq,
TP_PROTO(int freq, int err),
TP_ARGS(freq, err),
TP_STRUCT__entry(
__field(int, freq)
__field(int, err)
),
TP_fast_assign(
__entry->freq = freq;
__entry->err = err;
),
TP_printk("set RTC periodic IRQ frequency:%u (%d)",
__entry->freq, __entry->err
)
);
TRACE_EVENT(rtc_irq_set_state,
TP_PROTO(int enabled, int err),
TP_ARGS(enabled, err),
TP_STRUCT__entry(
__field(int, enabled)
__field(int, err)
),
TP_fast_assign(
__entry->enabled = enabled;
__entry->err = err;
),
TP_printk("%s RTC 2^N Hz periodic IRQs (%d)",
__entry->enabled ? "enable" : "disable",
__entry->err
)
);
TRACE_EVENT(rtc_alarm_irq_enable,
TP_PROTO(unsigned int enabled, int err),
TP_ARGS(enabled, err),
TP_STRUCT__entry(
__field(unsigned int, enabled)
__field(int, err)
),
TP_fast_assign(
__entry->enabled = enabled;
__entry->err = err;
),
TP_printk("%s RTC alarm IRQ (%d)",
__entry->enabled ? "enable" : "disable",
__entry->err
)
);
DECLARE_EVENT_CLASS(rtc_offset_class,
TP_PROTO(long offset, int err),
TP_ARGS(offset, err),
TP_STRUCT__entry(
__field(long, offset)
__field(int, err)
),
TP_fast_assign(
__entry->offset = offset;
__entry->err = err;
),
TP_printk("RTC offset: %ld (%d)",
__entry->offset, __entry->err
)
);
DEFINE_EVENT(rtc_offset_class, rtc_set_offset,
TP_PROTO(long offset, int err),
TP_ARGS(offset, err)
);
DEFINE_EVENT(rtc_offset_class, rtc_read_offset,
TP_PROTO(long offset, int err),
TP_ARGS(offset, err)
);
DECLARE_EVENT_CLASS(rtc_timer_class,
TP_PROTO(struct rtc_timer *timer),
TP_ARGS(timer),
TP_STRUCT__entry(
__field(struct rtc_timer *, timer)
__field(ktime_t, expires)
__field(ktime_t, period)
),
TP_fast_assign(
__entry->timer = timer;
__entry->expires = timer->node.expires;
__entry->period = timer->period;
),
TP_printk("RTC timer:(%p) expires:%lld period:%lld",
__entry->timer, __entry->expires, __entry->period
)
);
DEFINE_EVENT(rtc_timer_class, rtc_timer_enqueue,
TP_PROTO(struct rtc_timer *timer),
TP_ARGS(timer)
);
DEFINE_EVENT(rtc_timer_class, rtc_timer_dequeue,
TP_PROTO(struct rtc_timer *timer),
TP_ARGS(timer)
);
DEFINE_EVENT(rtc_timer_class, rtc_timer_fired,
TP_PROTO(struct rtc_timer *timer),
TP_ARGS(timer)
);
#endif /* _TRACE_RTC_H */
/* This part must be outside protection */
#include <trace/define_trace.h>