base.cc revision 13376
12810SN/A/* 212724Snikos.nikoleris@arm.com * Copyright (c) 2012-2013, 2018 ARM Limited 38856Sandreas.hansson@arm.com * All rights reserved. 48856Sandreas.hansson@arm.com * 58856Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall 68856Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual 78856Sandreas.hansson@arm.com * property including but not limited to intellectual property relating 88856Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software 98856Sandreas.hansson@arm.com * licensed hereunder. You may use the software subject to the license 108856Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated 118856Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software, 128856Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form. 138856Sandreas.hansson@arm.com * 142810SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan 152810SN/A * All rights reserved. 162810SN/A * 172810SN/A * Redistribution and use in source and binary forms, with or without 182810SN/A * modification, are permitted provided that the following conditions are 192810SN/A * met: redistributions of source code must retain the above copyright 202810SN/A * notice, this list of conditions and the following disclaimer; 212810SN/A * redistributions in binary form must reproduce the above copyright 222810SN/A * notice, this list of conditions and the following disclaimer in the 232810SN/A * documentation and/or other materials provided with the distribution; 242810SN/A * neither the name of the copyright holders nor the names of its 252810SN/A * contributors may be used to endorse or promote products derived from 262810SN/A * this software without specific prior written permission. 272810SN/A * 282810SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 292810SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 302810SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 312810SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 322810SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 332810SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 342810SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 352810SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 362810SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 372810SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 382810SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 392810SN/A * 402810SN/A * Authors: Erik Hallnor 4112724Snikos.nikoleris@arm.com * Nikos Nikoleris 422810SN/A */ 432810SN/A 442810SN/A/** 452810SN/A * @file 462810SN/A * Definition of BaseCache functions. 472810SN/A */ 482810SN/A 4911486Snikos.nikoleris@arm.com#include "mem/cache/base.hh" 5011486Snikos.nikoleris@arm.com 5112724Snikos.nikoleris@arm.com#include "base/compiler.hh" 5212724Snikos.nikoleris@arm.com#include "base/logging.hh" 538232Snate@binkert.org#include "debug/Cache.hh" 5412724Snikos.nikoleris@arm.com#include "debug/CachePort.hh" 5513222Sodanrc@yahoo.com.br#include "debug/CacheRepl.hh" 5612724Snikos.nikoleris@arm.com#include "debug/CacheVerbose.hh" 5711486Snikos.nikoleris@arm.com#include "mem/cache/mshr.hh" 5812724Snikos.nikoleris@arm.com#include "mem/cache/prefetch/base.hh" 5912724Snikos.nikoleris@arm.com#include "mem/cache/queue_entry.hh" 6012724Snikos.nikoleris@arm.com#include "params/BaseCache.hh" 6113352Snikos.nikoleris@arm.com#include "params/WriteAllocator.hh" 6212724Snikos.nikoleris@arm.com#include "sim/core.hh" 6312724Snikos.nikoleris@arm.com 6412724Snikos.nikoleris@arm.comclass BaseMasterPort; 6512724Snikos.nikoleris@arm.comclass BaseSlavePort; 662810SN/A 672810SN/Ausing namespace std; 682810SN/A 698856Sandreas.hansson@arm.comBaseCache::CacheSlavePort::CacheSlavePort(const std::string &_name, 708856Sandreas.hansson@arm.com BaseCache *_cache, 718856Sandreas.hansson@arm.com const std::string &_label) 728922Swilliam.wang@arm.com : QueuedSlavePort(_name, _cache, queue), queue(*_cache, *this, _label), 7312084Sspwilson2@wisc.edu blocked(false), mustSendRetry(false), 7412084Sspwilson2@wisc.edu sendRetryEvent([this]{ processSendRetry(); }, _name) 758856Sandreas.hansson@arm.com{ 768856Sandreas.hansson@arm.com} 774475SN/A 7811053Sandreas.hansson@arm.comBaseCache::BaseCache(const BaseCacheParams *p, unsigned blk_size) 795034SN/A : MemObject(p), 8012724Snikos.nikoleris@arm.com cpuSidePort (p->name + ".cpu_side", this, "CpuSidePort"), 8112724Snikos.nikoleris@arm.com memSidePort(p->name + ".mem_side", this, "MemSidePort"), 8211377Sandreas.hansson@arm.com mshrQueue("MSHRs", p->mshrs, 0, p->demand_mshr_reserve), // see below 8311377Sandreas.hansson@arm.com writeBuffer("write buffer", p->write_buffers, p->mshrs), // see below 8412724Snikos.nikoleris@arm.com tags(p->tags), 8512724Snikos.nikoleris@arm.com prefetcher(p->prefetcher), 8612724Snikos.nikoleris@arm.com prefetchOnAccess(p->prefetch_on_access), 8713352Snikos.nikoleris@arm.com writeAllocator(p->write_allocator), 8812724Snikos.nikoleris@arm.com writebackClean(p->writeback_clean), 8912724Snikos.nikoleris@arm.com tempBlockWriteback(nullptr), 9012724Snikos.nikoleris@arm.com writebackTempBlockAtomicEvent([this]{ writebackTempBlockAtomic(); }, 9112724Snikos.nikoleris@arm.com name(), false, 9212724Snikos.nikoleris@arm.com EventBase::Delayed_Writeback_Pri), 9311053Sandreas.hansson@arm.com blkSize(blk_size), 9411722Ssophiane.senni@gmail.com lookupLatency(p->tag_latency), 9511722Ssophiane.senni@gmail.com dataLatency(p->data_latency), 9611722Ssophiane.senni@gmail.com forwardLatency(p->tag_latency), 9711722Ssophiane.senni@gmail.com fillLatency(p->data_latency), 989263Smrinmoy.ghosh@arm.com responseLatency(p->response_latency), 995034SN/A numTarget(p->tgts_per_mshr), 10011331Sandreas.hansson@arm.com forwardSnoops(true), 10112724Snikos.nikoleris@arm.com clusivity(p->clusivity), 10210884Sandreas.hansson@arm.com isReadOnly(p->is_read_only), 1034626SN/A blocked(0), 10410360Sandreas.hansson@arm.com order(0), 10511484Snikos.nikoleris@arm.com noTargetMSHR(nullptr), 1065034SN/A missCount(p->max_miss_count), 1078883SAli.Saidi@ARM.com addrRanges(p->addr_ranges.begin(), p->addr_ranges.end()), 1088833Sdam.sunwoo@arm.com system(p->system) 1094458SN/A{ 11011377Sandreas.hansson@arm.com // the MSHR queue has no reserve entries as we check the MSHR 11111377Sandreas.hansson@arm.com // queue on every single allocation, whereas the write queue has 11211377Sandreas.hansson@arm.com // as many reserve entries as we have MSHRs, since every MSHR may 11311377Sandreas.hansson@arm.com // eventually require a writeback, and we do not check the write 11411377Sandreas.hansson@arm.com // buffer before committing to an MSHR 11511377Sandreas.hansson@arm.com 11611331Sandreas.hansson@arm.com // forward snoops is overridden in init() once we can query 11711331Sandreas.hansson@arm.com // whether the connected master is actually snooping or not 11812724Snikos.nikoleris@arm.com 11912843Srmk35@cl.cam.ac.uk tempBlock = new TempCacheBlk(blkSize); 12012724Snikos.nikoleris@arm.com 12113216Sodanrc@yahoo.com.br tags->init(this); 12212724Snikos.nikoleris@arm.com if (prefetcher) 12312724Snikos.nikoleris@arm.com prefetcher->setCache(this); 12412724Snikos.nikoleris@arm.com} 12512724Snikos.nikoleris@arm.com 12612724Snikos.nikoleris@arm.comBaseCache::~BaseCache() 12712724Snikos.nikoleris@arm.com{ 12812724Snikos.nikoleris@arm.com delete tempBlock; 1292810SN/A} 1302810SN/A 1313013SN/Avoid 1328856Sandreas.hansson@arm.comBaseCache::CacheSlavePort::setBlocked() 1332810SN/A{ 1343013SN/A assert(!blocked); 13510714Sandreas.hansson@arm.com DPRINTF(CachePort, "Port is blocking new requests\n"); 1362810SN/A blocked = true; 1379614Srene.dejong@arm.com // if we already scheduled a retry in this cycle, but it has not yet 1389614Srene.dejong@arm.com // happened, cancel it 1399614Srene.dejong@arm.com if (sendRetryEvent.scheduled()) { 14010345SCurtis.Dunham@arm.com owner.deschedule(sendRetryEvent); 14110714Sandreas.hansson@arm.com DPRINTF(CachePort, "Port descheduled retry\n"); 14210345SCurtis.Dunham@arm.com mustSendRetry = true; 1439614Srene.dejong@arm.com } 1442810SN/A} 1452810SN/A 1462810SN/Avoid 1478856Sandreas.hansson@arm.comBaseCache::CacheSlavePort::clearBlocked() 1482810SN/A{ 1493013SN/A assert(blocked); 15010714Sandreas.hansson@arm.com DPRINTF(CachePort, "Port is accepting new requests\n"); 1513013SN/A blocked = false; 1528856Sandreas.hansson@arm.com if (mustSendRetry) { 15310714Sandreas.hansson@arm.com // @TODO: need to find a better time (next cycle?) 1548922Swilliam.wang@arm.com owner.schedule(sendRetryEvent, curTick() + 1); 1552897SN/A } 1562810SN/A} 1572810SN/A 15810344Sandreas.hansson@arm.comvoid 15910344Sandreas.hansson@arm.comBaseCache::CacheSlavePort::processSendRetry() 16010344Sandreas.hansson@arm.com{ 16110714Sandreas.hansson@arm.com DPRINTF(CachePort, "Port is sending retry\n"); 16210344Sandreas.hansson@arm.com 16310344Sandreas.hansson@arm.com // reset the flag and call retry 16410344Sandreas.hansson@arm.com mustSendRetry = false; 16510713Sandreas.hansson@arm.com sendRetryReq(); 16610344Sandreas.hansson@arm.com} 1672844SN/A 16812730Sodanrc@yahoo.com.brAddr 16912730Sodanrc@yahoo.com.brBaseCache::regenerateBlkAddr(CacheBlk* blk) 17012730Sodanrc@yahoo.com.br{ 17112730Sodanrc@yahoo.com.br if (blk != tempBlock) { 17212730Sodanrc@yahoo.com.br return tags->regenerateBlkAddr(blk); 17312730Sodanrc@yahoo.com.br } else { 17412730Sodanrc@yahoo.com.br return tempBlock->getAddr(); 17512730Sodanrc@yahoo.com.br } 17612730Sodanrc@yahoo.com.br} 17712730Sodanrc@yahoo.com.br 1782810SN/Avoid 1792858SN/ABaseCache::init() 1802858SN/A{ 18112724Snikos.nikoleris@arm.com if (!cpuSidePort.isConnected() || !memSidePort.isConnected()) 1828922Swilliam.wang@arm.com fatal("Cache ports on %s are not connected\n", name()); 18312724Snikos.nikoleris@arm.com cpuSidePort.sendRangeChange(); 18412724Snikos.nikoleris@arm.com forwardSnoops = cpuSidePort.isSnooping(); 1852858SN/A} 1862858SN/A 1879294Sandreas.hansson@arm.comBaseMasterPort & 1889294Sandreas.hansson@arm.comBaseCache::getMasterPort(const std::string &if_name, PortID idx) 1898922Swilliam.wang@arm.com{ 1908922Swilliam.wang@arm.com if (if_name == "mem_side") { 19112724Snikos.nikoleris@arm.com return memSidePort; 1928922Swilliam.wang@arm.com } else { 1938922Swilliam.wang@arm.com return MemObject::getMasterPort(if_name, idx); 1948922Swilliam.wang@arm.com } 1958922Swilliam.wang@arm.com} 1968922Swilliam.wang@arm.com 1979294Sandreas.hansson@arm.comBaseSlavePort & 1989294Sandreas.hansson@arm.comBaseCache::getSlavePort(const std::string &if_name, PortID idx) 1998922Swilliam.wang@arm.com{ 2008922Swilliam.wang@arm.com if (if_name == "cpu_side") { 20112724Snikos.nikoleris@arm.com return cpuSidePort; 2028922Swilliam.wang@arm.com } else { 2038922Swilliam.wang@arm.com return MemObject::getSlavePort(if_name, idx); 2048922Swilliam.wang@arm.com } 2058922Swilliam.wang@arm.com} 2064628SN/A 20710821Sandreas.hansson@arm.combool 20810821Sandreas.hansson@arm.comBaseCache::inRange(Addr addr) const 20910821Sandreas.hansson@arm.com{ 21010821Sandreas.hansson@arm.com for (const auto& r : addrRanges) { 21110821Sandreas.hansson@arm.com if (r.contains(addr)) { 21210821Sandreas.hansson@arm.com return true; 21310821Sandreas.hansson@arm.com } 21410821Sandreas.hansson@arm.com } 21510821Sandreas.hansson@arm.com return false; 21610821Sandreas.hansson@arm.com} 21710821Sandreas.hansson@arm.com 2182858SN/Avoid 21912724Snikos.nikoleris@arm.comBaseCache::handleTimingReqHit(PacketPtr pkt, CacheBlk *blk, Tick request_time) 22012724Snikos.nikoleris@arm.com{ 22112724Snikos.nikoleris@arm.com if (pkt->needsResponse()) { 22212724Snikos.nikoleris@arm.com pkt->makeTimingResponse(); 22312724Snikos.nikoleris@arm.com // @todo: Make someone pay for this 22412724Snikos.nikoleris@arm.com pkt->headerDelay = pkt->payloadDelay = 0; 22512724Snikos.nikoleris@arm.com 22612724Snikos.nikoleris@arm.com // In this case we are considering request_time that takes 22712724Snikos.nikoleris@arm.com // into account the delay of the xbar, if any, and just 22812724Snikos.nikoleris@arm.com // lat, neglecting responseLatency, modelling hit latency 22912724Snikos.nikoleris@arm.com // just as lookupLatency or or the value of lat overriden 23012724Snikos.nikoleris@arm.com // by access(), that calls accessBlock() function. 23112724Snikos.nikoleris@arm.com cpuSidePort.schedTimingResp(pkt, request_time, true); 23212724Snikos.nikoleris@arm.com } else { 23312724Snikos.nikoleris@arm.com DPRINTF(Cache, "%s satisfied %s, no response needed\n", __func__, 23412724Snikos.nikoleris@arm.com pkt->print()); 23512724Snikos.nikoleris@arm.com 23612724Snikos.nikoleris@arm.com // queue the packet for deletion, as the sending cache is 23712724Snikos.nikoleris@arm.com // still relying on it; if the block is found in access(), 23812724Snikos.nikoleris@arm.com // CleanEvict and Writeback messages will be deleted 23912724Snikos.nikoleris@arm.com // here as well 24012724Snikos.nikoleris@arm.com pendingDelete.reset(pkt); 24112724Snikos.nikoleris@arm.com } 24212724Snikos.nikoleris@arm.com} 24312724Snikos.nikoleris@arm.com 24412724Snikos.nikoleris@arm.comvoid 24512724Snikos.nikoleris@arm.comBaseCache::handleTimingReqMiss(PacketPtr pkt, MSHR *mshr, CacheBlk *blk, 24612724Snikos.nikoleris@arm.com Tick forward_time, Tick request_time) 24712724Snikos.nikoleris@arm.com{ 24813352Snikos.nikoleris@arm.com if (writeAllocator && 24913352Snikos.nikoleris@arm.com pkt && pkt->isWrite() && !pkt->req->isUncacheable()) { 25013352Snikos.nikoleris@arm.com writeAllocator->updateMode(pkt->getAddr(), pkt->getSize(), 25113352Snikos.nikoleris@arm.com pkt->getBlockAddr(blkSize)); 25213352Snikos.nikoleris@arm.com } 25313352Snikos.nikoleris@arm.com 25412724Snikos.nikoleris@arm.com if (mshr) { 25512724Snikos.nikoleris@arm.com /// MSHR hit 25612724Snikos.nikoleris@arm.com /// @note writebacks will be checked in getNextMSHR() 25712724Snikos.nikoleris@arm.com /// for any conflicting requests to the same block 25812724Snikos.nikoleris@arm.com 25912724Snikos.nikoleris@arm.com //@todo remove hw_pf here 26012724Snikos.nikoleris@arm.com 26112724Snikos.nikoleris@arm.com // Coalesce unless it was a software prefetch (see above). 26212724Snikos.nikoleris@arm.com if (pkt) { 26312724Snikos.nikoleris@arm.com assert(!pkt->isWriteback()); 26412724Snikos.nikoleris@arm.com // CleanEvicts corresponding to blocks which have 26512724Snikos.nikoleris@arm.com // outstanding requests in MSHRs are simply sunk here 26612724Snikos.nikoleris@arm.com if (pkt->cmd == MemCmd::CleanEvict) { 26712724Snikos.nikoleris@arm.com pendingDelete.reset(pkt); 26812724Snikos.nikoleris@arm.com } else if (pkt->cmd == MemCmd::WriteClean) { 26912724Snikos.nikoleris@arm.com // A WriteClean should never coalesce with any 27012724Snikos.nikoleris@arm.com // outstanding cache maintenance requests. 27112724Snikos.nikoleris@arm.com 27212724Snikos.nikoleris@arm.com // We use forward_time here because there is an 27312724Snikos.nikoleris@arm.com // uncached memory write, forwarded to WriteBuffer. 27412724Snikos.nikoleris@arm.com allocateWriteBuffer(pkt, forward_time); 27512724Snikos.nikoleris@arm.com } else { 27612724Snikos.nikoleris@arm.com DPRINTF(Cache, "%s coalescing MSHR for %s\n", __func__, 27712724Snikos.nikoleris@arm.com pkt->print()); 27812724Snikos.nikoleris@arm.com 27912724Snikos.nikoleris@arm.com assert(pkt->req->masterId() < system->maxMasters()); 28012724Snikos.nikoleris@arm.com mshr_hits[pkt->cmdToIndex()][pkt->req->masterId()]++; 28112724Snikos.nikoleris@arm.com 28212724Snikos.nikoleris@arm.com // We use forward_time here because it is the same 28312724Snikos.nikoleris@arm.com // considering new targets. We have multiple 28412724Snikos.nikoleris@arm.com // requests for the same address here. It 28512724Snikos.nikoleris@arm.com // specifies the latency to allocate an internal 28612724Snikos.nikoleris@arm.com // buffer and to schedule an event to the queued 28712724Snikos.nikoleris@arm.com // port and also takes into account the additional 28812724Snikos.nikoleris@arm.com // delay of the xbar. 28912724Snikos.nikoleris@arm.com mshr->allocateTarget(pkt, forward_time, order++, 29012724Snikos.nikoleris@arm.com allocOnFill(pkt->cmd)); 29112724Snikos.nikoleris@arm.com if (mshr->getNumTargets() == numTarget) { 29212724Snikos.nikoleris@arm.com noTargetMSHR = mshr; 29312724Snikos.nikoleris@arm.com setBlocked(Blocked_NoTargets); 29412724Snikos.nikoleris@arm.com // need to be careful with this... if this mshr isn't 29512724Snikos.nikoleris@arm.com // ready yet (i.e. time > curTick()), we don't want to 29612724Snikos.nikoleris@arm.com // move it ahead of mshrs that are ready 29712724Snikos.nikoleris@arm.com // mshrQueue.moveToFront(mshr); 29812724Snikos.nikoleris@arm.com } 29912724Snikos.nikoleris@arm.com } 30012724Snikos.nikoleris@arm.com } 30112724Snikos.nikoleris@arm.com } else { 30212724Snikos.nikoleris@arm.com // no MSHR 30312724Snikos.nikoleris@arm.com assert(pkt->req->masterId() < system->maxMasters()); 30412724Snikos.nikoleris@arm.com mshr_misses[pkt->cmdToIndex()][pkt->req->masterId()]++; 30512724Snikos.nikoleris@arm.com 30612724Snikos.nikoleris@arm.com if (pkt->isEviction() || pkt->cmd == MemCmd::WriteClean) { 30712724Snikos.nikoleris@arm.com // We use forward_time here because there is an 30812724Snikos.nikoleris@arm.com // writeback or writeclean, forwarded to WriteBuffer. 30912724Snikos.nikoleris@arm.com allocateWriteBuffer(pkt, forward_time); 31012724Snikos.nikoleris@arm.com } else { 31112724Snikos.nikoleris@arm.com if (blk && blk->isValid()) { 31212724Snikos.nikoleris@arm.com // If we have a write miss to a valid block, we 31312724Snikos.nikoleris@arm.com // need to mark the block non-readable. Otherwise 31412724Snikos.nikoleris@arm.com // if we allow reads while there's an outstanding 31512724Snikos.nikoleris@arm.com // write miss, the read could return stale data 31612724Snikos.nikoleris@arm.com // out of the cache block... a more aggressive 31712724Snikos.nikoleris@arm.com // system could detect the overlap (if any) and 31812724Snikos.nikoleris@arm.com // forward data out of the MSHRs, but we don't do 31912724Snikos.nikoleris@arm.com // that yet. Note that we do need to leave the 32012724Snikos.nikoleris@arm.com // block valid so that it stays in the cache, in 32112724Snikos.nikoleris@arm.com // case we get an upgrade response (and hence no 32212724Snikos.nikoleris@arm.com // new data) when the write miss completes. 32312724Snikos.nikoleris@arm.com // As long as CPUs do proper store/load forwarding 32412724Snikos.nikoleris@arm.com // internally, and have a sufficiently weak memory 32512724Snikos.nikoleris@arm.com // model, this is probably unnecessary, but at some 32612724Snikos.nikoleris@arm.com // point it must have seemed like we needed it... 32712724Snikos.nikoleris@arm.com assert((pkt->needsWritable() && !blk->isWritable()) || 32812724Snikos.nikoleris@arm.com pkt->req->isCacheMaintenance()); 32912724Snikos.nikoleris@arm.com blk->status &= ~BlkReadable; 33012724Snikos.nikoleris@arm.com } 33112724Snikos.nikoleris@arm.com // Here we are using forward_time, modelling the latency of 33212724Snikos.nikoleris@arm.com // a miss (outbound) just as forwardLatency, neglecting the 33312724Snikos.nikoleris@arm.com // lookupLatency component. 33412724Snikos.nikoleris@arm.com allocateMissBuffer(pkt, forward_time); 33512724Snikos.nikoleris@arm.com } 33612724Snikos.nikoleris@arm.com } 33712724Snikos.nikoleris@arm.com} 33812724Snikos.nikoleris@arm.com 33912724Snikos.nikoleris@arm.comvoid 34012724Snikos.nikoleris@arm.comBaseCache::recvTimingReq(PacketPtr pkt) 34112724Snikos.nikoleris@arm.com{ 34212724Snikos.nikoleris@arm.com // anything that is merely forwarded pays for the forward latency and 34312724Snikos.nikoleris@arm.com // the delay provided by the crossbar 34412724Snikos.nikoleris@arm.com Tick forward_time = clockEdge(forwardLatency) + pkt->headerDelay; 34512724Snikos.nikoleris@arm.com 34612724Snikos.nikoleris@arm.com // We use lookupLatency here because it is used to specify the latency 34712724Snikos.nikoleris@arm.com // to access. 34812724Snikos.nikoleris@arm.com Cycles lat = lookupLatency; 34912724Snikos.nikoleris@arm.com CacheBlk *blk = nullptr; 35012724Snikos.nikoleris@arm.com bool satisfied = false; 35112724Snikos.nikoleris@arm.com { 35212724Snikos.nikoleris@arm.com PacketList writebacks; 35312724Snikos.nikoleris@arm.com // Note that lat is passed by reference here. The function 35412724Snikos.nikoleris@arm.com // access() calls accessBlock() which can modify lat value. 35512724Snikos.nikoleris@arm.com satisfied = access(pkt, blk, lat, writebacks); 35612724Snikos.nikoleris@arm.com 35712724Snikos.nikoleris@arm.com // copy writebacks to write buffer here to ensure they logically 35812820Srmk35@cl.cam.ac.uk // precede anything happening below 35912724Snikos.nikoleris@arm.com doWritebacks(writebacks, forward_time); 36012724Snikos.nikoleris@arm.com } 36112724Snikos.nikoleris@arm.com 36212724Snikos.nikoleris@arm.com // Here we charge the headerDelay that takes into account the latencies 36312724Snikos.nikoleris@arm.com // of the bus, if the packet comes from it. 36412724Snikos.nikoleris@arm.com // The latency charged it is just lat that is the value of lookupLatency 36512724Snikos.nikoleris@arm.com // modified by access() function, or if not just lookupLatency. 36612724Snikos.nikoleris@arm.com // In case of a hit we are neglecting response latency. 36712724Snikos.nikoleris@arm.com // In case of a miss we are neglecting forward latency. 36812724Snikos.nikoleris@arm.com Tick request_time = clockEdge(lat) + pkt->headerDelay; 36912724Snikos.nikoleris@arm.com // Here we reset the timing of the packet. 37012724Snikos.nikoleris@arm.com pkt->headerDelay = pkt->payloadDelay = 0; 37112724Snikos.nikoleris@arm.com // track time of availability of next prefetch, if any 37212724Snikos.nikoleris@arm.com Tick next_pf_time = MaxTick; 37312724Snikos.nikoleris@arm.com 37412724Snikos.nikoleris@arm.com if (satisfied) { 37512724Snikos.nikoleris@arm.com // if need to notify the prefetcher we have to do it before 37612724Snikos.nikoleris@arm.com // anything else as later handleTimingReqHit might turn the 37712724Snikos.nikoleris@arm.com // packet in a response 37812724Snikos.nikoleris@arm.com if (prefetcher && 37912724Snikos.nikoleris@arm.com (prefetchOnAccess || (blk && blk->wasPrefetched()))) { 38012724Snikos.nikoleris@arm.com if (blk) 38112724Snikos.nikoleris@arm.com blk->status &= ~BlkHWPrefetched; 38212724Snikos.nikoleris@arm.com 38312724Snikos.nikoleris@arm.com // Don't notify on SWPrefetch 38412724Snikos.nikoleris@arm.com if (!pkt->cmd.isSWPrefetch()) { 38512724Snikos.nikoleris@arm.com assert(!pkt->req->isCacheMaintenance()); 38612724Snikos.nikoleris@arm.com next_pf_time = prefetcher->notify(pkt); 38712724Snikos.nikoleris@arm.com } 38812724Snikos.nikoleris@arm.com } 38912724Snikos.nikoleris@arm.com 39012724Snikos.nikoleris@arm.com handleTimingReqHit(pkt, blk, request_time); 39112724Snikos.nikoleris@arm.com } else { 39212724Snikos.nikoleris@arm.com handleTimingReqMiss(pkt, blk, forward_time, request_time); 39312724Snikos.nikoleris@arm.com 39412724Snikos.nikoleris@arm.com // We should call the prefetcher reguardless if the request is 39512724Snikos.nikoleris@arm.com // satisfied or not, reguardless if the request is in the MSHR 39612724Snikos.nikoleris@arm.com // or not. The request could be a ReadReq hit, but still not 39712724Snikos.nikoleris@arm.com // satisfied (potentially because of a prior write to the same 39812724Snikos.nikoleris@arm.com // cache line. So, even when not satisfied, there is an MSHR 39912724Snikos.nikoleris@arm.com // already allocated for this, we need to let the prefetcher 40012724Snikos.nikoleris@arm.com // know about the request 40112724Snikos.nikoleris@arm.com 40213352Snikos.nikoleris@arm.com // Don't notify prefetcher on SWPrefetch, cache maintenance 40313352Snikos.nikoleris@arm.com // operations or for writes that we are coaslescing. 40412724Snikos.nikoleris@arm.com if (prefetcher && pkt && 40512724Snikos.nikoleris@arm.com !pkt->cmd.isSWPrefetch() && 40613352Snikos.nikoleris@arm.com !pkt->req->isCacheMaintenance() && 40713352Snikos.nikoleris@arm.com !(writeAllocator && writeAllocator->coalesce() && 40813352Snikos.nikoleris@arm.com pkt->isWrite())) { 40912724Snikos.nikoleris@arm.com next_pf_time = prefetcher->notify(pkt); 41012724Snikos.nikoleris@arm.com } 41112724Snikos.nikoleris@arm.com } 41212724Snikos.nikoleris@arm.com 41312724Snikos.nikoleris@arm.com if (next_pf_time != MaxTick) { 41412724Snikos.nikoleris@arm.com schedMemSideSendEvent(next_pf_time); 41512724Snikos.nikoleris@arm.com } 41612724Snikos.nikoleris@arm.com} 41712724Snikos.nikoleris@arm.com 41812724Snikos.nikoleris@arm.comvoid 41912724Snikos.nikoleris@arm.comBaseCache::handleUncacheableWriteResp(PacketPtr pkt) 42012724Snikos.nikoleris@arm.com{ 42112724Snikos.nikoleris@arm.com Tick completion_time = clockEdge(responseLatency) + 42212724Snikos.nikoleris@arm.com pkt->headerDelay + pkt->payloadDelay; 42312724Snikos.nikoleris@arm.com 42412724Snikos.nikoleris@arm.com // Reset the bus additional time as it is now accounted for 42512724Snikos.nikoleris@arm.com pkt->headerDelay = pkt->payloadDelay = 0; 42612724Snikos.nikoleris@arm.com 42712724Snikos.nikoleris@arm.com cpuSidePort.schedTimingResp(pkt, completion_time, true); 42812724Snikos.nikoleris@arm.com} 42912724Snikos.nikoleris@arm.com 43012724Snikos.nikoleris@arm.comvoid 43112724Snikos.nikoleris@arm.comBaseCache::recvTimingResp(PacketPtr pkt) 43212724Snikos.nikoleris@arm.com{ 43312724Snikos.nikoleris@arm.com assert(pkt->isResponse()); 43412724Snikos.nikoleris@arm.com 43512724Snikos.nikoleris@arm.com // all header delay should be paid for by the crossbar, unless 43612724Snikos.nikoleris@arm.com // this is a prefetch response from above 43712724Snikos.nikoleris@arm.com panic_if(pkt->headerDelay != 0 && pkt->cmd != MemCmd::HardPFResp, 43812724Snikos.nikoleris@arm.com "%s saw a non-zero packet delay\n", name()); 43912724Snikos.nikoleris@arm.com 44012724Snikos.nikoleris@arm.com const bool is_error = pkt->isError(); 44112724Snikos.nikoleris@arm.com 44212724Snikos.nikoleris@arm.com if (is_error) { 44312724Snikos.nikoleris@arm.com DPRINTF(Cache, "%s: Cache received %s with error\n", __func__, 44412724Snikos.nikoleris@arm.com pkt->print()); 44512724Snikos.nikoleris@arm.com } 44612724Snikos.nikoleris@arm.com 44712724Snikos.nikoleris@arm.com DPRINTF(Cache, "%s: Handling response %s\n", __func__, 44812724Snikos.nikoleris@arm.com pkt->print()); 44912724Snikos.nikoleris@arm.com 45012724Snikos.nikoleris@arm.com // if this is a write, we should be looking at an uncacheable 45112724Snikos.nikoleris@arm.com // write 45212724Snikos.nikoleris@arm.com if (pkt->isWrite()) { 45312724Snikos.nikoleris@arm.com assert(pkt->req->isUncacheable()); 45412724Snikos.nikoleris@arm.com handleUncacheableWriteResp(pkt); 45512724Snikos.nikoleris@arm.com return; 45612724Snikos.nikoleris@arm.com } 45712724Snikos.nikoleris@arm.com 45812724Snikos.nikoleris@arm.com // we have dealt with any (uncacheable) writes above, from here on 45912724Snikos.nikoleris@arm.com // we know we are dealing with an MSHR due to a miss or a prefetch 46012724Snikos.nikoleris@arm.com MSHR *mshr = dynamic_cast<MSHR*>(pkt->popSenderState()); 46112724Snikos.nikoleris@arm.com assert(mshr); 46212724Snikos.nikoleris@arm.com 46312724Snikos.nikoleris@arm.com if (mshr == noTargetMSHR) { 46412724Snikos.nikoleris@arm.com // we always clear at least one target 46512724Snikos.nikoleris@arm.com clearBlocked(Blocked_NoTargets); 46612724Snikos.nikoleris@arm.com noTargetMSHR = nullptr; 46712724Snikos.nikoleris@arm.com } 46812724Snikos.nikoleris@arm.com 46912724Snikos.nikoleris@arm.com // Initial target is used just for stats 47012724Snikos.nikoleris@arm.com MSHR::Target *initial_tgt = mshr->getTarget(); 47112724Snikos.nikoleris@arm.com int stats_cmd_idx = initial_tgt->pkt->cmdToIndex(); 47212724Snikos.nikoleris@arm.com Tick miss_latency = curTick() - initial_tgt->recvTime; 47312724Snikos.nikoleris@arm.com 47412724Snikos.nikoleris@arm.com if (pkt->req->isUncacheable()) { 47512724Snikos.nikoleris@arm.com assert(pkt->req->masterId() < system->maxMasters()); 47612724Snikos.nikoleris@arm.com mshr_uncacheable_lat[stats_cmd_idx][pkt->req->masterId()] += 47712724Snikos.nikoleris@arm.com miss_latency; 47812724Snikos.nikoleris@arm.com } else { 47912724Snikos.nikoleris@arm.com assert(pkt->req->masterId() < system->maxMasters()); 48012724Snikos.nikoleris@arm.com mshr_miss_latency[stats_cmd_idx][pkt->req->masterId()] += 48112724Snikos.nikoleris@arm.com miss_latency; 48212724Snikos.nikoleris@arm.com } 48312724Snikos.nikoleris@arm.com 48412724Snikos.nikoleris@arm.com PacketList writebacks; 48512724Snikos.nikoleris@arm.com 48612724Snikos.nikoleris@arm.com bool is_fill = !mshr->isForward && 48713350Snikos.nikoleris@arm.com (pkt->isRead() || pkt->cmd == MemCmd::UpgradeResp || 48813350Snikos.nikoleris@arm.com mshr->wasWholeLineWrite); 48913350Snikos.nikoleris@arm.com 49013350Snikos.nikoleris@arm.com // make sure that if the mshr was due to a whole line write then 49113350Snikos.nikoleris@arm.com // the response is an invalidation 49213350Snikos.nikoleris@arm.com assert(!mshr->wasWholeLineWrite || pkt->isInvalidate()); 49312724Snikos.nikoleris@arm.com 49412724Snikos.nikoleris@arm.com CacheBlk *blk = tags->findBlock(pkt->getAddr(), pkt->isSecure()); 49512724Snikos.nikoleris@arm.com 49612724Snikos.nikoleris@arm.com if (is_fill && !is_error) { 49712724Snikos.nikoleris@arm.com DPRINTF(Cache, "Block for addr %#llx being updated in Cache\n", 49812724Snikos.nikoleris@arm.com pkt->getAddr()); 49912724Snikos.nikoleris@arm.com 50013352Snikos.nikoleris@arm.com const bool allocate = (writeAllocator && mshr->wasWholeLineWrite) ? 50113352Snikos.nikoleris@arm.com writeAllocator->allocate() : mshr->allocOnFill(); 50213352Snikos.nikoleris@arm.com blk = handleFill(pkt, blk, writebacks, allocate); 50312724Snikos.nikoleris@arm.com assert(blk != nullptr); 50412724Snikos.nikoleris@arm.com } 50512724Snikos.nikoleris@arm.com 50612724Snikos.nikoleris@arm.com if (blk && blk->isValid() && pkt->isClean() && !pkt->isInvalidate()) { 50712724Snikos.nikoleris@arm.com // The block was marked not readable while there was a pending 50812724Snikos.nikoleris@arm.com // cache maintenance operation, restore its flag. 50912724Snikos.nikoleris@arm.com blk->status |= BlkReadable; 51012794Snikos.nikoleris@arm.com 51112794Snikos.nikoleris@arm.com // This was a cache clean operation (without invalidate) 51212794Snikos.nikoleris@arm.com // and we have a copy of the block already. Since there 51312794Snikos.nikoleris@arm.com // is no invalidation, we can promote targets that don't 51412794Snikos.nikoleris@arm.com // require a writable copy 51512794Snikos.nikoleris@arm.com mshr->promoteReadable(); 51612724Snikos.nikoleris@arm.com } 51712724Snikos.nikoleris@arm.com 51812724Snikos.nikoleris@arm.com if (blk && blk->isWritable() && !pkt->req->isCacheInvalidate()) { 51912724Snikos.nikoleris@arm.com // If at this point the referenced block is writable and the 52012724Snikos.nikoleris@arm.com // response is not a cache invalidate, we promote targets that 52112724Snikos.nikoleris@arm.com // were deferred as we couldn't guarrantee a writable copy 52212724Snikos.nikoleris@arm.com mshr->promoteWritable(); 52312724Snikos.nikoleris@arm.com } 52412724Snikos.nikoleris@arm.com 52512724Snikos.nikoleris@arm.com serviceMSHRTargets(mshr, pkt, blk, writebacks); 52612724Snikos.nikoleris@arm.com 52712724Snikos.nikoleris@arm.com if (mshr->promoteDeferredTargets()) { 52812724Snikos.nikoleris@arm.com // avoid later read getting stale data while write miss is 52912724Snikos.nikoleris@arm.com // outstanding.. see comment in timingAccess() 53012724Snikos.nikoleris@arm.com if (blk) { 53112724Snikos.nikoleris@arm.com blk->status &= ~BlkReadable; 53212724Snikos.nikoleris@arm.com } 53312724Snikos.nikoleris@arm.com mshrQueue.markPending(mshr); 53412724Snikos.nikoleris@arm.com schedMemSideSendEvent(clockEdge() + pkt->payloadDelay); 53512724Snikos.nikoleris@arm.com } else { 53612724Snikos.nikoleris@arm.com // while we deallocate an mshr from the queue we still have to 53712724Snikos.nikoleris@arm.com // check the isFull condition before and after as we might 53812724Snikos.nikoleris@arm.com // have been using the reserved entries already 53912724Snikos.nikoleris@arm.com const bool was_full = mshrQueue.isFull(); 54012724Snikos.nikoleris@arm.com mshrQueue.deallocate(mshr); 54112724Snikos.nikoleris@arm.com if (was_full && !mshrQueue.isFull()) { 54212724Snikos.nikoleris@arm.com clearBlocked(Blocked_NoMSHRs); 54312724Snikos.nikoleris@arm.com } 54412724Snikos.nikoleris@arm.com 54512724Snikos.nikoleris@arm.com // Request the bus for a prefetch if this deallocation freed enough 54612724Snikos.nikoleris@arm.com // MSHRs for a prefetch to take place 54712724Snikos.nikoleris@arm.com if (prefetcher && mshrQueue.canPrefetch()) { 54812724Snikos.nikoleris@arm.com Tick next_pf_time = std::max(prefetcher->nextPrefetchReadyTime(), 54912724Snikos.nikoleris@arm.com clockEdge()); 55012724Snikos.nikoleris@arm.com if (next_pf_time != MaxTick) 55112724Snikos.nikoleris@arm.com schedMemSideSendEvent(next_pf_time); 55212724Snikos.nikoleris@arm.com } 55312724Snikos.nikoleris@arm.com } 55412724Snikos.nikoleris@arm.com 55512724Snikos.nikoleris@arm.com // if we used temp block, check to see if its valid and then clear it out 55612724Snikos.nikoleris@arm.com if (blk == tempBlock && tempBlock->isValid()) { 55712724Snikos.nikoleris@arm.com evictBlock(blk, writebacks); 55812724Snikos.nikoleris@arm.com } 55912724Snikos.nikoleris@arm.com 56012724Snikos.nikoleris@arm.com const Tick forward_time = clockEdge(forwardLatency) + pkt->headerDelay; 56112724Snikos.nikoleris@arm.com // copy writebacks to write buffer 56212724Snikos.nikoleris@arm.com doWritebacks(writebacks, forward_time); 56312724Snikos.nikoleris@arm.com 56412724Snikos.nikoleris@arm.com DPRINTF(CacheVerbose, "%s: Leaving with %s\n", __func__, pkt->print()); 56512724Snikos.nikoleris@arm.com delete pkt; 56612724Snikos.nikoleris@arm.com} 56712724Snikos.nikoleris@arm.com 56812724Snikos.nikoleris@arm.com 56912724Snikos.nikoleris@arm.comTick 57012724Snikos.nikoleris@arm.comBaseCache::recvAtomic(PacketPtr pkt) 57112724Snikos.nikoleris@arm.com{ 57212724Snikos.nikoleris@arm.com // We are in atomic mode so we pay just for lookupLatency here. 57312724Snikos.nikoleris@arm.com Cycles lat = lookupLatency; 57412724Snikos.nikoleris@arm.com 57512724Snikos.nikoleris@arm.com // follow the same flow as in recvTimingReq, and check if a cache 57612724Snikos.nikoleris@arm.com // above us is responding 57712724Snikos.nikoleris@arm.com if (pkt->cacheResponding() && !pkt->isClean()) { 57812724Snikos.nikoleris@arm.com assert(!pkt->req->isCacheInvalidate()); 57912724Snikos.nikoleris@arm.com DPRINTF(Cache, "Cache above responding to %s: not responding\n", 58012724Snikos.nikoleris@arm.com pkt->print()); 58112724Snikos.nikoleris@arm.com 58212724Snikos.nikoleris@arm.com // if a cache is responding, and it had the line in Owned 58312724Snikos.nikoleris@arm.com // rather than Modified state, we need to invalidate any 58412724Snikos.nikoleris@arm.com // copies that are not on the same path to memory 58512724Snikos.nikoleris@arm.com assert(pkt->needsWritable() && !pkt->responderHadWritable()); 58612724Snikos.nikoleris@arm.com lat += ticksToCycles(memSidePort.sendAtomic(pkt)); 58712724Snikos.nikoleris@arm.com 58812724Snikos.nikoleris@arm.com return lat * clockPeriod(); 58912724Snikos.nikoleris@arm.com } 59012724Snikos.nikoleris@arm.com 59112724Snikos.nikoleris@arm.com // should assert here that there are no outstanding MSHRs or 59212724Snikos.nikoleris@arm.com // writebacks... that would mean that someone used an atomic 59312724Snikos.nikoleris@arm.com // access in timing mode 59412724Snikos.nikoleris@arm.com 59512724Snikos.nikoleris@arm.com CacheBlk *blk = nullptr; 59612724Snikos.nikoleris@arm.com PacketList writebacks; 59712724Snikos.nikoleris@arm.com bool satisfied = access(pkt, blk, lat, writebacks); 59812724Snikos.nikoleris@arm.com 59912724Snikos.nikoleris@arm.com if (pkt->isClean() && blk && blk->isDirty()) { 60012724Snikos.nikoleris@arm.com // A cache clean opearation is looking for a dirty 60112724Snikos.nikoleris@arm.com // block. If a dirty block is encountered a WriteClean 60212724Snikos.nikoleris@arm.com // will update any copies to the path to the memory 60312724Snikos.nikoleris@arm.com // until the point of reference. 60412724Snikos.nikoleris@arm.com DPRINTF(CacheVerbose, "%s: packet %s found block: %s\n", 60512724Snikos.nikoleris@arm.com __func__, pkt->print(), blk->print()); 60612724Snikos.nikoleris@arm.com PacketPtr wb_pkt = writecleanBlk(blk, pkt->req->getDest(), pkt->id); 60712724Snikos.nikoleris@arm.com writebacks.push_back(wb_pkt); 60812724Snikos.nikoleris@arm.com pkt->setSatisfied(); 60912724Snikos.nikoleris@arm.com } 61012724Snikos.nikoleris@arm.com 61112724Snikos.nikoleris@arm.com // handle writebacks resulting from the access here to ensure they 61212820Srmk35@cl.cam.ac.uk // logically precede anything happening below 61312724Snikos.nikoleris@arm.com doWritebacksAtomic(writebacks); 61412724Snikos.nikoleris@arm.com assert(writebacks.empty()); 61512724Snikos.nikoleris@arm.com 61612724Snikos.nikoleris@arm.com if (!satisfied) { 61712724Snikos.nikoleris@arm.com lat += handleAtomicReqMiss(pkt, blk, writebacks); 61812724Snikos.nikoleris@arm.com } 61912724Snikos.nikoleris@arm.com 62012724Snikos.nikoleris@arm.com // Note that we don't invoke the prefetcher at all in atomic mode. 62112724Snikos.nikoleris@arm.com // It's not clear how to do it properly, particularly for 62212724Snikos.nikoleris@arm.com // prefetchers that aggressively generate prefetch candidates and 62312724Snikos.nikoleris@arm.com // rely on bandwidth contention to throttle them; these will tend 62412724Snikos.nikoleris@arm.com // to pollute the cache in atomic mode since there is no bandwidth 62512724Snikos.nikoleris@arm.com // contention. If we ever do want to enable prefetching in atomic 62612724Snikos.nikoleris@arm.com // mode, though, this is the place to do it... see timingAccess() 62712724Snikos.nikoleris@arm.com // for an example (though we'd want to issue the prefetch(es) 62812724Snikos.nikoleris@arm.com // immediately rather than calling requestMemSideBus() as we do 62912724Snikos.nikoleris@arm.com // there). 63012724Snikos.nikoleris@arm.com 63112724Snikos.nikoleris@arm.com // do any writebacks resulting from the response handling 63212724Snikos.nikoleris@arm.com doWritebacksAtomic(writebacks); 63312724Snikos.nikoleris@arm.com 63412724Snikos.nikoleris@arm.com // if we used temp block, check to see if its valid and if so 63512724Snikos.nikoleris@arm.com // clear it out, but only do so after the call to recvAtomic is 63612724Snikos.nikoleris@arm.com // finished so that any downstream observers (such as a snoop 63712724Snikos.nikoleris@arm.com // filter), first see the fill, and only then see the eviction 63812724Snikos.nikoleris@arm.com if (blk == tempBlock && tempBlock->isValid()) { 63912724Snikos.nikoleris@arm.com // the atomic CPU calls recvAtomic for fetch and load/store 64012724Snikos.nikoleris@arm.com // sequentuially, and we may already have a tempBlock 64112724Snikos.nikoleris@arm.com // writeback from the fetch that we have not yet sent 64212724Snikos.nikoleris@arm.com if (tempBlockWriteback) { 64312724Snikos.nikoleris@arm.com // if that is the case, write the prevoius one back, and 64412724Snikos.nikoleris@arm.com // do not schedule any new event 64512724Snikos.nikoleris@arm.com writebackTempBlockAtomic(); 64612724Snikos.nikoleris@arm.com } else { 64712724Snikos.nikoleris@arm.com // the writeback/clean eviction happens after the call to 64812724Snikos.nikoleris@arm.com // recvAtomic has finished (but before any successive 64912724Snikos.nikoleris@arm.com // calls), so that the response handling from the fill is 65012724Snikos.nikoleris@arm.com // allowed to happen first 65112724Snikos.nikoleris@arm.com schedule(writebackTempBlockAtomicEvent, curTick()); 65212724Snikos.nikoleris@arm.com } 65312724Snikos.nikoleris@arm.com 65412724Snikos.nikoleris@arm.com tempBlockWriteback = evictBlock(blk); 65512724Snikos.nikoleris@arm.com } 65612724Snikos.nikoleris@arm.com 65712724Snikos.nikoleris@arm.com if (pkt->needsResponse()) { 65812724Snikos.nikoleris@arm.com pkt->makeAtomicResponse(); 65912724Snikos.nikoleris@arm.com } 66012724Snikos.nikoleris@arm.com 66112724Snikos.nikoleris@arm.com return lat * clockPeriod(); 66212724Snikos.nikoleris@arm.com} 66312724Snikos.nikoleris@arm.com 66412724Snikos.nikoleris@arm.comvoid 66512724Snikos.nikoleris@arm.comBaseCache::functionalAccess(PacketPtr pkt, bool from_cpu_side) 66612724Snikos.nikoleris@arm.com{ 66712724Snikos.nikoleris@arm.com Addr blk_addr = pkt->getBlockAddr(blkSize); 66812724Snikos.nikoleris@arm.com bool is_secure = pkt->isSecure(); 66912724Snikos.nikoleris@arm.com CacheBlk *blk = tags->findBlock(pkt->getAddr(), is_secure); 67012724Snikos.nikoleris@arm.com MSHR *mshr = mshrQueue.findMatch(blk_addr, is_secure); 67112724Snikos.nikoleris@arm.com 67212724Snikos.nikoleris@arm.com pkt->pushLabel(name()); 67312724Snikos.nikoleris@arm.com 67412724Snikos.nikoleris@arm.com CacheBlkPrintWrapper cbpw(blk); 67512724Snikos.nikoleris@arm.com 67612724Snikos.nikoleris@arm.com // Note that just because an L2/L3 has valid data doesn't mean an 67712724Snikos.nikoleris@arm.com // L1 doesn't have a more up-to-date modified copy that still 67812724Snikos.nikoleris@arm.com // needs to be found. As a result we always update the request if 67912724Snikos.nikoleris@arm.com // we have it, but only declare it satisfied if we are the owner. 68012724Snikos.nikoleris@arm.com 68112724Snikos.nikoleris@arm.com // see if we have data at all (owned or otherwise) 68212724Snikos.nikoleris@arm.com bool have_data = blk && blk->isValid() 68312823Srmk35@cl.cam.ac.uk && pkt->trySatisfyFunctional(&cbpw, blk_addr, is_secure, blkSize, 68412823Srmk35@cl.cam.ac.uk blk->data); 68512724Snikos.nikoleris@arm.com 68612724Snikos.nikoleris@arm.com // data we have is dirty if marked as such or if we have an 68712724Snikos.nikoleris@arm.com // in-service MSHR that is pending a modified line 68812724Snikos.nikoleris@arm.com bool have_dirty = 68912724Snikos.nikoleris@arm.com have_data && (blk->isDirty() || 69012724Snikos.nikoleris@arm.com (mshr && mshr->inService && mshr->isPendingModified())); 69112724Snikos.nikoleris@arm.com 69212724Snikos.nikoleris@arm.com bool done = have_dirty || 69312823Srmk35@cl.cam.ac.uk cpuSidePort.trySatisfyFunctional(pkt) || 69412823Srmk35@cl.cam.ac.uk mshrQueue.trySatisfyFunctional(pkt, blk_addr) || 69512823Srmk35@cl.cam.ac.uk writeBuffer.trySatisfyFunctional(pkt, blk_addr) || 69612823Srmk35@cl.cam.ac.uk memSidePort.trySatisfyFunctional(pkt); 69712724Snikos.nikoleris@arm.com 69812724Snikos.nikoleris@arm.com DPRINTF(CacheVerbose, "%s: %s %s%s%s\n", __func__, pkt->print(), 69912724Snikos.nikoleris@arm.com (blk && blk->isValid()) ? "valid " : "", 70012724Snikos.nikoleris@arm.com have_data ? "data " : "", done ? "done " : ""); 70112724Snikos.nikoleris@arm.com 70212724Snikos.nikoleris@arm.com // We're leaving the cache, so pop cache->name() label 70312724Snikos.nikoleris@arm.com pkt->popLabel(); 70412724Snikos.nikoleris@arm.com 70512724Snikos.nikoleris@arm.com if (done) { 70612724Snikos.nikoleris@arm.com pkt->makeResponse(); 70712724Snikos.nikoleris@arm.com } else { 70812724Snikos.nikoleris@arm.com // if it came as a request from the CPU side then make sure it 70912724Snikos.nikoleris@arm.com // continues towards the memory side 71012724Snikos.nikoleris@arm.com if (from_cpu_side) { 71112724Snikos.nikoleris@arm.com memSidePort.sendFunctional(pkt); 71212724Snikos.nikoleris@arm.com } else if (cpuSidePort.isSnooping()) { 71312724Snikos.nikoleris@arm.com // if it came from the memory side, it must be a snoop request 71412724Snikos.nikoleris@arm.com // and we should only forward it if we are forwarding snoops 71512724Snikos.nikoleris@arm.com cpuSidePort.sendFunctionalSnoop(pkt); 71612724Snikos.nikoleris@arm.com } 71712724Snikos.nikoleris@arm.com } 71812724Snikos.nikoleris@arm.com} 71912724Snikos.nikoleris@arm.com 72012724Snikos.nikoleris@arm.com 72112724Snikos.nikoleris@arm.comvoid 72212724Snikos.nikoleris@arm.comBaseCache::cmpAndSwap(CacheBlk *blk, PacketPtr pkt) 72312724Snikos.nikoleris@arm.com{ 72412724Snikos.nikoleris@arm.com assert(pkt->isRequest()); 72512724Snikos.nikoleris@arm.com 72612724Snikos.nikoleris@arm.com uint64_t overwrite_val; 72712724Snikos.nikoleris@arm.com bool overwrite_mem; 72812724Snikos.nikoleris@arm.com uint64_t condition_val64; 72912724Snikos.nikoleris@arm.com uint32_t condition_val32; 73012724Snikos.nikoleris@arm.com 73112724Snikos.nikoleris@arm.com int offset = pkt->getOffset(blkSize); 73212724Snikos.nikoleris@arm.com uint8_t *blk_data = blk->data + offset; 73312724Snikos.nikoleris@arm.com 73412724Snikos.nikoleris@arm.com assert(sizeof(uint64_t) >= pkt->getSize()); 73512724Snikos.nikoleris@arm.com 73612724Snikos.nikoleris@arm.com overwrite_mem = true; 73712724Snikos.nikoleris@arm.com // keep a copy of our possible write value, and copy what is at the 73812724Snikos.nikoleris@arm.com // memory address into the packet 73912724Snikos.nikoleris@arm.com pkt->writeData((uint8_t *)&overwrite_val); 74012724Snikos.nikoleris@arm.com pkt->setData(blk_data); 74112724Snikos.nikoleris@arm.com 74212724Snikos.nikoleris@arm.com if (pkt->req->isCondSwap()) { 74312724Snikos.nikoleris@arm.com if (pkt->getSize() == sizeof(uint64_t)) { 74412724Snikos.nikoleris@arm.com condition_val64 = pkt->req->getExtraData(); 74512724Snikos.nikoleris@arm.com overwrite_mem = !std::memcmp(&condition_val64, blk_data, 74612724Snikos.nikoleris@arm.com sizeof(uint64_t)); 74712724Snikos.nikoleris@arm.com } else if (pkt->getSize() == sizeof(uint32_t)) { 74812724Snikos.nikoleris@arm.com condition_val32 = (uint32_t)pkt->req->getExtraData(); 74912724Snikos.nikoleris@arm.com overwrite_mem = !std::memcmp(&condition_val32, blk_data, 75012724Snikos.nikoleris@arm.com sizeof(uint32_t)); 75112724Snikos.nikoleris@arm.com } else 75212724Snikos.nikoleris@arm.com panic("Invalid size for conditional read/write\n"); 75312724Snikos.nikoleris@arm.com } 75412724Snikos.nikoleris@arm.com 75512724Snikos.nikoleris@arm.com if (overwrite_mem) { 75612724Snikos.nikoleris@arm.com std::memcpy(blk_data, &overwrite_val, pkt->getSize()); 75712724Snikos.nikoleris@arm.com blk->status |= BlkDirty; 75812724Snikos.nikoleris@arm.com } 75912724Snikos.nikoleris@arm.com} 76012724Snikos.nikoleris@arm.com 76112724Snikos.nikoleris@arm.comQueueEntry* 76212724Snikos.nikoleris@arm.comBaseCache::getNextQueueEntry() 76312724Snikos.nikoleris@arm.com{ 76412724Snikos.nikoleris@arm.com // Check both MSHR queue and write buffer for potential requests, 76512724Snikos.nikoleris@arm.com // note that null does not mean there is no request, it could 76612724Snikos.nikoleris@arm.com // simply be that it is not ready 76712724Snikos.nikoleris@arm.com MSHR *miss_mshr = mshrQueue.getNext(); 76812724Snikos.nikoleris@arm.com WriteQueueEntry *wq_entry = writeBuffer.getNext(); 76912724Snikos.nikoleris@arm.com 77012724Snikos.nikoleris@arm.com // If we got a write buffer request ready, first priority is a 77112724Snikos.nikoleris@arm.com // full write buffer, otherwise we favour the miss requests 77212724Snikos.nikoleris@arm.com if (wq_entry && (writeBuffer.isFull() || !miss_mshr)) { 77312724Snikos.nikoleris@arm.com // need to search MSHR queue for conflicting earlier miss. 77412724Snikos.nikoleris@arm.com MSHR *conflict_mshr = 77512724Snikos.nikoleris@arm.com mshrQueue.findPending(wq_entry->blkAddr, 77612724Snikos.nikoleris@arm.com wq_entry->isSecure); 77712724Snikos.nikoleris@arm.com 77812724Snikos.nikoleris@arm.com if (conflict_mshr && conflict_mshr->order < wq_entry->order) { 77912724Snikos.nikoleris@arm.com // Service misses in order until conflict is cleared. 78012724Snikos.nikoleris@arm.com return conflict_mshr; 78112724Snikos.nikoleris@arm.com 78212724Snikos.nikoleris@arm.com // @todo Note that we ignore the ready time of the conflict here 78312724Snikos.nikoleris@arm.com } 78412724Snikos.nikoleris@arm.com 78512724Snikos.nikoleris@arm.com // No conflicts; issue write 78612724Snikos.nikoleris@arm.com return wq_entry; 78712724Snikos.nikoleris@arm.com } else if (miss_mshr) { 78812724Snikos.nikoleris@arm.com // need to check for conflicting earlier writeback 78912724Snikos.nikoleris@arm.com WriteQueueEntry *conflict_mshr = 79012724Snikos.nikoleris@arm.com writeBuffer.findPending(miss_mshr->blkAddr, 79112724Snikos.nikoleris@arm.com miss_mshr->isSecure); 79212724Snikos.nikoleris@arm.com if (conflict_mshr) { 79312724Snikos.nikoleris@arm.com // not sure why we don't check order here... it was in the 79412724Snikos.nikoleris@arm.com // original code but commented out. 79512724Snikos.nikoleris@arm.com 79612724Snikos.nikoleris@arm.com // The only way this happens is if we are 79712724Snikos.nikoleris@arm.com // doing a write and we didn't have permissions 79812724Snikos.nikoleris@arm.com // then subsequently saw a writeback (owned got evicted) 79912724Snikos.nikoleris@arm.com // We need to make sure to perform the writeback first 80012724Snikos.nikoleris@arm.com // To preserve the dirty data, then we can issue the write 80112724Snikos.nikoleris@arm.com 80212724Snikos.nikoleris@arm.com // should we return wq_entry here instead? I.e. do we 80312724Snikos.nikoleris@arm.com // have to flush writes in order? I don't think so... not 80412724Snikos.nikoleris@arm.com // for Alpha anyway. Maybe for x86? 80512724Snikos.nikoleris@arm.com return conflict_mshr; 80612724Snikos.nikoleris@arm.com 80712724Snikos.nikoleris@arm.com // @todo Note that we ignore the ready time of the conflict here 80812724Snikos.nikoleris@arm.com } 80912724Snikos.nikoleris@arm.com 81012724Snikos.nikoleris@arm.com // No conflicts; issue read 81112724Snikos.nikoleris@arm.com return miss_mshr; 81212724Snikos.nikoleris@arm.com } 81312724Snikos.nikoleris@arm.com 81412724Snikos.nikoleris@arm.com // fall through... no pending requests. Try a prefetch. 81512724Snikos.nikoleris@arm.com assert(!miss_mshr && !wq_entry); 81612724Snikos.nikoleris@arm.com if (prefetcher && mshrQueue.canPrefetch()) { 81712724Snikos.nikoleris@arm.com // If we have a miss queue slot, we can try a prefetch 81812724Snikos.nikoleris@arm.com PacketPtr pkt = prefetcher->getPacket(); 81912724Snikos.nikoleris@arm.com if (pkt) { 82012724Snikos.nikoleris@arm.com Addr pf_addr = pkt->getBlockAddr(blkSize); 82112724Snikos.nikoleris@arm.com if (!tags->findBlock(pf_addr, pkt->isSecure()) && 82212724Snikos.nikoleris@arm.com !mshrQueue.findMatch(pf_addr, pkt->isSecure()) && 82312724Snikos.nikoleris@arm.com !writeBuffer.findMatch(pf_addr, pkt->isSecure())) { 82412724Snikos.nikoleris@arm.com // Update statistic on number of prefetches issued 82512724Snikos.nikoleris@arm.com // (hwpf_mshr_misses) 82612724Snikos.nikoleris@arm.com assert(pkt->req->masterId() < system->maxMasters()); 82712724Snikos.nikoleris@arm.com mshr_misses[pkt->cmdToIndex()][pkt->req->masterId()]++; 82812724Snikos.nikoleris@arm.com 82912724Snikos.nikoleris@arm.com // allocate an MSHR and return it, note 83012724Snikos.nikoleris@arm.com // that we send the packet straight away, so do not 83112724Snikos.nikoleris@arm.com // schedule the send 83212724Snikos.nikoleris@arm.com return allocateMissBuffer(pkt, curTick(), false); 83312724Snikos.nikoleris@arm.com } else { 83412724Snikos.nikoleris@arm.com // free the request and packet 83512724Snikos.nikoleris@arm.com delete pkt; 83612724Snikos.nikoleris@arm.com } 83712724Snikos.nikoleris@arm.com } 83812724Snikos.nikoleris@arm.com } 83912724Snikos.nikoleris@arm.com 84012724Snikos.nikoleris@arm.com return nullptr; 84112724Snikos.nikoleris@arm.com} 84212724Snikos.nikoleris@arm.com 84312724Snikos.nikoleris@arm.comvoid 84412724Snikos.nikoleris@arm.comBaseCache::satisfyRequest(PacketPtr pkt, CacheBlk *blk, bool, bool) 84512724Snikos.nikoleris@arm.com{ 84612724Snikos.nikoleris@arm.com assert(pkt->isRequest()); 84712724Snikos.nikoleris@arm.com 84812724Snikos.nikoleris@arm.com assert(blk && blk->isValid()); 84912724Snikos.nikoleris@arm.com // Occasionally this is not true... if we are a lower-level cache 85012724Snikos.nikoleris@arm.com // satisfying a string of Read and ReadEx requests from 85112724Snikos.nikoleris@arm.com // upper-level caches, a Read will mark the block as shared but we 85212724Snikos.nikoleris@arm.com // can satisfy a following ReadEx anyway since we can rely on the 85312724Snikos.nikoleris@arm.com // Read requester(s) to have buffered the ReadEx snoop and to 85412724Snikos.nikoleris@arm.com // invalidate their blocks after receiving them. 85512724Snikos.nikoleris@arm.com // assert(!pkt->needsWritable() || blk->isWritable()); 85612724Snikos.nikoleris@arm.com assert(pkt->getOffset(blkSize) + pkt->getSize() <= blkSize); 85712724Snikos.nikoleris@arm.com 85812724Snikos.nikoleris@arm.com // Check RMW operations first since both isRead() and 85912724Snikos.nikoleris@arm.com // isWrite() will be true for them 86012724Snikos.nikoleris@arm.com if (pkt->cmd == MemCmd::SwapReq) { 86112766Sqtt2@cornell.edu if (pkt->isAtomicOp()) { 86212766Sqtt2@cornell.edu // extract data from cache and save it into the data field in 86312766Sqtt2@cornell.edu // the packet as a return value from this atomic op 86412766Sqtt2@cornell.edu 86512766Sqtt2@cornell.edu int offset = tags->extractBlkOffset(pkt->getAddr()); 86612766Sqtt2@cornell.edu uint8_t *blk_data = blk->data + offset; 86712766Sqtt2@cornell.edu std::memcpy(pkt->getPtr<uint8_t>(), blk_data, pkt->getSize()); 86812766Sqtt2@cornell.edu 86912766Sqtt2@cornell.edu // execute AMO operation 87012766Sqtt2@cornell.edu (*(pkt->getAtomicOp()))(blk_data); 87112766Sqtt2@cornell.edu 87212766Sqtt2@cornell.edu // set block status to dirty 87312766Sqtt2@cornell.edu blk->status |= BlkDirty; 87412766Sqtt2@cornell.edu } else { 87512766Sqtt2@cornell.edu cmpAndSwap(blk, pkt); 87612766Sqtt2@cornell.edu } 87712724Snikos.nikoleris@arm.com } else if (pkt->isWrite()) { 87812724Snikos.nikoleris@arm.com // we have the block in a writable state and can go ahead, 87912724Snikos.nikoleris@arm.com // note that the line may be also be considered writable in 88012724Snikos.nikoleris@arm.com // downstream caches along the path to memory, but always 88112724Snikos.nikoleris@arm.com // Exclusive, and never Modified 88212724Snikos.nikoleris@arm.com assert(blk->isWritable()); 88312724Snikos.nikoleris@arm.com // Write or WriteLine at the first cache with block in writable state 88412724Snikos.nikoleris@arm.com if (blk->checkWrite(pkt)) { 88512724Snikos.nikoleris@arm.com pkt->writeDataToBlock(blk->data, blkSize); 88612724Snikos.nikoleris@arm.com } 88712724Snikos.nikoleris@arm.com // Always mark the line as dirty (and thus transition to the 88812724Snikos.nikoleris@arm.com // Modified state) even if we are a failed StoreCond so we 88912724Snikos.nikoleris@arm.com // supply data to any snoops that have appended themselves to 89012724Snikos.nikoleris@arm.com // this cache before knowing the store will fail. 89112724Snikos.nikoleris@arm.com blk->status |= BlkDirty; 89212724Snikos.nikoleris@arm.com DPRINTF(CacheVerbose, "%s for %s (write)\n", __func__, pkt->print()); 89312724Snikos.nikoleris@arm.com } else if (pkt->isRead()) { 89412724Snikos.nikoleris@arm.com if (pkt->isLLSC()) { 89512724Snikos.nikoleris@arm.com blk->trackLoadLocked(pkt); 89612724Snikos.nikoleris@arm.com } 89712724Snikos.nikoleris@arm.com 89812724Snikos.nikoleris@arm.com // all read responses have a data payload 89912724Snikos.nikoleris@arm.com assert(pkt->hasRespData()); 90012724Snikos.nikoleris@arm.com pkt->setDataFromBlock(blk->data, blkSize); 90112724Snikos.nikoleris@arm.com } else if (pkt->isUpgrade()) { 90212724Snikos.nikoleris@arm.com // sanity check 90312724Snikos.nikoleris@arm.com assert(!pkt->hasSharers()); 90412724Snikos.nikoleris@arm.com 90512724Snikos.nikoleris@arm.com if (blk->isDirty()) { 90612724Snikos.nikoleris@arm.com // we were in the Owned state, and a cache above us that 90712724Snikos.nikoleris@arm.com // has the line in Shared state needs to be made aware 90812724Snikos.nikoleris@arm.com // that the data it already has is in fact dirty 90912724Snikos.nikoleris@arm.com pkt->setCacheResponding(); 91012724Snikos.nikoleris@arm.com blk->status &= ~BlkDirty; 91112724Snikos.nikoleris@arm.com } 91212794Snikos.nikoleris@arm.com } else if (pkt->isClean()) { 91312794Snikos.nikoleris@arm.com blk->status &= ~BlkDirty; 91412724Snikos.nikoleris@arm.com } else { 91512724Snikos.nikoleris@arm.com assert(pkt->isInvalidate()); 91612724Snikos.nikoleris@arm.com invalidateBlock(blk); 91712724Snikos.nikoleris@arm.com DPRINTF(CacheVerbose, "%s for %s (invalidation)\n", __func__, 91812724Snikos.nikoleris@arm.com pkt->print()); 91912724Snikos.nikoleris@arm.com } 92012724Snikos.nikoleris@arm.com} 92112724Snikos.nikoleris@arm.com 92212724Snikos.nikoleris@arm.com///////////////////////////////////////////////////// 92312724Snikos.nikoleris@arm.com// 92412724Snikos.nikoleris@arm.com// Access path: requests coming in from the CPU side 92512724Snikos.nikoleris@arm.com// 92612724Snikos.nikoleris@arm.com///////////////////////////////////////////////////// 92712724Snikos.nikoleris@arm.com 92812724Snikos.nikoleris@arm.combool 92912724Snikos.nikoleris@arm.comBaseCache::access(PacketPtr pkt, CacheBlk *&blk, Cycles &lat, 93012724Snikos.nikoleris@arm.com PacketList &writebacks) 93112724Snikos.nikoleris@arm.com{ 93212724Snikos.nikoleris@arm.com // sanity check 93312724Snikos.nikoleris@arm.com assert(pkt->isRequest()); 93412724Snikos.nikoleris@arm.com 93512724Snikos.nikoleris@arm.com chatty_assert(!(isReadOnly && pkt->isWrite()), 93612724Snikos.nikoleris@arm.com "Should never see a write in a read-only cache %s\n", 93712724Snikos.nikoleris@arm.com name()); 93812724Snikos.nikoleris@arm.com 93912724Snikos.nikoleris@arm.com // Here lat is the value passed as parameter to accessBlock() function 94012724Snikos.nikoleris@arm.com // that can modify its value. 94112724Snikos.nikoleris@arm.com blk = tags->accessBlock(pkt->getAddr(), pkt->isSecure(), lat); 94212724Snikos.nikoleris@arm.com 94312724Snikos.nikoleris@arm.com DPRINTF(Cache, "%s for %s %s\n", __func__, pkt->print(), 94412724Snikos.nikoleris@arm.com blk ? "hit " + blk->print() : "miss"); 94512724Snikos.nikoleris@arm.com 94612724Snikos.nikoleris@arm.com if (pkt->req->isCacheMaintenance()) { 94712724Snikos.nikoleris@arm.com // A cache maintenance operation is always forwarded to the 94812724Snikos.nikoleris@arm.com // memory below even if the block is found in dirty state. 94912724Snikos.nikoleris@arm.com 95012724Snikos.nikoleris@arm.com // We defer any changes to the state of the block until we 95112724Snikos.nikoleris@arm.com // create and mark as in service the mshr for the downstream 95212724Snikos.nikoleris@arm.com // packet. 95312724Snikos.nikoleris@arm.com return false; 95412724Snikos.nikoleris@arm.com } 95512724Snikos.nikoleris@arm.com 95612724Snikos.nikoleris@arm.com if (pkt->isEviction()) { 95712724Snikos.nikoleris@arm.com // We check for presence of block in above caches before issuing 95812724Snikos.nikoleris@arm.com // Writeback or CleanEvict to write buffer. Therefore the only 95912724Snikos.nikoleris@arm.com // possible cases can be of a CleanEvict packet coming from above 96012724Snikos.nikoleris@arm.com // encountering a Writeback generated in this cache peer cache and 96112724Snikos.nikoleris@arm.com // waiting in the write buffer. Cases of upper level peer caches 96212724Snikos.nikoleris@arm.com // generating CleanEvict and Writeback or simply CleanEvict and 96312724Snikos.nikoleris@arm.com // CleanEvict almost simultaneously will be caught by snoops sent out 96412724Snikos.nikoleris@arm.com // by crossbar. 96512724Snikos.nikoleris@arm.com WriteQueueEntry *wb_entry = writeBuffer.findMatch(pkt->getAddr(), 96612724Snikos.nikoleris@arm.com pkt->isSecure()); 96712724Snikos.nikoleris@arm.com if (wb_entry) { 96812724Snikos.nikoleris@arm.com assert(wb_entry->getNumTargets() == 1); 96912724Snikos.nikoleris@arm.com PacketPtr wbPkt = wb_entry->getTarget()->pkt; 97012724Snikos.nikoleris@arm.com assert(wbPkt->isWriteback()); 97112724Snikos.nikoleris@arm.com 97212724Snikos.nikoleris@arm.com if (pkt->isCleanEviction()) { 97312724Snikos.nikoleris@arm.com // The CleanEvict and WritebackClean snoops into other 97412724Snikos.nikoleris@arm.com // peer caches of the same level while traversing the 97512724Snikos.nikoleris@arm.com // crossbar. If a copy of the block is found, the 97612724Snikos.nikoleris@arm.com // packet is deleted in the crossbar. Hence, none of 97712724Snikos.nikoleris@arm.com // the other upper level caches connected to this 97812724Snikos.nikoleris@arm.com // cache have the block, so we can clear the 97912724Snikos.nikoleris@arm.com // BLOCK_CACHED flag in the Writeback if set and 98012724Snikos.nikoleris@arm.com // discard the CleanEvict by returning true. 98112724Snikos.nikoleris@arm.com wbPkt->clearBlockCached(); 98212724Snikos.nikoleris@arm.com return true; 98312724Snikos.nikoleris@arm.com } else { 98412724Snikos.nikoleris@arm.com assert(pkt->cmd == MemCmd::WritebackDirty); 98512724Snikos.nikoleris@arm.com // Dirty writeback from above trumps our clean 98612724Snikos.nikoleris@arm.com // writeback... discard here 98712724Snikos.nikoleris@arm.com // Note: markInService will remove entry from writeback buffer. 98812724Snikos.nikoleris@arm.com markInService(wb_entry); 98912724Snikos.nikoleris@arm.com delete wbPkt; 99012724Snikos.nikoleris@arm.com } 99112724Snikos.nikoleris@arm.com } 99212724Snikos.nikoleris@arm.com } 99312724Snikos.nikoleris@arm.com 99412724Snikos.nikoleris@arm.com // Writeback handling is special case. We can write the block into 99512724Snikos.nikoleris@arm.com // the cache without having a writeable copy (or any copy at all). 99612724Snikos.nikoleris@arm.com if (pkt->isWriteback()) { 99712724Snikos.nikoleris@arm.com assert(blkSize == pkt->getSize()); 99812724Snikos.nikoleris@arm.com 99912724Snikos.nikoleris@arm.com // we could get a clean writeback while we are having 100012724Snikos.nikoleris@arm.com // outstanding accesses to a block, do the simple thing for 100112724Snikos.nikoleris@arm.com // now and drop the clean writeback so that we do not upset 100212724Snikos.nikoleris@arm.com // any ordering/decisions about ownership already taken 100312724Snikos.nikoleris@arm.com if (pkt->cmd == MemCmd::WritebackClean && 100412724Snikos.nikoleris@arm.com mshrQueue.findMatch(pkt->getAddr(), pkt->isSecure())) { 100512724Snikos.nikoleris@arm.com DPRINTF(Cache, "Clean writeback %#llx to block with MSHR, " 100612724Snikos.nikoleris@arm.com "dropping\n", pkt->getAddr()); 100712724Snikos.nikoleris@arm.com return true; 100812724Snikos.nikoleris@arm.com } 100912724Snikos.nikoleris@arm.com 101012724Snikos.nikoleris@arm.com if (!blk) { 101112724Snikos.nikoleris@arm.com // need to do a replacement 101212754Sodanrc@yahoo.com.br blk = allocateBlock(pkt, writebacks); 101312724Snikos.nikoleris@arm.com if (!blk) { 101412724Snikos.nikoleris@arm.com // no replaceable block available: give up, fwd to next level. 101512724Snikos.nikoleris@arm.com incMissCount(pkt); 101612724Snikos.nikoleris@arm.com return false; 101712724Snikos.nikoleris@arm.com } 101812724Snikos.nikoleris@arm.com 101912724Snikos.nikoleris@arm.com blk->status |= (BlkValid | BlkReadable); 102012724Snikos.nikoleris@arm.com } 102112724Snikos.nikoleris@arm.com // only mark the block dirty if we got a writeback command, 102212724Snikos.nikoleris@arm.com // and leave it as is for a clean writeback 102312724Snikos.nikoleris@arm.com if (pkt->cmd == MemCmd::WritebackDirty) { 102412724Snikos.nikoleris@arm.com // TODO: the coherent cache can assert(!blk->isDirty()); 102512724Snikos.nikoleris@arm.com blk->status |= BlkDirty; 102612724Snikos.nikoleris@arm.com } 102712724Snikos.nikoleris@arm.com // if the packet does not have sharers, it is passing 102812724Snikos.nikoleris@arm.com // writable, and we got the writeback in Modified or Exclusive 102912724Snikos.nikoleris@arm.com // state, if not we are in the Owned or Shared state 103012724Snikos.nikoleris@arm.com if (!pkt->hasSharers()) { 103112724Snikos.nikoleris@arm.com blk->status |= BlkWritable; 103212724Snikos.nikoleris@arm.com } 103312724Snikos.nikoleris@arm.com // nothing else to do; writeback doesn't expect response 103412724Snikos.nikoleris@arm.com assert(!pkt->needsResponse()); 103512724Snikos.nikoleris@arm.com pkt->writeDataToBlock(blk->data, blkSize); 103612724Snikos.nikoleris@arm.com DPRINTF(Cache, "%s new state is %s\n", __func__, blk->print()); 103712724Snikos.nikoleris@arm.com incHitCount(pkt); 103812724Snikos.nikoleris@arm.com // populate the time when the block will be ready to access. 103912724Snikos.nikoleris@arm.com blk->whenReady = clockEdge(fillLatency) + pkt->headerDelay + 104012724Snikos.nikoleris@arm.com pkt->payloadDelay; 104112724Snikos.nikoleris@arm.com return true; 104212724Snikos.nikoleris@arm.com } else if (pkt->cmd == MemCmd::CleanEvict) { 104312724Snikos.nikoleris@arm.com if (blk) { 104412724Snikos.nikoleris@arm.com // Found the block in the tags, need to stop CleanEvict from 104512724Snikos.nikoleris@arm.com // propagating further down the hierarchy. Returning true will 104612724Snikos.nikoleris@arm.com // treat the CleanEvict like a satisfied write request and delete 104712724Snikos.nikoleris@arm.com // it. 104812724Snikos.nikoleris@arm.com return true; 104912724Snikos.nikoleris@arm.com } 105012724Snikos.nikoleris@arm.com // We didn't find the block here, propagate the CleanEvict further 105112724Snikos.nikoleris@arm.com // down the memory hierarchy. Returning false will treat the CleanEvict 105212724Snikos.nikoleris@arm.com // like a Writeback which could not find a replaceable block so has to 105312724Snikos.nikoleris@arm.com // go to next level. 105412724Snikos.nikoleris@arm.com return false; 105512724Snikos.nikoleris@arm.com } else if (pkt->cmd == MemCmd::WriteClean) { 105612724Snikos.nikoleris@arm.com // WriteClean handling is a special case. We can allocate a 105712724Snikos.nikoleris@arm.com // block directly if it doesn't exist and we can update the 105812724Snikos.nikoleris@arm.com // block immediately. The WriteClean transfers the ownership 105912724Snikos.nikoleris@arm.com // of the block as well. 106012724Snikos.nikoleris@arm.com assert(blkSize == pkt->getSize()); 106112724Snikos.nikoleris@arm.com 106212724Snikos.nikoleris@arm.com if (!blk) { 106312724Snikos.nikoleris@arm.com if (pkt->writeThrough()) { 106412724Snikos.nikoleris@arm.com // if this is a write through packet, we don't try to 106512724Snikos.nikoleris@arm.com // allocate if the block is not present 106612724Snikos.nikoleris@arm.com return false; 106712724Snikos.nikoleris@arm.com } else { 106812724Snikos.nikoleris@arm.com // a writeback that misses needs to allocate a new block 106912754Sodanrc@yahoo.com.br blk = allocateBlock(pkt, writebacks); 107012724Snikos.nikoleris@arm.com if (!blk) { 107112724Snikos.nikoleris@arm.com // no replaceable block available: give up, fwd to 107212724Snikos.nikoleris@arm.com // next level. 107312724Snikos.nikoleris@arm.com incMissCount(pkt); 107412724Snikos.nikoleris@arm.com return false; 107512724Snikos.nikoleris@arm.com } 107612724Snikos.nikoleris@arm.com 107712724Snikos.nikoleris@arm.com blk->status |= (BlkValid | BlkReadable); 107812724Snikos.nikoleris@arm.com } 107912724Snikos.nikoleris@arm.com } 108012724Snikos.nikoleris@arm.com 108112724Snikos.nikoleris@arm.com // at this point either this is a writeback or a write-through 108212724Snikos.nikoleris@arm.com // write clean operation and the block is already in this 108312724Snikos.nikoleris@arm.com // cache, we need to update the data and the block flags 108412724Snikos.nikoleris@arm.com assert(blk); 108512724Snikos.nikoleris@arm.com // TODO: the coherent cache can assert(!blk->isDirty()); 108612724Snikos.nikoleris@arm.com if (!pkt->writeThrough()) { 108712724Snikos.nikoleris@arm.com blk->status |= BlkDirty; 108812724Snikos.nikoleris@arm.com } 108912724Snikos.nikoleris@arm.com // nothing else to do; writeback doesn't expect response 109012724Snikos.nikoleris@arm.com assert(!pkt->needsResponse()); 109112724Snikos.nikoleris@arm.com pkt->writeDataToBlock(blk->data, blkSize); 109212724Snikos.nikoleris@arm.com DPRINTF(Cache, "%s new state is %s\n", __func__, blk->print()); 109312724Snikos.nikoleris@arm.com 109412724Snikos.nikoleris@arm.com incHitCount(pkt); 109512724Snikos.nikoleris@arm.com // populate the time when the block will be ready to access. 109612724Snikos.nikoleris@arm.com blk->whenReady = clockEdge(fillLatency) + pkt->headerDelay + 109712724Snikos.nikoleris@arm.com pkt->payloadDelay; 109812724Snikos.nikoleris@arm.com // if this a write-through packet it will be sent to cache 109912724Snikos.nikoleris@arm.com // below 110012724Snikos.nikoleris@arm.com return !pkt->writeThrough(); 110112724Snikos.nikoleris@arm.com } else if (blk && (pkt->needsWritable() ? blk->isWritable() : 110212724Snikos.nikoleris@arm.com blk->isReadable())) { 110312724Snikos.nikoleris@arm.com // OK to satisfy access 110412724Snikos.nikoleris@arm.com incHitCount(pkt); 110512724Snikos.nikoleris@arm.com satisfyRequest(pkt, blk); 110612724Snikos.nikoleris@arm.com maintainClusivity(pkt->fromCache(), blk); 110712724Snikos.nikoleris@arm.com 110812724Snikos.nikoleris@arm.com return true; 110912724Snikos.nikoleris@arm.com } 111012724Snikos.nikoleris@arm.com 111112724Snikos.nikoleris@arm.com // Can't satisfy access normally... either no block (blk == nullptr) 111212724Snikos.nikoleris@arm.com // or have block but need writable 111312724Snikos.nikoleris@arm.com 111412724Snikos.nikoleris@arm.com incMissCount(pkt); 111512724Snikos.nikoleris@arm.com 111612724Snikos.nikoleris@arm.com if (!blk && pkt->isLLSC() && pkt->isWrite()) { 111712724Snikos.nikoleris@arm.com // complete miss on store conditional... just give up now 111812724Snikos.nikoleris@arm.com pkt->req->setExtraData(0); 111912724Snikos.nikoleris@arm.com return true; 112012724Snikos.nikoleris@arm.com } 112112724Snikos.nikoleris@arm.com 112212724Snikos.nikoleris@arm.com return false; 112312724Snikos.nikoleris@arm.com} 112412724Snikos.nikoleris@arm.com 112512724Snikos.nikoleris@arm.comvoid 112612724Snikos.nikoleris@arm.comBaseCache::maintainClusivity(bool from_cache, CacheBlk *blk) 112712724Snikos.nikoleris@arm.com{ 112812724Snikos.nikoleris@arm.com if (from_cache && blk && blk->isValid() && !blk->isDirty() && 112912724Snikos.nikoleris@arm.com clusivity == Enums::mostly_excl) { 113012724Snikos.nikoleris@arm.com // if we have responded to a cache, and our block is still 113112724Snikos.nikoleris@arm.com // valid, but not dirty, and this cache is mostly exclusive 113212724Snikos.nikoleris@arm.com // with respect to the cache above, drop the block 113312724Snikos.nikoleris@arm.com invalidateBlock(blk); 113412724Snikos.nikoleris@arm.com } 113512724Snikos.nikoleris@arm.com} 113612724Snikos.nikoleris@arm.com 113712724Snikos.nikoleris@arm.comCacheBlk* 113812724Snikos.nikoleris@arm.comBaseCache::handleFill(PacketPtr pkt, CacheBlk *blk, PacketList &writebacks, 113912724Snikos.nikoleris@arm.com bool allocate) 114012724Snikos.nikoleris@arm.com{ 114113350Snikos.nikoleris@arm.com assert(pkt->isResponse()); 114212724Snikos.nikoleris@arm.com Addr addr = pkt->getAddr(); 114312724Snikos.nikoleris@arm.com bool is_secure = pkt->isSecure(); 114412724Snikos.nikoleris@arm.com#if TRACING_ON 114512724Snikos.nikoleris@arm.com CacheBlk::State old_state = blk ? blk->status : 0; 114612724Snikos.nikoleris@arm.com#endif 114712724Snikos.nikoleris@arm.com 114812724Snikos.nikoleris@arm.com // When handling a fill, we should have no writes to this line. 114912724Snikos.nikoleris@arm.com assert(addr == pkt->getBlockAddr(blkSize)); 115012724Snikos.nikoleris@arm.com assert(!writeBuffer.findMatch(addr, is_secure)); 115112724Snikos.nikoleris@arm.com 115212724Snikos.nikoleris@arm.com if (!blk) { 115312724Snikos.nikoleris@arm.com // better have read new data... 115413350Snikos.nikoleris@arm.com assert(pkt->hasData() || pkt->cmd == MemCmd::InvalidateResp); 115512724Snikos.nikoleris@arm.com 115612724Snikos.nikoleris@arm.com // need to do a replacement if allocating, otherwise we stick 115712724Snikos.nikoleris@arm.com // with the temporary storage 115812754Sodanrc@yahoo.com.br blk = allocate ? allocateBlock(pkt, writebacks) : nullptr; 115912724Snikos.nikoleris@arm.com 116012724Snikos.nikoleris@arm.com if (!blk) { 116112724Snikos.nikoleris@arm.com // No replaceable block or a mostly exclusive 116212724Snikos.nikoleris@arm.com // cache... just use temporary storage to complete the 116312724Snikos.nikoleris@arm.com // current request and then get rid of it 116412724Snikos.nikoleris@arm.com assert(!tempBlock->isValid()); 116512724Snikos.nikoleris@arm.com blk = tempBlock; 116612730Sodanrc@yahoo.com.br tempBlock->insert(addr, is_secure); 116712724Snikos.nikoleris@arm.com DPRINTF(Cache, "using temp block for %#llx (%s)\n", addr, 116812724Snikos.nikoleris@arm.com is_secure ? "s" : "ns"); 116912724Snikos.nikoleris@arm.com } 117012724Snikos.nikoleris@arm.com 117112724Snikos.nikoleris@arm.com // we should never be overwriting a valid block 117212724Snikos.nikoleris@arm.com assert(!blk->isValid()); 117312724Snikos.nikoleris@arm.com } else { 117412724Snikos.nikoleris@arm.com // existing block... probably an upgrade 117512747Sodanrc@yahoo.com.br assert(regenerateBlkAddr(blk) == addr); 117612729Sodanrc@yahoo.com.br assert(blk->isSecure() == is_secure); 117712724Snikos.nikoleris@arm.com // either we're getting new data or the block should already be valid 117812724Snikos.nikoleris@arm.com assert(pkt->hasData() || blk->isValid()); 117912724Snikos.nikoleris@arm.com // don't clear block status... if block is already dirty we 118012724Snikos.nikoleris@arm.com // don't want to lose that 118112724Snikos.nikoleris@arm.com } 118212724Snikos.nikoleris@arm.com 118312724Snikos.nikoleris@arm.com blk->status |= BlkValid | BlkReadable; 118412724Snikos.nikoleris@arm.com 118512724Snikos.nikoleris@arm.com // sanity check for whole-line writes, which should always be 118612724Snikos.nikoleris@arm.com // marked as writable as part of the fill, and then later marked 118712724Snikos.nikoleris@arm.com // dirty as part of satisfyRequest 118813350Snikos.nikoleris@arm.com if (pkt->cmd == MemCmd::InvalidateResp) { 118912724Snikos.nikoleris@arm.com assert(!pkt->hasSharers()); 119012724Snikos.nikoleris@arm.com } 119112724Snikos.nikoleris@arm.com 119212724Snikos.nikoleris@arm.com // here we deal with setting the appropriate state of the line, 119312724Snikos.nikoleris@arm.com // and we start by looking at the hasSharers flag, and ignore the 119412724Snikos.nikoleris@arm.com // cacheResponding flag (normally signalling dirty data) if the 119512724Snikos.nikoleris@arm.com // packet has sharers, thus the line is never allocated as Owned 119612724Snikos.nikoleris@arm.com // (dirty but not writable), and always ends up being either 119712724Snikos.nikoleris@arm.com // Shared, Exclusive or Modified, see Packet::setCacheResponding 119812724Snikos.nikoleris@arm.com // for more details 119912724Snikos.nikoleris@arm.com if (!pkt->hasSharers()) { 120012724Snikos.nikoleris@arm.com // we could get a writable line from memory (rather than a 120112724Snikos.nikoleris@arm.com // cache) even in a read-only cache, note that we set this bit 120212724Snikos.nikoleris@arm.com // even for a read-only cache, possibly revisit this decision 120312724Snikos.nikoleris@arm.com blk->status |= BlkWritable; 120412724Snikos.nikoleris@arm.com 120512724Snikos.nikoleris@arm.com // check if we got this via cache-to-cache transfer (i.e., from a 120612724Snikos.nikoleris@arm.com // cache that had the block in Modified or Owned state) 120712724Snikos.nikoleris@arm.com if (pkt->cacheResponding()) { 120812724Snikos.nikoleris@arm.com // we got the block in Modified state, and invalidated the 120912724Snikos.nikoleris@arm.com // owners copy 121012724Snikos.nikoleris@arm.com blk->status |= BlkDirty; 121112724Snikos.nikoleris@arm.com 121212724Snikos.nikoleris@arm.com chatty_assert(!isReadOnly, "Should never see dirty snoop response " 121312724Snikos.nikoleris@arm.com "in read-only cache %s\n", name()); 121412724Snikos.nikoleris@arm.com } 121512724Snikos.nikoleris@arm.com } 121612724Snikos.nikoleris@arm.com 121712724Snikos.nikoleris@arm.com DPRINTF(Cache, "Block addr %#llx (%s) moving from state %x to %s\n", 121812724Snikos.nikoleris@arm.com addr, is_secure ? "s" : "ns", old_state, blk->print()); 121912724Snikos.nikoleris@arm.com 122012724Snikos.nikoleris@arm.com // if we got new data, copy it in (checking for a read response 122112724Snikos.nikoleris@arm.com // and a response that has data is the same in the end) 122212724Snikos.nikoleris@arm.com if (pkt->isRead()) { 122312724Snikos.nikoleris@arm.com // sanity checks 122412724Snikos.nikoleris@arm.com assert(pkt->hasData()); 122512724Snikos.nikoleris@arm.com assert(pkt->getSize() == blkSize); 122612724Snikos.nikoleris@arm.com 122712724Snikos.nikoleris@arm.com pkt->writeDataToBlock(blk->data, blkSize); 122812724Snikos.nikoleris@arm.com } 122912724Snikos.nikoleris@arm.com // We pay for fillLatency here. 123012724Snikos.nikoleris@arm.com blk->whenReady = clockEdge() + fillLatency * clockPeriod() + 123112724Snikos.nikoleris@arm.com pkt->payloadDelay; 123212724Snikos.nikoleris@arm.com 123312724Snikos.nikoleris@arm.com return blk; 123412724Snikos.nikoleris@arm.com} 123512724Snikos.nikoleris@arm.com 123612724Snikos.nikoleris@arm.comCacheBlk* 123712754Sodanrc@yahoo.com.brBaseCache::allocateBlock(const PacketPtr pkt, PacketList &writebacks) 123812724Snikos.nikoleris@arm.com{ 123912754Sodanrc@yahoo.com.br // Get address 124012754Sodanrc@yahoo.com.br const Addr addr = pkt->getAddr(); 124112754Sodanrc@yahoo.com.br 124212754Sodanrc@yahoo.com.br // Get secure bit 124312754Sodanrc@yahoo.com.br const bool is_secure = pkt->isSecure(); 124412754Sodanrc@yahoo.com.br 124512724Snikos.nikoleris@arm.com // Find replacement victim 124612744Sodanrc@yahoo.com.br std::vector<CacheBlk*> evict_blks; 124712746Sodanrc@yahoo.com.br CacheBlk *victim = tags->findVictim(addr, is_secure, evict_blks); 124812724Snikos.nikoleris@arm.com 124912724Snikos.nikoleris@arm.com // It is valid to return nullptr if there is no victim 125012744Sodanrc@yahoo.com.br if (!victim) 125112724Snikos.nikoleris@arm.com return nullptr; 125212724Snikos.nikoleris@arm.com 125313222Sodanrc@yahoo.com.br // Print victim block's information 125413222Sodanrc@yahoo.com.br DPRINTF(CacheRepl, "Replacement victim: %s\n", victim->print()); 125513222Sodanrc@yahoo.com.br 125612744Sodanrc@yahoo.com.br // Check for transient state allocations. If any of the entries listed 125712744Sodanrc@yahoo.com.br // for eviction has a transient state, the allocation fails 125812744Sodanrc@yahoo.com.br for (const auto& blk : evict_blks) { 125912744Sodanrc@yahoo.com.br if (blk->isValid()) { 126012744Sodanrc@yahoo.com.br Addr repl_addr = regenerateBlkAddr(blk); 126112744Sodanrc@yahoo.com.br MSHR *repl_mshr = mshrQueue.findMatch(repl_addr, blk->isSecure()); 126212744Sodanrc@yahoo.com.br if (repl_mshr) { 126312744Sodanrc@yahoo.com.br // must be an outstanding upgrade or clean request 126412744Sodanrc@yahoo.com.br // on a block we're about to replace... 126512744Sodanrc@yahoo.com.br assert((!blk->isWritable() && repl_mshr->needsWritable()) || 126612744Sodanrc@yahoo.com.br repl_mshr->isCleaning()); 126712724Snikos.nikoleris@arm.com 126812744Sodanrc@yahoo.com.br // too hard to replace block with transient state 126912744Sodanrc@yahoo.com.br // allocation failed, block not inserted 127012744Sodanrc@yahoo.com.br return nullptr; 127112744Sodanrc@yahoo.com.br } 127212744Sodanrc@yahoo.com.br } 127312744Sodanrc@yahoo.com.br } 127412744Sodanrc@yahoo.com.br 127512744Sodanrc@yahoo.com.br // The victim will be replaced by a new entry, so increase the replacement 127612744Sodanrc@yahoo.com.br // counter if a valid block is being replaced 127712744Sodanrc@yahoo.com.br if (victim->isValid()) { 127812744Sodanrc@yahoo.com.br DPRINTF(Cache, "replacement: replacing %#llx (%s) with %#llx " 127912744Sodanrc@yahoo.com.br "(%s): %s\n", regenerateBlkAddr(victim), 128012744Sodanrc@yahoo.com.br victim->isSecure() ? "s" : "ns", 128112744Sodanrc@yahoo.com.br addr, is_secure ? "s" : "ns", 128212744Sodanrc@yahoo.com.br victim->isDirty() ? "writeback" : "clean"); 128312744Sodanrc@yahoo.com.br 128412744Sodanrc@yahoo.com.br replacements++; 128512744Sodanrc@yahoo.com.br } 128612744Sodanrc@yahoo.com.br 128712744Sodanrc@yahoo.com.br // Evict valid blocks associated to this victim block 128812744Sodanrc@yahoo.com.br for (const auto& blk : evict_blks) { 128912744Sodanrc@yahoo.com.br if (blk->isValid()) { 129012724Snikos.nikoleris@arm.com if (blk->wasPrefetched()) { 129112724Snikos.nikoleris@arm.com unusedPrefetches++; 129212724Snikos.nikoleris@arm.com } 129312744Sodanrc@yahoo.com.br 129412724Snikos.nikoleris@arm.com evictBlock(blk, writebacks); 129512724Snikos.nikoleris@arm.com } 129612724Snikos.nikoleris@arm.com } 129712724Snikos.nikoleris@arm.com 129812754Sodanrc@yahoo.com.br // Insert new block at victimized entry 129913215Sodanrc@yahoo.com.br tags->insertBlock(addr, is_secure, pkt->req->masterId(), 130013215Sodanrc@yahoo.com.br pkt->req->taskId(), victim); 130112754Sodanrc@yahoo.com.br 130212744Sodanrc@yahoo.com.br return victim; 130312724Snikos.nikoleris@arm.com} 130412724Snikos.nikoleris@arm.com 130512724Snikos.nikoleris@arm.comvoid 130612724Snikos.nikoleris@arm.comBaseCache::invalidateBlock(CacheBlk *blk) 130712724Snikos.nikoleris@arm.com{ 130813376Sodanrc@yahoo.com.br // If handling a block present in the Tags, let it do its invalidation 130913376Sodanrc@yahoo.com.br // process, which will update stats and invalidate the block itself 131013376Sodanrc@yahoo.com.br if (blk != tempBlock) { 131112724Snikos.nikoleris@arm.com tags->invalidate(blk); 131213376Sodanrc@yahoo.com.br } else { 131313376Sodanrc@yahoo.com.br tempBlock->invalidate(); 131413376Sodanrc@yahoo.com.br } 131512724Snikos.nikoleris@arm.com} 131612724Snikos.nikoleris@arm.com 131713358Sodanrc@yahoo.com.brvoid 131813358Sodanrc@yahoo.com.brBaseCache::evictBlock(CacheBlk *blk, PacketList &writebacks) 131913358Sodanrc@yahoo.com.br{ 132013358Sodanrc@yahoo.com.br PacketPtr pkt = evictBlock(blk); 132113358Sodanrc@yahoo.com.br if (pkt) { 132213358Sodanrc@yahoo.com.br writebacks.push_back(pkt); 132313358Sodanrc@yahoo.com.br } 132413358Sodanrc@yahoo.com.br} 132513358Sodanrc@yahoo.com.br 132612724Snikos.nikoleris@arm.comPacketPtr 132712724Snikos.nikoleris@arm.comBaseCache::writebackBlk(CacheBlk *blk) 132812724Snikos.nikoleris@arm.com{ 132912724Snikos.nikoleris@arm.com chatty_assert(!isReadOnly || writebackClean, 133012724Snikos.nikoleris@arm.com "Writeback from read-only cache"); 133112724Snikos.nikoleris@arm.com assert(blk && blk->isValid() && (blk->isDirty() || writebackClean)); 133212724Snikos.nikoleris@arm.com 133312724Snikos.nikoleris@arm.com writebacks[Request::wbMasterId]++; 133412724Snikos.nikoleris@arm.com 133512749Sgiacomo.travaglini@arm.com RequestPtr req = std::make_shared<Request>( 133612749Sgiacomo.travaglini@arm.com regenerateBlkAddr(blk), blkSize, 0, Request::wbMasterId); 133712749Sgiacomo.travaglini@arm.com 133812724Snikos.nikoleris@arm.com if (blk->isSecure()) 133912724Snikos.nikoleris@arm.com req->setFlags(Request::SECURE); 134012724Snikos.nikoleris@arm.com 134112724Snikos.nikoleris@arm.com req->taskId(blk->task_id); 134212724Snikos.nikoleris@arm.com 134312724Snikos.nikoleris@arm.com PacketPtr pkt = 134412724Snikos.nikoleris@arm.com new Packet(req, blk->isDirty() ? 134512724Snikos.nikoleris@arm.com MemCmd::WritebackDirty : MemCmd::WritebackClean); 134612724Snikos.nikoleris@arm.com 134712724Snikos.nikoleris@arm.com DPRINTF(Cache, "Create Writeback %s writable: %d, dirty: %d\n", 134812724Snikos.nikoleris@arm.com pkt->print(), blk->isWritable(), blk->isDirty()); 134912724Snikos.nikoleris@arm.com 135012724Snikos.nikoleris@arm.com if (blk->isWritable()) { 135112724Snikos.nikoleris@arm.com // not asserting shared means we pass the block in modified 135212724Snikos.nikoleris@arm.com // state, mark our own block non-writeable 135312724Snikos.nikoleris@arm.com blk->status &= ~BlkWritable; 135412724Snikos.nikoleris@arm.com } else { 135512724Snikos.nikoleris@arm.com // we are in the Owned state, tell the receiver 135612724Snikos.nikoleris@arm.com pkt->setHasSharers(); 135712724Snikos.nikoleris@arm.com } 135812724Snikos.nikoleris@arm.com 135912724Snikos.nikoleris@arm.com // make sure the block is not marked dirty 136012724Snikos.nikoleris@arm.com blk->status &= ~BlkDirty; 136112724Snikos.nikoleris@arm.com 136212724Snikos.nikoleris@arm.com pkt->allocate(); 136312724Snikos.nikoleris@arm.com pkt->setDataFromBlock(blk->data, blkSize); 136412724Snikos.nikoleris@arm.com 136512724Snikos.nikoleris@arm.com return pkt; 136612724Snikos.nikoleris@arm.com} 136712724Snikos.nikoleris@arm.com 136812724Snikos.nikoleris@arm.comPacketPtr 136912724Snikos.nikoleris@arm.comBaseCache::writecleanBlk(CacheBlk *blk, Request::Flags dest, PacketId id) 137012724Snikos.nikoleris@arm.com{ 137112749Sgiacomo.travaglini@arm.com RequestPtr req = std::make_shared<Request>( 137212749Sgiacomo.travaglini@arm.com regenerateBlkAddr(blk), blkSize, 0, Request::wbMasterId); 137312749Sgiacomo.travaglini@arm.com 137412724Snikos.nikoleris@arm.com if (blk->isSecure()) { 137512724Snikos.nikoleris@arm.com req->setFlags(Request::SECURE); 137612724Snikos.nikoleris@arm.com } 137712724Snikos.nikoleris@arm.com req->taskId(blk->task_id); 137812724Snikos.nikoleris@arm.com 137912724Snikos.nikoleris@arm.com PacketPtr pkt = new Packet(req, MemCmd::WriteClean, blkSize, id); 138012724Snikos.nikoleris@arm.com 138112724Snikos.nikoleris@arm.com if (dest) { 138212724Snikos.nikoleris@arm.com req->setFlags(dest); 138312724Snikos.nikoleris@arm.com pkt->setWriteThrough(); 138412724Snikos.nikoleris@arm.com } 138512724Snikos.nikoleris@arm.com 138612724Snikos.nikoleris@arm.com DPRINTF(Cache, "Create %s writable: %d, dirty: %d\n", pkt->print(), 138712724Snikos.nikoleris@arm.com blk->isWritable(), blk->isDirty()); 138812724Snikos.nikoleris@arm.com 138912724Snikos.nikoleris@arm.com if (blk->isWritable()) { 139012724Snikos.nikoleris@arm.com // not asserting shared means we pass the block in modified 139112724Snikos.nikoleris@arm.com // state, mark our own block non-writeable 139212724Snikos.nikoleris@arm.com blk->status &= ~BlkWritable; 139312724Snikos.nikoleris@arm.com } else { 139412724Snikos.nikoleris@arm.com // we are in the Owned state, tell the receiver 139512724Snikos.nikoleris@arm.com pkt->setHasSharers(); 139612724Snikos.nikoleris@arm.com } 139712724Snikos.nikoleris@arm.com 139812724Snikos.nikoleris@arm.com // make sure the block is not marked dirty 139912724Snikos.nikoleris@arm.com blk->status &= ~BlkDirty; 140012724Snikos.nikoleris@arm.com 140112724Snikos.nikoleris@arm.com pkt->allocate(); 140212724Snikos.nikoleris@arm.com pkt->setDataFromBlock(blk->data, blkSize); 140312724Snikos.nikoleris@arm.com 140412724Snikos.nikoleris@arm.com return pkt; 140512724Snikos.nikoleris@arm.com} 140612724Snikos.nikoleris@arm.com 140712724Snikos.nikoleris@arm.com 140812724Snikos.nikoleris@arm.comvoid 140912724Snikos.nikoleris@arm.comBaseCache::memWriteback() 141012724Snikos.nikoleris@arm.com{ 141112728Snikos.nikoleris@arm.com tags->forEachBlk([this](CacheBlk &blk) { writebackVisitor(blk); }); 141212724Snikos.nikoleris@arm.com} 141312724Snikos.nikoleris@arm.com 141412724Snikos.nikoleris@arm.comvoid 141512724Snikos.nikoleris@arm.comBaseCache::memInvalidate() 141612724Snikos.nikoleris@arm.com{ 141712728Snikos.nikoleris@arm.com tags->forEachBlk([this](CacheBlk &blk) { invalidateVisitor(blk); }); 141812724Snikos.nikoleris@arm.com} 141912724Snikos.nikoleris@arm.com 142012724Snikos.nikoleris@arm.combool 142112724Snikos.nikoleris@arm.comBaseCache::isDirty() const 142212724Snikos.nikoleris@arm.com{ 142312728Snikos.nikoleris@arm.com return tags->anyBlk([](CacheBlk &blk) { return blk.isDirty(); }); 142412724Snikos.nikoleris@arm.com} 142512724Snikos.nikoleris@arm.com 142612728Snikos.nikoleris@arm.comvoid 142712724Snikos.nikoleris@arm.comBaseCache::writebackVisitor(CacheBlk &blk) 142812724Snikos.nikoleris@arm.com{ 142912724Snikos.nikoleris@arm.com if (blk.isDirty()) { 143012724Snikos.nikoleris@arm.com assert(blk.isValid()); 143112724Snikos.nikoleris@arm.com 143212749Sgiacomo.travaglini@arm.com RequestPtr request = std::make_shared<Request>( 143312749Sgiacomo.travaglini@arm.com regenerateBlkAddr(&blk), blkSize, 0, Request::funcMasterId); 143412749Sgiacomo.travaglini@arm.com 143512749Sgiacomo.travaglini@arm.com request->taskId(blk.task_id); 143612724Snikos.nikoleris@arm.com if (blk.isSecure()) { 143712749Sgiacomo.travaglini@arm.com request->setFlags(Request::SECURE); 143812724Snikos.nikoleris@arm.com } 143912724Snikos.nikoleris@arm.com 144012749Sgiacomo.travaglini@arm.com Packet packet(request, MemCmd::WriteReq); 144112724Snikos.nikoleris@arm.com packet.dataStatic(blk.data); 144212724Snikos.nikoleris@arm.com 144312724Snikos.nikoleris@arm.com memSidePort.sendFunctional(&packet); 144412724Snikos.nikoleris@arm.com 144512724Snikos.nikoleris@arm.com blk.status &= ~BlkDirty; 144612724Snikos.nikoleris@arm.com } 144712724Snikos.nikoleris@arm.com} 144812724Snikos.nikoleris@arm.com 144912728Snikos.nikoleris@arm.comvoid 145012724Snikos.nikoleris@arm.comBaseCache::invalidateVisitor(CacheBlk &blk) 145112724Snikos.nikoleris@arm.com{ 145212724Snikos.nikoleris@arm.com if (blk.isDirty()) 145312724Snikos.nikoleris@arm.com warn_once("Invalidating dirty cache lines. " \ 145412724Snikos.nikoleris@arm.com "Expect things to break.\n"); 145512724Snikos.nikoleris@arm.com 145612724Snikos.nikoleris@arm.com if (blk.isValid()) { 145712724Snikos.nikoleris@arm.com assert(!blk.isDirty()); 145812724Snikos.nikoleris@arm.com invalidateBlock(&blk); 145912724Snikos.nikoleris@arm.com } 146012724Snikos.nikoleris@arm.com} 146112724Snikos.nikoleris@arm.com 146212724Snikos.nikoleris@arm.comTick 146312724Snikos.nikoleris@arm.comBaseCache::nextQueueReadyTime() const 146412724Snikos.nikoleris@arm.com{ 146512724Snikos.nikoleris@arm.com Tick nextReady = std::min(mshrQueue.nextReadyTime(), 146612724Snikos.nikoleris@arm.com writeBuffer.nextReadyTime()); 146712724Snikos.nikoleris@arm.com 146812724Snikos.nikoleris@arm.com // Don't signal prefetch ready time if no MSHRs available 146912724Snikos.nikoleris@arm.com // Will signal once enoguh MSHRs are deallocated 147012724Snikos.nikoleris@arm.com if (prefetcher && mshrQueue.canPrefetch()) { 147112724Snikos.nikoleris@arm.com nextReady = std::min(nextReady, 147212724Snikos.nikoleris@arm.com prefetcher->nextPrefetchReadyTime()); 147312724Snikos.nikoleris@arm.com } 147412724Snikos.nikoleris@arm.com 147512724Snikos.nikoleris@arm.com return nextReady; 147612724Snikos.nikoleris@arm.com} 147712724Snikos.nikoleris@arm.com 147812724Snikos.nikoleris@arm.com 147912724Snikos.nikoleris@arm.combool 148012724Snikos.nikoleris@arm.comBaseCache::sendMSHRQueuePacket(MSHR* mshr) 148112724Snikos.nikoleris@arm.com{ 148212724Snikos.nikoleris@arm.com assert(mshr); 148312724Snikos.nikoleris@arm.com 148412724Snikos.nikoleris@arm.com // use request from 1st target 148512724Snikos.nikoleris@arm.com PacketPtr tgt_pkt = mshr->getTarget()->pkt; 148612724Snikos.nikoleris@arm.com 148712724Snikos.nikoleris@arm.com DPRINTF(Cache, "%s: MSHR %s\n", __func__, tgt_pkt->print()); 148812724Snikos.nikoleris@arm.com 148913352Snikos.nikoleris@arm.com // if the cache is in write coalescing mode or (additionally) in 149013352Snikos.nikoleris@arm.com // no allocation mode, and we have a write packet with an MSHR 149113352Snikos.nikoleris@arm.com // that is not a whole-line write (due to incompatible flags etc), 149213352Snikos.nikoleris@arm.com // then reset the write mode 149313352Snikos.nikoleris@arm.com if (writeAllocator && writeAllocator->coalesce() && tgt_pkt->isWrite()) { 149413352Snikos.nikoleris@arm.com if (!mshr->isWholeLineWrite()) { 149513352Snikos.nikoleris@arm.com // if we are currently write coalescing, hold on the 149613352Snikos.nikoleris@arm.com // MSHR as many cycles extra as we need to completely 149713352Snikos.nikoleris@arm.com // write a cache line 149813352Snikos.nikoleris@arm.com if (writeAllocator->delay(mshr->blkAddr)) { 149913352Snikos.nikoleris@arm.com Tick delay = blkSize / tgt_pkt->getSize() * clockPeriod(); 150013352Snikos.nikoleris@arm.com DPRINTF(CacheVerbose, "Delaying pkt %s %llu ticks to allow " 150113352Snikos.nikoleris@arm.com "for write coalescing\n", tgt_pkt->print(), delay); 150213352Snikos.nikoleris@arm.com mshrQueue.delay(mshr, delay); 150313352Snikos.nikoleris@arm.com return false; 150413352Snikos.nikoleris@arm.com } else { 150513352Snikos.nikoleris@arm.com writeAllocator->reset(); 150613352Snikos.nikoleris@arm.com } 150713352Snikos.nikoleris@arm.com } else { 150813352Snikos.nikoleris@arm.com writeAllocator->resetDelay(mshr->blkAddr); 150913352Snikos.nikoleris@arm.com } 151013352Snikos.nikoleris@arm.com } 151113352Snikos.nikoleris@arm.com 151212724Snikos.nikoleris@arm.com CacheBlk *blk = tags->findBlock(mshr->blkAddr, mshr->isSecure); 151312724Snikos.nikoleris@arm.com 151412724Snikos.nikoleris@arm.com // either a prefetch that is not present upstream, or a normal 151512724Snikos.nikoleris@arm.com // MSHR request, proceed to get the packet to send downstream 151613350Snikos.nikoleris@arm.com PacketPtr pkt = createMissPacket(tgt_pkt, blk, mshr->needsWritable(), 151713350Snikos.nikoleris@arm.com mshr->isWholeLineWrite()); 151812724Snikos.nikoleris@arm.com 151912724Snikos.nikoleris@arm.com mshr->isForward = (pkt == nullptr); 152012724Snikos.nikoleris@arm.com 152112724Snikos.nikoleris@arm.com if (mshr->isForward) { 152212724Snikos.nikoleris@arm.com // not a cache block request, but a response is expected 152312724Snikos.nikoleris@arm.com // make copy of current packet to forward, keep current 152412724Snikos.nikoleris@arm.com // copy for response handling 152512724Snikos.nikoleris@arm.com pkt = new Packet(tgt_pkt, false, true); 152612724Snikos.nikoleris@arm.com assert(!pkt->isWrite()); 152712724Snikos.nikoleris@arm.com } 152812724Snikos.nikoleris@arm.com 152912724Snikos.nikoleris@arm.com // play it safe and append (rather than set) the sender state, 153012724Snikos.nikoleris@arm.com // as forwarded packets may already have existing state 153112724Snikos.nikoleris@arm.com pkt->pushSenderState(mshr); 153212724Snikos.nikoleris@arm.com 153312724Snikos.nikoleris@arm.com if (pkt->isClean() && blk && blk->isDirty()) { 153412724Snikos.nikoleris@arm.com // A cache clean opearation is looking for a dirty block. Mark 153512724Snikos.nikoleris@arm.com // the packet so that the destination xbar can determine that 153612724Snikos.nikoleris@arm.com // there will be a follow-up write packet as well. 153712724Snikos.nikoleris@arm.com pkt->setSatisfied(); 153812724Snikos.nikoleris@arm.com } 153912724Snikos.nikoleris@arm.com 154012724Snikos.nikoleris@arm.com if (!memSidePort.sendTimingReq(pkt)) { 154112724Snikos.nikoleris@arm.com // we are awaiting a retry, but we 154212724Snikos.nikoleris@arm.com // delete the packet and will be creating a new packet 154312724Snikos.nikoleris@arm.com // when we get the opportunity 154412724Snikos.nikoleris@arm.com delete pkt; 154512724Snikos.nikoleris@arm.com 154612724Snikos.nikoleris@arm.com // note that we have now masked any requestBus and 154712724Snikos.nikoleris@arm.com // schedSendEvent (we will wait for a retry before 154812724Snikos.nikoleris@arm.com // doing anything), and this is so even if we do not 154912724Snikos.nikoleris@arm.com // care about this packet and might override it before 155012724Snikos.nikoleris@arm.com // it gets retried 155112724Snikos.nikoleris@arm.com return true; 155212724Snikos.nikoleris@arm.com } else { 155312724Snikos.nikoleris@arm.com // As part of the call to sendTimingReq the packet is 155412724Snikos.nikoleris@arm.com // forwarded to all neighbouring caches (and any caches 155512724Snikos.nikoleris@arm.com // above them) as a snoop. Thus at this point we know if 155612724Snikos.nikoleris@arm.com // any of the neighbouring caches are responding, and if 155712724Snikos.nikoleris@arm.com // so, we know it is dirty, and we can determine if it is 155812724Snikos.nikoleris@arm.com // being passed as Modified, making our MSHR the ordering 155912724Snikos.nikoleris@arm.com // point 156012724Snikos.nikoleris@arm.com bool pending_modified_resp = !pkt->hasSharers() && 156112724Snikos.nikoleris@arm.com pkt->cacheResponding(); 156212724Snikos.nikoleris@arm.com markInService(mshr, pending_modified_resp); 156312724Snikos.nikoleris@arm.com 156412724Snikos.nikoleris@arm.com if (pkt->isClean() && blk && blk->isDirty()) { 156512724Snikos.nikoleris@arm.com // A cache clean opearation is looking for a dirty 156612724Snikos.nikoleris@arm.com // block. If a dirty block is encountered a WriteClean 156712724Snikos.nikoleris@arm.com // will update any copies to the path to the memory 156812724Snikos.nikoleris@arm.com // until the point of reference. 156912724Snikos.nikoleris@arm.com DPRINTF(CacheVerbose, "%s: packet %s found block: %s\n", 157012724Snikos.nikoleris@arm.com __func__, pkt->print(), blk->print()); 157112724Snikos.nikoleris@arm.com PacketPtr wb_pkt = writecleanBlk(blk, pkt->req->getDest(), 157212724Snikos.nikoleris@arm.com pkt->id); 157312724Snikos.nikoleris@arm.com PacketList writebacks; 157412724Snikos.nikoleris@arm.com writebacks.push_back(wb_pkt); 157512724Snikos.nikoleris@arm.com doWritebacks(writebacks, 0); 157612724Snikos.nikoleris@arm.com } 157712724Snikos.nikoleris@arm.com 157812724Snikos.nikoleris@arm.com return false; 157912724Snikos.nikoleris@arm.com } 158012724Snikos.nikoleris@arm.com} 158112724Snikos.nikoleris@arm.com 158212724Snikos.nikoleris@arm.combool 158312724Snikos.nikoleris@arm.comBaseCache::sendWriteQueuePacket(WriteQueueEntry* wq_entry) 158412724Snikos.nikoleris@arm.com{ 158512724Snikos.nikoleris@arm.com assert(wq_entry); 158612724Snikos.nikoleris@arm.com 158712724Snikos.nikoleris@arm.com // always a single target for write queue entries 158812724Snikos.nikoleris@arm.com PacketPtr tgt_pkt = wq_entry->getTarget()->pkt; 158912724Snikos.nikoleris@arm.com 159012724Snikos.nikoleris@arm.com DPRINTF(Cache, "%s: write %s\n", __func__, tgt_pkt->print()); 159112724Snikos.nikoleris@arm.com 159212724Snikos.nikoleris@arm.com // forward as is, both for evictions and uncacheable writes 159312724Snikos.nikoleris@arm.com if (!memSidePort.sendTimingReq(tgt_pkt)) { 159412724Snikos.nikoleris@arm.com // note that we have now masked any requestBus and 159512724Snikos.nikoleris@arm.com // schedSendEvent (we will wait for a retry before 159612724Snikos.nikoleris@arm.com // doing anything), and this is so even if we do not 159712724Snikos.nikoleris@arm.com // care about this packet and might override it before 159812724Snikos.nikoleris@arm.com // it gets retried 159912724Snikos.nikoleris@arm.com return true; 160012724Snikos.nikoleris@arm.com } else { 160112724Snikos.nikoleris@arm.com markInService(wq_entry); 160212724Snikos.nikoleris@arm.com return false; 160312724Snikos.nikoleris@arm.com } 160412724Snikos.nikoleris@arm.com} 160512724Snikos.nikoleris@arm.com 160612724Snikos.nikoleris@arm.comvoid 160712724Snikos.nikoleris@arm.comBaseCache::serialize(CheckpointOut &cp) const 160812724Snikos.nikoleris@arm.com{ 160912724Snikos.nikoleris@arm.com bool dirty(isDirty()); 161012724Snikos.nikoleris@arm.com 161112724Snikos.nikoleris@arm.com if (dirty) { 161212724Snikos.nikoleris@arm.com warn("*** The cache still contains dirty data. ***\n"); 161312724Snikos.nikoleris@arm.com warn(" Make sure to drain the system using the correct flags.\n"); 161412724Snikos.nikoleris@arm.com warn(" This checkpoint will not restore correctly " \ 161512724Snikos.nikoleris@arm.com "and dirty data in the cache will be lost!\n"); 161612724Snikos.nikoleris@arm.com } 161712724Snikos.nikoleris@arm.com 161812724Snikos.nikoleris@arm.com // Since we don't checkpoint the data in the cache, any dirty data 161912724Snikos.nikoleris@arm.com // will be lost when restoring from a checkpoint of a system that 162012724Snikos.nikoleris@arm.com // wasn't drained properly. Flag the checkpoint as invalid if the 162112724Snikos.nikoleris@arm.com // cache contains dirty data. 162212724Snikos.nikoleris@arm.com bool bad_checkpoint(dirty); 162312724Snikos.nikoleris@arm.com SERIALIZE_SCALAR(bad_checkpoint); 162412724Snikos.nikoleris@arm.com} 162512724Snikos.nikoleris@arm.com 162612724Snikos.nikoleris@arm.comvoid 162712724Snikos.nikoleris@arm.comBaseCache::unserialize(CheckpointIn &cp) 162812724Snikos.nikoleris@arm.com{ 162912724Snikos.nikoleris@arm.com bool bad_checkpoint; 163012724Snikos.nikoleris@arm.com UNSERIALIZE_SCALAR(bad_checkpoint); 163112724Snikos.nikoleris@arm.com if (bad_checkpoint) { 163212724Snikos.nikoleris@arm.com fatal("Restoring from checkpoints with dirty caches is not " 163312724Snikos.nikoleris@arm.com "supported in the classic memory system. Please remove any " 163412724Snikos.nikoleris@arm.com "caches or drain them properly before taking checkpoints.\n"); 163512724Snikos.nikoleris@arm.com } 163612724Snikos.nikoleris@arm.com} 163712724Snikos.nikoleris@arm.com 163812724Snikos.nikoleris@arm.comvoid 16392810SN/ABaseCache::regStats() 16402810SN/A{ 164111522Sstephan.diestelhorst@arm.com MemObject::regStats(); 164211522Sstephan.diestelhorst@arm.com 16432810SN/A using namespace Stats; 16442810SN/A 16452810SN/A // Hit statistics 16464022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 16474022SN/A MemCmd cmd(access_idx); 16484022SN/A const string &cstr = cmd.toString(); 16492810SN/A 16502810SN/A hits[access_idx] 16518833Sdam.sunwoo@arm.com .init(system->maxMasters()) 16522810SN/A .name(name() + "." + cstr + "_hits") 16532810SN/A .desc("number of " + cstr + " hits") 16542810SN/A .flags(total | nozero | nonan) 16552810SN/A ; 16568833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 16578833Sdam.sunwoo@arm.com hits[access_idx].subname(i, system->getMasterName(i)); 16588833Sdam.sunwoo@arm.com } 16592810SN/A } 16602810SN/A 16614871SN/A// These macros make it easier to sum the right subset of commands and 16624871SN/A// to change the subset of commands that are considered "demand" vs 16634871SN/A// "non-demand" 16644871SN/A#define SUM_DEMAND(s) \ 166511455Sandreas.hansson@arm.com (s[MemCmd::ReadReq] + s[MemCmd::WriteReq] + s[MemCmd::WriteLineReq] + \ 166610885Sandreas.hansson@arm.com s[MemCmd::ReadExReq] + s[MemCmd::ReadCleanReq] + s[MemCmd::ReadSharedReq]) 16674871SN/A 16684871SN/A// should writebacks be included here? prior code was inconsistent... 16694871SN/A#define SUM_NON_DEMAND(s) \ 167013367Syuetsu.kodama@riken.jp (s[MemCmd::SoftPFReq] + s[MemCmd::HardPFReq] + s[MemCmd::SoftPFExReq]) 16714871SN/A 16722810SN/A demandHits 16732810SN/A .name(name() + ".demand_hits") 16742810SN/A .desc("number of demand (read+write) hits") 16758833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 16762810SN/A ; 16774871SN/A demandHits = SUM_DEMAND(hits); 16788833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 16798833Sdam.sunwoo@arm.com demandHits.subname(i, system->getMasterName(i)); 16808833Sdam.sunwoo@arm.com } 16812810SN/A 16822810SN/A overallHits 16832810SN/A .name(name() + ".overall_hits") 16842810SN/A .desc("number of overall hits") 16858833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 16862810SN/A ; 16874871SN/A overallHits = demandHits + SUM_NON_DEMAND(hits); 16888833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 16898833Sdam.sunwoo@arm.com overallHits.subname(i, system->getMasterName(i)); 16908833Sdam.sunwoo@arm.com } 16912810SN/A 16922810SN/A // Miss statistics 16934022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 16944022SN/A MemCmd cmd(access_idx); 16954022SN/A const string &cstr = cmd.toString(); 16962810SN/A 16972810SN/A misses[access_idx] 16988833Sdam.sunwoo@arm.com .init(system->maxMasters()) 16992810SN/A .name(name() + "." + cstr + "_misses") 17002810SN/A .desc("number of " + cstr + " misses") 17012810SN/A .flags(total | nozero | nonan) 17022810SN/A ; 17038833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 17048833Sdam.sunwoo@arm.com misses[access_idx].subname(i, system->getMasterName(i)); 17058833Sdam.sunwoo@arm.com } 17062810SN/A } 17072810SN/A 17082810SN/A demandMisses 17092810SN/A .name(name() + ".demand_misses") 17102810SN/A .desc("number of demand (read+write) misses") 17118833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 17122810SN/A ; 17134871SN/A demandMisses = SUM_DEMAND(misses); 17148833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 17158833Sdam.sunwoo@arm.com demandMisses.subname(i, system->getMasterName(i)); 17168833Sdam.sunwoo@arm.com } 17172810SN/A 17182810SN/A overallMisses 17192810SN/A .name(name() + ".overall_misses") 17202810SN/A .desc("number of overall misses") 17218833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 17222810SN/A ; 17234871SN/A overallMisses = demandMisses + SUM_NON_DEMAND(misses); 17248833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 17258833Sdam.sunwoo@arm.com overallMisses.subname(i, system->getMasterName(i)); 17268833Sdam.sunwoo@arm.com } 17272810SN/A 17282810SN/A // Miss latency statistics 17294022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 17304022SN/A MemCmd cmd(access_idx); 17314022SN/A const string &cstr = cmd.toString(); 17322810SN/A 17332810SN/A missLatency[access_idx] 17348833Sdam.sunwoo@arm.com .init(system->maxMasters()) 17352810SN/A .name(name() + "." + cstr + "_miss_latency") 17362810SN/A .desc("number of " + cstr + " miss cycles") 17372810SN/A .flags(total | nozero | nonan) 17382810SN/A ; 17398833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 17408833Sdam.sunwoo@arm.com missLatency[access_idx].subname(i, system->getMasterName(i)); 17418833Sdam.sunwoo@arm.com } 17422810SN/A } 17432810SN/A 17442810SN/A demandMissLatency 17452810SN/A .name(name() + ".demand_miss_latency") 17462810SN/A .desc("number of demand (read+write) miss cycles") 17478833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 17482810SN/A ; 17494871SN/A demandMissLatency = SUM_DEMAND(missLatency); 17508833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 17518833Sdam.sunwoo@arm.com demandMissLatency.subname(i, system->getMasterName(i)); 17528833Sdam.sunwoo@arm.com } 17532810SN/A 17542810SN/A overallMissLatency 17552810SN/A .name(name() + ".overall_miss_latency") 17562810SN/A .desc("number of overall miss cycles") 17578833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 17582810SN/A ; 17594871SN/A overallMissLatency = demandMissLatency + SUM_NON_DEMAND(missLatency); 17608833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 17618833Sdam.sunwoo@arm.com overallMissLatency.subname(i, system->getMasterName(i)); 17628833Sdam.sunwoo@arm.com } 17632810SN/A 17642810SN/A // access formulas 17654022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 17664022SN/A MemCmd cmd(access_idx); 17674022SN/A const string &cstr = cmd.toString(); 17682810SN/A 17692810SN/A accesses[access_idx] 17702810SN/A .name(name() + "." + cstr + "_accesses") 17712810SN/A .desc("number of " + cstr + " accesses(hits+misses)") 17722810SN/A .flags(total | nozero | nonan) 17732810SN/A ; 17748833Sdam.sunwoo@arm.com accesses[access_idx] = hits[access_idx] + misses[access_idx]; 17752810SN/A 17768833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 17778833Sdam.sunwoo@arm.com accesses[access_idx].subname(i, system->getMasterName(i)); 17788833Sdam.sunwoo@arm.com } 17792810SN/A } 17802810SN/A 17812810SN/A demandAccesses 17822810SN/A .name(name() + ".demand_accesses") 17832810SN/A .desc("number of demand (read+write) accesses") 17848833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 17852810SN/A ; 17862810SN/A demandAccesses = demandHits + demandMisses; 17878833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 17888833Sdam.sunwoo@arm.com demandAccesses.subname(i, system->getMasterName(i)); 17898833Sdam.sunwoo@arm.com } 17902810SN/A 17912810SN/A overallAccesses 17922810SN/A .name(name() + ".overall_accesses") 17932810SN/A .desc("number of overall (read+write) accesses") 17948833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 17952810SN/A ; 17962810SN/A overallAccesses = overallHits + overallMisses; 17978833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 17988833Sdam.sunwoo@arm.com overallAccesses.subname(i, system->getMasterName(i)); 17998833Sdam.sunwoo@arm.com } 18002810SN/A 18012810SN/A // miss rate formulas 18024022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 18034022SN/A MemCmd cmd(access_idx); 18044022SN/A const string &cstr = cmd.toString(); 18052810SN/A 18062810SN/A missRate[access_idx] 18072810SN/A .name(name() + "." + cstr + "_miss_rate") 18082810SN/A .desc("miss rate for " + cstr + " accesses") 18092810SN/A .flags(total | nozero | nonan) 18102810SN/A ; 18118833Sdam.sunwoo@arm.com missRate[access_idx] = misses[access_idx] / accesses[access_idx]; 18122810SN/A 18138833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 18148833Sdam.sunwoo@arm.com missRate[access_idx].subname(i, system->getMasterName(i)); 18158833Sdam.sunwoo@arm.com } 18162810SN/A } 18172810SN/A 18182810SN/A demandMissRate 18192810SN/A .name(name() + ".demand_miss_rate") 18202810SN/A .desc("miss rate for demand accesses") 18218833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 18222810SN/A ; 18232810SN/A demandMissRate = demandMisses / demandAccesses; 18248833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 18258833Sdam.sunwoo@arm.com demandMissRate.subname(i, system->getMasterName(i)); 18268833Sdam.sunwoo@arm.com } 18272810SN/A 18282810SN/A overallMissRate 18292810SN/A .name(name() + ".overall_miss_rate") 18302810SN/A .desc("miss rate for overall accesses") 18318833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 18322810SN/A ; 18332810SN/A overallMissRate = overallMisses / overallAccesses; 18348833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 18358833Sdam.sunwoo@arm.com overallMissRate.subname(i, system->getMasterName(i)); 18368833Sdam.sunwoo@arm.com } 18372810SN/A 18382810SN/A // miss latency formulas 18394022SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 18404022SN/A MemCmd cmd(access_idx); 18414022SN/A const string &cstr = cmd.toString(); 18422810SN/A 18432810SN/A avgMissLatency[access_idx] 18442810SN/A .name(name() + "." + cstr + "_avg_miss_latency") 18452810SN/A .desc("average " + cstr + " miss latency") 18462810SN/A .flags(total | nozero | nonan) 18472810SN/A ; 18482810SN/A avgMissLatency[access_idx] = 18492810SN/A missLatency[access_idx] / misses[access_idx]; 18508833Sdam.sunwoo@arm.com 18518833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 18528833Sdam.sunwoo@arm.com avgMissLatency[access_idx].subname(i, system->getMasterName(i)); 18538833Sdam.sunwoo@arm.com } 18542810SN/A } 18552810SN/A 18562810SN/A demandAvgMissLatency 18572810SN/A .name(name() + ".demand_avg_miss_latency") 18582810SN/A .desc("average overall miss latency") 18598833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 18602810SN/A ; 18612810SN/A demandAvgMissLatency = demandMissLatency / demandMisses; 18628833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 18638833Sdam.sunwoo@arm.com demandAvgMissLatency.subname(i, system->getMasterName(i)); 18648833Sdam.sunwoo@arm.com } 18652810SN/A 18662810SN/A overallAvgMissLatency 18672810SN/A .name(name() + ".overall_avg_miss_latency") 18682810SN/A .desc("average overall miss latency") 18698833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 18702810SN/A ; 18712810SN/A overallAvgMissLatency = overallMissLatency / overallMisses; 18728833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 18738833Sdam.sunwoo@arm.com overallAvgMissLatency.subname(i, system->getMasterName(i)); 18748833Sdam.sunwoo@arm.com } 18752810SN/A 18762810SN/A blocked_cycles.init(NUM_BLOCKED_CAUSES); 18772810SN/A blocked_cycles 18782810SN/A .name(name() + ".blocked_cycles") 18792810SN/A .desc("number of cycles access was blocked") 18802810SN/A .subname(Blocked_NoMSHRs, "no_mshrs") 18812810SN/A .subname(Blocked_NoTargets, "no_targets") 18822810SN/A ; 18832810SN/A 18842810SN/A 18852810SN/A blocked_causes.init(NUM_BLOCKED_CAUSES); 18862810SN/A blocked_causes 18872810SN/A .name(name() + ".blocked") 18882810SN/A .desc("number of cycles access was blocked") 18892810SN/A .subname(Blocked_NoMSHRs, "no_mshrs") 18902810SN/A .subname(Blocked_NoTargets, "no_targets") 18912810SN/A ; 18922810SN/A 18932810SN/A avg_blocked 18942810SN/A .name(name() + ".avg_blocked_cycles") 18952810SN/A .desc("average number of cycles each access was blocked") 18962810SN/A .subname(Blocked_NoMSHRs, "no_mshrs") 18972810SN/A .subname(Blocked_NoTargets, "no_targets") 18982810SN/A ; 18992810SN/A 19002810SN/A avg_blocked = blocked_cycles / blocked_causes; 19012810SN/A 190211436SRekai.GonzalezAlberquilla@arm.com unusedPrefetches 190311436SRekai.GonzalezAlberquilla@arm.com .name(name() + ".unused_prefetches") 190411436SRekai.GonzalezAlberquilla@arm.com .desc("number of HardPF blocks evicted w/o reference") 190511436SRekai.GonzalezAlberquilla@arm.com .flags(nozero) 190611436SRekai.GonzalezAlberquilla@arm.com ; 190711436SRekai.GonzalezAlberquilla@arm.com 19084626SN/A writebacks 19098833Sdam.sunwoo@arm.com .init(system->maxMasters()) 19104626SN/A .name(name() + ".writebacks") 19114626SN/A .desc("number of writebacks") 19128833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 19134626SN/A ; 19148833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 19158833Sdam.sunwoo@arm.com writebacks.subname(i, system->getMasterName(i)); 19168833Sdam.sunwoo@arm.com } 19174626SN/A 19184626SN/A // MSHR statistics 19194626SN/A // MSHR hit statistics 19204626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 19214626SN/A MemCmd cmd(access_idx); 19224626SN/A const string &cstr = cmd.toString(); 19234626SN/A 19244626SN/A mshr_hits[access_idx] 19258833Sdam.sunwoo@arm.com .init(system->maxMasters()) 19264626SN/A .name(name() + "." + cstr + "_mshr_hits") 19274626SN/A .desc("number of " + cstr + " MSHR hits") 19284626SN/A .flags(total | nozero | nonan) 19294626SN/A ; 19308833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 19318833Sdam.sunwoo@arm.com mshr_hits[access_idx].subname(i, system->getMasterName(i)); 19328833Sdam.sunwoo@arm.com } 19334626SN/A } 19344626SN/A 19354626SN/A demandMshrHits 19364626SN/A .name(name() + ".demand_mshr_hits") 19374626SN/A .desc("number of demand (read+write) MSHR hits") 19388833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 19394626SN/A ; 19404871SN/A demandMshrHits = SUM_DEMAND(mshr_hits); 19418833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 19428833Sdam.sunwoo@arm.com demandMshrHits.subname(i, system->getMasterName(i)); 19438833Sdam.sunwoo@arm.com } 19444626SN/A 19454626SN/A overallMshrHits 19464626SN/A .name(name() + ".overall_mshr_hits") 19474626SN/A .desc("number of overall MSHR hits") 19488833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 19494626SN/A ; 19504871SN/A overallMshrHits = demandMshrHits + SUM_NON_DEMAND(mshr_hits); 19518833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 19528833Sdam.sunwoo@arm.com overallMshrHits.subname(i, system->getMasterName(i)); 19538833Sdam.sunwoo@arm.com } 19544626SN/A 19554626SN/A // MSHR miss statistics 19564626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 19574626SN/A MemCmd cmd(access_idx); 19584626SN/A const string &cstr = cmd.toString(); 19594626SN/A 19604626SN/A mshr_misses[access_idx] 19618833Sdam.sunwoo@arm.com .init(system->maxMasters()) 19624626SN/A .name(name() + "." + cstr + "_mshr_misses") 19634626SN/A .desc("number of " + cstr + " MSHR misses") 19644626SN/A .flags(total | nozero | nonan) 19654626SN/A ; 19668833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 19678833Sdam.sunwoo@arm.com mshr_misses[access_idx].subname(i, system->getMasterName(i)); 19688833Sdam.sunwoo@arm.com } 19694626SN/A } 19704626SN/A 19714626SN/A demandMshrMisses 19724626SN/A .name(name() + ".demand_mshr_misses") 19734626SN/A .desc("number of demand (read+write) MSHR misses") 19748833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 19754626SN/A ; 19764871SN/A demandMshrMisses = SUM_DEMAND(mshr_misses); 19778833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 19788833Sdam.sunwoo@arm.com demandMshrMisses.subname(i, system->getMasterName(i)); 19798833Sdam.sunwoo@arm.com } 19804626SN/A 19814626SN/A overallMshrMisses 19824626SN/A .name(name() + ".overall_mshr_misses") 19834626SN/A .desc("number of overall MSHR misses") 19848833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 19854626SN/A ; 19864871SN/A overallMshrMisses = demandMshrMisses + SUM_NON_DEMAND(mshr_misses); 19878833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 19888833Sdam.sunwoo@arm.com overallMshrMisses.subname(i, system->getMasterName(i)); 19898833Sdam.sunwoo@arm.com } 19904626SN/A 19914626SN/A // MSHR miss latency statistics 19924626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 19934626SN/A MemCmd cmd(access_idx); 19944626SN/A const string &cstr = cmd.toString(); 19954626SN/A 19964626SN/A mshr_miss_latency[access_idx] 19978833Sdam.sunwoo@arm.com .init(system->maxMasters()) 19984626SN/A .name(name() + "." + cstr + "_mshr_miss_latency") 19994626SN/A .desc("number of " + cstr + " MSHR miss cycles") 20004626SN/A .flags(total | nozero | nonan) 20014626SN/A ; 20028833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 20038833Sdam.sunwoo@arm.com mshr_miss_latency[access_idx].subname(i, system->getMasterName(i)); 20048833Sdam.sunwoo@arm.com } 20054626SN/A } 20064626SN/A 20074626SN/A demandMshrMissLatency 20084626SN/A .name(name() + ".demand_mshr_miss_latency") 20094626SN/A .desc("number of demand (read+write) MSHR miss cycles") 20108833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 20114626SN/A ; 20124871SN/A demandMshrMissLatency = SUM_DEMAND(mshr_miss_latency); 20138833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 20148833Sdam.sunwoo@arm.com demandMshrMissLatency.subname(i, system->getMasterName(i)); 20158833Sdam.sunwoo@arm.com } 20164626SN/A 20174626SN/A overallMshrMissLatency 20184626SN/A .name(name() + ".overall_mshr_miss_latency") 20194626SN/A .desc("number of overall MSHR miss cycles") 20208833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 20214626SN/A ; 20224871SN/A overallMshrMissLatency = 20234871SN/A demandMshrMissLatency + SUM_NON_DEMAND(mshr_miss_latency); 20248833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 20258833Sdam.sunwoo@arm.com overallMshrMissLatency.subname(i, system->getMasterName(i)); 20268833Sdam.sunwoo@arm.com } 20274626SN/A 20284626SN/A // MSHR uncacheable statistics 20294626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 20304626SN/A MemCmd cmd(access_idx); 20314626SN/A const string &cstr = cmd.toString(); 20324626SN/A 20334626SN/A mshr_uncacheable[access_idx] 20348833Sdam.sunwoo@arm.com .init(system->maxMasters()) 20354626SN/A .name(name() + "." + cstr + "_mshr_uncacheable") 20364626SN/A .desc("number of " + cstr + " MSHR uncacheable") 20374626SN/A .flags(total | nozero | nonan) 20384626SN/A ; 20398833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 20408833Sdam.sunwoo@arm.com mshr_uncacheable[access_idx].subname(i, system->getMasterName(i)); 20418833Sdam.sunwoo@arm.com } 20424626SN/A } 20434626SN/A 20444626SN/A overallMshrUncacheable 20454626SN/A .name(name() + ".overall_mshr_uncacheable_misses") 20464626SN/A .desc("number of overall MSHR uncacheable misses") 20478833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 20484626SN/A ; 20494871SN/A overallMshrUncacheable = 20504871SN/A SUM_DEMAND(mshr_uncacheable) + SUM_NON_DEMAND(mshr_uncacheable); 20518833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 20528833Sdam.sunwoo@arm.com overallMshrUncacheable.subname(i, system->getMasterName(i)); 20538833Sdam.sunwoo@arm.com } 20544626SN/A 20554626SN/A // MSHR miss latency statistics 20564626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 20574626SN/A MemCmd cmd(access_idx); 20584626SN/A const string &cstr = cmd.toString(); 20594626SN/A 20604626SN/A mshr_uncacheable_lat[access_idx] 20618833Sdam.sunwoo@arm.com .init(system->maxMasters()) 20624626SN/A .name(name() + "." + cstr + "_mshr_uncacheable_latency") 20634626SN/A .desc("number of " + cstr + " MSHR uncacheable cycles") 20644626SN/A .flags(total | nozero | nonan) 20654626SN/A ; 20668833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 206711483Snikos.nikoleris@arm.com mshr_uncacheable_lat[access_idx].subname( 206811483Snikos.nikoleris@arm.com i, system->getMasterName(i)); 20698833Sdam.sunwoo@arm.com } 20704626SN/A } 20714626SN/A 20724626SN/A overallMshrUncacheableLatency 20734626SN/A .name(name() + ".overall_mshr_uncacheable_latency") 20744626SN/A .desc("number of overall MSHR uncacheable cycles") 20758833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 20764626SN/A ; 20774871SN/A overallMshrUncacheableLatency = 20784871SN/A SUM_DEMAND(mshr_uncacheable_lat) + 20794871SN/A SUM_NON_DEMAND(mshr_uncacheable_lat); 20808833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 20818833Sdam.sunwoo@arm.com overallMshrUncacheableLatency.subname(i, system->getMasterName(i)); 20828833Sdam.sunwoo@arm.com } 20834626SN/A 20844626SN/A#if 0 20854626SN/A // MSHR access formulas 20864626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 20874626SN/A MemCmd cmd(access_idx); 20884626SN/A const string &cstr = cmd.toString(); 20894626SN/A 20904626SN/A mshrAccesses[access_idx] 20914626SN/A .name(name() + "." + cstr + "_mshr_accesses") 20924626SN/A .desc("number of " + cstr + " mshr accesses(hits+misses)") 20934626SN/A .flags(total | nozero | nonan) 20944626SN/A ; 20954626SN/A mshrAccesses[access_idx] = 20964626SN/A mshr_hits[access_idx] + mshr_misses[access_idx] 20974626SN/A + mshr_uncacheable[access_idx]; 20984626SN/A } 20994626SN/A 21004626SN/A demandMshrAccesses 21014626SN/A .name(name() + ".demand_mshr_accesses") 21024626SN/A .desc("number of demand (read+write) mshr accesses") 21034626SN/A .flags(total | nozero | nonan) 21044626SN/A ; 21054626SN/A demandMshrAccesses = demandMshrHits + demandMshrMisses; 21064626SN/A 21074626SN/A overallMshrAccesses 21084626SN/A .name(name() + ".overall_mshr_accesses") 21094626SN/A .desc("number of overall (read+write) mshr accesses") 21104626SN/A .flags(total | nozero | nonan) 21114626SN/A ; 21124626SN/A overallMshrAccesses = overallMshrHits + overallMshrMisses 21134626SN/A + overallMshrUncacheable; 21144626SN/A#endif 21154626SN/A 21164626SN/A // MSHR miss rate formulas 21174626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 21184626SN/A MemCmd cmd(access_idx); 21194626SN/A const string &cstr = cmd.toString(); 21204626SN/A 21214626SN/A mshrMissRate[access_idx] 21224626SN/A .name(name() + "." + cstr + "_mshr_miss_rate") 21234626SN/A .desc("mshr miss rate for " + cstr + " accesses") 21244626SN/A .flags(total | nozero | nonan) 21254626SN/A ; 21264626SN/A mshrMissRate[access_idx] = 21274626SN/A mshr_misses[access_idx] / accesses[access_idx]; 21288833Sdam.sunwoo@arm.com 21298833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 21308833Sdam.sunwoo@arm.com mshrMissRate[access_idx].subname(i, system->getMasterName(i)); 21318833Sdam.sunwoo@arm.com } 21324626SN/A } 21334626SN/A 21344626SN/A demandMshrMissRate 21354626SN/A .name(name() + ".demand_mshr_miss_rate") 21364626SN/A .desc("mshr miss rate for demand accesses") 21378833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 21384626SN/A ; 21394626SN/A demandMshrMissRate = demandMshrMisses / demandAccesses; 21408833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 21418833Sdam.sunwoo@arm.com demandMshrMissRate.subname(i, system->getMasterName(i)); 21428833Sdam.sunwoo@arm.com } 21434626SN/A 21444626SN/A overallMshrMissRate 21454626SN/A .name(name() + ".overall_mshr_miss_rate") 21464626SN/A .desc("mshr miss rate for overall accesses") 21478833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 21484626SN/A ; 21494626SN/A overallMshrMissRate = overallMshrMisses / overallAccesses; 21508833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 21518833Sdam.sunwoo@arm.com overallMshrMissRate.subname(i, system->getMasterName(i)); 21528833Sdam.sunwoo@arm.com } 21534626SN/A 21544626SN/A // mshrMiss latency formulas 21554626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 21564626SN/A MemCmd cmd(access_idx); 21574626SN/A const string &cstr = cmd.toString(); 21584626SN/A 21594626SN/A avgMshrMissLatency[access_idx] 21604626SN/A .name(name() + "." + cstr + "_avg_mshr_miss_latency") 21614626SN/A .desc("average " + cstr + " mshr miss latency") 21624626SN/A .flags(total | nozero | nonan) 21634626SN/A ; 21644626SN/A avgMshrMissLatency[access_idx] = 21654626SN/A mshr_miss_latency[access_idx] / mshr_misses[access_idx]; 21668833Sdam.sunwoo@arm.com 21678833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 216811483Snikos.nikoleris@arm.com avgMshrMissLatency[access_idx].subname( 216911483Snikos.nikoleris@arm.com i, system->getMasterName(i)); 21708833Sdam.sunwoo@arm.com } 21714626SN/A } 21724626SN/A 21734626SN/A demandAvgMshrMissLatency 21744626SN/A .name(name() + ".demand_avg_mshr_miss_latency") 21754626SN/A .desc("average overall mshr miss latency") 21768833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 21774626SN/A ; 21784626SN/A demandAvgMshrMissLatency = demandMshrMissLatency / demandMshrMisses; 21798833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 21808833Sdam.sunwoo@arm.com demandAvgMshrMissLatency.subname(i, system->getMasterName(i)); 21818833Sdam.sunwoo@arm.com } 21824626SN/A 21834626SN/A overallAvgMshrMissLatency 21844626SN/A .name(name() + ".overall_avg_mshr_miss_latency") 21854626SN/A .desc("average overall mshr miss latency") 21868833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 21874626SN/A ; 21884626SN/A overallAvgMshrMissLatency = overallMshrMissLatency / overallMshrMisses; 21898833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 21908833Sdam.sunwoo@arm.com overallAvgMshrMissLatency.subname(i, system->getMasterName(i)); 21918833Sdam.sunwoo@arm.com } 21924626SN/A 21934626SN/A // mshrUncacheable latency formulas 21944626SN/A for (int access_idx = 0; access_idx < MemCmd::NUM_MEM_CMDS; ++access_idx) { 21954626SN/A MemCmd cmd(access_idx); 21964626SN/A const string &cstr = cmd.toString(); 21974626SN/A 21984626SN/A avgMshrUncacheableLatency[access_idx] 21994626SN/A .name(name() + "." + cstr + "_avg_mshr_uncacheable_latency") 22004626SN/A .desc("average " + cstr + " mshr uncacheable latency") 22014626SN/A .flags(total | nozero | nonan) 22024626SN/A ; 22034626SN/A avgMshrUncacheableLatency[access_idx] = 22044626SN/A mshr_uncacheable_lat[access_idx] / mshr_uncacheable[access_idx]; 22058833Sdam.sunwoo@arm.com 22068833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 220711483Snikos.nikoleris@arm.com avgMshrUncacheableLatency[access_idx].subname( 220811483Snikos.nikoleris@arm.com i, system->getMasterName(i)); 22098833Sdam.sunwoo@arm.com } 22104626SN/A } 22114626SN/A 22124626SN/A overallAvgMshrUncacheableLatency 22134626SN/A .name(name() + ".overall_avg_mshr_uncacheable_latency") 22144626SN/A .desc("average overall mshr uncacheable latency") 22158833Sdam.sunwoo@arm.com .flags(total | nozero | nonan) 22164626SN/A ; 221711483Snikos.nikoleris@arm.com overallAvgMshrUncacheableLatency = 221811483Snikos.nikoleris@arm.com overallMshrUncacheableLatency / overallMshrUncacheable; 22198833Sdam.sunwoo@arm.com for (int i = 0; i < system->maxMasters(); i++) { 22208833Sdam.sunwoo@arm.com overallAvgMshrUncacheableLatency.subname(i, system->getMasterName(i)); 22218833Sdam.sunwoo@arm.com } 22224626SN/A 222312702Snikos.nikoleris@arm.com replacements 222412702Snikos.nikoleris@arm.com .name(name() + ".replacements") 222512702Snikos.nikoleris@arm.com .desc("number of replacements") 222612702Snikos.nikoleris@arm.com ; 22272810SN/A} 222812724Snikos.nikoleris@arm.com 222912724Snikos.nikoleris@arm.com/////////////// 223012724Snikos.nikoleris@arm.com// 223112724Snikos.nikoleris@arm.com// CpuSidePort 223212724Snikos.nikoleris@arm.com// 223312724Snikos.nikoleris@arm.com/////////////// 223412724Snikos.nikoleris@arm.combool 223512724Snikos.nikoleris@arm.comBaseCache::CpuSidePort::recvTimingSnoopResp(PacketPtr pkt) 223612724Snikos.nikoleris@arm.com{ 223712725Snikos.nikoleris@arm.com // Snoops shouldn't happen when bypassing caches 223812725Snikos.nikoleris@arm.com assert(!cache->system->bypassCaches()); 223912725Snikos.nikoleris@arm.com 224012725Snikos.nikoleris@arm.com assert(pkt->isResponse()); 224112725Snikos.nikoleris@arm.com 224212724Snikos.nikoleris@arm.com // Express snoop responses from master to slave, e.g., from L1 to L2 224312724Snikos.nikoleris@arm.com cache->recvTimingSnoopResp(pkt); 224412724Snikos.nikoleris@arm.com return true; 224512724Snikos.nikoleris@arm.com} 224612724Snikos.nikoleris@arm.com 224712724Snikos.nikoleris@arm.com 224812724Snikos.nikoleris@arm.combool 224912724Snikos.nikoleris@arm.comBaseCache::CpuSidePort::tryTiming(PacketPtr pkt) 225012724Snikos.nikoleris@arm.com{ 225112725Snikos.nikoleris@arm.com if (cache->system->bypassCaches() || pkt->isExpressSnoop()) { 225212724Snikos.nikoleris@arm.com // always let express snoop packets through even if blocked 225312724Snikos.nikoleris@arm.com return true; 225412724Snikos.nikoleris@arm.com } else if (blocked || mustSendRetry) { 225512724Snikos.nikoleris@arm.com // either already committed to send a retry, or blocked 225612724Snikos.nikoleris@arm.com mustSendRetry = true; 225712724Snikos.nikoleris@arm.com return false; 225812724Snikos.nikoleris@arm.com } 225912724Snikos.nikoleris@arm.com mustSendRetry = false; 226012724Snikos.nikoleris@arm.com return true; 226112724Snikos.nikoleris@arm.com} 226212724Snikos.nikoleris@arm.com 226312724Snikos.nikoleris@arm.combool 226412724Snikos.nikoleris@arm.comBaseCache::CpuSidePort::recvTimingReq(PacketPtr pkt) 226512724Snikos.nikoleris@arm.com{ 226612725Snikos.nikoleris@arm.com assert(pkt->isRequest()); 226712725Snikos.nikoleris@arm.com 226812725Snikos.nikoleris@arm.com if (cache->system->bypassCaches()) { 226912725Snikos.nikoleris@arm.com // Just forward the packet if caches are disabled. 227012725Snikos.nikoleris@arm.com // @todo This should really enqueue the packet rather 227112725Snikos.nikoleris@arm.com bool M5_VAR_USED success = cache->memSidePort.sendTimingReq(pkt); 227212725Snikos.nikoleris@arm.com assert(success); 227312725Snikos.nikoleris@arm.com return true; 227412725Snikos.nikoleris@arm.com } else if (tryTiming(pkt)) { 227512724Snikos.nikoleris@arm.com cache->recvTimingReq(pkt); 227612724Snikos.nikoleris@arm.com return true; 227712724Snikos.nikoleris@arm.com } 227812724Snikos.nikoleris@arm.com return false; 227912724Snikos.nikoleris@arm.com} 228012724Snikos.nikoleris@arm.com 228112724Snikos.nikoleris@arm.comTick 228212724Snikos.nikoleris@arm.comBaseCache::CpuSidePort::recvAtomic(PacketPtr pkt) 228312724Snikos.nikoleris@arm.com{ 228412725Snikos.nikoleris@arm.com if (cache->system->bypassCaches()) { 228512725Snikos.nikoleris@arm.com // Forward the request if the system is in cache bypass mode. 228612725Snikos.nikoleris@arm.com return cache->memSidePort.sendAtomic(pkt); 228712725Snikos.nikoleris@arm.com } else { 228812725Snikos.nikoleris@arm.com return cache->recvAtomic(pkt); 228912725Snikos.nikoleris@arm.com } 229012724Snikos.nikoleris@arm.com} 229112724Snikos.nikoleris@arm.com 229212724Snikos.nikoleris@arm.comvoid 229312724Snikos.nikoleris@arm.comBaseCache::CpuSidePort::recvFunctional(PacketPtr pkt) 229412724Snikos.nikoleris@arm.com{ 229512725Snikos.nikoleris@arm.com if (cache->system->bypassCaches()) { 229612725Snikos.nikoleris@arm.com // The cache should be flushed if we are in cache bypass mode, 229712725Snikos.nikoleris@arm.com // so we don't need to check if we need to update anything. 229812725Snikos.nikoleris@arm.com cache->memSidePort.sendFunctional(pkt); 229912725Snikos.nikoleris@arm.com return; 230012725Snikos.nikoleris@arm.com } 230112725Snikos.nikoleris@arm.com 230212724Snikos.nikoleris@arm.com // functional request 230312724Snikos.nikoleris@arm.com cache->functionalAccess(pkt, true); 230412724Snikos.nikoleris@arm.com} 230512724Snikos.nikoleris@arm.com 230612724Snikos.nikoleris@arm.comAddrRangeList 230712724Snikos.nikoleris@arm.comBaseCache::CpuSidePort::getAddrRanges() const 230812724Snikos.nikoleris@arm.com{ 230912724Snikos.nikoleris@arm.com return cache->getAddrRanges(); 231012724Snikos.nikoleris@arm.com} 231112724Snikos.nikoleris@arm.com 231212724Snikos.nikoleris@arm.com 231312724Snikos.nikoleris@arm.comBaseCache:: 231412724Snikos.nikoleris@arm.comCpuSidePort::CpuSidePort(const std::string &_name, BaseCache *_cache, 231512724Snikos.nikoleris@arm.com const std::string &_label) 231612724Snikos.nikoleris@arm.com : CacheSlavePort(_name, _cache, _label), cache(_cache) 231712724Snikos.nikoleris@arm.com{ 231812724Snikos.nikoleris@arm.com} 231912724Snikos.nikoleris@arm.com 232012724Snikos.nikoleris@arm.com/////////////// 232112724Snikos.nikoleris@arm.com// 232212724Snikos.nikoleris@arm.com// MemSidePort 232312724Snikos.nikoleris@arm.com// 232412724Snikos.nikoleris@arm.com/////////////// 232512724Snikos.nikoleris@arm.combool 232612724Snikos.nikoleris@arm.comBaseCache::MemSidePort::recvTimingResp(PacketPtr pkt) 232712724Snikos.nikoleris@arm.com{ 232812724Snikos.nikoleris@arm.com cache->recvTimingResp(pkt); 232912724Snikos.nikoleris@arm.com return true; 233012724Snikos.nikoleris@arm.com} 233112724Snikos.nikoleris@arm.com 233212724Snikos.nikoleris@arm.com// Express snooping requests to memside port 233312724Snikos.nikoleris@arm.comvoid 233412724Snikos.nikoleris@arm.comBaseCache::MemSidePort::recvTimingSnoopReq(PacketPtr pkt) 233512724Snikos.nikoleris@arm.com{ 233612725Snikos.nikoleris@arm.com // Snoops shouldn't happen when bypassing caches 233712725Snikos.nikoleris@arm.com assert(!cache->system->bypassCaches()); 233812725Snikos.nikoleris@arm.com 233912724Snikos.nikoleris@arm.com // handle snooping requests 234012724Snikos.nikoleris@arm.com cache->recvTimingSnoopReq(pkt); 234112724Snikos.nikoleris@arm.com} 234212724Snikos.nikoleris@arm.com 234312724Snikos.nikoleris@arm.comTick 234412724Snikos.nikoleris@arm.comBaseCache::MemSidePort::recvAtomicSnoop(PacketPtr pkt) 234512724Snikos.nikoleris@arm.com{ 234612725Snikos.nikoleris@arm.com // Snoops shouldn't happen when bypassing caches 234712725Snikos.nikoleris@arm.com assert(!cache->system->bypassCaches()); 234812725Snikos.nikoleris@arm.com 234912724Snikos.nikoleris@arm.com return cache->recvAtomicSnoop(pkt); 235012724Snikos.nikoleris@arm.com} 235112724Snikos.nikoleris@arm.com 235212724Snikos.nikoleris@arm.comvoid 235312724Snikos.nikoleris@arm.comBaseCache::MemSidePort::recvFunctionalSnoop(PacketPtr pkt) 235412724Snikos.nikoleris@arm.com{ 235512725Snikos.nikoleris@arm.com // Snoops shouldn't happen when bypassing caches 235612725Snikos.nikoleris@arm.com assert(!cache->system->bypassCaches()); 235712725Snikos.nikoleris@arm.com 235812724Snikos.nikoleris@arm.com // functional snoop (note that in contrast to atomic we don't have 235912724Snikos.nikoleris@arm.com // a specific functionalSnoop method, as they have the same 236012724Snikos.nikoleris@arm.com // behaviour regardless) 236112724Snikos.nikoleris@arm.com cache->functionalAccess(pkt, false); 236212724Snikos.nikoleris@arm.com} 236312724Snikos.nikoleris@arm.com 236412724Snikos.nikoleris@arm.comvoid 236512724Snikos.nikoleris@arm.comBaseCache::CacheReqPacketQueue::sendDeferredPacket() 236612724Snikos.nikoleris@arm.com{ 236712724Snikos.nikoleris@arm.com // sanity check 236812724Snikos.nikoleris@arm.com assert(!waitingOnRetry); 236912724Snikos.nikoleris@arm.com 237012724Snikos.nikoleris@arm.com // there should never be any deferred request packets in the 237112724Snikos.nikoleris@arm.com // queue, instead we resly on the cache to provide the packets 237212724Snikos.nikoleris@arm.com // from the MSHR queue or write queue 237312724Snikos.nikoleris@arm.com assert(deferredPacketReadyTime() == MaxTick); 237412724Snikos.nikoleris@arm.com 237512724Snikos.nikoleris@arm.com // check for request packets (requests & writebacks) 237612724Snikos.nikoleris@arm.com QueueEntry* entry = cache.getNextQueueEntry(); 237712724Snikos.nikoleris@arm.com 237812724Snikos.nikoleris@arm.com if (!entry) { 237912724Snikos.nikoleris@arm.com // can happen if e.g. we attempt a writeback and fail, but 238012724Snikos.nikoleris@arm.com // before the retry, the writeback is eliminated because 238112724Snikos.nikoleris@arm.com // we snoop another cache's ReadEx. 238212724Snikos.nikoleris@arm.com } else { 238312724Snikos.nikoleris@arm.com // let our snoop responses go first if there are responses to 238412724Snikos.nikoleris@arm.com // the same addresses 238512724Snikos.nikoleris@arm.com if (checkConflictingSnoop(entry->blkAddr)) { 238612724Snikos.nikoleris@arm.com return; 238712724Snikos.nikoleris@arm.com } 238812724Snikos.nikoleris@arm.com waitingOnRetry = entry->sendPacket(cache); 238912724Snikos.nikoleris@arm.com } 239012724Snikos.nikoleris@arm.com 239112724Snikos.nikoleris@arm.com // if we succeeded and are not waiting for a retry, schedule the 239212724Snikos.nikoleris@arm.com // next send considering when the next queue is ready, note that 239312724Snikos.nikoleris@arm.com // snoop responses have their own packet queue and thus schedule 239412724Snikos.nikoleris@arm.com // their own events 239512724Snikos.nikoleris@arm.com if (!waitingOnRetry) { 239612724Snikos.nikoleris@arm.com schedSendEvent(cache.nextQueueReadyTime()); 239712724Snikos.nikoleris@arm.com } 239812724Snikos.nikoleris@arm.com} 239912724Snikos.nikoleris@arm.com 240012724Snikos.nikoleris@arm.comBaseCache::MemSidePort::MemSidePort(const std::string &_name, 240112724Snikos.nikoleris@arm.com BaseCache *_cache, 240212724Snikos.nikoleris@arm.com const std::string &_label) 240312724Snikos.nikoleris@arm.com : CacheMasterPort(_name, _cache, _reqQueue, _snoopRespQueue), 240412724Snikos.nikoleris@arm.com _reqQueue(*_cache, *this, _snoopRespQueue, _label), 240512724Snikos.nikoleris@arm.com _snoopRespQueue(*_cache, *this, _label), cache(_cache) 240612724Snikos.nikoleris@arm.com{ 240712724Snikos.nikoleris@arm.com} 240813352Snikos.nikoleris@arm.com 240913352Snikos.nikoleris@arm.comvoid 241013352Snikos.nikoleris@arm.comWriteAllocator::updateMode(Addr write_addr, unsigned write_size, 241113352Snikos.nikoleris@arm.com Addr blk_addr) 241213352Snikos.nikoleris@arm.com{ 241313352Snikos.nikoleris@arm.com // check if we are continuing where the last write ended 241413352Snikos.nikoleris@arm.com if (nextAddr == write_addr) { 241513352Snikos.nikoleris@arm.com delayCtr[blk_addr] = delayThreshold; 241613352Snikos.nikoleris@arm.com // stop if we have already saturated 241713352Snikos.nikoleris@arm.com if (mode != WriteMode::NO_ALLOCATE) { 241813352Snikos.nikoleris@arm.com byteCount += write_size; 241913352Snikos.nikoleris@arm.com // switch to streaming mode if we have passed the lower 242013352Snikos.nikoleris@arm.com // threshold 242113352Snikos.nikoleris@arm.com if (mode == WriteMode::ALLOCATE && 242213352Snikos.nikoleris@arm.com byteCount > coalesceLimit) { 242313352Snikos.nikoleris@arm.com mode = WriteMode::COALESCE; 242413352Snikos.nikoleris@arm.com DPRINTF(Cache, "Switched to write coalescing\n"); 242513352Snikos.nikoleris@arm.com } else if (mode == WriteMode::COALESCE && 242613352Snikos.nikoleris@arm.com byteCount > noAllocateLimit) { 242713352Snikos.nikoleris@arm.com // and continue and switch to non-allocating mode if we 242813352Snikos.nikoleris@arm.com // pass the upper threshold 242913352Snikos.nikoleris@arm.com mode = WriteMode::NO_ALLOCATE; 243013352Snikos.nikoleris@arm.com DPRINTF(Cache, "Switched to write-no-allocate\n"); 243113352Snikos.nikoleris@arm.com } 243213352Snikos.nikoleris@arm.com } 243313352Snikos.nikoleris@arm.com } else { 243413352Snikos.nikoleris@arm.com // we did not see a write matching the previous one, start 243513352Snikos.nikoleris@arm.com // over again 243613352Snikos.nikoleris@arm.com byteCount = write_size; 243713352Snikos.nikoleris@arm.com mode = WriteMode::ALLOCATE; 243813352Snikos.nikoleris@arm.com resetDelay(blk_addr); 243913352Snikos.nikoleris@arm.com } 244013352Snikos.nikoleris@arm.com nextAddr = write_addr + write_size; 244113352Snikos.nikoleris@arm.com} 244213352Snikos.nikoleris@arm.com 244313352Snikos.nikoleris@arm.comWriteAllocator* 244413352Snikos.nikoleris@arm.comWriteAllocatorParams::create() 244513352Snikos.nikoleris@arm.com{ 244613352Snikos.nikoleris@arm.com return new WriteAllocator(this); 244713352Snikos.nikoleris@arm.com} 2448