cache.cc (11286:2071db8f864b) | cache.cc (11288:57c340f947c7) |
---|---|
1/* 2 * Copyright (c) 2010-2015 ARM Limited 3 * All rights reserved. 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 44 unchanged lines hidden (view full) --- 53 54#include "mem/cache/cache.hh" 55 56#include "base/misc.hh" 57#include "base/types.hh" 58#include "debug/Cache.hh" 59#include "debug/CachePort.hh" 60#include "debug/CacheTags.hh" | 1/* 2 * Copyright (c) 2010-2015 ARM Limited 3 * All rights reserved. 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 44 unchanged lines hidden (view full) --- 53 54#include "mem/cache/cache.hh" 55 56#include "base/misc.hh" 57#include "base/types.hh" 58#include "debug/Cache.hh" 59#include "debug/CachePort.hh" 60#include "debug/CacheTags.hh" |
61#include "debug/CacheVerbose.hh" |
|
61#include "mem/cache/blk.hh" 62#include "mem/cache/mshr.hh" 63#include "mem/cache/prefetch/base.hh" 64#include "sim/sim_exit.hh" 65 66Cache::Cache(const CacheParams *p) 67 : BaseCache(p, p->system->cacheLineSize()), 68 tags(p->tags), --- 105 unchanged lines hidden (view full) --- 174 if (blk->checkWrite(pkt)) { 175 pkt->writeDataToBlock(blk->data, blkSize); 176 } 177 // Always mark the line as dirty (and thus transition to the 178 // Modified state) even if we are a failed StoreCond so we 179 // supply data to any snoops that have appended themselves to 180 // this cache before knowing the store will fail. 181 blk->status |= BlkDirty; | 62#include "mem/cache/blk.hh" 63#include "mem/cache/mshr.hh" 64#include "mem/cache/prefetch/base.hh" 65#include "sim/sim_exit.hh" 66 67Cache::Cache(const CacheParams *p) 68 : BaseCache(p, p->system->cacheLineSize()), 69 tags(p->tags), --- 105 unchanged lines hidden (view full) --- 175 if (blk->checkWrite(pkt)) { 176 pkt->writeDataToBlock(blk->data, blkSize); 177 } 178 // Always mark the line as dirty (and thus transition to the 179 // Modified state) even if we are a failed StoreCond so we 180 // supply data to any snoops that have appended themselves to 181 // this cache before knowing the store will fail. 182 blk->status |= BlkDirty; |
182 DPRINTF(Cache, "%s for %s addr %#llx size %d (write)\n", __func__, 183 pkt->cmdString(), pkt->getAddr(), pkt->getSize()); | 183 DPRINTF(CacheVerbose, "%s for %s addr %#llx size %d (write)\n", 184 __func__, pkt->cmdString(), pkt->getAddr(), pkt->getSize()); |
184 } else if (pkt->isRead()) { 185 if (pkt->isLLSC()) { 186 blk->trackLoadLocked(pkt); 187 } 188 189 // all read responses have a data payload 190 assert(pkt->hasRespData()); 191 pkt->setDataFromBlock(blk->data, blkSize); --- 83 unchanged lines hidden (view full) --- 275 } 276 } else { 277 // Upgrade or Invalidate 278 assert(pkt->isUpgrade() || pkt->isInvalidate()); 279 280 // for invalidations we could be looking at the temp block 281 // (for upgrades we always allocate) 282 invalidateBlock(blk); | 185 } else if (pkt->isRead()) { 186 if (pkt->isLLSC()) { 187 blk->trackLoadLocked(pkt); 188 } 189 190 // all read responses have a data payload 191 assert(pkt->hasRespData()); 192 pkt->setDataFromBlock(blk->data, blkSize); --- 83 unchanged lines hidden (view full) --- 276 } 277 } else { 278 // Upgrade or Invalidate 279 assert(pkt->isUpgrade() || pkt->isInvalidate()); 280 281 // for invalidations we could be looking at the temp block 282 // (for upgrades we always allocate) 283 invalidateBlock(blk); |
283 DPRINTF(Cache, "%s for %s addr %#llx size %d (invalidation)\n", | 284 DPRINTF(CacheVerbose, "%s for %s addr %#llx size %d (invalidation)\n", |
284 __func__, pkt->cmdString(), pkt->getAddr(), pkt->getSize()); 285 } 286} 287 288 289///////////////////////////////////////////////////// 290// 291// MSHR helper functions --- 19 unchanged lines hidden (view full) --- 311{ 312 // sanity check 313 assert(pkt->isRequest()); 314 315 chatty_assert(!(isReadOnly && pkt->isWrite()), 316 "Should never see a write in a read-only cache %s\n", 317 name()); 318 | 285 __func__, pkt->cmdString(), pkt->getAddr(), pkt->getSize()); 286 } 287} 288 289 290///////////////////////////////////////////////////// 291// 292// MSHR helper functions --- 19 unchanged lines hidden (view full) --- 312{ 313 // sanity check 314 assert(pkt->isRequest()); 315 316 chatty_assert(!(isReadOnly && pkt->isWrite()), 317 "Should never see a write in a read-only cache %s\n", 318 name()); 319 |
319 DPRINTF(Cache, "%s for %s addr %#llx size %d\n", __func__, | 320 DPRINTF(CacheVerbose, "%s for %s addr %#llx size %d\n", __func__, |
320 pkt->cmdString(), pkt->getAddr(), pkt->getSize()); 321 322 if (pkt->req->isUncacheable()) { 323 DPRINTF(Cache, "%s%s addr %#llx uncacheable\n", pkt->cmdString(), 324 pkt->req->isInstFetch() ? " (ifetch)" : "", 325 pkt->getAddr()); 326 327 // flush and invalidate any existing block --- 889 unchanged lines hidden (view full) --- 1217 (mshr && mshr->inService && mshr->isPendingModified())); 1218 1219 bool done = have_dirty 1220 || cpuSidePort->checkFunctional(pkt) 1221 || mshrQueue.checkFunctional(pkt, blk_addr) 1222 || writeBuffer.checkFunctional(pkt, blk_addr) 1223 || memSidePort->checkFunctional(pkt); 1224 | 321 pkt->cmdString(), pkt->getAddr(), pkt->getSize()); 322 323 if (pkt->req->isUncacheable()) { 324 DPRINTF(Cache, "%s%s addr %#llx uncacheable\n", pkt->cmdString(), 325 pkt->req->isInstFetch() ? " (ifetch)" : "", 326 pkt->getAddr()); 327 328 // flush and invalidate any existing block --- 889 unchanged lines hidden (view full) --- 1218 (mshr && mshr->inService && mshr->isPendingModified())); 1219 1220 bool done = have_dirty 1221 || cpuSidePort->checkFunctional(pkt) 1222 || mshrQueue.checkFunctional(pkt, blk_addr) 1223 || writeBuffer.checkFunctional(pkt, blk_addr) 1224 || memSidePort->checkFunctional(pkt); 1225 |
1225 DPRINTF(Cache, "functional %s %#llx (%s) %s%s%s\n", | 1226 DPRINTF(CacheVerbose, "functional %s %#llx (%s) %s%s%s\n", |
1226 pkt->cmdString(), pkt->getAddr(), is_secure ? "s" : "ns", 1227 (blk && blk->isValid()) ? "valid " : "", 1228 have_data ? "data " : "", done ? "done " : ""); 1229 1230 // We're leaving the cache, so pop cache->name() label 1231 pkt->popLabel(); 1232 1233 if (done) { --- 294 unchanged lines hidden (view full) --- 1528 if (isCachedAbove(wcPkt)) 1529 delete wcPkt; 1530 else 1531 allocateWriteBuffer(wcPkt, forward_time); 1532 } 1533 blk->invalidate(); 1534 } 1535 | 1227 pkt->cmdString(), pkt->getAddr(), is_secure ? "s" : "ns", 1228 (blk && blk->isValid()) ? "valid " : "", 1229 have_data ? "data " : "", done ? "done " : ""); 1230 1231 // We're leaving the cache, so pop cache->name() label 1232 pkt->popLabel(); 1233 1234 if (done) { --- 294 unchanged lines hidden (view full) --- 1529 if (isCachedAbove(wcPkt)) 1530 delete wcPkt; 1531 else 1532 allocateWriteBuffer(wcPkt, forward_time); 1533 } 1534 blk->invalidate(); 1535 } 1536 |
1536 DPRINTF(Cache, "Leaving %s with %s for addr %#llx\n", __func__, | 1537 DPRINTF(CacheVerbose, "Leaving %s with %s for addr %#llx\n", __func__, |
1537 pkt->cmdString(), pkt->getAddr()); 1538 delete pkt; 1539} 1540 1541PacketPtr 1542Cache::writebackBlk(CacheBlk *blk) 1543{ 1544 chatty_assert(!isReadOnly || writebackClean, --- 331 unchanged lines hidden (view full) --- 1876 pkt->cmd = MemCmd::ReadRespWithInvalidate; 1877 } 1878 // Here we consider forward_time, paying for just forward latency and 1879 // also charging the delay provided by the xbar. 1880 // forward_time is used as send_time in next allocateWriteBuffer(). 1881 Tick forward_time = clockEdge(forwardLatency) + pkt->headerDelay; 1882 // Here we reset the timing of the packet. 1883 pkt->headerDelay = pkt->payloadDelay = 0; | 1538 pkt->cmdString(), pkt->getAddr()); 1539 delete pkt; 1540} 1541 1542PacketPtr 1543Cache::writebackBlk(CacheBlk *blk) 1544{ 1545 chatty_assert(!isReadOnly || writebackClean, --- 331 unchanged lines hidden (view full) --- 1877 pkt->cmd = MemCmd::ReadRespWithInvalidate; 1878 } 1879 // Here we consider forward_time, paying for just forward latency and 1880 // also charging the delay provided by the xbar. 1881 // forward_time is used as send_time in next allocateWriteBuffer(). 1882 Tick forward_time = clockEdge(forwardLatency) + pkt->headerDelay; 1883 // Here we reset the timing of the packet. 1884 pkt->headerDelay = pkt->payloadDelay = 0; |
1884 DPRINTF(Cache, "%s created response: %s addr %#llx size %d tick: %lu\n", | 1885 DPRINTF(CacheVerbose, 1886 "%s created response: %s addr %#llx size %d tick: %lu\n", |
1885 __func__, pkt->cmdString(), pkt->getAddr(), pkt->getSize(), 1886 forward_time); 1887 memSidePort->schedTimingSnoopResp(pkt, forward_time, true); 1888} 1889 1890uint32_t 1891Cache::handleSnoop(PacketPtr pkt, CacheBlk *blk, bool is_timing, 1892 bool is_deferred, bool pending_inval) 1893{ | 1887 __func__, pkt->cmdString(), pkt->getAddr(), pkt->getSize(), 1888 forward_time); 1889 memSidePort->schedTimingSnoopResp(pkt, forward_time, true); 1890} 1891 1892uint32_t 1893Cache::handleSnoop(PacketPtr pkt, CacheBlk *blk, bool is_timing, 1894 bool is_deferred, bool pending_inval) 1895{ |
1894 DPRINTF(Cache, "%s for %s addr %#llx size %d\n", __func__, | 1896 DPRINTF(CacheVerbose, "%s for %s addr %#llx size %d\n", __func__, |
1895 pkt->cmdString(), pkt->getAddr(), pkt->getSize()); 1896 // deferred snoops can only happen in timing mode 1897 assert(!(is_deferred && !is_timing)); 1898 // pending_inval only makes sense on deferred snoops 1899 assert(!(pending_inval && !is_deferred)); 1900 assert(pkt->isRequest()); 1901 1902 // the packet may get modified if we or a forwarded snooper --- 55 unchanged lines hidden (view full) --- 1958 // cache-to-cache response from some upper cache: 1959 // forward response to original requester 1960 assert(pkt->isResponse()); 1961 } 1962 } 1963 } 1964 1965 if (!blk || !blk->isValid()) { | 1897 pkt->cmdString(), pkt->getAddr(), pkt->getSize()); 1898 // deferred snoops can only happen in timing mode 1899 assert(!(is_deferred && !is_timing)); 1900 // pending_inval only makes sense on deferred snoops 1901 assert(!(pending_inval && !is_deferred)); 1902 assert(pkt->isRequest()); 1903 1904 // the packet may get modified if we or a forwarded snooper --- 55 unchanged lines hidden (view full) --- 1960 // cache-to-cache response from some upper cache: 1961 // forward response to original requester 1962 assert(pkt->isResponse()); 1963 } 1964 } 1965 } 1966 1967 if (!blk || !blk->isValid()) { |
1966 DPRINTF(Cache, "%s snoop miss for %s addr %#llx size %d\n", | 1968 DPRINTF(CacheVerbose, "%s snoop miss for %s addr %#llx size %d\n", |
1967 __func__, pkt->cmdString(), pkt->getAddr(), pkt->getSize()); 1968 return snoop_delay; 1969 } else { | 1969 __func__, pkt->cmdString(), pkt->getAddr(), pkt->getSize()); 1970 return snoop_delay; 1971 } else { |
1970 DPRINTF(Cache, "%s snoop hit for %s for addr %#llx size %d, " 1971 "old state is %s\n", __func__, pkt->cmdString(), 1972 pkt->getAddr(), pkt->getSize(), blk->print()); | 1972 DPRINTF(Cache, "%s snoop hit for %s addr %#llx size %d, " 1973 "old state is %s\n", __func__, pkt->cmdString(), 1974 pkt->getAddr(), pkt->getSize(), blk->print()); |
1973 } 1974 1975 chatty_assert(!(isReadOnly && blk->isDirty()), 1976 "Should never have a dirty block in a read-only cache %s\n", 1977 name()); 1978 1979 // We may end up modifying both the block state and the packet (if 1980 // we respond in atomic mode), so just figure out what to do now --- 87 unchanged lines hidden (view full) --- 2068 2069 return snoop_delay; 2070} 2071 2072 2073void 2074Cache::recvTimingSnoopReq(PacketPtr pkt) 2075{ | 1975 } 1976 1977 chatty_assert(!(isReadOnly && blk->isDirty()), 1978 "Should never have a dirty block in a read-only cache %s\n", 1979 name()); 1980 1981 // We may end up modifying both the block state and the packet (if 1982 // we respond in atomic mode), so just figure out what to do now --- 87 unchanged lines hidden (view full) --- 2070 2071 return snoop_delay; 2072} 2073 2074 2075void 2076Cache::recvTimingSnoopReq(PacketPtr pkt) 2077{ |
2076 DPRINTF(Cache, "%s for %s addr %#llx size %d\n", __func__, | 2078 DPRINTF(CacheVerbose, "%s for %s addr %#llx size %d\n", __func__, |
2077 pkt->cmdString(), pkt->getAddr(), pkt->getSize()); 2078 2079 // Snoops shouldn't happen when bypassing caches 2080 assert(!system->bypassCaches()); 2081 2082 // no need to snoop requests that are not in range 2083 if (!inRange(pkt->getAddr())) { 2084 return; --- 611 unchanged lines hidden --- | 2079 pkt->cmdString(), pkt->getAddr(), pkt->getSize()); 2080 2081 // Snoops shouldn't happen when bypassing caches 2082 assert(!system->bypassCaches()); 2083 2084 // no need to snoop requests that are not in range 2085 if (!inRange(pkt->getAddr())) { 2086 return; --- 611 unchanged lines hidden --- |