mirror of
https://github.com/apache/nuttx.git
synced 2025-01-12 22:08:35 +08:00
xtensa/esp32s3: add lock for async operation work
g_work as singleton can be changed by context switching, but previous one async operation have not finished yet.
This commit is contained in:
parent
d1786507b6
commit
10a1d17a85
1 changed files with 9 additions and 0 deletions
|
@ -205,6 +205,7 @@ static mutex_t g_lock = NXMUTEX_INITIALIZER;
|
|||
|
||||
#ifdef CONFIG_ESP32S3_SPI_FLASH_SUPPORT_PSRAM_STACK
|
||||
static struct work_s g_work;
|
||||
static mutex_t g_work_lock = NXMUTEX_INITIALIZER;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -335,6 +336,12 @@ static int esp32s3_async_op(enum spiflash_op_code_e opcode,
|
|||
.sem = NXSEM_INITIALIZER(0, 0)
|
||||
};
|
||||
|
||||
ret = nxmutex_lock(&g_work_lock);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = work_queue(LPWORK, &g_work, esp32s3_spiflash_work, &work_arg, 0);
|
||||
if (ret == 0)
|
||||
{
|
||||
|
@ -342,6 +349,8 @@ static int esp32s3_async_op(enum spiflash_op_code_e opcode,
|
|||
ret = work_arg.ret;
|
||||
}
|
||||
|
||||
nxmutex_unlock(&g_work_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue