Revert "risc-v/esp32c3: Use onexit to free thread private semaphore"

This reverts commit f5eaf82c93.

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
This commit is contained in:
Gustavo Henrique Nihei 2022-05-24 12:41:18 -03:00 committed by Masayuki Ishikawa
parent 4b308f6cbd
commit b2d77c0e9c
4 changed files with 17 additions and 27 deletions

View File

@ -38,7 +38,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <irq/irq.h>
#include <sched/sched.h>
#include <nuttx/kmalloc.h>
#include <nuttx/mqueue.h>
#include <nuttx/spinlock.h>
@ -84,10 +83,6 @@
* Pre-processor Definitions
****************************************************************************/
#ifndef CONFIG_SCHED_ONEXIT
# error "on_exit() API must be enabled for deallocating Wi-Fi resources"
#endif
#define PHY_RF_MASK ((1 << PHY_BT_MODULE) | (1 << PHY_WIFI_MODULE))
#ifdef CONFIG_ESP32C3_WIFI_SAVE_PARAM
@ -844,7 +839,7 @@ static int esp_int_adpt_cb(int irq, void *context, void *arg)
*
****************************************************************************/
static void esp_thread_semphr_free(int status, void *semphr)
static void esp_thread_semphr_free(void *semphr)
{
if (semphr)
{
@ -1339,20 +1334,22 @@ static int IRAM_ATTR wifi_is_in_isr(void)
static void *esp_thread_semphr_get(void)
{
int ret;
int i;
void *sem;
struct tcb_s *tcb = this_task();
struct task_group_s *group = tcb->group;
for (i = 0; i < CONFIG_SCHED_EXIT_MAX; i++)
{
if (group->tg_exit[i].func.on == esp_thread_semphr_free)
{
break;
}
}
if (g_wifi_tkey_init)
{
ret = pthread_key_create(&g_wifi_thread_key, esp_thread_semphr_free);
if (ret)
{
wlerr("ERROR: Failed to create pthread key\n");
return NULL;
}
if (i >= CONFIG_SCHED_EXIT_MAX)
g_wifi_tkey_init = true;
}
sem = pthread_getspecific(g_wifi_thread_key);
if (!sem)
{
sem = esp_semphr_create(1, 0);
if (!sem)
@ -1361,18 +1358,14 @@ static void *esp_thread_semphr_get(void)
return NULL;
}
ret = on_exit(esp_thread_semphr_free, sem);
if (ret < 0)
ret = pthread_setspecific(g_wifi_thread_key, sem);
if (ret)
{
wlerr("ERROR: Failed to bind semaphore\n");
wlerr("ERROR: Failed to set specific\n");
esp_semphr_delete(sem);
return NULL;
}
}
else
{
sem = group->tg_exit[i].arg;
}
return sem;
}

View File

@ -52,7 +52,6 @@ CONFIG_PREALLOC_TIMERS=4
CONFIG_PTHREAD_MUTEX_TYPES=y
CONFIG_RAW_BINARY=y
CONFIG_SCHED_LPWORK=y
CONFIG_SCHED_ONEXIT=y
CONFIG_SCHED_WAITPID=y
CONFIG_SIG_DEFAULT=y
CONFIG_START_DAY=6

View File

@ -65,7 +65,6 @@ CONFIG_PTHREAD_MUTEX_TYPES=y
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_LPWORK=y
CONFIG_SCHED_ONEXIT=y
CONFIG_SCHED_WAITPID=y
CONFIG_SIG_DEFAULT=y
CONFIG_SPIFFS_NAME_MAX=48

View File

@ -50,7 +50,6 @@ CONFIG_PTHREAD_MUTEX_TYPES=y
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_LPWORK=y
CONFIG_SCHED_ONEXIT=y
CONFIG_SCHED_WAITPID=y
CONFIG_SIG_DEFAULT=y
CONFIG_START_DAY=6