[ion/cache] Improve cache cleaning

- Avoid fetching CCSIDR twice
 - Use for loop instead of do/while
 - Only compute the target register once
 - Avoid an useless nop
This commit is contained in:
Romain Goyet
2019-12-15 17:13:27 -05:00
committed by EmilieNumworks
parent 67302a90c7
commit 273834ee84
2 changed files with 21 additions and 19 deletions

View File

@@ -17,28 +17,29 @@ void privateCleanInvalidateDisableDCache(bool clean, bool invalidate, bool disab
dsb();
}
uint32_t sets = CORTEX.CCSIDR()->getNUMSETS();
uint32_t ways = CORTEX.CCSIDR()->getASSOCIATIVITY();
// Pick the right DC??SW register according to invalidate/disable parameters
volatile CORTEX::DCSW * target = nullptr;
if (clean && invalidate) {
target = CORTEX.DCCISW();
} else if (clean) {
target = CORTEX.DCCSW();
} else {
assert(invalidate);
target = CORTEX.DCISW();
}
do {
uint32_t w = ways;
do {
class CORTEX::CCSIDR ccsidr = CORTEX.CCSIDR()->get();
uint32_t sets = ccsidr.getNUMSETS();
uint32_t ways = ccsidr.getASSOCIATIVITY();
for (int set = sets; set >= 0; set--) {
for (int way = ways; way >= 0; way--) {
class CORTEX::DCSW dcsw;
dcsw.setSET(sets);
dcsw.setWAY(w);
volatile CORTEX::DCSW * target = nullptr;
if (clean && invalidate) {
target = CORTEX.DCCISW();
} else if (clean) {
target = CORTEX.DCCSW();
} else {
assert(invalidate);
target = CORTEX.DCISW();
}
dcsw.setSET(set);
dcsw.setWAY(way);
target->set(dcsw);
__asm volatile("nop");
} while (w-- != 0);
} while (sets-- != 0);
}
}
dsb();
isb();

View File

@@ -72,6 +72,7 @@ public:
#if REGS_CORTEX_CONFIG_CACHE
class CCSIDR : public Register32 {
public:
using Register32::Register32;
REGS_FIELD(ASSOCIATIVITY, uint16_t, 12, 3);
REGS_FIELD(NUMSETS, uint16_t, 27, 13);
};