2006-06-28 17:02:14 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2002-2005 The Regents of The University of Michigan
|
2010-08-25 23:08:27 +02:00
|
|
|
* Copyright (c) 2010 Advanced Micro Devices, Inc.
|
2006-06-28 17:02:14 +02:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer;
|
|
|
|
* redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution;
|
|
|
|
* neither the name of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* Authors: Erik Hallnor
|
|
|
|
* Dave Greene
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Miss Status and Handling Register (MSHR) definitions.
|
|
|
|
*/
|
|
|
|
|
2009-05-17 23:34:52 +02:00
|
|
|
#include <algorithm>
|
|
|
|
#include <cassert>
|
2006-06-28 17:02:14 +02:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "base/misc.hh"
|
2009-05-17 23:34:52 +02:00
|
|
|
#include "base/types.hh"
|
2011-04-15 19:44:32 +02:00
|
|
|
#include "debug/Cache.hh"
|
2006-06-28 17:02:14 +02:00
|
|
|
#include "mem/cache/cache.hh"
|
2009-05-17 23:34:52 +02:00
|
|
|
#include "mem/cache/mshr.hh"
|
|
|
|
#include "sim/core.hh"
|
2006-06-28 17:02:14 +02:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
MSHR::MSHR()
|
|
|
|
{
|
|
|
|
inService = false;
|
|
|
|
ntargets = 0;
|
2009-05-26 18:23:13 +02:00
|
|
|
threadNum = InvalidThreadID;
|
2007-07-22 03:18:42 +02:00
|
|
|
targets = new TargetList();
|
|
|
|
deferredTargets = new TargetList();
|
2006-06-28 17:02:14 +02:00
|
|
|
}
|
|
|
|
|
2007-07-22 03:18:42 +02:00
|
|
|
|
|
|
|
MSHR::TargetList::TargetList()
|
|
|
|
: needsExclusive(false), hasUpgrade(false)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
inline void
|
2007-07-23 06:43:38 +02:00
|
|
|
MSHR::TargetList::add(PacketPtr pkt, Tick readyTime,
|
2009-02-16 17:56:40 +01:00
|
|
|
Counter order, Target::Source source, bool markPending)
|
2007-07-22 03:18:42 +02:00
|
|
|
{
|
2009-02-16 17:56:40 +01:00
|
|
|
if (source != Target::FromSnoop) {
|
2007-07-22 03:18:42 +02:00
|
|
|
if (pkt->needsExclusive()) {
|
|
|
|
needsExclusive = true;
|
|
|
|
}
|
|
|
|
|
2010-09-09 20:40:19 +02:00
|
|
|
// StoreCondReq is effectively an upgrade if it's in an MSHR
|
|
|
|
// since it would have been failed already if we didn't have a
|
|
|
|
// read-only copy
|
|
|
|
if (pkt->isUpgrade() || pkt->cmd == MemCmd::StoreCondReq) {
|
2007-07-22 03:18:42 +02:00
|
|
|
hasUpgrade = true;
|
|
|
|
}
|
2008-01-03 00:18:33 +01:00
|
|
|
}
|
2007-07-23 06:43:38 +02:00
|
|
|
|
2008-01-03 00:18:33 +01:00
|
|
|
if (markPending) {
|
2007-07-23 06:43:38 +02:00
|
|
|
MSHR *mshr = dynamic_cast<MSHR*>(pkt->senderState);
|
|
|
|
if (mshr != NULL) {
|
|
|
|
assert(!mshr->downstreamPending);
|
|
|
|
mshr->downstreamPending = true;
|
|
|
|
}
|
2007-07-22 03:18:42 +02:00
|
|
|
}
|
|
|
|
|
2009-02-16 17:56:40 +01:00
|
|
|
push_back(Target(pkt, readyTime, order, source, markPending));
|
2007-07-22 03:18:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-09 20:40:18 +02:00
|
|
|
static void
|
|
|
|
replaceUpgrade(PacketPtr pkt)
|
|
|
|
{
|
|
|
|
if (pkt->cmd == MemCmd::UpgradeReq) {
|
|
|
|
pkt->cmd = MemCmd::ReadExReq;
|
|
|
|
DPRINTF(Cache, "Replacing UpgradeReq with ReadExReq\n");
|
|
|
|
} else if (pkt->cmd == MemCmd::SCUpgradeReq) {
|
|
|
|
pkt->cmd = MemCmd::SCUpgradeFailReq;
|
|
|
|
DPRINTF(Cache, "Replacing SCUpgradeReq with SCUpgradeFailReq\n");
|
2010-09-09 20:40:19 +02:00
|
|
|
} else if (pkt->cmd == MemCmd::StoreCondReq) {
|
|
|
|
pkt->cmd = MemCmd::StoreCondFailReq;
|
|
|
|
DPRINTF(Cache, "Replacing StoreCondReq with StoreCondFailReq\n");
|
2010-09-09 20:40:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-22 03:18:42 +02:00
|
|
|
void
|
|
|
|
MSHR::TargetList::replaceUpgrades()
|
|
|
|
{
|
|
|
|
if (!hasUpgrade)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Iterator end_i = end();
|
|
|
|
for (Iterator i = begin(); i != end_i; ++i) {
|
2010-09-09 20:40:18 +02:00
|
|
|
replaceUpgrade(i->pkt);
|
2007-07-22 03:18:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hasUpgrade = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-23 06:43:38 +02:00
|
|
|
void
|
|
|
|
MSHR::TargetList::clearDownstreamPending()
|
|
|
|
{
|
|
|
|
Iterator end_i = end();
|
|
|
|
for (Iterator i = begin(); i != end_i; ++i) {
|
2008-01-03 00:18:33 +01:00
|
|
|
if (i->markedPending) {
|
|
|
|
MSHR *mshr = dynamic_cast<MSHR*>(i->pkt->senderState);
|
|
|
|
if (mshr != NULL) {
|
|
|
|
mshr->clearDownstreamPending();
|
|
|
|
}
|
2007-07-23 06:43:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-27 21:46:45 +02:00
|
|
|
bool
|
|
|
|
MSHR::TargetList::checkFunctional(PacketPtr pkt)
|
|
|
|
{
|
|
|
|
Iterator end_i = end();
|
|
|
|
for (Iterator i = begin(); i != end_i; ++i) {
|
|
|
|
if (pkt->checkFunctional(i->pkt)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-02 21:20:15 +01:00
|
|
|
void
|
|
|
|
MSHR::TargetList::
|
|
|
|
print(std::ostream &os, int verbosity, const std::string &prefix) const
|
|
|
|
{
|
|
|
|
ConstIterator end_i = end();
|
|
|
|
for (ConstIterator i = begin(); i != end_i; ++i) {
|
2009-02-16 17:56:40 +01:00
|
|
|
const char *s;
|
|
|
|
switch (i->source) {
|
2012-05-11 01:04:26 +02:00
|
|
|
case Target::FromCPU:
|
|
|
|
s = "FromCPU";
|
|
|
|
break;
|
|
|
|
case Target::FromSnoop:
|
|
|
|
s = "FromSnoop";
|
|
|
|
break;
|
|
|
|
case Target::FromPrefetcher:
|
|
|
|
s = "FromPrefetcher";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
s = "";
|
|
|
|
break;
|
2009-02-16 17:56:40 +01:00
|
|
|
}
|
|
|
|
ccprintf(os, "%s%s: ", prefix, s);
|
2008-01-02 21:20:15 +01:00
|
|
|
i->pkt->print(os, verbosity, "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-28 17:02:14 +02:00
|
|
|
void
|
2007-06-25 15:47:05 +02:00
|
|
|
MSHR::allocate(Addr _addr, int _size, PacketPtr target,
|
2007-06-30 22:34:16 +02:00
|
|
|
Tick whenReady, Counter _order)
|
2006-06-28 17:02:14 +02:00
|
|
|
{
|
2006-07-10 23:16:15 +02:00
|
|
|
addr = _addr;
|
2007-06-18 02:27:53 +02:00
|
|
|
size = _size;
|
2007-06-30 22:34:16 +02:00
|
|
|
readyTime = whenReady;
|
2007-06-25 15:47:05 +02:00
|
|
|
order = _order;
|
2007-06-18 02:27:53 +02:00
|
|
|
assert(target);
|
2008-11-10 23:10:28 +01:00
|
|
|
isForward = false;
|
2007-06-18 02:27:53 +02:00
|
|
|
_isUncacheable = target->req->isUncacheable();
|
|
|
|
inService = false;
|
2007-07-23 06:43:38 +02:00
|
|
|
downstreamPending = false;
|
2007-06-18 02:27:53 +02:00
|
|
|
threadNum = 0;
|
|
|
|
ntargets = 1;
|
2007-07-22 03:18:42 +02:00
|
|
|
assert(targets->isReset());
|
2009-02-16 17:56:40 +01:00
|
|
|
// Don't know of a case where we would allocate a new MSHR for a
|
|
|
|
// snoop (mem-side request), so set source according to request here
|
|
|
|
Target::Source source = (target->cmd == MemCmd::HardPFReq) ?
|
|
|
|
Target::FromPrefetcher : Target::FromCPU;
|
|
|
|
targets->add(target, whenReady, _order, source, true);
|
2007-07-22 03:18:42 +02:00
|
|
|
assert(deferredTargets->isReset());
|
2007-06-26 23:53:15 +02:00
|
|
|
data = NULL;
|
2006-06-28 17:02:14 +02:00
|
|
|
}
|
|
|
|
|
2007-07-23 06:43:38 +02:00
|
|
|
|
2008-01-03 00:18:33 +01:00
|
|
|
void
|
|
|
|
MSHR::clearDownstreamPending()
|
|
|
|
{
|
|
|
|
assert(downstreamPending);
|
|
|
|
downstreamPending = false;
|
|
|
|
// recursively clear flag on any MSHRs we will be forwarding
|
|
|
|
// responses to
|
|
|
|
targets->clearDownstreamPending();
|
|
|
|
}
|
|
|
|
|
2007-07-23 06:43:38 +02:00
|
|
|
bool
|
2010-09-09 20:40:18 +02:00
|
|
|
MSHR::markInService(PacketPtr pkt)
|
2007-07-23 06:43:38 +02:00
|
|
|
{
|
|
|
|
assert(!inService);
|
2008-11-10 23:10:28 +01:00
|
|
|
if (isForwardNoResponse()) {
|
2007-07-23 06:43:38 +02:00
|
|
|
// we just forwarded the request packet & don't expect a
|
|
|
|
// response, so get rid of it
|
|
|
|
assert(getNumTargets() == 1);
|
|
|
|
popTarget();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
inService = true;
|
2010-09-09 20:40:18 +02:00
|
|
|
pendingDirty = (targets->needsExclusive ||
|
|
|
|
(!pkt->sharedAsserted() && pkt->memInhibitAsserted()));
|
|
|
|
postInvalidate = postDowngrade = false;
|
|
|
|
|
2007-07-23 06:43:38 +02:00
|
|
|
if (!downstreamPending) {
|
|
|
|
// let upstream caches know that the request has made it to a
|
|
|
|
// level where it's going to get a response
|
|
|
|
targets->clearDownstreamPending();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-28 17:02:14 +02:00
|
|
|
void
|
|
|
|
MSHR::deallocate()
|
|
|
|
{
|
2007-07-22 03:18:42 +02:00
|
|
|
assert(targets->empty());
|
|
|
|
targets->resetFlags();
|
|
|
|
assert(deferredTargets->isReset());
|
2006-06-28 17:02:14 +02:00
|
|
|
assert(ntargets == 0);
|
|
|
|
inService = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Adds a target to an MSHR
|
|
|
|
*/
|
|
|
|
void
|
2007-07-22 03:18:42 +02:00
|
|
|
MSHR::allocateTarget(PacketPtr pkt, Tick whenReady, Counter _order)
|
2006-06-28 17:02:14 +02:00
|
|
|
{
|
2007-07-22 03:18:42 +02:00
|
|
|
// if there's a request already in service for this MSHR, we will
|
|
|
|
// have to defer the new target until after the response if any of
|
|
|
|
// the following are true:
|
|
|
|
// - there are other targets already deferred
|
|
|
|
// - there's a pending invalidate to be applied after the response
|
|
|
|
// comes back (but before this target is processed)
|
2010-09-09 20:40:18 +02:00
|
|
|
// - this target requires an exclusive block and either we're not
|
|
|
|
// getting an exclusive block back or we have already snooped
|
|
|
|
// another read request that will downgrade our exclusive block
|
|
|
|
// to shared
|
2009-02-16 17:56:40 +01:00
|
|
|
|
|
|
|
// assume we'd never issue a prefetch when we've got an
|
|
|
|
// outstanding miss
|
|
|
|
assert(pkt->cmd != MemCmd::HardPFReq);
|
|
|
|
|
2007-07-22 03:18:42 +02:00
|
|
|
if (inService &&
|
2010-09-09 20:40:18 +02:00
|
|
|
(!deferredTargets->empty() || hasPostInvalidate() ||
|
|
|
|
(pkt->needsExclusive() &&
|
|
|
|
(!isPendingDirty() || hasPostDowngrade() || isForward)))) {
|
2007-07-22 03:18:42 +02:00
|
|
|
// need to put on deferred list
|
2010-09-09 20:40:18 +02:00
|
|
|
if (hasPostInvalidate())
|
|
|
|
replaceUpgrade(pkt);
|
2009-02-16 17:56:40 +01:00
|
|
|
deferredTargets->add(pkt, whenReady, _order, Target::FromCPU, true);
|
2007-06-25 02:32:31 +02:00
|
|
|
} else {
|
2008-01-03 00:18:33 +01:00
|
|
|
// No request outstanding, or still OK to append to
|
|
|
|
// outstanding request: append to regular target list. Only
|
|
|
|
// mark pending if current request hasn't been issued yet
|
|
|
|
// (isn't in service).
|
2009-02-16 17:56:40 +01:00
|
|
|
targets->add(pkt, whenReady, _order, Target::FromCPU, !inService);
|
2007-06-25 02:32:31 +02:00
|
|
|
}
|
2006-06-28 17:02:14 +02:00
|
|
|
|
2007-06-25 02:32:31 +02:00
|
|
|
++ntargets;
|
|
|
|
}
|
|
|
|
|
2007-07-21 22:45:17 +02:00
|
|
|
bool
|
|
|
|
MSHR::handleSnoop(PacketPtr pkt, Counter _order)
|
2007-06-25 02:32:31 +02:00
|
|
|
{
|
2007-07-24 07:28:40 +02:00
|
|
|
if (!inService || (pkt->isExpressSnoop() && downstreamPending)) {
|
2007-07-22 03:18:42 +02:00
|
|
|
// Request has not been issued yet, or it's been issued
|
|
|
|
// locally but is buffered unissued at some downstream cache
|
|
|
|
// which is forwarding us this snoop. Either way, the packet
|
|
|
|
// we're snooping logically precedes this MSHR's request, so
|
|
|
|
// the snoop has no impact on the MSHR, but must be processed
|
|
|
|
// in the standard way by the cache. The only exception is
|
|
|
|
// that if we're an L2+ cache buffering an UpgradeReq from a
|
|
|
|
// higher-level cache, and the snoop is invalidating, then our
|
|
|
|
// buffered upgrades must be converted to read exclusives,
|
|
|
|
// since the upper-level cache no longer has a valid copy.
|
|
|
|
// That is, even though the upper-level cache got out on its
|
|
|
|
// local bus first, some other invalidating transaction
|
|
|
|
// reached the global bus before the upgrade did.
|
|
|
|
if (pkt->needsExclusive()) {
|
|
|
|
targets->replaceUpgrades();
|
|
|
|
deferredTargets->replaceUpgrades();
|
|
|
|
}
|
|
|
|
|
2007-07-21 22:45:17 +02:00
|
|
|
return false;
|
|
|
|
}
|
2007-06-25 02:32:31 +02:00
|
|
|
|
2007-07-22 03:18:42 +02:00
|
|
|
// From here on down, the request issued by this MSHR logically
|
|
|
|
// precedes the request we're snooping.
|
|
|
|
if (pkt->needsExclusive()) {
|
|
|
|
// snooped request still precedes the re-request we'll have to
|
|
|
|
// issue for deferred targets, if any...
|
|
|
|
deferredTargets->replaceUpgrades();
|
|
|
|
}
|
|
|
|
|
2010-09-09 20:40:18 +02:00
|
|
|
if (hasPostInvalidate()) {
|
2007-06-25 02:32:31 +02:00
|
|
|
// a prior snoop has already appended an invalidation, so
|
2007-07-22 03:18:42 +02:00
|
|
|
// logically we don't have the block anymore; no need for
|
|
|
|
// further snooping.
|
2007-07-21 22:45:17 +02:00
|
|
|
return true;
|
2006-06-28 17:02:14 +02:00
|
|
|
}
|
2007-06-25 02:32:31 +02:00
|
|
|
|
2010-09-09 20:40:18 +02:00
|
|
|
if (isPendingDirty() || pkt->isInvalidate()) {
|
|
|
|
// We need to save and replay the packet in two cases:
|
|
|
|
// 1. We're awaiting an exclusive copy, so ownership is pending,
|
|
|
|
// and we need to respond after we receive data.
|
|
|
|
// 2. It's an invalidation (e.g., UpgradeReq), and we need
|
|
|
|
// to forward the snoop up the hierarchy after the current
|
|
|
|
// transaction completes.
|
|
|
|
|
2012-04-06 19:46:31 +02:00
|
|
|
// Actual target device (typ. a memory) will delete the
|
2010-09-09 20:40:18 +02:00
|
|
|
// packet on reception, so we need to save a copy here.
|
2007-08-13 01:43:54 +02:00
|
|
|
PacketPtr cp_pkt = new Packet(pkt, true);
|
2011-01-08 06:50:29 +01:00
|
|
|
targets->add(cp_pkt, curTick(), _order, Target::FromSnoop,
|
2008-01-03 00:18:33 +01:00
|
|
|
downstreamPending && targets->needsExclusive);
|
2007-06-27 07:23:10 +02:00
|
|
|
++ntargets;
|
|
|
|
|
2010-09-09 20:40:18 +02:00
|
|
|
if (isPendingDirty()) {
|
2007-06-27 07:23:10 +02:00
|
|
|
pkt->assertMemInhibit();
|
2007-07-27 02:04:17 +02:00
|
|
|
pkt->setSupplyExclusive();
|
2007-06-27 07:23:10 +02:00
|
|
|
}
|
2007-06-26 07:23:29 +02:00
|
|
|
|
2007-06-27 07:23:10 +02:00
|
|
|
if (pkt->needsExclusive()) {
|
|
|
|
// This transaction will take away our pending copy
|
2010-09-09 20:40:18 +02:00
|
|
|
postInvalidate = true;
|
2007-06-27 07:23:10 +02:00
|
|
|
}
|
2010-09-09 20:40:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!pkt->needsExclusive()) {
|
|
|
|
// This transaction will get a read-shared copy, downgrading
|
|
|
|
// our copy if we had an exclusive one
|
|
|
|
postDowngrade = true;
|
2007-06-27 07:23:10 +02:00
|
|
|
pkt->assertShared();
|
2006-06-28 17:02:14 +02:00
|
|
|
}
|
2007-07-21 22:45:17 +02:00
|
|
|
|
|
|
|
return true;
|
2007-06-25 02:32:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
MSHR::promoteDeferredTargets()
|
|
|
|
{
|
2007-07-22 03:18:42 +02:00
|
|
|
assert(targets->empty());
|
|
|
|
if (deferredTargets->empty()) {
|
2007-06-25 02:32:31 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-07-22 03:18:42 +02:00
|
|
|
// swap targets & deferredTargets lists
|
|
|
|
TargetList *tmp = targets;
|
2007-06-25 02:32:31 +02:00
|
|
|
targets = deferredTargets;
|
2007-07-22 03:18:42 +02:00
|
|
|
deferredTargets = tmp;
|
|
|
|
|
|
|
|
assert(targets->size() == ntargets);
|
|
|
|
|
|
|
|
// clear deferredTargets flags
|
|
|
|
deferredTargets->resetFlags();
|
2006-06-28 17:02:14 +02:00
|
|
|
|
2007-07-22 03:18:42 +02:00
|
|
|
order = targets->front().order;
|
2011-01-08 06:50:29 +01:00
|
|
|
readyTime = std::max(curTick(), targets->front().readyTime);
|
2007-06-25 02:32:31 +02:00
|
|
|
|
|
|
|
return true;
|
2006-06-28 17:02:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-26 23:53:15 +02:00
|
|
|
void
|
2007-06-27 07:23:10 +02:00
|
|
|
MSHR::handleFill(Packet *pkt, CacheBlk *blk)
|
2007-06-26 23:53:15 +02:00
|
|
|
{
|
2010-09-09 20:40:18 +02:00
|
|
|
if (!pkt->sharedAsserted()
|
|
|
|
&& !(hasPostInvalidate() || hasPostDowngrade())
|
2007-11-17 05:10:32 +01:00
|
|
|
&& deferredTargets->needsExclusive) {
|
|
|
|
// We got an exclusive response, but we have deferred targets
|
|
|
|
// which are waiting to request an exclusive copy (not because
|
|
|
|
// of a pending invalidate). This can happen if the original
|
|
|
|
// request was for a read-only (non-exclusive) block, but we
|
|
|
|
// got an exclusive copy anyway because of the E part of the
|
|
|
|
// MOESI/MESI protocol. Since we got the exclusive copy
|
|
|
|
// there's no need to defer the targets, so move them up to
|
|
|
|
// the regular target list.
|
|
|
|
assert(!targets->needsExclusive);
|
|
|
|
targets->needsExclusive = true;
|
2008-01-03 00:18:33 +01:00
|
|
|
// if any of the deferred targets were upper-level cache
|
|
|
|
// requests marked downstreamPending, need to clear that
|
|
|
|
assert(!downstreamPending); // not pending here anymore
|
|
|
|
deferredTargets->clearDownstreamPending();
|
2007-11-17 05:10:32 +01:00
|
|
|
// this clears out deferredTargets too
|
|
|
|
targets->splice(targets->end(), *deferredTargets);
|
|
|
|
deferredTargets->resetFlags();
|
|
|
|
}
|
2007-06-26 23:53:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-02 21:20:15 +01:00
|
|
|
bool
|
|
|
|
MSHR::checkFunctional(PacketPtr pkt)
|
|
|
|
{
|
|
|
|
// For printing, we treat the MSHR as a whole as single entity.
|
|
|
|
// For other requests, we iterate over the individual targets
|
|
|
|
// since that's where the actual data lies.
|
|
|
|
if (pkt->isPrint()) {
|
|
|
|
pkt->checkFunctional(this, addr, size, NULL);
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return (targets->checkFunctional(pkt) ||
|
|
|
|
deferredTargets->checkFunctional(pkt));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-28 17:02:14 +02:00
|
|
|
void
|
2008-01-02 21:20:15 +01:00
|
|
|
MSHR::print(std::ostream &os, int verbosity, const std::string &prefix) const
|
2006-06-28 17:02:14 +02:00
|
|
|
{
|
2008-01-02 21:20:15 +01:00
|
|
|
ccprintf(os, "%s[%x:%x] %s %s %s state: %s %s %s %s\n",
|
|
|
|
prefix, addr, addr+size-1,
|
2008-11-10 23:10:28 +01:00
|
|
|
isForward ? "Forward" : "",
|
|
|
|
isForwardNoResponse() ? "ForwNoResp" : "",
|
2008-01-02 21:20:15 +01:00
|
|
|
needsExclusive() ? "Excl" : "",
|
|
|
|
_isUncacheable ? "Unc" : "",
|
|
|
|
inService ? "InSvc" : "",
|
|
|
|
downstreamPending ? "DwnPend" : "",
|
2010-09-09 20:40:18 +02:00
|
|
|
hasPostInvalidate() ? "PostInv" : "",
|
|
|
|
hasPostDowngrade() ? "PostDowngr" : "");
|
2008-01-02 21:20:15 +01:00
|
|
|
|
|
|
|
ccprintf(os, "%s Targets:\n", prefix);
|
|
|
|
targets->print(os, verbosity, prefix + " ");
|
|
|
|
if (!deferredTargets->empty()) {
|
|
|
|
ccprintf(os, "%s Deferred Targets:\n", prefix);
|
|
|
|
deferredTargets->print(os, verbosity, prefix + " ");
|
2006-06-28 17:02:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MSHR::~MSHR()
|
|
|
|
{
|
2012-07-09 18:35:30 +02:00
|
|
|
delete[] targets;
|
|
|
|
delete[] deferredTargets;
|
2006-06-28 17:02:14 +02:00
|
|
|
}
|