mem: Add ReadCleanReq and ReadSharedReq packets

This patch adds two new read requests packets:

ReadCleanReq - For a cache to explicitly request clean data. The
response is thus exclusive or shared, but not owned or modified. The
read-only caches (see previous patch) use this request type to ensure
they do not get dirty data.

ReadSharedReq - We add this to distinguish cache read requests from
those issued by other masters, such as devices and CPUs. Thus, devices
use ReadReq, and caches use ReadCleanReq, ReadExReq, or
ReadSharedReq. For the latter, the response can be any state, shared,
exclusive, owned or even modified.

Both ReadCleanReq and ReadSharedReq re-use the normal ReadResp. The
two transactions are aligned with the emerging cache-coherent TLM
standard and the AMBA nomenclature.

With this change, the normal ReadReq should never be used by a cache,
and is reserved for the actual (non-caching) masters in the system. We
thus have a way of identifying if a request came from a cache or
not. The introduction of ReadSharedReq thus removes the need for the
current isTopLevel hack, and also allows us to stop relying on
checking the packet size to determine if the source is a cache or
not. This is fixed in follow-on patches.
This commit is contained in:
Andreas Hansson 2015-07-03 10:14:40 -04:00
parent 893533a126
commit 0ddde83a47
4 changed files with 28 additions and 7 deletions

View file

@ -190,7 +190,8 @@ BaseCache::regStats()
// to change the subset of commands that are considered "demand" vs // to change the subset of commands that are considered "demand" vs
// "non-demand" // "non-demand"
#define SUM_DEMAND(s) \ #define SUM_DEMAND(s) \
(s[MemCmd::ReadReq] + s[MemCmd::WriteReq] + s[MemCmd::ReadExReq]) (s[MemCmd::ReadReq] + s[MemCmd::WriteReq] + \
s[MemCmd::ReadExReq] + s[MemCmd::ReadCleanReq] + s[MemCmd::ReadSharedReq])
// should writebacks be included here? prior code was inconsistent... // should writebacks be included here? prior code was inconsistent...
#define SUM_NON_DEMAND(s) \ #define SUM_NON_DEMAND(s) \

View file

@ -184,6 +184,10 @@ Cache::satisfyCpuSideRequest(PacketPtr pkt, CacheBlk *blk,
// special handling for coherent block requests from // special handling for coherent block requests from
// upper-level caches // upper-level caches
if (pkt->needsExclusive()) { if (pkt->needsExclusive()) {
// sanity check
assert(pkt->cmd == MemCmd::ReadExReq ||
pkt->cmd == MemCmd::SCUpgradeFailReq);
// if we have a dirty copy, make sure the recipient // if we have a dirty copy, make sure the recipient
// keeps it marked dirty // keeps it marked dirty
if (blk->isDirty()) { if (blk->isDirty()) {
@ -193,8 +197,9 @@ Cache::satisfyCpuSideRequest(PacketPtr pkt, CacheBlk *blk,
if (blk != tempBlock) if (blk != tempBlock)
tags->invalidate(blk); tags->invalidate(blk);
blk->invalidate(); blk->invalidate();
} else if (blk->isWritable() && !pending_downgrade } else if (blk->isWritable() && !pending_downgrade &&
&& !pkt->sharedAsserted() && !pkt->req->isInstFetch()) { !pkt->sharedAsserted() &&
pkt->cmd != MemCmd::ReadCleanReq) {
// we can give the requester an exclusive copy (by not // we can give the requester an exclusive copy (by not
// asserting shared line) on a read request if: // asserting shared line) on a read request if:
// - we have an exclusive copy at this level (& below) // - we have an exclusive copy at this level (& below)
@ -901,7 +906,8 @@ Cache::getBusPacket(PacketPtr cpu_pkt, CacheBlk *blk,
cmd = cpu_pkt->cmd; cmd = cpu_pkt->cmd;
} else { } else {
// block is invalid // block is invalid
cmd = needsExclusive ? MemCmd::ReadExReq : MemCmd::ReadReq; cmd = needsExclusive ? MemCmd::ReadExReq :
(isReadOnly ? MemCmd::ReadCleanReq : MemCmd::ReadSharedReq);
} }
PacketPtr pkt = new Packet(cpu_pkt->req, cmd, blkSize); PacketPtr pkt = new Packet(cpu_pkt->req, cmd, blkSize);

View file

@ -71,7 +71,8 @@ MemCmd::commandInfo[] =
{ {
/* InvalidCmd */ /* InvalidCmd */
{ 0, InvalidCmd, "InvalidCmd" }, { 0, InvalidCmd, "InvalidCmd" },
/* ReadReq */ /* ReadReq - Read issued by a non-caching agent such as a CPU or
* device, with no restrictions on alignment. */
{ SET3(IsRead, IsRequest, NeedsResponse), ReadResp, "ReadReq" }, { SET3(IsRead, IsRequest, NeedsResponse), ReadResp, "ReadReq" },
/* ReadResp */ /* ReadResp */
{ SET3(IsRead, IsResponse, HasData), InvalidCmd, "ReadResp" }, { SET3(IsRead, IsResponse, HasData), InvalidCmd, "ReadResp" },
@ -125,12 +126,23 @@ MemCmd::commandInfo[] =
* that it has failed, acquires line as Dirty*/ * that it has failed, acquires line as Dirty*/
{ SET4(IsRead, NeedsExclusive, IsResponse, HasData), { SET4(IsRead, NeedsExclusive, IsResponse, HasData),
InvalidCmd, "UpgradeFailResp" }, InvalidCmd, "UpgradeFailResp" },
/* ReadExReq */ /* ReadExReq - Read issues by a cache, always cache-line aligned,
* and the response is guaranteed to be writeable (exclusive or
* even modified) */
{ SET5(IsRead, NeedsExclusive, IsInvalidate, IsRequest, NeedsResponse), { SET5(IsRead, NeedsExclusive, IsInvalidate, IsRequest, NeedsResponse),
ReadExResp, "ReadExReq" }, ReadExResp, "ReadExReq" },
/* ReadExResp */ /* ReadExResp - Response matching a read exclusive, as we check
* the need for exclusive also on responses */
{ SET4(IsRead, NeedsExclusive, IsResponse, HasData), { SET4(IsRead, NeedsExclusive, IsResponse, HasData),
InvalidCmd, "ReadExResp" }, InvalidCmd, "ReadExResp" },
/* ReadCleanReq - Read issued by a cache, always cache-line
* aligned, and the response is guaranteed to not contain dirty data
* (exclusive or shared).*/
{ SET3(IsRead, IsRequest, NeedsResponse), ReadResp, "ReadCleanReq" },
/* ReadSharedReq - Read issued by a cache, always cache-line
* aligned, response is shared, possibly exclusive, owned or even
* modified. */
{ SET3(IsRead, IsRequest, NeedsResponse), ReadResp, "ReadSharedReq" },
/* LoadLockedReq: note that we use plain ReadResp as response, so that /* LoadLockedReq: note that we use plain ReadResp as response, so that
* we can also use ReadRespWithInvalidate when needed */ * we can also use ReadRespWithInvalidate when needed */
{ SET4(IsRead, IsLlsc, IsRequest, NeedsResponse), { SET4(IsRead, IsLlsc, IsRequest, NeedsResponse),

View file

@ -101,6 +101,8 @@ class MemCmd
UpgradeFailResp, // Valid for SCUpgradeReq only UpgradeFailResp, // Valid for SCUpgradeReq only
ReadExReq, ReadExReq,
ReadExResp, ReadExResp,
ReadCleanReq,
ReadSharedReq,
LoadLockedReq, LoadLockedReq,
StoreCondReq, StoreCondReq,
StoreCondFailReq, // Failed StoreCondReq in MSHR (never sent) StoreCondFailReq, // Failed StoreCondReq in MSHR (never sent)