mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(riscv): Remove the memory barrier when changing interrupt threshold
This commit is contained in:
parent
f68c131e56
commit
2217854092
@ -60,15 +60,6 @@ FORCE_INLINE_ATTR void __attribute__((always_inline)) rv_utils_wait_for_intr(voi
|
||||
asm volatile ("wfi\n");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------- Memory Barrier ----------------------------------------------------
|
||||
*
|
||||
* ------------------------------------------------------------------------------------------------------------------ */
|
||||
//TODO: IDF-7898
|
||||
FORCE_INLINE_ATTR void rv_utils_memory_barrier(void)
|
||||
{
|
||||
asm volatile("fence iorw, iorw" : : : "memory");
|
||||
}
|
||||
|
||||
/* -------------------------------------------------- CPU Registers ----------------------------------------------------
|
||||
*
|
||||
* ------------------------------------------------------------------------------------------------------------------ */
|
||||
@ -191,15 +182,11 @@ FORCE_INLINE_ATTR uint32_t __attribute__((always_inline)) rv_utils_set_intlevel(
|
||||
|
||||
REG_SET_FIELD(CLIC_INT_THRESH_REG, CLIC_CPU_INT_THRESH, ((intlevel << (8 - NLBITS))) | 0x1f);
|
||||
/**
|
||||
* TODO: IDF-7898
|
||||
* Here is an issue that,
|
||||
* 1. Set the CLIC_INT_THRESH_REG to mask off interrupts whose level is lower than `intlevel`.
|
||||
* 2. Set MSTATUS_MIE (global interrupt), then program may jump to interrupt vector.
|
||||
* 3. The register value change in Step 1 may happen during Step 2.
|
||||
*
|
||||
* To prevent this, here a fence is used
|
||||
* After writing the threshold register, the new threshold is not directly taken into account by the CPU.
|
||||
* By executing ~8 nop instructions, or by performing a memory load right now, the previous memory write
|
||||
* operations is forced, making the new threshold active. It is then safe to re-enable MIE bit in mstatus.
|
||||
*/
|
||||
rv_utils_memory_barrier();
|
||||
REG_READ(CLIC_INT_THRESH_REG);
|
||||
RV_SET_CSR(mstatus, old_mstatus & MSTATUS_MIE);
|
||||
|
||||
return old_thresh;
|
||||
|
Loading…
Reference in New Issue
Block a user