All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH Dovetail 0/4] Get rid of the APC interface
@ 2021-01-09 16:02 Philippe Gerum
  2021-01-09 16:02 ` [PATCH Dovetail 1/4] cobalt/pipe: drop dependency on APCs Philippe Gerum
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Philippe Gerum @ 2021-01-09 16:02 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

This patch starts a series aiming at dropping the (functionally
redundant) APC interface entirely.

APCs are a relic from the Dark Ages, with no upside compared to open
coded requests triggering virtual/synthetic IRQs to be handled by the
root domain. As a matter of fact, an APC does run as a client handler
of a synthetic IRQ under the hood. In other words, the APC
encapsulation adds nothing but useless overhead.

Philippe Gerum (4):
  cobalt/pipe: drop dependency on APCs
  cobalt/registry: drop dependency on APCs
  cobalt/select: drop dependency on APCs
  cobalt/apc: drop obsolete APC mechanism

 include/cobalt/kernel/apc.h                   |  32 ---
 .../cobalt/kernel/ipipe/pipeline/machine.h    |   2 -
 include/cobalt/kernel/rtdm/driver.h           |   1 -
 kernel/cobalt/ipipe/Makefile                  |   2 +-
 kernel/cobalt/ipipe/apc.c                     | 202 ------------------
 kernel/cobalt/ipipe/init.c                    |  19 --
 kernel/cobalt/pipe.c                          |  26 ++-
 kernel/cobalt/procfs.c                        |  42 ----
 kernel/cobalt/registry.c                      |  30 +--
 kernel/cobalt/rtdm/core.c                     |   1 -
 kernel/cobalt/select.c                        |  23 +-
 11 files changed, 49 insertions(+), 331 deletions(-)
 delete mode 100644 include/cobalt/kernel/apc.h
 delete mode 100644 kernel/cobalt/ipipe/apc.c

-- 
2.26.2



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

* [PATCH Dovetail 1/4] cobalt/pipe: drop dependency on APCs
  2021-01-09 16:02 [PATCH Dovetail 0/4] Get rid of the APC interface Philippe Gerum
@ 2021-01-09 16:02 ` Philippe Gerum
  2021-01-09 16:02 ` [PATCH Dovetail 2/4] cobalt/registry: " Philippe Gerum
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Philippe Gerum @ 2021-01-09 16:02 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

This patch starts a series aiming at dropping the (functionally
redundant) APC interface entirely.

APCs are a relic from the Dark Ages, with no upside compared to open
coded requests triggering virtual/synthetic IRQs to be handled by the
root domain. As a matter of fact, an APC does run as a client handler
of a synthetic IRQ under the hood.

With this change, all APCs will not be multiplexed over a single
synthetic IRQ anymore but each deferred procedure is going to be
assigned its own synthetic IRQ channel, which is hardly a problem
since we only have a couple of APCs to deal with, much fewer than the
number of synthetic IRQs available to us.

As a result, /proc/xenomai/apc will not be available for inspecting
the trigger count of synthetic interrupts used by the core
anymore. Since the I-pipe is on its way out, having this obscure
feature dropped in this context seems acceptable. However, the related
information will still be available to Dovetail-based builds directly
from /proc/interrupts, as synthetic IRQs are (mostly) regular
interrupts there.

Start with using a virtual/synthetic IRQ for kicking the wakeup
procedure for message pipes, dropping the dependency on APCs.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 kernel/cobalt/pipe.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/kernel/cobalt/pipe.c b/kernel/cobalt/pipe.c
index 0c83095ba..8044c3ff7 100644
--- a/kernel/cobalt/pipe.c
+++ b/kernel/cobalt/pipe.c
@@ -32,7 +32,6 @@
 #include <cobalt/kernel/sched.h>
 #include <cobalt/kernel/heap.h>
 #include <cobalt/kernel/pipe.h>
-#include <cobalt/kernel/apc.h>
 
 static int xnpipe_asyncsig = SIGIO;
 
@@ -47,7 +46,7 @@ static LIST_HEAD(xnpipe_sleepq);
 
 static LIST_HEAD(xnpipe_asyncq);
 
-int xnpipe_wakeup_apc;
+static int xnpipe_wakeup_virq;
 
 static struct class *xnpipe_class;
 
@@ -146,7 +145,7 @@ static inline void xnpipe_dequeue_all(struct xnpipe_state *state, int mask)
 	__sigpending;							\
 })
 
-static void xnpipe_wakeup_proc(void *cookie)
+static void xnpipe_wakeup_proc(unsigned int virq, void *arg)
 {
 	struct xnpipe_state *state;
 	unsigned long rbits;
@@ -224,7 +223,7 @@ out:
 
 static inline void xnpipe_schedule_request(void) /* hw IRQs off */
 {
-	__xnapc_schedule(xnpipe_wakeup_apc);
+	ipipe_post_irq_root(xnpipe_wakeup_virq);
 }
 
 static inline ssize_t xnpipe_flush_bufq(void (*fn)(void *buf, void *xstate),
@@ -1153,14 +1152,22 @@ int xnpipe_mount(void)
 
 	if (register_chrdev(XNPIPE_DEV_MAJOR, "rtpipe", &xnpipe_fops)) {
 		printk(XENO_ERR
-		       "unable to reserve major #%d for message pipe support\n",
+		       "unable to reserve major #%d for message pipes\n",
 		       XNPIPE_DEV_MAJOR);
 		return -EBUSY;
 	}
 
-	xnpipe_wakeup_apc =
-	    xnapc_alloc("pipe_wakeup", &xnpipe_wakeup_proc, NULL);
+	xnpipe_wakeup_virq = ipipe_alloc_virq();
+	if (xnpipe_wakeup_virq == 0) {
+		printk(XENO_ERR
+		       "unable to reserve synthetic IRQ for message pipes\n");
+		return -EBUSY;
+	}
 
+	ipipe_request_irq(ipipe_root_domain,
+			  xnpipe_wakeup_virq,
+			  xnpipe_wakeup_proc,
+			  NULL, NULL);
 	return 0;
 }
 
@@ -1168,7 +1175,10 @@ void xnpipe_umount(void)
 {
 	int i;
 
-	xnapc_free(xnpipe_wakeup_apc);
+	ipipe_free_irq(ipipe_root_domain,
+		       xnpipe_wakeup_virq);
+	ipipe_free_virq(xnpipe_wakeup_virq);
+
 	unregister_chrdev(XNPIPE_DEV_MAJOR, "rtpipe");
 
 	for (i = 0; i < XNPIPE_NDEVS; i++)
-- 
2.26.2



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

* [PATCH Dovetail 2/4] cobalt/registry: drop dependency on APCs
  2021-01-09 16:02 [PATCH Dovetail 0/4] Get rid of the APC interface Philippe Gerum
  2021-01-09 16:02 ` [PATCH Dovetail 1/4] cobalt/pipe: drop dependency on APCs Philippe Gerum
@ 2021-01-09 16:02 ` Philippe Gerum
  2021-01-09 16:02 ` [PATCH Dovetail 3/4] cobalt/select: " Philippe Gerum
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Philippe Gerum @ 2021-01-09 16:02 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

Directly use a virtual/synthetic IRQ for waking up the export/unexport
procedure, dropping the dependency on APCs.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 kernel/cobalt/registry.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/kernel/cobalt/registry.c b/kernel/cobalt/registry.c
index dc1edd01a..7f7cb9eea 100644
--- a/kernel/cobalt/registry.c
+++ b/kernel/cobalt/registry.c
@@ -21,7 +21,6 @@
 #include <cobalt/kernel/heap.h>
 #include <cobalt/kernel/registry.h>
 #include <cobalt/kernel/thread.h>
-#include <cobalt/kernel/apc.h>
 #include <cobalt/kernel/assert.h>
 
 /**
@@ -62,13 +61,13 @@ static struct xnsynch register_synch;
 
 static void proc_callback(struct work_struct *work);
 
-static void registry_proc_schedule(void *cookie);
+static void registry_proc_schedule(unsigned int virq, void *arg);
 
 static LIST_HEAD(proc_object_list);	/* Objects waiting for /proc handling. */
 
 static DECLARE_WORK(registry_proc_work, proc_callback);
 
-static int proc_apc;
+static int proc_virq;
 
 static struct xnvfile_directory registry_vfroot;
 
@@ -124,14 +123,17 @@ int xnregistry_init(void)
 		return ret;
 	}
 
-	proc_apc =
-	    xnapc_alloc("registry_export", &registry_proc_schedule, NULL);
-
-	if (proc_apc < 0) {
+	proc_virq = ipipe_alloc_virq();
+	if (proc_virq == 0) {
 		xnvfile_destroy_regular(&usage_vfile);
 		xnvfile_destroy_dir(&registry_vfroot);
-		return proc_apc;
+		return -EBUSY;
 	}
+
+	ipipe_request_irq(ipipe_root_domain,
+			  proc_virq,
+			  registry_proc_schedule,
+			  NULL, NULL);
 #endif /* CONFIG_XENO_OPT_VFILE */
 
 	next_object_stamp = 0;
@@ -153,7 +155,8 @@ int xnregistry_init(void)
 #ifdef CONFIG_XENO_OPT_VFILE
 		xnvfile_destroy_regular(&usage_vfile);
 		xnvfile_destroy_dir(&registry_vfroot);
-		xnapc_free(proc_apc);
+		ipipe_free_irq(ipipe_root_domain, proc_virq);
+		ipipe_free_virq(proc_virq);
 #endif /* CONFIG_XENO_OPT_VFILE */
 		return -ENOMEM;
 	}
@@ -199,7 +202,8 @@ void xnregistry_cleanup(void)
 	xnsynch_destroy(&register_synch);
 
 #ifdef CONFIG_XENO_OPT_VFILE
-	xnapc_free(proc_apc);
+	ipipe_free_irq(ipipe_root_domain, proc_virq);
+	ipipe_free_virq(proc_virq);
 	flush_scheduled_work();
 	xnvfile_destroy_regular(&usage_vfile);
 	xnvfile_destroy_dir(&registry_vfroot);
@@ -328,7 +332,7 @@ static void proc_callback(struct work_struct *work)
 	up(&export_mutex);
 }
 
-static void registry_proc_schedule(void *cookie)
+static void registry_proc_schedule(unsigned int virq, void *arg)
 {
 	/*
 	 * schedule_work() will check for us if the work has already
@@ -469,7 +473,7 @@ static inline void registry_export_pnode(struct xnobject *object,
 	object->pnode = pnode;
 	list_del(&object->link);
 	list_add_tail(&object->link, &proc_object_list);
-	__xnapc_schedule(proc_apc);
+	ipipe_post_irq_root(proc_virq);
 }
 
 static inline void registry_unexport_pnode(struct xnobject *object)
@@ -485,7 +489,7 @@ static inline void registry_unexport_pnode(struct xnobject *object)
 			object->pnode->ops->touch(object);
 		list_del(&object->link);
 		list_add_tail(&object->link, &proc_object_list);
-		__xnapc_schedule(proc_apc);
+		ipipe_post_irq_root(proc_virq);
 	} else {
 		/*
 		 * Unexporting before the lower stage has had a chance
-- 
2.26.2



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

* [PATCH Dovetail 3/4] cobalt/select: drop dependency on APCs
  2021-01-09 16:02 [PATCH Dovetail 0/4] Get rid of the APC interface Philippe Gerum
  2021-01-09 16:02 ` [PATCH Dovetail 1/4] cobalt/pipe: drop dependency on APCs Philippe Gerum
  2021-01-09 16:02 ` [PATCH Dovetail 2/4] cobalt/registry: " Philippe Gerum
@ 2021-01-09 16:02 ` Philippe Gerum
  2021-01-09 16:02 ` [PATCH Dovetail 4/4] cobalt/apc: drop obsolete APC mechanism Philippe Gerum
  2021-01-11 12:10 ` [PATCH Dovetail 0/4] Get rid of the APC interface Jan Kiszka
  4 siblings, 0 replies; 7+ messages in thread
From: Philippe Gerum @ 2021-01-09 16:02 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

Directly use a virtual/synthetic IRQ for kicking the deletion
procedure for RTDM file descriptors, dropping the dependency on APCs.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 kernel/cobalt/select.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/kernel/cobalt/select.c b/kernel/cobalt/select.c
index df3d960db..f45905112 100644
--- a/kernel/cobalt/select.c
+++ b/kernel/cobalt/select.c
@@ -23,7 +23,6 @@
 #include <cobalt/kernel/sched.h>
 #include <cobalt/kernel/synch.h>
 #include <cobalt/kernel/select.h>
-#include <cobalt/kernel/apc.h>
 
 /**
  * @ingroup cobalt_core
@@ -49,7 +48,7 @@
  */
 
 static LIST_HEAD(selector_list);
-static int deletion_apc;
+static int deletion_virq;
 
 /**
  * Initialize a @a struct @a xnselect structure.
@@ -399,12 +398,12 @@ void xnselector_destroy(struct xnselector *selector)
 
 	xnlock_get_irqsave(&nklock, s);
 	list_add_tail(&selector->destroy_link, &selector_list);
-	__xnapc_schedule(deletion_apc);
+	ipipe_post_irq_root(deletion_virq);
 	xnlock_put_irqrestore(&nklock, s);
 }
 EXPORT_SYMBOL_GPL(xnselector_destroy);
 
-static void xnselector_destroy_loop(void *cookie)
+static void xnselector_destroy_loop(unsigned int virq, void *arg)
 {
 	struct xnselect_binding *binding, *tmpb;
 	struct xnselector *selector, *tmps;
@@ -443,17 +442,21 @@ out:
 
 int xnselect_mount(void)
 {
-	deletion_apc = xnapc_alloc("selector_list_destroy",
-				   xnselector_destroy_loop, NULL);
-	if (deletion_apc < 0)
-		return deletion_apc;
-
+	deletion_virq = ipipe_alloc_virq();
+	if (deletion_virq == 0)
+		return -EBUSY;
+
+	ipipe_request_irq(ipipe_root_domain,
+			deletion_virq,
+			xnselector_destroy_loop,
+			NULL, NULL);
 	return 0;
 }
 
 int xnselect_umount(void)
 {
-	xnapc_free(deletion_apc);
+	ipipe_free_irq(ipipe_root_domain, deletion_virq);
+	ipipe_free_virq(deletion_virq);
 	return 0;
 }
 
-- 
2.26.2



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

* [PATCH Dovetail 4/4] cobalt/apc: drop obsolete APC mechanism
  2021-01-09 16:02 [PATCH Dovetail 0/4] Get rid of the APC interface Philippe Gerum
                   ` (2 preceding siblings ...)
  2021-01-09 16:02 ` [PATCH Dovetail 3/4] cobalt/select: " Philippe Gerum
@ 2021-01-09 16:02 ` Philippe Gerum
  2021-01-11 12:10 ` [PATCH Dovetail 0/4] Get rid of the APC interface Jan Kiszka
  4 siblings, 0 replies; 7+ messages in thread
From: Philippe Gerum @ 2021-01-09 16:02 UTC (permalink / raw)
  To: xenomai

From: Philippe Gerum <rpm@xenomai.org>

No more in-tree users.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
 include/cobalt/kernel/apc.h                   |  32 ---
 .../cobalt/kernel/ipipe/pipeline/machine.h    |   2 -
 include/cobalt/kernel/rtdm/driver.h           |   1 -
 kernel/cobalt/ipipe/Makefile                  |   2 +-
 kernel/cobalt/ipipe/apc.c                     | 202 ------------------
 kernel/cobalt/ipipe/init.c                    |  19 --
 kernel/cobalt/procfs.c                        |  42 ----
 kernel/cobalt/rtdm/core.c                     |   1 -
 8 files changed, 1 insertion(+), 300 deletions(-)
 delete mode 100644 include/cobalt/kernel/apc.h
 delete mode 100644 kernel/cobalt/ipipe/apc.c

diff --git a/include/cobalt/kernel/apc.h b/include/cobalt/kernel/apc.h
deleted file mode 100644
index 45d70b146..000000000
--- a/include/cobalt/kernel/apc.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2012 Philippe Gerum <rpm@xenomai.org>.
- *
- * 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_APC_H
-#define _COBALT_KERNEL_APC_H
-
-int xnapc_alloc(const char *name,
-		void (*handler)(void *cookie),
-		void *cookie);
-
-void xnapc_free(int apc);
-
-void __xnapc_schedule(int apc);
-
-void xnapc_schedule(int apc);
-
-#endif /* !_COBALT_KERNEL_APC_H */
diff --git a/include/cobalt/kernel/ipipe/pipeline/machine.h b/include/cobalt/kernel/ipipe/pipeline/machine.h
index 4a434bc4d..211e4c744 100644
--- a/include/cobalt/kernel/ipipe/pipeline/machine.h
+++ b/include/cobalt/kernel/ipipe/pipeline/machine.h
@@ -42,8 +42,6 @@ struct cobalt_pipeline {
 	struct ipipe_domain domain;
 	unsigned long timer_freq;
 	unsigned long clock_freq;
-	unsigned int apc_virq;
-	unsigned long apc_map;
 	unsigned int escalate_virq;
 	struct {
 		void (*handler)(void *cookie);
diff --git a/include/cobalt/kernel/rtdm/driver.h b/include/cobalt/kernel/rtdm/driver.h
index 581e7a5c0..0d3b5a5d0 100644
--- a/include/cobalt/kernel/rtdm/driver.h
+++ b/include/cobalt/kernel/rtdm/driver.h
@@ -40,7 +40,6 @@
 #include <cobalt/kernel/synch.h>
 #include <cobalt/kernel/select.h>
 #include <cobalt/kernel/clock.h>
-#include <cobalt/kernel/apc.h>
 #include <cobalt/kernel/init.h>
 #include <cobalt/kernel/ancillaries.h>
 #include <cobalt/kernel/tree.h>
diff --git a/kernel/cobalt/ipipe/Makefile b/kernel/cobalt/ipipe/Makefile
index 573b17947..1daa84440 100644
--- a/kernel/cobalt/ipipe/Makefile
+++ b/kernel/cobalt/ipipe/Makefile
@@ -2,4 +2,4 @@ ccflags-y += -I$(srctree)/kernel
 
 obj-y +=	pipeline.o
 
-pipeline-y :=	init.o intr.o kevents.o apc.o tick.o syscall.o
+pipeline-y :=	init.o intr.o kevents.o tick.o syscall.o
diff --git a/kernel/cobalt/ipipe/apc.c b/kernel/cobalt/ipipe/apc.c
deleted file mode 100644
index 715997727..000000000
--- a/kernel/cobalt/ipipe/apc.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright (C) 2007,2012 Philippe Gerum <rpm@xenomai.org>.
- *
- * 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.
- */
-#include <linux/spinlock.h>
-#include <linux/ipipe.h>
-#include <asm/xenomai/machine.h>
-#include <cobalt/kernel/apc.h>
-
-/**
- * @ingroup cobalt_core
- * @defgroup cobalt_core_apc Asynchronous Procedure Calls
- *
- * Services for scheduling function calls in the Linux domain
- *
- * APC is the acronym for Asynchronous Procedure Call, a mean by which
- * activities from the Xenomai domain can schedule deferred
- * invocations of handlers to be run into the Linux domain, as soon as
- * possible when the Linux kernel gets back in control.
- *
- * Up to BITS_PER_LONG APC slots can be active at any point in time.
- *
- * APC support is built upon the interrupt pipeline's virtual
- * interrupt support.
- *
- * @{
- */
-static IPIPE_DEFINE_SPINLOCK(apc_lock);
-
-void apc_dispatch(unsigned int virq, void *arg)
-{
-	void (*handler)(void *), *cookie;
-	unsigned long *p;
-	int apc;
-
-	/*
-	 * CAUTION: The APC dispatch loop is not protected against a
-	 * handler becoming unavailable while processing the pending
-	 * queue; the software must make sure to uninstall all APCs
-	 * before eventually unloading any module that may contain APC
-	 * handlers. We keep the handler affinity with the poster's
-	 * CPU, so that the handler is invoked on the same CPU than
-	 * the code which called xnapc_schedule().
-	 */
-	raw_spin_lock(&apc_lock);
-
-	/* This is atomic linux context (non-threaded IRQ). */
-	p = &raw_cpu_ptr(&cobalt_machine_cpudata)->apc_pending;
-	while (*p) {
-		apc = ffnz(*p);
-		clear_bit(apc, p);
-		handler = cobalt_pipeline.apc_table[apc].handler;
-		cookie = cobalt_pipeline.apc_table[apc].cookie;
-		raw_cpu_ptr(&cobalt_machine_cpudata)->apc_shots[apc]++;
-		raw_spin_unlock(&apc_lock);
-		handler(cookie);
-		raw_spin_lock(&apc_lock);
-	}
-
-	raw_spin_unlock(&apc_lock);
-}
-
-/**
- * @fn int xnapc_alloc(const char *name,void (*handler)(void *cookie),void *cookie)
- *
- * @brief Allocate an APC slot.
- *
- * APC is the acronym for Asynchronous Procedure Call, a mean by which
- * activities from the Xenomai domain can schedule deferred
- * invocations of handlers to be run into the Linux domain, as soon as
- * possible when the Linux kernel gets back in control. Up to
- * BITS_PER_LONG APC slots can be active at any point in time. APC
- * support is built upon the interrupt pipeline's virtual interrupt
- * support.
- *
- * Any Linux kernel service which is callable from a regular Linux
- * interrupt handler is in essence available to APC handlers.
- *
- * @param name is a symbolic name identifying the APC which will get
- * reported through the /proc/xenomai/apc interface. Passing NULL to
- * create an anonymous APC is allowed.
- *
- * @param handler The address of the fault handler to call upon
- * exception condition. The handle will be passed the @a cookie value
- * unmodified.
- *
- * @param cookie A user-defined opaque pointer the APC handler
- * receives as its sole argument.
- *
- * @return a valid APC identifier is returned upon success, or a
- * negative error code otherwise:
- *
- * - -EINVAL is returned if @a handler is invalid.
- *
- * - -EBUSY is returned if no more APC slots are available.
- *
- * @coretags{unrestricted}
- */
-int xnapc_alloc(const char *name,
-		void (*handler)(void *cookie), void *cookie)
-{
-	unsigned long flags;
-	int apc;
-
-	if (handler == NULL)
-		return -EINVAL;
-
-	raw_spin_lock_irqsave(&apc_lock, flags);
-
-	if (cobalt_pipeline.apc_map == ~0) {
-		apc = -EBUSY;
-		goto out;
-	}
-
-	apc = ffz(cobalt_pipeline.apc_map);
-	__set_bit(apc, &cobalt_pipeline.apc_map);
-	cobalt_pipeline.apc_table[apc].handler = handler;
-	cobalt_pipeline.apc_table[apc].cookie = cookie;
-	cobalt_pipeline.apc_table[apc].name = name;
-out:
-	raw_spin_unlock_irqrestore(&apc_lock, flags);
-
-	return apc;
-}
-EXPORT_SYMBOL_GPL(xnapc_alloc);
-
-/**
- * @fn int xnapc_free(int apc)
- *
- * @brief Releases an APC slot.
- *
- * This service deallocates an APC slot obtained by xnapc_alloc().
- *
- * @param apc The APC id. to release, as returned by a successful call
- * to the xnapc_alloc() service.
- *
- * @coretags{unrestricted}
- */
-void xnapc_free(int apc)
-{
-	BUG_ON(apc < 0 || apc >= BITS_PER_LONG);
-	clear_bit(apc, &cobalt_pipeline.apc_map);
-	smp_mb__after_atomic();
-}
-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 d901c417f..d61d150d7 100644
--- a/kernel/cobalt/ipipe/init.c
+++ b/kernel/cobalt/ipipe/init.c
@@ -10,7 +10,6 @@
 #include <linux/ipipe_tickdev.h>
 #include <cobalt/kernel/sched.h>
 #include <cobalt/kernel/clock.h>
-#include <cobalt/kernel/apc.h>
 
 static unsigned long timerfreq_arg;
 module_param_named(timerfreq, timerfreq_arg, ulong, 0444);
@@ -18,8 +17,6 @@ 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;
@@ -53,18 +50,6 @@ int __init pipeline_init(void)
 
 	ipipe_register_head(&xnsched_realtime_domain, "Xenomai");
 
-	ret = -EBUSY;
-	virq = ipipe_alloc_virq();
-	if (virq == 0)
-		goto fail_apc;
-
-	cobalt_pipeline.apc_virq = virq;
-
-	ipipe_request_irq(ipipe_root_domain,
-			  cobalt_pipeline.apc_virq,
-			  apc_dispatch,
-			  NULL, NULL);
-
 	virq = ipipe_alloc_virq();
 	if (virq == 0)
 		goto fail_escalate;
@@ -87,10 +72,6 @@ fail_clock:
 		       cobalt_pipeline.escalate_virq);
 	ipipe_free_virq(cobalt_pipeline.escalate_virq);
 fail_escalate:
-	ipipe_free_irq(ipipe_root_domain,
-		       cobalt_pipeline.apc_virq);
-	ipipe_free_virq(cobalt_pipeline.apc_virq);
-fail_apc:
 	ipipe_unregister_head(&xnsched_realtime_domain);
 
 	if (cobalt_machine.cleanup)
diff --git a/kernel/cobalt/procfs.c b/kernel/cobalt/procfs.c
index c453ee370..0aaf691dd 100644
--- a/kernel/cobalt/procfs.c
+++ b/kernel/cobalt/procfs.c
@@ -18,7 +18,6 @@
  */
 #include <cobalt/kernel/lock.h>
 #include <cobalt/kernel/clock.h>
-#include <cobalt/kernel/apc.h>
 #include <cobalt/kernel/vfile.h>
 #include <cobalt/kernel/intr.h>
 #include <cobalt/kernel/heap.h>
@@ -174,45 +173,6 @@ static struct xnvfile_regular faults_vfile = {
 	.ops = &faults_vfile_ops,
 };
 
-static int apc_vfile_show(struct xnvfile_regular_iterator *it, void *data)
-{
-	int cpu, apc;
-
-	/* We assume the entire output fits in a single page. */
-
-	xnvfile_puts(it, "APC  ");
-
-	for_each_realtime_cpu(cpu)
-		xnvfile_printf(it, "        CPU%d", cpu);
-
-	for (apc = 0; apc < BITS_PER_LONG; apc++) {
-		if (!test_bit(apc, &cobalt_pipeline.apc_map))
-			continue; /* Not hooked. */
-
-		xnvfile_printf(it, "\n%3d: ", apc);
-
-		for_each_realtime_cpu(cpu)
-			xnvfile_printf(it, "%12lu",
-				       per_cpu(cobalt_machine_cpudata, cpu).apc_shots[apc]);
-
-		if (cobalt_pipeline.apc_table[apc].name)
-			xnvfile_printf(it, "    (%s)",
-				       cobalt_pipeline.apc_table[apc].name);
-	}
-
-	xnvfile_putc(it, '\n');
-
-	return 0;
-}
-
-static struct xnvfile_regular_ops apc_vfile_ops = {
-	.show = apc_vfile_show,
-};
-
-static struct xnvfile_regular apc_vfile = {
-	.ops = &apc_vfile_ops,
-};
-
 void xnprocfs_cleanup_tree(void)
 {
 #ifdef CONFIG_XENO_OPT_DEBUG
@@ -221,7 +181,6 @@ void xnprocfs_cleanup_tree(void)
 #endif
 	xnvfile_destroy_dir(&cobalt_debug_vfroot);
 #endif /* XENO_OPT_DEBUG */
-	xnvfile_destroy_regular(&apc_vfile);
 	xnvfile_destroy_regular(&faults_vfile);
 	xnvfile_destroy_regular(&version_vfile);
 	xnvfile_destroy_regular(&latency_vfile);
@@ -250,7 +209,6 @@ int __init xnprocfs_init_tree(void)
 	xnvfile_init_regular("latency", &latency_vfile, &cobalt_vfroot);
 	xnvfile_init_regular("version", &version_vfile, &cobalt_vfroot);
 	xnvfile_init_regular("faults", &faults_vfile, &cobalt_vfroot);
-	xnvfile_init_regular("apc", &apc_vfile, &cobalt_vfroot);
 #ifdef CONFIG_XENO_OPT_DEBUG
 	xnvfile_init_dir("debug", &cobalt_debug_vfroot, &cobalt_vfroot);
 #ifdef CONFIG_XENO_OPT_DEBUG_LOCKING
diff --git a/kernel/cobalt/rtdm/core.c b/kernel/cobalt/rtdm/core.c
index 843193a2b..2e5aeb44e 100644
--- a/kernel/cobalt/rtdm/core.c
+++ b/kernel/cobalt/rtdm/core.c
@@ -26,7 +26,6 @@
 #include <linux/anon_inodes.h>
 #include <cobalt/kernel/ppd.h>
 #include <cobalt/kernel/heap.h>
-#include <cobalt/kernel/apc.h>
 #include "rtdm/internal.h"
 #define CREATE_TRACE_POINTS
 #include <trace/events/cobalt-rtdm.h>
-- 
2.26.2



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

* Re: [PATCH Dovetail 0/4] Get rid of the APC interface
  2021-01-09 16:02 [PATCH Dovetail 0/4] Get rid of the APC interface Philippe Gerum
                   ` (3 preceding siblings ...)
  2021-01-09 16:02 ` [PATCH Dovetail 4/4] cobalt/apc: drop obsolete APC mechanism Philippe Gerum
@ 2021-01-11 12:10 ` Jan Kiszka
  2021-01-11 13:07   ` Philippe Gerum
  4 siblings, 1 reply; 7+ messages in thread
From: Jan Kiszka @ 2021-01-11 12:10 UTC (permalink / raw)
  To: Philippe Gerum, xenomai

On 09.01.21 17:02, Philippe Gerum wrote:
> From: Philippe Gerum <rpm@xenomai.org>
> 
> This patch starts a series aiming at dropping the (functionally
> redundant) APC interface entirely.
> 
> APCs are a relic from the Dark Ages, with no upside compared to open
> coded requests triggering virtual/synthetic IRQs to be handled by the
> root domain. As a matter of fact, an APC does run as a client handler
> of a synthetic IRQ under the hood. In other words, the APC
> encapsulation adds nothing but useless overhead.
> 
> Philippe Gerum (4):
>   cobalt/pipe: drop dependency on APCs
>   cobalt/registry: drop dependency on APCs
>   cobalt/select: drop dependency on APCs
>   cobalt/apc: drop obsolete APC mechanism
> 
>  include/cobalt/kernel/apc.h                   |  32 ---
>  .../cobalt/kernel/ipipe/pipeline/machine.h    |   2 -
>  include/cobalt/kernel/rtdm/driver.h           |   1 -
>  kernel/cobalt/ipipe/Makefile                  |   2 +-
>  kernel/cobalt/ipipe/apc.c                     | 202 ------------------
>  kernel/cobalt/ipipe/init.c                    |  19 --
>  kernel/cobalt/pipe.c                          |  26 ++-
>  kernel/cobalt/procfs.c                        |  42 ----
>  kernel/cobalt/registry.c                      |  30 +--
>  kernel/cobalt/rtdm/core.c                     |   1 -
>  kernel/cobalt/select.c                        |  23 +-
>  11 files changed, 49 insertions(+), 331 deletions(-)
>  delete mode 100644 include/cobalt/kernel/apc.h
>  delete mode 100644 kernel/cobalt/ipipe/apc.c
> 

Would it make sense to introduce the pipeline abstraction of those
services first? Then you won't touch the core code twice, once again for
removing all the ipipe references.

Jan

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


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

* Re: [PATCH Dovetail 0/4] Get rid of the APC interface
  2021-01-11 12:10 ` [PATCH Dovetail 0/4] Get rid of the APC interface Jan Kiszka
@ 2021-01-11 13:07   ` Philippe Gerum
  0 siblings, 0 replies; 7+ messages in thread
From: Philippe Gerum @ 2021-01-11 13:07 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: xenomai


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

> On 09.01.21 17:02, Philippe Gerum wrote:
>> From: Philippe Gerum <rpm@xenomai.org>
>> 
>> This patch starts a series aiming at dropping the (functionally
>> redundant) APC interface entirely.
>> 
>> APCs are a relic from the Dark Ages, with no upside compared to open
>> coded requests triggering virtual/synthetic IRQs to be handled by the
>> root domain. As a matter of fact, an APC does run as a client handler
>> of a synthetic IRQ under the hood. In other words, the APC
>> encapsulation adds nothing but useless overhead.
>> 
>> Philippe Gerum (4):
>>   cobalt/pipe: drop dependency on APCs
>>   cobalt/registry: drop dependency on APCs
>>   cobalt/select: drop dependency on APCs
>>   cobalt/apc: drop obsolete APC mechanism
>> 
>>  include/cobalt/kernel/apc.h                   |  32 ---
>>  .../cobalt/kernel/ipipe/pipeline/machine.h    |   2 -
>>  include/cobalt/kernel/rtdm/driver.h           |   1 -
>>  kernel/cobalt/ipipe/Makefile                  |   2 +-
>>  kernel/cobalt/ipipe/apc.c                     | 202 ------------------
>>  kernel/cobalt/ipipe/init.c                    |  19 --
>>  kernel/cobalt/pipe.c                          |  26 ++-
>>  kernel/cobalt/procfs.c                        |  42 ----
>>  kernel/cobalt/registry.c                      |  30 +--
>>  kernel/cobalt/rtdm/core.c                     |   1 -
>>  kernel/cobalt/select.c                        |  23 +-
>>  11 files changed, 49 insertions(+), 331 deletions(-)
>>  delete mode 100644 include/cobalt/kernel/apc.h
>>  delete mode 100644 kernel/cobalt/ipipe/apc.c
>> 
>
> Would it make sense to introduce the pipeline abstraction of those
> services first? Then you won't touch the core code twice, once again for
> removing all the ipipe references.
>

I'd rather do it the way it is: first we prove that there is no
regression in open coding APCs based on virtual IRQs, then we do a 1:1
mapping from the I-pipe virtual IRQs to Dovetail's synthetic IRQs which
have the very same semantics.

-- 
Philippe.


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

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

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-09 16:02 [PATCH Dovetail 0/4] Get rid of the APC interface Philippe Gerum
2021-01-09 16:02 ` [PATCH Dovetail 1/4] cobalt/pipe: drop dependency on APCs Philippe Gerum
2021-01-09 16:02 ` [PATCH Dovetail 2/4] cobalt/registry: " Philippe Gerum
2021-01-09 16:02 ` [PATCH Dovetail 3/4] cobalt/select: " Philippe Gerum
2021-01-09 16:02 ` [PATCH Dovetail 4/4] cobalt/apc: drop obsolete APC mechanism Philippe Gerum
2021-01-11 12:10 ` [PATCH Dovetail 0/4] Get rid of the APC interface Jan Kiszka
2021-01-11 13:07   ` Philippe Gerum

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.