From 913aec1667b854f62b99c4c7ef7c06d65fad1f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Fri, 13 May 2022 13:07:28 +0200 Subject: [PATCH] pc_wifi_drv: dissolve user tasks interdependence The 'uplink' task was created by the 'socketcall' task although both may operate independently. Issue #4506. --- repos/pc/lib/mk/wifi.inc | 1 + repos/pc/src/lib/wifi/lx_socket_call.c | 17 ++++++++-------- repos/pc/src/lib/wifi/lx_user.c | 28 ++++++++++++++++++++++++++ repos/pc/src/lib/wifi/lx_user.h | 28 ++++++++++++++++++++++++++ repos/pc/src/lib/wifi/socket_call.cc | 13 ++++-------- repos/pc/src/lib/wifi/uplink.c | 2 ++ repos/pc/src/lib/wifi/wlan.cc | 4 ++-- 7 files changed, 73 insertions(+), 20 deletions(-) create mode 100644 repos/pc/src/lib/wifi/lx_user.c create mode 100644 repos/pc/src/lib/wifi/lx_user.h diff --git a/repos/pc/lib/mk/wifi.inc b/repos/pc/lib/mk/wifi.inc index 6ebe687585..52f50331e0 100644 --- a/repos/pc/lib/mk/wifi.inc +++ b/repos/pc/lib/mk/wifi.inc @@ -17,6 +17,7 @@ SRC_CC += time.cc SRC_C += dummies.c SRC_C += lx_emul.c +SRC_C += lx_user.c SRC_C += uplink.c CC_OPT_lx_socket_call += -DKBUILD_MODNAME='"lx_socket_call"' diff --git a/repos/pc/src/lib/wifi/lx_socket_call.c b/repos/pc/src/lib/wifi/lx_socket_call.c index 45ce95436f..9ad6ca6830 100644 --- a/repos/pc/src/lib/wifi/lx_socket_call.c +++ b/repos/pc/src/lib/wifi/lx_socket_call.c @@ -13,26 +13,25 @@ /* DDE Linux includes */ #include "lx_socket_call.h" +#include "lx_user.h" /* kernel includes */ #include #include #include - -struct task_struct *lx_socket_call_task; -void *lx_socket_call_task_args; -extern int run_lx_socket_call_task(void *p); - +struct task_struct *socketcall_task_struct_ptr; +extern int socketcall_task_function(void *p); extern struct net init_net; -void lx_user_init(void) + +void socketcall_init(void) { - int pid = kernel_thread(run_lx_socket_call_task, - lx_socket_call_task_args, + int pid = kernel_thread(socketcall_task_function, + NULL, CLONE_FS | CLONE_FILES); - lx_socket_call_task = find_task_by_pid_ns(pid, NULL); + socketcall_task_struct_ptr = find_task_by_pid_ns(pid, NULL); } diff --git a/repos/pc/src/lib/wifi/lx_user.c b/repos/pc/src/lib/wifi/lx_user.c new file mode 100644 index 0000000000..139ef130f6 --- /dev/null +++ b/repos/pc/src/lib/wifi/lx_user.c @@ -0,0 +1,28 @@ +/** + * \brief Lx user definitions + * \author Josef Soentgen + * \date 2022-05-12 + */ + +/* + * Copyright (C) 2022 Genode Labs GmbH + * + * This file is distributed under the terms of the GNU General Public License + * version 2. + */ + +/* DDE Linux includes */ +#include + +/* local includes */ +#include "lx_user.h" + + +void lx_user_init(void) +{ + uplink_init(); + socketcall_init(); +} + + +void lx_user_handle_io(void) { } diff --git a/repos/pc/src/lib/wifi/lx_user.h b/repos/pc/src/lib/wifi/lx_user.h new file mode 100644 index 0000000000..4e12b2fcb4 --- /dev/null +++ b/repos/pc/src/lib/wifi/lx_user.h @@ -0,0 +1,28 @@ +/** + * \brief Lx user definitions + * \author Josef Soentgen + * \date 2022-05-12 + */ + +/* + * Copyright (C) 2022 Genode Labs GmbH + * + * This file is distributed under the terms of the GNU General Public License + * version 2. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct task_struct; + +extern struct task_struct *uplink_task_struct_ptr; +void uplink_init(void); + +extern struct task_struct *socketcall_task_struct_ptr; +void socketcall_init(void); + +#ifdef __cplusplus +} +#endif diff --git a/repos/pc/src/lib/wifi/socket_call.cc b/repos/pc/src/lib/wifi/socket_call.cc index 45aee65b4f..63eb435763 100644 --- a/repos/pc/src/lib/wifi/socket_call.cc +++ b/repos/pc/src/lib/wifi/socket_call.cc @@ -22,6 +22,7 @@ #include /* local includes */ +#include "lx_user.h" #include "lx_socket_call.h" #include "libc_errno.h" @@ -129,10 +130,6 @@ static int convert_errno_from_linux(int linux_errno) static_assert((unsigned)Wifi::Msghdr::MAX_IOV_LEN == (unsigned)MAX_IOV_LEN); -extern "C" struct task_struct *lx_socket_call_task; -extern "C" void *lx_socket_call_task_args; - - /* XXX move Wifi::Socket definition to better location */ struct Wifi::Socket @@ -410,7 +407,7 @@ class Lx::Socket void _handle() { - lx_emul_task_unblock(lx_socket_call_task); + lx_emul_task_unblock(socketcall_task_struct_ptr); Lx_kit::env().scheduler.schedule(); } @@ -466,14 +463,12 @@ static Lx::Socket *_socket; extern Genode::Blockade *wpa_blockade; -extern "C" void uplink_init(void); -extern "C" int run_lx_socket_call_task(void *) +extern "C" int socketcall_task_function(void *) { static Lx::Socket inst(Lx_kit::env().env.ep()); _socket = &inst; - uplink_init(); wpa_blockade->wakeup(); while (true) { @@ -490,7 +485,7 @@ void wifi_kick_socketcall() /* ignore silently, the function might be called to before init */ if (!_socket) { return; } - lx_emul_task_unblock(lx_socket_call_task); + lx_emul_task_unblock(socketcall_task_struct_ptr); Lx_kit::env().scheduler.schedule(); } diff --git a/repos/pc/src/lib/wifi/uplink.c b/repos/pc/src/lib/wifi/uplink.c index d278b6fa43..3317c50b63 100644 --- a/repos/pc/src/lib/wifi/uplink.c +++ b/repos/pc/src/lib/wifi/uplink.c @@ -12,6 +12,8 @@ * version 2. */ +#include "lx_user.h" + #include #include #include diff --git a/repos/pc/src/lib/wifi/wlan.cc b/repos/pc/src/lib/wifi/wlan.cc index 98c48dff3a..77a89f9066 100644 --- a/repos/pc/src/lib/wifi/wlan.cc +++ b/repos/pc/src/lib/wifi/wlan.cc @@ -25,8 +25,8 @@ #include #include - -extern "C" void lx_user_handle_io(void) { } +/* local includes */ +#include "lx_user.h" using namespace Genode;