From 0e832f4d6d0e7dd03ab37cdeb7a7fced5b3fb289 Mon Sep 17 00:00:00 2001 From: Tiago Medicci Serrano Date: Tue, 25 Jun 2024 12:33:56 -0300 Subject: [PATCH] espressif: Fix error while evaluating Wi-Fi task ID Use `nxsched_gettid` instead of `nxsched_getpid`. Previously each kernel thread was modelled as a task, so the pid is the same of the kthread id. Now, with shared kthread group (introduced by #12320), the pid of all kthreads will be 0 by design in shared group. --- arch/risc-v/src/esp32c3-legacy/esp32c3_wifi_adapter.c | 4 ++-- arch/risc-v/src/esp32c3/esp_wifi_adapter.c | 6 +++--- arch/risc-v/src/esp32c6/esp_wifi_adapter.c | 6 +++--- arch/xtensa/src/esp32/esp32_wifi_adapter.c | 4 ++-- arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/risc-v/src/esp32c3-legacy/esp32c3_wifi_adapter.c b/arch/risc-v/src/esp32c3-legacy/esp32c3_wifi_adapter.c index 0512f59e3b9f4..6978ba7f778aa 100644 --- a/arch/risc-v/src/esp32c3-legacy/esp32c3_wifi_adapter.c +++ b/arch/risc-v/src/esp32c3-legacy/esp32c3_wifi_adapter.c @@ -2094,7 +2094,7 @@ static int32_t esp_task_ms_to_tick(uint32_t ms) static void *esp_task_get_current_task(void) { - pid_t pid = nxsched_getpid(); + pid_t pid = nxsched_gettid(); return (void *)((uintptr_t)pid); } @@ -4769,7 +4769,7 @@ int esp_wifi_notify_subscribe(pid_t pid, struct sigevent *event) { if (pid == 0) { - pid = nxsched_getpid(); + pid = nxsched_gettid(); wlinfo("Actual PID=%d\n", pid); } diff --git a/arch/risc-v/src/esp32c3/esp_wifi_adapter.c b/arch/risc-v/src/esp32c3/esp_wifi_adapter.c index 0ac761bd47e13..ba1080f652ccf 100644 --- a/arch/risc-v/src/esp32c3/esp_wifi_adapter.c +++ b/arch/risc-v/src/esp32c3/esp_wifi_adapter.c @@ -3273,7 +3273,7 @@ static void task_delete_wrapper(void *task_handle) * * Description: * This function gets the current task's PID and returns it as a void - * pointer. This is a wrapper around the NuttX function nxsched_getpid. + * pointer. This is a wrapper around the NuttX function nxsched_gettid. * * Input Parameters: * None @@ -3285,7 +3285,7 @@ static void task_delete_wrapper(void *task_handle) static void *task_get_current_task_wrapper(void) { - pid_t pid = nxsched_getpid(); + pid_t pid = nxsched_gettid(); return (void *)((uintptr_t)pid); } @@ -3601,7 +3601,7 @@ int esp_wifi_notify_subscribe(pid_t pid, struct sigevent *event) { if (pid == 0) { - pid = nxsched_getpid(); + pid = nxsched_gettid(); wlinfo("Actual PID=%d\n", pid); } diff --git a/arch/risc-v/src/esp32c6/esp_wifi_adapter.c b/arch/risc-v/src/esp32c6/esp_wifi_adapter.c index 4ba19299c59b2..4dd2a7d0ef3db 100644 --- a/arch/risc-v/src/esp32c6/esp_wifi_adapter.c +++ b/arch/risc-v/src/esp32c6/esp_wifi_adapter.c @@ -3227,7 +3227,7 @@ static void task_delete_wrapper(void *task_handle) * * Description: * This function gets the current task's PID and returns it as a void - * pointer. This is a wrapper around the NuttX function nxsched_getpid. + * pointer. This is a wrapper around the NuttX function nxsched_gettid. * * Input Parameters: * None @@ -3239,7 +3239,7 @@ static void task_delete_wrapper(void *task_handle) static void *task_get_current_task_wrapper(void) { - pid_t pid = nxsched_getpid(); + pid_t pid = nxsched_gettid(); return (void *)((uintptr_t)pid); } @@ -3555,7 +3555,7 @@ int esp_wifi_notify_subscribe(pid_t pid, struct sigevent *event) { if (pid == 0) { - pid = nxsched_getpid(); + pid = nxsched_gettid(); wlinfo("Actual PID=%d\n", pid); } diff --git a/arch/xtensa/src/esp32/esp32_wifi_adapter.c b/arch/xtensa/src/esp32/esp32_wifi_adapter.c index 79b7a8e35eb88..5c91bfd2e7d94 100644 --- a/arch/xtensa/src/esp32/esp32_wifi_adapter.c +++ b/arch/xtensa/src/esp32/esp32_wifi_adapter.c @@ -1938,7 +1938,7 @@ static int32_t esp_task_ms_to_tick(uint32_t ms) static void *esp_task_get_current_task(void) { - pid_t pid = nxsched_getpid(); + pid_t pid = nxsched_gettid(); return (void *)((uintptr_t)pid); } @@ -4422,7 +4422,7 @@ int esp_wifi_notify_subscribe(pid_t pid, struct sigevent *event) { if (pid == 0) { - pid = nxsched_getpid(); + pid = nxsched_gettid(); wlinfo("Actual PID=%d\n", pid); } diff --git a/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c b/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c index f33434a66c518..e9ac72dc2bac8 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c +++ b/arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c @@ -1945,7 +1945,7 @@ static int32_t esp_task_ms_to_tick(uint32_t ms) static void *esp_task_get_current_task(void) { - pid_t pid = nxsched_getpid(); + pid_t pid = nxsched_gettid(); return (void *)((uintptr_t)pid); } @@ -4466,7 +4466,7 @@ int esp_wifi_notify_subscribe(pid_t pid, struct sigevent *event) { if (pid == 0) { - pid = nxsched_getpid(); + pid = nxsched_gettid(); wlinfo("Actual PID=%d\n", pid); }