bus.cc:
authorSteve Reinhardt <stever@eecs.umich.edu>
Mon, 2 Jul 2007 08:02:35 +0000 (01:02 -0700)
committerSteve Reinhardt <stever@eecs.umich.edu>
Mon, 2 Jul 2007 08:02:35 +0000 (01:02 -0700)
Fix atomic timing issue.

src/mem/bus.cc:
    Fix atomic timing issue.

--HG--
extra : convert_revision : a22ff80cd75f83c785b0604c2a4fde2e2e9f71ef

src/mem/bus.cc

index 83ce0f87dce64c1ded8cdd65847e0f3e3eefc67d..34f7f4fd0181b2be666535edda98110598424aeb 100644 (file)
@@ -377,7 +377,8 @@ Bus::recvAtomic(PacketPtr pkt)
     // original command so that additional snoops can take place
     // properly
     MemCmd orig_cmd = pkt->cmd;
-    MemCmd response_cmd = MemCmd::InvalidCmd;
+    MemCmd snoop_response_cmd = MemCmd::InvalidCmd;
+    Tick snoop_response_latency = 0;
     int orig_src = pkt->getSrc();
 
     Port *target_port = findPort(pkt->getAddr(), pkt->getSrc());
@@ -388,15 +389,16 @@ Bus::recvAtomic(PacketPtr pkt)
         // same port should not have both target addresses and snooping
         assert(p != target_port);
         if (p->getId() != pkt->getSrc()) {
-            p->sendAtomic(pkt);
+            Tick latency = p->sendAtomic(pkt);
             if (pkt->isResponse()) {
                 // response from snoop agent
                 assert(pkt->cmd != orig_cmd);
                 assert(pkt->memInhibitAsserted());
                 // should only happen once
-                assert(response_cmd == MemCmd::InvalidCmd);
+                assert(snoop_response_cmd == MemCmd::InvalidCmd);
                 // save response state
-                response_cmd = pkt->cmd;
+                snoop_response_cmd = pkt->cmd;
+                snoop_response_latency = latency;
                 // restore original packet state for remaining snoopers
                 pkt->cmd = orig_cmd;
                 pkt->setSrc(orig_src);
@@ -405,19 +407,20 @@ Bus::recvAtomic(PacketPtr pkt)
         }
     }
 
-    Tick response_time = target_port->sendAtomic(pkt);
+    Tick response_latency = target_port->sendAtomic(pkt);
 
     // if we got a response from a snooper, restore it here
-    if (response_cmd != MemCmd::InvalidCmd) {
+    if (snoop_response_cmd != MemCmd::InvalidCmd) {
         // no one else should have responded
         assert(!pkt->isResponse());
         assert(pkt->cmd == orig_cmd);
-        pkt->cmd = response_cmd;
+        pkt->cmd = snoop_response_cmd;
+        response_latency = snoop_response_latency;
     }
 
     // why do we have this packet field and the return value both???
-    pkt->finishTime = std::max(response_time, curTick + clock);
-    return pkt->finishTime;
+    pkt->finishTime = curTick + response_latency;
+    return response_latency;
 }
 
 /** Function called by the port when the bus is receiving a Functional