xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/scheduler/gpu_scheduler_trace.h (revision 41ec02673d281bbb3d38e6c78504ce6e30c228c1)
1 /*	$NetBSD: gpu_scheduler_trace.h,v 1.2 2021/12/18 23:45:43 riastradh Exp $	*/
2 
3 /*
4  * Copyright 2017 Advanced Micro Devices, Inc.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */
25 
26 #if !defined(_GPU_SCHED_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
27 #define _GPU_SCHED_TRACE_H_
28 
29 #include <linux/stringify.h>
30 #include <linux/types.h>
31 #include <linux/tracepoint.h>
32 
33 #undef TRACE_SYSTEM
34 #define TRACE_SYSTEM gpu_scheduler
35 #define TRACE_INCLUDE_FILE gpu_scheduler_trace
36 
37 TRACE_EVENT(drm_sched_job,
38 	    TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
39 	    TP_ARGS(sched_job, entity),
40 	    TP_STRUCT__entry(
41 			     __field(struct drm_sched_entity *, entity)
42 			     __field(struct dma_fence *, fence)
43 			     __field(const char *, name)
44 			     __field(uint64_t, id)
45 			     __field(u32, job_count)
46 			     __field(int, hw_job_count)
47 			     ),
48 
49 	    TP_fast_assign(
50 			   __entry->entity = entity;
51 			   __entry->id = sched_job->id;
52 			   __entry->fence = &sched_job->s_fence->finished;
53 			   __entry->name = sched_job->sched->name;
54 			   __entry->job_count = spsc_queue_count(&entity->job_queue);
55 			   __entry->hw_job_count = atomic_read(
56 				   &sched_job->sched->hw_rq_count);
57 			   ),
58 	    TP_printk("entity=%p, id=%llu, fence=%p, ring=%s, job count:%u, hw job count:%d",
59 		      __entry->entity, __entry->id,
60 		      __entry->fence, __entry->name,
61 		      __entry->job_count, __entry->hw_job_count)
62 );
63 
64 TRACE_EVENT(drm_sched_process_job,
65 	    TP_PROTO(struct drm_sched_fence *fence),
66 	    TP_ARGS(fence),
67 	    TP_STRUCT__entry(
68 		    __field(struct dma_fence *, fence)
69 		    ),
70 
71 	    TP_fast_assign(
72 		    __entry->fence = &fence->finished;
73 		    ),
74 	    TP_printk("fence=%p signaled", __entry->fence)
75 );
76 
77 TRACE_EVENT(drm_sched_job_wait_dep,
78 	    TP_PROTO(struct drm_sched_job *sched_job, struct dma_fence *fence),
79 	    TP_ARGS(sched_job, fence),
80 	    TP_STRUCT__entry(
81 			     __field(const char *,name)
82 			     __field(uint64_t, id)
83 			     __field(struct dma_fence *, fence)
84 			     __field(uint64_t, ctx)
85 			     __field(unsigned, seqno)
86 			     ),
87 
88 	    TP_fast_assign(
89 			   __entry->name = sched_job->sched->name;
90 			   __entry->id = sched_job->id;
91 			   __entry->fence = fence;
92 			   __entry->ctx = fence->context;
93 			   __entry->seqno = fence->seqno;
94 			   ),
95 	    TP_printk("job ring=%s, id=%llu, depends fence=%p, context=%llu, seq=%u",
96 		      __entry->name, __entry->id,
97 		      __entry->fence, __entry->ctx,
98 		      __entry->seqno)
99 );
100 
101 #endif
102 
103 /* This part must be outside protection */
104 #undef TRACE_INCLUDE_PATH
105 #define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/scheduler
106 #include <trace/define_trace.h>
107