# HG changeset patch
# User Liang Wang <lw2aw@virginia.edu>
# Date 1287067125 14400
# Node ID e243628273d060d88216863b53c8e50705118c81
# Parent  84bd4089958b0ba44c128914ed496b624209a439
solve a deadlock bug

diff -r 84bd4089958b -r e243628273d0 src/cpu/o3/comm.hh
--- a/src/cpu/o3/comm.hh	Tue May 25 20:15:44 2010 -0700
+++ b/src/cpu/o3/comm.hh	Thu Oct 14 10:38:45 2010 -0400
@@ -186,6 +186,22 @@ struct TimeBufStruct {
 
         bool interruptPending;
         bool clearInterrupt;
+
+        /* ** solution to deadlock <liang.wang@virginia.edu>
+         *  Indicate there are stores committed, mark them as able
+         *  to writeback at next cycle in IEW no matter whether or 
+         *  not the squahsing happens. Mark stores as soon as possible
+         *  can prevent potential deadlock.
+         *
+         *  storeCommitted: indicate committed sotres
+         *  youngest_store: Sequence number for the youngest committed
+         *                  stores. It is not redundant with doneSeqNum
+         *                  since doneSeqNum is set to instruction leading
+         *                  to squash rather than the youngest instruction
+         *                  that have been committed.
+         */
+        bool storeCommitted;
+        InstSeqNum youngest_store;
     };
 
     commitComm commitInfo[Impl::MaxThreads];
diff -r 84bd4089958b -r e243628273d0 src/cpu/o3/commit_impl.hh
--- a/src/cpu/o3/commit_impl.hh	Tue May 25 20:15:44 2010 -0700
+++ b/src/cpu/o3/commit_impl.hh	Thu Oct 14 10:38:45 2010 -0400
@@ -1025,6 +1025,12 @@ DefaultCommit<Impl>::commitHead(DynInstP
         head_inst->setCompleted();
     }
 
+    // ** solution to the deadlock <liang.wang@virginia.edu>
+    if (head_inst->isStore() && inst_fault == NoFault) {
+        toIEW->commitInfo[tid].storeCommitted = true;
+        toIEW->commitInfo[tid].youngest_store = head_inst->seqNum;
+    }
+
 #if USE_CHECKER
     // Use checker prior to updating anything due to traps or PC
     // based events.
diff -r 84bd4089958b -r e243628273d0 src/cpu/o3/iew_impl.hh
--- a/src/cpu/o3/iew_impl.hh	Tue May 25 20:15:44 2010 -0700
+++ b/src/cpu/o3/iew_impl.hh	Thu Oct 14 10:38:45 2010 -0400
@@ -1492,12 +1492,23 @@ DefaultIEW<Impl>::tick()
 
         DPRINTF(IEW,"Processing [tid:%i]\n",tid);
 
+        // ** solution to the deadlock <liang.wang@virginia.edu>
+        if (fromCommit->commitInfo[tid].storeCommitted) {
+            DPRINTF(IEW, "Try to mark stores be able to writeback from [sn:%lli]\n",
+                    fromCommit->commitInfo[tid].youngest_store);
+  
+            ldstQueue.commitStores(fromCommit->commitInfo[tid].doneSeqNum,tid);
+  
+            updateLSQNextCycle = true;
+            instQueue.commit(fromCommit->commitInfo[tid].doneSeqNum,tid);
+        }
+
         // Update structures based on instructions committed.
         if (fromCommit->commitInfo[tid].doneSeqNum != 0 &&
             !fromCommit->commitInfo[tid].squash &&
             !fromCommit->commitInfo[tid].robSquashing) {
 
-            ldstQueue.commitStores(fromCommit->commitInfo[tid].doneSeqNum,tid);
+//            ldstQueue.commitStores(fromCommit->commitInfo[tid].doneSeqNum,tid);
 
             ldstQueue.commitLoads(fromCommit->commitInfo[tid].doneSeqNum,tid);
 
