This patch looks at the request and response command to determine if
either actually has any data payload, and if not, we do not allocate
any space for packet data.
The only tricky case is where the command type is changed as part of
the MSHR functionality. In these cases where the original packet had
no data, but the new packet does, we need to explicitly call
allocate().
if (pkt->isLLSC()) {
blk->trackLoadLocked(pkt);
}
if (pkt->isLLSC()) {
blk->trackLoadLocked(pkt);
}
+
+ // all read responses have a data payload
+ assert(pkt->hasRespData());
pkt->setDataFromBlock(blk->data, blkSize);
pkt->setDataFromBlock(blk->data, blkSize);
// determine if this read is from a (coherent) cache, or not
// by looking at the command type; we could potentially add a
// packet attribute such as 'FromCache' to make this check a
// determine if this read is from a (coherent) cache, or not
// by looking at the command type; we could potentially add a
// packet attribute such as 'FromCache' to make this check a
}
pkt->makeTimingResponse();
}
pkt->makeTimingResponse();
- // for debugging, set all the bits in the response data
- // (also keeps valgrind from complaining when debugging settings
- // print out instruction results)
- std::memset(pkt->getPtr<uint8_t>(), 0xFF, pkt->getSize());
// request_time is used here, taking into account lat and the delay
// charged if the packet comes from the xbar.
cpuSidePort->schedTimingResp(pkt, request_time, true);
// request_time is used here, taking into account lat and the delay
// charged if the packet comes from the xbar.
cpuSidePort->schedTimingResp(pkt, request_time, true);
doTimingSupplyResponse(pkt, blk->data, is_deferred, pending_inval);
} else {
pkt->makeAtomicResponse();
doTimingSupplyResponse(pkt, blk->data, is_deferred, pending_inval);
} else {
pkt->makeAtomicResponse();
- pkt->setDataFromBlock(blk->data, blkSize);
+ // packets such as upgrades do not actually have any data
+ // payload
+ if (pkt->hasData())
+ pkt->setDataFromBlock(blk->data, blkSize);
static void
replaceUpgrade(PacketPtr pkt)
{
static void
replaceUpgrade(PacketPtr pkt)
{
+ // remember if the current packet has data allocated
+ bool has_data = pkt->hasData() || pkt->hasRespData();
+
if (pkt->cmd == MemCmd::UpgradeReq) {
pkt->cmd = MemCmd::ReadExReq;
DPRINTF(Cache, "Replacing UpgradeReq with ReadExReq\n");
if (pkt->cmd == MemCmd::UpgradeReq) {
pkt->cmd = MemCmd::ReadExReq;
DPRINTF(Cache, "Replacing UpgradeReq with ReadExReq\n");
pkt->cmd = MemCmd::StoreCondFailReq;
DPRINTF(Cache, "Replacing StoreCondReq with StoreCondFailReq\n");
}
pkt->cmd = MemCmd::StoreCondFailReq;
DPRINTF(Cache, "Replacing StoreCondReq with StoreCondFailReq\n");
}
+
+ if (!has_data) {
+ // there is no sensible way of setting the data field if the
+ // new command actually would carry data
+ assert(!pkt->hasData());
+
+ if (pkt->hasRespData()) {
+ // we went from a packet that had no data (neither request,
+ // nor response), to one that does, and therefore we need to
+ // actually allocate space for the data payload
+ pkt->allocate();
+ }
+ }
bool isEviction() const { return cmd.isEviction(); }
bool isWriteback() const { return cmd.isWriteback(); }
bool hasData() const { return cmd.hasData(); }
bool isEviction() const { return cmd.isEviction(); }
bool isWriteback() const { return cmd.isWriteback(); }
bool hasData() const { return cmd.hasData(); }
+ bool hasRespData() const
+ {
+ MemCmd resp_cmd = cmd.responseCommand();
+ return resp_cmd.hasData();
+ }
bool isLLSC() const { return cmd.isLLSC(); }
bool isError() const { return cmd.isError(); }
bool isPrint() const { return cmd.isPrint(); }
bool isLLSC() const { return cmd.isLLSC(); }
bool isError() const { return cmd.isError(); }
bool isPrint() const { return cmd.isPrint(); }
- assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA));
- flags.set(DYNAMIC_DATA);
- data = new uint8_t[getSize()];
+ // if either this command or the response command has a data
+ // payload, actually allocate space
+ if (hasData() || hasRespData()) {
+ assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA));
+ flags.set(DYNAMIC_DATA);
+ data = new uint8_t[getSize()];
+ }