diff options
Diffstat (limited to 'dvalin/kernel/drivers/gpu/arm/midgard/tl/mali_kbase_tlstream.c')
-rw-r--r-- | dvalin/kernel/drivers/gpu/arm/midgard/tl/mali_kbase_tlstream.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/dvalin/kernel/drivers/gpu/arm/midgard/tl/mali_kbase_tlstream.c b/dvalin/kernel/drivers/gpu/arm/midgard/tl/mali_kbase_tlstream.c index bec4be7..0275bad 100644 --- a/dvalin/kernel/drivers/gpu/arm/midgard/tl/mali_kbase_tlstream.c +++ b/dvalin/kernel/drivers/gpu/arm/midgard/tl/mali_kbase_tlstream.c @@ -1,11 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note /* * - * (C) COPYRIGHT 2015-2020 ARM Limited. All rights reserved. + * (C) COPYRIGHT 2015-2021 ARM Limited. All rights reserved. * * This program is free software and is provided to you under the terms of the * GNU General Public License version 2 as published by the Free Software * Foundation, and any use by you of this program is subject to the terms - * of such GNU licence. + * of such GNU license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -16,8 +17,6 @@ * along with this program; if not, you can access it online at * http://www.gnu.org/licenses/gpl-2.0.html. * - * SPDX-License-Identifier: GPL-2.0 - * */ #include "mali_kbase_tlstream.h" @@ -57,20 +56,19 @@ static void kbasep_packet_header_setup( * @numbered: non-zero if the stream is numbered * * Function updates mutable part of packet header in the given buffer. - * Note that value of data_size must not including size of the header. + * Note that value of data_size must not include size of the header. */ static void kbasep_packet_header_update( char *buffer, size_t data_size, int numbered) { - u32 word0; u32 word1 = MIPE_PACKET_HEADER_W1((u32)data_size, !!numbered); KBASE_DEBUG_ASSERT(buffer); - CSTD_UNUSED(word0); - memcpy(&buffer[sizeof(word0)], &word1, sizeof(word1)); + /* we copy the contents of word1 to its respective position in the buffer */ + memcpy(&buffer[sizeof(u32)], &word1, sizeof(word1)); } /** @@ -131,6 +129,14 @@ static const struct { TL_PACKET_TYPE_BODY, TL_STREAM_ID_KERNEL, }, +#if MALI_USE_CSF + { + TL_PACKET_FAMILY_TL, + TL_PACKET_CLASS_OBJ, + TL_PACKET_TYPE_BODY, + TL_STREAM_ID_CSFFW, + }, +#endif }; void kbase_tlstream_init( @@ -141,12 +147,12 @@ void kbase_tlstream_init( unsigned int i; KBASE_DEBUG_ASSERT(stream); - KBASE_DEBUG_ASSERT(TL_STREAM_TYPE_COUNT > stream_type); + KBASE_DEBUG_ASSERT(stream_type < TL_STREAM_TYPE_COUNT); spin_lock_init(&stream->lock); /* All packets carrying tracepoints shall be numbered. */ - if (TL_PACKET_TYPE_BODY == tl_stream_cfg[stream_type].pkt_type) + if (tl_stream_cfg[stream_type].pkt_type == TL_PACKET_TYPE_BODY) stream->numbered = 1; else stream->numbered = 0; @@ -209,7 +215,8 @@ static size_t kbasep_tlstream_msgbuf_submit( /* Increasing write buffer index will expose this packet to the reader. * As stream->lock is not taken on reader side we must make sure memory - * is updated correctly before this will happen. */ + * is updated correctly before this will happen. + */ smp_wmb(); atomic_inc(&stream->wbi); @@ -243,7 +250,7 @@ char *kbase_tlstream_msgbuf_acquire( wb_size = atomic_read(&stream->buffer[wb_idx].size); /* Select next buffer if data will not fit into current one. */ - if (PACKET_SIZE < wb_size + msg_size) { + if (wb_size + msg_size > PACKET_SIZE) { wb_size = kbasep_tlstream_msgbuf_submit( stream, wb_idx_raw, wb_size); wb_idx = (wb_idx_raw + 1) % PACKET_COUNT; @@ -269,7 +276,7 @@ void kbase_tlstream_msgbuf_release( spin_unlock_irqrestore(&stream->lock, flags); } -void kbase_tlstream_flush_stream( +size_t kbase_tlstream_flush_stream( struct kbase_tlstream *stream) { unsigned long flags; @@ -278,6 +285,7 @@ void kbase_tlstream_flush_stream( size_t wb_size; size_t min_size = PACKET_HEADER_SIZE; + if (stream->numbered) min_size += PACKET_NUMBER_SIZE; @@ -292,7 +300,14 @@ void kbase_tlstream_flush_stream( stream, wb_idx_raw, wb_size); wb_idx = (wb_idx_raw + 1) % PACKET_COUNT; atomic_set(&stream->buffer[wb_idx].size, wb_size); + } else { + /* we return that there is no bytes to be read.*/ + /* Timeline io fsync will use this info the decide whether + * fsync should return an error + */ + wb_size = 0; } + spin_unlock_irqrestore(&stream->lock, flags); + return wb_size; } - |