From: Philippe Gerum <rpm@xenomai.org>
To: Russell Johnson <russell.johnson@kratosdefense.com>
Cc: "xenomai@lists.linux.dev" <xenomai@lists.linux.dev>
Subject: Re: Interrupts
Date: Mon, 20 Jun 2022 17:42:32 +0200 [thread overview]
Message-ID: <87pmj3iaz3.fsf@xenomai.org> (raw)
In-Reply-To: <PH1P110MB1050B18C8CE66B077B50B31CE2B09@PH1P110MB1050.NAMP110.PROD.OUTLOOK.COM>
Russell Johnson <russell.johnson@kratosdefense.com> writes:
> [[S/MIME Signed Part:Undecided]]
>> The recommended way with EVL is to follow the common patterns used for
>
>> developing regular linux drivers, except that the EVL kernel API must be
>
>> used instead of the regular/in-band kernel API for anything which wants
>
>> to synchronize threads over the oob stage.
>
>>
>
>
>
>> Typically, you could share an EVL semaphore [1] or an event flag group
>
>> [2] between the interrupt handler and the oob_ioctl() or oob_read()
>
>> call, which would block the user-space task until the matching event
>
>> happens. To monitor complex events, you could use an EVL wait queue
>
>> instead of a semaphore or a flag.
>
>>
>
>
>
>> If you need to monitor multiple event sources in userland, you can use
>
>> the EVL poll API [4] with the file descriptors you would otherwise pass
>
>> to the oob_{ioctl, read, write}() calls.
>
>>
>
>
>
>> [1] https://evlproject.org/core/user-api/semaphore/
>
>> [2] https://evlproject.org/core/user-api/flags/
>
>> [3] https://evlproject.org/core/kernel-api/wait/
>
>> [4] https://evlproject.org/core/user-api/poll/
>
>>
>
>
>
>> --
>
>> Philippe.
>
>
>
> If I create an EVL semaphore or event flag group on the userspace side (using the libevl API), how would I go about passing a reference to that down to the kernel driver (through ioctl)? Wouldn’t the kernel driver need to know what a “struct evl_sem” or a “struct evl_flags” is? But those are defined in the libevl usersapce API and the kernel does not have access to those headers from what I can see.
>
>
>
You could export the file structure of a userland object to a kernel
driver, but this is not the recommended way, especially since this would
require to deal with the lifetime of those objects using the internal
EVL API in kernel space.
The proper way for an application is to create a kernel semaphore/flag,
post it from kernel space (e.g. from an interrupt handler), pend on it
from an oob_ioctl/oob_read handler typically.
The sequence would be as follows:
1. the user task issues oob_ioctl(fd, IOC_WAIT_FOO) or oob_read(fd),
which invokes the corresponding oob_ioctl and/or oob_read handlers in
the kernel driver.
2. Those handlers call e.g. evl_down() on the kernel sem, which the
interrupt handler can post using evl_up() at some point in order to
signal the event. Conversely, the user task would wait for such event,
sleeping in kernel context until it occurs.
--
Philippe.
next prev parent reply other threads:[~2022-06-20 15:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 15:17 Interrupts Russell Johnson
2022-06-20 15:42 ` Philippe Gerum [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-06-17 19:23 Interrupts Russell Johnson
2022-06-18 8:44 ` Interrupts Philippe Gerum
[not found] <D6CF33887D864426B02D21261537559B@ChuckPC>
2010-09-17 16:42 ` interrupts Luis R. Rodriguez
2010-09-17 17:39 ` interrupts Christian Lamparter
2007-04-01 15:05 Interrupts Guy Zana
2004-03-15 3:22 Interrupts Nishant Nagalia
2004-03-15 5:51 ` Interrupts Zwane Mwaikambo
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=87pmj3iaz3.fsf@xenomai.org \
--to=rpm@xenomai.org \
--cc=russell.johnson@kratosdefense.com \
--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.