From: Nikos Nikoleris Date: Tue, 22 Jan 2019 17:40:17 +0000 (+0000) Subject: mem-cache: Copy over flags to forwarded response X-Git-Tag: v19.0.0.0~1087 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8e723650586e9d902d4b462ddf5bb067e5eb0757;p=gem5.git mem-cache: Copy over flags to forwarded response A cache that forwards a request to the memory below does not fill and forwards the response with the data to cache above. This change ensures that the flags of the original response are also preserved. Change-Id: I244b20b073c31b976358816c5b14bba413b8271f Signed-off-by: Nikos Nikoleris Reviewed-on: https://gem5-review.googlesource.com/c/16182 Reviewed-by: Daniel Carvalho --- diff --git a/src/mem/cache/cache.cc b/src/mem/cache/cache.cc index e23c4ef30..89e40f328 100644 --- a/src/mem/cache/cache.cc +++ b/src/mem/cache/cache.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2018 ARM Limited + * Copyright (c) 2010-2019 ARM Limited * All rights reserved. * * The license below extends only to copyright in the software and shall @@ -786,6 +786,11 @@ Cache::serviceMSHRTargets(MSHR *mshr, const PacketPtr pkt, CacheBlk *blk) tgt_pkt->setData(pkt->getConstPtr()); } + + // this response did not allocate here and therefore + // it was not consumed, make sure that any flags are + // carried over to cache above + tgt_pkt->copyResponderFlags(pkt); } tgt_pkt->makeTimingResponse(); // if this packet is an error copy that to the new packet @@ -965,7 +970,6 @@ Cache::handleSnoop(PacketPtr pkt, CacheBlk *blk, bool is_timing, // first propagate snoop upward to see if anyone above us wants to // handle it. save & restore packet src since it will get // rewritten to be relative to cpu-side bus (if any) - bool alreadyResponded = pkt->cacheResponding(); if (is_timing) { // copy the packet so that we can clear any flags before // forwarding it upwards, we also allocate data (passing @@ -983,16 +987,6 @@ Cache::handleSnoop(PacketPtr pkt, CacheBlk *blk, bool is_timing, // cache snoop_delay += snoopPkt.headerDelay; - if (snoopPkt.cacheResponding()) { - // cache-to-cache response from some upper cache - assert(!alreadyResponded); - pkt->setCacheResponding(); - } - // upstream cache has the block, or has an outstanding - // MSHR, pass the flag on - if (snoopPkt.hasSharers()) { - pkt->setHasSharers(); - } // If this request is a prefetch or clean evict and an upper level // signals block present, make sure to propagate the block // presence to the requester. @@ -1004,9 +998,14 @@ Cache::handleSnoop(PacketPtr pkt, CacheBlk *blk, bool is_timing, if (snoopPkt.satisfied()) { pkt->setSatisfied(); } + + // Copy over flags from the snoop response to make sure we + // inform the final destination + pkt->copyResponderFlags(&snoopPkt); } else { + bool already_responded = pkt->cacheResponding(); cpuSidePort.sendAtomicSnoop(pkt); - if (!alreadyResponded && pkt->cacheResponding()) { + if (!already_responded && pkt->cacheResponding()) { // cache-to-cache response from some upper cache: // forward response to original requester assert(pkt->isResponse()); diff --git a/src/mem/packet.cc b/src/mem/packet.cc index 4369e168f..e1c760cd0 100644 --- a/src/mem/packet.cc +++ b/src/mem/packet.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2018 ARM Limited + * Copyright (c) 2011-2019 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -302,6 +302,16 @@ Packet::trySatisfyFunctional(Printable *obj, Addr addr, bool is_secure, int size return false; } +void +Packet::copyResponderFlags(const PacketPtr pkt) +{ + assert(isRequest()); + // If we have already found a responder, no other cache should + // commit to responding + assert(!pkt->cacheResponding() || !cacheResponding()); + flags.set(pkt->flags & RESPONDER_FLAGS); +} + void Packet::pushSenderState(Packet::SenderState *sender_state) { diff --git a/src/mem/packet.hh b/src/mem/packet.hh index c59db362e..2bcbf4dab 100644 --- a/src/mem/packet.hh +++ b/src/mem/packet.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2018 ARM Limited + * Copyright (c) 2012-2019 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -265,6 +265,9 @@ class Packet : public Printable // Flags to transfer across when copying a packet COPY_FLAGS = 0x0000003F, + // Flags that are used to create reponse packets + RESPONDER_FLAGS = 0x00000009, + // Does this packet have sharers (which means it should not be // considered writable) or not. See setHasSharers below. HAS_SHARERS = 0x00000001, @@ -649,6 +652,15 @@ class Packet : public Printable bool responderHadWritable() const { return flags.isSet(RESPONDER_HAD_WRITABLE); } + /** + * Copy the reponse flags from an input packet to this packet. The + * reponse flags determine whether a responder has been found and + * the state at which the block will be at the destination. + * + * @pkt The packet that we will copy flags from + */ + void copyResponderFlags(const PacketPtr pkt); + /** * A writeback/writeclean cmd gets propagated further downstream * by the receiver when the flag is set.