Commit 5545419e authored by Federico Vaga's avatar Federico Vaga

tst: DMA read throughput test

Signed-off-by: Federico Vaga's avatarFederico Vaga <>
parent 01547b49
......@@ -5,6 +5,8 @@ SPDX-FileCopyrightText: 2020 CERN
import pytest
import random
import math
import os
import re
from PySPEC import PySPEC
random_repetitions = 0
......@@ -224,3 +226,43 @@ class TestDma(object):
assert data[0:4] ==, 4)
except OSError as error:
assert False, "Failed after {:d} transfers".format(i)
[2**20 * x for x in range(1, 5)])
def test_dma_throughput_read(self, spec, dma_alloc_size):
It roughly measure read throughput by using the kernel
tracer. It does a simple avarage of 100 acquisitions.
A safe expectation today is 230MBps
tracing_path = "/sys/kernel/debug/tracing"
with open(os.path.join(tracing_path, "current_tracer"), "w") as f:
with open(os.path.join(tracing_path, "set_ftrace_filter"), "w") as f:
with open(os.path.join(tracing_path, "trace"), "w") as f:
diff = []
for i in range(100):
with open(os.path.join(tracing_path, "trace"), "w") as f:
with spec.dma(dma_alloc_size) as dma:
data =, dma_alloc_size)
assert len(data) == dma_alloc_size
with open(os.path.join(tracing_path, "trace"), "r") as f:
trace =
start ="([0-9]+\.[0-9]{6}): gn412x_dma_start_task", trace, re.MULTILINE)
assert start is not None, trace
assert len(start.groups()) == 1
end ="([0-9]+\.[0-9]{6}): gn412x_dma_irq_handler", trace, re.MULTILINE)
assert end is not None, trace
assert len(end.groups()) == 1
diff.append(float( - float(
assert diff[-1] > 0
throughput_m = int((dma_alloc_size / (round(math.fsum(diff) / 100, 6))) / 1024 / 1024)
assert throughput_m > 230, \
"Expected mora than {:d} MBps, got {:d} MBps".format(500,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment