From bb0e52e2572eb36e82c70bda4fd42847492fe95e Mon Sep 17 00:00:00 2001 From: predutta Date: Wed, 24 Jun 2026 18:35:14 -0700 Subject: [PATCH 1/2] Fix for aie_status Signed-off-by: predutta --- .../plugin/aie_status/aie_status_plugin.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/profile/plugin/aie_status/aie_status_plugin.cpp b/profile/plugin/aie_status/aie_status_plugin.cpp index 5163467e..71e82de0 100644 --- a/profile/plugin/aie_status/aie_status_plugin.cpp +++ b/profile/plugin/aie_status/aie_status_plugin.cpp @@ -505,13 +505,6 @@ namespace xdp { ***************************************************************************/ void AIEStatusPlugin::endPollforDevice(void* handle) { - // Last chance at writing status reports - for (auto w : writers) { - mtxWriterThread.lock(); - w->write(false, handle); - mtxWriterThread.unlock(); - } - // When ending polling for a device, if we are on edge we must instead // shut down all of the threads and not just a single one in order // to avoid race conditions between the zynq driver destructor and our own. @@ -519,7 +512,18 @@ namespace xdp { // Currently, Edge is the only supported type of platform so we can // safely end all threads here, but this must be revisited if we extend // AIE status functionality to other types of platforms. + // + // Stop background threads before the final write. pollDeadlock reads AIE + // registers while write() queries sysfs via get_info; running both during + // teardown can hang the driver. endPoll(); + + // Last chance at writing status reports + for (auto w : writers) { + mtxWriterThread.lock(); + w->write(false, handle); + mtxWriterThread.unlock(); + } } /**************************************************************************** From d7fcf74392a1429da881982c3cc373c43139c40b Mon Sep 17 00:00:00 2001 From: predutta Date: Fri, 26 Jun 2026 11:58:32 -0700 Subject: [PATCH 2/2] Mutex fix as per copilot suggestion Signed-off-by: predutta --- profile/plugin/aie_status/aie_status_plugin.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/profile/plugin/aie_status/aie_status_plugin.cpp b/profile/plugin/aie_status/aie_status_plugin.cpp index 71e82de0..347a83ea 100644 --- a/profile/plugin/aie_status/aie_status_plugin.cpp +++ b/profile/plugin/aie_status/aie_status_plugin.cpp @@ -520,9 +520,10 @@ namespace xdp { // Last chance at writing status reports for (auto w : writers) { - mtxWriterThread.lock(); + //mtxWriterThread.lock(); + std::lock_guard lock(mtxWriterThread); w->write(false, handle); - mtxWriterThread.unlock(); + //mtxWriterThread.unlock(); } }