3 * (C) COPYRIGHT 2015-2016 ARM Limited. All rights reserved.
5 * This program is free software and is provided to you under the terms of the
6 * GNU General Public License version 2 as published by the Free Software
7 * Foundation, and any use by you of this program is subject to the terms
10 * A copy of the licence is included with the program, and can also be obtained
11 * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12 * Boston, MA 02110-1301, USA.
18 #include <linux/anon_inodes.h>
19 #include <linux/atomic.h>
20 #include <linux/file.h>
21 #include <linux/mutex.h>
22 #include <linux/poll.h>
23 #include <linux/spinlock.h>
24 #include <linux/string.h>
25 #include <linux/stringify.h>
26 #include <linux/timer.h>
27 #include <linux/wait.h>
29 #include <mali_kbase.h>
30 #include <mali_kbase_jm.h>
31 #include <mali_kbase_tlstream.h>
33 /*****************************************************************************/
35 /* The version of swtrace protocol used in timeline stream. */
36 #define SWTRACE_VERSION 3
38 /* The maximum expected length of string in tracepoint descriptor. */
39 #define STRLEN_MAX 64 /* bytes */
41 /* The number of nanoseconds in a second. */
42 #define NSECS_IN_SEC 1000000000ull /* ns */
44 /* The period of autoflush checker execution in milliseconds. */
45 #define AUTOFLUSH_INTERVAL 1000 /* ms */
47 /* The maximum size of a single packet used by timeline. */
48 #define PACKET_SIZE 4096 /* bytes */
50 /* The number of packets used by one timeline stream. */
51 #define PACKET_COUNT 16
53 /* The number of bytes reserved for packet header.
54 * These value must be defined according to MIPE documentation. */
55 #define PACKET_HEADER_SIZE 8 /* bytes */
57 /* The number of bytes reserved for packet sequence number.
58 * These value must be defined according to MIPE documentation. */
59 #define PACKET_NUMBER_SIZE 4 /* bytes */
61 /* Packet header - first word.
62 * These values must be defined according to MIPE documentation. */
63 #define PACKET_STREAMID_POS 0
64 #define PACKET_STREAMID_LEN 8
65 #define PACKET_RSVD1_POS (PACKET_STREAMID_POS + PACKET_STREAMID_LEN)
66 #define PACKET_RSVD1_LEN 8
67 #define PACKET_TYPE_POS (PACKET_RSVD1_POS + PACKET_RSVD1_LEN)
68 #define PACKET_TYPE_LEN 3
69 #define PACKET_CLASS_POS (PACKET_TYPE_POS + PACKET_TYPE_LEN)
70 #define PACKET_CLASS_LEN 7
71 #define PACKET_FAMILY_POS (PACKET_CLASS_POS + PACKET_CLASS_LEN)
72 #define PACKET_FAMILY_LEN 6
74 /* Packet header - second word
75 * These values must be defined according to MIPE documentation. */
76 #define PACKET_LENGTH_POS 0
77 #define PACKET_LENGTH_LEN 24
78 #define PACKET_SEQBIT_POS (PACKET_LENGTH_POS + PACKET_LENGTH_LEN)
79 #define PACKET_SEQBIT_LEN 1
80 #define PACKET_RSVD2_POS (PACKET_SEQBIT_POS + PACKET_SEQBIT_LEN)
81 #define PACKET_RSVD2_LEN 7
83 /* Types of streams generated by timeline.
84 * Order is significant! Header streams must precede respective body streams. */
86 TL_STREAM_TYPE_OBJ_HEADER,
87 TL_STREAM_TYPE_OBJ_SUMMARY,
89 TL_STREAM_TYPE_AUX_HEADER,
95 /* Timeline packet family ids.
96 * Values are significant! Check MIPE documentation. */
97 enum tl_packet_family {
98 TL_PACKET_FAMILY_CTRL = 0, /* control packets */
99 TL_PACKET_FAMILY_TL = 1, /* timeline packets */
101 TL_PACKET_FAMILY_COUNT
104 /* Packet classes used in timeline streams.
105 * Values are significant! Check MIPE documentation. */
106 enum tl_packet_class {
107 TL_PACKET_CLASS_OBJ = 0, /* timeline objects packet */
108 TL_PACKET_CLASS_AUX = 1, /* auxiliary events packet */
111 /* Packet types used in timeline streams.
112 * Values are significant! Check MIPE documentation. */
113 enum tl_packet_type {
114 TL_PACKET_TYPE_HEADER = 0, /* stream's header/directory */
115 TL_PACKET_TYPE_BODY = 1, /* stream's body */
116 TL_PACKET_TYPE_SUMMARY = 2, /* stream's summary */
119 /* Message ids of trace events that are recorded in the timeline stream. */
121 /* Timeline object events. */
129 KBASE_TL_LIFELINK_LPU_GPU,
130 KBASE_TL_LIFELINK_AS_GPU,
131 KBASE_TL_RET_CTX_LPU,
132 KBASE_TL_RET_ATOM_CTX,
133 KBASE_TL_RET_ATOM_LPU,
134 KBASE_TL_NRET_CTX_LPU,
135 KBASE_TL_NRET_ATOM_CTX,
136 KBASE_TL_NRET_ATOM_LPU,
138 KBASE_TL_NRET_AS_CTX,
139 KBASE_TL_RET_ATOM_AS,
140 KBASE_TL_NRET_ATOM_AS,
141 KBASE_TL_DEP_ATOM_ATOM,
142 KBASE_TL_NDEP_ATOM_ATOM,
143 KBASE_TL_RDEP_ATOM_ATOM,
144 KBASE_TL_ATTRIB_ATOM_CONFIG,
145 KBASE_TL_ATTRIB_AS_CONFIG,
147 /* Job dump specific events. */
148 KBASE_JD_GPU_SOFT_RESET
151 /* Message ids of trace events that are recorded in the auxiliary stream. */
154 KBASE_AUX_ISSUE_JOB_SOFTSTOP,
155 KBASE_AUX_JOB_SOFTSTOP,
156 KBASE_AUX_JOB_SOFTSTOP_EX,
161 /*****************************************************************************/
164 * struct tl_stream - timeline stream structure
165 * @lock: message order lock
166 * @buffer: array of buffers
167 * @wbi: write buffer index
168 * @rbi: read buffer index
169 * @numbered: if non-zero stream's packets are sequentially numbered
170 * @autoflush_counter: counter tracking stream's autoflush state
172 * This structure holds information needed to construct proper packets in the
173 * timeline stream. Each message in sequence must bear timestamp that is greater
174 * to one in previous message in the same stream. For this reason lock is held
175 * throughout the process of message creation. Each stream contains set of
176 * buffers. Each buffer will hold one MIPE packet. In case there is no free
177 * space required to store incoming message the oldest buffer is discarded.
178 * Each packet in timeline body stream has sequence number embedded (this value
179 * must increment monotonically and is used by packets receiver to discover
181 * Autoflush counter is set to negative number when there is no data pending
182 * for flush and it is set to zero on every update of the buffer. Autoflush
183 * timer will increment the counter by one on every expiry. In case there will
184 * be no activity on the buffer during two consecutive timer expiries, stream
185 * buffer will be flushed.
191 atomic_t size; /* number of bytes in buffer */
192 char data[PACKET_SIZE]; /* buffer's data */
193 } buffer[PACKET_COUNT];
199 atomic_t autoflush_counter;
203 * struct tp_desc - tracepoint message descriptor structure
204 * @id: tracepoint ID identifying message in stream
205 * @id_str: human readable version of tracepoint ID
206 * @name: tracepoint description
207 * @arg_types: tracepoint's arguments types declaration
208 * @arg_names: comma separated list of tracepoint's arguments names
214 const char *arg_types;
215 const char *arg_names;
218 /*****************************************************************************/
220 /* Configuration of timeline streams generated by kernel.
221 * Kernel emit only streams containing either timeline object events or
222 * auxiliary events. All streams have stream id value of 1 (as opposed to user
223 * space streams that have value of 0). */
224 static const struct {
225 enum tl_packet_family pkt_family;
226 enum tl_packet_class pkt_class;
227 enum tl_packet_type pkt_type;
228 unsigned int stream_id;
229 } tl_stream_cfg[TL_STREAM_TYPE_COUNT] = {
230 {TL_PACKET_FAMILY_TL, TL_PACKET_CLASS_OBJ, TL_PACKET_TYPE_HEADER, 1},
231 {TL_PACKET_FAMILY_TL, TL_PACKET_CLASS_OBJ, TL_PACKET_TYPE_SUMMARY, 1},
232 {TL_PACKET_FAMILY_TL, TL_PACKET_CLASS_OBJ, TL_PACKET_TYPE_BODY, 1},
233 {TL_PACKET_FAMILY_TL, TL_PACKET_CLASS_AUX, TL_PACKET_TYPE_HEADER, 1},
234 {TL_PACKET_FAMILY_TL, TL_PACKET_CLASS_AUX, TL_PACKET_TYPE_BODY, 1}
237 /* The timeline streams generated by kernel. */
238 static struct tl_stream *tl_stream[TL_STREAM_TYPE_COUNT];
240 /* Autoflush timer. */
241 static struct timer_list autoflush_timer;
243 /* If non-zero autoflush timer is active. */
244 static atomic_t autoflush_timer_active;
246 /* Reader lock. Only one reader is allowed to have access to the timeline
247 * streams at any given time. */
248 static DEFINE_MUTEX(tl_reader_lock);
250 /* Timeline stream event queue. */
251 static DECLARE_WAIT_QUEUE_HEAD(tl_event_queue);
253 /* The timeline stream file operations functions. */
254 static ssize_t kbasep_tlstream_read(
259 static unsigned int kbasep_tlstream_poll(struct file *filp, poll_table *wait);
260 static int kbasep_tlstream_release(struct inode *inode, struct file *filp);
262 /* The timeline stream file operations structure. */
263 static const struct file_operations kbasep_tlstream_fops = {
264 .release = kbasep_tlstream_release,
265 .read = kbasep_tlstream_read,
266 .poll = kbasep_tlstream_poll,
269 /* Descriptors of timeline messages transmitted in object events stream. */
270 static const struct tp_desc tp_desc_obj[] = {
273 __stringify(KBASE_TL_NEW_CTX),
274 "object ctx is created",
280 __stringify(KBASE_TL_NEW_GPU),
281 "object gpu is created",
283 "gpu,gpu_id,core_count"
287 __stringify(KBASE_TL_NEW_LPU),
288 "object lpu is created",
294 __stringify(KBASE_TL_NEW_ATOM),
295 "object atom is created",
301 __stringify(KBASE_TL_NEW_AS),
302 "address space object is created",
304 "address_space,as_nr"
308 __stringify(KBASE_TL_DEL_CTX),
309 "context is destroyed",
315 __stringify(KBASE_TL_DEL_ATOM),
321 KBASE_TL_LIFELINK_LPU_GPU,
322 __stringify(KBASE_TL_LIFELINK_LPU_GPU),
323 "lpu is deleted with gpu",
328 KBASE_TL_LIFELINK_AS_GPU,
329 __stringify(KBASE_TL_LIFELINK_AS_GPU),
330 "address space is deleted with gpu",
335 KBASE_TL_RET_CTX_LPU,
336 __stringify(KBASE_TL_RET_CTX_LPU),
337 "context is retained by lpu",
342 KBASE_TL_RET_ATOM_CTX,
343 __stringify(KBASE_TL_RET_ATOM_CTX),
344 "atom is retained by context",
349 KBASE_TL_RET_ATOM_LPU,
350 __stringify(KBASE_TL_RET_ATOM_LPU),
351 "atom is retained by lpu",
353 "atom,lpu,attrib_match_list"
356 KBASE_TL_NRET_CTX_LPU,
357 __stringify(KBASE_TL_NRET_CTX_LPU),
358 "context is released by lpu",
363 KBASE_TL_NRET_ATOM_CTX,
364 __stringify(KBASE_TL_NRET_ATOM_CTX),
365 "atom is released by context",
370 KBASE_TL_NRET_ATOM_LPU,
371 __stringify(KBASE_TL_NRET_ATOM_LPU),
372 "atom is released by lpu",
378 __stringify(KBASE_TL_RET_AS_CTX),
379 "address space is retained by context",
384 KBASE_TL_NRET_AS_CTX,
385 __stringify(KBASE_TL_NRET_AS_CTX),
386 "address space is released by context",
391 KBASE_TL_RET_ATOM_AS,
392 __stringify(KBASE_TL_RET_ATOM_AS),
393 "atom is retained by address space",
398 KBASE_TL_NRET_ATOM_AS,
399 __stringify(KBASE_TL_NRET_ATOM_AS),
400 "atom is released by address space",
405 KBASE_TL_DEP_ATOM_ATOM,
406 __stringify(KBASE_TL_DEP_ATOM_ATOM),
407 "atom2 depends on atom1",
412 KBASE_TL_NDEP_ATOM_ATOM,
413 __stringify(KBASE_TL_NDEP_ATOM_ATOM),
414 "atom2 no longer depends on atom1",
419 KBASE_TL_RDEP_ATOM_ATOM,
420 __stringify(KBASE_TL_RDEP_ATOM_ATOM),
421 "resolved dependecy of atom2 depending on atom1",
426 KBASE_TL_ATTRIB_ATOM_CONFIG,
427 __stringify(KBASE_TL_ATTRIB_ATOM_CONFIG),
428 "atom job slot attributes",
430 "atom,descriptor,affinity,config"
433 KBASE_TL_ATTRIB_AS_CONFIG,
434 __stringify(KBASE_TL_ATTRIB_AS_CONFIG),
435 "address space attributes",
437 "address_space,transtab,memattr,transcfg"
440 KBASE_JD_GPU_SOFT_RESET,
441 __stringify(KBASE_JD_GPU_SOFT_RESET),
448 /* Descriptors of timeline messages transmitted in auxiliary events stream. */
449 static const struct tp_desc tp_desc_aux[] = {
452 __stringify(KBASE_AUX_PM_STATE),
455 "core_type,core_state_bitset"
458 KBASE_AUX_ISSUE_JOB_SOFTSTOP,
459 __stringify(KBASE_AUX_ISSUE_JOB_SOFTSTOP),
460 "Issuing job soft stop",
465 KBASE_AUX_JOB_SOFTSTOP,
466 __stringify(KBASE_AUX_JOB_SOFTSTOP),
472 KBASE_AUX_JOB_SOFTSTOP_EX,
473 __stringify(KBASE_AUX_JOB_SOFTSTOP_EX),
474 "Job soft stop, more details",
480 __stringify(KBASE_AUX_PAGEFAULT),
483 "ctx_nr,page_cnt_change"
486 KBASE_AUX_PAGESALLOC,
487 __stringify(KBASE_AUX_PAGESALLOC),
488 "Total alloc pages change",
495 /* Number of bytes read by user. */
496 static atomic_t tlstream_bytes_collected = {0};
498 /* Number of bytes generated by tracepoint messages. */
499 static atomic_t tlstream_bytes_generated = {0};
500 #endif /* MALI_UNIT_TEST */
502 /*****************************************************************************/
504 /* Indicator of whether the timeline stream file descriptor is used. */
505 atomic_t kbase_tlstream_enabled = {0};
507 /*****************************************************************************/
510 * kbasep_tlstream_get_timestamp - return timestamp
512 * Function returns timestamp value based on raw monotonic timer. Value will
513 * wrap around zero in case of overflow.
514 * Return: timestamp value
516 static u64 kbasep_tlstream_get_timestamp(void)
521 getrawmonotonic(&ts);
522 timestamp = (u64)ts.tv_sec * NSECS_IN_SEC + ts.tv_nsec;
527 * kbasep_tlstream_write_bytes - write data to message buffer
528 * @buffer: buffer where data will be written
529 * @pos: position in the buffer where to place data
530 * @bytes: pointer to buffer holding data
531 * @len: length of data to be written
533 * Return: updated position in the buffer
535 static size_t kbasep_tlstream_write_bytes(
541 KBASE_DEBUG_ASSERT(buffer);
542 KBASE_DEBUG_ASSERT(bytes);
544 memcpy(&buffer[pos], bytes, len);
550 * kbasep_tlstream_write_string - write string to message buffer
551 * @buffer: buffer where data will be written
552 * @pos: position in the buffer where to place data
553 * @string: pointer to buffer holding the source string
554 * @max_write_size: number of bytes that can be stored in buffer
556 * Return: updated position in the buffer
558 static size_t kbasep_tlstream_write_string(
562 size_t max_write_size)
566 KBASE_DEBUG_ASSERT(buffer);
567 KBASE_DEBUG_ASSERT(string);
568 /* Timeline string consists of at least string length and nul
570 KBASE_DEBUG_ASSERT(max_write_size >= sizeof(string_len) + sizeof(char));
571 max_write_size -= sizeof(string_len);
573 string_len = strlcpy(
574 &buffer[pos + sizeof(string_len)],
577 string_len += sizeof(char);
579 /* Make sure that the source string fit into the buffer. */
580 KBASE_DEBUG_ASSERT(string_len <= max_write_size);
582 /* Update string length. */
583 memcpy(&buffer[pos], &string_len, sizeof(string_len));
585 return pos + sizeof(string_len) + string_len;
589 * kbasep_tlstream_write_timestamp - write timestamp to message buffer
590 * @buffer: buffer where data will be written
591 * @pos: position in the buffer where to place data
593 * Return: updated position in the buffer
595 static size_t kbasep_tlstream_write_timestamp(void *buffer, size_t pos)
597 u64 timestamp = kbasep_tlstream_get_timestamp();
599 return kbasep_tlstream_write_bytes(
601 ×tamp, sizeof(timestamp));
605 * kbasep_tlstream_put_bits - put bits in a word
606 * @word: pointer to the words being modified
607 * @value: value that shall be written to given position
608 * @bitpos: position where value shall be written (in bits)
609 * @bitlen: length of value (in bits)
611 static void kbasep_tlstream_put_bits(
617 const u32 mask = ((1 << bitlen) - 1) << bitpos;
619 KBASE_DEBUG_ASSERT(word);
620 KBASE_DEBUG_ASSERT((0 != bitlen) && (32 >= bitlen));
621 KBASE_DEBUG_ASSERT((bitpos + bitlen) <= 32);
624 *word |= ((value << bitpos) & mask);
628 * kbasep_tlstream_packet_header_setup - setup the packet header
629 * @buffer: pointer to the buffer
630 * @pkt_family: packet's family
631 * @pkt_type: packet's type
632 * @pkt_class: packet's class
633 * @stream_id: stream id
634 * @numbered: non-zero if this stream is numbered
636 * Function sets up immutable part of packet header in the given buffer.
638 static void kbasep_tlstream_packet_header_setup(
640 enum tl_packet_family pkt_family,
641 enum tl_packet_class pkt_class,
642 enum tl_packet_type pkt_type,
643 unsigned int stream_id,
649 KBASE_DEBUG_ASSERT(buffer);
650 KBASE_DEBUG_ASSERT(pkt_family == TL_PACKET_FAMILY_TL);
652 (pkt_type == TL_PACKET_TYPE_HEADER) ||
653 (pkt_type == TL_PACKET_TYPE_SUMMARY) ||
654 (pkt_type == TL_PACKET_TYPE_BODY));
656 (pkt_class == TL_PACKET_CLASS_OBJ) ||
657 (pkt_class == TL_PACKET_CLASS_AUX));
659 kbasep_tlstream_put_bits(
661 PACKET_FAMILY_POS, PACKET_FAMILY_LEN);
662 kbasep_tlstream_put_bits(
664 PACKET_CLASS_POS, PACKET_CLASS_LEN);
665 kbasep_tlstream_put_bits(
667 PACKET_TYPE_POS, PACKET_TYPE_LEN);
668 kbasep_tlstream_put_bits(
670 PACKET_STREAMID_POS, PACKET_STREAMID_LEN);
673 kbasep_tlstream_put_bits(
675 PACKET_SEQBIT_POS, PACKET_SEQBIT_LEN);
677 memcpy(&buffer[0], &word0, sizeof(word0));
678 memcpy(&buffer[sizeof(word0)], &word1, sizeof(word1));
682 * kbasep_tlstream_packet_header_update - update the packet header
683 * @buffer: pointer to the buffer
684 * @data_size: amount of data carried in this packet
686 * Function updates mutable part of packet header in the given buffer.
687 * Note that value of data_size must not including size of the header.
689 static void kbasep_tlstream_packet_header_update(
696 KBASE_DEBUG_ASSERT(buffer);
699 memcpy(&word1, &buffer[sizeof(word0)], sizeof(word1));
701 kbasep_tlstream_put_bits(
703 PACKET_LENGTH_POS, PACKET_LENGTH_LEN);
705 memcpy(&buffer[sizeof(word0)], &word1, sizeof(word1));
709 * kbasep_tlstream_packet_number_update - update the packet number
710 * @buffer: pointer to the buffer
711 * @counter: value of packet counter for this packet's stream
713 * Function updates packet number embedded within the packet placed in the
716 static void kbasep_tlstream_packet_number_update(char *buffer, u32 counter)
718 KBASE_DEBUG_ASSERT(buffer);
720 memcpy(&buffer[PACKET_HEADER_SIZE], &counter, sizeof(counter));
724 * kbasep_timeline_stream_reset - reset stream
725 * @stream: pointer to the stream structure
727 * Function discards all pending messages and resets packet counters.
729 static void kbasep_timeline_stream_reset(struct tl_stream *stream)
733 for (i = 0; i < PACKET_COUNT; i++) {
734 if (stream->numbered)
736 &stream->buffer[i].size,
740 atomic_set(&stream->buffer[i].size, PACKET_HEADER_SIZE);
743 atomic_set(&stream->wbi, 0);
744 atomic_set(&stream->rbi, 0);
748 * kbasep_timeline_stream_init - initialize timeline stream
749 * @stream: pointer to the stream structure
750 * @stream_type: stream type
752 static void kbasep_timeline_stream_init(
753 struct tl_stream *stream,
754 enum tl_stream_type stream_type)
758 KBASE_DEBUG_ASSERT(stream);
759 KBASE_DEBUG_ASSERT(TL_STREAM_TYPE_COUNT > stream_type);
761 spin_lock_init(&stream->lock);
763 /* All packets carrying tracepoints shall be numbered. */
764 if (TL_PACKET_TYPE_BODY == tl_stream_cfg[stream_type].pkt_type)
765 stream->numbered = 1;
767 stream->numbered = 0;
769 for (i = 0; i < PACKET_COUNT; i++)
770 kbasep_tlstream_packet_header_setup(
771 stream->buffer[i].data,
772 tl_stream_cfg[stream_type].pkt_family,
773 tl_stream_cfg[stream_type].pkt_class,
774 tl_stream_cfg[stream_type].pkt_type,
775 tl_stream_cfg[stream_type].stream_id,
778 kbasep_timeline_stream_reset(tl_stream[stream_type]);
782 * kbasep_timeline_stream_term - terminate timeline stream
783 * @stream: pointer to the stream structure
785 static void kbasep_timeline_stream_term(struct tl_stream *stream)
787 KBASE_DEBUG_ASSERT(stream);
791 * kbasep_tlstream_msgbuf_submit - submit packet to the user space
792 * @stream: pointer to the stream structure
793 * @wb_idx_raw: write buffer index
794 * @wb_size: length of data stored in current buffer
796 * Function updates currently written buffer with packet header. Then write
797 * index is incremented and buffer is handled to user space. Parameters
798 * of new buffer are returned using provided arguments.
800 * Return: length of data in new buffer
802 * Warning: User must update the stream structure with returned value.
804 static size_t kbasep_tlstream_msgbuf_submit(
805 struct tl_stream *stream,
806 unsigned int wb_idx_raw,
807 unsigned int wb_size)
809 unsigned int rb_idx_raw = atomic_read(&stream->rbi);
810 unsigned int wb_idx = wb_idx_raw % PACKET_COUNT;
812 /* Set stream as flushed. */
813 atomic_set(&stream->autoflush_counter, -1);
815 kbasep_tlstream_packet_header_update(
816 stream->buffer[wb_idx].data,
817 wb_size - PACKET_HEADER_SIZE);
819 if (stream->numbered)
820 kbasep_tlstream_packet_number_update(
821 stream->buffer[wb_idx].data,
824 /* Increasing write buffer index will expose this packet to the reader.
825 * As stream->lock is not taken on reader side we must make sure memory
826 * is updated correctly before this will happen. */
829 atomic_set(&stream->wbi, wb_idx_raw);
831 /* Inform user that packets are ready for reading. */
832 wake_up_interruptible(&tl_event_queue);
834 /* Detect and mark overflow in this stream. */
835 if (PACKET_COUNT == wb_idx_raw - rb_idx_raw) {
836 /* Reader side depends on this increment to correctly handle
837 * overflows. The value shall be updated only if it was not
838 * modified by the reader. The data holding buffer will not be
839 * updated before stream->lock is released, however size of the
840 * buffer will. Make sure this increment is globally visible
841 * before information about selected write buffer size. */
842 atomic_cmpxchg(&stream->rbi, rb_idx_raw, rb_idx_raw + 1);
845 wb_size = PACKET_HEADER_SIZE;
846 if (stream->numbered)
847 wb_size += PACKET_NUMBER_SIZE;
853 * kbasep_tlstream_msgbuf_acquire - lock selected stream and reserves buffer
854 * @stream_type: type of the stream that shall be locked
855 * @msg_size: message size
856 * @flags: pointer to store flags passed back on stream release
858 * Function will lock the stream and reserve the number of bytes requested
859 * in msg_size for the user.
861 * Return: pointer to the buffer where message can be stored
863 * Warning: Stream must be released with kbasep_tlstream_msgbuf_release().
864 * Only atomic operations are allowed while stream is locked
865 * (i.e. do not use any operation that may sleep).
867 static char *kbasep_tlstream_msgbuf_acquire(
868 enum tl_stream_type stream_type,
870 unsigned long *flags) __acquires(&stream->lock)
872 struct tl_stream *stream;
873 unsigned int wb_idx_raw;
877 KBASE_DEBUG_ASSERT(TL_STREAM_TYPE_COUNT > stream_type);
879 PACKET_SIZE - PACKET_HEADER_SIZE - PACKET_NUMBER_SIZE >=
882 stream = tl_stream[stream_type];
884 spin_lock_irqsave(&stream->lock, *flags);
886 wb_idx_raw = atomic_read(&stream->wbi);
887 wb_idx = wb_idx_raw % PACKET_COUNT;
888 wb_size = atomic_read(&stream->buffer[wb_idx].size);
890 /* Select next buffer if data will not fit into current one. */
891 if (PACKET_SIZE < wb_size + msg_size) {
892 wb_size = kbasep_tlstream_msgbuf_submit(
893 stream, wb_idx_raw, wb_size);
894 wb_idx = (wb_idx_raw + 1) % PACKET_COUNT;
897 /* Reserve space in selected buffer. */
898 atomic_set(&stream->buffer[wb_idx].size, wb_size + msg_size);
901 atomic_add(msg_size, &tlstream_bytes_generated);
902 #endif /* MALI_UNIT_TEST */
904 return &stream->buffer[wb_idx].data[wb_size];
908 * kbasep_tlstream_msgbuf_release - unlock selected stream
909 * @stream_type: type of the stream that shall be locked
910 * @flags: value obtained during stream acquire
912 * Function releases stream that has been previously locked with a call to
913 * kbasep_tlstream_msgbuf_acquire().
915 static void kbasep_tlstream_msgbuf_release(
916 enum tl_stream_type stream_type,
917 unsigned long flags) __releases(&stream->lock)
919 struct tl_stream *stream;
921 KBASE_DEBUG_ASSERT(TL_STREAM_TYPE_COUNT > stream_type);
923 stream = tl_stream[stream_type];
925 /* Mark stream as containing unflushed data. */
926 atomic_set(&stream->autoflush_counter, 0);
928 spin_unlock_irqrestore(&stream->lock, flags);
931 /*****************************************************************************/
934 * kbasep_tlstream_flush_stream - flush stream
935 * @stype: type of stream to be flushed
937 * Flush pending data in timeline stream.
939 static void kbasep_tlstream_flush_stream(enum tl_stream_type stype)
941 struct tl_stream *stream = tl_stream[stype];
943 unsigned int wb_idx_raw;
946 size_t min_size = PACKET_HEADER_SIZE;
948 if (stream->numbered)
949 min_size += PACKET_NUMBER_SIZE;
951 spin_lock_irqsave(&stream->lock, flags);
953 wb_idx_raw = atomic_read(&stream->wbi);
954 wb_idx = wb_idx_raw % PACKET_COUNT;
955 wb_size = atomic_read(&stream->buffer[wb_idx].size);
957 if (wb_size > min_size) {
958 wb_size = kbasep_tlstream_msgbuf_submit(
959 stream, wb_idx_raw, wb_size);
960 wb_idx = (wb_idx_raw + 1) % PACKET_COUNT;
961 atomic_set(&stream->buffer[wb_idx].size, wb_size);
963 spin_unlock_irqrestore(&stream->lock, flags);
967 * kbasep_tlstream_autoflush_timer_callback - autoflush timer callback
970 * Timer is executed periodically to check if any of the stream contains
971 * buffer ready to be submitted to user space.
973 static void kbasep_tlstream_autoflush_timer_callback(unsigned long data)
975 enum tl_stream_type stype;
980 for (stype = 0; stype < TL_STREAM_TYPE_COUNT; stype++) {
981 struct tl_stream *stream = tl_stream[stype];
983 unsigned int wb_idx_raw;
986 size_t min_size = PACKET_HEADER_SIZE;
988 int af_cnt = atomic_read(&stream->autoflush_counter);
990 /* Check if stream contain unflushed data. */
994 /* Check if stream should be flushed now. */
995 if (af_cnt != atomic_cmpxchg(
996 &stream->autoflush_counter,
1003 /* Autoflush this stream. */
1004 if (stream->numbered)
1005 min_size += PACKET_NUMBER_SIZE;
1007 spin_lock_irqsave(&stream->lock, flags);
1009 wb_idx_raw = atomic_read(&stream->wbi);
1010 wb_idx = wb_idx_raw % PACKET_COUNT;
1011 wb_size = atomic_read(&stream->buffer[wb_idx].size);
1013 if (wb_size > min_size) {
1014 wb_size = kbasep_tlstream_msgbuf_submit(
1015 stream, wb_idx_raw, wb_size);
1016 wb_idx = (wb_idx_raw + 1) % PACKET_COUNT;
1017 atomic_set(&stream->buffer[wb_idx].size,
1020 spin_unlock_irqrestore(&stream->lock, flags);
1023 if (atomic_read(&autoflush_timer_active))
1026 jiffies + msecs_to_jiffies(AUTOFLUSH_INTERVAL));
1031 * kbasep_tlstream_packet_pending - check timeline streams for pending packets
1032 * @stype: pointer to variable where stream type will be placed
1033 * @rb_idx_raw: pointer to variable where read buffer index will be placed
1035 * Function checks all streams for pending packets. It will stop as soon as
1036 * packet ready to be submitted to user space is detected. Variables under
1037 * pointers, passed as the parameters to this function will be updated with
1038 * values pointing to right stream and buffer.
1040 * Return: non-zero if any of timeline streams has at last one packet ready
1042 static int kbasep_tlstream_packet_pending(
1043 enum tl_stream_type *stype,
1044 unsigned int *rb_idx_raw)
1048 KBASE_DEBUG_ASSERT(stype);
1049 KBASE_DEBUG_ASSERT(rb_idx_raw);
1053 (*stype < TL_STREAM_TYPE_COUNT) && !pending;
1055 if (NULL != tl_stream[*stype]) {
1056 *rb_idx_raw = atomic_read(&tl_stream[*stype]->rbi);
1057 /* Read buffer index may be updated by writer in case of
1058 * overflow. Read and write buffer indexes must be
1059 * loaded in correct order. */
1061 if (atomic_read(&tl_stream[*stype]->wbi) != *rb_idx_raw)
1071 * kbasep_tlstream_read - copy data from streams to buffer provided by user
1072 * @filp: pointer to file structure (unused)
1073 * @buffer: pointer to the buffer provided by user
1074 * @size: maximum amount of data that can be stored in the buffer
1075 * @f_pos: pointer to file offset (unused)
1077 * Return: number of bytes stored in the buffer
1079 static ssize_t kbasep_tlstream_read(
1081 char __user *buffer,
1085 ssize_t copy_len = 0;
1087 KBASE_DEBUG_ASSERT(filp);
1088 KBASE_DEBUG_ASSERT(buffer);
1089 KBASE_DEBUG_ASSERT(f_pos);
1092 if ((0 > *f_pos) || (PACKET_SIZE > size))
1095 mutex_lock(&tl_reader_lock);
1097 while (copy_len < size) {
1098 enum tl_stream_type stype;
1099 unsigned int rb_idx_raw = 0;
1100 unsigned int rb_idx;
1103 /* If we don't have any data yet, wait for packet to be
1104 * submitted. If we already read some packets and there is no
1105 * packet pending return back to user. */
1107 if (!kbasep_tlstream_packet_pending(
1112 if (wait_event_interruptible(
1114 kbasep_tlstream_packet_pending(
1117 copy_len = -ERESTARTSYS;
1122 /* Check if this packet fits into the user buffer.
1123 * If so copy its content. */
1124 rb_idx = rb_idx_raw % PACKET_COUNT;
1125 rb_size = atomic_read(&tl_stream[stype]->buffer[rb_idx].size);
1126 if (rb_size > size - copy_len)
1130 tl_stream[stype]->buffer[rb_idx].data,
1136 /* If the rbi still points to the packet we just processed
1137 * then there was no overflow so we add the copied size to
1138 * copy_len and move rbi on to the next packet
1141 if (atomic_read(&tl_stream[stype]->rbi) == rb_idx_raw) {
1142 copy_len += rb_size;
1143 atomic_inc(&tl_stream[stype]->rbi);
1146 atomic_add(rb_size, &tlstream_bytes_collected);
1147 #endif /* MALI_UNIT_TEST */
1151 mutex_unlock(&tl_reader_lock);
1157 * kbasep_tlstream_poll - poll timeline stream for packets
1158 * @filp: pointer to file structure
1159 * @wait: pointer to poll table
1160 * Return: POLLIN if data can be read without blocking, otherwise zero
1162 static unsigned int kbasep_tlstream_poll(struct file *filp, poll_table *wait)
1164 enum tl_stream_type stream_type;
1165 unsigned int rb_idx;
1167 KBASE_DEBUG_ASSERT(filp);
1168 KBASE_DEBUG_ASSERT(wait);
1170 poll_wait(filp, &tl_event_queue, wait);
1171 if (kbasep_tlstream_packet_pending(&stream_type, &rb_idx))
1177 * kbasep_tlstream_release - release timeline stream descriptor
1178 * @inode: pointer to inode structure
1179 * @filp: pointer to file structure
1181 * Return always return zero
1183 static int kbasep_tlstream_release(struct inode *inode, struct file *filp)
1185 KBASE_DEBUG_ASSERT(inode);
1186 KBASE_DEBUG_ASSERT(filp);
1190 /* Stop autoflush timer before releasing access to streams. */
1191 atomic_set(&autoflush_timer_active, 0);
1192 del_timer_sync(&autoflush_timer);
1194 atomic_set(&kbase_tlstream_enabled, 0);
1199 * kbasep_tlstream_timeline_header - prepare timeline header stream packet
1200 * @stream_type: type of the stream that will carry header data
1201 * @tp_desc: pointer to array with tracepoint descriptors
1202 * @tp_count: number of descriptors in the given array
1204 * Functions fills in information about tracepoints stored in body stream
1205 * associated with this header stream.
1207 static void kbasep_tlstream_timeline_header(
1208 enum tl_stream_type stream_type,
1209 const struct tp_desc *tp_desc,
1212 const u8 tv = SWTRACE_VERSION; /* protocol version */
1213 const u8 ps = sizeof(void *); /* pointer size */
1214 size_t msg_size = sizeof(tv) + sizeof(ps) + sizeof(tp_count);
1217 unsigned long flags;
1220 KBASE_DEBUG_ASSERT(TL_STREAM_TYPE_COUNT > stream_type);
1221 KBASE_DEBUG_ASSERT(tp_desc);
1223 /* Calculate the size of the timeline message. */
1224 for (i = 0; i < tp_count; i++) {
1225 msg_size += sizeof(tp_desc[i].id);
1227 strnlen(tp_desc[i].id_str, STRLEN_MAX) +
1228 sizeof(char) + sizeof(u32);
1230 strnlen(tp_desc[i].name, STRLEN_MAX) +
1231 sizeof(char) + sizeof(u32);
1233 strnlen(tp_desc[i].arg_types, STRLEN_MAX) +
1234 sizeof(char) + sizeof(u32);
1236 strnlen(tp_desc[i].arg_names, STRLEN_MAX) +
1237 sizeof(char) + sizeof(u32);
1240 KBASE_DEBUG_ASSERT(PACKET_SIZE - PACKET_HEADER_SIZE >= msg_size);
1242 buffer = kbasep_tlstream_msgbuf_acquire(stream_type, msg_size, &flags);
1243 KBASE_DEBUG_ASSERT(buffer);
1245 pos = kbasep_tlstream_write_bytes(buffer, pos, &tv, sizeof(tv));
1246 pos = kbasep_tlstream_write_bytes(buffer, pos, &ps, sizeof(ps));
1247 pos = kbasep_tlstream_write_bytes(
1248 buffer, pos, &tp_count, sizeof(tp_count));
1250 for (i = 0; i < tp_count; i++) {
1251 pos = kbasep_tlstream_write_bytes(
1253 &tp_desc[i].id, sizeof(tp_desc[i].id));
1254 pos = kbasep_tlstream_write_string(
1256 tp_desc[i].id_str, msg_size - pos);
1257 pos = kbasep_tlstream_write_string(
1259 tp_desc[i].name, msg_size - pos);
1260 pos = kbasep_tlstream_write_string(
1262 tp_desc[i].arg_types, msg_size - pos);
1263 pos = kbasep_tlstream_write_string(
1265 tp_desc[i].arg_names, msg_size - pos);
1268 KBASE_DEBUG_ASSERT(msg_size == pos);
1270 kbasep_tlstream_msgbuf_release(stream_type, flags);
1272 /* We don't expect any more data to be read in this stream.
1273 * As header stream must be read before its associated body stream,
1274 * make this packet visible to the user straightaway. */
1275 kbasep_tlstream_flush_stream(stream_type);
1278 /*****************************************************************************/
1280 int kbase_tlstream_init(void)
1282 enum tl_stream_type i;
1284 /* Prepare stream structures. */
1285 for (i = 0; i < TL_STREAM_TYPE_COUNT; i++) {
1286 tl_stream[i] = kmalloc(sizeof(**tl_stream), GFP_KERNEL);
1289 kbasep_timeline_stream_init(tl_stream[i], i);
1291 if (TL_STREAM_TYPE_COUNT > i) {
1292 for (; i > 0; i--) {
1293 kbasep_timeline_stream_term(tl_stream[i - 1]);
1294 kfree(tl_stream[i - 1]);
1299 /* Initialize autoflush timer. */
1300 atomic_set(&autoflush_timer_active, 0);
1301 setup_timer(&autoflush_timer,
1302 kbasep_tlstream_autoflush_timer_callback,
1308 void kbase_tlstream_term(void)
1310 enum tl_stream_type i;
1312 for (i = 0; i < TL_STREAM_TYPE_COUNT; i++) {
1313 kbasep_timeline_stream_term(tl_stream[i]);
1314 kfree(tl_stream[i]);
1318 int kbase_tlstream_acquire(struct kbase_context *kctx, int *fd)
1320 if (0 == atomic_cmpxchg(&kbase_tlstream_enabled, 0, 1)) {
1323 *fd = anon_inode_getfd(
1325 &kbasep_tlstream_fops,
1327 O_RDONLY | O_CLOEXEC);
1329 atomic_set(&kbase_tlstream_enabled, 0);
1333 /* Reset and initialize header streams. */
1334 kbasep_timeline_stream_reset(
1335 tl_stream[TL_STREAM_TYPE_OBJ_HEADER]);
1336 kbasep_timeline_stream_reset(
1337 tl_stream[TL_STREAM_TYPE_OBJ_SUMMARY]);
1338 kbasep_timeline_stream_reset(
1339 tl_stream[TL_STREAM_TYPE_AUX_HEADER]);
1340 kbasep_tlstream_timeline_header(
1341 TL_STREAM_TYPE_OBJ_HEADER,
1343 ARRAY_SIZE(tp_desc_obj));
1344 kbasep_tlstream_timeline_header(
1345 TL_STREAM_TYPE_AUX_HEADER,
1347 ARRAY_SIZE(tp_desc_aux));
1349 /* Start autoflush timer. */
1350 atomic_set(&autoflush_timer_active, 1);
1353 jiffies + msecs_to_jiffies(AUTOFLUSH_INTERVAL));
1363 void kbase_tlstream_flush_streams(void)
1365 enum tl_stream_type stype;
1367 for (stype = 0; stype < TL_STREAM_TYPE_COUNT; stype++)
1368 kbasep_tlstream_flush_stream(stype);
1371 void kbase_tlstream_reset_body_streams(void)
1373 kbasep_timeline_stream_reset(
1374 tl_stream[TL_STREAM_TYPE_OBJ]);
1375 kbasep_timeline_stream_reset(
1376 tl_stream[TL_STREAM_TYPE_AUX]);
1380 void kbase_tlstream_stats(u32 *bytes_collected, u32 *bytes_generated)
1382 KBASE_DEBUG_ASSERT(bytes_collected);
1383 KBASE_DEBUG_ASSERT(bytes_generated);
1384 *bytes_collected = atomic_read(&tlstream_bytes_collected);
1385 *bytes_generated = atomic_read(&tlstream_bytes_generated);
1387 #endif /* MALI_UNIT_TEST */
1389 /*****************************************************************************/
1391 void __kbase_tlstream_tl_summary_new_ctx(void *context, u32 nr, u32 tgid)
1393 const u32 msg_id = KBASE_TL_NEW_CTX;
1394 const size_t msg_size =
1395 sizeof(msg_id) + sizeof(u64) + sizeof(context) + sizeof(nr) +
1397 unsigned long flags;
1401 buffer = kbasep_tlstream_msgbuf_acquire(
1402 TL_STREAM_TYPE_OBJ_SUMMARY,
1404 KBASE_DEBUG_ASSERT(buffer);
1406 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1407 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1408 pos = kbasep_tlstream_write_bytes(
1409 buffer, pos, &context, sizeof(context));
1410 pos = kbasep_tlstream_write_bytes(
1411 buffer, pos, &nr, sizeof(nr));
1412 pos = kbasep_tlstream_write_bytes(
1413 buffer, pos, &tgid, sizeof(tgid));
1415 KBASE_DEBUG_ASSERT(msg_size == pos);
1417 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ_SUMMARY, flags);
1420 void __kbase_tlstream_tl_summary_new_gpu(void *gpu, u32 id, u32 core_count)
1422 const u32 msg_id = KBASE_TL_NEW_GPU;
1423 const size_t msg_size =
1424 sizeof(msg_id) + sizeof(u64) + sizeof(gpu) + sizeof(id) +
1426 unsigned long flags;
1430 buffer = kbasep_tlstream_msgbuf_acquire(
1431 TL_STREAM_TYPE_OBJ_SUMMARY,
1433 KBASE_DEBUG_ASSERT(buffer);
1435 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1436 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1437 pos = kbasep_tlstream_write_bytes(
1438 buffer, pos, &gpu, sizeof(gpu));
1439 pos = kbasep_tlstream_write_bytes(
1440 buffer, pos, &id, sizeof(id));
1441 pos = kbasep_tlstream_write_bytes(
1442 buffer, pos, &core_count, sizeof(core_count));
1443 KBASE_DEBUG_ASSERT(msg_size == pos);
1445 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ_SUMMARY, flags);
1448 void __kbase_tlstream_tl_summary_new_lpu(void *lpu, u32 nr, u32 fn)
1450 const u32 msg_id = KBASE_TL_NEW_LPU;
1451 const size_t msg_size =
1452 sizeof(msg_id) + sizeof(u64) + sizeof(lpu) + sizeof(nr) +
1454 unsigned long flags;
1458 buffer = kbasep_tlstream_msgbuf_acquire(
1459 TL_STREAM_TYPE_OBJ_SUMMARY,
1461 KBASE_DEBUG_ASSERT(buffer);
1463 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1464 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1465 pos = kbasep_tlstream_write_bytes(
1466 buffer, pos, &lpu, sizeof(lpu));
1467 pos = kbasep_tlstream_write_bytes(
1468 buffer, pos, &nr, sizeof(nr));
1469 pos = kbasep_tlstream_write_bytes(
1470 buffer, pos, &fn, sizeof(fn));
1471 KBASE_DEBUG_ASSERT(msg_size == pos);
1473 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ_SUMMARY, flags);
1476 void __kbase_tlstream_tl_summary_lifelink_lpu_gpu(void *lpu, void *gpu)
1478 const u32 msg_id = KBASE_TL_LIFELINK_LPU_GPU;
1479 const size_t msg_size =
1480 sizeof(msg_id) + sizeof(u64) + sizeof(lpu) + sizeof(gpu);
1481 unsigned long flags;
1485 buffer = kbasep_tlstream_msgbuf_acquire(
1486 TL_STREAM_TYPE_OBJ_SUMMARY,
1488 KBASE_DEBUG_ASSERT(buffer);
1490 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1491 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1492 pos = kbasep_tlstream_write_bytes(
1493 buffer, pos, &lpu, sizeof(lpu));
1494 pos = kbasep_tlstream_write_bytes(
1495 buffer, pos, &gpu, sizeof(gpu));
1496 KBASE_DEBUG_ASSERT(msg_size == pos);
1498 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ_SUMMARY, flags);
1501 void __kbase_tlstream_tl_summary_new_as(void *as, u32 nr)
1503 const u32 msg_id = KBASE_TL_NEW_AS;
1504 const size_t msg_size =
1505 sizeof(msg_id) + sizeof(u64) + sizeof(as) + sizeof(nr);
1506 unsigned long flags;
1510 buffer = kbasep_tlstream_msgbuf_acquire(
1511 TL_STREAM_TYPE_OBJ_SUMMARY,
1513 KBASE_DEBUG_ASSERT(buffer);
1515 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1516 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1517 pos = kbasep_tlstream_write_bytes(
1518 buffer, pos, &as, sizeof(as));
1519 pos = kbasep_tlstream_write_bytes(
1520 buffer, pos, &nr, sizeof(nr));
1521 KBASE_DEBUG_ASSERT(msg_size == pos);
1523 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ_SUMMARY, flags);
1526 void __kbase_tlstream_tl_summary_lifelink_as_gpu(void *as, void *gpu)
1528 const u32 msg_id = KBASE_TL_LIFELINK_AS_GPU;
1529 const size_t msg_size =
1530 sizeof(msg_id) + sizeof(u64) + sizeof(as) + sizeof(gpu);
1531 unsigned long flags;
1535 buffer = kbasep_tlstream_msgbuf_acquire(
1536 TL_STREAM_TYPE_OBJ_SUMMARY,
1538 KBASE_DEBUG_ASSERT(buffer);
1540 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1541 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1542 pos = kbasep_tlstream_write_bytes(
1543 buffer, pos, &as, sizeof(as));
1544 pos = kbasep_tlstream_write_bytes(
1545 buffer, pos, &gpu, sizeof(gpu));
1546 KBASE_DEBUG_ASSERT(msg_size == pos);
1548 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ_SUMMARY, flags);
1551 /*****************************************************************************/
1553 void __kbase_tlstream_tl_new_ctx(void *context, u32 nr, u32 tgid)
1555 const u32 msg_id = KBASE_TL_NEW_CTX;
1556 const size_t msg_size =
1557 sizeof(msg_id) + sizeof(u64) + sizeof(context) + sizeof(nr) +
1559 unsigned long flags;
1563 buffer = kbasep_tlstream_msgbuf_acquire(
1566 KBASE_DEBUG_ASSERT(buffer);
1568 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1569 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1570 pos = kbasep_tlstream_write_bytes(
1571 buffer, pos, &context, sizeof(context));
1572 pos = kbasep_tlstream_write_bytes(
1573 buffer, pos, &nr, sizeof(nr));
1574 pos = kbasep_tlstream_write_bytes(
1575 buffer, pos, &tgid, sizeof(tgid));
1576 KBASE_DEBUG_ASSERT(msg_size == pos);
1578 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1581 void __kbase_tlstream_tl_new_atom(void *atom, u32 nr)
1583 const u32 msg_id = KBASE_TL_NEW_ATOM;
1584 const size_t msg_size =
1585 sizeof(msg_id) + sizeof(u64) + sizeof(atom) + sizeof(nr);
1586 unsigned long flags;
1590 buffer = kbasep_tlstream_msgbuf_acquire(
1593 KBASE_DEBUG_ASSERT(buffer);
1595 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1596 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1597 pos = kbasep_tlstream_write_bytes(
1598 buffer, pos, &atom, sizeof(atom));
1599 pos = kbasep_tlstream_write_bytes(
1600 buffer, pos, &nr, sizeof(nr));
1601 KBASE_DEBUG_ASSERT(msg_size == pos);
1603 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1606 void __kbase_tlstream_tl_del_ctx(void *context)
1608 const u32 msg_id = KBASE_TL_DEL_CTX;
1609 const size_t msg_size =
1610 sizeof(msg_id) + sizeof(u64) + sizeof(context);
1611 unsigned long flags;
1615 buffer = kbasep_tlstream_msgbuf_acquire(
1618 KBASE_DEBUG_ASSERT(buffer);
1620 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1621 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1622 pos = kbasep_tlstream_write_bytes(
1623 buffer, pos, &context, sizeof(context));
1624 KBASE_DEBUG_ASSERT(msg_size == pos);
1626 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1629 void __kbase_tlstream_tl_del_atom(void *atom)
1631 const u32 msg_id = KBASE_TL_DEL_ATOM;
1632 const size_t msg_size =
1633 sizeof(msg_id) + sizeof(u64) + sizeof(atom);
1634 unsigned long flags;
1638 buffer = kbasep_tlstream_msgbuf_acquire(
1641 KBASE_DEBUG_ASSERT(buffer);
1643 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1644 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1645 pos = kbasep_tlstream_write_bytes(
1646 buffer, pos, &atom, sizeof(atom));
1647 KBASE_DEBUG_ASSERT(msg_size == pos);
1649 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1652 void __kbase_tlstream_tl_ret_ctx_lpu(void *context, void *lpu)
1654 const u32 msg_id = KBASE_TL_RET_CTX_LPU;
1655 const size_t msg_size =
1656 sizeof(msg_id) + sizeof(u64) + sizeof(context) + sizeof(lpu);
1657 unsigned long flags;
1661 buffer = kbasep_tlstream_msgbuf_acquire(
1664 KBASE_DEBUG_ASSERT(buffer);
1666 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1667 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1668 pos = kbasep_tlstream_write_bytes(
1669 buffer, pos, &context, sizeof(context));
1670 pos = kbasep_tlstream_write_bytes(
1671 buffer, pos, &lpu, sizeof(lpu));
1672 KBASE_DEBUG_ASSERT(msg_size == pos);
1674 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1677 void __kbase_tlstream_tl_ret_atom_ctx(void *atom, void *context)
1679 const u32 msg_id = KBASE_TL_RET_ATOM_CTX;
1680 const size_t msg_size =
1681 sizeof(msg_id) + sizeof(u64) + sizeof(atom) + sizeof(context);
1682 unsigned long flags;
1686 buffer = kbasep_tlstream_msgbuf_acquire(
1689 KBASE_DEBUG_ASSERT(buffer);
1691 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1692 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1693 pos = kbasep_tlstream_write_bytes(
1694 buffer, pos, &atom, sizeof(atom));
1695 pos = kbasep_tlstream_write_bytes(
1696 buffer, pos, &context, sizeof(context));
1697 KBASE_DEBUG_ASSERT(msg_size == pos);
1699 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1702 void __kbase_tlstream_tl_ret_atom_lpu(
1703 void *atom, void *lpu, const char *attrib_match_list)
1705 const u32 msg_id = KBASE_TL_RET_ATOM_LPU;
1706 const size_t msg_s0 = sizeof(u32) + sizeof(char) +
1707 strnlen(attrib_match_list, STRLEN_MAX);
1708 const size_t msg_size =
1709 sizeof(msg_id) + sizeof(u64) +
1710 sizeof(atom) + sizeof(lpu) + msg_s0;
1711 unsigned long flags;
1715 buffer = kbasep_tlstream_msgbuf_acquire(
1718 KBASE_DEBUG_ASSERT(buffer);
1720 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1721 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1722 pos = kbasep_tlstream_write_bytes(
1723 buffer, pos, &atom, sizeof(atom));
1724 pos = kbasep_tlstream_write_bytes(
1725 buffer, pos, &lpu, sizeof(lpu));
1726 pos = kbasep_tlstream_write_string(
1727 buffer, pos, attrib_match_list, msg_s0);
1728 KBASE_DEBUG_ASSERT(msg_size == pos);
1730 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1733 void __kbase_tlstream_tl_nret_ctx_lpu(void *context, void *lpu)
1735 const u32 msg_id = KBASE_TL_NRET_CTX_LPU;
1736 const size_t msg_size =
1737 sizeof(msg_id) + sizeof(u64) + sizeof(context) + sizeof(lpu);
1738 unsigned long flags;
1742 buffer = kbasep_tlstream_msgbuf_acquire(
1745 KBASE_DEBUG_ASSERT(buffer);
1747 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1748 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1749 pos = kbasep_tlstream_write_bytes(
1750 buffer, pos, &context, sizeof(context));
1751 pos = kbasep_tlstream_write_bytes(
1752 buffer, pos, &lpu, sizeof(lpu));
1753 KBASE_DEBUG_ASSERT(msg_size == pos);
1755 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1758 void __kbase_tlstream_tl_nret_atom_ctx(void *atom, void *context)
1760 const u32 msg_id = KBASE_TL_NRET_ATOM_CTX;
1761 const size_t msg_size =
1762 sizeof(msg_id) + sizeof(u64) + sizeof(atom) + sizeof(context);
1763 unsigned long flags;
1767 buffer = kbasep_tlstream_msgbuf_acquire(
1770 KBASE_DEBUG_ASSERT(buffer);
1772 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1773 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1774 pos = kbasep_tlstream_write_bytes(
1775 buffer, pos, &atom, sizeof(atom));
1776 pos = kbasep_tlstream_write_bytes(
1777 buffer, pos, &context, sizeof(context));
1778 KBASE_DEBUG_ASSERT(msg_size == pos);
1780 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1783 void __kbase_tlstream_tl_dep_atom_atom(void *atom1, void *atom2)
1785 const u32 msg_id = KBASE_TL_DEP_ATOM_ATOM;
1786 const size_t msg_size =
1787 sizeof(msg_id) + sizeof(u64) + sizeof(atom1) + sizeof(atom2);
1788 unsigned long flags;
1792 buffer = kbasep_tlstream_msgbuf_acquire(
1795 KBASE_DEBUG_ASSERT(buffer);
1797 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1798 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1799 pos = kbasep_tlstream_write_bytes(
1800 buffer, pos, &atom1, sizeof(atom1));
1801 pos = kbasep_tlstream_write_bytes(
1802 buffer, pos, &atom2, sizeof(atom2));
1803 KBASE_DEBUG_ASSERT(msg_size == pos);
1805 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1808 void __kbase_tlstream_tl_ndep_atom_atom(void *atom1, void *atom2)
1810 const u32 msg_id = KBASE_TL_NDEP_ATOM_ATOM;
1811 const size_t msg_size =
1812 sizeof(msg_id) + sizeof(u64) + sizeof(atom1) + sizeof(atom2);
1813 unsigned long flags;
1817 buffer = kbasep_tlstream_msgbuf_acquire(
1820 KBASE_DEBUG_ASSERT(buffer);
1822 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1823 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1824 pos = kbasep_tlstream_write_bytes(
1825 buffer, pos, &atom1, sizeof(atom1));
1826 pos = kbasep_tlstream_write_bytes(
1827 buffer, pos, &atom2, sizeof(atom2));
1828 KBASE_DEBUG_ASSERT(msg_size == pos);
1830 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1833 void __kbase_tlstream_tl_rdep_atom_atom(void *atom1, void *atom2)
1835 const u32 msg_id = KBASE_TL_RDEP_ATOM_ATOM;
1836 const size_t msg_size =
1837 sizeof(msg_id) + sizeof(u64) + sizeof(atom1) + sizeof(atom2);
1838 unsigned long flags;
1842 buffer = kbasep_tlstream_msgbuf_acquire(
1845 KBASE_DEBUG_ASSERT(buffer);
1847 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1848 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1849 pos = kbasep_tlstream_write_bytes(
1850 buffer, pos, &atom1, sizeof(atom1));
1851 pos = kbasep_tlstream_write_bytes(
1852 buffer, pos, &atom2, sizeof(atom2));
1853 KBASE_DEBUG_ASSERT(msg_size == pos);
1855 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1858 void __kbase_tlstream_tl_nret_atom_lpu(void *atom, void *lpu)
1860 const u32 msg_id = KBASE_TL_NRET_ATOM_LPU;
1861 const size_t msg_size =
1862 sizeof(msg_id) + sizeof(u64) + sizeof(atom) + sizeof(lpu);
1863 unsigned long flags;
1867 buffer = kbasep_tlstream_msgbuf_acquire(
1870 KBASE_DEBUG_ASSERT(buffer);
1872 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1873 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1874 pos = kbasep_tlstream_write_bytes(
1875 buffer, pos, &atom, sizeof(atom));
1876 pos = kbasep_tlstream_write_bytes(
1877 buffer, pos, &lpu, sizeof(lpu));
1878 KBASE_DEBUG_ASSERT(msg_size == pos);
1880 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1883 void __kbase_tlstream_tl_ret_as_ctx(void *as, void *ctx)
1885 const u32 msg_id = KBASE_TL_RET_AS_CTX;
1886 const size_t msg_size =
1887 sizeof(msg_id) + sizeof(u64) + sizeof(as) + sizeof(ctx);
1888 unsigned long flags;
1892 buffer = kbasep_tlstream_msgbuf_acquire(
1895 KBASE_DEBUG_ASSERT(buffer);
1897 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1898 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1899 pos = kbasep_tlstream_write_bytes(
1900 buffer, pos, &as, sizeof(as));
1901 pos = kbasep_tlstream_write_bytes(
1902 buffer, pos, &ctx, sizeof(ctx));
1903 KBASE_DEBUG_ASSERT(msg_size == pos);
1905 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1908 void __kbase_tlstream_tl_nret_as_ctx(void *as, void *ctx)
1910 const u32 msg_id = KBASE_TL_NRET_AS_CTX;
1911 const size_t msg_size =
1912 sizeof(msg_id) + sizeof(u64) + sizeof(as) + sizeof(ctx);
1913 unsigned long flags;
1917 buffer = kbasep_tlstream_msgbuf_acquire(
1920 KBASE_DEBUG_ASSERT(buffer);
1922 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1923 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1924 pos = kbasep_tlstream_write_bytes(
1925 buffer, pos, &as, sizeof(as));
1926 pos = kbasep_tlstream_write_bytes(
1927 buffer, pos, &ctx, sizeof(ctx));
1928 KBASE_DEBUG_ASSERT(msg_size == pos);
1930 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1933 void __kbase_tlstream_tl_ret_atom_as(void *atom, void *as)
1935 const u32 msg_id = KBASE_TL_RET_ATOM_AS;
1936 const size_t msg_size =
1937 sizeof(msg_id) + sizeof(u64) + sizeof(atom) + sizeof(as);
1938 unsigned long flags;
1942 buffer = kbasep_tlstream_msgbuf_acquire(
1945 KBASE_DEBUG_ASSERT(buffer);
1947 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1948 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1949 pos = kbasep_tlstream_write_bytes(
1950 buffer, pos, &atom, sizeof(atom));
1951 pos = kbasep_tlstream_write_bytes(
1952 buffer, pos, &as, sizeof(as));
1953 KBASE_DEBUG_ASSERT(msg_size == pos);
1955 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1958 void __kbase_tlstream_tl_nret_atom_as(void *atom, void *as)
1960 const u32 msg_id = KBASE_TL_NRET_ATOM_AS;
1961 const size_t msg_size =
1962 sizeof(msg_id) + sizeof(u64) + sizeof(atom) + sizeof(as);
1963 unsigned long flags;
1967 buffer = kbasep_tlstream_msgbuf_acquire(
1970 KBASE_DEBUG_ASSERT(buffer);
1972 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
1973 pos = kbasep_tlstream_write_timestamp(buffer, pos);
1974 pos = kbasep_tlstream_write_bytes(
1975 buffer, pos, &atom, sizeof(atom));
1976 pos = kbasep_tlstream_write_bytes(
1977 buffer, pos, &as, sizeof(as));
1978 KBASE_DEBUG_ASSERT(msg_size == pos);
1980 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
1983 void __kbase_tlstream_tl_attrib_atom_config(
1984 void *atom, u64 jd, u64 affinity, u32 config)
1986 const u32 msg_id = KBASE_TL_ATTRIB_ATOM_CONFIG;
1987 const size_t msg_size =
1988 sizeof(msg_id) + sizeof(u64) + sizeof(atom) +
1989 sizeof(jd) + sizeof(affinity) + sizeof(config);
1990 unsigned long flags;
1994 buffer = kbasep_tlstream_msgbuf_acquire(
1997 KBASE_DEBUG_ASSERT(buffer);
1999 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
2000 pos = kbasep_tlstream_write_timestamp(buffer, pos);
2001 pos = kbasep_tlstream_write_bytes(
2002 buffer, pos, &atom, sizeof(atom));
2003 pos = kbasep_tlstream_write_bytes(
2004 buffer, pos, &jd, sizeof(jd));
2005 pos = kbasep_tlstream_write_bytes(
2006 buffer, pos, &affinity, sizeof(affinity));
2007 pos = kbasep_tlstream_write_bytes(
2008 buffer, pos, &config, sizeof(config));
2009 KBASE_DEBUG_ASSERT(msg_size == pos);
2011 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
2014 void __kbase_tlstream_tl_attrib_as_config(
2015 void *as, u64 transtab, u64 memattr, u64 transcfg)
2017 const u32 msg_id = KBASE_TL_ATTRIB_AS_CONFIG;
2018 const size_t msg_size =
2019 sizeof(msg_id) + sizeof(u64) + sizeof(as) +
2020 sizeof(transtab) + sizeof(memattr) + sizeof(transcfg);
2021 unsigned long flags;
2025 buffer = kbasep_tlstream_msgbuf_acquire(
2028 KBASE_DEBUG_ASSERT(buffer);
2030 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
2031 pos = kbasep_tlstream_write_timestamp(buffer, pos);
2032 pos = kbasep_tlstream_write_bytes(
2033 buffer, pos, &as, sizeof(as));
2034 pos = kbasep_tlstream_write_bytes(
2035 buffer, pos, &transtab, sizeof(transtab));
2036 pos = kbasep_tlstream_write_bytes(
2037 buffer, pos, &memattr, sizeof(memattr));
2038 pos = kbasep_tlstream_write_bytes(
2039 buffer, pos, &transcfg, sizeof(transcfg));
2040 KBASE_DEBUG_ASSERT(msg_size == pos);
2042 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
2045 void __kbase_tlstream_jd_gpu_soft_reset(void *gpu)
2047 const u32 msg_id = KBASE_JD_GPU_SOFT_RESET;
2048 const size_t msg_size =
2049 sizeof(msg_id) + sizeof(u64) + sizeof(gpu);
2050 unsigned long flags;
2054 buffer = kbasep_tlstream_msgbuf_acquire(
2057 KBASE_DEBUG_ASSERT(buffer);
2059 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
2060 pos = kbasep_tlstream_write_timestamp(buffer, pos);
2061 pos = kbasep_tlstream_write_bytes(
2062 buffer, pos, &gpu, sizeof(gpu));
2063 KBASE_DEBUG_ASSERT(msg_size == pos);
2065 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_OBJ, flags);
2068 /*****************************************************************************/
2070 void __kbase_tlstream_aux_pm_state(u32 core_type, u64 state)
2072 const u32 msg_id = KBASE_AUX_PM_STATE;
2073 const size_t msg_size =
2074 sizeof(msg_id) + sizeof(u64) + sizeof(core_type) +
2076 unsigned long flags;
2080 buffer = kbasep_tlstream_msgbuf_acquire(
2083 KBASE_DEBUG_ASSERT(buffer);
2085 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
2086 pos = kbasep_tlstream_write_timestamp(buffer, pos);
2087 pos = kbasep_tlstream_write_bytes(
2088 buffer, pos, &core_type, sizeof(core_type));
2089 pos = kbasep_tlstream_write_bytes(buffer, pos, &state, sizeof(state));
2090 KBASE_DEBUG_ASSERT(msg_size == pos);
2092 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_AUX, flags);
2095 void __kbase_tlstream_aux_issue_job_softstop(void *katom)
2097 const u32 msg_id = KBASE_AUX_ISSUE_JOB_SOFTSTOP;
2098 const size_t msg_size =
2099 sizeof(msg_id) + sizeof(u64) + sizeof(katom);
2100 unsigned long flags;
2104 buffer = kbasep_tlstream_msgbuf_acquire(
2105 TL_STREAM_TYPE_AUX, msg_size, &flags);
2106 KBASE_DEBUG_ASSERT(buffer);
2108 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
2109 pos = kbasep_tlstream_write_timestamp(buffer, pos);
2110 pos = kbasep_tlstream_write_bytes(buffer, pos, &katom, sizeof(katom));
2111 KBASE_DEBUG_ASSERT(msg_size == pos);
2113 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_AUX, flags);
2116 void __kbase_tlstream_aux_job_softstop(u32 js_id)
2118 const u32 msg_id = KBASE_AUX_JOB_SOFTSTOP;
2119 const size_t msg_size =
2120 sizeof(msg_id) + sizeof(u64) + sizeof(js_id);
2121 unsigned long flags;
2125 buffer = kbasep_tlstream_msgbuf_acquire(
2128 KBASE_DEBUG_ASSERT(buffer);
2130 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
2131 pos = kbasep_tlstream_write_timestamp(buffer, pos);
2132 pos = kbasep_tlstream_write_bytes(buffer, pos, &js_id, sizeof(js_id));
2133 KBASE_DEBUG_ASSERT(msg_size == pos);
2135 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_AUX, flags);
2139 * __kbase_tlstream_aux_job_softstop_ex_record - record the trace point
2140 * @katom: the atom that has been soft-stopped
2141 * @job_type: the job type
2143 static void __kbase_tlstream_aux_job_softstop_ex_record(
2144 void *katom, u32 job_type)
2146 const u32 msg_id = KBASE_AUX_JOB_SOFTSTOP_EX;
2147 const size_t msg_size =
2148 sizeof(msg_id) + sizeof(u64) + sizeof(katom) + sizeof(job_type);
2149 unsigned long flags;
2153 buffer = kbasep_tlstream_msgbuf_acquire(
2154 TL_STREAM_TYPE_AUX, msg_size, &flags);
2155 KBASE_DEBUG_ASSERT(buffer);
2157 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
2158 pos = kbasep_tlstream_write_timestamp(buffer, pos);
2159 pos = kbasep_tlstream_write_bytes(buffer, pos, &katom, sizeof(katom));
2160 pos = kbasep_tlstream_write_bytes(
2161 buffer, pos, &job_type, sizeof(job_type));
2162 KBASE_DEBUG_ASSERT(msg_size == pos);
2164 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_AUX, flags);
2167 void __kbase_tlstream_aux_job_softstop_ex(struct kbase_jd_atom *katom)
2169 struct kbase_context *kctx = katom->kctx;
2173 struct job_descriptor_header *job;
2174 struct kbase_vmap_struct map;
2176 job = kbase_vmap(kctx, jd, sizeof(*job), &map);
2178 dev_err(kctx->kbdev->dev,
2179 "__kbase_tlstream_aux_job_softstop_ex: failed to map job descriptor 0x%llx for atom 0x%p\n",
2183 if (job->exception_status != BASE_JD_EVENT_STOPPED) {
2184 kbase_vunmap(kctx, &map);
2188 __kbase_tlstream_aux_job_softstop_ex_record(
2189 katom, job->job_type);
2191 jd = job->job_descriptor_size ?
2192 job->next_job._64 : job->next_job._32;
2193 kbase_vunmap(kctx, &map);
2197 void __kbase_tlstream_aux_pagefault(u32 ctx_nr, u64 page_count_change)
2199 const u32 msg_id = KBASE_AUX_PAGEFAULT;
2200 const size_t msg_size =
2201 sizeof(msg_id) + sizeof(u64) + sizeof(ctx_nr) +
2202 sizeof(page_count_change);
2203 unsigned long flags;
2207 buffer = kbasep_tlstream_msgbuf_acquire(
2208 TL_STREAM_TYPE_AUX, msg_size, &flags);
2209 KBASE_DEBUG_ASSERT(buffer);
2211 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
2212 pos = kbasep_tlstream_write_timestamp(buffer, pos);
2213 pos = kbasep_tlstream_write_bytes(buffer, pos, &ctx_nr, sizeof(ctx_nr));
2214 pos = kbasep_tlstream_write_bytes(
2216 &page_count_change, sizeof(page_count_change));
2217 KBASE_DEBUG_ASSERT(msg_size == pos);
2219 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_AUX, flags);
2222 void __kbase_tlstream_aux_pagesalloc(u32 ctx_nr, u64 page_count)
2224 const u32 msg_id = KBASE_AUX_PAGESALLOC;
2225 const size_t msg_size =
2226 sizeof(msg_id) + sizeof(u64) + sizeof(ctx_nr) +
2228 unsigned long flags;
2232 buffer = kbasep_tlstream_msgbuf_acquire(
2233 TL_STREAM_TYPE_AUX, msg_size, &flags);
2234 KBASE_DEBUG_ASSERT(buffer);
2236 pos = kbasep_tlstream_write_bytes(buffer, pos, &msg_id, sizeof(msg_id));
2237 pos = kbasep_tlstream_write_timestamp(buffer, pos);
2238 pos = kbasep_tlstream_write_bytes(buffer, pos, &ctx_nr, sizeof(ctx_nr));
2239 pos = kbasep_tlstream_write_bytes(
2240 buffer, pos, &page_count, sizeof(page_count));
2241 KBASE_DEBUG_ASSERT(msg_size == pos);
2243 kbasep_tlstream_msgbuf_release(TL_STREAM_TYPE_AUX, flags);