firewire: core: add tracepoints events for starting/stopping of isochronous context
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 23 Jun 2024 22:08:54 +0000 (07:08 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 24 Jun 2024 22:31:38 +0000 (07:31 +0900)
It is helpful to trace the starting and stopping of isochronous context
when the core function is requested them by both in-kernel unit drivers
and userspace applications.

This commit adds some tracepoints events for the aim.

Link: https://lore.kernel.org/r/20240623220859.851685-4-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
drivers/firewire/core-iso.c
include/trace/events/firewire.h

index 7ec84de..49feb4c 100644 (file)
@@ -171,6 +171,10 @@ EXPORT_SYMBOL(fw_iso_context_destroy);
 int fw_iso_context_start(struct fw_iso_context *ctx,
                         int cycle, int sync, int tags)
 {
+       trace_isoc_outbound_start(ctx, cycle);
+       trace_isoc_inbound_single_start(ctx, cycle, sync, tags);
+       trace_isoc_inbound_multiple_start(ctx, cycle, sync, tags);
+
        return ctx->card->driver->start_iso(ctx, cycle, sync, tags);
 }
 EXPORT_SYMBOL(fw_iso_context_start);
@@ -205,6 +209,10 @@ EXPORT_SYMBOL(fw_iso_context_flush_completions);
 
 int fw_iso_context_stop(struct fw_iso_context *ctx)
 {
+       trace_isoc_outbound_stop(ctx);
+       trace_isoc_inbound_single_stop(ctx);
+       trace_isoc_inbound_multiple_stop(ctx);
+
        return ctx->card->driver->stop_iso(ctx);
 }
 EXPORT_SYMBOL(fw_iso_context_stop);
index 0334e02..c984b7d 100644 (file)
@@ -562,6 +562,114 @@ TRACE_EVENT(isoc_inbound_multiple_channels,
        )
 );
 
+TRACE_EVENT_CONDITION(isoc_outbound_start,
+       TP_PROTO(const struct fw_iso_context *ctx, int cycle_match),
+       TP_ARGS(ctx, cycle_match),
+       TP_CONDITION(ctx->type == FW_ISO_CONTEXT_TRANSMIT),
+       TP_STRUCT__entry(
+               __field(u64, context)
+               __field(u8, card_index)
+               __field(bool, cycle_match)
+               __field(u16, cycle)
+       ),
+       TP_fast_assign(
+               __entry->context = (uintptr_t)ctx;
+               __entry->card_index = ctx->card->index;
+               __entry->cycle_match = cycle_match < 0 ? false : true;
+               __entry->cycle = __entry->cycle_match ? (u16)cycle_match : 0;
+       ),
+       TP_printk(
+               "context=0x%llx card_index=%u cycle_match=%s cycle=0x%04x",
+               __entry->context,
+               __entry->card_index,
+               __entry->cycle_match ? "true" : "false",
+               __entry->cycle
+       )
+);
+
+DECLARE_EVENT_CLASS(isoc_inbound_start_template,
+       TP_PROTO(const struct fw_iso_context *ctx, int cycle_match, unsigned int sync, unsigned int tags),
+       TP_ARGS(ctx, cycle_match, sync, tags),
+       TP_STRUCT__entry(
+               __field(u64, context)
+               __field(u8, card_index)
+               __field(bool, cycle_match)
+               __field(u16, cycle)
+               __field(u8, sync)
+               __field(u8, tags)
+       ),
+       TP_fast_assign(
+               __entry->context = (uintptr_t)ctx;
+               __entry->card_index = ctx->card->index;
+               __entry->cycle_match = cycle_match < 0 ? false : true;
+               __entry->cycle = __entry->cycle_match ? (u16)cycle_match : 0;
+               __entry->sync = sync;
+               __entry->tags = tags;
+       ),
+       TP_printk(
+               "context=0x%llx card_index=%u cycle_match=%s cycle=0x%04x sync=%u tags=%s",
+               __entry->context,
+               __entry->card_index,
+               __entry->cycle_match ? "true" : "false",
+               __entry->cycle,
+               __entry->sync,
+               __print_flags(__entry->tags, "|",
+                       { FW_ISO_CONTEXT_MATCH_TAG0, "0" },
+                       { FW_ISO_CONTEXT_MATCH_TAG1, "1" },
+                       { FW_ISO_CONTEXT_MATCH_TAG2, "2" },
+                       { FW_ISO_CONTEXT_MATCH_TAG3, "3" }
+               )
+       )
+);
+
+DEFINE_EVENT_CONDITION(isoc_inbound_start_template, isoc_inbound_single_start,
+       TP_PROTO(const struct fw_iso_context *ctx, int cycle_match, unsigned int sync, unsigned int tags),
+       TP_ARGS(ctx, cycle_match, sync, tags),
+       TP_CONDITION(ctx->type == FW_ISO_CONTEXT_RECEIVE)
+);
+
+DEFINE_EVENT_CONDITION(isoc_inbound_start_template, isoc_inbound_multiple_start,
+       TP_PROTO(const struct fw_iso_context *ctx, int cycle_match, unsigned int sync, unsigned int tags),
+       TP_ARGS(ctx, cycle_match, sync, tags),
+       TP_CONDITION(ctx->type == FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL)
+);
+
+DECLARE_EVENT_CLASS(isoc_stop_template,
+       TP_PROTO(const struct fw_iso_context *ctx),
+       TP_ARGS(ctx),
+       TP_STRUCT__entry(
+               __field(u64, context)
+               __field(u8, card_index)
+       ),
+       TP_fast_assign(
+               __entry->context = (uintptr_t)ctx;
+               __entry->card_index = ctx->card->index;
+       ),
+       TP_printk(
+               "context=0x%llx card_index=%u",
+               __entry->context,
+               __entry->card_index
+       )
+)
+
+DEFINE_EVENT_CONDITION(isoc_stop_template, isoc_outbound_stop,
+       TP_PROTO(const struct fw_iso_context *ctx),
+       TP_ARGS(ctx),
+       TP_CONDITION(ctx->type == FW_ISO_CONTEXT_TRANSMIT)
+);
+
+DEFINE_EVENT_CONDITION(isoc_stop_template, isoc_inbound_single_stop,
+       TP_PROTO(const struct fw_iso_context *ctx),
+       TP_ARGS(ctx),
+       TP_CONDITION(ctx->type == FW_ISO_CONTEXT_RECEIVE)
+);
+
+DEFINE_EVENT_CONDITION(isoc_stop_template, isoc_inbound_multiple_stop,
+       TP_PROTO(const struct fw_iso_context *ctx),
+       TP_ARGS(ctx),
+       TP_CONDITION(ctx->type == FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL)
+);
+
 #undef QUADLET_SIZE
 
 #endif // _FIREWIRE_TRACE_EVENT_H