diff --git a/include/evl/clock.h b/include/evl/clock.h index 8822ea7afb4ca3..cb1bbf2cc8b19a 100644 --- a/include/evl/clock.h +++ b/include/evl/clock.h @@ -14,7 +14,8 @@ #include #include #include -#include +#include +#include #define ONE_BILLION 1000000000 diff --git a/include/evl/control.h b/include/evl/control.h index 5a736ab2e5eabb..dcc90775f0de8c 100644 --- a/include/evl/control.h +++ b/include/evl/control.h @@ -10,6 +10,8 @@ #include #include #include +#include +#include enum evl_run_states { EVL_STATE_DISABLED, diff --git a/include/evl/factory.h b/include/evl/factory.h index 358aac28f5610e..6b7f82de280761 100644 --- a/include/evl/factory.h +++ b/include/evl/factory.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include #define element_of(__filp, __type) \ ({ \ diff --git a/include/evl/monitor.h b/include/evl/monitor.h index 441decab3aad77..632f95d4855174 100644 --- a/include/evl/monitor.h +++ b/include/evl/monitor.h @@ -7,9 +7,8 @@ #ifndef _EVL_MONITOR_H #define _EVL_MONITOR_H -#include #include -#include +#include int evl_signal_monitor_targeted(struct evl_thread *target, int monfd); diff --git a/include/evl/mutex.h b/include/evl/mutex.h index 8b3287b6953c6a..0313768cdb81a0 100644 --- a/include/evl/mutex.h +++ b/include/evl/mutex.h @@ -15,7 +15,6 @@ #include #include #include -#include struct evl_clock; struct evl_thread; @@ -93,6 +92,12 @@ bool evl_requeue_mutex_wait(struct evl_wait_channel *wchan, void evl_drop_current_ownership(void); +static inline bool +evl_is_mutex_owner(atomic_t *fastlock, fundle_t ownerh) +{ + return evl_get_index(atomic_read(fastlock)) == ownerh; +} + struct evl_kmutex { struct evl_mutex mutex; atomic_t fastlock; diff --git a/include/evl/net/socket.h b/include/evl/net/socket.h index 94bafd0cad7a58..8a62114c0f4bd8 100644 --- a/include/evl/net/socket.h +++ b/include/evl/net/socket.h @@ -16,7 +16,9 @@ #include #include #include -#include +#include +#include +#include struct evl_socket; struct net; diff --git a/include/evl/observable.h b/include/evl/observable.h index aff0364e439e5e..21f57ab9aa4b96 100644 --- a/include/evl/observable.h +++ b/include/evl/observable.h @@ -14,7 +14,8 @@ #include #include #include -#include +#include +#include struct file; diff --git a/include/evl/poll.h b/include/evl/poll.h index efa2b953519716..fba3da8d9373c9 100644 --- a/include/evl/poll.h +++ b/include/evl/poll.h @@ -14,7 +14,8 @@ #include #include #include -#include +#include +#include struct file; diff --git a/include/evl/thread.h b/include/evl/thread.h index 2d1d6f8745c096..1c2e4a269ebe39 100644 --- a/include/evl/thread.h +++ b/include/evl/thread.h @@ -22,9 +22,9 @@ #include #include #include -#include +#include +#include #include -#include #include /* All bits which may cause an EVL thread to block in oob context. */ diff --git a/include/uapi/evl/clock.h b/include/uapi/evl/clock-abi.h similarity index 90% rename from include/uapi/evl/clock.h rename to include/uapi/evl/clock-abi.h index 4d3e3ff2ca94f9..1d678d9665a2c7 100644 --- a/include/uapi/evl/clock.h +++ b/include/uapi/evl/clock-abi.h @@ -4,10 +4,10 @@ * Copyright (C) 2018 Philippe Gerum */ -#ifndef _EVL_UAPI_CLOCK_H -#define _EVL_UAPI_CLOCK_H +#ifndef _EVL_UAPI_CLOCK_ABI_H +#define _EVL_UAPI_CLOCK_ABI_H -#include +#include #define EVL_CLOCK_MONOTONIC_DEV "monotonic" #define EVL_CLOCK_REALTIME_DEV "realtime" @@ -34,4 +34,4 @@ struct evl_timerfd_setreq { #define EVL_TFDIOC_SET _IOWR(EVL_TIMERFD_IOCBASE, 0, struct evl_timerfd_setreq) #define EVL_TFDIOC_GET _IOR(EVL_TIMERFD_IOCBASE, 1, struct __evl_itimerspec) -#endif /* !_EVL_UAPI_CLOCK_H */ +#endif /* !_EVL_UAPI_CLOCK_ABI_H */ diff --git a/include/uapi/evl/control.h b/include/uapi/evl/control-abi.h similarity index 89% rename from include/uapi/evl/control.h rename to include/uapi/evl/control-abi.h index 4a33e38e6b9d96..9532d57c04e856 100644 --- a/include/uapi/evl/control.h +++ b/include/uapi/evl/control-abi.h @@ -4,11 +4,10 @@ * Copyright (C) 2018 Philippe Gerum */ -#ifndef _EVL_UAPI_CONTROL_H -#define _EVL_UAPI_CONTROL_H +#ifndef _EVL_UAPI_CONTROL_ABI_H +#define _EVL_UAPI_CONTROL_ABI_H #include -#include /* Earliest ABI level we support. */ #define EVL_ABI_BASE 23 @@ -40,4 +39,4 @@ struct evl_cpu_state { #define EVL_CTLIOC_SCHEDCTL _IOWR(EVL_CONTROL_IOCBASE, 1, struct evl_sched_ctlreq) #define EVL_CTLIOC_GET_CPUSTATE _IOR(EVL_CONTROL_IOCBASE, 2, struct evl_cpu_state) -#endif /* !_EVL_UAPI_CONTROL_H */ +#endif /* !_EVL_UAPI_CONTROL_ABI_H */ diff --git a/include/uapi/evl/factory.h b/include/uapi/evl/factory-abi.h similarity index 92% rename from include/uapi/evl/factory.h rename to include/uapi/evl/factory-abi.h index fde46bc92bd559..84e4959103459f 100644 --- a/include/uapi/evl/factory.h +++ b/include/uapi/evl/factory-abi.h @@ -4,8 +4,8 @@ * Copyright (C) 2018 Philippe Gerum */ -#ifndef _EVL_UAPI_FACTORY_H -#define _EVL_UAPI_FACTORY_H +#ifndef _EVL_UAPI_FACTORY_ABI_H +#define _EVL_UAPI_FACTORY_ABI_H #include @@ -45,4 +45,4 @@ struct evl_clone_req { #define EVL_IOC_CLONE _IOWR(EVL_FACTORY_IOCBASE, 0, struct evl_clone_req) -#endif /* !_EVL_UAPI_FACTORY_H */ +#endif /* !_EVL_UAPI_FACTORY_ABI_H */ diff --git a/include/uapi/evl/monitor.h b/include/uapi/evl/monitor-abi.h similarity index 90% rename from include/uapi/evl/monitor.h rename to include/uapi/evl/monitor-abi.h index 434bb089464dce..d77da903816b8c 100644 --- a/include/uapi/evl/monitor.h +++ b/include/uapi/evl/monitor-abi.h @@ -4,12 +4,10 @@ * Copyright (C) 2018 Philippe Gerum */ -#ifndef _EVL_UAPI_MONITOR_H -#define _EVL_UAPI_MONITOR_H +#ifndef _EVL_UAPI_MONITOR_ABI_H +#define _EVL_UAPI_MONITOR_ABI_H -#include -#include -#include +#include #define EVL_MONITOR_DEV "monitor" @@ -39,14 +37,14 @@ struct evl_monitor_state { __u32 flags; union { struct { - atomic_t owner; + __u32 owner; /* atomic_t */ __u32 ceiling; __u32 recursive: 1, nesting : 31; } gate; struct { - atomic_t value; - atomic_t pollrefs; + __u32 value; /* atomic_t */ + __u32 pollrefs; /* atomic_t */ __u32 gate_offset; } event; } u; @@ -87,4 +85,4 @@ struct evl_monitor_binding { #define EVL_MONIOC_TRYWAIT _IOWR(EVL_MONITOR_IOCBASE, 9, struct evl_monitor_trywaitreq) #define EVL_MONIOC_TRYWAIT_EXACT _IOWR(EVL_MONITOR_IOCBASE, 10, struct evl_monitor_trywaitreq) -#endif /* !_EVL_UAPI_MONITOR_H */ +#endif /* !_EVL_UAPI_MONITOR_ABI_H */ diff --git a/include/uapi/evl/mutex.h b/include/uapi/evl/mutex.h deleted file mode 100644 index 9a1979483313de..00000000000000 --- a/include/uapi/evl/mutex.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note - * - * Derived from Xenomai Cobalt, https://xenomai.org/ - * Copyright (C) 2001, 2013, 2018 Philippe Gerum - * Copyright (C) 2008, 2009 Jan Kiszka . - */ - -#ifndef _EVL_UAPI_MUTEX_H -#define _EVL_UAPI_MUTEX_H - -#include - -static inline int -evl_is_mutex_owner(atomic_t *fastlock, fundle_t ownerh) -{ - return evl_get_index(atomic_read(fastlock)) == ownerh; -} - -static inline -int evl_fast_lock_mutex(atomic_t *fastlock, fundle_t new_ownerh) -{ - fundle_t h; - - h = atomic_cmpxchg(fastlock, EVL_NO_HANDLE, new_ownerh); - if (h != EVL_NO_HANDLE) { - if (evl_get_index(h) == new_ownerh) - return -EBUSY; - - return -EAGAIN; - } - - return 0; -} - -static inline -int evl_fast_unlock_mutex(atomic_t *fastlock, fundle_t cur_ownerh) -{ - return (fundle_t)atomic_cmpxchg(fastlock, cur_ownerh, EVL_NO_HANDLE) - == cur_ownerh; -} - -#endif /* !_EVL_UAPI_MUTEX_H */ diff --git a/include/uapi/evl/net/sched.h b/include/uapi/evl/net/sched.h deleted file mode 100644 index 583103d5a405a7..00000000000000 --- a/include/uapi/evl/net/sched.h +++ /dev/null @@ -1,10 +0,0 @@ -/* - * SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note - * - * Copyright (C) 2020 Philippe Gerum - */ - -#ifndef _EVL_UAPI_NET_SCHED_H -#define _EVL_UAPI_NET_SCHED_H - -#endif /* !_EVL_UAPI_NET_SCHED_H */ diff --git a/include/uapi/evl/net/socket.h b/include/uapi/evl/net/socket-abi.h similarity index 88% rename from include/uapi/evl/net/socket.h rename to include/uapi/evl/net/socket-abi.h index aee01982c11dfe..4973e7d0daee2f 100644 --- a/include/uapi/evl/net/socket.h +++ b/include/uapi/evl/net/socket-abi.h @@ -4,11 +4,10 @@ * Copyright (C) 2020 Philippe Gerum */ -#ifndef _EVL_UAPI_NET_SOCKET_H -#define _EVL_UAPI_NET_SOCKET_H +#ifndef _EVL_UAPI_NET_SOCKET_ABI_H +#define _EVL_UAPI_NET_SOCKET_ABI_H -#include -#include +#include #define AF_OOB 46 /* Out-of-band domain sockets */ @@ -42,4 +41,4 @@ struct evl_netdev_activation { #define EVL_SOCKIOC_SETRECVSZ _IOW(EVL_SOCKET_IOCBASE, 6, int) #define EVL_SOCKIOC_SETSENDSZ _IOW(EVL_SOCKET_IOCBASE, 7, int) -#endif /* !_EVL_UAPI_NET_SOCKET_H */ +#endif /* !_EVL_UAPI_NET_SOCKET_ABI_H */ diff --git a/include/uapi/evl/observable.h b/include/uapi/evl/observable-abi.h similarity index 86% rename from include/uapi/evl/observable.h rename to include/uapi/evl/observable-abi.h index 5e610bde4b5660..3da0a47aef3615 100644 --- a/include/uapi/evl/observable.h +++ b/include/uapi/evl/observable-abi.h @@ -4,10 +4,10 @@ * Copyright (C) 2020 Philippe Gerum */ -#ifndef _EVL_UAPI_OBSERVABLE_H -#define _EVL_UAPI_OBSERVABLE_H +#ifndef _EVL_UAPI_OBSERVABLE_ABI_H +#define _EVL_UAPI_OBSERVABLE_ABI_H -#include +#include #define EVL_OBSERVABLE_DEV "observable" @@ -42,4 +42,4 @@ struct __evl_notification { #define EVL_OBSIOC_SUBSCRIBE _IOW(EVL_OBSERVABLE_IOCBASE, 0, struct evl_subscription) #define EVL_OBSIOC_UNSUBSCRIBE _IO(EVL_OBSERVABLE_IOCBASE, 1) -#endif /* !_EVL_UAPI_OBSERVABLE_H */ +#endif /* !_EVL_UAPI_OBSERVABLE_ABI_H */ diff --git a/include/uapi/evl/poll.h b/include/uapi/evl/poll-abi.h similarity index 86% rename from include/uapi/evl/poll.h rename to include/uapi/evl/poll-abi.h index d9475b8d310465..ba2816e62a3bf3 100644 --- a/include/uapi/evl/poll.h +++ b/include/uapi/evl/poll-abi.h @@ -4,10 +4,10 @@ * Copyright (C) 2018 Philippe Gerum */ -#ifndef _EVL_UAPI_POLL_H -#define _EVL_UAPI_POLL_H +#ifndef _EVL_UAPI_POLL_ABI_H +#define _EVL_UAPI_POLL_ABI_H -#include +#include #define EVL_POLL_DEV "poll" @@ -39,4 +39,4 @@ struct evl_poll_waitreq { #define EVL_POLIOC_CTL _IOW(EVL_POLL_IOCBASE, 0, struct evl_poll_ctlreq) #define EVL_POLIOC_WAIT _IOWR(EVL_POLL_IOCBASE, 1, struct evl_poll_waitreq) -#endif /* !_EVL_UAPI_POLL_H */ +#endif /* !_EVL_UAPI_POLL_ABI_H */ diff --git a/include/uapi/evl/proxy.h b/include/uapi/evl/proxy-abi.h similarity index 72% rename from include/uapi/evl/proxy.h rename to include/uapi/evl/proxy-abi.h index 4b01a3b72ee289..6425e282ba4de0 100644 --- a/include/uapi/evl/proxy.h +++ b/include/uapi/evl/proxy-abi.h @@ -4,8 +4,8 @@ * Copyright (C) 2019 Philippe Gerum */ -#ifndef _EVL_UAPI_PROXY_H -#define _EVL_UAPI_PROXY_H +#ifndef _EVL_UAPI_PROXY_ABI_H +#define _EVL_UAPI_PROXY_ABI_H #include @@ -17,4 +17,4 @@ struct evl_proxy_attrs { __u32 granularity; }; -#endif /* !_EVL_UAPI_PROXY_H */ +#endif /* !_EVL_UAPI_PROXY_ABI_H */ diff --git a/include/uapi/evl/sched.h b/include/uapi/evl/sched-abi.h similarity index 95% rename from include/uapi/evl/sched.h rename to include/uapi/evl/sched-abi.h index f66081a56ab7e7..8c453c86c78891 100644 --- a/include/uapi/evl/sched.h +++ b/include/uapi/evl/sched-abi.h @@ -5,10 +5,10 @@ * Copyright (C) 2005, 2018 Philippe Gerum */ -#ifndef _EVL_UAPI_SCHED_H -#define _EVL_UAPI_SCHED_H +#ifndef _EVL_UAPI_SCHED_ABI_H +#define _EVL_UAPI_SCHED_ABI_H -#include +#include #define EVL_CPU_OOB (1 << 0) #define EVL_CPU_ISOL (1 << 1) @@ -130,4 +130,4 @@ struct evl_sched_ctlreq { __u64 info_ptr; /* (union evl_sched_ctlinfo __user *info) */ }; -#endif /* !_EVL_UAPI_SCHED_H */ +#endif /* !_EVL_UAPI_SCHED_ABI_H */ diff --git a/include/uapi/evl/syscall.h b/include/uapi/evl/syscall-abi.h similarity index 73% rename from include/uapi/evl/syscall.h rename to include/uapi/evl/syscall-abi.h index 1378aeb6d7dcd0..ecc2412f31b773 100644 --- a/include/uapi/evl/syscall.h +++ b/include/uapi/evl/syscall-abi.h @@ -4,8 +4,8 @@ * Copyright (C) 2018 Philippe Gerum */ -#ifndef _EVL_UAPI_SYSCALL_H -#define _EVL_UAPI_SYSCALL_H +#ifndef _EVL_UAPI_SYSCALL_ABI_H +#define _EVL_UAPI_SYSCALL_ABI_H #define sys_evl_read 0 /* oob_read() */ #define sys_evl_write 1 /* oob_write() */ @@ -13,4 +13,4 @@ #define NR_EVL_SYSCALLS 3 -#endif /* !_EVL_UAPI_SYSCALL_H */ +#endif /* !_EVL_UAPI_SYSCALL_ABI_H */ diff --git a/include/uapi/evl/thread.h b/include/uapi/evl/thread-abi.h similarity index 97% rename from include/uapi/evl/thread.h rename to include/uapi/evl/thread-abi.h index c8aed16319465c..8b3c76aa2176a0 100644 --- a/include/uapi/evl/thread.h +++ b/include/uapi/evl/thread-abi.h @@ -5,11 +5,10 @@ * Copyright (C) 2005, 2018 Philippe Gerum */ -#ifndef _EVL_UAPI_THREAD_H -#define _EVL_UAPI_THREAD_H +#ifndef _EVL_UAPI_THREAD_ABI_H +#define _EVL_UAPI_THREAD_ABI_H -#include -#include +#include #define EVL_THREAD_DEV "thread" @@ -131,4 +130,4 @@ struct evl_thread_state { #define EVL_THRIOC_DEMOTE _IO(EVL_THREAD_IOCBASE, 11) #define EVL_THRIOC_YIELD _IO(EVL_THREAD_IOCBASE, 12) -#endif /* !_EVL_UAPI_THREAD_H */ +#endif /* !_EVL_UAPI_THREAD_ABI_H */ diff --git a/include/uapi/evl/xbuf.h b/include/uapi/evl/xbuf-abi.h similarity index 72% rename from include/uapi/evl/xbuf.h rename to include/uapi/evl/xbuf-abi.h index d24c896160d35a..816496cf2b9329 100644 --- a/include/uapi/evl/xbuf.h +++ b/include/uapi/evl/xbuf-abi.h @@ -4,8 +4,8 @@ * Copyright (C) 2018 Philippe Gerum */ -#ifndef _EVL_UAPI_XBUF_H -#define _EVL_UAPI_XBUF_H +#ifndef _EVL_UAPI_XBUF_ABI_H +#define _EVL_UAPI_XBUF_ABI_H #include @@ -16,4 +16,4 @@ struct evl_xbuf_attrs { __u32 o_bufsz; }; -#endif /* !_EVL_UAPI_XBUF_H */ +#endif /* !_EVL_UAPI_XBUF_ABI_H */ diff --git a/kernel/evl/clock.c b/kernel/evl/clock.c index e72db15cc6ca84..3e8dd473f66b5a 100644 --- a/kernel/evl/clock.c +++ b/kernel/evl/clock.c @@ -34,8 +34,6 @@ #include #include #include -#include -#include #include static const struct file_operations clock_fops; diff --git a/kernel/evl/control.c b/kernel/evl/control.c index f58dc8139edb2c..6c27dabe132cae 100644 --- a/kernel/evl/control.c +++ b/kernel/evl/control.c @@ -9,17 +9,13 @@ #include #include #include -#include #include -#include #include -#include #include #include #include #include #include -#include static BLOCKING_NOTIFIER_HEAD(state_notifier_list); diff --git a/kernel/evl/factory.c b/kernel/evl/factory.c index 17ea7567d1f9ca..ffffa3a6a5a8dc 100644 --- a/kernel/evl/factory.c +++ b/kernel/evl/factory.c @@ -27,10 +27,9 @@ #include #include #include -#include #include #include -#include +#include static struct class *evl_class; diff --git a/kernel/evl/memory.c b/kernel/evl/memory.c index 7d60bc7ae068ee..232b8900cb9aa6 100644 --- a/kernel/evl/memory.c +++ b/kernel/evl/memory.c @@ -18,11 +18,9 @@ #include #include #include -#include +#include #include #include -#include -#include static unsigned long sysheap_size_arg; module_param_named(sysheap_size, sysheap_size_arg, ulong, 0444); diff --git a/kernel/evl/monitor.c b/kernel/evl/monitor.c index aac19df39f7a1f..8c78f53831ea77 100644 --- a/kernel/evl/monitor.c +++ b/kernel/evl/monitor.c @@ -8,20 +8,20 @@ #include #include #include -#include #include -#include -#include #include #include -#include #include -#include +#include #include #include -#include #include +static __always_inline atomic_t *__ATOMIC32(__u32 *ptr) +{ + return (atomic_t *)ptr; +} + struct evl_monitor { struct evl_element element; struct evl_monitor_state *state; @@ -290,13 +290,13 @@ static int trywait_count(struct evl_monitor *event) int ret = 0, val; /* atomic_dec_unless_zero_or_negative */ - val = atomic_read(&state->u.event.value); + val = atomic_read(__ATOMIC32(&state->u.event.value)); do { if (unlikely(val <= 0)) { ret = -EAGAIN; break; } - } while (!atomic_try_cmpxchg(&state->u.event.value, &val, val - 1)); + } while (!atomic_try_cmpxchg(__ATOMIC32(&state->u.event.value), &val, val - 1)); return ret; } @@ -320,14 +320,14 @@ static int wait_count(struct file *filp, * likely going to wait anyway. */ raw_spin_lock_irqsave(&event->wait_queue.wchan.lock, flags); - if (atomic_dec_return(&state->u.event.value) < 0) { + if (atomic_dec_return(__ATOMIC32(&state->u.event.value)) < 0) { evl_add_wait_queue(&event->wait_queue, timeout, tmode); raw_spin_unlock_irqrestore(&event->wait_queue.wchan.lock, flags); ret = evl_wait_schedule(&event->wait_queue); if (ret) { /* Rollback decrement if failed. */ - atomic_inc(&state->u.event.value); + atomic_inc(__ATOMIC32(&state->u.event.value)); } else { /* * If waking up on a broadcast, we did @@ -376,11 +376,11 @@ static int post_count(struct evl_monitor *event, s32 sigval, * added back to the count. */ if (val > 0) - atomic_add(val, &state->u.event.value); + atomic_add(val, __ATOMIC32(&state->u.event.value)); /* Userland might have slipped in, re-check. */ - pollable = atomic_read(&state->u.event.value) > 0; + pollable = atomic_read(__ATOMIC32(&state->u.event.value)) > 0; } else { - if (atomic_inc_return(&state->u.event.value) <= 0) { + if (atomic_inc_return(__ATOMIC32(&state->u.event.value)) <= 0) { evl_wake_up_head(&event->wait_queue); pollable = false; } @@ -407,11 +407,11 @@ static bool __trywait_mask(struct evl_monitor *event, struct evl_monitor_state *state = event->state; int testval; - *r_value = atomic_read(&state->u.event.value) & match_value; + *r_value = atomic_read(__ATOMIC32(&state->u.event.value)) & match_value; testval = exact_match ? match_value : *r_value; if (*r_value && *r_value == testval) { - atomic_andnot(*r_value, &state->u.event.value); - testval = atomic_read(&state->u.event.value); + atomic_andnot(*r_value, __ATOMIC32(&state->u.event.value)); + testval = atomic_read(__ATOMIC32(&state->u.event.value)); raw_spin_unlock_irqrestore(&event->wait_queue.wchan.lock, flags); if (!testval) { evl_signal_poll_events(&event->poll_head, POLLOUT|POLLWRNORM); @@ -512,11 +512,11 @@ static int post_mask(struct evl_monitor *event, int bits, bool bcast) * word when an ABI jump is required from applications for * some compelling reason. */ - atomic_or(bits, &state->u.event.value); + atomic_or(bits, __ATOMIC32(&state->u.event.value)); evl_for_each_waiter_safe(waiter, tmp, &event->wait_queue) { w = waiter->wait_data; - waitval = w->value & atomic_read(&state->u.event.value); + waitval = w->value & atomic_read(__ATOMIC32(&state->u.event.value)); testval = w->exact_match ? w->value : waitval; if (waitval && waitval == testval) { w->value = waitval; @@ -528,9 +528,9 @@ static int post_mask(struct evl_monitor *event, int bits, bool bcast) } if (consumed) - atomic_andnot(consumed, &state->u.event.value); + atomic_andnot(consumed, __ATOMIC32(&state->u.event.value)); - val = atomic_read(&state->u.event.value); + val = atomic_read(__ATOMIC32(&state->u.event.value)); raw_spin_unlock_irqrestore(&event->wait_queue.wchan.lock, flags); @@ -874,7 +874,7 @@ static void monitor_unwatch(struct evl_poll_head *head) struct evl_monitor *mon; mon = container_of(head, struct evl_monitor, poll_head); - atomic_dec(&mon->state->u.event.pollrefs); + atomic_dec(__ATOMIC32(&mon->state->u.event.pollrefs)); } static __poll_t monitor_oob_poll(struct file *filp, @@ -895,8 +895,8 @@ static __poll_t monitor_oob_poll(struct file *filp, switch (mon->protocol) { case EVL_EVENT_COUNT: evl_poll_watch(&mon->poll_head, wait, monitor_unwatch); - atomic_inc(&state->u.event.pollrefs); - if (atomic_read(&state->u.event.value) > 0) + atomic_inc(__ATOMIC32(&state->u.event.pollrefs)); + if (atomic_read(__ATOMIC32(&state->u.event.value)) > 0) ret = POLLIN|POLLRDNORM; break; case EVL_EVENT_MASK: @@ -906,8 +906,8 @@ static __poll_t monitor_oob_poll(struct file *filp, * date as long as we support legacy ABIs * (pre-32). */ - atomic_inc(&state->u.event.pollrefs); - val = atomic_read(&state->u.event.value); + atomic_inc(__ATOMIC32(&state->u.event.pollrefs)); + val = atomic_read(__ATOMIC32(&state->u.event.value)); /* * Return POLLIN when some bits are present, * ready for consumption, or POLLOUT when the @@ -1046,12 +1046,12 @@ monitor_factory_build(struct evl_factory *fac, const char __user *u_name, case EVL_GATE_PP: state->u.gate.ceiling = attrs.initval; evl_init_mutex_pp(&mon->mutex, clock, - &state->u.gate.owner, + __ATOMIC32(&state->u.gate.owner), &state->u.gate.ceiling); break; case EVL_GATE_PI: evl_init_mutex_pi(&mon->mutex, clock, - &state->u.gate.owner); + __ATOMIC32(&state->u.gate.owner)); break; } raw_spin_lock_init(&mon->lock); @@ -1060,7 +1060,7 @@ monitor_factory_build(struct evl_factory *fac, const char __user *u_name, case EVL_MONITOR_EVENT: evl_init_wait(&mon->wait_queue, clock, EVL_WAIT_PRIO); state->u.event.gate_offset = EVL_MONITOR_NOGATE; - atomic_set(&state->u.event.value, attrs.initval); + atomic_set(__ATOMIC32(&state->u.event.value), attrs.initval); evl_init_poll_head(&mon->poll_head); } @@ -1134,11 +1134,11 @@ static ssize_t state_show(struct device *dev, switch (mon->protocol) { case EVL_EVENT_MASK: ret = snprintf(buf, PAGE_SIZE, "%#x\n", - atomic_read(&state->u.event.value)); + atomic_read(__ATOMIC32(&state->u.event.value))); break; case EVL_EVENT_COUNT: ret = snprintf(buf, PAGE_SIZE, "%d\n", - atomic_read(&state->u.event.value)); + atomic_read(__ATOMIC32(&state->u.event.value))); break; case EVL_EVENT_GATED: ret = snprintf(buf, PAGE_SIZE, "%#x\n", @@ -1146,7 +1146,7 @@ static ssize_t state_show(struct device *dev, break; } } else { - fun = atomic_read(&state->u.gate.owner); + fun = atomic_read(__ATOMIC32(&state->u.gate.owner)); if (fun != EVL_NO_HANDLE) { owner = evl_get_factory_element_by_fundle(&evl_thread_factory, evl_get_index(fun), diff --git a/kernel/evl/mutex.c b/kernel/evl/mutex.c index bb57f3d8d93d08..aa32059054a6aa 100644 --- a/kernel/evl/mutex.c +++ b/kernel/evl/mutex.c @@ -2,17 +2,14 @@ * SPDX-License-Identifier: GPL-2.0 * * Derived from Xenomai Cobalt, https://xenomai.org/ - * Copyright (C) 2001, 2019 Philippe Gerum + * Copyright (C) 2001, 2019, 2022 Philippe Gerum + * Copyright (C) 2008, 2009 Jan Kiszka . */ #include #include -#include -#include #include #include -#include -#include #include #include #include diff --git a/kernel/evl/net/qdisc/fifo.c b/kernel/evl/net/qdisc/fifo.c index a1d8e97da88950..0d4d2448d39aa6 100644 --- a/kernel/evl/net/qdisc/fifo.c +++ b/kernel/evl/net/qdisc/fifo.c @@ -9,7 +9,6 @@ #include #include #include -#include struct qdisc_fifo_priv { struct evl_net_skb_queue q; diff --git a/kernel/evl/observable.c b/kernel/evl/observable.c index d488335514043b..b38edd82984ed8 100644 --- a/kernel/evl/observable.c +++ b/kernel/evl/observable.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/kernel/evl/proxy.c b/kernel/evl/proxy.c index e18fcedf284ec7..35f07a2adb6d3b 100644 --- a/kernel/evl/proxy.c +++ b/kernel/evl/proxy.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #define EVL_PROXY_CLONE_FLAGS \ (EVL_CLONE_PUBLIC|EVL_CLONE_OUTPUT|EVL_CLONE_INPUT) diff --git a/kernel/evl/sched/core.c b/kernel/evl/sched/core.c index 3bfbe37b1eb7bd..be5c9923e78106 100644 --- a/kernel/evl/sched/core.c +++ b/kernel/evl/sched/core.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/kernel/evl/sched/quota.c b/kernel/evl/sched/quota.c index 158bb2e2423e5b..70b64cb4e05a5e 100644 --- a/kernel/evl/sched/quota.c +++ b/kernel/evl/sched/quota.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include /* * With this policy, each per-CPU runqueue maintains a list of active diff --git a/kernel/evl/sched/tp.c b/kernel/evl/sched/tp.c index d55b214f81e609..a4054266ef2cd9 100644 --- a/kernel/evl/sched/tp.c +++ b/kernel/evl/sched/tp.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include static void tp_schedule_next(struct evl_sched_tp *tp) { diff --git a/kernel/evl/sched/weak.c b/kernel/evl/sched/weak.c index 5dfd470009a6f2..b3d25186cbc4a8 100644 --- a/kernel/evl/sched/weak.c +++ b/kernel/evl/sched/weak.c @@ -6,7 +6,7 @@ */ #include -#include +#include static void weak_init(struct evl_rq *rq) { diff --git a/kernel/evl/sem.c b/kernel/evl/sem.c index f3e1e467681513..7609e35d4a4a57 100644 --- a/kernel/evl/sem.c +++ b/kernel/evl/sem.c @@ -4,9 +4,6 @@ * Copyright (C) 2019 Philippe Gerum */ -#include -#include -#include #include #include diff --git a/kernel/evl/syscall.c b/kernel/evl/syscall.c index 216c8108b021a6..c2a3f13ebe372d 100644 --- a/kernel/evl/syscall.c +++ b/kernel/evl/syscall.c @@ -17,17 +17,12 @@ #include #include #include -#include #include -#include -#include -#include #include -#include -#include #include -#include +#include #include +#include #define EVL_SYSCALL(__name, __args) \ long EVL_ ## __name __args diff --git a/kernel/evl/thread.c b/kernel/evl/thread.c index 5cd1539cd3a31a..1c5bfe12d231cb 100644 --- a/kernel/evl/thread.c +++ b/kernel/evl/thread.c @@ -23,16 +23,9 @@ #include #include #include -#include -#include -#include -#include -#include -#include #include #include #include -#include #include #include #include @@ -41,6 +34,7 @@ #include #include #include +#include #include #define EVL_THREAD_CLONE_FLAGS \ diff --git a/kernel/evl/tick.c b/kernel/evl/tick.c index 8a3a02c665fd22..3d9c433631ceab 100644 --- a/kernel/evl/tick.c +++ b/kernel/evl/tick.c @@ -8,17 +8,11 @@ #include #include #include -#include #include #include #include #include -#include -#include -#include -#include #include -#include #include static DEFINE_PER_CPU(struct clock_proxy_device *, proxy_device); diff --git a/kernel/evl/timer.c b/kernel/evl/timer.c index a53a53eb3e6f95..ec372f9cda21cc 100644 --- a/kernel/evl/timer.c +++ b/kernel/evl/timer.c @@ -6,13 +6,8 @@ * Copyright (C) 2001, 2018 Philippe Gerum */ -#include -#include -#include -#include #include #include -#include #include #include #include diff --git a/kernel/evl/wait.c b/kernel/evl/wait.c index 26d48cee3b5519..69f24e73588789 100644 --- a/kernel/evl/wait.c +++ b/kernel/evl/wait.c @@ -6,10 +6,8 @@ */ #include -#include #include #include -#include #include #include diff --git a/kernel/evl/work.c b/kernel/evl/work.c index 1c3774482a9b85..4a7f4a0acc0236 100644 --- a/kernel/evl/work.c +++ b/kernel/evl/work.c @@ -4,7 +4,6 @@ * Copyright (C) 2020 Philippe Gerum */ -#include #include static void do_wq_work(struct work_struct *wq_work) diff --git a/kernel/evl/xbuf.c b/kernel/evl/xbuf.c index 05423fe876da73..fca6d2a834013d 100644 --- a/kernel/evl/xbuf.c +++ b/kernel/evl/xbuf.c @@ -12,16 +12,13 @@ #include #include #include -#include #include -#include #include -#include #include #include #include #include -#include +#include struct xbuf_ring { void *bufmem;