All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH Dovetail 00/13] Keep on abstracting the pipeline interface
@ 2021-01-02  9:33 Philippe Gerum
  2021-01-02  9:33 ` [PATCH Dovetail 01/13] cobalt/thread: pipeline: abstract threadinfo accessor Philippe Gerum
                   ` (12 more replies)
  0 siblings, 13 replies; 23+ messages in thread
From: Philippe Gerum @ 2021-01-02  9:33 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

Most importantly: Happy new year, and best wishes.

Sidenote: this is the next series of patches (out of 70+) which adds
an abstraction layer to the Cobalt core, so that we can choose to
interface it to the legacy I-pipe or Dovetail at build time. This is
on top of the -next branch as usual.

Philippe Gerum (13):
  cobalt/thread: pipeline: abstract threadinfo accessor
  cobalt/apc: pipeline: abstract interface for deferred routine calls
  cobalt/trace: pipeline: abstract trace calls
  cobalt/lock: pipeline: abstract hard lock API
  cobalt/kernel: pipeline: abstract execution stage predicates
  cobalt/sched, clock: pipeline: abstract IPI management
  cobalt/clock: pipeline: make HOSTRT depend on IPIPE
  cobalt/build: pipeline: select IPIPE layer only if present
  cobalt/clock: pipeline: abstract clock, timer access services
  cobalt/wrappers: pipeline: abstract pipeline-related bits
  cobalt/timer: pipeline: abstract tick management
  cobalt/debug: pipeline: abstract panic prep call
  cobalt/syscall: pipeline: abstract syscall entry points

 include/cobalt/kernel/apc.h                   |  51 +---
 include/cobalt/kernel/assert.h                |   5 +-
 include/cobalt/kernel/clock.h                 |   8 +-
 include/cobalt/kernel/intr.h                  |   1 -
 include/cobalt/kernel/ipipe/pipeline/clock.h  |  32 ++
 .../cobalt/kernel/ipipe/pipeline/kevents.h    |   3 +
 include/cobalt/kernel/ipipe/pipeline/lock.h   |  21 ++
 .../cobalt/kernel/ipipe/pipeline/pipeline.h   |  80 +++++
 include/cobalt/kernel/ipipe/pipeline/thread.h |  26 ++
 include/cobalt/kernel/ipipe/pipeline/tick.h   |  12 +
 include/cobalt/kernel/ipipe/pipeline/trace.h  | 111 +++++++
 .../cobalt/kernel/ipipe/pipeline/wrappers.h   |  25 ++
 include/cobalt/kernel/lock.h                  |  44 +--
 include/cobalt/kernel/rtdm/driver.h           |  11 +-
 include/cobalt/kernel/sched.h                 |   2 -
 include/cobalt/kernel/stat.h                  |   3 -
 include/cobalt/kernel/thread.h                |   5 +-
 include/cobalt/kernel/timer.h                 |   4 -
 include/cobalt/kernel/trace.h                 | 101 +------
 include/cobalt/kernel/vdso.h                  |  18 +-
 kernel/cobalt/Kconfig                         |   4 -
 kernel/cobalt/Makefile                        |   3 +-
 kernel/cobalt/clock.c                         |   7 +-
 kernel/cobalt/debug.c                         |   2 +-
 .../include/asm-generic/xenomai/wrappers.h    |   4 -
 .../cobalt/include/linux/xenomai/wrappers.h   |  23 +-
 kernel/cobalt/init.c                          |   5 +-
 kernel/cobalt/ipipe/Makefile                  |   2 +-
 kernel/cobalt/{ => ipipe}/apc.c               |  42 +++
 kernel/cobalt/ipipe/init.c                    |   2 +
 kernel/cobalt/ipipe/intr.c                    |   2 +-
 kernel/cobalt/ipipe/kevents.c                 |  20 +-
 kernel/cobalt/ipipe/syscall.c                 |  29 ++
 kernel/cobalt/ipipe/tick.c                    | 278 ++++++++++++++++++
 kernel/cobalt/posix/clock.c                   |   4 +-
 kernel/cobalt/posix/corectl.c                 |   8 +-
 kernel/cobalt/posix/process.c                 |   6 +-
 kernel/cobalt/posix/process.h                 |   8 +-
 kernel/cobalt/posix/syscall.c                 |  32 +-
 kernel/cobalt/posix/syscall.h                 |   7 +
 kernel/cobalt/registry.c                      |   2 +-
 kernel/cobalt/rtdm/drvlib.c                   |   2 +-
 kernel/cobalt/rtdm/fd.c                       |  14 +-
 kernel/cobalt/sched.c                         |  16 +-
 kernel/cobalt/thread.c                        |   6 +-
 kernel/cobalt/timer.c                         | 272 +----------------
 kernel/drivers/testing/timerbench.c           |  12 +-
 scripts/Kconfig.frag                          |   8 +-
 48 files changed, 776 insertions(+), 607 deletions(-)
 create mode 100644 include/cobalt/kernel/ipipe/pipeline/clock.h
 create mode 100644 include/cobalt/kernel/ipipe/pipeline/lock.h
 create mode 100644 include/cobalt/kernel/ipipe/pipeline/pipeline.h
 create mode 100644 include/cobalt/kernel/ipipe/pipeline/thread.h
 create mode 100644 include/cobalt/kernel/ipipe/pipeline/tick.h
 create mode 100644 include/cobalt/kernel/ipipe/pipeline/trace.h
 create mode 100644 include/cobalt/kernel/ipipe/pipeline/wrappers.h
 rename kernel/cobalt/{ => ipipe}/apc.c (80%)
 create mode 100644 kernel/cobalt/ipipe/syscall.c
 create mode 100644 kernel/cobalt/ipipe/tick.c

-- 
2.26.2



^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH Dovetail 01/13] cobalt/thread: pipeline: abstract threadinfo accessor
  2021-01-02  9:33 [PATCH Dovetail 00/13] Keep on abstracting the pipeline interface Philippe Gerum
@ 2021-01-02  9:33 ` Philippe Gerum
  2021-01-08  9:02   ` Jan Kiszka
  2021-01-02  9:33 ` [PATCH Dovetail 02/13] cobalt/apc: pipeline: abstract interface for deferred routine calls Philippe Gerum
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 23+ messages in thread
From: Philippe Gerum @ 2021-01-02  9:33 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

The I-pipe and Dovetail access the per-thread information block
differently. Abstract this kernel interface.

No functional change is introduced.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 include/cobalt/kernel/ipipe/pipeline/thread.h | 26 +++++++++++++++++++
 include/cobalt/kernel/thread.h                |  5 ++--
 kernel/cobalt/ipipe/kevents.c                 |  6 ++---
 kernel/cobalt/posix/process.c                 |  4 +--
 kernel/cobalt/posix/process.h                 |  5 ++--
 kernel/cobalt/thread.c                        |  4 +--
 6 files changed, 39 insertions(+), 11 deletions(-)
 create mode 100644 include/cobalt/kernel/ipipe/pipeline/thread.h

diff --git a/include/cobalt/kernel/ipipe/pipeline/thread.h b/include/cobalt/kernel/ipipe/pipeline/thread.h
new file mode 100644
index 000000000..a62e622c4
--- /dev/null
+++ b/include/cobalt/kernel/ipipe/pipeline/thread.h
@@ -0,0 +1,26 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2019 Philippe Gerum  <rpm@xenomai.org>
+ */
+
+#ifndef _COBALT_KERNEL_IPIPE_THREAD_H
+#define _COBALT_KERNEL_IPIPE_THREAD_H
+
+#include <linux/ipipe.h>
+
+struct xnthread;
+
+#define cobalt_threadinfo ipipe_threadinfo
+
+static inline struct cobalt_threadinfo *pipeline_current(void)
+{
+	return ipipe_current_threadinfo();
+}
+
+static inline struct xnthread *pipeline_thread_from_task(struct task_struct *p)
+{
+	return ipipe_task_threadinfo(p)->thread;
+}
+
+#endif /* !_COBALT_KERNEL_IPIPE_THREAD_H */
diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h
index 21a8603b4..2d57b8398 100644
--- a/include/cobalt/kernel/thread.h
+++ b/include/cobalt/kernel/thread.h
@@ -22,6 +22,7 @@
 #include <linux/wait.h>
 #include <linux/sched.h>
 #include <linux/sched/rt.h>
+#include <pipeline/thread.h>
 #include <cobalt/kernel/list.h>
 #include <cobalt/kernel/stat.h>
 #include <cobalt/kernel/timer.h>
@@ -372,7 +373,7 @@ void __xnthread_discard(struct xnthread *thread);
  */
 static inline struct xnthread *xnthread_current(void)
 {
-	return ipipe_current_threadinfo()->thread;
+	return pipeline_current()->thread;
 }
 
 /**
@@ -388,7 +389,7 @@ static inline struct xnthread *xnthread_current(void)
  */
 static inline struct xnthread *xnthread_from_task(struct task_struct *p)
 {
-	return ipipe_task_threadinfo(p)->thread;
+	return pipeline_thread_from_task(p);
 }
 
 /**
diff --git a/kernel/cobalt/ipipe/kevents.c b/kernel/cobalt/ipipe/kevents.c
index ba584677c..e0d4a1288 100644
--- a/kernel/cobalt/ipipe/kevents.c
+++ b/kernel/cobalt/ipipe/kevents.c
@@ -831,16 +831,16 @@ static inline int get_mayday_prot(void)
 
 void pipeline_attach_current(struct xnthread *thread)
 {
-	struct ipipe_threadinfo *p;
+	struct cobalt_threadinfo *p;
 
-	p = ipipe_current_threadinfo();
+	p = pipeline_current();
 	p->thread = thread;
 	p->process = cobalt_search_process(current->mm);
 }
 
 static void detach_current(void)
 {
-	struct ipipe_threadinfo *p = ipipe_current_threadinfo();
+	struct cobalt_threadinfo *p = pipeline_current();
 	p->thread = NULL;
 	p->process = NULL;
 }
diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
index 9bc6082d0..accd989ca 100644
--- a/kernel/cobalt/posix/process.c
+++ b/kernel/cobalt/posix/process.c
@@ -463,7 +463,7 @@ EXPORT_SYMBOL_GPL(cobalt_unregister_personality);
 struct xnthread_personality *
 cobalt_push_personality(int xid)
 {
-	struct ipipe_threadinfo *p = ipipe_current_threadinfo();
+	struct cobalt_threadinfo *p = pipeline_current();
 	struct xnthread_personality *prev, *next;
 	struct xnthread *thread = p->thread;
 
@@ -504,7 +504,7 @@ EXPORT_SYMBOL_GPL(cobalt_push_personality);
  */
 void cobalt_pop_personality(struct xnthread_personality *prev)
 {
-	struct ipipe_threadinfo *p = ipipe_current_threadinfo();
+	struct cobalt_threadinfo *p = pipeline_current();
 	struct xnthread *thread = p->thread;
 
 	secondary_mode_only();
diff --git a/kernel/cobalt/posix/process.h b/kernel/cobalt/posix/process.h
index 3a38ae639..a2f4ec591 100644
--- a/kernel/cobalt/posix/process.h
+++ b/kernel/cobalt/posix/process.h
@@ -20,6 +20,7 @@
 
 #include <linux/list.h>
 #include <linux/bitmap.h>
+#include <pipeline/thread.h>
 #include <cobalt/kernel/ppd.h>
 
 #define KEVENT_PROPAGATE   0
@@ -94,13 +95,13 @@ extern struct cobalt_resources cobalt_global_resources;
 
 static inline struct cobalt_process *cobalt_current_process(void)
 {
-	return ipipe_current_threadinfo()->process;
+	return pipeline_current()->process;
 }
 
 static inline struct cobalt_process *
 cobalt_set_process(struct cobalt_process *process)
 {
-	struct ipipe_threadinfo *p = ipipe_current_threadinfo();
+	struct cobalt_threadinfo *p = pipeline_current();
 	struct cobalt_process *old;
 
 	old = p->process;
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index a882bcc45..b871e6069 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -2452,9 +2452,9 @@ static inline void wakeup_parent(struct completion *done)
 
 static inline void init_kthread_info(struct xnthread *thread)
 {
-	struct ipipe_threadinfo *p;
+	struct cobalt_threadinfo *p;
 
-	p = ipipe_current_threadinfo();
+	p = pipeline_current();
 	p->thread = thread;
 	p->process = NULL;
 }
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH Dovetail 02/13] cobalt/apc: pipeline: abstract interface for deferred routine calls
  2021-01-02  9:33 [PATCH Dovetail 00/13] Keep on abstracting the pipeline interface Philippe Gerum
  2021-01-02  9:33 ` [PATCH Dovetail 01/13] cobalt/thread: pipeline: abstract threadinfo accessor Philippe Gerum
@ 2021-01-02  9:33 ` Philippe Gerum
  2021-01-02  9:33 ` [PATCH Dovetail 03/13] cobalt/trace: pipeline: abstract trace calls Philippe Gerum
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 23+ messages in thread
From: Philippe Gerum @ 2021-01-02  9:33 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

Dovetail enables the regular irq_work() for submitting work from the
out-of-band stage (primary mode) to the in-band one (secondary
mode). We won't need APCs in the Dovetail case, let's move this code
to the I-pipe section.

No functional change is introduced.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 include/cobalt/kernel/apc.h     | 51 ++-------------------------------
 kernel/cobalt/Makefile          |  3 +-
 kernel/cobalt/ipipe/Makefile    |  2 +-
 kernel/cobalt/{ => ipipe}/apc.c | 42 +++++++++++++++++++++++++++
 kernel/cobalt/ipipe/init.c      |  2 ++
 5 files changed, 48 insertions(+), 52 deletions(-)
 rename kernel/cobalt/{ => ipipe}/apc.c (80%)

diff --git a/include/cobalt/kernel/apc.h b/include/cobalt/kernel/apc.h
index 7075ad07a..45d70b146 100644
--- a/include/cobalt/kernel/apc.h
+++ b/include/cobalt/kernel/apc.h
@@ -19,61 +19,14 @@
 #ifndef _COBALT_KERNEL_APC_H
 #define _COBALT_KERNEL_APC_H
 
-#include <linux/ipipe.h>
-#include <asm/xenomai/machine.h>
-
-/**
- * @addtogroup cobalt_core_apc
- * @{
- */
-
 int xnapc_alloc(const char *name,
 		void (*handler)(void *cookie),
 		void *cookie);
 
 void xnapc_free(int apc);
 
-static inline void __xnapc_schedule(int apc)
-{
-	unsigned long *p = &raw_cpu_ptr(&cobalt_machine_cpudata)->apc_pending;
-
-	if (!__test_and_set_bit(apc, p))
-		ipipe_post_irq_root(cobalt_pipeline.apc_virq);
-}
-
-/**
- * @fn static inline int xnapc_schedule(int apc)
- *
- * @brief Schedule an APC invocation.
- *
- * This service marks the APC as pending for the Linux domain, so that
- * its handler will be called as soon as possible, when the Linux
- * domain gets back in control.
- *
- * When posted from the Linux domain, the APC handler is fired as soon
- * as the interrupt mask is explicitly cleared by some kernel
- * code. When posted from the Xenomai domain, the APC handler is
- * fired as soon as the Linux domain is resumed, i.e. after Xenomai has
- * completed all its pending duties.
- *
- * @param apc The APC id. to schedule.
- *
- * This service can be called from:
- *
- * - Any domain context, albeit the usual calling place is from the
- * Xenomai domain.
- */
-static inline void xnapc_schedule(int apc)
-{
-	unsigned long flags;
-
-	flags = ipipe_test_and_stall_head() & 1;
-	__xnapc_schedule(apc);
-	ipipe_restore_head(flags);
-}
-
-void apc_dispatch(unsigned int virq, void *arg);
+void __xnapc_schedule(int apc);
 
-/** @} */
+void xnapc_schedule(int apc);
 
 #endif /* !_COBALT_KERNEL_APC_H */
diff --git a/kernel/cobalt/Makefile b/kernel/cobalt/Makefile
index de3ae1bfc..129005d8f 100644
--- a/kernel/cobalt/Makefile
+++ b/kernel/cobalt/Makefile
@@ -1,7 +1,6 @@
 obj-$(CONFIG_XENOMAI) += pipeline/ xenomai.o rtdm/ posix/
 
-xenomai-y :=	apc.o		\
-		arith.o 	\
+xenomai-y :=	arith.o 	\
 		bufd.o		\
 		clock.o		\
 		heap.o		\
diff --git a/kernel/cobalt/ipipe/Makefile b/kernel/cobalt/ipipe/Makefile
index 5170bb32b..13186dc7f 100644
--- a/kernel/cobalt/ipipe/Makefile
+++ b/kernel/cobalt/ipipe/Makefile
@@ -2,4 +2,4 @@ ccflags-y += -Ikernel
 
 obj-y +=	pipeline.o
 
-pipeline-y :=	init.o intr.o kevents.o
+pipeline-y :=	init.o intr.o kevents.o apc.o
diff --git a/kernel/cobalt/apc.c b/kernel/cobalt/ipipe/apc.c
similarity index 80%
rename from kernel/cobalt/apc.c
rename to kernel/cobalt/ipipe/apc.c
index 97edcfc4c..715997727 100644
--- a/kernel/cobalt/apc.c
+++ b/kernel/cobalt/ipipe/apc.c
@@ -18,6 +18,7 @@
  */
 #include <linux/spinlock.h>
 #include <linux/ipipe.h>
+#include <asm/xenomai/machine.h>
 #include <cobalt/kernel/apc.h>
 
 /**
@@ -157,4 +158,45 @@ void xnapc_free(int apc)
 }
 EXPORT_SYMBOL_GPL(xnapc_free);
 
+void __xnapc_schedule(int apc)
+{
+	unsigned long *p = &raw_cpu_ptr(&cobalt_machine_cpudata)->apc_pending;
+
+	if (!__test_and_set_bit(apc, p))
+		ipipe_post_irq_root(cobalt_pipeline.apc_virq);
+}
+EXPORT_SYMBOL_GPL(__xnapc_schedule);
+
+/**
+ * @fn static inline int xnapc_schedule(int apc)
+ *
+ * @brief Schedule an APC invocation.
+ *
+ * This service marks the APC as pending for the Linux domain, so that
+ * its handler will be called as soon as possible, when the Linux
+ * domain gets back in control.
+ *
+ * When posted from the Linux domain, the APC handler is fired as soon
+ * as the interrupt mask is explicitly cleared by some kernel
+ * code. When posted from the Xenomai domain, the APC handler is
+ * fired as soon as the Linux domain is resumed, i.e. after Xenomai has
+ * completed all its pending duties.
+ *
+ * @param apc The APC id. to schedule.
+ *
+ * This service can be called from:
+ *
+ * - Any domain context, albeit the usual calling place is from the
+ * Xenomai domain.
+ */
+void xnapc_schedule(int apc)
+{
+	unsigned long flags;
+
+	flags = ipipe_test_and_stall_head() & 1;
+	__xnapc_schedule(apc);
+	ipipe_restore_head(flags);
+}
+EXPORT_SYMBOL_GPL(xnapc_schedule);
+
 /** @} */
diff --git a/kernel/cobalt/ipipe/init.c b/kernel/cobalt/ipipe/init.c
index 4d7ac04de..d901c417f 100644
--- a/kernel/cobalt/ipipe/init.c
+++ b/kernel/cobalt/ipipe/init.c
@@ -18,6 +18,8 @@ module_param_named(timerfreq, timerfreq_arg, ulong, 0444);
 static unsigned long clockfreq_arg;
 module_param_named(clockfreq, clockfreq_arg, ulong, 0444);
 
+void apc_dispatch(unsigned int virq, void *arg);
+
 int __init pipeline_init(void)
 {
 	struct ipipe_sysinfo sysinfo;
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH Dovetail 03/13] cobalt/trace: pipeline: abstract trace calls
  2021-01-02  9:33 [PATCH Dovetail 00/13] Keep on abstracting the pipeline interface Philippe Gerum
  2021-01-02  9:33 ` [PATCH Dovetail 01/13] cobalt/thread: pipeline: abstract threadinfo accessor Philippe Gerum
  2021-01-02  9:33 ` [PATCH Dovetail 02/13] cobalt/apc: pipeline: abstract interface for deferred routine calls Philippe Gerum
@ 2021-01-02  9:33 ` Philippe Gerum
  2021-01-02  9:33 ` [PATCH Dovetail 04/13] cobalt/lock: pipeline: abstract hard lock API Philippe Gerum
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 23+ messages in thread
From: Philippe Gerum @ 2021-01-02  9:33 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

Unlike the I-pipe, Dovetail comes with no specific tracer, tracepoints
can be sent to common ftrace-based tracers, with the 'function' tracer
reporting Dovetail-specific information such as the current execution
stage, and the real & virtual interrupt states (hard disabled/enabled,
stalled/unstalled) for the current context.

In other words, ftrace's 'function' tracer with Dovetail is similar to
the I-pipe specific tracer.

Since we can use ftrace through the regular kernel interface with
Dovetail, the legacy trace interface can move to the I-pipe section.

No functional change is introduced.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 include/cobalt/kernel/ipipe/pipeline/trace.h | 111 +++++++++++++++++++
 include/cobalt/kernel/trace.h                | 101 +----------------
 kernel/drivers/testing/timerbench.c          |  12 +-
 3 files changed, 120 insertions(+), 104 deletions(-)
 create mode 100644 include/cobalt/kernel/ipipe/pipeline/trace.h

diff --git a/include/cobalt/kernel/ipipe/pipeline/trace.h b/include/cobalt/kernel/ipipe/pipeline/trace.h
new file mode 100644
index 000000000..d92e57a63
--- /dev/null
+++ b/include/cobalt/kernel/ipipe/pipeline/trace.h
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2006 Jan Kiszka <jan.kiszka@web.de>.
+ *
+ * Xenomai is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * Xenomai is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Xenomai; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+#ifndef _COBALT_KERNEL_IPIPE_TRACE_H
+#define _COBALT_KERNEL_IPIPE_TRACE_H
+
+#include <linux/types.h>
+#include <linux/kconfig.h>
+#include <linux/ipipe_trace.h>
+#include <cobalt/uapi/kernel/trace.h>
+
+static inline int xntrace_max_begin(unsigned long v)
+{
+	ipipe_trace_begin(v);
+	return 0;
+}
+
+static inline int xntrace_max_end(unsigned long v)
+{
+	ipipe_trace_end(v);
+	return 0;
+}
+
+static inline int xntrace_max_reset(void)
+{
+	ipipe_trace_max_reset();
+	return 0;
+}
+
+static inline int xntrace_user_start(void)
+{
+	return ipipe_trace_frozen_reset();
+}
+
+static inline int xntrace_user_stop(unsigned long v)
+{
+	ipipe_trace_freeze(v);
+	return 0;
+}
+
+static inline int xntrace_user_freeze(unsigned long v, int once)
+{
+	int ret = 0;
+
+	if (!once)
+		ret = ipipe_trace_frozen_reset();
+
+	ipipe_trace_freeze(v);
+
+	return ret;
+}
+
+static inline int xntrace_special(unsigned char id, unsigned long v)
+{
+	ipipe_trace_special(id, v);
+	return 0;
+}
+
+static inline int xntrace_special_u64(unsigned char id,
+				      unsigned long long v)
+{
+	ipipe_trace_special(id, (unsigned long)(v >> 32));
+	ipipe_trace_special(id, (unsigned long)(v & 0xFFFFFFFF));
+	return 0;
+}
+
+static inline int xntrace_pid(pid_t pid, short prio)
+{
+	ipipe_trace_pid(pid, prio);
+	return 0;
+}
+
+static inline int xntrace_tick(unsigned long delay_ticks)
+{
+	ipipe_trace_event(0, delay_ticks);
+	return 0;
+}
+
+static inline int xntrace_panic_freeze(void)
+{
+	ipipe_trace_panic_freeze();
+	return 0;
+}
+
+static inline int xntrace_panic_dump(void)
+{
+	ipipe_trace_panic_dump();
+	return 0;
+}
+
+static inline bool xntrace_enabled(void)
+{
+	return IS_ENABLED(CONFIG_IPIPE_TRACE);
+}
+
+#endif /* !_COBALT_KERNEL_IPIPE_TRACE_H */
diff --git a/include/cobalt/kernel/trace.h b/include/cobalt/kernel/trace.h
index 5f2b6ca2a..e46dd4ebd 100644
--- a/include/cobalt/kernel/trace.h
+++ b/include/cobalt/kernel/trace.h
@@ -1,105 +1,10 @@
 /*
- * Copyright (C) 2006 Jan Kiszka <jan.kiszka@web.de>.
- *
- * Xenomai is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2 of the License,
- * or (at your option) any later version.
- *
- * Xenomai is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Xenomai; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * SPDX-License-Identifier: GPL-2.0
  */
+
 #ifndef _COBALT_KERNEL_TRACE_H
 #define _COBALT_KERNEL_TRACE_H
 
-#include <linux/types.h>
-#include <linux/ipipe_trace.h>
-#include <cobalt/uapi/kernel/trace.h>
-
-static inline int xntrace_max_begin(unsigned long v)
-{
-	ipipe_trace_begin(v);
-	return 0;
-}
-
-static inline int xntrace_max_end(unsigned long v)
-{
-	ipipe_trace_end(v);
-	return 0;
-}
-
-static inline int xntrace_max_reset(void)
-{
-	ipipe_trace_max_reset();
-	return 0;
-}
-
-static inline int xntrace_user_start(void)
-{
-	return ipipe_trace_frozen_reset();
-}
-
-static inline int xntrace_user_stop(unsigned long v)
-{
-	ipipe_trace_freeze(v);
-	return 0;
-}
-
-static inline int xntrace_user_freeze(unsigned long v, int once)
-{
-	int ret = 0;
-
-	if (!once)
-		ret = ipipe_trace_frozen_reset();
-
-	ipipe_trace_freeze(v);
-
-	return ret;
-}
-
-static inline int xntrace_special(unsigned char id, unsigned long v)
-{
-	ipipe_trace_special(id, v);
-	return 0;
-}
-
-static inline int xntrace_special_u64(unsigned char id,
-				      unsigned long long v)
-{
-	ipipe_trace_special(id, (unsigned long)(v >> 32));
-	ipipe_trace_special(id, (unsigned long)(v & 0xFFFFFFFF));
-	return 0;
-}
-
-static inline int xntrace_pid(pid_t pid, short prio)
-{
-	ipipe_trace_pid(pid, prio);
-	return 0;
-}
-
-static inline int xntrace_tick(unsigned long delay_ticks)
-{
-	ipipe_trace_event(0, delay_ticks);
-	return 0;
-}
-
-static inline int xntrace_panic_freeze(void)
-{
-	ipipe_trace_panic_freeze();
-	return 0;
-}
-
-static inline int xntrace_panic_dump(void)
-{
-	ipipe_trace_panic_dump();
-	return 0;
-}
+#include <pipeline/trace.h>
 
 #endif /* !_COBALT_KERNEL_TRACE_H */
diff --git a/kernel/drivers/testing/timerbench.c b/kernel/drivers/testing/timerbench.c
index 8b91bae9b..31f0bea76 100644
--- a/kernel/drivers/testing/timerbench.c
+++ b/kernel/drivers/testing/timerbench.c
@@ -19,7 +19,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/semaphore.h>
-#include <linux/ipipe_trace.h>
+#include <cobalt/kernel/trace.h>
 #include <cobalt/kernel/arith.h>
 #include <rtdm/testing.h>
 #include <rtdm/driver.h>
@@ -78,13 +78,13 @@ static void eval_inner_loop(struct rt_tmbench_context *ctx, __s32 dt)
 		ctx->curr.min = dt;
 	ctx->curr.avg += dt;
 
-#ifdef CONFIG_IPIPE_TRACE
-	if (ctx->freeze_max && (dt > ctx->result.overall.max) && !ctx->warmup) {
-		ipipe_trace_frozen_reset();
-		ipipe_trace_freeze(dt);
+	if (xntrace_enabled() &&
+		ctx->freeze_max &&
+		(dt > ctx->result.overall.max) &&
+		!ctx->warmup) {
+		xntrace_user_freeze(dt, false);
 		ctx->result.overall.max = dt;
 	}
-#endif /* CONFIG_IPIPE_TRACE */
 
 	ctx->date += ctx->period;
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH Dovetail 04/13] cobalt/lock: pipeline: abstract hard lock API
  2021-01-02  9:33 [PATCH Dovetail 00/13] Keep on abstracting the pipeline interface Philippe Gerum
                   ` (2 preceding siblings ...)
  2021-01-02  9:33 ` [PATCH Dovetail 03/13] cobalt/trace: pipeline: abstract trace calls Philippe Gerum
@ 2021-01-02  9:33 ` Philippe Gerum
  2021-01-02  9:33 ` [PATCH Dovetail 05/13] cobalt/kernel: pipeline: abstract execution stage predicates Philippe Gerum
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 23+ messages in thread
From: Philippe Gerum @ 2021-01-02  9:33 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

Dovetail implements two types of locks: hard, and hybrid ones.  See
https://evlproject.org/dovetail/pipeline/locking/ for details.

Cobalt is interested in using Dovetail's hard_spinlock_t locks, which
are strictly equivalent to the ipipe_spinlock_t locks. Provide a
wrapper mapping a generic hard lock to the proper implementation
depending on the underlying pipeline flavour.

No functional change is introduced.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 include/cobalt/kernel/ipipe/pipeline/lock.h   | 21 +++++++++
 .../cobalt/kernel/ipipe/pipeline/pipeline.h   | 25 +++++++++++
 include/cobalt/kernel/lock.h                  | 44 +------------------
 include/cobalt/kernel/rtdm/driver.h           |  9 ++--
 4 files changed, 53 insertions(+), 46 deletions(-)
 create mode 100644 include/cobalt/kernel/ipipe/pipeline/lock.h
 create mode 100644 include/cobalt/kernel/ipipe/pipeline/pipeline.h

diff --git a/include/cobalt/kernel/ipipe/pipeline/lock.h b/include/cobalt/kernel/ipipe/pipeline/lock.h
new file mode 100644
index 000000000..f33b041c7
--- /dev/null
+++ b/include/cobalt/kernel/ipipe/pipeline/lock.h
@@ -0,0 +1,21 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef _COBALT_KERNEL_IPIPE_LOCK_H
+#define _COBALT_KERNEL_IPIPE_LOCK_H
+
+#include <pipeline/pipeline.h>
+
+typedef ipipe_spinlock_t pipeline_spinlock_t;
+
+#define PIPELINE_SPIN_LOCK_UNLOCKED(__name)  IPIPE_SPIN_LOCK_UNLOCKED
+
+#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
+/* Disable UP-over-SMP kernel optimization in debug mode. */
+#define __locking_active__  1
+#else
+#define __locking_active__  ipipe_smp_p
+#endif
+
+#endif /* !_COBALT_KERNEL_IPIPE_LOCK_H */
diff --git a/include/cobalt/kernel/ipipe/pipeline/pipeline.h b/include/cobalt/kernel/ipipe/pipeline/pipeline.h
new file mode 100644
index 000000000..317fa62d7
--- /dev/null
+++ b/include/cobalt/kernel/ipipe/pipeline/pipeline.h
@@ -0,0 +1,25 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef _COBALT_KERNEL_IPIPE_PIPELINE_H
+#define _COBALT_KERNEL_IPIPE_PIPELINE_H
+
+#include <linux/ipipe.h>
+
+typedef unsigned long spl_t;
+
+#define splhigh(x)  ((x) = ipipe_test_and_stall_head() & 1)
+#ifdef CONFIG_SMP
+#define splexit(x)  ipipe_restore_head(x & 1)
+#else /* !CONFIG_SMP */
+#define splexit(x)  ipipe_restore_head(x)
+#endif /* !CONFIG_SMP */
+#define splmax()    ipipe_stall_head()
+#define splnone()   ipipe_unstall_head()
+#define spltest()   ipipe_test_head()
+
+#define is_secondary_domain()	ipipe_root_p
+#define is_primary_domain()	(!ipipe_root_p)
+
+#endif /* !_COBALT_KERNEL_IPIPE_PIPELINE_H */
diff --git a/include/cobalt/kernel/lock.h b/include/cobalt/kernel/lock.h
index bae047524..185f6e785 100644
--- a/include/cobalt/kernel/lock.h
+++ b/include/cobalt/kernel/lock.h
@@ -20,49 +20,16 @@
 #ifndef _COBALT_KERNEL_LOCK_H
 #define _COBALT_KERNEL_LOCK_H
 
-#include <linux/ipipe.h>
+#include <pipeline/lock.h>
 #include <linux/percpu.h>
 #include <cobalt/kernel/assert.h>
+#include <pipeline/pipeline.h>
 
 /**
  * @addtogroup cobalt_core_lock
  *
  * @{
  */
-typedef unsigned long spl_t;
-
-/**
- * Hard disable interrupts on the local processor, saving previous state.
- *
- * @param[out] x An unsigned long integer context variable
- */
-#define splhigh(x)  ((x) = ipipe_test_and_stall_head() & 1)
-#ifdef CONFIG_SMP
-/**
- * Restore the saved hard interrupt state on the local processor.
- *
- * @param[in] x The context variable previously updated by splhigh()
- */
-#define splexit(x)  ipipe_restore_head(x & 1)
-#else /* !CONFIG_SMP */
-#define splexit(x)  ipipe_restore_head(x)
-#endif /* !CONFIG_SMP */
-/**
- * Hard disable interrupts on the local processor.
- */
-#define splmax()    ipipe_stall_head()
-/**
- * Hard enable interrupts on the local processor.
- */
-#define splnone()   ipipe_unstall_head()
-/**
- * Test hard interrupt state on the local processor.
- *
- * @return Zero if the local processor currently accepts interrupts,
- * non-zero otherwise.
- */
-#define spltest()   ipipe_test_head()
-
 #ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
 
 struct xnlock {
@@ -209,13 +176,6 @@ int ___xnlock_get(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS);
 void ___xnlock_put(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS);
 #endif /* out of line xnlock */
 
-#ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
-/* Disable UP-over-SMP kernel optimization in debug mode. */
-#define __locking_active__  1
-#else
-#define __locking_active__  ipipe_smp_p
-#endif
-
 static inline spl_t
 __xnlock_get_irqsave(struct xnlock *lock /*, */ XNLOCK_DBG_CONTEXT_ARGS)
 {
diff --git a/include/cobalt/kernel/rtdm/driver.h b/include/cobalt/kernel/rtdm/driver.h
index 894e6f67e..84309d0b1 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -32,6 +32,7 @@
 #include <linux/cdev.h>
 #include <linux/wait.h>
 #include <linux/notifier.h>
+#include <pipeline/lock.h>
 #include <xenomai/version.h>
 #include <cobalt/kernel/heap.h>
 #include <cobalt/kernel/sched.h>
@@ -541,13 +542,13 @@ rtdm_execute_atomically(void) { }
 /**
  * Static lock initialisation
  */
-#define RTDM_LOCK_UNLOCKED(__name)	IPIPE_SPIN_LOCK_UNLOCKED
+#define RTDM_LOCK_UNLOCKED(__name)	PIPELINE_SPIN_LOCK_UNLOCKED(__name)
 
 #define DEFINE_RTDM_LOCK(__name)		\
 	rtdm_lock_t __name = RTDM_LOCK_UNLOCKED(__name)
 
 /** Lock variable */
-typedef ipipe_spinlock_t rtdm_lock_t;
+typedef pipeline_spinlock_t rtdm_lock_t;
 
 /** Variable to save the context while holding a lock */
 typedef unsigned long rtdm_lockctx_t;
@@ -606,7 +607,7 @@ static inline rtdm_lockctx_t __rtdm_lock_get_irqsave(rtdm_lock_t *lock)
 {
 	rtdm_lockctx_t context;
 
-	context = ipipe_test_and_stall_head();
+	splhigh(context);
 	raw_spin_lock(lock);
 	xnsched_lock();
 
@@ -626,7 +627,7 @@ void rtdm_lock_put_irqrestore(rtdm_lock_t *lock, rtdm_lockctx_t context)
 {
 	raw_spin_unlock(lock);
 	xnsched_unlock();
-	ipipe_restore_head(context);
+	splexit(context);
 }
 
 /**
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH Dovetail 05/13] cobalt/kernel: pipeline: abstract execution stage predicates
  2021-01-02  9:33 [PATCH Dovetail 00/13] Keep on abstracting the pipeline interface Philippe Gerum
                   ` (3 preceding siblings ...)
  2021-01-02  9:33 ` [PATCH Dovetail 04/13] cobalt/lock: pipeline: abstract hard lock API Philippe Gerum
@ 2021-01-02  9:33 ` Philippe Gerum
  2021-01-02  9:33 ` [PATCH Dovetail 06/13] cobalt/sched, clock: pipeline: abstract IPI management Philippe Gerum
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 23+ messages in thread
From: Philippe Gerum @ 2021-01-02  9:33 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

ipipe_root_p, !ipipe_root_p belong to the I-pipe jargon. Dovetail uses
running_inband(), running_oob() for the same purpose instead.

Replace all occurrences of ipipe_root_p found in generic code with
is_primary_domain(), is_secondary_domain(), which in turn map to the
proper predicates depending on the underlying pipeline flavour.

No functional change is introduced.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 include/cobalt/kernel/assert.h      |  5 +++--
 include/cobalt/kernel/clock.h       |  2 +-
 include/cobalt/kernel/rtdm/driver.h |  2 +-
 kernel/cobalt/posix/corectl.c       |  3 +--
 kernel/cobalt/posix/syscall.c       |  6 +++---
 kernel/cobalt/registry.c            |  2 +-
 kernel/cobalt/rtdm/drvlib.c         |  2 +-
 kernel/cobalt/rtdm/fd.c             | 14 +++++++-------
 kernel/cobalt/sched.c               |  5 +++--
 kernel/cobalt/thread.c              |  2 +-
 10 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/include/cobalt/kernel/assert.h b/include/cobalt/kernel/assert.h
index 7c93b7e5c..7d9433abc 100644
--- a/include/cobalt/kernel/assert.h
+++ b/include/cobalt/kernel/assert.h
@@ -20,6 +20,7 @@
 #define _COBALT_KERNEL_ASSERT_H
 
 #include <linux/kconfig.h>
+#include <pipeline/pipeline.h>
 #include <cobalt/kernel/trace.h>
 #include <cobalt/kernel/ancillaries.h>
 
@@ -57,8 +58,8 @@
 	do { } while (0)
 #endif
 
-#define primary_mode_only()	XENO_BUG_ON(CONTEXT, ipipe_root_p)
-#define secondary_mode_only()	XENO_BUG_ON(CONTEXT, !ipipe_root_p)
+#define primary_mode_only()	XENO_BUG_ON(CONTEXT, is_secondary_domain())
+#define secondary_mode_only()	XENO_BUG_ON(CONTEXT, !is_secondary_domain())
 #define interrupt_only()	XENO_BUG_ON(CONTEXT, !xnsched_interrupt_p())
 #define realtime_cpu_only()	XENO_BUG_ON(CONTEXT, !xnsched_supported_cpu(raw_smp_processor_id()))
 #define thread_only()		XENO_BUG_ON(CONTEXT, xnsched_interrupt_p())
diff --git a/include/cobalt/kernel/clock.h b/include/cobalt/kernel/clock.h
index 94dfd2f99..d4a9d2686 100644
--- a/include/cobalt/kernel/clock.h
+++ b/include/cobalt/kernel/clock.h
@@ -19,7 +19,7 @@
 #ifndef _COBALT_KERNEL_CLOCK_H
 #define _COBALT_KERNEL_CLOCK_H
 
-#include <linux/ipipe.h>
+#include <pipeline/pipeline.h>
 #include <cobalt/kernel/list.h>
 #include <cobalt/kernel/vfile.h>
 #include <cobalt/uapi/kernel/types.h>
diff --git a/include/cobalt/kernel/rtdm/driver.h b/include/cobalt/kernel/rtdm/driver.h
index 84309d0b1..581e7a5c0 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -1316,7 +1316,7 @@ static inline int rtdm_rt_capable(struct rtdm_fd *fd)
 
 static inline int rtdm_in_rt_context(void)
 {
-	return (ipipe_current_domain != ipipe_root_domain);
+	return is_primary_domain();
 }
 
 #define RTDM_IOV_FASTMAX  16
diff --git a/kernel/cobalt/posix/corectl.c b/kernel/cobalt/posix/corectl.c
index f7129ca64..998fe572d 100644
--- a/kernel/cobalt/posix/corectl.c
+++ b/kernel/cobalt/posix/corectl.c
@@ -17,7 +17,6 @@
  */
 #include <linux/types.h>
 #include <linux/errno.h>
-#include <linux/ipipe.h>
 #include <linux/kconfig.h>
 #include <linux/atomic.h>
 #include <linux/printk.h>
@@ -89,7 +88,7 @@ static int do_conf_option(int option, void __user *u_buf, size_t u_bufsz)
 		val = realtime_core_state();
 		break;
 	default:
-		if (!ipipe_root_p)
+		if (is_primary_domain())
 			/* Switch to secondary mode first. */
 			return -ENOSYS;
 		vec.u_buf = u_buf;
diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
index 0a09322be..4d2331ddc 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -112,7 +112,7 @@ static COBALT_SYSCALL(migrate, current, (int domain))
 {
 	struct xnthread *thread = xnthread_current();
 
-	if (ipipe_root_p) {
+	if (is_secondary_domain()) {
 		if (domain == COBALT_PRIMARY) {
 			if (thread == NULL)
 				return -EPERM;
@@ -129,7 +129,7 @@ static COBALT_SYSCALL(migrate, current, (int domain))
 		return 0;
 	}
 
-	/* ipipe_current_domain != ipipe_root_domain */
+	/* We are running on the head stage, apply relax request. */
 	if (domain == COBALT_SECONDARY) {
 		xnthread_relax(0, 0);
 		return 1;
@@ -779,7 +779,7 @@ ret_handled:
 
 int ipipe_syscall_hook(struct ipipe_domain *ipd, struct pt_regs *regs)
 {
-	if (unlikely(ipipe_root_p))
+	if (unlikely(is_secondary_domain()))
 		return handle_root_syscall(ipd, regs);
 
 	return handle_head_syscall(ipd, regs);
diff --git a/kernel/cobalt/registry.c b/kernel/cobalt/registry.c
index 4b01abd63..dc1edd01a 100644
--- a/kernel/cobalt/registry.c
+++ b/kernel/cobalt/registry.c
@@ -852,7 +852,7 @@ int xnregistry_remove(xnhandle_t handle)
 			 */
 			if (object->pnode) {
 				xnlock_put_irqrestore(&nklock, s);
-				if (ipipe_root_p)
+				if (is_secondary_domain())
 					flush_work(&registry_proc_work);
 				return 0;
 			}
diff --git a/kernel/cobalt/rtdm/drvlib.c b/kernel/cobalt/rtdm/drvlib.c
index 5778ad559..40d2e401b 100644
--- a/kernel/cobalt/rtdm/drvlib.c
+++ b/kernel/cobalt/rtdm/drvlib.c
@@ -1630,7 +1630,7 @@ void rtdm_schedule_nrt_work(struct work_struct *lostage_work)
 		.lostage_work = lostage_work,
 	};
 
-	if (ipipe_root_p)
+	if (is_secondary_domain())
 		schedule_work(lostage_work);
 	else
 		ipipe_post_work_root(&ipipe_work, work);
diff --git a/kernel/cobalt/rtdm/fd.c b/kernel/cobalt/rtdm/fd.c
index eb80aa7bf..afb9ca5c5 100644
--- a/kernel/cobalt/rtdm/fd.c
+++ b/kernel/cobalt/rtdm/fd.c
@@ -306,7 +306,7 @@ static void __put_fd(struct rtdm_fd *fd, spl_t s)
 	if (!destroy)
 		return;
 
-	if (ipipe_root_p)
+	if (is_secondary_domain())
 		fd->ops->close(fd);
 	else {
 		struct lostage_trigger_close closework = {
@@ -470,7 +470,7 @@ static struct rtdm_fd *get_fd_fixup_mode(int ufd)
 	 * the syscall from secondary mode.
 	 */
 	thread = xnthread_current();
-	if (unlikely(ipipe_root_p)) {
+	if (unlikely(is_secondary_domain())) {
 		if (thread == NULL ||
 		    xnthread_test_localinfo(thread, XNDESCENT))
 			return fd;
@@ -508,7 +508,7 @@ int rtdm_fd_ioctl(int ufd, unsigned int request, ...)
 
 	trace_cobalt_fd_ioctl(current, fd, ufd, request);
 
-	if (ipipe_root_p)
+	if (is_secondary_domain())
 		err = fd->ops->ioctl_nrt(fd, request, arg);
 	else
 		err = fd->ops->ioctl_rt(fd, request, arg);
@@ -547,7 +547,7 @@ rtdm_fd_read(int ufd, void __user *buf, size_t size)
 
 	trace_cobalt_fd_read(current, fd, ufd, size);
 
-	if (ipipe_root_p)
+	if (is_secondary_domain())
 		ret = fd->ops->read_nrt(fd, buf, size);
 	else
 		ret = fd->ops->read_rt(fd, buf, size);
@@ -580,7 +580,7 @@ ssize_t rtdm_fd_write(int ufd, const void __user *buf, size_t size)
 
 	trace_cobalt_fd_write(current, fd, ufd, size);
 
-	if (ipipe_root_p)
+	if (is_secondary_domain())
 		ret = fd->ops->write_nrt(fd, buf, size);
 	else
 		ret = fd->ops->write_rt(fd, buf, size);
@@ -616,7 +616,7 @@ ssize_t rtdm_fd_recvmsg(int ufd, struct user_msghdr *msg, int flags)
 	if (fd->oflags & O_NONBLOCK)
 		flags |= MSG_DONTWAIT;
 
-	if (ipipe_root_p)
+	if (is_secondary_domain())
 		ret = fd->ops->recvmsg_nrt(fd, msg, flags);
 	else
 		ret = fd->ops->recvmsg_rt(fd, msg, flags);
@@ -761,7 +761,7 @@ ssize_t rtdm_fd_sendmsg(int ufd, const struct user_msghdr *msg, int flags)
 	if (fd->oflags & O_NONBLOCK)
 		flags |= MSG_DONTWAIT;
 
-	if (ipipe_root_p)
+	if (is_secondary_domain())
 		ret = fd->ops->sendmsg_nrt(fd, msg, flags);
 	else
 		ret = fd->ops->sendmsg_rt(fd, msg, flags);
diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index 7ff8a6c82..b16903bd8 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -912,7 +912,8 @@ int ___xnsched_run(struct xnsched *sched)
 	int switched, shadow;
 	spl_t s;
 
-	XENO_WARN_ON_ONCE(COBALT, !hard_irqs_disabled() && ipipe_root_p);
+	XENO_WARN_ON_ONCE(COBALT,
+			  !hard_irqs_disabled() && is_secondary_domain());
 
 	if (xnarch_escalate())
 		return 0;
@@ -983,7 +984,7 @@ int ___xnsched_run(struct xnsched *sched)
 	 * In such a case, we are running over the regular schedule()
 	 * tail code, so we have to skip our tail code.
 	 */
-	if (shadow && ipipe_root_p)
+	if (shadow && is_secondary_domain())
 		goto shadow_epilogue;
 
 	switched = 1;
diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
index b871e6069..88a4ff621 100644
--- a/kernel/cobalt/thread.c
+++ b/kernel/cobalt/thread.c
@@ -2107,7 +2107,7 @@ void xnthread_relax(int notify, int reason)
 	 * Basic sanity check after an expected transition to secondary
 	 * mode.
 	 */
-	XENO_WARN(COBALT, !ipipe_root_p,
+	XENO_WARN(COBALT, is_primary_domain(),
 		  "xnthread_relax() failed for thread %s[%d]",
 		  thread->name, xnthread_host_pid(thread));
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH Dovetail 06/13] cobalt/sched, clock: pipeline: abstract IPI management
  2021-01-02  9:33 [PATCH Dovetail 00/13] Keep on abstracting the pipeline interface Philippe Gerum
                   ` (4 preceding siblings ...)
  2021-01-02  9:33 ` [PATCH Dovetail 05/13] cobalt/kernel: pipeline: abstract execution stage predicates Philippe Gerum
@ 2021-01-02  9:33 ` Philippe Gerum
  2021-01-08  9:40   ` Jan Kiszka
  2021-01-02  9:33 ` [PATCH Dovetail 07/13] cobalt/clock: pipeline: make HOSTRT depend on IPIPE Philippe Gerum
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 23+ messages in thread
From: Philippe Gerum @ 2021-01-02  9:33 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

The I-pipe and Dovetail share the very same concept of out-of-band,
high-priority IPI, but using a different interface. Let's abstract the
calls manipulating those IPIs to make them pipeline-specific.

No functional change is introduced.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 .../cobalt/kernel/ipipe/pipeline/pipeline.h   | 50 ++++++++++++++++++-
 kernel/cobalt/clock.c                         |  2 +-
 .../include/asm-generic/xenomai/wrappers.h    |  4 --
 kernel/cobalt/sched.c                         | 11 ++--
 kernel/cobalt/timer.c                         |  7 +--
 5 files changed, 56 insertions(+), 18 deletions(-)

diff --git a/include/cobalt/kernel/ipipe/pipeline/pipeline.h b/include/cobalt/kernel/ipipe/pipeline/pipeline.h
index 317fa62d7..6f6958402 100644
--- a/include/cobalt/kernel/ipipe/pipeline/pipeline.h
+++ b/include/cobalt/kernel/ipipe/pipeline/pipeline.h
@@ -5,7 +5,13 @@
 #ifndef _COBALT_KERNEL_IPIPE_PIPELINE_H
 #define _COBALT_KERNEL_IPIPE_PIPELINE_H
 
-#include <linux/ipipe.h>
+#ifdef CONFIG_IPIPE_LEGACY
+#error "CONFIG_IPIPE_LEGACY must be switched off"
+#endif
+
+#include <pipeline/machine.h>
+
+#define PIPELINE_NR_IRQS  IPIPE_NR_IRQS
 
 typedef unsigned long spl_t;
 
@@ -22,4 +28,46 @@ typedef unsigned long spl_t;
 #define is_secondary_domain()	ipipe_root_p
 #define is_primary_domain()	(!ipipe_root_p)
 
+#ifdef CONFIG_SMP
+
+static inline int pipeline_request_resched_ipi(void (*handler)(void))
+{
+	return ipipe_request_irq(&cobalt_pipeline.domain,
+				IPIPE_RESCHEDULE_IPI,
+				(ipipe_irq_handler_t)handler,
+				NULL, NULL);
+}
+
+static inline void pipeline_free_resched_ipi(void)
+{
+	ipipe_free_irq(&cobalt_pipeline.domain,
+		IPIPE_RESCHEDULE_IPI);
+}
+
+static inline void pipeline_send_resched_ipi(const struct cpumask *dest)
+{
+	ipipe_send_ipi(IPIPE_RESCHEDULE_IPI, *dest);
+}
+
+static inline int pipeline_request_timer_ipi(void (*handler)(void))
+{
+	return ipipe_request_irq(&cobalt_pipeline.domain,
+				IPIPE_HRTIMER_IPI,
+				(ipipe_irq_handler_t)handler,
+				NULL, NULL);
+}
+
+static inline void pipeline_free_timer_ipi(void)
+{
+	return ipipe_free_irq(&cobalt_pipeline.domain,
+			IPIPE_HRTIMER_IPI);
+}
+
+static inline void pipeline_send_timer_ipi(const struct cpumask *dest)
+{
+	ipipe_send_ipi(IPIPE_HRTIMER_IPI, *dest);
+}
+
+#endif
+
 #endif /* !_COBALT_KERNEL_IPIPE_PIPELINE_H */
diff --git a/kernel/cobalt/clock.c b/kernel/cobalt/clock.c
index 2a5b61760..d73ade3f9 100644
--- a/kernel/cobalt/clock.c
+++ b/kernel/cobalt/clock.c
@@ -228,7 +228,7 @@ void xnclock_core_local_shot(struct xnsched *sched)
 #ifdef CONFIG_SMP
 void xnclock_core_remote_shot(struct xnsched *sched)
 {
-	ipipe_send_ipi(IPIPE_HRTIMER_IPI, *cpumask_of(xnsched_cpu(sched)));
+	pipeline_send_timer_ipi(cpumask_of(xnsched_cpu(sched)));
 }
 #endif
 
diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
index e266d5acf..e093676e1 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
@@ -20,10 +20,6 @@
 
 #include <linux/xenomai/wrappers.h>
 
-#ifdef CONFIG_IPIPE_LEGACY
-#error "CONFIG_IPIPE_LEGACY must be switched off"
-#endif
-
 #define COBALT_BACKPORT(__sym) __cobalt_backport_ ##__sym
 
 /*
diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index b16903bd8..a44109e78 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -235,10 +235,7 @@ void xnsched_init_all(void)
 	}
 
 #ifdef CONFIG_SMP
-	ipipe_request_irq(&xnsched_realtime_domain,
-			  IPIPE_RESCHEDULE_IPI,
-			  (ipipe_irq_handler_t)__xnsched_run_handler,
-			  NULL, NULL);
+	pipeline_request_resched_ipi(__xnsched_run_handler);
 #endif
 }
 
@@ -261,7 +258,7 @@ void xnsched_destroy_all(void)
 	spl_t s;
 
 #ifdef CONFIG_SMP
-	ipipe_free_irq(&xnsched_realtime_domain, IPIPE_RESCHEDULE_IPI);
+	pipeline_free_resched_ipi();
 #endif
 
 	xnlock_get_irqsave(&nklock, s);
@@ -860,7 +857,7 @@ static inline int test_resched(struct xnsched *sched)
 	/* Send resched IPI to remote CPU(s). */
 	if (unlikely(!cpumask_empty(&sched->resched))) {
 		smp_mb();
-		ipipe_send_ipi(IPIPE_RESCHEDULE_IPI, sched->resched);
+		pipeline_send_resched_ipi(&sched->resched);
 		cpumask_clear(&sched->resched);
 	}
 #endif
@@ -1280,7 +1277,7 @@ static int vfile_schedstat_next(struct xnvfile_snapshot_iterator *it,
 
 scan_irqs:
 #ifdef CONFIG_XENO_OPT_STATS_IRQS
-	if (priv->irq >= IPIPE_NR_IRQS)
+	if (priv->irq >= PIPELINE_NR_IRQS)
 		return 0;	/* All done. */
 
 	ret = xnintr_query_next(priv->irq, &priv->intr_it, p->name);
diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
index ccd3c3b70..b8c3f5a11 100644
--- a/kernel/cobalt/timer.c
+++ b/kernel/cobalt/timer.c
@@ -578,15 +578,12 @@ EXPORT_SYMBOL_GPL(__xntimer_set_affinity);
 
 int xntimer_setup_ipi(void)
 {
-	return ipipe_request_irq(&xnsched_realtime_domain,
-				 IPIPE_HRTIMER_IPI,
-				 (ipipe_irq_handler_t)xnintr_core_clock_handler,
-				 NULL, NULL);
+	return pipeline_request_timer_ipi(xnintr_core_clock_handler);
 }
 
 void xntimer_release_ipi(void)
 {
-	ipipe_free_irq(&xnsched_realtime_domain, IPIPE_HRTIMER_IPI);
+	pipeline_free_timer_ipi();
 }
 
 #endif /* CONFIG_SMP */
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH Dovetail 07/13] cobalt/clock: pipeline: make HOSTRT depend on IPIPE
  2021-01-02  9:33 [PATCH Dovetail 00/13] Keep on abstracting the pipeline interface Philippe Gerum
                   ` (5 preceding siblings ...)
  2021-01-02  9:33 ` [PATCH Dovetail 06/13] cobalt/sched, clock: pipeline: abstract IPI management Philippe Gerum
@ 2021-01-02  9:33 ` Philippe Gerum
  2021-01-07 13:52   ` Jan Kiszka
  2021-01-02  9:33 ` [PATCH Dovetail 08/13] cobalt/build: pipeline: select IPIPE layer only if present Philippe Gerum
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 23+ messages in thread
From: Philippe Gerum @ 2021-01-02  9:33 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

This interface is pointless with Dovetail whose applications directly
refer to the wallclock time exported through the common vDSO.

No functional change is introduced.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 include/cobalt/kernel/vdso.h  | 18 +++++++++++-------
 kernel/cobalt/Kconfig         |  4 ----
 kernel/cobalt/ipipe/kevents.c | 14 ++++++++------
 kernel/cobalt/posix/clock.c   |  4 ++--
 4 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/include/cobalt/kernel/vdso.h b/include/cobalt/kernel/vdso.h
index f7140adc7..7da88a730 100644
--- a/include/cobalt/kernel/vdso.h
+++ b/include/cobalt/kernel/vdso.h
@@ -25,21 +25,25 @@
 #include <asm/processor.h>
 #include <cobalt/uapi/kernel/vdso.h>
 
+extern struct xnvdso *nkvdso;
+
 /*
  * Define the available feature set here. We have a single feature
- * defined for now.
+ * defined for now, only in the I-pipe case.
  */
-#ifdef CONFIG_XENO_OPT_HOSTRT
-#define XNVDSO_FEATURES XNVDSO_FEAT_HOST_REALTIME
-#else
-#define XNVDSO_FEATURES 0
-#endif /* CONFIG_XENO_OPT_HOSTRT */
+#ifdef CONFIG_IPIPE_HAVE_HOSTRT
 
-extern struct xnvdso *nkvdso;
+#define XNVDSO_FEATURES XNVDSO_FEAT_HOST_REALTIME
 
 static inline struct xnvdso_hostrt_data *get_hostrt_data(void)
 {
 	return &nkvdso->hostrt_data;
 }
 
+#else
+
+#define XNVDSO_FEATURES 0
+
+#endif
+
 #endif /* _COBALT_KERNEL_VDSO_H */
diff --git a/kernel/cobalt/Kconfig b/kernel/cobalt/Kconfig
index 0d96913bd..ead4740c1 100644
--- a/kernel/cobalt/Kconfig
+++ b/kernel/cobalt/Kconfig
@@ -210,10 +210,6 @@ config XENO_OPT_TIMER_RBTREE
 
 endchoice
 
-config XENO_OPT_HOSTRT
-       depends on IPIPE_HAVE_HOSTRT
-       def_bool y
-
 config XENO_OPT_PIPE
 	bool
 
diff --git a/kernel/cobalt/ipipe/kevents.c b/kernel/cobalt/ipipe/kevents.c
index e0d4a1288..595faffd3 100644
--- a/kernel/cobalt/ipipe/kevents.c
+++ b/kernel/cobalt/ipipe/kevents.c
@@ -377,7 +377,7 @@ void ipipe_migration_hook(struct task_struct *p) /* hw IRQs off */
 	xnsched_run();
 }
 
-#ifdef CONFIG_XENO_OPT_HOSTRT
+#ifdef CONFIG_IPIPE_HAVE_HOSTRT
 
 static IPIPE_DEFINE_SPINLOCK(__hostrtlock);
 
@@ -417,7 +417,7 @@ static inline void init_hostrt(void)
 	nkvdso->hostrt_data.live = 0;
 }
 
-#else /* !CONFIG_XENO_OPT_HOSTRT */
+#else /* !CONFIG_IPIPE_HAVE_HOSTRT */
 
 struct ipipe_hostrt_data;
 
@@ -428,7 +428,7 @@ static inline int handle_hostrt_event(struct ipipe_hostrt_data *hostrt)
 
 static inline void init_hostrt(void) { }
 
-#endif /* !CONFIG_XENO_OPT_HOSTRT */
+#endif /* !CONFIG_IPIPE_HAVE_HOSTRT */
 
 static void __handle_taskexit_event(struct task_struct *p)
 {
@@ -756,12 +756,14 @@ int ipipe_kevent_hook(int kevent, void *data)
 	case IPIPE_KEVT_CLEANUP:
 		ret = handle_cleanup_event(data);
 		break;
-	case IPIPE_KEVT_HOSTRT:
-		ret = handle_hostrt_event(data);
-		break;
 	case IPIPE_KEVT_SETAFFINITY:
 		ret = handle_setaffinity_event(data);
 		break;
+#ifdef IPIPE_KEVT_HOSTRT
+	case IPIPE_KEVT_HOSTRT:
+		ret = handle_hostrt_event(data);
+		break;
+#endif
 #ifdef IPIPE_KEVT_CLOCKFREQ
 	case IPIPE_KEVT_CLOCKFREQ:
 		ret = handle_clockfreq_event(data);
diff --git a/kernel/cobalt/posix/clock.c b/kernel/cobalt/posix/clock.c
index 561358e74..40271f3ed 100644
--- a/kernel/cobalt/posix/clock.c
+++ b/kernel/cobalt/posix/clock.c
@@ -31,7 +31,7 @@ DECLARE_BITMAP(cobalt_clock_extids, COBALT_MAX_EXTCLOCKS);
 
 static int do_clock_host_realtime(struct timespec *tp)
 {
-#ifdef CONFIG_XENO_OPT_HOSTRT
+#ifdef CONFIG_IPIPE_HAVE_HOSTRT
 	struct xnvdso_hostrt_data *hostrt_data;
 	u64 now, base, mask, cycle_delta;
 	__u32 mult, shift;
@@ -78,7 +78,7 @@ static int do_clock_host_realtime(struct timespec *tp)
 	tp->tv_nsec = rem;
 
 	return 0;
-#else /* CONFIG_XENO_OPT_HOSTRT */
+#else
 	return -EINVAL;
 #endif
 }
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH Dovetail 08/13] cobalt/build: pipeline: select IPIPE layer only if present
  2021-01-02  9:33 [PATCH Dovetail 00/13] Keep on abstracting the pipeline interface Philippe Gerum
                   ` (6 preceding siblings ...)
  2021-01-02  9:33 ` [PATCH Dovetail 07/13] cobalt/clock: pipeline: make HOSTRT depend on IPIPE Philippe Gerum
@ 2021-01-02  9:33 ` Philippe Gerum
  2021-01-02  9:33 ` [PATCH Dovetail 09/13] cobalt/clock: pipeline: abstract clock, timer access services Philippe Gerum
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 23+ messages in thread
From: Philippe Gerum @ 2021-01-02  9:33 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

We may be able to build against a Dovetail-enabled kernel at some
point, so do not force-enable CONFIG_IPIPE, it might not be there.

At this chance, remove obsolete internal switches and conditions. All
I-pipe implementations depend on the GENERIC_CLOCKEVENTS framework,
and support for the legacy I-pipe V1 API is long gone.

No functional change is introduced.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 scripts/Kconfig.frag | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/scripts/Kconfig.frag b/scripts/Kconfig.frag
index f2e89a896..319683369 100644
--- a/scripts/Kconfig.frag
+++ b/scripts/Kconfig.frag
@@ -1,8 +1,8 @@
 menuconfig XENOMAI
 	depends on X86_TSC || !X86
 	bool "Xenomai/cobalt"
-	select IPIPE
-	select IPIPE_WANT_APIREV_2
+	select IPIPE if HAVE_IPIPE_SUPPORT
+	select IPIPE_WANT_APIREV_2 if IPIPE
 	default y
 	help
 	  Xenomai's Cobalt core is a real-time extension to the Linux
@@ -30,10 +30,6 @@ comment "or CPU idle features is enabled. Any of these options may"
 comment "cause troubles with Xenomai. You should disable them."
 endif
 
-if !GENERIC_CLOCKEVENTS
-comment "NOTE: Xenomai 3.x requires CONFIG_GENERIC_CLOCKEVENTS"
-endif
-
 config XENO_VERSION_MAJOR
        int
        default @VERSION_MAJOR@
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH Dovetail 09/13] cobalt/clock: pipeline: abstract clock, timer access services
  2021-01-02  9:33 [PATCH Dovetail 00/13] Keep on abstracting the pipeline interface Philippe Gerum
                   ` (7 preceding siblings ...)
  2021-01-02  9:33 ` [PATCH Dovetail 08/13] cobalt/build: pipeline: select IPIPE layer only if present Philippe Gerum
@ 2021-01-02  9:33 ` Philippe Gerum
  2021-01-02  9:33 ` [PATCH Dovetail 10/13] cobalt/wrappers: pipeline: abstract pipeline-related bits Philippe Gerum
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 23+ messages in thread
From: Philippe Gerum @ 2021-01-02  9:33 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

Dovetail exports integrated services for proxying the host tick, which
requires no specific interface for managing the hardware timer beyond
the common clockevents interface.

Likewise, the monotonic and realtime clocks can be read directly from
the out-of-band stage via the regular kernel calls available from NMI
context (ktime_get_mono_fast_ns(), ktime_get_real_fast()).

Move the related support to the I-pipe section, we won't need it for
Dovetail.

No functional change is introduced.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 include/cobalt/kernel/clock.h                |  6 ++--
 include/cobalt/kernel/ipipe/pipeline/clock.h | 32 ++++++++++++++++++++
 kernel/cobalt/clock.c                        |  5 ++-
 3 files changed, 37 insertions(+), 6 deletions(-)
 create mode 100644 include/cobalt/kernel/ipipe/pipeline/clock.h

diff --git a/include/cobalt/kernel/clock.h b/include/cobalt/kernel/clock.h
index d4a9d2686..2d17c0422 100644
--- a/include/cobalt/kernel/clock.h
+++ b/include/cobalt/kernel/clock.h
@@ -20,6 +20,7 @@
 #define _COBALT_KERNEL_CLOCK_H
 
 #include <pipeline/pipeline.h>
+#include <pipeline/clock.h>
 #include <cobalt/kernel/list.h>
 #include <cobalt/kernel/vfile.h>
 #include <cobalt/uapi/kernel/types.h>
@@ -31,6 +32,7 @@
 
 struct xnsched;
 struct xntimerdata;
+struct timex;
 
 struct xnclock_gravity {
 	unsigned long irq;
@@ -128,9 +130,7 @@ xnticks_t xnclock_core_read_monotonic(void);
 
 static inline xnticks_t xnclock_core_read_raw(void)
 {
-	unsigned long long t;
-	ipipe_read_tsc(t);
-	return t;
+	return pipeline_read_cycle_counter();
 }
 
 /* We use the Linux defaults */
diff --git a/include/cobalt/kernel/ipipe/pipeline/clock.h b/include/cobalt/kernel/ipipe/pipeline/clock.h
new file mode 100644
index 000000000..c607d9585
--- /dev/null
+++ b/include/cobalt/kernel/ipipe/pipeline/clock.h
@@ -0,0 +1,32 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef _COBALT_KERNEL_IPIPE_CLOCK_H
+#define _COBALT_KERNEL_IPIPE_CLOCK_H
+
+#include <linux/ipipe_tickdev.h>
+
+static inline u64 pipeline_read_cycle_counter(void)
+{
+	u64 t;
+	ipipe_read_tsc(t);
+	return t;
+}
+
+static inline void pipeline_set_timer_shot(unsigned long cycles)
+{
+	ipipe_timer_set(cycles);
+}
+
+static inline const char *pipeline_timer_name(void)
+{
+	return ipipe_timer_name();
+}
+
+static inline const char *pipeline_clock_name(void)
+{
+	return ipipe_clock_name();
+}
+
+#endif /* !_COBALT_KERNEL_IPIPE_CLOCK_H */
diff --git a/kernel/cobalt/clock.c b/kernel/cobalt/clock.c
index d73ade3f9..cae9dd7a1 100644
--- a/kernel/cobalt/clock.c
+++ b/kernel/cobalt/clock.c
@@ -18,7 +18,6 @@
  */
 #include <linux/percpu.h>
 #include <linux/errno.h>
-#include <linux/ipipe_tickdev.h>
 #include <cobalt/kernel/sched.h>
 #include <cobalt/kernel/timer.h>
 #include <cobalt/kernel/clock.h>
@@ -222,7 +221,7 @@ void xnclock_core_local_shot(struct xnsched *sched)
 
 	xntrace_tick((unsigned)delay);
 
-	ipipe_timer_set(delay);
+	pipeline_set_timer_shot(delay);
 }
 
 #ifdef CONFIG_SMP
@@ -507,7 +506,7 @@ void print_core_clock_status(struct xnclock *clock,
 #endif /* CONFIG_XENO_OPT_WATCHDOG */
 
 	xnvfile_printf(it, "%8s: timer=%s, clock=%s\n",
-		       "devices", ipipe_timer_name(), ipipe_clock_name());
+		       "devices", pipeline_timer_name(), pipeline_clock_name());
 	xnvfile_printf(it, "%8s: %s\n", "watchdog", wd_status);
 	xnvfile_printf(it, "%8s: %Lu\n", "setup",
 		       xnclock_ticks_to_ns(&nkclock, nktimerlat));
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH Dovetail 10/13] cobalt/wrappers: pipeline: abstract pipeline-related bits
  2021-01-02  9:33 [PATCH Dovetail 00/13] Keep on abstracting the pipeline interface Philippe Gerum
                   ` (8 preceding siblings ...)
  2021-01-02  9:33 ` [PATCH Dovetail 09/13] cobalt/clock: pipeline: abstract clock, timer access services Philippe Gerum
@ 2021-01-02  9:33 ` Philippe Gerum
  2021-01-07 13:56   ` Jan Kiszka
  2021-01-11 12:59   ` Jan Kiszka
  2021-01-02  9:33 ` [PATCH Dovetail 11/13] cobalt/timer: pipeline: abstract tick management Philippe Gerum
                   ` (2 subsequent siblings)
  12 siblings, 2 replies; 23+ messages in thread
From: Philippe Gerum @ 2021-01-02  9:33 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

No functional change is introduced.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 .../cobalt/kernel/ipipe/pipeline/wrappers.h   | 25 +++++++++++++++++++
 .../cobalt/include/linux/xenomai/wrappers.h   | 23 ++++-------------
 kernel/cobalt/posix/process.c                 |  2 +-
 3 files changed, 31 insertions(+), 19 deletions(-)
 create mode 100644 include/cobalt/kernel/ipipe/pipeline/wrappers.h

diff --git a/include/cobalt/kernel/ipipe/pipeline/wrappers.h b/include/cobalt/kernel/ipipe/pipeline/wrappers.h
new file mode 100644
index 000000000..ac940fb32
--- /dev/null
+++ b/include/cobalt/kernel/ipipe/pipeline/wrappers.h
@@ -0,0 +1,25 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0
+ */
+#ifndef _COBALT_KERNEL_IPIPE_WRAPPERS_H
+#define _COBALT_KERNEL_IPIPE_WRAPPERS_H
+
+#include <linux/ipipe.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0)
+#define cobalt_set_task_state(tsk, state_value)	\
+	set_task_state(tsk, state_value)
+#else
+/*
+ * The co-kernel can still set the current task state safely if it
+ * runs on the head stage.
+ */
+#define cobalt_set_task_state(tsk, state_value)	\
+		smp_store_mb((tsk)->state, (state_value))
+#endif
+
+#ifndef ipipe_root_nr_syscalls
+#define ipipe_root_nr_syscalls(ti)	NR_syscalls
+#endif
+
+#endif /* !_COBALT_KERNEL_IPIPE_WRAPPERS_H */
diff --git a/kernel/cobalt/include/linux/xenomai/wrappers.h b/kernel/cobalt/include/linux/xenomai/wrappers.h
index 847d68088..3e825e366 100644
--- a/kernel/cobalt/include/linux/xenomai/wrappers.h
+++ b/kernel/cobalt/include/linux/xenomai/wrappers.h
@@ -21,12 +21,13 @@
 
 #include <linux/version.h>
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
+typedef siginfo_t kernel_siginfo_t;
+#endif
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0)
 #include <linux/sched.h>
 #include <linux/sched/rt.h>
-
-#define cobalt_set_task_state(tsk, state_value)	\
-	set_task_state(tsk, state_value)
 #else
 #include <linux/sched.h>
 #include <linux/sched/signal.h>
@@ -35,22 +36,8 @@
 #include <linux/sched/debug.h>
 #include <linux/sched/task_stack.h>
 #include <uapi/linux/sched/types.h>
-/*
- * The co-kernel can still do this sanely for a thread which is
- * currently active on the head stage.
- */
-#define cobalt_set_task_state(tsk, state_value)	\
-		smp_store_mb((tsk)->state, (state_value))
 #endif
 
-#include <linux/ipipe.h>
-
-#ifndef ipipe_root_nr_syscalls
-#define ipipe_root_nr_syscalls(ti)	NR_syscalls
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
-typedef siginfo_t kernel_siginfo_t;
-#endif
+#include <pipeline/wrappers.h>
 
 #endif /* !_COBALT_LINUX_WRAPPERS_H */
diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
index accd989ca..fcae7df06 100644
--- a/kernel/cobalt/posix/process.c
+++ b/kernel/cobalt/posix/process.c
@@ -640,7 +640,7 @@ int cobalt_map_user(struct xnthread *thread, __u32 __user *u_winoff)
 	 * it.
 	 */
 	xnthread_run_handler(thread, map_thread);
-	pipeline_enable_kevents(current);
+	pipeline_enable_kevents();
 
 	attr.mode = 0;
 	attr.entry = NULL;
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH Dovetail 11/13] cobalt/timer: pipeline: abstract tick management
  2021-01-02  9:33 [PATCH Dovetail 00/13] Keep on abstracting the pipeline interface Philippe Gerum
                   ` (9 preceding siblings ...)
  2021-01-02  9:33 ` [PATCH Dovetail 10/13] cobalt/wrappers: pipeline: abstract pipeline-related bits Philippe Gerum
@ 2021-01-02  9:33 ` Philippe Gerum
  2021-01-02  9:33 ` [PATCH Dovetail 12/13] cobalt/debug: pipeline: abstract panic prep call Philippe Gerum
  2021-01-02  9:33 ` [PATCH Dovetail 13/13] cobalt/syscall: pipeline: abstract syscall entry points Philippe Gerum
  12 siblings, 0 replies; 23+ messages in thread
From: Philippe Gerum @ 2021-01-02  9:33 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

Dovetail comes with built-in support for proxy tick device management,
which enables a client core to grab control over the timer hardware
based on the common clockevents abstraction.

Once Dovetail's proxy tick device is declared to the common clockevent
device layer, all timing requests issued by the in-band kernel for
programming timer shots and controlling the device are transparently
redirected to the real-time core for handling.

The legacy ipipe_timer interface needs to move to the I-pipe section.

No functional change is introduced.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 include/cobalt/kernel/intr.h                |   1 -
 include/cobalt/kernel/ipipe/pipeline/tick.h |  12 +
 include/cobalt/kernel/stat.h                |   3 -
 include/cobalt/kernel/timer.h               |   4 -
 kernel/cobalt/init.c                        |   5 +-
 kernel/cobalt/ipipe/Makefile                |   2 +-
 kernel/cobalt/ipipe/intr.c                  |   2 +-
 kernel/cobalt/ipipe/tick.c                  | 278 ++++++++++++++++++++
 kernel/cobalt/posix/corectl.c               |   5 +-
 kernel/cobalt/timer.c                       | 265 -------------------
 10 files changed, 298 insertions(+), 279 deletions(-)
 create mode 100644 include/cobalt/kernel/ipipe/pipeline/tick.h
 create mode 100644 kernel/cobalt/ipipe/tick.c

diff --git a/include/cobalt/kernel/intr.h b/include/cobalt/kernel/intr.h
index 2e8253895..107b16bfc 100644
--- a/include/cobalt/kernel/intr.h
+++ b/include/cobalt/kernel/intr.h
@@ -133,7 +133,6 @@ void xnintr_affinity(struct xnintr *intr,
 		     cpumask_t cpumask);
 
 #ifdef CONFIG_XENO_OPT_STATS_IRQS
-extern struct xnintr nktimer;
 
 int xnintr_query_init(struct xnintr_iterator *iterator);
 
diff --git a/include/cobalt/kernel/ipipe/pipeline/tick.h b/include/cobalt/kernel/ipipe/pipeline/tick.h
new file mode 100644
index 000000000..409581a3c
--- /dev/null
+++ b/include/cobalt/kernel/ipipe/pipeline/tick.h
@@ -0,0 +1,12 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0
+ */
+
+#ifndef _COBALT_KERNEL_IPIPE_TICK_H
+#define _COBALT_KERNEL_IPIPE_TICK_H
+
+int pipeline_install_tick_proxy(void);
+
+void pipeline_uninstall_tick_proxy(void);
+
+#endif /* !_COBALT_KERNEL_IPIPE_TICK_H */
diff --git a/include/cobalt/kernel/stat.h b/include/cobalt/kernel/stat.h
index d252e1429..b08567b41 100644
--- a/include/cobalt/kernel/stat.h
+++ b/include/cobalt/kernel/stat.h
@@ -37,8 +37,6 @@ typedef struct xnstat_exectime {
 
 } xnstat_exectime_t;
 
-#define xnstat_percpu_data	raw_cpu_ptr(nktimer.stats)
-
 /* Return current date which can be passed to other xnstat services for
    immediate or lazy accounting. */
 #define xnstat_exectime_now() xnclock_core_read_raw()
@@ -114,7 +112,6 @@ static inline void xnstat_counter_set(xnstat_counter_t *c, unsigned long value)
 typedef struct xnstat_exectime {
 } xnstat_exectime_t;
 
-#define xnstat_percpu_data					NULL
 #define xnstat_exectime_now()					({ 0; })
 #define xnstat_exectime_update(sched, date)			do { } while (0)
 #define xnstat_exectime_set_current(sched, new_account)		({ (void)sched; NULL; })
diff --git a/include/cobalt/kernel/timer.h b/include/cobalt/kernel/timer.h
index 889504324..691be7a3b 100644
--- a/include/cobalt/kernel/timer.h
+++ b/include/cobalt/kernel/timer.h
@@ -557,10 +557,6 @@ static inline void xntimer_set_affinity(struct xntimer *timer,
 char *xntimer_format_time(xnticks_t ns,
 			  char *buf, size_t bufsz);
 
-int xntimer_grab_hardware(void);
-
-void xntimer_release_hardware(void);
-
 /** @} */
 
 #endif /* !_COBALT_KERNEL_TIMER_H */
diff --git a/kernel/cobalt/init.c b/kernel/cobalt/init.c
index 94b653350..f94943f2d 100644
--- a/kernel/cobalt/init.c
+++ b/kernel/cobalt/init.c
@@ -20,6 +20,7 @@
 #include <linux/module.h>
 #include <xenomai/version.h>
 #include <pipeline/machine.h>
+#include <pipeline/tick.h>
 #include <cobalt/kernel/sched.h>
 #include <cobalt/kernel/timer.h>
 #include <cobalt/kernel/heap.h>
@@ -112,7 +113,7 @@ static void sys_shutdown(void)
 {
 	void *membase;
 
-	xntimer_release_hardware();
+	pipeline_uninstall_tick_proxy();
 	xnsched_destroy_all();
 	xnregistry_cleanup();
 	membase = xnheap_get_membase(&cobalt_heap);
@@ -168,7 +169,7 @@ static __init int sys_init(void)
 	 * not enable the core timer.
 	 */
 	if (realtime_core_state() == COBALT_STATE_WARMUP) {
-		ret = xntimer_grab_hardware();
+		ret = pipeline_install_tick_proxy();
 		if (ret) {
 			sys_shutdown();
 			return ret;
diff --git a/kernel/cobalt/ipipe/Makefile b/kernel/cobalt/ipipe/Makefile
index 13186dc7f..0490f8800 100644
--- a/kernel/cobalt/ipipe/Makefile
+++ b/kernel/cobalt/ipipe/Makefile
@@ -2,4 +2,4 @@ ccflags-y += -Ikernel
 
 obj-y +=	pipeline.o
 
-pipeline-y :=	init.o intr.o kevents.o apc.o
+pipeline-y :=	init.o intr.o kevents.o apc.o tick.o
diff --git a/kernel/cobalt/ipipe/intr.c b/kernel/cobalt/ipipe/intr.c
index d45c22326..91b63d490 100644
--- a/kernel/cobalt/ipipe/intr.c
+++ b/kernel/cobalt/ipipe/intr.c
@@ -143,7 +143,7 @@ static inline xnstat_exectime_t *switch_core_irqstats(struct xnsched *sched)
 	struct xnirqstat *statp;
 	xnstat_exectime_t *prev;
 
-	statp = xnstat_percpu_data;
+	statp = raw_cpu_ptr(nktimer.stats);
 	prev = xnstat_exectime_switch(sched, &statp->account);
 	xnstat_counter_inc(&statp->hits);
 
diff --git a/kernel/cobalt/ipipe/tick.c b/kernel/cobalt/ipipe/tick.c
new file mode 100644
index 000000000..da1563a66
--- /dev/null
+++ b/kernel/cobalt/ipipe/tick.c
@@ -0,0 +1,278 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2001,2002,2003,2007,2012 Philippe Gerum <rpm@xenomai.org>.
+ * Copyright (C) 2004 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
+ */
+#include <linux/ipipe.h>
+#include <linux/ipipe_tickdev.h>
+#include <linux/sched.h>
+#include <cobalt/kernel/sched.h>
+#include <cobalt/kernel/timer.h>
+#include <cobalt/kernel/intr.h>
+#include <cobalt/kernel/clock.h>
+#include <cobalt/kernel/arith.h>
+
+extern struct xnintr nktimer;
+
+/**
+ * @internal
+ * @fn static int program_htick_shot(unsigned long delay, struct clock_event_device *cdev)
+ *
+ * @brief Program next host tick as a Xenomai timer event.
+ *
+ * Program the next shot for the host tick on the current CPU.
+ * Emulation is done using a nucleus timer attached to the master
+ * timebase.
+ *
+ * @param delay The time delta from the current date to the next tick,
+ * expressed as a count of nanoseconds.
+ *
+ * @param cdev An pointer to the clock device which notifies us.
+ *
+ * @coretags{unrestricted}
+ */
+static int program_htick_shot(unsigned long delay,
+			      struct clock_event_device *cdev)
+{
+	struct xnsched *sched;
+	int ret;
+	spl_t s;
+
+	xnlock_get_irqsave(&nklock, s);
+	sched = xnsched_current();
+	ret = xntimer_start(&sched->htimer, delay, XN_INFINITE, XN_RELATIVE);
+	xnlock_put_irqrestore(&nklock, s);
+
+	return ret ? -ETIME : 0;
+}
+
+/**
+ * @internal
+ * @fn void switch_htick_mode(enum clock_event_mode mode, struct clock_event_device *cdev)
+ *
+ * @brief Tick mode switch emulation callback.
+ *
+ * Changes the host tick mode for the tick device of the current CPU.
+ *
+ * @param mode The new mode to switch to. The possible values are:
+ *
+ * - CLOCK_EVT_MODE_ONESHOT, for a switch to oneshot mode.
+ *
+ * - CLOCK_EVT_MODE_PERIODIC, for a switch to periodic mode. The current
+ * implementation for the generic clockevent layer Linux exhibits
+ * should never downgrade from a oneshot to a periodic tick mode, so
+ * this mode should not be encountered. This said, the associated code
+ * is provided, basically for illustration purposes.
+ *
+ * - CLOCK_EVT_MODE_SHUTDOWN, indicates the removal of the current
+ * tick device. Normally, the nucleus only interposes on tick devices
+ * which should never be shut down, so this mode should not be
+ * encountered.
+ *
+ * @param cdev An opaque pointer to the clock device which notifies us.
+ *
+ * @coretags{unrestricted}
+ *
+ * @note GENERIC_CLOCKEVENTS is required from the host kernel.
+ */
+static void switch_htick_mode(enum clock_event_mode mode,
+			      struct clock_event_device *cdev)
+{
+	struct xnsched *sched;
+	xnticks_t tickval;
+	spl_t s;
+
+	if (mode == CLOCK_EVT_MODE_ONESHOT)
+		return;
+
+	xnlock_get_irqsave(&nklock, s);
+
+	sched = xnsched_current();
+
+	switch (mode) {
+	case CLOCK_EVT_MODE_PERIODIC:
+		tickval = 1000000000UL / HZ;
+		xntimer_start(&sched->htimer, tickval, tickval, XN_RELATIVE);
+		break;
+	case CLOCK_EVT_MODE_SHUTDOWN:
+		xntimer_stop(&sched->htimer);
+		break;
+	default:
+		XENO_BUG(COBALT);
+	}
+
+	xnlock_put_irqrestore(&nklock, s);
+}
+
+static int grab_timer_on_cpu(int cpu)
+{
+	int tickval, ret;
+
+	ret = ipipe_timer_start(xnintr_core_clock_handler,
+				switch_htick_mode, program_htick_shot, cpu);
+	switch (ret) {
+	case CLOCK_EVT_MODE_PERIODIC:
+		/*
+		 * Oneshot tick emulation callback won't be used, ask
+		 * the caller to start an internal timer for emulating
+		 * a periodic tick.
+		 */
+		tickval = 1000000000UL / HZ;
+		break;
+
+	case CLOCK_EVT_MODE_ONESHOT:
+		/* oneshot tick emulation */
+		tickval = 1;
+		break;
+
+	case CLOCK_EVT_MODE_UNUSED:
+		/* we don't need to emulate the tick at all. */
+		tickval = 0;
+		break;
+
+	case CLOCK_EVT_MODE_SHUTDOWN:
+		return -ENODEV;
+
+	default:
+		return ret;
+	}
+
+	return tickval;
+}
+
+/**
+ * @fn int pipeline_install_tick_proxy(void)
+ * @brief Grab the hardware timer on all real-time CPUs.
+ *
+ * pipeline_install_tick_proxy() grabs and tunes the hardware timer for all
+ * real-time CPUs.
+ *
+ * Host tick emulation is performed for sharing the clock chip between
+ * Linux and Xenomai.
+ *
+ * @return a positive value is returned on success, representing the
+ * duration of a Linux periodic tick expressed as a count of
+ * nanoseconds; zero should be returned when the Linux kernel does not
+ * undergo periodic timing on the given CPU (e.g. oneshot
+ * mode). Otherwise:
+ *
+ * - -EBUSY is returned if the hardware timer has already been
+ * grabbed.  xntimer_release_hardware() must be issued before
+ * pipeline_install_tick_proxy() is called again.
+ *
+ * - -ENODEV is returned if the hardware timer cannot be used.  This
+ * situation may occur after the kernel disabled the timer due to
+ * invalid calibration results; in such a case, such hardware is
+ * unusable for any timing duties.
+ *
+ * @coretags{secondary-only}
+ */
+
+int pipeline_install_tick_proxy(void)
+{
+	struct xnsched *sched;
+	int ret, cpu, _cpu;
+	spl_t s;
+
+#ifdef CONFIG_XENO_OPT_STATS_IRQS
+	/*
+	 * Only for statistical purpose, the timer interrupt is
+	 * attached by pipeline_install_tick_proxy().
+	 */
+	xnintr_init(&nktimer, "[timer]",
+		    per_cpu(ipipe_percpu.hrtimer_irq, 0), NULL, NULL, 0);
+#endif /* CONFIG_XENO_OPT_STATS_IRQS */
+
+	nkclock.wallclock_offset =
+		ktime_to_ns(ktime_get_real()) - xnclock_read_monotonic(&nkclock);
+
+	ret = xntimer_setup_ipi();
+	if (ret)
+		return ret;
+
+	for_each_realtime_cpu(cpu) {
+		ret = grab_timer_on_cpu(cpu);
+		if (ret < 0)
+			goto fail;
+
+		xnlock_get_irqsave(&nklock, s);
+
+		/*
+		 * If the current tick device for the target CPU is
+		 * periodic, we won't be called back for host tick
+		 * emulation. Therefore, we need to start a periodic
+		 * nucleus timer which will emulate the ticking for
+		 * that CPU, since we are going to hijack the hw clock
+		 * chip for managing our own system timer.
+		 *
+		 * CAUTION:
+		 *
+		 * - nucleus timers may be started only _after_ the hw
+		 * timer has been set up for the target CPU through a
+		 * call to pipeline_install_tick_proxy().
+		 *
+		 * - we don't compensate for the elapsed portion of
+		 * the current host tick, since we cannot get this
+		 * information easily for all CPUs except the current
+		 * one, and also because of the declining relevance of
+		 * the jiffies clocksource anyway.
+		 *
+		 * - we must not hold the nklock across calls to
+		 * pipeline_install_tick_proxy().
+		 */
+
+		sched = xnsched_struct(cpu);
+		/* Set up timer with host tick period if valid. */
+		if (ret > 1)
+			xntimer_start(&sched->htimer, ret, ret, XN_RELATIVE);
+		else if (ret == 1)
+			xntimer_start(&sched->htimer, 0, 0, XN_RELATIVE);
+
+		xnlock_put_irqrestore(&nklock, s);
+	}
+
+	return 0;
+fail:
+	for_each_realtime_cpu(_cpu) {
+		if (_cpu == cpu)
+			break;
+		xnlock_get_irqsave(&nklock, s);
+		sched = xnsched_struct(cpu);
+		xntimer_stop(&sched->htimer);
+		xnlock_put_irqrestore(&nklock, s);
+		ipipe_timer_stop(_cpu);
+	}
+
+	xntimer_release_ipi();
+
+	return ret;
+}
+
+/**
+ * @fn void pipeline_uninstall_tick_proxy(void)
+ * @brief Release hardware timers.
+ *
+ * Releases hardware timers previously grabbed by a call to
+ * pipeline_install_tick_proxy().
+ *
+ * @coretags{secondary-only}
+ */
+void pipeline_uninstall_tick_proxy(void)
+{
+	int cpu;
+
+	/*
+	 * We must not hold the nklock while stopping the hardware
+	 * timer, since this could cause deadlock situations to arise
+	 * on SMP systems.
+	 */
+	for_each_realtime_cpu(cpu)
+		ipipe_timer_stop(cpu);
+
+	xntimer_release_ipi();
+
+#ifdef CONFIG_XENO_OPT_STATS_IRQS
+	xnintr_destroy(&nktimer);
+#endif /* CONFIG_XENO_OPT_STATS_IRQS */
+}
diff --git a/kernel/cobalt/posix/corectl.c b/kernel/cobalt/posix/corectl.c
index 998fe572d..fd012d029 100644
--- a/kernel/cobalt/posix/corectl.c
+++ b/kernel/cobalt/posix/corectl.c
@@ -23,6 +23,7 @@
 #include <cobalt/kernel/init.h>
 #include <cobalt/kernel/thread.h>
 #include <xenomai/version.h>
+#include <pipeline/tick.h>
 #include <asm/xenomai/syscall.h>
 #include "corectl.h"
 
@@ -147,7 +148,7 @@ static int stop_services(const void __user *u_buf, size_t u_bufsz)
 		ret = xnthread_killall(final_grace_period, 0);
 		if (ret == -EAGAIN)
 			printk(XENO_WARNING "some RTDM tasks won't stop");
-		xntimer_release_hardware();
+		pipeline_uninstall_tick_proxy();
 		set_realtime_core_state(COBALT_STATE_STOPPED);
 		printk(XENO_INFO "services stopped\n");
 		break;
@@ -170,7 +171,7 @@ static int start_services(void)
 	case COBALT_STATE_RUNNING:
 		break;
 	case COBALT_STATE_STOPPED:
-		xntimer_grab_hardware();
+		pipeline_install_tick_proxy();
 		cobalt_call_state_chain(COBALT_STATE_WARMUP);
 		set_realtime_core_state(COBALT_STATE_RUNNING);
 		printk(XENO_INFO "services started\n");
diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
index b8c3f5a11..7f5033c87 100644
--- a/kernel/cobalt/timer.c
+++ b/kernel/cobalt/timer.c
@@ -17,8 +17,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  * 02111-1307, USA.
  */
-#include <linux/ipipe.h>
-#include <linux/ipipe_tickdev.h>
 #include <linux/sched.h>
 #include <cobalt/kernel/sched.h>
 #include <cobalt/kernel/thread.h>
@@ -681,269 +679,6 @@ char *xntimer_format_time(xnticks_t ns, char *buf, size_t bufsz)
 }
 EXPORT_SYMBOL_GPL(xntimer_format_time);
 
-/**
- * @internal
- * @fn static int program_htick_shot(unsigned long delay, struct clock_event_device *cdev)
- *
- * @brief Program next host tick as a Xenomai timer event.
- *
- * Program the next shot for the host tick on the current CPU.
- * Emulation is done using a nucleus timer attached to the master
- * timebase.
- *
- * @param delay The time delta from the current date to the next tick,
- * expressed as a count of nanoseconds.
- *
- * @param cdev An pointer to the clock device which notifies us.
- *
- * @coretags{unrestricted}
- */
-static int program_htick_shot(unsigned long delay,
-			      struct clock_event_device *cdev)
-{
-	struct xnsched *sched;
-	int ret;
-	spl_t s;
-
-	xnlock_get_irqsave(&nklock, s);
-	sched = xnsched_current();
-	ret = xntimer_start(&sched->htimer, delay, XN_INFINITE, XN_RELATIVE);
-	xnlock_put_irqrestore(&nklock, s);
-
-	return ret ? -ETIME : 0;
-}
-
-/**
- * @internal
- * @fn void switch_htick_mode(enum clock_event_mode mode, struct clock_event_device *cdev)
- *
- * @brief Tick mode switch emulation callback.
- *
- * Changes the host tick mode for the tick device of the current CPU.
- *
- * @param mode The new mode to switch to. The possible values are:
- *
- * - CLOCK_EVT_MODE_ONESHOT, for a switch to oneshot mode.
- *
- * - CLOCK_EVT_MODE_PERIODIC, for a switch to periodic mode. The current
- * implementation for the generic clockevent layer Linux exhibits
- * should never downgrade from a oneshot to a periodic tick mode, so
- * this mode should not be encountered. This said, the associated code
- * is provided, basically for illustration purposes.
- *
- * - CLOCK_EVT_MODE_SHUTDOWN, indicates the removal of the current
- * tick device. Normally, the nucleus only interposes on tick devices
- * which should never be shut down, so this mode should not be
- * encountered.
- *
- * @param cdev An opaque pointer to the clock device which notifies us.
- *
- * @coretags{unrestricted}
- *
- * @note GENERIC_CLOCKEVENTS is required from the host kernel.
- */
-static void switch_htick_mode(enum clock_event_mode mode,
-			      struct clock_event_device *cdev)
-{
-	struct xnsched *sched;
-	xnticks_t tickval;
-	spl_t s;
-
-	if (mode == CLOCK_EVT_MODE_ONESHOT)
-		return;
-
-	xnlock_get_irqsave(&nklock, s);
-
-	sched = xnsched_current();
-
-	switch (mode) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		tickval = 1000000000UL / HZ;
-		xntimer_start(&sched->htimer, tickval, tickval, XN_RELATIVE);
-		break;
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		xntimer_stop(&sched->htimer);
-		break;
-	default:
-		XENO_BUG(COBALT);
-	}
-
-	xnlock_put_irqrestore(&nklock, s);
-}
-
-/**
- * @fn int xntimer_grab_hardware(void)
- * @brief Grab the hardware timer on all real-time CPUs.
- *
- * xntimer_grab_hardware() grabs and tunes the hardware timer for all
- * real-time CPUs.
- *
- * Host tick emulation is performed for sharing the clock chip between
- * Linux and Xenomai.
- *
- * @return a positive value is returned on success, representing the
- * duration of a Linux periodic tick expressed as a count of
- * nanoseconds; zero should be returned when the Linux kernel does not
- * undergo periodic timing on the given CPU (e.g. oneshot
- * mode). Otherwise:
- *
- * - -EBUSY is returned if the hardware timer has already been
- * grabbed.  xntimer_release_hardware() must be issued before
- * xntimer_grab_hardware() is called again.
- *
- * - -ENODEV is returned if the hardware timer cannot be used.  This
- * situation may occur after the kernel disabled the timer due to
- * invalid calibration results; in such a case, such hardware is
- * unusable for any timing duties.
- *
- * @coretags{secondary-only}
- */
-static int grab_hardware_timer(int cpu)
-{
-	int tickval, ret;
-
-	ret = ipipe_timer_start(xnintr_core_clock_handler,
-				switch_htick_mode, program_htick_shot, cpu);
-	switch (ret) {
-	case CLOCK_EVT_MODE_PERIODIC:
-		/*
-		 * Oneshot tick emulation callback won't be used, ask
-		 * the caller to start an internal timer for emulating
-		 * a periodic tick.
-		 */
-		tickval = 1000000000UL / HZ;
-		break;
-
-	case CLOCK_EVT_MODE_ONESHOT:
-		/* oneshot tick emulation */
-		tickval = 1;
-		break;
-
-	case CLOCK_EVT_MODE_UNUSED:
-		/* we don't need to emulate the tick at all. */
-		tickval = 0;
-		break;
-
-	case CLOCK_EVT_MODE_SHUTDOWN:
-		return -ENODEV;
-
-	default:
-		return ret;
-	}
-
-	return tickval;
-}
-
-int xntimer_grab_hardware(void)
-{
-	struct xnsched *sched;
-	int ret, cpu, _cpu;
-	spl_t s;
-
-#ifdef CONFIG_XENO_OPT_STATS_IRQS
-	/*
-	 * Only for statistical purpose, the timer interrupt is
-	 * attached by xntimer_grab_hardware().
-	 */
-	xnintr_init(&nktimer, "[timer]",
-		    per_cpu(ipipe_percpu.hrtimer_irq, 0), NULL, NULL, 0);
-#endif /* CONFIG_XENO_OPT_STATS_IRQS */
-
-	nkclock.wallclock_offset =
-		ktime_to_ns(ktime_get_real()) - xnclock_read_monotonic(&nkclock);
-
-	ret = xntimer_setup_ipi();
-	if (ret)
-		return ret;
-
-	for_each_realtime_cpu(cpu) {
-		ret = grab_hardware_timer(cpu);
-		if (ret < 0)
-			goto fail;
-
-		xnlock_get_irqsave(&nklock, s);
-
-		/*
-		 * If the current tick device for the target CPU is
-		 * periodic, we won't be called back for host tick
-		 * emulation. Therefore, we need to start a periodic
-		 * nucleus timer which will emulate the ticking for
-		 * that CPU, since we are going to hijack the hw clock
-		 * chip for managing our own system timer.
-		 *
-		 * CAUTION:
-		 *
-		 * - nucleus timers may be started only _after_ the hw
-		 * timer has been set up for the target CPU through a
-		 * call to xntimer_grab_hardware().
-		 *
-		 * - we don't compensate for the elapsed portion of
-		 * the current host tick, since we cannot get this
-		 * information easily for all CPUs except the current
-		 * one, and also because of the declining relevance of
-		 * the jiffies clocksource anyway.
-		 *
-		 * - we must not hold the nklock across calls to
-		 * xntimer_grab_hardware().
-		 */
-
-		sched = xnsched_struct(cpu);
-		/* Set up timer with host tick period if valid. */
-		if (ret > 1)
-			xntimer_start(&sched->htimer, ret, ret, XN_RELATIVE);
-		else if (ret == 1)
-			xntimer_start(&sched->htimer, 0, 0, XN_RELATIVE);
-
-		xnlock_put_irqrestore(&nklock, s);
-	}
-
-	return 0;
-fail:
-	for_each_realtime_cpu(_cpu) {
-		if (_cpu == cpu)
-			break;
-		xnlock_get_irqsave(&nklock, s);
-		sched = xnsched_struct(cpu);
-		xntimer_stop(&sched->htimer);
-		xnlock_put_irqrestore(&nklock, s);
-		ipipe_timer_stop(_cpu);
-	}
-
-	xntimer_release_ipi();
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(xntimer_grab_hardware);
-
-/**
- * @fn void xntimer_release_hardware(void)
- * @brief Release hardware timers.
- *
- * Releases hardware timers previously grabbed by a call to
- * xntimer_grab_hardware().
- *
- * @coretags{secondary-only}
- */
-void xntimer_release_hardware(void)
-{
-	int cpu;
-
-	/*
-	 * We must not hold the nklock while stopping the hardware
-	 * timer, since this could cause deadlock situations to arise
-	 * on SMP systems.
-	 */
-	for_each_realtime_cpu(cpu)
-		ipipe_timer_stop(cpu);
-
-	xntimer_release_ipi();
-
-#ifdef CONFIG_XENO_OPT_STATS_IRQS
-	xnintr_destroy(&nktimer);
-#endif /* CONFIG_XENO_OPT_STATS_IRQS */
-}
-EXPORT_SYMBOL_GPL(xntimer_release_hardware);
-
 #if defined(CONFIG_XENO_OPT_TIMER_RBTREE)
 static inline bool xntimerh_is_lt(xntimerh_t *left, xntimerh_t *right)
 {
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH Dovetail 12/13] cobalt/debug: pipeline: abstract panic prep call
  2021-01-02  9:33 [PATCH Dovetail 00/13] Keep on abstracting the pipeline interface Philippe Gerum
                   ` (10 preceding siblings ...)
  2021-01-02  9:33 ` [PATCH Dovetail 11/13] cobalt/timer: pipeline: abstract tick management Philippe Gerum
@ 2021-01-02  9:33 ` Philippe Gerum
  2021-01-02  9:33 ` [PATCH Dovetail 13/13] cobalt/syscall: pipeline: abstract syscall entry points Philippe Gerum
  12 siblings, 0 replies; 23+ messages in thread
From: Philippe Gerum @ 2021-01-02  9:33 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

No functional change is introduced.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 include/cobalt/kernel/ipipe/pipeline/pipeline.h | 5 +++++
 kernel/cobalt/debug.c                           | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/cobalt/kernel/ipipe/pipeline/pipeline.h b/include/cobalt/kernel/ipipe/pipeline/pipeline.h
index 6f6958402..0ffc9b00b 100644
--- a/include/cobalt/kernel/ipipe/pipeline/pipeline.h
+++ b/include/cobalt/kernel/ipipe/pipeline/pipeline.h
@@ -70,4 +70,9 @@ static inline void pipeline_send_timer_ipi(const struct cpumask *dest)
 
 #endif
 
+static inline void pipeline_prepare_panic(void)
+{
+	ipipe_prepare_panic();
+}
+
 #endif /* !_COBALT_KERNEL_IPIPE_PIPELINE_H */
diff --git a/kernel/cobalt/debug.c b/kernel/cobalt/debug.c
index 12fc57289..1e9edda99 100644
--- a/kernel/cobalt/debug.c
+++ b/kernel/cobalt/debug.c
@@ -587,7 +587,7 @@ int xnlock_dbg_release(struct xnlock *lock,
 	}
 
 	if (unlikely(lock->owner != cpu)) {
-		ipipe_prepare_panic();
+		pipeline_prepare_panic();
 		printk(XENO_ERR "lock %p already unlocked on CPU #%d\n"
 				"          last owner = %s:%u (%s(), CPU #%d)\n",
 		       lock, cpu, lock->file, lock->line, lock->function,
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH Dovetail 13/13] cobalt/syscall: pipeline: abstract syscall entry points
  2021-01-02  9:33 [PATCH Dovetail 00/13] Keep on abstracting the pipeline interface Philippe Gerum
                   ` (11 preceding siblings ...)
  2021-01-02  9:33 ` [PATCH Dovetail 12/13] cobalt/debug: pipeline: abstract panic prep call Philippe Gerum
@ 2021-01-02  9:33 ` Philippe Gerum
  2021-01-07 14:08   ` Jan Kiszka
  12 siblings, 1 reply; 23+ messages in thread
From: Philippe Gerum @ 2021-01-02  9:33 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

The I-pipe and Dovetail differ only marginally with respect to syscall
handling. Abstract only the few details we need to cope with both
interfaces.

No functional change is introduced.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 .../cobalt/kernel/ipipe/pipeline/kevents.h    |  3 ++
 .../cobalt/kernel/ipipe/pipeline/pipeline.h   |  2 ++
 include/cobalt/kernel/sched.h                 |  2 --
 kernel/cobalt/ipipe/Makefile                  |  2 +-
 kernel/cobalt/ipipe/syscall.c                 | 29 +++++++++++++++++++
 kernel/cobalt/posix/process.h                 |  3 --
 kernel/cobalt/posix/syscall.c                 | 28 ++++--------------
 kernel/cobalt/posix/syscall.h                 |  7 +++++
 8 files changed, 47 insertions(+), 29 deletions(-)
 create mode 100644 kernel/cobalt/ipipe/syscall.c

diff --git a/include/cobalt/kernel/ipipe/pipeline/kevents.h b/include/cobalt/kernel/ipipe/pipeline/kevents.h
index 30425a96b..2f186a57e 100644
--- a/include/cobalt/kernel/ipipe/pipeline/kevents.h
+++ b/include/cobalt/kernel/ipipe/pipeline/kevents.h
@@ -7,6 +7,9 @@
 #ifndef _COBALT_KERNEL_IPIPE_KEVENTS_H
 #define _COBALT_KERNEL_IPIPE_KEVENTS_H
 
+#define KEVENT_PROPAGATE   0
+#define KEVENT_STOP        1
+
 struct cobalt_process;
 struct cobalt_thread;
 
diff --git a/include/cobalt/kernel/ipipe/pipeline/pipeline.h b/include/cobalt/kernel/ipipe/pipeline/pipeline.h
index 0ffc9b00b..fb0465fb2 100644
--- a/include/cobalt/kernel/ipipe/pipeline/pipeline.h
+++ b/include/cobalt/kernel/ipipe/pipeline/pipeline.h
@@ -11,6 +11,8 @@
 
 #include <pipeline/machine.h>
 
+#define xnsched_realtime_domain  cobalt_pipeline.domain
+
 #define PIPELINE_NR_IRQS  IPIPE_NR_IRQS
 
 typedef unsigned long spl_t;
diff --git a/include/cobalt/kernel/sched.h b/include/cobalt/kernel/sched.h
index 5d278838f..ad815b595 100644
--- a/include/cobalt/kernel/sched.h
+++ b/include/cobalt/kernel/sched.h
@@ -233,8 +233,6 @@ static inline void xnsched_set_self_resched(struct xnsched *sched)
 	sched->status |= XNRESCHED;
 }
 
-#define xnsched_realtime_domain  cobalt_pipeline.domain
-
 /* Set resched flag for the given scheduler. */
 #ifdef CONFIG_SMP
 
diff --git a/kernel/cobalt/ipipe/Makefile b/kernel/cobalt/ipipe/Makefile
index 0490f8800..3c0ad2098 100644
--- a/kernel/cobalt/ipipe/Makefile
+++ b/kernel/cobalt/ipipe/Makefile
@@ -2,4 +2,4 @@ ccflags-y += -Ikernel
 
 obj-y +=	pipeline.o
 
-pipeline-y :=	init.o intr.o kevents.o apc.o tick.o
+pipeline-y :=	init.o intr.o kevents.o apc.o tick.o syscall.o
diff --git a/kernel/cobalt/ipipe/syscall.c b/kernel/cobalt/ipipe/syscall.c
new file mode 100644
index 000000000..18aa996bd
--- /dev/null
+++ b/kernel/cobalt/ipipe/syscall.c
@@ -0,0 +1,29 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2005 Philippe Gerum <rpm@xenomai.org>
+ * Copyright (C) 2005 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
+ */
+
+#include <pipeline/pipeline.h>
+#include <pipeline/kevents.h>
+#include <cobalt/kernel/assert.h>
+#include <xenomai/posix/syscall.h>
+
+int ipipe_syscall_hook(struct ipipe_domain *ipd, struct pt_regs *regs)
+{
+	if (unlikely(is_secondary_domain()))
+		return handle_root_syscall(regs);
+
+	return handle_head_syscall(ipd != &xnsched_realtime_domain, regs);
+}
+
+int ipipe_fastcall_hook(struct pt_regs *regs)
+{
+	int ret;
+
+	ret = handle_head_syscall(false, regs);
+	XENO_BUG_ON(COBALT, ret == KEVENT_PROPAGATE);
+
+	return ret;
+}
diff --git a/kernel/cobalt/posix/process.h b/kernel/cobalt/posix/process.h
index a2f4ec591..22142ee03 100644
--- a/kernel/cobalt/posix/process.h
+++ b/kernel/cobalt/posix/process.h
@@ -23,9 +23,6 @@
 #include <pipeline/thread.h>
 #include <cobalt/kernel/ppd.h>
 
-#define KEVENT_PROPAGATE   0
-#define KEVENT_STOP        1
-
 #define NR_PERSONALITIES  4
 #if BITS_PER_LONG < NR_PERSONALITIES
 #error "NR_PERSONALITIES overflows internal bitmap"
diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
index 4d2331ddc..3b3eaee8e 100644
--- a/kernel/cobalt/posix/syscall.c
+++ b/kernel/cobalt/posix/syscall.c
@@ -18,7 +18,6 @@
  */
 #include <linux/types.h>
 #include <linux/err.h>
-#include <linux/ipipe.h>
 #include <linux/sched.h>
 #include <linux/kconfig.h>
 #include <linux/unistd.h>
@@ -26,6 +25,7 @@
 #include <cobalt/kernel/tree.h>
 #include <cobalt/kernel/vdso.h>
 #include <cobalt/kernel/init.h>
+#include <pipeline/kevents.h>
 #include <asm/syscall.h>
 #include "internal.h"
 #include "thread.h"
@@ -475,7 +475,7 @@ static inline int allowed_syscall(struct cobalt_process *process,
 	return cap_raised(current_cap(), CAP_SYS_NICE);
 }
 
-static int handle_head_syscall(struct ipipe_domain *ipd, struct pt_regs *regs)
+int handle_head_syscall(bool caller_is_relaxed, struct pt_regs *regs)
 {
 	struct cobalt_process *process;
 	int switched, sigs, sysflags;
@@ -553,7 +553,7 @@ restart:
 		/*
 		 * The syscall must run from the Linux domain.
 		 */
-		if (ipd == &xnsched_realtime_domain) {
+		if (!caller_is_relaxed) {
 			/*
 			 * Request originates from the Xenomai domain:
 			 * relax the caller then invoke the syscall
@@ -578,7 +578,7 @@ restart:
 		 * hand it over to our secondary-mode dispatcher.
 		 * Otherwise, invoke the syscall handler immediately.
 		 */
-		if (ipd != &xnsched_realtime_domain)
+		if (caller_is_relaxed)
 			return KEVENT_PROPAGATE;
 	}
 
@@ -667,7 +667,7 @@ bad_syscall:
 	return KEVENT_STOP;
 }
 
-static int handle_root_syscall(struct ipipe_domain *ipd, struct pt_regs *regs)
+int handle_root_syscall(struct pt_regs *regs)
 {
 	int sysflags, switched, sigs;
 	struct xnthread *thread;
@@ -777,24 +777,6 @@ ret_handled:
 	return KEVENT_STOP;
 }
 
-int ipipe_syscall_hook(struct ipipe_domain *ipd, struct pt_regs *regs)
-{
-	if (unlikely(is_secondary_domain()))
-		return handle_root_syscall(ipd, regs);
-
-	return handle_head_syscall(ipd, regs);
-}
-
-int ipipe_fastcall_hook(struct pt_regs *regs)
-{
-	int ret;
-
-	ret = handle_head_syscall(&xnsched_realtime_domain, regs);
-	XENO_BUG_ON(COBALT, ret == KEVENT_PROPAGATE);
-
-	return ret;
-}
-
 long cobalt_restart_syscall_placeholder(struct restart_block *param)
 {
 	return -EINVAL;
diff --git a/kernel/cobalt/posix/syscall.h b/kernel/cobalt/posix/syscall.h
index 690cb2263..3a4c98d7a 100644
--- a/kernel/cobalt/posix/syscall.h
+++ b/kernel/cobalt/posix/syscall.h
@@ -20,6 +20,8 @@
 
 #include <cobalt/uapi/syscall.h>
 
+struct pt_regs;
+
 /* Regular (native) syscall handler implementation. */
 #define COBALT_SYSCALL(__name, __mode, __args)	\
 	long CoBaLt_ ## __name __args
@@ -30,4 +32,9 @@
 
 #include <asm/xenomai/syscall32.h>
 
+int handle_head_syscall(bool caller_is_relaxed,
+			struct pt_regs *regs);
+
+int handle_root_syscall(struct pt_regs *regs);
+
 #endif /* !_COBALT_POSIX_SYSCALL_H */
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH Dovetail 07/13] cobalt/clock: pipeline: make HOSTRT depend on IPIPE
  2021-01-02  9:33 ` [PATCH Dovetail 07/13] cobalt/clock: pipeline: make HOSTRT depend on IPIPE Philippe Gerum
@ 2021-01-07 13:52   ` Jan Kiszka
  2021-01-09 10:45     ` Philippe Gerum
  0 siblings, 1 reply; 23+ messages in thread
From: Jan Kiszka @ 2021-01-07 13:52 UTC (permalink / raw)
  To: Philippe Gerum, xenomai

On 02.01.21 10:33, Philippe Gerum wrote:
> From: Philippe Gerum <rpm@xenomai.org>
> 
> This interface is pointless with Dovetail whose applications directly
> refer to the wallclock time exported through the common vDSO.
> 
> No functional change is introduced.
> 
> Signed-off-by: Philippe Gerum <rpm@xenomai.org>
> ---
>  include/cobalt/kernel/vdso.h  | 18 +++++++++++-------
>  kernel/cobalt/Kconfig         |  4 ----
>  kernel/cobalt/ipipe/kevents.c | 14 ++++++++------
>  kernel/cobalt/posix/clock.c   |  4 ++--
>  4 files changed, 21 insertions(+), 19 deletions(-)
> 
> diff --git a/include/cobalt/kernel/vdso.h b/include/cobalt/kernel/vdso.h
> index f7140adc7..7da88a730 100644
> --- a/include/cobalt/kernel/vdso.h
> +++ b/include/cobalt/kernel/vdso.h
> @@ -25,21 +25,25 @@
>  #include <asm/processor.h>
>  #include <cobalt/uapi/kernel/vdso.h>
>  
> +extern struct xnvdso *nkvdso;
> +
>  /*
>   * Define the available feature set here. We have a single feature
> - * defined for now.
> + * defined for now, only in the I-pipe case.
>   */
> -#ifdef CONFIG_XENO_OPT_HOSTRT
> -#define XNVDSO_FEATURES XNVDSO_FEAT_HOST_REALTIME
> -#else
> -#define XNVDSO_FEATURES 0
> -#endif /* CONFIG_XENO_OPT_HOSTRT */
> +#ifdef CONFIG_IPIPE_HAVE_HOSTRT
>  
> -extern struct xnvdso *nkvdso;
> +#define XNVDSO_FEATURES XNVDSO_FEAT_HOST_REALTIME
>  
>  static inline struct xnvdso_hostrt_data *get_hostrt_data(void)
>  {
>  	return &nkvdso->hostrt_data;
>  }
>  
> +#else
> +
> +#define XNVDSO_FEATURES 0
> +
> +#endif
> +
>  #endif /* _COBALT_KERNEL_VDSO_H */
> diff --git a/kernel/cobalt/Kconfig b/kernel/cobalt/Kconfig
> index 0d96913bd..ead4740c1 100644
> --- a/kernel/cobalt/Kconfig
> +++ b/kernel/cobalt/Kconfig
> @@ -210,10 +210,6 @@ config XENO_OPT_TIMER_RBTREE
>  
>  endchoice
>  
> -config XENO_OPT_HOSTRT
> -       depends on IPIPE_HAVE_HOSTRT
> -       def_bool y
> -
>  config XENO_OPT_PIPE
>  	bool
>  
> diff --git a/kernel/cobalt/ipipe/kevents.c b/kernel/cobalt/ipipe/kevents.c
> index e0d4a1288..595faffd3 100644
> --- a/kernel/cobalt/ipipe/kevents.c
> +++ b/kernel/cobalt/ipipe/kevents.c
> @@ -377,7 +377,7 @@ void ipipe_migration_hook(struct task_struct *p) /* hw IRQs off */
>  	xnsched_run();
>  }
>  
> -#ifdef CONFIG_XENO_OPT_HOSTRT
> +#ifdef CONFIG_IPIPE_HAVE_HOSTRT
>  
>  static IPIPE_DEFINE_SPINLOCK(__hostrtlock);
>  
> @@ -417,7 +417,7 @@ static inline void init_hostrt(void)
>  	nkvdso->hostrt_data.live = 0;
>  }
>  
> -#else /* !CONFIG_XENO_OPT_HOSTRT */
> +#else /* !CONFIG_IPIPE_HAVE_HOSTRT */
>  
>  struct ipipe_hostrt_data;
>  
> @@ -428,7 +428,7 @@ static inline int handle_hostrt_event(struct ipipe_hostrt_data *hostrt)
>  
>  static inline void init_hostrt(void) { }
>  
> -#endif /* !CONFIG_XENO_OPT_HOSTRT */
> +#endif /* !CONFIG_IPIPE_HAVE_HOSTRT */
>  
>  static void __handle_taskexit_event(struct task_struct *p)
>  {
> @@ -756,12 +756,14 @@ int ipipe_kevent_hook(int kevent, void *data)
>  	case IPIPE_KEVT_CLEANUP:
>  		ret = handle_cleanup_event(data);
>  		break;
> -	case IPIPE_KEVT_HOSTRT:
> -		ret = handle_hostrt_event(data);
> -		break;
>  	case IPIPE_KEVT_SETAFFINITY:
>  		ret = handle_setaffinity_event(data);
>  		break;
> +#ifdef IPIPE_KEVT_HOSTRT

Wouldn't CONFIG_IPIPE_HAVE_HOSTRT be cleaner here?

Jan

> +	case IPIPE_KEVT_HOSTRT:
> +		ret = handle_hostrt_event(data);
> +		break;
> +#endif
>  #ifdef IPIPE_KEVT_CLOCKFREQ
>  	case IPIPE_KEVT_CLOCKFREQ:
>  		ret = handle_clockfreq_event(data);
> diff --git a/kernel/cobalt/posix/clock.c b/kernel/cobalt/posix/clock.c
> index 561358e74..40271f3ed 100644
> --- a/kernel/cobalt/posix/clock.c
> +++ b/kernel/cobalt/posix/clock.c
> @@ -31,7 +31,7 @@ DECLARE_BITMAP(cobalt_clock_extids, COBALT_MAX_EXTCLOCKS);
>  
>  static int do_clock_host_realtime(struct timespec *tp)
>  {
> -#ifdef CONFIG_XENO_OPT_HOSTRT
> +#ifdef CONFIG_IPIPE_HAVE_HOSTRT
>  	struct xnvdso_hostrt_data *hostrt_data;
>  	u64 now, base, mask, cycle_delta;
>  	__u32 mult, shift;
> @@ -78,7 +78,7 @@ static int do_clock_host_realtime(struct timespec *tp)
>  	tp->tv_nsec = rem;
>  
>  	return 0;
> -#else /* CONFIG_XENO_OPT_HOSTRT */
> +#else
>  	return -EINVAL;
>  #endif
>  }
> 

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH Dovetail 10/13] cobalt/wrappers: pipeline: abstract pipeline-related bits
  2021-01-02  9:33 ` [PATCH Dovetail 10/13] cobalt/wrappers: pipeline: abstract pipeline-related bits Philippe Gerum
@ 2021-01-07 13:56   ` Jan Kiszka
  2021-01-11 12:59   ` Jan Kiszka
  1 sibling, 0 replies; 23+ messages in thread
From: Jan Kiszka @ 2021-01-07 13:56 UTC (permalink / raw)
  To: Philippe Gerum, xenomai

On 02.01.21 10:33, Philippe Gerum wrote:
> From: Philippe Gerum <rpm@xenomai.org>
> 
> No functional change is introduced.
> 
> Signed-off-by: Philippe Gerum <rpm@xenomai.org>
> ---
>  .../cobalt/kernel/ipipe/pipeline/wrappers.h   | 25 +++++++++++++++++++
>  .../cobalt/include/linux/xenomai/wrappers.h   | 23 ++++-------------
>  kernel/cobalt/posix/process.c                 |  2 +-
>  3 files changed, 31 insertions(+), 19 deletions(-)
>  create mode 100644 include/cobalt/kernel/ipipe/pipeline/wrappers.h
> 
> diff --git a/include/cobalt/kernel/ipipe/pipeline/wrappers.h b/include/cobalt/kernel/ipipe/pipeline/wrappers.h
> new file mode 100644
> index 000000000..ac940fb32
> --- /dev/null
> +++ b/include/cobalt/kernel/ipipe/pipeline/wrappers.h
> @@ -0,0 +1,25 @@
> +/*
> + * SPDX-License-Identifier: GPL-2.0
> + */
> +#ifndef _COBALT_KERNEL_IPIPE_WRAPPERS_H
> +#define _COBALT_KERNEL_IPIPE_WRAPPERS_H
> +
> +#include <linux/ipipe.h>
> +
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0)
> +#define cobalt_set_task_state(tsk, state_value)	\
> +	set_task_state(tsk, state_value)
> +#else
> +/*
> + * The co-kernel can still set the current task state safely if it
> + * runs on the head stage.
> + */
> +#define cobalt_set_task_state(tsk, state_value)	\
> +		smp_store_mb((tsk)->state, (state_value))
> +#endif
> +
> +#ifndef ipipe_root_nr_syscalls
> +#define ipipe_root_nr_syscalls(ti)	NR_syscalls
> +#endif
> +
> +#endif /* !_COBALT_KERNEL_IPIPE_WRAPPERS_H */
> diff --git a/kernel/cobalt/include/linux/xenomai/wrappers.h b/kernel/cobalt/include/linux/xenomai/wrappers.h
> index 847d68088..3e825e366 100644
> --- a/kernel/cobalt/include/linux/xenomai/wrappers.h
> +++ b/kernel/cobalt/include/linux/xenomai/wrappers.h
> @@ -21,12 +21,13 @@
>  
>  #include <linux/version.h>
>  
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
> +typedef siginfo_t kernel_siginfo_t;
> +#endif
> +
>  #if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0)
>  #include <linux/sched.h>
>  #include <linux/sched/rt.h>
> -
> -#define cobalt_set_task_state(tsk, state_value)	\
> -	set_task_state(tsk, state_value)
>  #else
>  #include <linux/sched.h>
>  #include <linux/sched/signal.h>
> @@ -35,22 +36,8 @@
>  #include <linux/sched/debug.h>
>  #include <linux/sched/task_stack.h>
>  #include <uapi/linux/sched/types.h>
> -/*
> - * The co-kernel can still do this sanely for a thread which is
> - * currently active on the head stage.
> - */
> -#define cobalt_set_task_state(tsk, state_value)	\
> -		smp_store_mb((tsk)->state, (state_value))

Look over-indented - I can fix that up on merge.

Jan

>  #endif
>  
> -#include <linux/ipipe.h>
> -
> -#ifndef ipipe_root_nr_syscalls
> -#define ipipe_root_nr_syscalls(ti)	NR_syscalls
> -#endif
> -
> -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
> -typedef siginfo_t kernel_siginfo_t;
> -#endif
> +#include <pipeline/wrappers.h>
>  
>  #endif /* !_COBALT_LINUX_WRAPPERS_H */
> diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
> index accd989ca..fcae7df06 100644
> --- a/kernel/cobalt/posix/process.c
> +++ b/kernel/cobalt/posix/process.c
> @@ -640,7 +640,7 @@ int cobalt_map_user(struct xnthread *thread, __u32 __user *u_winoff)
>  	 * it.
>  	 */
>  	xnthread_run_handler(thread, map_thread);
> -	pipeline_enable_kevents(current);
> +	pipeline_enable_kevents();
>  
>  	attr.mode = 0;
>  	attr.entry = NULL;
> 


-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH Dovetail 13/13] cobalt/syscall: pipeline: abstract syscall entry points
  2021-01-02  9:33 ` [PATCH Dovetail 13/13] cobalt/syscall: pipeline: abstract syscall entry points Philippe Gerum
@ 2021-01-07 14:08   ` Jan Kiszka
  2021-01-09 10:58     ` Philippe Gerum
  0 siblings, 1 reply; 23+ messages in thread
From: Jan Kiszka @ 2021-01-07 14:08 UTC (permalink / raw)
  To: Philippe Gerum, xenomai

On 02.01.21 10:33, Philippe Gerum wrote:
> From: Philippe Gerum <rpm@xenomai.org>
> 
> The I-pipe and Dovetail differ only marginally with respect to syscall
> handling. Abstract only the few details we need to cope with both
> interfaces.
> 
> No functional change is introduced.
> 
> Signed-off-by: Philippe Gerum <rpm@xenomai.org>
> ---
>  .../cobalt/kernel/ipipe/pipeline/kevents.h    |  3 ++
>  .../cobalt/kernel/ipipe/pipeline/pipeline.h   |  2 ++
>  include/cobalt/kernel/sched.h                 |  2 --
>  kernel/cobalt/ipipe/Makefile                  |  2 +-
>  kernel/cobalt/ipipe/syscall.c                 | 29 +++++++++++++++++++
>  kernel/cobalt/posix/process.h                 |  3 --
>  kernel/cobalt/posix/syscall.c                 | 28 ++++--------------
>  kernel/cobalt/posix/syscall.h                 |  7 +++++
>  8 files changed, 47 insertions(+), 29 deletions(-)
>  create mode 100644 kernel/cobalt/ipipe/syscall.c
> 
> diff --git a/include/cobalt/kernel/ipipe/pipeline/kevents.h b/include/cobalt/kernel/ipipe/pipeline/kevents.h
> index 30425a96b..2f186a57e 100644
> --- a/include/cobalt/kernel/ipipe/pipeline/kevents.h
> +++ b/include/cobalt/kernel/ipipe/pipeline/kevents.h
> @@ -7,6 +7,9 @@
>  #ifndef _COBALT_KERNEL_IPIPE_KEVENTS_H
>  #define _COBALT_KERNEL_IPIPE_KEVENTS_H
>  
> +#define KEVENT_PROPAGATE   0
> +#define KEVENT_STOP        1
> +
>  struct cobalt_process;
>  struct cobalt_thread;
>  
> diff --git a/include/cobalt/kernel/ipipe/pipeline/pipeline.h b/include/cobalt/kernel/ipipe/pipeline/pipeline.h
> index 0ffc9b00b..fb0465fb2 100644
> --- a/include/cobalt/kernel/ipipe/pipeline/pipeline.h
> +++ b/include/cobalt/kernel/ipipe/pipeline/pipeline.h
> @@ -11,6 +11,8 @@
>  
>  #include <pipeline/machine.h>
>  
> +#define xnsched_realtime_domain  cobalt_pipeline.domain
> +

Why not use the chance and call also this xnsched_primary_domain?

Jan

>  #define PIPELINE_NR_IRQS  IPIPE_NR_IRQS
>  
>  typedef unsigned long spl_t;
> diff --git a/include/cobalt/kernel/sched.h b/include/cobalt/kernel/sched.h
> index 5d278838f..ad815b595 100644
> --- a/include/cobalt/kernel/sched.h
> +++ b/include/cobalt/kernel/sched.h
> @@ -233,8 +233,6 @@ static inline void xnsched_set_self_resched(struct xnsched *sched)
>  	sched->status |= XNRESCHED;
>  }
>  
> -#define xnsched_realtime_domain  cobalt_pipeline.domain
> -
>  /* Set resched flag for the given scheduler. */
>  #ifdef CONFIG_SMP
>  
> diff --git a/kernel/cobalt/ipipe/Makefile b/kernel/cobalt/ipipe/Makefile
> index 0490f8800..3c0ad2098 100644
> --- a/kernel/cobalt/ipipe/Makefile
> +++ b/kernel/cobalt/ipipe/Makefile
> @@ -2,4 +2,4 @@ ccflags-y += -Ikernel
>  
>  obj-y +=	pipeline.o
>  
> -pipeline-y :=	init.o intr.o kevents.o apc.o tick.o
> +pipeline-y :=	init.o intr.o kevents.o apc.o tick.o syscall.o
> diff --git a/kernel/cobalt/ipipe/syscall.c b/kernel/cobalt/ipipe/syscall.c
> new file mode 100644
> index 000000000..18aa996bd
> --- /dev/null
> +++ b/kernel/cobalt/ipipe/syscall.c
> @@ -0,0 +1,29 @@
> +/*
> + * SPDX-License-Identifier: GPL-2.0
> + *
> + * Copyright (C) 2005 Philippe Gerum <rpm@xenomai.org>
> + * Copyright (C) 2005 Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
> + */
> +
> +#include <pipeline/pipeline.h>
> +#include <pipeline/kevents.h>
> +#include <cobalt/kernel/assert.h>
> +#include <xenomai/posix/syscall.h>
> +
> +int ipipe_syscall_hook(struct ipipe_domain *ipd, struct pt_regs *regs)
> +{
> +	if (unlikely(is_secondary_domain()))
> +		return handle_root_syscall(regs);
> +
> +	return handle_head_syscall(ipd != &xnsched_realtime_domain, regs);
> +}
> +
> +int ipipe_fastcall_hook(struct pt_regs *regs)
> +{
> +	int ret;
> +
> +	ret = handle_head_syscall(false, regs);
> +	XENO_BUG_ON(COBALT, ret == KEVENT_PROPAGATE);
> +
> +	return ret;
> +}
> diff --git a/kernel/cobalt/posix/process.h b/kernel/cobalt/posix/process.h
> index a2f4ec591..22142ee03 100644
> --- a/kernel/cobalt/posix/process.h
> +++ b/kernel/cobalt/posix/process.h
> @@ -23,9 +23,6 @@
>  #include <pipeline/thread.h>
>  #include <cobalt/kernel/ppd.h>
>  
> -#define KEVENT_PROPAGATE   0
> -#define KEVENT_STOP        1
> -
>  #define NR_PERSONALITIES  4
>  #if BITS_PER_LONG < NR_PERSONALITIES
>  #error "NR_PERSONALITIES overflows internal bitmap"
> diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c
> index 4d2331ddc..3b3eaee8e 100644
> --- a/kernel/cobalt/posix/syscall.c
> +++ b/kernel/cobalt/posix/syscall.c
> @@ -18,7 +18,6 @@
>   */
>  #include <linux/types.h>
>  #include <linux/err.h>
> -#include <linux/ipipe.h>
>  #include <linux/sched.h>
>  #include <linux/kconfig.h>
>  #include <linux/unistd.h>
> @@ -26,6 +25,7 @@
>  #include <cobalt/kernel/tree.h>
>  #include <cobalt/kernel/vdso.h>
>  #include <cobalt/kernel/init.h>
> +#include <pipeline/kevents.h>
>  #include <asm/syscall.h>
>  #include "internal.h"
>  #include "thread.h"
> @@ -475,7 +475,7 @@ static inline int allowed_syscall(struct cobalt_process *process,
>  	return cap_raised(current_cap(), CAP_SYS_NICE);
>  }
>  
> -static int handle_head_syscall(struct ipipe_domain *ipd, struct pt_regs *regs)
> +int handle_head_syscall(bool caller_is_relaxed, struct pt_regs *regs)
>  {
>  	struct cobalt_process *process;
>  	int switched, sigs, sysflags;
> @@ -553,7 +553,7 @@ restart:
>  		/*
>  		 * The syscall must run from the Linux domain.
>  		 */
> -		if (ipd == &xnsched_realtime_domain) {
> +		if (!caller_is_relaxed) {
>  			/*
>  			 * Request originates from the Xenomai domain:
>  			 * relax the caller then invoke the syscall
> @@ -578,7 +578,7 @@ restart:
>  		 * hand it over to our secondary-mode dispatcher.
>  		 * Otherwise, invoke the syscall handler immediately.
>  		 */
> -		if (ipd != &xnsched_realtime_domain)
> +		if (caller_is_relaxed)
>  			return KEVENT_PROPAGATE;
>  	}
>  
> @@ -667,7 +667,7 @@ bad_syscall:
>  	return KEVENT_STOP;
>  }
>  
> -static int handle_root_syscall(struct ipipe_domain *ipd, struct pt_regs *regs)
> +int handle_root_syscall(struct pt_regs *regs)
>  {
>  	int sysflags, switched, sigs;
>  	struct xnthread *thread;
> @@ -777,24 +777,6 @@ ret_handled:
>  	return KEVENT_STOP;
>  }
>  
> -int ipipe_syscall_hook(struct ipipe_domain *ipd, struct pt_regs *regs)
> -{
> -	if (unlikely(is_secondary_domain()))
> -		return handle_root_syscall(ipd, regs);
> -
> -	return handle_head_syscall(ipd, regs);
> -}
> -
> -int ipipe_fastcall_hook(struct pt_regs *regs)
> -{
> -	int ret;
> -
> -	ret = handle_head_syscall(&xnsched_realtime_domain, regs);
> -	XENO_BUG_ON(COBALT, ret == KEVENT_PROPAGATE);
> -
> -	return ret;
> -}
> -
>  long cobalt_restart_syscall_placeholder(struct restart_block *param)
>  {
>  	return -EINVAL;
> diff --git a/kernel/cobalt/posix/syscall.h b/kernel/cobalt/posix/syscall.h
> index 690cb2263..3a4c98d7a 100644
> --- a/kernel/cobalt/posix/syscall.h
> +++ b/kernel/cobalt/posix/syscall.h
> @@ -20,6 +20,8 @@
>  
>  #include <cobalt/uapi/syscall.h>
>  
> +struct pt_regs;
> +
>  /* Regular (native) syscall handler implementation. */
>  #define COBALT_SYSCALL(__name, __mode, __args)	\
>  	long CoBaLt_ ## __name __args
> @@ -30,4 +32,9 @@
>  
>  #include <asm/xenomai/syscall32.h>
>  
> +int handle_head_syscall(bool caller_is_relaxed,
> +			struct pt_regs *regs);
> +
> +int handle_root_syscall(struct pt_regs *regs);
> +
>  #endif /* !_COBALT_POSIX_SYSCALL_H */
> 


-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH Dovetail 01/13] cobalt/thread: pipeline: abstract threadinfo accessor
  2021-01-02  9:33 ` [PATCH Dovetail 01/13] cobalt/thread: pipeline: abstract threadinfo accessor Philippe Gerum
@ 2021-01-08  9:02   ` Jan Kiszka
  0 siblings, 0 replies; 23+ messages in thread
From: Jan Kiszka @ 2021-01-08  9:02 UTC (permalink / raw)
  To: Philippe Gerum, xenomai

On 02.01.21 10:33, Philippe Gerum wrote:
> From: Philippe Gerum <rpm@xenomai.org>
> 
> The I-pipe and Dovetail access the per-thread information block
> differently. Abstract this kernel interface.
> 
> No functional change is introduced.
> 
> Signed-off-by: Philippe Gerum <rpm@xenomai.org>
> ---
>  include/cobalt/kernel/ipipe/pipeline/thread.h | 26 +++++++++++++++++++
>  include/cobalt/kernel/thread.h                |  5 ++--
>  kernel/cobalt/ipipe/kevents.c                 |  6 ++---
>  kernel/cobalt/posix/process.c                 |  4 +--
>  kernel/cobalt/posix/process.h                 |  5 ++--
>  kernel/cobalt/thread.c                        |  4 +--
>  6 files changed, 39 insertions(+), 11 deletions(-)
>  create mode 100644 include/cobalt/kernel/ipipe/pipeline/thread.h
> 
> diff --git a/include/cobalt/kernel/ipipe/pipeline/thread.h b/include/cobalt/kernel/ipipe/pipeline/thread.h
> new file mode 100644
> index 000000000..a62e622c4
> --- /dev/null
> +++ b/include/cobalt/kernel/ipipe/pipeline/thread.h
> @@ -0,0 +1,26 @@
> +/*
> + * SPDX-License-Identifier: GPL-2.0
> + *
> + * Copyright (C) 2019 Philippe Gerum  <rpm@xenomai.org>
> + */
> +
> +#ifndef _COBALT_KERNEL_IPIPE_THREAD_H
> +#define _COBALT_KERNEL_IPIPE_THREAD_H
> +
> +#include <linux/ipipe.h>

We also need linux/sched.h for older kernels (<= 4.14). Fixing up on merge.

Jan

> +
> +struct xnthread;
> +
> +#define cobalt_threadinfo ipipe_threadinfo
> +
> +static inline struct cobalt_threadinfo *pipeline_current(void)
> +{
> +	return ipipe_current_threadinfo();
> +}
> +
> +static inline struct xnthread *pipeline_thread_from_task(struct task_struct *p)
> +{
> +	return ipipe_task_threadinfo(p)->thread;
> +}
> +
> +#endif /* !_COBALT_KERNEL_IPIPE_THREAD_H */
> diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h
> index 21a8603b4..2d57b8398 100644
> --- a/include/cobalt/kernel/thread.h
> +++ b/include/cobalt/kernel/thread.h
> @@ -22,6 +22,7 @@
>  #include <linux/wait.h>
>  #include <linux/sched.h>
>  #include <linux/sched/rt.h>
> +#include <pipeline/thread.h>
>  #include <cobalt/kernel/list.h>
>  #include <cobalt/kernel/stat.h>
>  #include <cobalt/kernel/timer.h>
> @@ -372,7 +373,7 @@ void __xnthread_discard(struct xnthread *thread);
>   */
>  static inline struct xnthread *xnthread_current(void)
>  {
> -	return ipipe_current_threadinfo()->thread;
> +	return pipeline_current()->thread;
>  }
>  
>  /**
> @@ -388,7 +389,7 @@ static inline struct xnthread *xnthread_current(void)
>   */
>  static inline struct xnthread *xnthread_from_task(struct task_struct *p)
>  {
> -	return ipipe_task_threadinfo(p)->thread;
> +	return pipeline_thread_from_task(p);
>  }
>  
>  /**
> diff --git a/kernel/cobalt/ipipe/kevents.c b/kernel/cobalt/ipipe/kevents.c
> index ba584677c..e0d4a1288 100644
> --- a/kernel/cobalt/ipipe/kevents.c
> +++ b/kernel/cobalt/ipipe/kevents.c
> @@ -831,16 +831,16 @@ static inline int get_mayday_prot(void)
>  
>  void pipeline_attach_current(struct xnthread *thread)
>  {
> -	struct ipipe_threadinfo *p;
> +	struct cobalt_threadinfo *p;
>  
> -	p = ipipe_current_threadinfo();
> +	p = pipeline_current();
>  	p->thread = thread;
>  	p->process = cobalt_search_process(current->mm);
>  }
>  
>  static void detach_current(void)
>  {
> -	struct ipipe_threadinfo *p = ipipe_current_threadinfo();
> +	struct cobalt_threadinfo *p = pipeline_current();
>  	p->thread = NULL;
>  	p->process = NULL;
>  }
> diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
> index 9bc6082d0..accd989ca 100644
> --- a/kernel/cobalt/posix/process.c
> +++ b/kernel/cobalt/posix/process.c
> @@ -463,7 +463,7 @@ EXPORT_SYMBOL_GPL(cobalt_unregister_personality);
>  struct xnthread_personality *
>  cobalt_push_personality(int xid)
>  {
> -	struct ipipe_threadinfo *p = ipipe_current_threadinfo();
> +	struct cobalt_threadinfo *p = pipeline_current();
>  	struct xnthread_personality *prev, *next;
>  	struct xnthread *thread = p->thread;
>  
> @@ -504,7 +504,7 @@ EXPORT_SYMBOL_GPL(cobalt_push_personality);
>   */
>  void cobalt_pop_personality(struct xnthread_personality *prev)
>  {
> -	struct ipipe_threadinfo *p = ipipe_current_threadinfo();
> +	struct cobalt_threadinfo *p = pipeline_current();
>  	struct xnthread *thread = p->thread;
>  
>  	secondary_mode_only();
> diff --git a/kernel/cobalt/posix/process.h b/kernel/cobalt/posix/process.h
> index 3a38ae639..a2f4ec591 100644
> --- a/kernel/cobalt/posix/process.h
> +++ b/kernel/cobalt/posix/process.h
> @@ -20,6 +20,7 @@
>  
>  #include <linux/list.h>
>  #include <linux/bitmap.h>
> +#include <pipeline/thread.h>
>  #include <cobalt/kernel/ppd.h>
>  
>  #define KEVENT_PROPAGATE   0
> @@ -94,13 +95,13 @@ extern struct cobalt_resources cobalt_global_resources;
>  
>  static inline struct cobalt_process *cobalt_current_process(void)
>  {
> -	return ipipe_current_threadinfo()->process;
> +	return pipeline_current()->process;
>  }
>  
>  static inline struct cobalt_process *
>  cobalt_set_process(struct cobalt_process *process)
>  {
> -	struct ipipe_threadinfo *p = ipipe_current_threadinfo();
> +	struct cobalt_threadinfo *p = pipeline_current();
>  	struct cobalt_process *old;
>  
>  	old = p->process;
> diff --git a/kernel/cobalt/thread.c b/kernel/cobalt/thread.c
> index a882bcc45..b871e6069 100644
> --- a/kernel/cobalt/thread.c
> +++ b/kernel/cobalt/thread.c
> @@ -2452,9 +2452,9 @@ static inline void wakeup_parent(struct completion *done)
>  
>  static inline void init_kthread_info(struct xnthread *thread)
>  {
> -	struct ipipe_threadinfo *p;
> +	struct cobalt_threadinfo *p;
>  
> -	p = ipipe_current_threadinfo();
> +	p = pipeline_current();
>  	p->thread = thread;
>  	p->process = NULL;
>  }
> 

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH Dovetail 06/13] cobalt/sched, clock: pipeline: abstract IPI management
  2021-01-02  9:33 ` [PATCH Dovetail 06/13] cobalt/sched, clock: pipeline: abstract IPI management Philippe Gerum
@ 2021-01-08  9:40   ` Jan Kiszka
  0 siblings, 0 replies; 23+ messages in thread
From: Jan Kiszka @ 2021-01-08  9:40 UTC (permalink / raw)
  To: Philippe Gerum, xenomai

On 02.01.21 10:33, Philippe Gerum wrote:
> From: Philippe Gerum <rpm@xenomai.org>
> 
> The I-pipe and Dovetail share the very same concept of out-of-band,
> high-priority IPI, but using a different interface. Let's abstract the
> calls manipulating those IPIs to make them pipeline-specific.
> 
> No functional change is introduced.
> 
> Signed-off-by: Philippe Gerum <rpm@xenomai.org>
> ---
>  .../cobalt/kernel/ipipe/pipeline/pipeline.h   | 50 ++++++++++++++++++-
>  kernel/cobalt/clock.c                         |  2 +-
>  .../include/asm-generic/xenomai/wrappers.h    |  4 --
>  kernel/cobalt/sched.c                         | 11 ++--
>  kernel/cobalt/timer.c                         |  7 +--
>  5 files changed, 56 insertions(+), 18 deletions(-)
> 
> diff --git a/include/cobalt/kernel/ipipe/pipeline/pipeline.h b/include/cobalt/kernel/ipipe/pipeline/pipeline.h
> index 317fa62d7..6f6958402 100644
> --- a/include/cobalt/kernel/ipipe/pipeline/pipeline.h
> +++ b/include/cobalt/kernel/ipipe/pipeline/pipeline.h
> @@ -5,7 +5,13 @@
>  #ifndef _COBALT_KERNEL_IPIPE_PIPELINE_H
>  #define _COBALT_KERNEL_IPIPE_PIPELINE_H
>  
> -#include <linux/ipipe.h>
> +#ifdef CONFIG_IPIPE_LEGACY
> +#error "CONFIG_IPIPE_LEGACY must be switched off"
> +#endif
> +
> +#include <pipeline/machine.h>
> +
> +#define PIPELINE_NR_IRQS  IPIPE_NR_IRQS
>  
>  typedef unsigned long spl_t;
>  
> @@ -22,4 +28,46 @@ typedef unsigned long spl_t;
>  #define is_secondary_domain()	ipipe_root_p
>  #define is_primary_domain()	(!ipipe_root_p)
>  
> +#ifdef CONFIG_SMP
> +
> +static inline int pipeline_request_resched_ipi(void (*handler)(void))
> +{
> +	return ipipe_request_irq(&cobalt_pipeline.domain,
> +				IPIPE_RESCHEDULE_IPI,
> +				(ipipe_irq_handler_t)handler,
> +				NULL, NULL);
> +}
> +
> +static inline void pipeline_free_resched_ipi(void)
> +{
> +	ipipe_free_irq(&cobalt_pipeline.domain,
> +		IPIPE_RESCHEDULE_IPI);
> +}
> +
> +static inline void pipeline_send_resched_ipi(const struct cpumask *dest)
> +{
> +	ipipe_send_ipi(IPIPE_RESCHEDULE_IPI, *dest);
> +}
> +
> +static inline int pipeline_request_timer_ipi(void (*handler)(void))
> +{
> +	return ipipe_request_irq(&cobalt_pipeline.domain,
> +				IPIPE_HRTIMER_IPI,
> +				(ipipe_irq_handler_t)handler,
> +				NULL, NULL);
> +}
> +
> +static inline void pipeline_free_timer_ipi(void)
> +{
> +	return ipipe_free_irq(&cobalt_pipeline.domain,
> +			IPIPE_HRTIMER_IPI);
> +}
> +
> +static inline void pipeline_send_timer_ipi(const struct cpumask *dest)
> +{
> +	ipipe_send_ipi(IPIPE_HRTIMER_IPI, *dest);
> +}
> +
> +#endif
> +
>  #endif /* !_COBALT_KERNEL_IPIPE_PIPELINE_H */
> diff --git a/kernel/cobalt/clock.c b/kernel/cobalt/clock.c
> index 2a5b61760..d73ade3f9 100644
> --- a/kernel/cobalt/clock.c
> +++ b/kernel/cobalt/clock.c
> @@ -228,7 +228,7 @@ void xnclock_core_local_shot(struct xnsched *sched)
>  #ifdef CONFIG_SMP
>  void xnclock_core_remote_shot(struct xnsched *sched)
>  {
> -	ipipe_send_ipi(IPIPE_HRTIMER_IPI, *cpumask_of(xnsched_cpu(sched)));
> +	pipeline_send_timer_ipi(cpumask_of(xnsched_cpu(sched)));
>  }
>  #endif
>  
> diff --git a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
> index e266d5acf..e093676e1 100644
> --- a/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
> +++ b/kernel/cobalt/include/asm-generic/xenomai/wrappers.h
> @@ -20,10 +20,6 @@
>  
>  #include <linux/xenomai/wrappers.h>
>  
> -#ifdef CONFIG_IPIPE_LEGACY
> -#error "CONFIG_IPIPE_LEGACY must be switched off"
> -#endif
> -
>  #define COBALT_BACKPORT(__sym) __cobalt_backport_ ##__sym
>  
>  /*
> diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
> index b16903bd8..a44109e78 100644
> --- a/kernel/cobalt/sched.c
> +++ b/kernel/cobalt/sched.c
> @@ -235,10 +235,7 @@ void xnsched_init_all(void)
>  	}
>  
>  #ifdef CONFIG_SMP
> -	ipipe_request_irq(&xnsched_realtime_domain,
> -			  IPIPE_RESCHEDULE_IPI,
> -			  (ipipe_irq_handler_t)__xnsched_run_handler,
> -			  NULL, NULL);
> +	pipeline_request_resched_ipi(__xnsched_run_handler);
>  #endif
>  }
>  
> @@ -261,7 +258,7 @@ void xnsched_destroy_all(void)
>  	spl_t s;
>  
>  #ifdef CONFIG_SMP
> -	ipipe_free_irq(&xnsched_realtime_domain, IPIPE_RESCHEDULE_IPI);
> +	pipeline_free_resched_ipi();
>  #endif
>  
>  	xnlock_get_irqsave(&nklock, s);
> @@ -860,7 +857,7 @@ static inline int test_resched(struct xnsched *sched)
>  	/* Send resched IPI to remote CPU(s). */
>  	if (unlikely(!cpumask_empty(&sched->resched))) {
>  		smp_mb();
> -		ipipe_send_ipi(IPIPE_RESCHEDULE_IPI, sched->resched);
> +		pipeline_send_resched_ipi(&sched->resched);
>  		cpumask_clear(&sched->resched);
>  	}
>  #endif
> @@ -1280,7 +1277,7 @@ static int vfile_schedstat_next(struct xnvfile_snapshot_iterator *it,
>  
>  scan_irqs:
>  #ifdef CONFIG_XENO_OPT_STATS_IRQS
> -	if (priv->irq >= IPIPE_NR_IRQS)
> +	if (priv->irq >= PIPELINE_NR_IRQS)
>  		return 0;	/* All done. */
>  
>  	ret = xnintr_query_next(priv->irq, &priv->intr_it, p->name);
> diff --git a/kernel/cobalt/timer.c b/kernel/cobalt/timer.c
> index ccd3c3b70..b8c3f5a11 100644
> --- a/kernel/cobalt/timer.c
> +++ b/kernel/cobalt/timer.c
> @@ -578,15 +578,12 @@ EXPORT_SYMBOL_GPL(__xntimer_set_affinity);
>  
>  int xntimer_setup_ipi(void)
>  {
> -	return ipipe_request_irq(&xnsched_realtime_domain,
> -				 IPIPE_HRTIMER_IPI,
> -				 (ipipe_irq_handler_t)xnintr_core_clock_handler,
> -				 NULL, NULL);
> +	return pipeline_request_timer_ipi(xnintr_core_clock_handler);
>  }
>  
>  void xntimer_release_ipi(void)
>  {
> -	ipipe_free_irq(&xnsched_realtime_domain, IPIPE_HRTIMER_IPI);
> +	pipeline_free_timer_ipi();
>  }
>  
>  #endif /* CONFIG_SMP */
> 

Thanks, applied up to here (with the fixup of patch 1), just waiting for
feedback on my comments on patch 7 and beyond.

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH Dovetail 07/13] cobalt/clock: pipeline: make HOSTRT depend on IPIPE
  2021-01-07 13:52   ` Jan Kiszka
@ 2021-01-09 10:45     ` Philippe Gerum
  0 siblings, 0 replies; 23+ messages in thread
From: Philippe Gerum @ 2021-01-09 10:45 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: xenomai


Jan Kiszka <jan.kiszka@siemens.com> writes:

> On 02.01.21 10:33, Philippe Gerum wrote:
>> From: Philippe Gerum <rpm@xenomai.org>
>> 
>> This interface is pointless with Dovetail whose applications directly
>> refer to the wallclock time exported through the common vDSO.
>> 
>> No functional change is introduced.
>> 
>> Signed-off-by: Philippe Gerum <rpm@xenomai.org>
>> ---
>>  include/cobalt/kernel/vdso.h  | 18 +++++++++++-------
>>  kernel/cobalt/Kconfig         |  4 ----
>>  kernel/cobalt/ipipe/kevents.c | 14 ++++++++------
>>  kernel/cobalt/posix/clock.c   |  4 ++--
>>  4 files changed, 21 insertions(+), 19 deletions(-)
>> 
>> diff --git a/include/cobalt/kernel/vdso.h b/include/cobalt/kernel/vdso.h
>> index f7140adc7..7da88a730 100644
>> --- a/include/cobalt/kernel/vdso.h
>> +++ b/include/cobalt/kernel/vdso.h
>> @@ -25,21 +25,25 @@
>>  #include <asm/processor.h>
>>  #include <cobalt/uapi/kernel/vdso.h>
>>  
>> +extern struct xnvdso *nkvdso;
>> +
>>  /*
>>   * Define the available feature set here. We have a single feature
>> - * defined for now.
>> + * defined for now, only in the I-pipe case.
>>   */
>> -#ifdef CONFIG_XENO_OPT_HOSTRT
>> -#define XNVDSO_FEATURES XNVDSO_FEAT_HOST_REALTIME
>> -#else
>> -#define XNVDSO_FEATURES 0
>> -#endif /* CONFIG_XENO_OPT_HOSTRT */
>> +#ifdef CONFIG_IPIPE_HAVE_HOSTRT
>>  
>> -extern struct xnvdso *nkvdso;
>> +#define XNVDSO_FEATURES XNVDSO_FEAT_HOST_REALTIME
>>  
>>  static inline struct xnvdso_hostrt_data *get_hostrt_data(void)
>>  {
>>  	return &nkvdso->hostrt_data;
>>  }
>>  
>> +#else
>> +
>> +#define XNVDSO_FEATURES 0
>> +
>> +#endif
>> +
>>  #endif /* _COBALT_KERNEL_VDSO_H */
>> diff --git a/kernel/cobalt/Kconfig b/kernel/cobalt/Kconfig
>> index 0d96913bd..ead4740c1 100644
>> --- a/kernel/cobalt/Kconfig
>> +++ b/kernel/cobalt/Kconfig
>> @@ -210,10 +210,6 @@ config XENO_OPT_TIMER_RBTREE
>>  
>>  endchoice
>>  
>> -config XENO_OPT_HOSTRT
>> -       depends on IPIPE_HAVE_HOSTRT
>> -       def_bool y
>> -
>>  config XENO_OPT_PIPE
>>  	bool
>>  
>> diff --git a/kernel/cobalt/ipipe/kevents.c b/kernel/cobalt/ipipe/kevents.c
>> index e0d4a1288..595faffd3 100644
>> --- a/kernel/cobalt/ipipe/kevents.c
>> +++ b/kernel/cobalt/ipipe/kevents.c
>> @@ -377,7 +377,7 @@ void ipipe_migration_hook(struct task_struct *p) /* hw IRQs off */
>>  	xnsched_run();
>>  }
>>  
>> -#ifdef CONFIG_XENO_OPT_HOSTRT
>> +#ifdef CONFIG_IPIPE_HAVE_HOSTRT
>>  
>>  static IPIPE_DEFINE_SPINLOCK(__hostrtlock);
>>  
>> @@ -417,7 +417,7 @@ static inline void init_hostrt(void)
>>  	nkvdso->hostrt_data.live = 0;
>>  }
>>  
>> -#else /* !CONFIG_XENO_OPT_HOSTRT */
>> +#else /* !CONFIG_IPIPE_HAVE_HOSTRT */
>>  
>>  struct ipipe_hostrt_data;
>>  
>> @@ -428,7 +428,7 @@ static inline int handle_hostrt_event(struct ipipe_hostrt_data *hostrt)
>>  
>>  static inline void init_hostrt(void) { }
>>  
>> -#endif /* !CONFIG_XENO_OPT_HOSTRT */
>> +#endif /* !CONFIG_IPIPE_HAVE_HOSTRT */
>>  
>>  static void __handle_taskexit_event(struct task_struct *p)
>>  {
>> @@ -756,12 +756,14 @@ int ipipe_kevent_hook(int kevent, void *data)
>>  	case IPIPE_KEVT_CLEANUP:
>>  		ret = handle_cleanup_event(data);
>>  		break;
>> -	case IPIPE_KEVT_HOSTRT:
>> -		ret = handle_hostrt_event(data);
>> -		break;
>>  	case IPIPE_KEVT_SETAFFINITY:
>>  		ret = handle_setaffinity_event(data);
>>  		break;
>> +#ifdef IPIPE_KEVT_HOSTRT
>
> Wouldn't CONFIG_IPIPE_HAVE_HOSTRT be cleaner here?
>

Certainly. I squeezed that change into rev #2 of the current patch since
rev #1 was not pushed to -next yet.

-- 
Philippe.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH Dovetail 13/13] cobalt/syscall: pipeline: abstract syscall entry points
  2021-01-07 14:08   ` Jan Kiszka
@ 2021-01-09 10:58     ` Philippe Gerum
  2021-01-11 12:11       ` Jan Kiszka
  0 siblings, 1 reply; 23+ messages in thread
From: Philippe Gerum @ 2021-01-09 10:58 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: xenomai


Jan Kiszka <jan.kiszka@siemens.com> writes:

> On 02.01.21 10:33, Philippe Gerum wrote:
>> From: Philippe Gerum <rpm@xenomai.org>
>> 
>> The I-pipe and Dovetail differ only marginally with respect to syscall
>> handling. Abstract only the few details we need to cope with both
>> interfaces.
>> 
>> No functional change is introduced.
>> 
>> Signed-off-by: Philippe Gerum <rpm@xenomai.org>
>> ---
>>  .../cobalt/kernel/ipipe/pipeline/kevents.h    |  3 ++
>>  .../cobalt/kernel/ipipe/pipeline/pipeline.h   |  2 ++
>>  include/cobalt/kernel/sched.h                 |  2 --
>>  kernel/cobalt/ipipe/Makefile                  |  2 +-
>>  kernel/cobalt/ipipe/syscall.c                 | 29 +++++++++++++++++++
>>  kernel/cobalt/posix/process.h                 |  3 --
>>  kernel/cobalt/posix/syscall.c                 | 28 ++++--------------
>>  kernel/cobalt/posix/syscall.h                 |  7 +++++
>>  8 files changed, 47 insertions(+), 29 deletions(-)
>>  create mode 100644 kernel/cobalt/ipipe/syscall.c
>> 
>> diff --git a/include/cobalt/kernel/ipipe/pipeline/kevents.h b/include/cobalt/kernel/ipipe/pipeline/kevents.h
>> index 30425a96b..2f186a57e 100644
>> --- a/include/cobalt/kernel/ipipe/pipeline/kevents.h
>> +++ b/include/cobalt/kernel/ipipe/pipeline/kevents.h
>> @@ -7,6 +7,9 @@
>>  #ifndef _COBALT_KERNEL_IPIPE_KEVENTS_H
>>  #define _COBALT_KERNEL_IPIPE_KEVENTS_H
>>  
>> +#define KEVENT_PROPAGATE   0
>> +#define KEVENT_STOP        1
>> +
>>  struct cobalt_process;
>>  struct cobalt_thread;
>>  
>> diff --git a/include/cobalt/kernel/ipipe/pipeline/pipeline.h b/include/cobalt/kernel/ipipe/pipeline/pipeline.h
>> index 0ffc9b00b..fb0465fb2 100644
>> --- a/include/cobalt/kernel/ipipe/pipeline/pipeline.h
>> +++ b/include/cobalt/kernel/ipipe/pipeline/pipeline.h
>> @@ -11,6 +11,8 @@
>>  
>>  #include <pipeline/machine.h>
>>  
>> +#define xnsched_realtime_domain  cobalt_pipeline.domain
>> +
>
> Why not use the chance and call also this xnsched_primary_domain?

Agreed on the reasoning. However I'll push that change on top top of my
current patch queue, without affecting this intermediate patch only for
a cosmetic change, not to cause useless merge conflicts - I have several
other series of changes pending for kernel/cobalt/ipipe/{init, intr}.c
typically.

-- 
Philippe.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH Dovetail 13/13] cobalt/syscall: pipeline: abstract syscall entry points
  2021-01-09 10:58     ` Philippe Gerum
@ 2021-01-11 12:11       ` Jan Kiszka
  0 siblings, 0 replies; 23+ messages in thread
From: Jan Kiszka @ 2021-01-11 12:11 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: xenomai

On 09.01.21 11:58, Philippe Gerum wrote:
> 
> Jan Kiszka <jan.kiszka@siemens.com> writes:
> 
>> On 02.01.21 10:33, Philippe Gerum wrote:
>>> From: Philippe Gerum <rpm@xenomai.org>
>>>
>>> The I-pipe and Dovetail differ only marginally with respect to syscall
>>> handling. Abstract only the few details we need to cope with both
>>> interfaces.
>>>
>>> No functional change is introduced.
>>>
>>> Signed-off-by: Philippe Gerum <rpm@xenomai.org>
>>> ---
>>>  .../cobalt/kernel/ipipe/pipeline/kevents.h    |  3 ++
>>>  .../cobalt/kernel/ipipe/pipeline/pipeline.h   |  2 ++
>>>  include/cobalt/kernel/sched.h                 |  2 --
>>>  kernel/cobalt/ipipe/Makefile                  |  2 +-
>>>  kernel/cobalt/ipipe/syscall.c                 | 29 +++++++++++++++++++
>>>  kernel/cobalt/posix/process.h                 |  3 --
>>>  kernel/cobalt/posix/syscall.c                 | 28 ++++--------------
>>>  kernel/cobalt/posix/syscall.h                 |  7 +++++
>>>  8 files changed, 47 insertions(+), 29 deletions(-)
>>>  create mode 100644 kernel/cobalt/ipipe/syscall.c
>>>
>>> diff --git a/include/cobalt/kernel/ipipe/pipeline/kevents.h b/include/cobalt/kernel/ipipe/pipeline/kevents.h
>>> index 30425a96b..2f186a57e 100644
>>> --- a/include/cobalt/kernel/ipipe/pipeline/kevents.h
>>> +++ b/include/cobalt/kernel/ipipe/pipeline/kevents.h
>>> @@ -7,6 +7,9 @@
>>>  #ifndef _COBALT_KERNEL_IPIPE_KEVENTS_H
>>>  #define _COBALT_KERNEL_IPIPE_KEVENTS_H
>>>  
>>> +#define KEVENT_PROPAGATE   0
>>> +#define KEVENT_STOP        1
>>> +
>>>  struct cobalt_process;
>>>  struct cobalt_thread;
>>>  
>>> diff --git a/include/cobalt/kernel/ipipe/pipeline/pipeline.h b/include/cobalt/kernel/ipipe/pipeline/pipeline.h
>>> index 0ffc9b00b..fb0465fb2 100644
>>> --- a/include/cobalt/kernel/ipipe/pipeline/pipeline.h
>>> +++ b/include/cobalt/kernel/ipipe/pipeline/pipeline.h
>>> @@ -11,6 +11,8 @@
>>>  
>>>  #include <pipeline/machine.h>
>>>  
>>> +#define xnsched_realtime_domain  cobalt_pipeline.domain
>>> +
>>
>> Why not use the chance and call also this xnsched_primary_domain?
> 
> Agreed on the reasoning. However I'll push that change on top top of my
> current patch queue, without affecting this intermediate patch only for
> a cosmetic change, not to cause useless merge conflicts - I have several
> other series of changes pending for kernel/cobalt/ipipe/{init, intr}.c
> typically.
> 

OK. All now applied (with v2 of patch 7).

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH Dovetail 10/13] cobalt/wrappers: pipeline: abstract pipeline-related bits
  2021-01-02  9:33 ` [PATCH Dovetail 10/13] cobalt/wrappers: pipeline: abstract pipeline-related bits Philippe Gerum
  2021-01-07 13:56   ` Jan Kiszka
@ 2021-01-11 12:59   ` Jan Kiszka
  1 sibling, 0 replies; 23+ messages in thread
From: Jan Kiszka @ 2021-01-11 12:59 UTC (permalink / raw)
  To: Philippe Gerum, xenomai

On 02.01.21 10:33, Philippe Gerum wrote:
> From: Philippe Gerum <rpm@xenomai.org>
> 
> No functional change is introduced.
> 
> Signed-off-by: Philippe Gerum <rpm@xenomai.org>
> ---
>  .../cobalt/kernel/ipipe/pipeline/wrappers.h   | 25 +++++++++++++++++++
>  .../cobalt/include/linux/xenomai/wrappers.h   | 23 ++++-------------
>  kernel/cobalt/posix/process.c                 |  2 +-
>  3 files changed, 31 insertions(+), 19 deletions(-)
>  create mode 100644 include/cobalt/kernel/ipipe/pipeline/wrappers.h
> 
> diff --git a/include/cobalt/kernel/ipipe/pipeline/wrappers.h b/include/cobalt/kernel/ipipe/pipeline/wrappers.h
> new file mode 100644
> index 000000000..ac940fb32
> --- /dev/null
> +++ b/include/cobalt/kernel/ipipe/pipeline/wrappers.h
> @@ -0,0 +1,25 @@
> +/*
> + * SPDX-License-Identifier: GPL-2.0
> + */
> +#ifndef _COBALT_KERNEL_IPIPE_WRAPPERS_H
> +#define _COBALT_KERNEL_IPIPE_WRAPPERS_H
> +
> +#include <linux/ipipe.h>
> +
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0)
> +#define cobalt_set_task_state(tsk, state_value)	\
> +	set_task_state(tsk, state_value)
> +#else
> +/*
> + * The co-kernel can still set the current task state safely if it
> + * runs on the head stage.
> + */
> +#define cobalt_set_task_state(tsk, state_value)	\
> +		smp_store_mb((tsk)->state, (state_value))
> +#endif
> +
> +#ifndef ipipe_root_nr_syscalls
> +#define ipipe_root_nr_syscalls(ti)	NR_syscalls
> +#endif
> +
> +#endif /* !_COBALT_KERNEL_IPIPE_WRAPPERS_H */
> diff --git a/kernel/cobalt/include/linux/xenomai/wrappers.h b/kernel/cobalt/include/linux/xenomai/wrappers.h
> index 847d68088..3e825e366 100644
> --- a/kernel/cobalt/include/linux/xenomai/wrappers.h
> +++ b/kernel/cobalt/include/linux/xenomai/wrappers.h
> @@ -21,12 +21,13 @@
>  
>  #include <linux/version.h>
>  
> +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)

#include <linux/signal.h>

Builds failed over 4.4. Fixed up in next.

Jan

> +typedef siginfo_t kernel_siginfo_t;
> +#endif
> +
>  #if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0)
>  #include <linux/sched.h>
>  #include <linux/sched/rt.h>
> -
> -#define cobalt_set_task_state(tsk, state_value)	\
> -	set_task_state(tsk, state_value)
>  #else
>  #include <linux/sched.h>
>  #include <linux/sched/signal.h>
> @@ -35,22 +36,8 @@
>  #include <linux/sched/debug.h>
>  #include <linux/sched/task_stack.h>
>  #include <uapi/linux/sched/types.h>
> -/*
> - * The co-kernel can still do this sanely for a thread which is
> - * currently active on the head stage.
> - */
> -#define cobalt_set_task_state(tsk, state_value)	\
> -		smp_store_mb((tsk)->state, (state_value))
>  #endif
>  
> -#include <linux/ipipe.h>
> -
> -#ifndef ipipe_root_nr_syscalls
> -#define ipipe_root_nr_syscalls(ti)	NR_syscalls
> -#endif
> -
> -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 20, 0)
> -typedef siginfo_t kernel_siginfo_t;
> -#endif
> +#include <pipeline/wrappers.h>
>  
>  #endif /* !_COBALT_LINUX_WRAPPERS_H */
> diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c
> index accd989ca..fcae7df06 100644
> --- a/kernel/cobalt/posix/process.c
> +++ b/kernel/cobalt/posix/process.c
> @@ -640,7 +640,7 @@ int cobalt_map_user(struct xnthread *thread, __u32 __user *u_winoff)
>  	 * it.
>  	 */
>  	xnthread_run_handler(thread, map_thread);
> -	pipeline_enable_kevents(current);
> +	pipeline_enable_kevents();
>  
>  	attr.mode = 0;
>  	attr.entry = NULL;
> 


-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2021-01-11 12:59 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-02  9:33 [PATCH Dovetail 00/13] Keep on abstracting the pipeline interface Philippe Gerum
2021-01-02  9:33 ` [PATCH Dovetail 01/13] cobalt/thread: pipeline: abstract threadinfo accessor Philippe Gerum
2021-01-08  9:02   ` Jan Kiszka
2021-01-02  9:33 ` [PATCH Dovetail 02/13] cobalt/apc: pipeline: abstract interface for deferred routine calls Philippe Gerum
2021-01-02  9:33 ` [PATCH Dovetail 03/13] cobalt/trace: pipeline: abstract trace calls Philippe Gerum
2021-01-02  9:33 ` [PATCH Dovetail 04/13] cobalt/lock: pipeline: abstract hard lock API Philippe Gerum
2021-01-02  9:33 ` [PATCH Dovetail 05/13] cobalt/kernel: pipeline: abstract execution stage predicates Philippe Gerum
2021-01-02  9:33 ` [PATCH Dovetail 06/13] cobalt/sched, clock: pipeline: abstract IPI management Philippe Gerum
2021-01-08  9:40   ` Jan Kiszka
2021-01-02  9:33 ` [PATCH Dovetail 07/13] cobalt/clock: pipeline: make HOSTRT depend on IPIPE Philippe Gerum
2021-01-07 13:52   ` Jan Kiszka
2021-01-09 10:45     ` Philippe Gerum
2021-01-02  9:33 ` [PATCH Dovetail 08/13] cobalt/build: pipeline: select IPIPE layer only if present Philippe Gerum
2021-01-02  9:33 ` [PATCH Dovetail 09/13] cobalt/clock: pipeline: abstract clock, timer access services Philippe Gerum
2021-01-02  9:33 ` [PATCH Dovetail 10/13] cobalt/wrappers: pipeline: abstract pipeline-related bits Philippe Gerum
2021-01-07 13:56   ` Jan Kiszka
2021-01-11 12:59   ` Jan Kiszka
2021-01-02  9:33 ` [PATCH Dovetail 11/13] cobalt/timer: pipeline: abstract tick management Philippe Gerum
2021-01-02  9:33 ` [PATCH Dovetail 12/13] cobalt/debug: pipeline: abstract panic prep call Philippe Gerum
2021-01-02  9:33 ` [PATCH Dovetail 13/13] cobalt/syscall: pipeline: abstract syscall entry points Philippe Gerum
2021-01-07 14:08   ` Jan Kiszka
2021-01-09 10:58     ` Philippe Gerum
2021-01-11 12:11       ` Jan Kiszka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.