From 12413ba041f70f52048f464092e87c3dc84929c6 Mon Sep 17 00:00:00 2001 From: Joris van Rantwijk Date: Thu, 19 Sep 2024 22:55:31 +0200 Subject: [PATCH] Do not disable DMA in destructor The "puzzlecmd" tool needs to create multiple instances of PuzzleFwDevice, one for the data server and one for simple register commands. We don't want these instances fighting over the state of the DMA engine. --- os/src/userspace/puzzlefw.cpp | 3 --- os/src/userspace/puzzlefw.hpp | 7 +++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/os/src/userspace/puzzlefw.cpp b/os/src/userspace/puzzlefw.cpp index ada17e2..b130a74 100644 --- a/os/src/userspace/puzzlefw.cpp +++ b/os/src/userspace/puzzlefw.cpp @@ -160,9 +160,6 @@ puzzlefw::PuzzleFwDevice::PuzzleFwDevice() /* Destructor. */ puzzlefw::PuzzleFwDevice::~PuzzleFwDevice() { - // Disable DMA engine. - set_dma_enabled(false); - // Unmap memory regions. munmap((void*)m_regs, puzzlefw::REGS_SIZE); munmap((void*)m_dma_buf, m_dma_buf_size); diff --git a/os/src/userspace/puzzlefw.hpp b/os/src/userspace/puzzlefw.hpp index 755bdad..35eeb1a 100644 --- a/os/src/userspace/puzzlefw.hpp +++ b/os/src/userspace/puzzlefw.hpp @@ -108,14 +108,13 @@ struct VersionInfo { * This class uses the UIO driver framework and the custom PuzzleFW Linux * kernel driver to access the PuzzleFW firmware. * - * Only a single instance of this class should exist at any time in any - * process on the system. Creating multiple instances, even in separate - * processes, may cause the firmware to function incorrectly. - * * Methods of this class may throw exceptions to report error conditions. * "std::invalid_argument" is used to report invalid arguments. * "std::runtime_error" is used to report errors during opening of the device. * + * It is generally not safe to access the firmware concurrently + * through multiple instances of this class, even from separate processes. + * * Unless stated otherwise, the methods of this class must not be called * concurrently from multiple threads without explicit synchronization. */