cpu-o3: Prevent cpu from suspending if it is already draining
authorNikos Nikoleris <nikos.nikoleris@arm.com>
Mon, 9 Oct 2017 12:57:49 +0000 (13:57 +0100)
committerNikos Nikoleris <nikos.nikoleris@arm.com>
Tue, 21 Nov 2017 13:54:35 +0000 (13:54 +0000)
Suspending the current thread context while draining due to a quiesce
pseudo instruction (for example a wfi instruction) could deadlock the
cpu and prevent it from successfully draining. This change ensures
that the cpu is not draining before suspending the thread context.

Change-Id: I7c019847f5a870d4bc9ce2b19936bc3dc45e5fd7
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/5881
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>

src/cpu/o3/thread_context_impl.hh

index fdaa35134c70430bb72608932e93cc83dbfd9f60..d9f84fb521f3bbcf0f1849612ea431646299b7ca 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2012, 2016 ARM Limited
+ * Copyright (c) 2010-2012, 2016-2017 ARM Limited
  * Copyright (c) 2013 Advanced Micro Devices, Inc.
  * All rights reserved
  *
@@ -109,6 +109,11 @@ O3ThreadContext<Impl>::suspend()
     if (thread->status() == ThreadContext::Suspended)
         return;
 
+    if (cpu->isDraining()) {
+        DPRINTF(O3CPU, "Ignoring suspend on TC due to pending drain\n");
+        return;
+    }
+
     thread->lastActivate = curTick();
     thread->lastSuspend = curTick();