From b0ccbddc6f40b534429729ef976ec0af8f1df753 Mon Sep 17 00:00:00 2001 From: Niklas Eiling Date: Sat, 10 Feb 2024 16:20:31 +0100 Subject: [PATCH] card: call stop on all ips when destructor is called Signed-off-by: Niklas Eiling --- fpga/lib/card.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/fpga/lib/card.cpp b/fpga/lib/card.cpp index 7bd8dc38c..549d9ffed 100644 --- a/fpga/lib/card.cpp +++ b/fpga/lib/card.cpp @@ -15,21 +15,25 @@ using namespace villas::fpga; Card::~Card() { - // Ensure IP destructors are called before memory is unmapped - ips.clear(); + for (auto ip = ips.rbegin(); ip != ips.rend(); ++ip){ + (*ip)->stop(); + } + // Ensure IP destructors are called before memory is unmapped + ips.clear(); - auto &mm = MemoryManager::get(); + auto &mm = MemoryManager::get(); - // Unmap all memory blocks - for (auto &mappedMemoryBlock : memoryBlocksMapped) { - auto translation = mm.getTranslation(addrSpaceIdDeviceToHost, mappedMemoryBlock.first); + // Unmap all memory blocks + for (auto &mappedMemoryBlock : memoryBlocksMapped) { + auto translation = + mm.getTranslation(addrSpaceIdDeviceToHost, mappedMemoryBlock.first); - const uintptr_t iova = translation.getLocalAddr(0); - const size_t size = translation.getSize(); + const uintptr_t iova = translation.getLocalAddr(0); + const size_t size = translation.getSize(); - logger->debug("Unmap block {} at IOVA {:#x} of size {:#x}", - mappedMemoryBlock.first, iova, size); - vfioContainer->memoryUnmap(iova, size); + logger->debug("Unmap block {} at IOVA {:#x} of size {:#x}", + mappedMemoryBlock.first, iova, size); + vfioContainer->memoryUnmap(iova, size); } }