From: "Richard Weinberger (sigma star gmbh)" <rw@kernel.org>
To: xenomai@lists.linux.dev
Cc: upstream+xenomai@sigma-star.at, Richard Weinberger <richard@nod.at>
Subject: [PATCH 5/7] lib/alchemy/event: Require a Xenomai task only for waiting over Mercury
Date: Wed, 25 Nov 2026 22:34:17 +0100 [thread overview]
Message-ID: <20261125213419.2363742-6-rw@kernel.org> (raw)
In-Reply-To: <20261125213419.2363742-1-rw@kernel.org>
From: Richard Weinberger <richard@nod.at>
Over Cobalt, rt_event_wait*() is based on a Cobalt event which any
Cobalt thread may wait for. Only the Mercury implementation needs a
Copperplate TCB, and only when actually waiting. Move the check there
and keep rejecting blocking calls from asynchronous contexts.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
lib/alchemy/event.c | 10 +++++-----
lib/copperplate/eventobj.c | 5 +++++
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/lib/alchemy/event.c b/lib/alchemy/event.c
index 8428db539..c08b224c7 100644
--- a/lib/alchemy/event.c
+++ b/lib/alchemy/event.c
@@ -378,10 +378,10 @@ out:
* sleeping on it. In such a case, @a event is no more valid upon
* return of this service.
*
- * - -EPERM is returned if this service was not called from a Xenomai
- * task, unless @a abs_timeout is { .tv_sec = 0, .tv_nsec = 0 }. Over
- * Cobalt, this error is also returned if the caller is not a Xenomai
- * thread.
+ * - -EPERM is returned if this service should block, but was called
+ * from an asynchronous context, or over Mercury not from a Xenomai
+ * task. Over Cobalt, this error is also returned if the caller is not
+ * a Xenomai thread.
*
* @apitags{xthread-nowait, switch-primary}
*/
@@ -393,7 +393,7 @@ int rt_event_wait_timed(RT_EVENT *event,
struct alchemy_event *evcb;
struct service svc;
- if (!threadobj_current_p() && !alchemy_poll_mode(abs_timeout))
+ if (threadobj_irq_p() && !alchemy_poll_mode(abs_timeout))
return -EPERM;
if (mode & ~EVOBJ_ANY)
diff --git a/lib/copperplate/eventobj.c b/lib/copperplate/eventobj.c
index 28b7c167f..c5a726a89 100644
--- a/lib/copperplate/eventobj.c
+++ b/lib/copperplate/eventobj.c
@@ -229,6 +229,11 @@ int eventobj_wait(struct eventobj *evobj,
goto done;
}
+ if (!threadobj_current_p()) {
+ ret = -EPERM;
+ goto done;
+ }
+
wait = threadobj_prepare_wait(struct eventobj_wait_struct);
wait->value = bits;
wait->mode = mode;
--
2.55.0
next prev parent reply other threads:[~2026-11-25 21:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 21:34 [PATCH 0/7] Alchemy: Fix calling context checks and documentation Richard Weinberger (sigma star gmbh)
2026-11-25 21:34 ` [PATCH 1/7] lib/alchemy/mutex: Allow any Xenomai thread to acquire a mutex Richard Weinberger (sigma star gmbh)
2026-11-26 6:14 ` Jan Kiszka
2026-11-26 7:53 ` Richard Weinberger
2026-11-25 21:34 ` [PATCH 2/7] lib/alchemy/task: Allow rt_task_yield() from any thread Richard Weinberger (sigma star gmbh)
2026-11-25 21:34 ` [PATCH 3/7] lib/alchemy: Document the actual calling context requirements Richard Weinberger (sigma star gmbh)
2026-11-25 21:34 ` [PATCH 4/7] lib/alchemy/pipe: Do not require a Xenomai task for blocking reads Richard Weinberger (sigma star gmbh)
2026-11-25 21:34 ` Richard Weinberger (sigma star gmbh) [this message]
2026-11-25 21:34 ` [PATCH 6/7] lib/alchemy: Require a Xenomai task only when actually waiting Richard Weinberger (sigma star gmbh)
2026-11-26 6:09 ` Jan Kiszka
2026-11-25 21:34 ` [PATCH 7/7] testsuite/smokey/alchemytests: Test Alchemy services from POSIX threads Richard Weinberger (sigma star gmbh)
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=20261125213419.2363742-6-rw@kernel.org \
--to=rw@kernel.org \
--cc=richard@nod.at \
--cc=upstream+xenomai@sigma-star.at \
--cc=xenomai@lists.linux.dev \
/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.