DPRINTF(Fetch, "[tid:%u] Waking up from cache miss.\n",tid);
+ assert(!pkt->wasNacked());
+
// Only change the status if it's still waiting on the icache access
// to return.
if (fetchStatus[tid] != IcacheWaitResponse ||
bool
LSQ<Impl>::DcachePort::recvTiming(PacketPtr pkt)
{
+ if (pkt->isError())
+ DPRINTF(LSQ, "Got error packet back for address: %#X\n", pkt->getAddr());
if (pkt->isResponse()) {
lsq->thread[pkt->req->getThreadNum()].completeDataAccess(pkt);
}
//iewStage->ldstQueue.removeMSHR(inst->threadNumber,inst->seqNum);
+ assert(!pkt->wasNacked());
+
if (isSwitchedOut() || inst->isSquashed()) {
iewStage->decrWb(inst->seqNum);
} else {
dcache_latency = dcachePort.sendAtomic(&pkt);
}
dcache_access = true;
+
assert(!pkt.isError());
data = gtoh(data);
else
icache_latency = icachePort.sendAtomic(&ifetch_pkt);
+ assert(!ifetch_pkt.isError());
// ifetch_req is initialized to read the instruction directly
// into the CPU object's inst field.
bool
TimingSimpleCPU::IcachePort::recvTiming(PacketPtr pkt)
{
- if (pkt->isResponse()) {
+ if (pkt->isResponse() && !pkt->wasNacked()) {
// delay processing of returned data until next CPU clock edge
Tick next_tick = cpu->nextCycle(curTick);
bool
TimingSimpleCPU::DcachePort::recvTiming(PacketPtr pkt)
{
- if (pkt->isResponse()) {
+ if (pkt->isResponse() && !pkt->wasNacked()) {
// delay processing of returned data until next CPU clock edge
Tick next_tick = cpu->nextCycle(curTick);
Addr daddr = pkt->getAddr() - pioAddr;
pkt->allocate();
+ pkt->makeAtomicResponse();
switch (pkt->getSize())
{
default:
pkt->setBadAddress();
}
- pkt->makeAtomicResponse();
return pioDelay;
}
IsaFake::read(PacketPtr pkt)
{
+ pkt->makeAtomicResponse();
if (params()->warn_access != "")
warn("Device %s accessed by read to address %#x size=%d\n",
name(), pkt->getAddr(), pkt->getSize());
default:
panic("invalid access size!\n");
}
- pkt->makeAtomicResponse();
}
return pioDelay;
}
Tick
IsaFake::write(PacketPtr pkt)
{
+ pkt->makeAtomicResponse();
if (params()->warn_access != "") {
uint64_t data;
switch (pkt->getSize()) {
panic("invalid access size!\n");
}
}
- pkt->makeAtomicResponse();
}
return pioDelay;
}
DPRINTF(BusBridge, "Local queue size: %d outreq: %d outresp: %d\n",
sendQueue.size(), queuedRequests, outstandingResponses);
- DPRINTF(BusBridge, "Remove queue size: %d outreq: %d outresp: %d\n",
+ DPRINTF(BusBridge, "Remote queue size: %d outreq: %d outresp: %d\n",
otherPort->sendQueue.size(), otherPort->queuedRequests,
otherPort->outstandingResponses);
- if (pkt->isRequest() && otherPort->reqQueueFull() && !pkt->wasNacked()) {
+ if (pkt->isRequest() && otherPort->reqQueueFull()) {
DPRINTF(BusBridge, "Remote queue full, nacking\n");
nackRequest(pkt);
return true;
}
- if (pkt->needsResponse() && !pkt->wasNacked())
+ if (pkt->needsResponse())
if (respQueueFull()) {
DPRINTF(BusBridge, "Local queue full, no space for response, nacking\n");
DPRINTF(BusBridge, "queue size: %d outreq: %d outstanding resp: %d\n",
Bridge::BridgePort::nackRequest(PacketPtr pkt)
{
// Nack the packet
+ pkt->makeTimingResponse();
pkt->setNacked();
- pkt->setDest(pkt->getSrc());
//put it on the list to send
Tick readyTime = curTick + nackDelay;
void
Bridge::BridgePort::queueForSendTiming(PacketPtr pkt)
{
- if (pkt->isResponse() || pkt->wasNacked()) {
+ if (pkt->isResponse()) {
// This is a response for a request we forwarded earlier. The
// corresponding PacketBuffer should be stored in the packet's
// senderState field.
+
PacketBuffer *buf = dynamic_cast<PacketBuffer*>(pkt->senderState);
assert(buf != NULL);
// set up new packet dest & senderState based on values saved
// from original request
buf->fixResponse(pkt);
- // Check if this packet was expecting a response and it's a nacked
- // packet, in which case we will never being seeing it
- if (buf->expectResponse && pkt->wasNacked())
- --outstandingResponses;
-
DPRINTF(BusBridge, "response, new dest %d\n", pkt->getDest());
delete buf;
}
- if (pkt->isRequest() && !pkt->wasNacked()) {
+ if (pkt->isRequest()) {
++queuedRequests;
}
buf->origSrc, pkt->getDest(), pkt->getAddr());
bool wasReq = pkt->isRequest();
- bool wasNacked = pkt->wasNacked();
+ bool was_nacked_here = buf->nackedHere;
+
+ // If the send was successful, make sure sender state was set to NULL
+ // otherwise we could get a NACK back of a packet that didn't expect a
+ // response and we would try to use freed memory.
+
+ Packet::SenderState *old_sender_state = pkt->senderState;
+ if (pkt->isRequest() && !buf->expectResponse)
+ pkt->senderState = NULL;
if (sendTiming(pkt)) {
// send successful
delete buf;
}
- if (!wasNacked) {
- if (wasReq)
- --queuedRequests;
- else
- --outstandingResponses;
- }
+ if (wasReq)
+ --queuedRequests;
+ else if (!was_nacked_here)
+ --outstandingResponses;
// If there are more packets to send, schedule event to try again.
if (!sendQueue.empty()) {
}
} else {
DPRINTF(BusBridge, " unsuccessful\n");
+ pkt->senderState = old_sender_state;
inRetry = true;
}
+
DPRINTF(BusBridge, "trySend: queue size: %d outreq: %d outstanding resp: %d\n",
sendQueue.size(), queuedRequests, outstandingResponses);
}
public:
Tick ready;
PacketPtr pkt;
+ bool nackedHere;
Packet::SenderState *origSenderState;
short origSrc;
bool expectResponse;
PacketBuffer(PacketPtr _pkt, Tick t, bool nack = false)
- : ready(t), pkt(_pkt),
- origSenderState(_pkt->senderState), origSrc(_pkt->getSrc()),
+ : ready(t), pkt(_pkt), nackedHere(nack),
+ origSenderState(_pkt->senderState),
+ origSrc(nack ? _pkt->getDest() : _pkt->getSrc() ),
expectResponse(_pkt->needsResponse() && !nack)
{
- if (!pkt->isResponse() && !nack && !pkt->wasNacked())
+ if (!pkt->isResponse() && !nack)
pkt->senderState = this;
}
if (dest_port_id == src) {
// Must be forwarded snoop up from below...
assert(dest == Packet::Broadcast);
+ assert(src != defaultId); // catch infinite loops
} else {
// send to actual target
if (!dest_port->sendTiming(pkt)) {
DPRINTF(Cache, "Receive response: %s for addr %x in state %i\n",
busPkt->cmdString(), busPkt->getAddr(), old_state);
- if (isCacheFill) {
+ bool is_error = busPkt->isError();
+ assert(!busPkt->wasNacked());
+
+ if (is_error && pkt->needsResponse()) {
+ pkt->makeAtomicResponse();
+ pkt->copyError(busPkt);
+ } else if (isCacheFill && !is_error) {
PacketList writebacks;
blk = handleFill(busPkt, blk, writebacks);
satisfyCpuSideRequest(pkt, blk);
{
Tick time = curTick + hitLatency;
MSHR *mshr = dynamic_cast<MSHR*>(pkt->senderState);
+ bool is_error = pkt->isError();
+
assert(mshr);
if (pkt->wasNacked()) {
"not implemented\n");
return;
}
- assert(!pkt->isError());
+ if (is_error) {
+ DPRINTF(Cache, "Cache received packet with error for address %x, "
+ "cmd: %s\n", pkt->getAddr(), pkt->cmdString());
+ }
+
DPRINTF(Cache, "Handling response to %x\n", pkt->getAddr());
MSHRQueue *mq = mshr->queue;
miss_latency;
}
- if (mshr->isCacheFill) {
+ if (mshr->isCacheFill && !is_error) {
DPRINTF(Cache, "Block for addr %x being updated in Cache\n",
pkt->getAddr());
} else {
// not a cache fill, just forwarding response
completion_time = tags->getHitLatency() + pkt->finishTime;
- if (pkt->isRead()) {
+ if (pkt->isRead() && !is_error) {
target->pkt->setData(pkt->getPtr<uint8_t>());
}
}
target->pkt->makeTimingResponse();
+ // if this packet is an error copy that to the new packet
+ if (is_error)
+ target->pkt->copyError(pkt);
cpuSidePort->respond(target->pkt, completion_time);
} else {
+ // I don't believe that a snoop can be in an error state
+ assert(!is_error);
// response to snoop request
DPRINTF(Cache, "processing deferred snoop...\n");
handleSnoop(target->pkt, blk, true, true);
{ SET5(IsRead, IsWrite, NeedsExclusive, IsResponse, HasData),
InvalidCmd, "SwapResp" },
/* NetworkNackError -- nacked at network layer (not by protocol) */
- { SET2(IsRequest, IsError), InvalidCmd, "NetworkNackError" },
+ { SET2(IsResponse, IsError), InvalidCmd, "NetworkNackError" },
/* InvalidDestError -- packet dest field invalid */
- { SET2(IsRequest, IsError), InvalidCmd, "InvalidDestError" },
+ { SET2(IsResponse, IsError), InvalidCmd, "InvalidDestError" },
/* BadAddressError -- memory address invalid */
- { SET2(IsRequest, IsError), InvalidCmd, "BadAddressError" }
+ { SET2(IsResponse, IsError), InvalidCmd, "BadAddressError" }
};
// Network error conditions... encapsulate them as methods since
// their encoding keeps changing (from result field to command
// field, etc.)
- void setNacked() { origCmd = cmd; cmd = MemCmd::NetworkNackError; }
- void setBadAddress() { origCmd = cmd; cmd = MemCmd::BadAddressError; }
+ void setNacked() { assert(isResponse()); cmd = MemCmd::NetworkNackError; }
+ void setBadAddress() { assert(isResponse()); cmd = MemCmd::BadAddressError; }
bool wasNacked() { return cmd == MemCmd::NetworkNackError; }
bool hadBadAddress() { return cmd == MemCmd::BadAddressError; }
+ void copyError(Packet *pkt) { assert(pkt->isError()); cmd = pkt->cmd; }
bool nic_pkt() { panic("Unimplemented"); M5_DUMMY_RETURN }
{
assert(needsResponse());
assert(isRequest());
+ origCmd = cmd;
cmd = cmd.responseCommand();
dest = src;
destValid = srcValid;