* [PATCH 1/4] cobalt/kernel: pipeline: add abstract synthetic IRQ API
@ 2021-01-17 15:25 Philippe Gerum
2021-01-17 15:25 ` [PATCH 2/4] cobalt/pipe: pipeline: convert to " Philippe Gerum
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Philippe Gerum @ 2021-01-17 15:25 UTC (permalink / raw)
To: xenomai
From: Philippe Gerum <rpm@xenomai.org>
Add wrappers to create "synthetic IRQs" the I-pipe way (used to be
called "virtual IRQs" there). Those interrupt channels can only be
triggered by software, with per-CPU semantics. We use them to schedule
handlers to be run on the in-band execution stage, meaning "secondary
mode" in the Cobalt jargon.
We don't provide for executing handlers on the out-of-band stage,
because Cobalt does not need this.
Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
include/cobalt/kernel/ipipe/pipeline/sirq.h | 58 +++++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 include/cobalt/kernel/ipipe/pipeline/sirq.h
diff --git a/include/cobalt/kernel/ipipe/pipeline/sirq.h b/include/cobalt/kernel/ipipe/pipeline/sirq.h
new file mode 100644
index 000000000..7c39244f9
--- /dev/null
+++ b/include/cobalt/kernel/ipipe/pipeline/sirq.h
@@ -0,0 +1,58 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2020 Philippe Gerum <rpm@xenomai.org>
+ */
+
+#ifndef _COBALT_KERNEL_IPIPE_SIRQ_H
+#define _COBALT_KERNEL_IPIPE_SIRQ_H
+
+#include <linux/ipipe.h>
+#include <pipeline/machine.h>
+
+/*
+ * Wrappers to create "synthetic IRQs" the I-pipe way (used to be
+ * called "virtual IRQs" there). Those interrupt channels can only be
+ * triggered by software; they have per-CPU semantics. We use them to
+ * schedule handlers to be run on the in-band execution stage, meaning
+ * "secondary mode" in the Cobalt jargon.
+ */
+
+static inline
+int pipeline_create_inband_sirq(irqreturn_t (*handler)(int irq, void *dev_id))
+{
+ int sirq = ipipe_alloc_virq(), ret;
+
+ if (sirq == 0)
+ return -EAGAIN;
+
+ /*
+ * ipipe_irq_handler_t is close enough to the signature of a
+ * regular IRQ handler: use the latter in the generic code
+ * shared with Dovetail. The extraneous return code will be
+ * ignored by the I-pipe core.
+ */
+ ret = ipipe_request_irq(ipipe_root_domain, sirq,
+ (ipipe_irq_handler_t)handler,
+ NULL, NULL);
+ if (ret) {
+ ipipe_free_virq(sirq);
+ return ret;
+ }
+
+ return sirq;
+}
+
+static inline
+void pipeline_delete_inband_sirq(int sirq)
+{
+ ipipe_free_irq(ipipe_root_domain, sirq);
+ ipipe_free_virq(sirq);
+}
+
+static inline void pipeline_post_sirq(int sirq)
+{
+ ipipe_post_irq_root(sirq);
+}
+
+#endif /* !_COBALT_KERNEL_IPIPE_SIRQ_H */
--
2.26.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] cobalt/pipe: pipeline: convert to abstract synthetic IRQ API
2021-01-17 15:25 [PATCH 1/4] cobalt/kernel: pipeline: add abstract synthetic IRQ API Philippe Gerum
@ 2021-01-17 15:25 ` Philippe Gerum
2021-01-17 15:25 ` [PATCH 3/4] cobalt/registry: " Philippe Gerum
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Philippe Gerum @ 2021-01-17 15:25 UTC (permalink / raw)
To: xenomai
From: Philippe Gerum <rpm@xenomai.org>
Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
kernel/cobalt/pipe.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/kernel/cobalt/pipe.c b/kernel/cobalt/pipe.c
index 8044c3ff7..9465fb2da 100644
--- a/kernel/cobalt/pipe.c
+++ b/kernel/cobalt/pipe.c
@@ -32,6 +32,7 @@
#include <cobalt/kernel/sched.h>
#include <cobalt/kernel/heap.h>
#include <cobalt/kernel/pipe.h>
+#include <pipeline/sirq.h>
static int xnpipe_asyncsig = SIGIO;
@@ -145,7 +146,7 @@ static inline void xnpipe_dequeue_all(struct xnpipe_state *state, int mask)
__sigpending; \
})
-static void xnpipe_wakeup_proc(unsigned int virq, void *arg)
+static irqreturn_t xnpipe_wakeup_proc(int sirq, void *dev_id)
{
struct xnpipe_state *state;
unsigned long rbits;
@@ -219,11 +220,13 @@ check_async:
}
out:
xnlock_put_irqrestore(&nklock, s);
+
+ return IRQ_HANDLED;
}
static inline void xnpipe_schedule_request(void) /* hw IRQs off */
{
- ipipe_post_irq_root(xnpipe_wakeup_virq);
+ pipeline_post_sirq(xnpipe_wakeup_virq);
}
static inline ssize_t xnpipe_flush_bufq(void (*fn)(void *buf, void *xstate),
@@ -1157,17 +1160,13 @@ int xnpipe_mount(void)
return -EBUSY;
}
- xnpipe_wakeup_virq = ipipe_alloc_virq();
- if (xnpipe_wakeup_virq == 0) {
+ xnpipe_wakeup_virq = pipeline_create_inband_sirq(xnpipe_wakeup_proc);
+ if (xnpipe_wakeup_virq < 0) {
printk(XENO_ERR
"unable to reserve synthetic IRQ for message pipes\n");
- return -EBUSY;
+ return xnpipe_wakeup_virq;
}
- ipipe_request_irq(ipipe_root_domain,
- xnpipe_wakeup_virq,
- xnpipe_wakeup_proc,
- NULL, NULL);
return 0;
}
@@ -1175,9 +1174,7 @@ void xnpipe_umount(void)
{
int i;
- ipipe_free_irq(ipipe_root_domain,
- xnpipe_wakeup_virq);
- ipipe_free_virq(xnpipe_wakeup_virq);
+ pipeline_delete_inband_sirq(xnpipe_wakeup_virq);
unregister_chrdev(XNPIPE_DEV_MAJOR, "rtpipe");
--
2.26.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] cobalt/registry: pipeline: convert to abstract synthetic IRQ API
2021-01-17 15:25 [PATCH 1/4] cobalt/kernel: pipeline: add abstract synthetic IRQ API Philippe Gerum
2021-01-17 15:25 ` [PATCH 2/4] cobalt/pipe: pipeline: convert to " Philippe Gerum
@ 2021-01-17 15:25 ` Philippe Gerum
2021-01-17 15:25 ` [PATCH 4/4] cobalt/select: " Philippe Gerum
2021-01-19 13:54 ` [PATCH 1/4] cobalt/kernel: pipeline: add " Jan Kiszka
3 siblings, 0 replies; 6+ messages in thread
From: Philippe Gerum @ 2021-01-17 15:25 UTC (permalink / raw)
To: xenomai
From: Philippe Gerum <rpm@xenomai.org>
Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
kernel/cobalt/registry.c | 28 ++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/kernel/cobalt/registry.c b/kernel/cobalt/registry.c
index 7f7cb9eea..816102f7a 100644
--- a/kernel/cobalt/registry.c
+++ b/kernel/cobalt/registry.c
@@ -22,6 +22,7 @@
#include <cobalt/kernel/registry.h>
#include <cobalt/kernel/thread.h>
#include <cobalt/kernel/assert.h>
+#include <pipeline/sirq.h>
/**
* @ingroup cobalt_core
@@ -61,7 +62,7 @@ static struct xnsynch register_synch;
static void proc_callback(struct work_struct *work);
-static void registry_proc_schedule(unsigned int virq, void *arg);
+static irqreturn_t registry_proc_schedule(int virq, void *dev_id);
static LIST_HEAD(proc_object_list); /* Objects waiting for /proc handling. */
@@ -123,17 +124,12 @@ int xnregistry_init(void)
return ret;
}
- proc_virq = ipipe_alloc_virq();
- if (proc_virq == 0) {
+ proc_virq = pipeline_create_inband_sirq(registry_proc_schedule);
+ if (proc_virq < 0) {
xnvfile_destroy_regular(&usage_vfile);
xnvfile_destroy_dir(®istry_vfroot);
- return -EBUSY;
+ return proc_virq;
}
-
- ipipe_request_irq(ipipe_root_domain,
- proc_virq,
- registry_proc_schedule,
- NULL, NULL);
#endif /* CONFIG_XENO_OPT_VFILE */
next_object_stamp = 0;
@@ -155,8 +151,7 @@ int xnregistry_init(void)
#ifdef CONFIG_XENO_OPT_VFILE
xnvfile_destroy_regular(&usage_vfile);
xnvfile_destroy_dir(®istry_vfroot);
- ipipe_free_irq(ipipe_root_domain, proc_virq);
- ipipe_free_virq(proc_virq);
+ pipeline_delete_inband_sirq(proc_virq);
#endif /* CONFIG_XENO_OPT_VFILE */
return -ENOMEM;
}
@@ -202,8 +197,7 @@ void xnregistry_cleanup(void)
xnsynch_destroy(®ister_synch);
#ifdef CONFIG_XENO_OPT_VFILE
- ipipe_free_irq(ipipe_root_domain, proc_virq);
- ipipe_free_virq(proc_virq);
+ pipeline_delete_inband_sirq(proc_virq);
flush_scheduled_work();
xnvfile_destroy_regular(&usage_vfile);
xnvfile_destroy_dir(®istry_vfroot);
@@ -332,13 +326,15 @@ static void proc_callback(struct work_struct *work)
up(&export_mutex);
}
-static void registry_proc_schedule(unsigned int virq, void *arg)
+static irqreturn_t registry_proc_schedule(int virq, void *dev_id)
{
/*
* schedule_work() will check for us if the work has already
* been scheduled, so just be lazy and submit blindly.
*/
schedule_work(®istry_proc_work);
+
+ return IRQ_HANDLED;
}
static int registry_export_vfsnap(struct xnobject *object,
@@ -473,7 +469,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);
- ipipe_post_irq_root(proc_virq);
+ pipeline_post_sirq(proc_virq);
}
static inline void registry_unexport_pnode(struct xnobject *object)
@@ -489,7 +485,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);
- ipipe_post_irq_root(proc_virq);
+ pipeline_post_sirq(proc_virq);
} else {
/*
* Unexporting before the lower stage has had a chance
--
2.26.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] cobalt/select: pipeline: convert to abstract synthetic IRQ API
2021-01-17 15:25 [PATCH 1/4] cobalt/kernel: pipeline: add abstract synthetic IRQ API Philippe Gerum
2021-01-17 15:25 ` [PATCH 2/4] cobalt/pipe: pipeline: convert to " Philippe Gerum
2021-01-17 15:25 ` [PATCH 3/4] cobalt/registry: " Philippe Gerum
@ 2021-01-17 15:25 ` Philippe Gerum
2021-01-19 13:55 ` Jan Kiszka
2021-01-19 13:54 ` [PATCH 1/4] cobalt/kernel: pipeline: add " Jan Kiszka
3 siblings, 1 reply; 6+ messages in thread
From: Philippe Gerum @ 2021-01-17 15:25 UTC (permalink / raw)
To: xenomai
From: Philippe Gerum <rpm@xenomai.org>
Signed-off-by: Philippe Gerum <rpm@xenomai.org>
---
kernel/cobalt/select.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/kernel/cobalt/select.c b/kernel/cobalt/select.c
index f45905112..bd790affe 100644
--- a/kernel/cobalt/select.c
+++ b/kernel/cobalt/select.c
@@ -23,6 +23,7 @@
#include <cobalt/kernel/sched.h>
#include <cobalt/kernel/synch.h>
#include <cobalt/kernel/select.h>
+#include <pipeline/sirq.h>
/**
* @ingroup cobalt_core
@@ -398,12 +399,12 @@ void xnselector_destroy(struct xnselector *selector)
xnlock_get_irqsave(&nklock, s);
list_add_tail(&selector->destroy_link, &selector_list);
- ipipe_post_irq_root(deletion_virq);
+ pipeline_post_sirq(deletion_virq);
xnlock_put_irqrestore(&nklock, s);
}
EXPORT_SYMBOL_GPL(xnselector_destroy);
-static void xnselector_destroy_loop(unsigned int virq, void *arg)
+static irqreturn_t xnselector_destroy_loop(int virq, void *dev_id)
{
struct xnselect_binding *binding, *tmpb;
struct xnselector *selector, *tmps;
@@ -438,25 +439,22 @@ static void xnselector_destroy_loop(unsigned int virq, void *arg)
}
out:
xnlock_put_irqrestore(&nklock, s);
+
+ return IRQ_HANDLED;
}
int xnselect_mount(void)
{
- deletion_virq = ipipe_alloc_virq();
- if (deletion_virq == 0)
- return -EBUSY;
-
- ipipe_request_irq(ipipe_root_domain,
- deletion_virq,
- xnselector_destroy_loop,
- NULL, NULL);
+ deletion_virq = pipeline_create_inband_sirq(xnselector_destroy_loop);
+ if (deletion_virq < 0)
+ return deletion_virq;
+
return 0;
}
int xnselect_umount(void)
{
- ipipe_free_irq(ipipe_root_domain, deletion_virq);
- ipipe_free_virq(deletion_virq);
+ pipeline_delete_inband_sirq(deletion_virq);
return 0;
}
--
2.26.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/4] cobalt/kernel: pipeline: add abstract synthetic IRQ API
2021-01-17 15:25 [PATCH 1/4] cobalt/kernel: pipeline: add abstract synthetic IRQ API Philippe Gerum
` (2 preceding siblings ...)
2021-01-17 15:25 ` [PATCH 4/4] cobalt/select: " Philippe Gerum
@ 2021-01-19 13:54 ` Jan Kiszka
3 siblings, 0 replies; 6+ messages in thread
From: Jan Kiszka @ 2021-01-19 13:54 UTC (permalink / raw)
To: Philippe Gerum, xenomai
On 17.01.21 16:25, Philippe Gerum wrote:
> From: Philippe Gerum <rpm@xenomai.org>
>
> Add wrappers to create "synthetic IRQs" the I-pipe way (used to be
> called "virtual IRQs" there). Those interrupt channels can only be
> triggered by software, with per-CPU semantics. We use them to schedule
> handlers to be run on the in-band execution stage, meaning "secondary
> mode" in the Cobalt jargon.
>
> We don't provide for executing handlers on the out-of-band stage,
> because Cobalt does not need this.
>
> Signed-off-by: Philippe Gerum <rpm@xenomai.org>
> ---
> include/cobalt/kernel/ipipe/pipeline/sirq.h | 58 +++++++++++++++++++++
> 1 file changed, 58 insertions(+)
> create mode 100644 include/cobalt/kernel/ipipe/pipeline/sirq.h
>
> diff --git a/include/cobalt/kernel/ipipe/pipeline/sirq.h b/include/cobalt/kernel/ipipe/pipeline/sirq.h
> new file mode 100644
> index 000000000..7c39244f9
> --- /dev/null
> +++ b/include/cobalt/kernel/ipipe/pipeline/sirq.h
> @@ -0,0 +1,58 @@
> +/*
> + * SPDX-License-Identifier: GPL-2.0
> + *
> + * Copyright (C) 2020 Philippe Gerum <rpm@xenomai.org>
> + */
> +
> +#ifndef _COBALT_KERNEL_IPIPE_SIRQ_H
> +#define _COBALT_KERNEL_IPIPE_SIRQ_H
> +
> +#include <linux/ipipe.h>
> +#include <pipeline/machine.h>
> +
> +/*
> + * Wrappers to create "synthetic IRQs" the I-pipe way (used to be
> + * called "virtual IRQs" there). Those interrupt channels can only be
> + * triggered by software; they have per-CPU semantics. We use them to
> + * schedule handlers to be run on the in-band execution stage, meaning
> + * "secondary mode" in the Cobalt jargon.
> + */
> +
> +static inline
> +int pipeline_create_inband_sirq(irqreturn_t (*handler)(int irq, void *dev_id))
> +{
> + int sirq = ipipe_alloc_virq(), ret;
Correct but uncommon style. I've broken that up into two lines.
Jan
> +
> + if (sirq == 0)
> + return -EAGAIN;
> +
> + /*
> + * ipipe_irq_handler_t is close enough to the signature of a
> + * regular IRQ handler: use the latter in the generic code
> + * shared with Dovetail. The extraneous return code will be
> + * ignored by the I-pipe core.
> + */
> + ret = ipipe_request_irq(ipipe_root_domain, sirq,
> + (ipipe_irq_handler_t)handler,
> + NULL, NULL);
> + if (ret) {
> + ipipe_free_virq(sirq);
> + return ret;
> + }
> +
> + return sirq;
> +}
> +
> +static inline
> +void pipeline_delete_inband_sirq(int sirq)
> +{
> + ipipe_free_irq(ipipe_root_domain, sirq);
> + ipipe_free_virq(sirq);
> +}
> +
> +static inline void pipeline_post_sirq(int sirq)
> +{
> + ipipe_post_irq_root(sirq);
> +}
> +
> +#endif /* !_COBALT_KERNEL_IPIPE_SIRQ_H */
>
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 4/4] cobalt/select: pipeline: convert to abstract synthetic IRQ API
2021-01-17 15:25 ` [PATCH 4/4] cobalt/select: " Philippe Gerum
@ 2021-01-19 13:55 ` Jan Kiszka
0 siblings, 0 replies; 6+ messages in thread
From: Jan Kiszka @ 2021-01-19 13:55 UTC (permalink / raw)
To: Philippe Gerum, xenomai
On 17.01.21 16:25, Philippe Gerum wrote:
> From: Philippe Gerum <rpm@xenomai.org>
>
> Signed-off-by: Philippe Gerum <rpm@xenomai.org>
> ---
> kernel/cobalt/select.c | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/kernel/cobalt/select.c b/kernel/cobalt/select.c
> index f45905112..bd790affe 100644
> --- a/kernel/cobalt/select.c
> +++ b/kernel/cobalt/select.c
> @@ -23,6 +23,7 @@
> #include <cobalt/kernel/sched.h>
> #include <cobalt/kernel/synch.h>
> #include <cobalt/kernel/select.h>
> +#include <pipeline/sirq.h>
>
> /**
> * @ingroup cobalt_core
> @@ -398,12 +399,12 @@ void xnselector_destroy(struct xnselector *selector)
>
> xnlock_get_irqsave(&nklock, s);
> list_add_tail(&selector->destroy_link, &selector_list);
> - ipipe_post_irq_root(deletion_virq);
> + pipeline_post_sirq(deletion_virq);
> xnlock_put_irqrestore(&nklock, s);
> }
> EXPORT_SYMBOL_GPL(xnselector_destroy);
>
> -static void xnselector_destroy_loop(unsigned int virq, void *arg)
> +static irqreturn_t xnselector_destroy_loop(int virq, void *dev_id)
> {
> struct xnselect_binding *binding, *tmpb;
> struct xnselector *selector, *tmps;
> @@ -438,25 +439,22 @@ static void xnselector_destroy_loop(unsigned int virq, void *arg)
> }
> out:
> xnlock_put_irqrestore(&nklock, s);
> +
> + return IRQ_HANDLED;
> }
>
> int xnselect_mount(void)
> {
> - deletion_virq = ipipe_alloc_virq();
> - if (deletion_virq == 0)
> - return -EBUSY;
> -
> - ipipe_request_irq(ipipe_root_domain,
> - deletion_virq,
> - xnselector_destroy_loop,
> - NULL, NULL);
> + deletion_virq = pipeline_create_inband_sirq(xnselector_destroy_loop);
> + if (deletion_virq < 0)
> + return deletion_virq;
> +
> return 0;
> }
>
> int xnselect_umount(void)
> {
> - ipipe_free_irq(ipipe_root_domain, deletion_virq);
> - ipipe_free_virq(deletion_virq);
> + pipeline_delete_inband_sirq(deletion_virq);
> return 0;
> }
>
>
Thanks, all 4 applied.
Jan
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-01-19 13:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-17 15:25 [PATCH 1/4] cobalt/kernel: pipeline: add abstract synthetic IRQ API Philippe Gerum
2021-01-17 15:25 ` [PATCH 2/4] cobalt/pipe: pipeline: convert to " Philippe Gerum
2021-01-17 15:25 ` [PATCH 3/4] cobalt/registry: " Philippe Gerum
2021-01-17 15:25 ` [PATCH 4/4] cobalt/select: " Philippe Gerum
2021-01-19 13:55 ` Jan Kiszka
2021-01-19 13:54 ` [PATCH 1/4] cobalt/kernel: pipeline: add " 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.