diff --git a/sw/snRuntime/src/dma.h b/sw/snRuntime/src/dma.h index 29d5d226c..79b009d33 100644 --- a/sw/snRuntime/src/dma.h +++ b/sw/snRuntime/src/dma.h @@ -51,7 +51,7 @@ inline snrt_dma_txid_t snrt_dma_start_1d_wideptr(uint64_t dst, uint64_t src, return reg_txid; } else { - return -1; + return 0; } } @@ -129,7 +129,7 @@ inline snrt_dma_txid_t snrt_dma_start_2d_wideptr(uint64_t dst, uint64_t src, return reg_txid; } else { - return -1; + return 0; } } diff --git a/sw/tests/dma_empty_transfer.c b/sw/tests/dma_empty_transfer.c new file mode 100644 index 000000000..5c1a13238 --- /dev/null +++ b/sw/tests/dma_empty_transfer.c @@ -0,0 +1,25 @@ +// Copyright 2020 ETH Zurich and University of Bologna. +// Licensed under the Apache License, Version 2.0, see LICENSE for details. +// SPDX-License-Identifier: Apache-2.0 + +#include + +// Allocate a buffer in the main memory which we will use to copy data around +// with the DMA. +uint32_t buffer[32]; + +int main() { + if (snrt_global_core_idx() != 8) return 0; // only DMA core + + // Populate source buffer. + uint32_t buffer_src[32]; + for (uint32_t i = 0; i < 32; i++) { + buffer_src[i] = i + 1; + } + + // Start a DMA transfer of zero size. + snrt_dma_txid_t id = snrt_dma_start_1d(buffer, buffer_src, 0); + snrt_dma_wait(id); + + // Test is successful if the previous transfer doesn't block. +} diff --git a/target/snitch_cluster/sw/run.yaml b/target/snitch_cluster/sw/run.yaml index 3842e3e70..188a8a1c5 100644 --- a/target/snitch_cluster/sw/run.yaml +++ b/target/snitch_cluster/sw/run.yaml @@ -9,6 +9,7 @@ runs: simulators: [vsim, vcs, verilator] # banshee fails with exit code 0x4 - elf: tests/build/barrier.elf - elf: tests/build/data_mover.elf + - elf: tests/build/dma_empty_transfer.elf - elf: tests/build/dma_simple.elf - elf: tests/build/event_unit.elf - elf: tests/build/fence_i.elf