base.cc (12730:6c2ea88bf129) base.cc (12744:d1ff0b42b747)
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
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 CacheBlk *blk = tags->findVictim(addr);
1212 std::vector<CacheBlk*> evict_blks;
1213 CacheBlk *victim = tags->findVictim(addr, evict_blks);
1213
1214 // It is valid to return nullptr if there is no victim
1214
1215 // It is valid to return nullptr if there is no victim
1215 if (!blk)
1216 if (!victim)
1216 return nullptr;
1217
1217 return nullptr;
1218
1218 if (blk->isValid()) {
1219 Addr repl_addr = regenerateBlkAddr(blk);
1220 MSHR *repl_mshr = mshrQueue.findMatch(repl_addr, blk->isSecure());
1221 if (repl_mshr) {
1222 // must be an outstanding upgrade or clean request
1223 // on a block we're about to replace...
1224 assert((!blk->isWritable() && repl_mshr->needsWritable()) ||
1225 repl_mshr->isCleaning());
1226 // too hard to replace block with transient state
1227 // allocation failed, block not inserted
1228 return nullptr;
1229 } else {
1230 DPRINTF(Cache, "replacement: replacing %#llx (%s) with %#llx "
1231 "(%s): %s\n", repl_addr, blk->isSecure() ? "s" : "ns",
1232 addr, is_secure ? "s" : "ns",
1233 blk->isDirty() ? "writeback" : "clean");
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());
1234
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()) {
1235 if (blk->wasPrefetched()) {
1236 unusedPrefetches++;
1237 }
1253 if (blk->wasPrefetched()) {
1254 unusedPrefetches++;
1255 }
1256
1238 evictBlock(blk, writebacks);
1257 evictBlock(blk, writebacks);
1239 replacements++;
1240 }
1241 }
1242
1258 }
1259 }
1260
1243 return blk;
1261 return victim;
1244}
1245
1246void
1247BaseCache::invalidateBlock(CacheBlk *blk)
1248{
1249 if (blk != tempBlock)
1250 tags->invalidate(blk);
1251 blk->invalidate();

--- 1057 unchanged lines hidden ---
1262}
1263
1264void
1265BaseCache::invalidateBlock(CacheBlk *blk)
1266{
1267 if (blk != tempBlock)
1268 tags->invalidate(blk);
1269 blk->invalidate();

--- 1057 unchanged lines hidden ---