Skip to content

Commit

Permalink
cpu-o3: fetch: fix fetch missalighed cause error, two replay packet u…
Browse files Browse the repository at this point in the history
…se one replayPkt,

so use replayPkt vector

cpu-o3: fetch: fix running assert error

Change-Id: I375ff435b2f13c6e081609d14b9247bec1b4a9c4
  • Loading branch information
tastynoob committed Dec 27, 2024
1 parent fc1f4aa commit d46d2c5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
49 changes: 28 additions & 21 deletions src/cpu/o3/fetch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Fetch::Fetch(CPU *_cpu, const BaseO3CPUParams &params)
commitToFetchDelay(params.commitToFetchDelay),
fetchWidth(params.fetchWidth),
decodeWidth(params.decodeWidth),
retryPkt(NULL),
retryPkt(),
retryTid(InvalidThreadID),
cacheBlkSize(cpu->cacheLineSize()),
fetchBufferSize(params.fetchBufferSize),
Expand Down Expand Up @@ -556,7 +556,7 @@ void
Fetch::drainSanityCheck() const
{
assert(isDrained());
assert(retryPkt == NULL);
assert(retryPkt.size() == 0);
assert(retryTid == InvalidThreadID);
assert(!cacheBlocked);
assert(!interruptPending);
Expand Down Expand Up @@ -896,16 +896,16 @@ Fetch::finishTranslation(const Fault &fault, const RequestPtr &mem_req)

// Access the cache.
if (!icachePort.sendTimingReq(data_pkt)) {
assert(retryPkt == NULL);
assert(retryTid == InvalidThreadID);
//assert(retryPkt == NULL);
// assert(retryTid == InvalidThreadID);
DPRINTF(Fetch, "[tid:%i] Out of MSHRs!\n", tid);

fetchStatus[tid] = IcacheWaitRetry;
data_pkt->setRetriedPkt();
DPRINTF(Fetch, "[tid:%i] mem_req.addr=%#lx needs retry.\n", tid,
mem_req->getVaddr());
setAllFetchStalls(StallReason::IcacheStall);
retryPkt = data_pkt;
retryPkt.push_back(data_pkt);
retryTid = tid;
cacheBlocked = true;

Expand Down Expand Up @@ -1023,10 +1023,10 @@ Fetch::doSquash(const PCStateBase &new_pc, const DynInstPtr squashInst, const In
// Get rid of the retrying packet if it was from this thread.
if (retryTid == tid) {
assert(cacheBlocked);
if (retryPkt) {
delete retryPkt;
for (auto it : retryPkt) {
delete it;
}
retryPkt = NULL;
retryPkt.clear();
retryTid = InvalidThreadID;
}

Expand Down Expand Up @@ -1991,24 +1991,31 @@ Fetch::fetch(bool &status_change)
void
Fetch::recvReqRetry()
{
if (retryPkt != NULL) {
assert(cacheBlocked);
assert(retryTid != InvalidThreadID);
assert(fetchStatus[retryTid] == IcacheWaitRetry);
if (retryPkt.size() == 0) {
assert(retryTid == InvalidThreadID);
// Access has been squashed since it was sent out. Just clear
// the cache being blocked.
cacheBlocked = false;
return;
}
assert(cacheBlocked);
// assert(retryTid != InvalidThreadID);
// assert(fetchStatus[retryTid] == IcacheWaitRetry);

if (icachePort.sendTimingReq(retryPkt)) {
for (auto it = retryPkt.begin(); it != retryPkt.end();) {
if (icachePort.sendTimingReq(*it)) {
fetchStatus[retryTid] = IcacheWaitResponse;
// Notify Fetch Request probe when a retryPkt is successfully sent.
// Note that notify must be called before retryPkt is set to NULL.
ppFetchRequestSent->notify(retryPkt->req);
retryPkt = NULL;
retryTid = InvalidThreadID;
cacheBlocked = false;
ppFetchRequestSent->notify((*it)->req);
it = retryPkt.erase(it);
} else {
it++;
}
} else {
assert(retryTid == InvalidThreadID);
// Access has been squashed since it was sent out. Just clear
// the cache being blocked.
}

if (retryPkt.size() == 0) {
retryTid = InvalidThreadID;
cacheBlocked = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/o3/fetch.hh
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ class Fetch
bool cacheBlocked;

/** The packet that is waiting to be retried. */
PacketPtr retryPkt;
std::vector<PacketPtr> retryPkt;

/** The thread that is waiting on the cache to tell fetch to retry. */
ThreadID retryTid;
Expand Down

0 comments on commit d46d2c5

Please sign in to comment.