1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

dma: throw exception in makeAccesibleFromVA instead of returning bool

This commit is contained in:
Steffen Vogel 2022-10-28 08:16:58 -04:00
parent ab994f2c87
commit 7e0848b7d5
4 changed files with 12 additions and 21 deletions

View file

@ -57,7 +57,7 @@ public:
bool memcpy(const MemoryBlock &src, const MemoryBlock &dst, size_t len);
bool makeAccesibleFromVA(const MemoryBlock &mem);
void makeAccesibleFromVA(const MemoryBlock &mem);
bool makeInaccesibleFromVA(const MemoryBlock &mem);
inline bool

View file

@ -460,28 +460,22 @@ Dma::readCompleteSimple()
return bytesRead;
}
bool
void
Dma::makeAccesibleFromVA(const MemoryBlock &mem)
{
// Only symmetric mapping supported currently
if (isMemoryBlockAccesible(mem, s2mmInterface) and
isMemoryBlockAccesible(mem, mm2sInterface))
return true;
return;
// Try mapping via FPGA-card (VFIO)
if (not card->mapMemoryBlock(mem)) {
logger->error("Memory not accessible by DMA");
return false;
}
if (not card->mapMemoryBlock(mem))
throw RuntimeError("Memory not accessible by DMA");
// Sanity-check if mapping worked, this shouldn't be neccessary
if (not isMemoryBlockAccesible(mem, s2mmInterface) or
not isMemoryBlockAccesible(mem, mm2sInterface)) {
logger->error("Mapping memory via card didn't work, but reported success?!");
return false;
}
return true;
not isMemoryBlockAccesible(mem, mm2sInterface))
throw RuntimeError("Mapping memory via card didn't work, but reported success?!");
}
bool

View file

@ -82,10 +82,8 @@ Test(fpga, dma, .description = "DMA")
auto dst = HostRam::getAllocator().allocate<char>(len);
#endif
// Make sure memory is accessible for DMA
cr_assert(dma->makeAccesibleFromVA(src.getMemoryBlock()),
"Source memory not accessible for DMA");
cr_assert(dma->makeAccesibleFromVA(dst.getMemoryBlock()),
"Destination memory not accessible for DMA");
dma->makeAccesibleFromVA(src.getMemoryBlock());
dma->makeAccesibleFromVA(dst.getMemoryBlock());
// Get new random data
const size_t lenRandom = utils::readRandom(&src, len);

View file

@ -119,10 +119,9 @@ Test(fpga, gpu_dma, .description = "GPU DMA tests")
if (dma != nullptr and dma->connectLoopback()) {
memcpyFuncs.push_back({
"DMA memcpy", [&]() {
if (not dma->makeAccesibleFromVA(src.getMemoryBlock()) or
not dma->makeAccesibleFromVA(dst.getMemoryBlock())) {
return;
}
dma->makeAccesibleFromVA(src.getMemoryBlock());
dma->makeAccesibleFromVA(dst.getMemoryBlock()));
dma->memcpy(src.getMemoryBlock(), dst.getMemoryBlock(), len);
}});
}