From 4808092e3ae50328dfb29dccfdea4866a41b41ea Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Thu, 8 Dec 2022 16:28:18 +0100 Subject: [PATCH 01/16] exclude thirdparty gpu Signed-off-by: Pascal Bauer --- fpga/.gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/fpga/.gitlab-ci.yml b/fpga/.gitlab-ci.yml index c57867823..b3d82d542 100644 --- a/fpga/.gitlab-ci.yml +++ b/fpga/.gitlab-ci.yml @@ -73,6 +73,7 @@ test:cppcheck: src/ lib/ tests/unit/ | tee cppcheck.log + -igpu/thirdparty image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV} dependencies: - build:source From 65a9a85456bb3f6c5c6dfe2df692960d71faac94 Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Thu, 8 Dec 2022 16:31:29 +0100 Subject: [PATCH 02/16] fixed pipe before parameter Signed-off-by: Pascal Bauer --- fpga/.gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fpga/.gitlab-ci.yml b/fpga/.gitlab-ci.yml index b3d82d542..1b7b7dbe1 100644 --- a/fpga/.gitlab-ci.yml +++ b/fpga/.gitlab-ci.yml @@ -72,8 +72,8 @@ test:cppcheck: gpu/ src/ lib/ - tests/unit/ | tee cppcheck.log - -igpu/thirdparty + tests/unit/ + -igpu/thirdparty | tee cppcheck.log image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV} dependencies: - build:source From 6a8acc467b3e3aa954ffd1f8296f900fd8dea2cc Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Thu, 8 Dec 2022 13:01:20 +0100 Subject: [PATCH 03/16] changed casting from intmax to uintmax Signed-off-by: Pascal Bauer --- fpga/src/pcimem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fpga/src/pcimem.c b/fpga/src/pcimem.c index 8c3814667..1f281abf9 100644 --- a/fpga/src/pcimem.c +++ b/fpga/src/pcimem.c @@ -75,14 +75,14 @@ int main(int argc, char **argv) { PRINT_ERROR; printf("%s opened.\n", filename); - printf("Target offset is %#jx, page size is %lu\n", (intmax_t) target, sysconf(_SC_PAGE_SIZE)); + printf("Target offset is %#jx, page size is %lu\n", (uintmax_t) target, sysconf(_SC_PAGE_SIZE)); fflush(stdout); // Map one page printf("mmap(%d, %lu, %#x, %#x, %d, %#jx)\n", 0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, - fd, (intmax_t) target); + fd, (uintmax_t) target); map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, target & ~MAP_MASK); @@ -109,7 +109,7 @@ int main(int argc, char **argv) { exit(2); } - printf("Value at offset %#jx (%p): %#x\n", (intmax_t) target, virt_addr, read_result); + printf("Value at offset %#jx (%p): %#x\n", (uintmax_t) target, virt_addr, read_result); fflush(stdout); if (argc > 4) { From a2b8b2942ed0f863b3275e82b24b078d0b41638d Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Fri, 9 Dec 2022 12:43:49 +0100 Subject: [PATCH 04/16] fixed memory leak (missing deletes before return) Signed-off-by: Pascal Bauer --- fpga/lib/ips/emc.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/fpga/lib/ips/emc.cpp b/fpga/lib/ips/emc.cpp index 62d4a3cfb..6b0ccf2fb 100644 --- a/fpga/lib/ips/emc.cpp +++ b/fpga/lib/ips/emc.cpp @@ -118,8 +118,10 @@ EMC::flash(uint32_t offset, uint32_t length, uint8_t *data) /* Reset the Flash Device. This clears the ret registers and puts * the device in Read mode. */ ret = XFlash_Reset(&xflash); - if (ret != XST_SUCCESS) + if (ret != XST_SUCCESS){ + delete[] verify_data; return false; + } /* Perform an unlock operation before the erase operation for the Intel * Flash. The erase operation will result in an error if the block is @@ -128,30 +130,39 @@ EMC::flash(uint32_t offset, uint32_t length, uint8_t *data) (xflash.CommandSet == XFL_CMDSET_INTEL_EXTENDED) || (xflash.CommandSet == XFL_CMDSET_INTEL_G18)) { ret = XFlash_Unlock(&xflash, offset, 0); - if(ret != XST_SUCCESS) + if(ret != XST_SUCCESS){ + delete[] verify_data; return false; + } } // Perform the Erase operation. ret = XFlash_Erase(&xflash, start, length); - if (ret != XST_SUCCESS) + if (ret != XST_SUCCESS){ + delete[] verify_data; return false; + } // Perform the Write operation. ret = XFlash_Write(&xflash, start, length, data); - if (ret != XST_SUCCESS) + if (ret != XST_SUCCESS){ + delete[] verify_data; return false; + } // Perform the read operation. ret = XFlash_Read(&xflash, start, length, verify_data); if(ret != XST_SUCCESS) { + delete[] verify_data; return false; } // Compare the data read against the data Written. for (unsigned i = 0; i < length; i++) { - if (verify_data[i] != data[i]) + if (verify_data[i] != data[i]){ + delete[] verify_data; return false; + } } delete[] verify_data; From 00fa5094f9be1c260c9d07d03575b64fe17ea22b Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Fri, 9 Dec 2022 12:54:28 +0100 Subject: [PATCH 05/16] pass constructor parameter as const ref for performance Signed-off-by: Pascal Bauer --- fpga/include/villas/fpga/vlnv.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpga/include/villas/fpga/vlnv.hpp b/fpga/include/villas/fpga/vlnv.hpp index ac865201d..0f6d1a752 100644 --- a/fpga/include/villas/fpga/vlnv.hpp +++ b/fpga/include/villas/fpga/vlnv.hpp @@ -41,7 +41,7 @@ public: version("") { } - Vlnv(std::string s) + Vlnv(const std::string &s) { parseFromString(s); } From 327f343924ccc3d8dcb80f629dfe5b408530b70a Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Fri, 9 Dec 2022 12:57:32 +0100 Subject: [PATCH 06/16] changed parameters to const refs Signed-off-by: Pascal Bauer --- fpga/include/villas/fpga/core.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fpga/include/villas/fpga/core.hpp b/fpga/include/villas/fpga/core.hpp index 43c0cbe1e..9614d5f35 100644 --- a/fpga/include/villas/fpga/core.hpp +++ b/fpga/include/villas/fpga/core.hpp @@ -54,12 +54,12 @@ class InterruptController; class IpIdentifier { public: - IpIdentifier(Vlnv vlnv = Vlnv::getWildcard(), std::string name = "") : + IpIdentifier(const Vlnv &vlnv = Vlnv::getWildcard(), const std::string &name = "") : vlnv(vlnv), name(name) { } - IpIdentifier(std::string vlnvString, std::string name = "") : + IpIdentifier(const std::string &vlnvString, const std::string &name = "") : vlnv(vlnvString), name(name) { } From c77d124682741144955e4a81c01df11c9d8f9bbc Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Fri, 9 Dec 2022 13:03:34 +0100 Subject: [PATCH 07/16] fixed allocation order Signed-off-by: Pascal Bauer --- fpga/lib/ips/emc.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/fpga/lib/ips/emc.cpp b/fpga/lib/ips/emc.cpp index 6b0ccf2fb..c4eeabba5 100644 --- a/fpga/lib/ips/emc.cpp +++ b/fpga/lib/ips/emc.cpp @@ -113,13 +113,10 @@ EMC::flash(uint32_t offset, uint32_t length, uint8_t *data) int ret = XST_FAILURE; uint32_t start = offset; - uint8_t *verify_data = new uint8_t[length]; - /* Reset the Flash Device. This clears the ret registers and puts * the device in Read mode. */ ret = XFlash_Reset(&xflash); if (ret != XST_SUCCESS){ - delete[] verify_data; return false; } @@ -131,26 +128,24 @@ EMC::flash(uint32_t offset, uint32_t length, uint8_t *data) (xflash.CommandSet == XFL_CMDSET_INTEL_G18)) { ret = XFlash_Unlock(&xflash, offset, 0); if(ret != XST_SUCCESS){ - delete[] verify_data; return false; } } // Perform the Erase operation. ret = XFlash_Erase(&xflash, start, length); - if (ret != XST_SUCCESS){ - delete[] verify_data; + if (ret != XST_SUCCESS){; return false; } // Perform the Write operation. ret = XFlash_Write(&xflash, start, length, data); if (ret != XST_SUCCESS){ - delete[] verify_data; return false; } // Perform the read operation. + uint8_t *verify_data = new uint8_t[length]; ret = XFlash_Read(&xflash, start, length, verify_data); if(ret != XST_SUCCESS) { delete[] verify_data; From 0644f1310d7ad80162f709099d05ee36a1915074 Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Fri, 9 Dec 2022 13:15:50 +0100 Subject: [PATCH 08/16] removed empty brackets Signed-off-by: Pascal Bauer --- fpga/tests/unit/gpu.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fpga/tests/unit/gpu.cpp b/fpga/tests/unit/gpu.cpp index 4a7087274..aaa0c9e5c 100644 --- a/fpga/tests/unit/gpu.cpp +++ b/fpga/tests/unit/gpu.cpp @@ -118,11 +118,10 @@ Test(fpga, gpu_dma, .description = "GPU DMA tests") if (dma != nullptr and dma->connectLoopback()) { memcpyFuncs.push_back({ - "DMA memcpy", [&]() { + "DMA memcpy", [&] { dma->makeAccesibleFromVA(src.getMemoryBlock()); dma->makeAccesibleFromVA(dst.getMemoryBlock())); - - dma->memcpy(src.getMemoryBlock(), dst.getMemoryBlock(), len); + dma->memcpy(src.getMemoryBlock(), dst.getMemoryBlock(), len); }}); } From 3840fa1fa6afab48638d89a79e46cf9d04248af3 Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Fri, 9 Dec 2022 14:03:41 +0100 Subject: [PATCH 09/16] removed unnecessary closing bracket Signed-off-by: Pascal Bauer --- fpga/tests/unit/gpu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fpga/tests/unit/gpu.cpp b/fpga/tests/unit/gpu.cpp index aaa0c9e5c..a8a3a37b2 100644 --- a/fpga/tests/unit/gpu.cpp +++ b/fpga/tests/unit/gpu.cpp @@ -118,9 +118,9 @@ Test(fpga, gpu_dma, .description = "GPU DMA tests") if (dma != nullptr and dma->connectLoopback()) { memcpyFuncs.push_back({ - "DMA memcpy", [&] { + "DMA memcpy", [&] (){ dma->makeAccesibleFromVA(src.getMemoryBlock()); - dma->makeAccesibleFromVA(dst.getMemoryBlock())); + dma->makeAccesibleFromVA(dst.getMemoryBlock()); dma->memcpy(src.getMemoryBlock(), dst.getMemoryBlock(), len); }}); } From f84651c1aed70cb7bf02230d8bef315e688ddcab Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Wed, 14 Dec 2022 16:03:25 +0100 Subject: [PATCH 10/16] removed unnecessary virtual Signed-off-by: Pascal Bauer --- fpga/include/villas/fpga/ips/dma.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/fpga/include/villas/fpga/ips/dma.hpp b/fpga/include/villas/fpga/ips/dma.hpp index dcf36d752..892fd66cf 100644 --- a/fpga/include/villas/fpga/ips/dma.hpp +++ b/fpga/include/villas/fpga/ips/dma.hpp @@ -43,7 +43,6 @@ public: virtual bool init() override; - virtual bool reset() override; // Memory-mapped to stream (MM2S) From 2c7e9151e66cf93d91683c7446733abfd9e1dcfd Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Wed, 14 Dec 2022 16:09:40 +0100 Subject: [PATCH 11/16] removed duplicate member already present in parent class Signed-off-by: Pascal Bauer --- fpga/include/villas/fpga/ips/rtds2gpu.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/fpga/include/villas/fpga/ips/rtds2gpu.hpp b/fpga/include/villas/fpga/ips/rtds2gpu.hpp index 7dfd8a120..d44fdb330 100644 --- a/fpga/include/villas/fpga/ips/rtds2gpu.hpp +++ b/fpga/include/villas/fpga/ips/rtds2gpu.hpp @@ -56,8 +56,6 @@ public: doorbellRegister = 0; } - static constexpr const char* registerMemory = "Reg"; - std::list getMemoryBlocks() const { return { From 082dd40edbe56c7372ffb6d582ec04d2e7b54a72 Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Fri, 16 Dec 2022 13:24:59 +0100 Subject: [PATCH 12/16] added class name before virtual method Signed-off-by: Pascal Bauer --- fpga/lib/ips/dma.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpga/lib/ips/dma.cpp b/fpga/lib/ips/dma.cpp index d159362d1..4b2cb4ad6 100644 --- a/fpga/lib/ips/dma.cpp +++ b/fpga/lib/ips/dma.cpp @@ -207,7 +207,7 @@ bool Dma::reset() Dma::~Dma() { - reset(); + Dma::reset(); } bool Dma::memcpy(const MemoryBlock &src, const MemoryBlock &dst, size_t len) From ef7bb1697d3536795cddeb2073a440329e46749f Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Fri, 16 Dec 2022 14:13:40 +0100 Subject: [PATCH 13/16] suppress "unmatchedSuppression" Signed-off-by: Pascal Bauer --- fpga/.gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/fpga/.gitlab-ci.yml b/fpga/.gitlab-ci.yml index 1b7b7dbe1..3f92f75ce 100644 --- a/fpga/.gitlab-ci.yml +++ b/fpga/.gitlab-ci.yml @@ -73,6 +73,7 @@ test:cppcheck: src/ lib/ tests/unit/ + --suppress=unmatchedSuppression -igpu/thirdparty | tee cppcheck.log image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG_DEV} dependencies: From 1c85a4330f692a964dbbd91b01caf8bdf30a8de3 Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Fri, 16 Dec 2022 16:38:46 +0100 Subject: [PATCH 14/16] cast voidpointer to uint for arithmetik Signed-off-by: Pascal Bauer --- fpga/src/pcimem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpga/src/pcimem.c b/fpga/src/pcimem.c index 1f281abf9..4494f859a 100644 --- a/fpga/src/pcimem.c +++ b/fpga/src/pcimem.c @@ -92,7 +92,7 @@ int main(int argc, char **argv) { printf("PCI Memory mapped to address %p.\n", map_base); fflush(stdout); - virt_addr = map_base + (target & MAP_MASK); + virt_addr = (uint8_t*) map_base + (target & MAP_MASK); switch(access_type) { case 'b': From 56dcf9fac6071af2ce480e0e8031d41ff0fe6d84 Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Fri, 16 Dec 2022 17:01:42 +0100 Subject: [PATCH 15/16] add comment to suppress casting warning Signed-off-by: Pascal Bauer --- fpga/src/villas-fpga-cat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpga/src/villas-fpga-cat.cpp b/fpga/src/villas-fpga-cat.cpp index ace383da7..5b4f54bd7 100644 --- a/fpga/src/villas-fpga-cat.cpp +++ b/fpga/src/villas-fpga-cat.cpp @@ -135,7 +135,7 @@ int main(int argc, char* argv[]) for (size_t i = 0; i*4 < bytesRead; i++) { int32_t ival = mem[cur][i]; - float fval = *((float*)(&ival)); + float fval = *((float*)(&ival)); // cppcheck-suppress invalidPointerCast //std::cerr << std::hex << ival << ","; std::cerr << fval << std::endl; /*int64_t ival = (int64_t)(mem[1] & 0xFFFF) << 48 | From 3fc982bcef092580c33a974ade2e3e6967d64af4 Mon Sep 17 00:00:00 2001 From: Pascal Bauer Date: Fri, 16 Dec 2022 17:16:48 +0100 Subject: [PATCH 16/16] update common submodule Signed-off-by: Pascal Bauer --- fpga/common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpga/common b/fpga/common index 1912f2106..51e32a4b9 160000 --- a/fpga/common +++ b/fpga/common @@ -1 +1 @@ -Subproject commit 1912f2106453cea3a20358942ad7f360b2129bc3 +Subproject commit 51e32a4b9164b176da5ba3843b645ad6b49b3ec2