Skip to content

Commit

Permalink
Fix msm events handling
Browse files Browse the repository at this point in the history
The code that handled msm events failed to set `id_start` and
`user_comm` correctly which caused the wrong command name to appear in
the timeline and sw and hw queue to incorrectly look identical.

Handle those similarly to how they are handled for AMD.
  • Loading branch information
pac85 authored and mikesart committed Oct 8, 2024
1 parent a846ab7 commit 89b4dbc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/gpuvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,8 @@ static void add_sched_switch_pid_comm( trace_info_t &trace_info, const trace_eve

static bool is_msm_timeline_event( const char *name )
{
return ( !strcmp( name, "msm_gpu_submit_flush" ) ||
return ( !strcmp( name, "msm_gpu_submit" ) ||
!strcmp( name, "msm_gpu_submit_flush" ) ||
!strcmp( name, "msm_gpu_submit_retired" ) );
}

Expand Down Expand Up @@ -1960,7 +1961,7 @@ uint64_t TraceEvents::get_event_gfxcontext_hash( const trace_event_t &event )
{
if ( is_msm_timeline_event( event.name ) )
{
return atoi( get_event_field_val( event, "seqno", "0" ) );
return atoi( get_event_field_val( event, "id", "0" ) );
}

if ( is_drm_sched_timeline_event( event ) )
Expand Down Expand Up @@ -2142,9 +2143,9 @@ void TraceEvents::init_msm_timeline_event( trace_event_t &event )

m_gfxcontext_locs.add_location_u64( gfxcontext_hash, event.id );

event.flags |= TRACE_FLAG_TIMELINE;
const std::vector< uint32_t > *plocs = m_gfxcontext_locs.get_locations_u64( gfxcontext_hash );

event.id_start = INVALID_ID;
event.flags |= TRACE_FLAG_TIMELINE;

if ( !strcmp( event.name, "msm_gpu_submit_retired" ) )
{
Expand All @@ -2155,17 +2156,18 @@ void TraceEvents::init_msm_timeline_event( trace_event_t &event )
event.flags |= TRACE_FLAG_HW_QUEUE;
}

const std::vector< uint32_t > *plocs = m_gfxcontext_locs.get_locations_u64( gfxcontext_hash );
if ( plocs->size() > 1 )
{
// First event.
trace_event_t &event0 = m_events[ plocs->front() ];
event0.flags |= TRACE_FLAG_SW_QUEUE;

// Assume the user comm is the first comm event in this set.
event.user_comm = event0.comm;
// Event right before the event we just added.
auto it = plocs->rbegin() + 1;
trace_event_t &event_prev = m_events[ *it ];

// We shouldn't recycle seqnos in the same trace hopefully?
event.id_start = event0.id;
event.user_comm = event0.comm;
event.id_start = event_prev.id;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/trace-cmd/trace-read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,8 @@ static void init_event_flags( trace_data_t &trace_data, trace_event_t &event )
event.flags |= TRACE_FLAG_FENCE_SIGNALED;
else if ( strstr( event.name, "amdgpu_cs_ioctl" ) )
event.flags |= TRACE_FLAG_SW_QUEUE;
else if ( strstr( event.name, "msm_gpu_submit" ) )
event.flags |= TRACE_FLAG_SW_QUEUE;
else if ( strstr( event.name, "amdgpu_sched_run_job" ) )
event.flags |= TRACE_FLAG_HW_QUEUE;
}
Expand Down

0 comments on commit 89b4dbc

Please sign in to comment.