Fix it so that the cache does not assume to gave the packet it sent out via sendTiming.

Still need to fix upgrades to use this path

src/mem/cache/base_cache.cc:
    Copy the pkt to the MSHR before issuing the sendTiming where it may be changed/consumed
src/mem/cache/cache_impl.hh:
    Use copy of packet, because sendTiming may have changed the pkt
    Also, delete the copy when the time comes

--HG--
extra : convert_revision : 635cde6b4f08d010affde310c46b1caf50fbe424
This commit is contained in:
Ron Dreslinski 2006-10-17 15:05:21 -04:00
parent db6cc97e31
commit 288b98eb69
2 changed files with 14 additions and 2 deletions

View file

@ -36,6 +36,7 @@
#include "mem/cache/base_cache.hh" #include "mem/cache/base_cache.hh"
#include "cpu/smt.hh" #include "cpu/smt.hh"
#include "cpu/base.hh" #include "cpu/base.hh"
#include "mem/cache/miss/mshr.hh"
using namespace std; using namespace std;
@ -179,6 +180,10 @@ BaseCache::CachePort::recvRetry()
} }
pkt = cache->getPacket(); pkt = cache->getPacket();
MSHR* mshr = (MSHR*)pkt->senderState; MSHR* mshr = (MSHR*)pkt->senderState;
//Copy the packet, it may be modified/destroyed elsewhere
Packet * copyPkt = new Packet(*pkt);
copyPkt->dataStatic<uint8_t>(pkt->getPtr<uint8_t>());
mshr->pkt = copyPkt;
bool success = sendTiming(pkt); bool success = sendTiming(pkt);
DPRINTF(Cache, "Address %x was %s in sending the timing request\n", DPRINTF(Cache, "Address %x was %s in sending the timing request\n",
pkt->getAddr(), success ? "succesful" : "unsuccesful"); pkt->getAddr(), success ? "succesful" : "unsuccesful");
@ -288,6 +293,11 @@ BaseCache::CacheEvent::process()
pkt = cachePort->cache->getPacket(); pkt = cachePort->cache->getPacket();
MSHR* mshr = (MSHR*) pkt->senderState; MSHR* mshr = (MSHR*) pkt->senderState;
//Copy the packet, it may be modified/destroyed elsewhere
Packet * copyPkt = new Packet(*pkt);
copyPkt->dataStatic<uint8_t>(pkt->getPtr<uint8_t>());
mshr->pkt = copyPkt;
bool success = cachePort->sendTiming(pkt); bool success = cachePort->sendTiming(pkt);
DPRINTF(Cache, "Address %x was %s in sending the timing request\n", DPRINTF(Cache, "Address %x was %s in sending the timing request\n",
pkt->getAddr(), success ? "succesful" : "unsuccesful"); pkt->getAddr(), success ? "succesful" : "unsuccesful");

View file

@ -273,9 +273,9 @@ void
Cache<TagStore,Buffering,Coherence>::sendResult(PacketPtr &pkt, MSHR* mshr, bool success) Cache<TagStore,Buffering,Coherence>::sendResult(PacketPtr &pkt, MSHR* mshr, bool success)
{ {
if (success && !(pkt->flags & NACKED_LINE)) { if (success && !(pkt->flags & NACKED_LINE)) {
missQueue->markInService(pkt, mshr); missQueue->markInService(mshr->pkt, mshr);
//Temp Hack for UPGRADES //Temp Hack for UPGRADES
if (pkt->cmd == Packet::UpgradeReq) { if (mshr->pkt->cmd == Packet::UpgradeReq) {
pkt->flags &= ~CACHE_LINE_FILL; pkt->flags &= ~CACHE_LINE_FILL;
BlkType *blk = tags->findBlock(pkt); BlkType *blk = tags->findBlock(pkt);
CacheBlk::State old_state = (blk) ? blk->status : 0; CacheBlk::State old_state = (blk) ? blk->status : 0;
@ -304,6 +304,8 @@ Cache<TagStore,Buffering,Coherence>::handleResponse(Packet * &pkt)
{ {
BlkType *blk = NULL; BlkType *blk = NULL;
if (pkt->senderState) { if (pkt->senderState) {
//Delete temp copy in MSHR, restore it.
delete ((MSHR*)pkt->senderState)->pkt;
((MSHR*)pkt->senderState)->pkt = pkt; ((MSHR*)pkt->senderState)->pkt = pkt;
if (pkt->result == Packet::Nacked) { if (pkt->result == Packet::Nacked) {
//pkt->reinitFromRequest(); //pkt->reinitFromRequest();