esp32: fix a crash with PSRAM + SMP
this function is called via esp_spiram_init_cache early in the boot.
This commit is contained in:
parent
f084685da8
commit
c06a742a63
@ -93,8 +93,8 @@ unsigned int IRAM_ATTR cache_sram_mmu_set(int cpu_no, int pid,
|
||||
uint32_t regval;
|
||||
#ifdef CONFIG_SMP
|
||||
int cpu_to_stop = 0;
|
||||
bool smp_start = OSINIT_OS_READY();
|
||||
#endif
|
||||
const bool os_ready = OSINIT_OS_READY();
|
||||
unsigned int i;
|
||||
unsigned int shift;
|
||||
unsigned int mask_s;
|
||||
@ -176,14 +176,18 @@ unsigned int IRAM_ATTR cache_sram_mmu_set(int cpu_no, int pid,
|
||||
* the flash guards to make sure the cache is disabled.
|
||||
*/
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = 0; /* suppress GCC warning */
|
||||
if (os_ready)
|
||||
{
|
||||
flags = enter_critical_section();
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
/* The other CPU might be accessing the cache at the same time, just by
|
||||
* using variables in external RAM.
|
||||
*/
|
||||
|
||||
if (smp_start)
|
||||
if (os_ready)
|
||||
{
|
||||
cpu_to_stop = up_cpu_index() == 1 ? 0 : 1;
|
||||
up_cpu_pause(cpu_to_stop);
|
||||
@ -222,13 +226,17 @@ unsigned int IRAM_ATTR cache_sram_mmu_set(int cpu_no, int pid,
|
||||
#ifdef CONFIG_SMP
|
||||
spi_enable_cache(1);
|
||||
|
||||
if (smp_start)
|
||||
if (os_ready)
|
||||
{
|
||||
up_cpu_resume(cpu_to_stop);
|
||||
}
|
||||
#endif
|
||||
|
||||
leave_critical_section(flags);
|
||||
if (os_ready)
|
||||
{
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user