Skip to content

Commit

Permalink
Add support for importing Qualcomm MSM DRM timing events.
Browse files Browse the repository at this point in the history
Imports them into AMD timelines, as AMD is pretty close to what a generic GPU
timeline should look like.
  • Loading branch information
Plagman committed Dec 4, 2019
1 parent 03c27b8 commit 95ee1b5
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
69 changes: 69 additions & 0 deletions src/gpuvis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,12 @@ 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" ) ||
!strcmp( name, "msm_gpu_submit_retired" ) );
}

TraceEvents::~TraceEvents()
{
for ( trace_event_t &event : m_events )
Expand Down Expand Up @@ -1699,6 +1705,11 @@ const tgid_info_t *TraceEvents::tgid_from_commstr( const char *comm )

uint32_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" ) );
}

if ( event.seqno )
{
const char *context = get_event_field_val( event, "context", NULL );
Expand Down Expand Up @@ -1857,6 +1868,44 @@ void TraceEvents::init_amd_timeline_event( trace_event_t &event )
}
}

void TraceEvents::init_msm_timeline_event( trace_event_t &event )
{
uint32_t gfxcontext_hash = get_event_gfxcontext_hash( event );

int ringid = atoi( get_event_field_val( event, "ringid", "0" ) );
std::string str = string_format( "msm ring%d", ringid );

m_amd_timeline_locs.add_location_str( str.c_str(), event.id );

m_gfxcontext_locs.add_location_u32( gfxcontext_hash, event.id );

event.flags |= TRACE_FLAG_TIMELINE;

event.id_start = INVALID_ID;

if ( !strcmp( event.name, "msm_gpu_submit_retired" ) )
{
event.flags |= TRACE_FLAG_FENCE_SIGNALED;
}
else if ( !strcmp( event.name, "msm_gpu_submit_flush" ) )
{
event.flags |= TRACE_FLAG_HW_QUEUE;
}

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

// Assume the user comm is the first comm event in this set.
event.user_comm = event0.comm;

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

void TraceEvents::init_i915_event( trace_event_t &event )
{
i915_type_t event_type = get_i915_reqtype( event );
Expand Down Expand Up @@ -2048,6 +2097,10 @@ void TraceEvents::init_new_event( trace_event_t &event )
{
init_amd_timeline_event( event );
}
else if ( is_msm_timeline_event( event.name ) )
{
init_msm_timeline_event( event );
}
else if ( event.seqno && !event.is_ftrace_print() )
{
init_i915_event( event );
Expand Down Expand Up @@ -2634,6 +2687,22 @@ const std::vector< uint32_t > *TraceEvents::get_locs( const char *name,
plocs = get_tdopexpr_locs( plot->m_filter_str.c_str() );
}
}
else if ( !strncmp( name, "msm ring", 8 ) )
{
std::string timeline_name = name;
size_t len = strlen( name );

if ( !strcmp( name + len - 3, " hw" ) )
{
timeline_name.erase( len - 3 );
type = LOC_TYPE_AMDTimeline_hw;
}
else
{
type = LOC_TYPE_AMDTimeline;
}
plocs = m_amd_timeline_locs.get_locations_str( timeline_name.c_str() );
}
else
{
size_t len = strlen( name );
Expand Down
1 change: 1 addition & 0 deletions src/gpuvis.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ class TraceEvents
void init_sched_switch_event( trace_event_t &event );
void init_sched_process_fork( trace_event_t &event );
void init_amd_timeline_event( trace_event_t &event );
void init_msm_timeline_event( trace_event_t &event );
void init_i915_event( trace_event_t &event );

int new_event_cb( const trace_event_t &event );
Expand Down
16 changes: 16 additions & 0 deletions src/gpuvis_graphrows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,22 @@ void GraphRows::init( TraceEvents &trace_events )
}
}

// Qualcomm MSM GPU timeline
{
// How many max rings on Qualcomm MSM?
for ( int ring = 0; ring < 9; ring++)
{
std::string str = string_format( "msm ring%d", ring );
std::string str_hw = string_format( "msm ring%d hw", ring );

if ( ( plocs = trace_events.get_locs( str.c_str(), &type ) ) )
push_row( str, type, plocs->size() );

if ( ( plocs = trace_events.get_locs( str_hw.c_str(), &type ) ) )
push_row( str_hw, type, plocs->size() );
}
}

if ( ( plocs = trace_events.get_locs( "cpu graph", &type ) ) )
{
push_row( "cpu graph", type, plocs->size(), false );
Expand Down

0 comments on commit 95ee1b5

Please sign in to comment.