Skip to content

Commit daf763c

Browse files
committed
firewire: core: add tracepoints events for completions of packets in isochronous context
It is helpful to trace completion of packets in isochronous context when the core function is requested them by both in-kernel units driver and userspace applications. This commit adds some tracepoints events for the aim. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Sakamoto <[email protected]>
1 parent 1f3c0d7 commit daf763c

File tree

3 files changed

+99
-6
lines changed

3 files changed

+99
-6
lines changed

drivers/firewire/core-trace.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ void copy_port_status(u8 *port_status, unsigned int port_capacity,
2020
self_id_sequence_get_port_status(self_id_sequence, quadlet_count, port_index);
2121
}
2222
}
23+
24+
EXPORT_TRACEPOINT_SYMBOL_GPL(isoc_inbound_single_completions);
25+
EXPORT_TRACEPOINT_SYMBOL_GPL(isoc_inbound_multiple_completions);
26+
EXPORT_TRACEPOINT_SYMBOL_GPL(isoc_outbound_completions);
2327
#endif

drivers/firewire/ohci.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2833,8 +2833,13 @@ static void ohci_write_csr(struct fw_card *card, int csr_offset, u32 value)
28332833
}
28342834
}
28352835

2836-
static void flush_iso_completions(struct iso_context *ctx)
2836+
static void flush_iso_completions(struct iso_context *ctx, enum fw_iso_context_completions_cause cause)
28372837
{
2838+
trace_isoc_inbound_single_completions(&ctx->base, ctx->last_timestamp, cause, ctx->header,
2839+
ctx->header_length);
2840+
trace_isoc_outbound_completions(&ctx->base, ctx->last_timestamp, cause, ctx->header,
2841+
ctx->header_length);
2842+
28382843
ctx->base.callback.sc(&ctx->base, ctx->last_timestamp,
28392844
ctx->header_length, ctx->header,
28402845
ctx->base.callback_data);
@@ -2848,7 +2853,7 @@ static void copy_iso_headers(struct iso_context *ctx, const u32 *dma_hdr)
28482853
if (ctx->header_length + ctx->base.header_size > PAGE_SIZE) {
28492854
if (ctx->base.drop_overflow_headers)
28502855
return;
2851-
flush_iso_completions(ctx);
2856+
flush_iso_completions(ctx, FW_ISO_CONTEXT_COMPLETIONS_CAUSE_HEADER_OVERFLOW);
28522857
}
28532858

28542859
ctx_hdr = ctx->header + ctx->header_length;
@@ -2897,7 +2902,7 @@ static int handle_ir_packet_per_buffer(struct context *context,
28972902
copy_iso_headers(ctx, (u32 *) (last + 1));
28982903

28992904
if (last->control & cpu_to_le16(DESCRIPTOR_IRQ_ALWAYS))
2900-
flush_iso_completions(ctx);
2905+
flush_iso_completions(ctx, FW_ISO_CONTEXT_COMPLETIONS_CAUSE_IRQ);
29012906

29022907
return 1;
29032908
}
@@ -2932,6 +2937,9 @@ static int handle_ir_buffer_fill(struct context *context,
29322937
completed, DMA_FROM_DEVICE);
29332938

29342939
if (last->control & cpu_to_le16(DESCRIPTOR_IRQ_ALWAYS)) {
2940+
trace_isoc_inbound_multiple_completions(&ctx->base, completed,
2941+
FW_ISO_CONTEXT_COMPLETIONS_CAUSE_IRQ);
2942+
29352943
ctx->base.callback.mc(&ctx->base,
29362944
buffer_dma + completed,
29372945
ctx->base.callback_data);
@@ -2948,6 +2956,9 @@ static void flush_ir_buffer_fill(struct iso_context *ctx)
29482956
ctx->mc_buffer_bus & ~PAGE_MASK,
29492957
ctx->mc_completed, DMA_FROM_DEVICE);
29502958

2959+
trace_isoc_inbound_multiple_completions(&ctx->base, ctx->mc_completed,
2960+
FW_ISO_CONTEXT_COMPLETIONS_CAUSE_FLUSH);
2961+
29512962
ctx->base.callback.mc(&ctx->base,
29522963
ctx->mc_buffer_bus + ctx->mc_completed,
29532964
ctx->base.callback_data);
@@ -3012,7 +3023,7 @@ static int handle_it_packet(struct context *context,
30123023
if (ctx->header_length + 4 > PAGE_SIZE) {
30133024
if (ctx->base.drop_overflow_headers)
30143025
return 1;
3015-
flush_iso_completions(ctx);
3026+
flush_iso_completions(ctx, FW_ISO_CONTEXT_COMPLETIONS_CAUSE_HEADER_OVERFLOW);
30163027
}
30173028

30183029
ctx_hdr = ctx->header + ctx->header_length;
@@ -3023,7 +3034,7 @@ static int handle_it_packet(struct context *context,
30233034
ctx->header_length += 4;
30243035

30253036
if (last->control & cpu_to_le16(DESCRIPTOR_IRQ_ALWAYS))
3026-
flush_iso_completions(ctx);
3037+
flush_iso_completions(ctx, FW_ISO_CONTEXT_COMPLETIONS_CAUSE_IRQ);
30273038

30283039
return 1;
30293040
}
@@ -3588,7 +3599,7 @@ static int ohci_flush_iso_completions(struct fw_iso_context *base)
35883599
case FW_ISO_CONTEXT_TRANSMIT:
35893600
case FW_ISO_CONTEXT_RECEIVE:
35903601
if (ctx->header_length != 0)
3591-
flush_iso_completions(ctx);
3602+
flush_iso_completions(ctx, FW_ISO_CONTEXT_COMPLETIONS_CAUSE_FLUSH);
35923603
break;
35933604
case FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL:
35943605
if (ctx->mc_completed != 0)

include/trace/events/firewire.h

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,84 @@ TRACE_EVENT_CONDITION(isoc_inbound_multiple_queue,
821821
#undef TP_STRUCT__entry_iso_packet
822822
#undef TP_fast_assign_iso_packet
823823

824+
#ifndef show_cause
825+
enum fw_iso_context_completions_cause {
826+
FW_ISO_CONTEXT_COMPLETIONS_CAUSE_FLUSH = 0,
827+
FW_ISO_CONTEXT_COMPLETIONS_CAUSE_IRQ,
828+
FW_ISO_CONTEXT_COMPLETIONS_CAUSE_HEADER_OVERFLOW,
829+
};
830+
#define show_cause(cause) \
831+
__print_symbolic(cause, \
832+
{ FW_ISO_CONTEXT_COMPLETIONS_CAUSE_FLUSH, "FLUSH" }, \
833+
{ FW_ISO_CONTEXT_COMPLETIONS_CAUSE_IRQ, "IRQ" }, \
834+
{ FW_ISO_CONTEXT_COMPLETIONS_CAUSE_HEADER_OVERFLOW, "HEADER_OVERFLOW" } \
835+
)
836+
#endif
837+
838+
DECLARE_EVENT_CLASS(isoc_single_completions_template,
839+
TP_PROTO(const struct fw_iso_context *ctx, u16 timestamp, enum fw_iso_context_completions_cause cause, const u32 *header, unsigned int header_length),
840+
TP_ARGS(ctx, timestamp, cause, header, header_length),
841+
TP_STRUCT__entry(
842+
__field(u64, context)
843+
__field(u8, card_index)
844+
__field(u16, timestamp)
845+
__field(u8, cause)
846+
__dynamic_array(u32, header, header_length / QUADLET_SIZE)
847+
),
848+
TP_fast_assign(
849+
__entry->context = (uintptr_t)ctx;
850+
__entry->card_index = ctx->card->index;
851+
__entry->timestamp = timestamp;
852+
__entry->cause = cause;
853+
memcpy(__get_dynamic_array(header), header, __get_dynamic_array_len(header));
854+
),
855+
TP_printk(
856+
"context=0x%llx card_index=%u timestap=0x%04x cause=%s header=%s",
857+
__entry->context,
858+
__entry->card_index,
859+
__entry->timestamp,
860+
show_cause(__entry->cause),
861+
__print_array(__get_dynamic_array(header),
862+
__get_dynamic_array_len(header) / QUADLET_SIZE, QUADLET_SIZE)
863+
)
864+
)
865+
866+
DEFINE_EVENT_CONDITION(isoc_single_completions_template, isoc_outbound_completions,
867+
TP_PROTO(const struct fw_iso_context *ctx, u16 timestamp, enum fw_iso_context_completions_cause cause, const u32 *header, unsigned int header_length),
868+
TP_ARGS(ctx, timestamp, cause, header, header_length),
869+
TP_CONDITION(ctx->type == FW_ISO_CONTEXT_TRANSMIT)
870+
);
871+
872+
DEFINE_EVENT_CONDITION(isoc_single_completions_template, isoc_inbound_single_completions,
873+
TP_PROTO(const struct fw_iso_context *ctx, u16 timestamp, enum fw_iso_context_completions_cause cause, const u32 *header, unsigned int header_length),
874+
TP_ARGS(ctx, timestamp, cause, header, header_length),
875+
TP_CONDITION(ctx->type == FW_ISO_CONTEXT_RECEIVE)
876+
);
877+
878+
TRACE_EVENT(isoc_inbound_multiple_completions,
879+
TP_PROTO(const struct fw_iso_context *ctx, unsigned int completed, enum fw_iso_context_completions_cause cause),
880+
TP_ARGS(ctx, completed, cause),
881+
TP_STRUCT__entry(
882+
__field(u64, context)
883+
__field(u8, card_index)
884+
__field(u16, completed)
885+
__field(u8, cause)
886+
),
887+
TP_fast_assign(
888+
__entry->context = (uintptr_t)ctx;
889+
__entry->card_index = ctx->card->index;
890+
__entry->completed = completed;
891+
__entry->cause = cause;
892+
),
893+
TP_printk(
894+
"context=0x%llx card_index=%u comleted=%u cause=%s",
895+
__entry->context,
896+
__entry->card_index,
897+
__entry->completed,
898+
show_cause(__entry->cause)
899+
)
900+
);
901+
824902
#undef QUADLET_SIZE
825903

826904
#endif // _FIREWIRE_TRACE_EVENT_H

0 commit comments

Comments
 (0)