1/* 2 * Copyright (c) 2012-2013, 2018 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 --- 1195 unchanged lines hidden (view full) --- 1204 1205 return blk; 1206} 1207 1208CacheBlk* 1209BaseCache::allocateBlock(Addr addr, bool is_secure, PacketList &writebacks) 1210{ 1211 // Find replacement victim |
1212 std::vector<CacheBlk*> evict_blks; 1213 CacheBlk *victim = tags->findVictim(addr, evict_blks); |
1214 1215 // It is valid to return nullptr if there is no victim |
1216 if (!victim) |
1217 return nullptr; 1218 |
1219 // Check for transient state allocations. If any of the entries listed 1220 // for eviction has a transient state, the allocation fails 1221 for (const auto& blk : evict_blks) { 1222 if (blk->isValid()) { 1223 Addr repl_addr = regenerateBlkAddr(blk); 1224 MSHR *repl_mshr = mshrQueue.findMatch(repl_addr, blk->isSecure()); 1225 if (repl_mshr) { 1226 // must be an outstanding upgrade or clean request 1227 // on a block we're about to replace... 1228 assert((!blk->isWritable() && repl_mshr->needsWritable()) || 1229 repl_mshr->isCleaning()); |
1230 |
1231 // too hard to replace block with transient state 1232 // allocation failed, block not inserted 1233 return nullptr; 1234 } 1235 } 1236 } 1237 1238 // The victim will be replaced by a new entry, so increase the replacement 1239 // counter if a valid block is being replaced 1240 if (victim->isValid()) { 1241 DPRINTF(Cache, "replacement: replacing %#llx (%s) with %#llx " 1242 "(%s): %s\n", regenerateBlkAddr(victim), 1243 victim->isSecure() ? "s" : "ns", 1244 addr, is_secure ? "s" : "ns", 1245 victim->isDirty() ? "writeback" : "clean"); 1246 1247 replacements++; 1248 } 1249 1250 // Evict valid blocks associated to this victim block 1251 for (const auto& blk : evict_blks) { 1252 if (blk->isValid()) { |
1253 if (blk->wasPrefetched()) { 1254 unusedPrefetches++; 1255 } |
1256 |
1257 evictBlock(blk, writebacks); |
1258 } 1259 } 1260 |
1261 return victim; |
1262} 1263 1264void 1265BaseCache::invalidateBlock(CacheBlk *blk) 1266{ 1267 if (blk != tempBlock) 1268 tags->invalidate(blk); 1269 blk->invalidate(); --- 1057 unchanged lines hidden --- |