mem: Clarify cache MSHR handling on fill
authorAndreas Hansson <andreas.hansson@arm.com>
Thu, 29 Oct 2015 12:48:20 +0000 (08:48 -0400)
committerAndreas Hansson <andreas.hansson@arm.com>
Thu, 29 Oct 2015 12:48:20 +0000 (08:48 -0400)
This patch addresses the upgrading of deferred targets in the MSHR,
and makes it clearer by explicitly calling out what is happening
(deferred targets are promoted if we get exclusivity without asking
for it).

src/mem/cache/cache.cc
src/mem/cache/mshr.cc
src/mem/cache/mshr.hh

index 71fbb18847f81281346c09f3029b1d43cb90151f..3e5ed42bc9340fe3a026e7353045c9115a723e19 100644 (file)
@@ -1190,7 +1190,6 @@ Cache::recvTimingResp(PacketPtr pkt)
 
     // Initial target is used just for stats
     MSHR::Target *initial_tgt = mshr->getTarget();
-    CacheBlk *blk = tags->findBlock(pkt->getAddr(), pkt->isSecure());
     int stats_cmd_idx = initial_tgt->pkt->cmdToIndex();
     Tick miss_latency = curTick() - initial_tgt->recvTime;
     PacketList writebacks;
@@ -1212,16 +1211,20 @@ Cache::recvTimingResp(PacketPtr pkt)
             miss_latency;
     }
 
+    // upgrade deferred targets if we got exclusive
+    if (!pkt->sharedAsserted()) {
+        mshr->promoteExclusive();
+    }
+
     bool is_fill = !mshr->isForward &&
         (pkt->isRead() || pkt->cmd == MemCmd::UpgradeResp);
 
+    CacheBlk *blk = tags->findBlock(pkt->getAddr(), pkt->isSecure());
+
     if (is_fill && !is_error) {
         DPRINTF(Cache, "Block for addr %#llx being updated in Cache\n",
                 pkt->getAddr());
 
-        // give mshr a chance to do some dirty work
-        mshr->handleFill(pkt, blk);
-
         blk = handleFill(pkt, blk, writebacks);
         assert(blk != NULL);
     }
@@ -1262,9 +1265,10 @@ Cache::recvTimingResp(PacketPtr pkt)
             // from above.
             if (tgt_pkt->cmd == MemCmd::WriteLineReq) {
                 assert(!is_error);
-
+                // we got the block in exclusive state, so promote any
+                // deferred targets if possible
+                mshr->promoteExclusive();
                 // NB: we use the original packet here and not the response!
-                mshr->handleFill(tgt_pkt, blk);
                 blk = handleFill(tgt_pkt, blk, writebacks);
                 assert(blk != NULL);
 
index 085b8dae0d04763f1b6bef01d18bfe53ce937ed3..f71ff65247a80d571f495205df872aa1c3b6a85d 100644 (file)
@@ -430,11 +430,10 @@ MSHR::promoteDeferredTargets()
 
 
 void
-MSHR::handleFill(PacketPtr pkt, CacheBlk *blk)
+MSHR::promoteExclusive()
 {
-    if (!pkt->sharedAsserted()
-        && !(hasPostInvalidate() || hasPostDowngrade())
-        && deferredTargets.needsExclusive) {
+    if (deferredTargets.needsExclusive &&
+        !(hasPostInvalidate() || hasPostDowngrade())) {
         // We got an exclusive response, but we have deferred targets
         // which are waiting to request an exclusive copy (not because
         // of a pending invalidate).  This can happen if the original
index 65740c1079b1e5d22f037eb3ebccf4c8e963ff46..11ca4db402bcaac9ca412b10978b290178e34ed9 100644 (file)
@@ -282,7 +282,7 @@ class MSHR : public Packet::SenderState, public Printable
 
     bool promoteDeferredTargets();
 
-    void handleFill(PacketPtr pkt, CacheBlk *blk);
+    void promoteExclusive();
 
     bool checkFunctional(PacketPtr pkt);