mem-cache: Simplify writeback for the tempBlock in recvTimingResp
authorNikos Nikoleris <nikos.nikoleris@arm.com>
Tue, 1 May 2018 11:02:14 +0000 (12:02 +0100)
committerNikos Nikoleris <nikos.nikoleris@arm.com>
Thu, 17 May 2018 14:16:01 +0000 (14:16 +0000)
When we use the tempBlock to fill-in, we have to write it back and
invalidate it at the end of current transaction. This patch simplifies
the writeback flow by treating it as a regular writeback.

Change-Id: I257be7bbff211e2832ad001a4e991daf67704485
Reviewed-on: https://gem5-review.googlesource.com/10421
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>

src/mem/cache/cache.cc

index 2d3ab83128e582361a6908312b630d7ae9e98edf..b9625beeee535b7780f9060698b90a4e90ef0abd 100644 (file)
@@ -1611,33 +1611,17 @@ Cache::recvTimingResp(PacketPtr pkt)
     // reset the xbar additional timinig  as it is now accounted for
     pkt->headerDelay = pkt->payloadDelay = 0;
 
-    // copy writebacks to write buffer
-    doWritebacks(writebacks, forward_time);
-
     // if we used temp block, check to see if its valid and then clear it out
     if (blk == tempBlock && tempBlock->isValid()) {
-        // We use forwardLatency here because we are copying
-        // Writebacks/CleanEvicts to write buffer. It specifies the latency to
-        // allocate an internal buffer and to schedule an event to the
-        // queued port.
-        if (blk->isDirty() || writebackClean) {
-            PacketPtr wbPkt = writebackBlk(blk);
-            allocateWriteBuffer(wbPkt, forward_time);
-            // Set BLOCK_CACHED flag if cached above.
-            if (isCachedAbove(wbPkt))
-                wbPkt->setBlockCached();
-        } else {
-            PacketPtr wcPkt = cleanEvictBlk(blk);
-            // Check to see if block is cached above. If not allocate
-            // write buffer
-            if (isCachedAbove(wcPkt))
-                delete wcPkt;
-            else
-                allocateWriteBuffer(wcPkt, forward_time);
-        }
-        invalidateBlock(blk);
+        PacketPtr wb_pkt = tempBlock->isDirty() || writebackClean ?
+            writebackBlk(blk) : cleanEvictBlk(blk);
+        writebacks.push_back(wb_pkt);
+        invalidateBlock(tempBlock);
     }
 
+    // copy writebacks to write buffer
+    doWritebacks(writebacks, forward_time);
+
     DPRINTF(CacheVerbose, "%s: Leaving with %s\n", __func__, pkt->print());
     delete pkt;
 }