This is an automated email from the ASF dual-hosted git repository. masayuki pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit b2d77c0e9c43b8bb5e95f230c6832bce4a40627a Author: Gustavo Henrique Nihei <gustavo.ni...@espressif.com> AuthorDate: Tue May 24 12:41:18 2022 -0300 Revert "risc-v/esp32c3: Use onexit to free thread private semaphore" This reverts commit f5eaf82c9338823c9eb1c7a5e083fe37896cb2de. Signed-off-by: Gustavo Henrique Nihei <gustavo.ni...@espressif.com> --- arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c | 41 +++++++++------------- .../esp32c3-devkit/configs/autopm/defconfig | 1 - .../esp32c3-devkit/configs/sta_softap/defconfig | 1 - .../esp32c3/esp32c3-devkit/configs/wapi/defconfig | 1 - 4 files changed, 17 insertions(+), 27 deletions(-) diff --git a/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c b/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c index 3f80fde166..5fa785a2e7 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c +++ b/arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c @@ -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; } diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/configs/autopm/defconfig b/boards/risc-v/esp32c3/esp32c3-devkit/configs/autopm/defconfig index 0adab7cb2d..ac1a7b1ccd 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/configs/autopm/defconfig +++ b/boards/risc-v/esp32c3/esp32c3-devkit/configs/autopm/defconfig @@ -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 diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/configs/sta_softap/defconfig b/boards/risc-v/esp32c3/esp32c3-devkit/configs/sta_softap/defconfig index 46625ecc36..0ce646eb70 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/configs/sta_softap/defconfig +++ b/boards/risc-v/esp32c3/esp32c3-devkit/configs/sta_softap/defconfig @@ -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 diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/configs/wapi/defconfig b/boards/risc-v/esp32c3/esp32c3-devkit/configs/wapi/defconfig index ea4b5d6ece..887b0577a7 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/configs/wapi/defconfig +++ b/boards/risc-v/esp32c3/esp32c3-devkit/configs/wapi/defconfig @@ -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