All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philippe  Gerum <rpm@xenomai.org>
To: xenomai@xenomai.org
Subject: [PATCH Dovetail 02/13] cobalt/apc: pipeline: abstract interface for deferred routine calls
Date: Sat,  2 Jan 2021 10:33:42 +0100	[thread overview]
Message-ID: <20210102093353.3195090-3-rpm@xenomai.org> (raw)
In-Reply-To: <20210102093353.3195090-1-rpm@xenomai.org>

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



  parent reply	other threads:[~2021-01-02  9:33 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Philippe Gerum [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210102093353.3195090-3-rpm@xenomai.org \
    --to=rpm@xenomai.org \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.