Merge zizzer:/n/wexford/x/gblack/m5/newmem_bus
into  zazzer.eecs.umich.edu:/z/rdreslin/m5bk/newmemcleanest

src/mem/bus.cc:
    SCCS merged

--HG--
extra : convert_revision : 18608114350c466a56ab499ae523b01fcb2f6ef2
diff --git a/src/base/traceflags.py b/src/base/traceflags.py
index 274407b..f871ce3 100644
--- a/src/base/traceflags.py
+++ b/src/base/traceflags.py
@@ -58,6 +58,7 @@
     'BusAddrRanges',
     'BusBridge',
     'Cache',
+    'CachePort',
     'Chains',
     'Checker',
     'Clock',
diff --git a/src/mem/bus.cc b/src/mem/bus.cc
index 7bdd441..03c1a42 100644
--- a/src/mem/bus.cc
+++ b/src/mem/bus.cc
@@ -188,6 +188,7 @@
         // Packet was successfully sent. Return true.
         // Also take care of retries
         if (inRetry) {
+            DPRINTF(Bus, "Remove retry from list %i\n", retryList.front());
             retryList.front()->onRetryList(false);
             retryList.pop_front();
             inRetry = false;
@@ -196,6 +197,7 @@
     }
 
     // Packet not successfully sent. Leave or put it on the retry list.
+    DPRINTF(Bus, "Adding a retry to RETRY list %i\n", pktPort);
     addToRetryList(pktPort);
     return false;
 }
@@ -203,10 +205,12 @@
 void
 Bus::recvRetry(int id)
 {
+    DPRINTF(Bus, "Received a retry\n");
     // If there's anything waiting...
     if (retryList.size()) {
         //retryingPort = retryList.front();
         inRetry = true;
+        DPRINTF(Bus, "Sending a retry\n");
         retryList.front()->sendRetry();
         // If inRetry is still true, sendTiming wasn't called
         if (inRetry)
@@ -266,8 +270,8 @@
             //Careful  to not overlap ranges
             //or snoop will be called more than once on the port
             ports.push_back(portSnoopList[i].portId);
-            DPRINTF(Bus, "  found snoop addr %#llx on device%d\n", addr,
-                    portSnoopList[i].portId);
+//            DPRINTF(Bus, "  found snoop addr %#llx on device%d\n", addr,
+//                    portSnoopList[i].portId);
         }
         i++;
     }
diff --git a/src/mem/cache/base_cache.cc b/src/mem/cache/base_cache.cc
index 0141fa2..cdb9d54 100644
--- a/src/mem/cache/base_cache.cc
+++ b/src/mem/cache/base_cache.cc
@@ -116,12 +116,16 @@
     Packet *pkt;
     assert(waitingOnRetry);
     if (!drainList.empty()) {
+        DPRINTF(CachePort, "%s attempting to send a retry for response\n", name());
         //We have some responses to drain first
         if (sendTiming(drainList.front())) {
+            DPRINTF(CachePort, "%s sucessful in sending a retry for response\n", name());
             drainList.pop_front();
             if (!drainList.empty() ||
                 !isCpuSide && cache->doMasterRequest() ||
                 isCpuSide && cache->doSlaveRequest()) {
+
+                DPRINTF(CachePort, "%s has more responses/requests\n", name());
                 BaseCache::CacheEvent * reqCpu = new BaseCache::CacheEvent(this);
                 reqCpu->schedule(curTick + 1);
             }
@@ -130,6 +134,7 @@
     }
     else if (!isCpuSide)
     {
+        DPRINTF(CachePort, "%s attempting to send a retry for MSHR\n", name());
         assert(cache->doMasterRequest());
         pkt = cache->getPacket();
         MSHR* mshr = (MSHR*)pkt->senderState;
@@ -140,6 +145,7 @@
         waitingOnRetry = !success;
         if (success && cache->doMasterRequest())
         {
+            DPRINTF(CachePort, "%s has more requests\n", name());
             //Still more to issue, rerequest in 1 cycle
             pkt = NULL;
             BaseCache::CacheEvent * reqCpu = new BaseCache::CacheEvent(this);
@@ -163,6 +169,8 @@
             cshrRetry = NULL;
         }
     }
+    if (waitingOnRetry) DPRINTF(CachePort, "%s STILL Waiting on retry\n", name());
+    else DPRINTF(CachePort, "%s no longer waiting on retry\n", name());
     return;
 }
 void
@@ -210,17 +218,27 @@
         if (cachePort->waitingOnRetry) return;
        //We have some responses to drain first
         if (!cachePort->drainList.empty()) {
+            DPRINTF(CachePort, "%s trying to drain a response\n", cachePort->name());
             if (cachePort->sendTiming(cachePort->drainList.front())) {
+                DPRINTF(CachePort, "%s drains a response succesfully\n", cachePort->name());
                 cachePort->drainList.pop_front();
                 if (!cachePort->drainList.empty() ||
                     !cachePort->isCpuSide && cachePort->cache->doMasterRequest() ||
-                    cachePort->isCpuSide && cachePort->cache->doSlaveRequest())
+                    cachePort->isCpuSide && cachePort->cache->doSlaveRequest()) {
+
+                    DPRINTF(CachePort, "%s still has outstanding bus reqs\n", cachePort->name());
                     this->schedule(curTick + 1);
+                }
             }
-            else cachePort->waitingOnRetry = true;
+            else {
+                cachePort->waitingOnRetry = true;
+                DPRINTF(CachePort, "%s now waiting on a retry\n", cachePort->name());
+            }
         }
         else if (!cachePort->isCpuSide)
         {
+            DPRINTF(CachePort, "%s trying to send a MSHR request\n", cachePort->name());
+            assert(cachePort->cache->doMasterRequest());
             //MSHR
             pkt = cachePort->cache->getPacket();
             MSHR* mshr = (MSHR*) pkt->senderState;
@@ -229,8 +247,10 @@
                     pkt->getAddr(), success ? "succesful" : "unsuccesful");
             cachePort->cache->sendResult(pkt, mshr, success);
             cachePort->waitingOnRetry = !success;
+            if (cachePort->waitingOnRetry) DPRINTF(CachePort, "%s now waiting on a retry\n", cachePort->name());
             if (success && cachePort->cache->doMasterRequest())
             {
+                DPRINTF(CachePort, "%s still more MSHR requests to send\n", cachePort->name());
                 //Still more to issue, rerequest in 1 cycle
                 pkt = NULL;
                 this->schedule(curTick+1);
@@ -238,6 +258,7 @@
         }
         else
         {
+            assert(cachePort->cache->doSlaveRequest());
             //CSHR
             pkt = cachePort->cache->getCoherencePacket();
             bool success = cachePort->sendTiming(pkt);
@@ -262,12 +283,15 @@
     else
         pkt->result = Packet::Success;
     pkt->makeTimingResponse();
+    DPRINTF(CachePort, "%s attempting to send a response\n", cachePort->name());
     if (!cachePort->drainList.empty()) {
         //Already have a list, just append
         cachePort->drainList.push_back(pkt);
+        DPRINTF(CachePort, "%s appending response onto drain list\n", cachePort->name());
     }
     else if (!cachePort->sendTiming(pkt)) {
         //It failed, save it to list of drain events
+        DPRINTF(CachePort, "%s now waiting for a retry\n", cachePort->name());
         cachePort->drainList.push_back(pkt);
         cachePort->waitingOnRetry = true;
     }
diff --git a/src/mem/cache/base_cache.hh b/src/mem/cache/base_cache.hh
index 41c28f3..563b1ca 100644
--- a/src/mem/cache/base_cache.hh
+++ b/src/mem/cache/base_cache.hh
@@ -467,7 +467,7 @@
      */
     void setMasterRequest(RequestCause cause, Tick time)
     {
-        if (!doMasterRequest() && memSidePort->drainList.empty())
+        if (!doMasterRequest() && !memSidePort->waitingOnRetry)
         {
             BaseCache::CacheEvent * reqCpu = new BaseCache::CacheEvent(memSidePort);
             reqCpu->schedule(time);