AnsweredAssumed Answered

Disabling L3 (CPC) cache during runtime (P4080)

Question asked by Clemens Reibetanz on Jun 8, 2015
Latest reply on Jun 10, 2015 by Scott Wood

Hi,

I try to disable the CPC cache during runtime.

I follow the instructions given in P4080RM at page 350.

 

To flush the CPC cache and ensure that no valid entries exist after the flush (that is, for the purposes of powering down or disabling) the following high level sequence of operations should be used:

1. Clear all bits in CPCPAR0-CPCPAR15 to prevent new transactions from allocating in the CPC

2. Set CPCCSR0[CPCFL]

3. Wait for CPCCSR0[CPCFL] to be cleared by hardware

4. Clear CPCCSR0[CPCE]

 

In my code this looks like:

 

// 1. Clear all bits in CPCPAR0-CPCPAR15 to prevent new transactions from allocating in the CPC 
for (int k=0; k < 16; k++) {
    asm ("mbar");
    asm ("isync");
    // CPC1_CPCPARn register clear
    *((uint32_t*) (0xFE000000 + 0x10208 + 0x10 * k)) = 0;
    // CPC2_CPCPARn register clear
    *((uint32_t*) (0xFE000000 + 0x11208 + 0x10 * k)) = 0;        
    asm ("mbar");
}

// 2. Set CPCCSR0[CPCFL] 
// 3. Wait for CPCCSR0[CPCFL] to be cleared by hardware 
// CPC 1
asm ("mbar");
asm ("isync");
*((uint32_t*) (0xFE000000 + 0x10000)) |= (1 << (31-20));
while ((*((uint32_t*) (0xFE000000 + 0x10000)) >> (31-20)) & 1) {}
asm ("mbar");
// CPC2
asm ("mbar");
asm ("isync");
*((uint32_t*) (0xFE000000 + 0x11000)) = *((uint32_t*) (0xFE000000 + 0x11000)) | (1 << (31-20));
while ((*((uint32_t*) (0xFE000000 + 0x11000)) >> (31-20)) & 1) {}
asm ("mbar");

// 4. Clear CPCCSR0[CPCE]
// CPC1
asm ("mbar");
asm ("isync");
*((uint32_t*) (0xFE000000 + 0x10000)) &= ~(1 << (31-0));
cache_register = *((uint32_t*) (0xFE000000 + 0x10000));
asm ("mbar");
// CPC2
asm ("mbar");
asm ("isync");
*((uint32_t*) (0xFE000000 + 0x11000)) &= ~(1 << (31-0)); 
cache_register = *((uint32_t*) (0xFE000000 + 0x11000));
asm ("mbar");

 

 

The problem is that after disabling the CPC I get an alignment error and a machine check interrupt at a std::cout.

Am I doing anything wrong when disabling CPC? Did I forget anything? Why do these error occur?

 

Thanks in advance

 

Clemens

Outcomes