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" |
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; |
183 DPRINTF(CacheVerbose, "%s for %s addr %#llx size %d (write)\n", 184 __func__, pkt->cmdString(), pkt->getAddr(), pkt->getSize()); |
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); |
284 DPRINTF(CacheVerbose, "%s for %s addr %#llx size %d (invalidation)\n", |
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 |
320 DPRINTF(CacheVerbose, "%s for %s addr %#llx size %d\n", __func__, |
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 |
1226 DPRINTF(CacheVerbose, "functional %s %#llx (%s) %s%s%s\n", |
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 |
1537 DPRINTF(CacheVerbose, "Leaving %s with %s for addr %#llx\n", __func__, |
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; |
1885 DPRINTF(CacheVerbose, 1886 "%s created response: %s addr %#llx size %d tick: %lu\n", |
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{ |
1896 DPRINTF(CacheVerbose, "%s for %s addr %#llx size %d\n", __func__, |
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()) { |
1968 DPRINTF(CacheVerbose, "%s snoop miss for %s addr %#llx size %d\n", |
1969 __func__, pkt->cmdString(), pkt->getAddr(), pkt->getSize()); 1970 return snoop_delay; 1971 } else { |
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()); |
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{ |
2078 DPRINTF(CacheVerbose, "%s for %s addr %#llx size %d\n", __func__, |
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 --- |