Traces for page directories and tables allocation/destroy and map/unmap. Signed-off-by: Michel Thierry <michel.thierry@xxxxxxxxx> --- drivers/gpu/drm/i915/i915_gem.c | 2 + drivers/gpu/drm/i915/i915_gem_gtt.c | 17 ++++++ drivers/gpu/drm/i915/i915_trace.h | 115 ++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 65e055c..bab62d2 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -3587,6 +3587,8 @@ search_free: /* allocate before insert / bind */ if (vma->vm->allocate_va_range) { + trace_i915_va_alloc(vma->vm, vma->node.start, vma->node.size, + VM_TO_TRACE_NAME(vma->vm)); ret = vma->vm->allocate_va_range(vma->vm, vma->node.start, vma->node.size); diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index d37bd83..40996fe 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -1176,6 +1176,7 @@ static int gen6_alloc_va_range(struct i915_address_space *vm, ppgtt->pd.page_tables[pde] = pt; set_bit(pde, new_page_tables); + trace_i915_page_table_entry_alloc(vm, pde, start, GEN6_PDE_SHIFT); } start = start_save; @@ -1190,6 +1191,10 @@ static int gen6_alloc_va_range(struct i915_address_space *vm, if (test_and_clear_bit(pde, new_page_tables)) gen6_write_pdes(&ppgtt->pd, pde, pt); + trace_i915_page_table_entry_map(vm, pde, pt, + gen6_pte_index(start), + gen6_pte_count(start, length), + I915_PPGTT_PT_ENTRIES); bitmap_or(pt->used_ptes, tmp_bitmap, pt->used_ptes, I915_PPGTT_PT_ENTRIES); } @@ -1229,10 +1234,18 @@ static void gen6_teardown_va_range(struct i915_address_space *vm, vm, pde, start, start + length)) continue; + trace_i915_page_table_entry_unmap(vm, pde, pt, + gen6_pte_index(start), + gen6_pte_count(start, length), + I915_PPGTT_PT_ENTRIES); + bitmap_clear(pt->used_ptes, gen6_pte_index(start), gen6_pte_count(start, length)); if (bitmap_empty(pt->used_ptes, I915_PPGTT_PT_ENTRIES)) { + trace_i915_page_table_entry_destroy(vm, pde, + start & GENMASK_ULL(63, GEN6_PDE_SHIFT), + GEN6_PDE_SHIFT); gen6_write_pdes(&ppgtt->pd, pde, ppgtt->scratch_pt); ppgtt->pd.page_tables[pde] = ppgtt->scratch_pt; } @@ -1525,6 +1538,10 @@ static void ppgtt_unbind_vma(struct i915_vma *vma) vma->obj->base.size, true); if (vma->vm->teardown_va_range) { + trace_i915_va_teardown(vma->vm, + vma->node.start, vma->node.size, + VM_TO_TRACE_NAME(vma->vm)); + vma->vm->teardown_va_range(vma->vm, vma->node.start, vma->node.size); } diff --git a/drivers/gpu/drm/i915/i915_trace.h b/drivers/gpu/drm/i915/i915_trace.h index f004d3d..22fa11d 100644 --- a/drivers/gpu/drm/i915/i915_trace.h +++ b/drivers/gpu/drm/i915/i915_trace.h @@ -156,6 +156,121 @@ TRACE_EVENT(i915_vma_unbind, __entry->obj, __entry->offset, __entry->size, __entry->vm) ); +#define VM_TO_TRACE_NAME(vm) \ + (i915_is_ggtt(vm) ? "GGTT" : \ + "Private VM") + +DECLARE_EVENT_CLASS(i915_va, + TP_PROTO(struct i915_address_space *vm, u64 start, u64 length, const char *name), + TP_ARGS(vm, start, length, name), + + TP_STRUCT__entry( + __field(struct i915_address_space *, vm) + __field(u64, start) + __field(u64, end) + __string(name, name) + ), + + TP_fast_assign( + __entry->vm = vm; + __entry->start = start; + __entry->end = start + length; + __assign_str(name, name); + ), + + TP_printk("vm=%p (%s), 0x%llx-0x%llx", + __entry->vm, __get_str(name), __entry->start, __entry->end) +); + +DEFINE_EVENT(i915_va, i915_va_alloc, + TP_PROTO(struct i915_address_space *vm, u64 start, u64 length, const char *name), + TP_ARGS(vm, start, length, name) +); + +DEFINE_EVENT(i915_va, i915_va_teardown, + TP_PROTO(struct i915_address_space *vm, u64 start, u64 length, const char *name), + TP_ARGS(vm, start, length, name) +); + +DECLARE_EVENT_CLASS(i915_page_table_entry, + TP_PROTO(struct i915_address_space *vm, u32 pde, u64 start, u64 pde_shift), + TP_ARGS(vm, pde, start, pde_shift), + + TP_STRUCT__entry( + __field(struct i915_address_space *, vm) + __field(u32, pde) + __field(u64, start) + __field(u64, end) + ), + + TP_fast_assign( + __entry->vm = vm; + __entry->pde = pde; + __entry->start = start; + __entry->end = (start + (1ULL << pde_shift)) & ~((1ULL << pde_shift)-1); + ), + + TP_printk("vm=%p, pde=%d (0x%llx-0x%llx)", + __entry->vm, __entry->pde, __entry->start, __entry->end) +); + +DEFINE_EVENT(i915_page_table_entry, i915_page_table_entry_alloc, + TP_PROTO(struct i915_address_space *vm, u32 pde, u64 start, u64 pde_shift), + TP_ARGS(vm, pde, start, pde_shift) +); + +DEFINE_EVENT(i915_page_table_entry, i915_page_table_entry_destroy, + TP_PROTO(struct i915_address_space *vm, u32 pde, u64 start, u64 pde_shift), + TP_ARGS(vm, pde, start, pde_shift) +); + +/* Avoid extra math because we only support two sizes. The format is defined by + * bitmap_scnprintf. Each 32 bits is 8 HEX digits followed by comma */ +#define TRACE_PT_SIZE(bits) \ + ((((bits) == 1024) ? 288 : 144) + 1) + +DECLARE_EVENT_CLASS(i915_page_table_entry_update, + TP_PROTO(struct i915_address_space *vm, u32 pde, + struct i915_page_table_entry *pt, u32 first, u32 len, size_t bits), + TP_ARGS(vm, pde, pt, first, len, bits), + + TP_STRUCT__entry( + __field(struct i915_address_space *, vm) + __field(u32, pde) + __field(u32, first) + __field(u32, last) + __dynamic_array(char, cur_ptes, TRACE_PT_SIZE(bits)) + ), + + TP_fast_assign( + __entry->vm = vm; + __entry->pde = pde; + __entry->first = first; + __entry->last = first + len; + + bitmap_scnprintf(__get_str(cur_ptes), + TRACE_PT_SIZE(bits), + pt->used_ptes, + bits); + ), + + TP_printk("vm=%p, pde=%d, updating %u:%u\t%s", + __entry->vm, __entry->pde, __entry->last, __entry->first, + __get_str(cur_ptes)) +); + +DEFINE_EVENT(i915_page_table_entry_update, i915_page_table_entry_map, + TP_PROTO(struct i915_address_space *vm, u32 pde, + struct i915_page_table_entry *pt, u32 first, u32 len, size_t bits), + TP_ARGS(vm, pde, pt, first, len, bits) +); + +DEFINE_EVENT(i915_page_table_entry_update, i915_page_table_entry_unmap, + TP_PROTO(struct i915_address_space *vm, u32 pde, + struct i915_page_table_entry *pt, u32 first, u32 len, size_t bits), + TP_ARGS(vm, pde, pt, first, len, bits) +); + TRACE_EVENT(i915_gem_object_change_domain, TP_PROTO(struct drm_i915_gem_object *obj, u32 old_read, u32 old_write), TP_ARGS(obj, old_read, old_write), -- 2.1.1 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx