@@ -56,13 +56,6 @@ static uint64_t trace_work(void *data, uint64_t delay)
5656 int32_t size ;
5757 uint32_t overflow ;
5858
59- /* any data to copy ? */
60- if (avail == 0 )
61- return DMA_TRACE_PERIOD ;
62-
63- /* DMA trace copying is working */
64- d -> copy_in_progress = 1 ;
65-
6659 /* make sure we don't write more than buffer */
6760 if (avail > DMA_TRACE_LOCAL_SIZE ) {
6861 overflow = avail - DMA_TRACE_LOCAL_SIZE ;
@@ -75,8 +68,15 @@ static uint64_t trace_work(void *data, uint64_t delay)
7568 /* support, so do it differently based on HW features */
7669 size = dma_trace_get_avali_data (d , buffer , avail );
7770
71+ /* any data to copy ? */
72+ if (size == 0 )
73+ return DMA_TRACE_PERIOD ;
74+
7875 d -> overflow = overflow ;
7976
77+ /* DMA trace copying is working */
78+ d -> copy_in_progress = 1 ;
79+
8080 /* copy this section to host */
8181 size = dma_copy_to_host_nowait (& d -> dc , config , d -> host_offset ,
8282 buffer -> r_ptr , size );
@@ -258,6 +258,9 @@ static int dma_trace_get_avali_data(struct dma_trace_data *d,
258258 d -> old_host_offset = d -> host_offset ;
259259 }
260260
261+ if (avail == 0 )
262+ return 0 ;
263+
261264 /* writeback trace data */
262265 if (buffer -> r_ptr + avail <= buffer -> end_addr ) {
263266 dcache_writeback_region ((void * )buffer -> r_ptr , avail );
@@ -284,6 +287,9 @@ static int dma_trace_get_avali_data(struct dma_trace_data *d,
284287 lsize = avail ;
285288 hsize = avail ;
286289
290+ if (avail == 0 )
291+ return 0 ;
292+
287293 /* host buffer wrap ? */
288294 if (d -> host_offset + avail > d -> host_size )
289295 hsize = d -> host_size - d -> host_offset ;
0 commit comments