From: Mirek23 <miroslaw.dach@psi.ch>
To: linuxppc-embedded@ozlabs.org
Subject: Re: signals handling in the kernel
Date: Thu, 30 Aug 2007 08:23:27 -0700 (PDT) [thread overview]
Message-ID: <12409543.post@talk.nabble.com> (raw)
In-Reply-To: <46B9FB23.8040903@ovro.caltech.edu>
Hi David,
I went throught the Rubini book about device drivers and I see that
you are absolutly right about
the way how to handle interrupts in the user space.
When I find a bit of time I will try your first suggestion with read() which
bolckes in the user space and
waits forr ISR to write data to the buffer.
Many thanks for all your suggestions
Best Regards
Mirek
David Hawkins-3 wrote:
>
> Hi Mirek,
>
>> I run embedded Linux on ppc405 (ml403 xilinx evaluation board).
>> I use the GPIO based device build on FPGA part of the xilinx
>> chip. My gpio device generates interrupts whenever it changes
>> its state.
>>
>> I use Montavista gpio driver with some modifications to react
>> on interrupts. Each time when interrupt occurs the interrupt
>> handler routine is called. This routine sends the signal to the
>> application in user space to trigger it. When the application
>> is triggered it reads the data from the GPIO device.
>>
>> I read that in this situation the best is to use signals. In my
>> case the ideal would be to use kill_proc_info which sends to the
>> application the Signal with info data were I intended to put just
>> one integer value. Such a value determines how to react for the
>> signal on the application level.
>
> Signals are not the appropriate solution.
>
> It sounds like your application is read-only, so how about
> the following use-cases for the driver:
>
> 1. In user-space, you only have one GPIO, and the code
> only needs to react in response to this one I/O port.
> The information required by user-space is the 1-byte
> (or 2, or 4) of GPIO
>
> Solution:
> The driver implements a buffer that a user-space read() call
> consumes. A user-space read() call blocks until there is
> data in the buffer.
>
> The driver ISR reads the GPIO port, and writes the
> contents to the buffer.
>
> 2. In user-space, you have multiple GPIO ports, and
> the code needs to respond to any one.
>
> Solution:
> The driver implements the poll() call back so that
> user-space can call select() on the multiple GPIO
> file descriptors.
>
> Again, the driver ISR reads the different GPIO ports,
> and writes the data to the GPIO specific buffer.
>
> I have plenty of driver code lying around, and can point
> you to an example that implements both of these options.
> The driver easily supports both (1) and (2) since
> (1) is just a blocking-read, and (2) is poll().
>
> Is the kernel 2.4 or 2.6? Here's some code I wrote for
> 2.6, and this code was ported from some 2.4 drivers
> (and I still have that code in CVS)
>
> http://www.ovro.caltech.edu/~dwh/correlator/cobra_docs.html
> http://www.ovro.caltech.edu/~dwh/correlator/software/driver_design.tar.gz
> http://www.ovro.caltech.edu/~dwh/correlator/pdf/LNX-762-Hawkins.pdf
>
> I can re-write say the parallel port example to demonstrate
> how the value of the GPIO port (the parallel port) can be
> sent to user space. There's a parallel port interrupt
> example in there somewhere. I know I wrote a GPIO driver
> for my Yosemite board (440EP example), but I don't see it
> in that zip ... it must be lying around here somewhere :)
>
> I wouldn't necessarily copy say a parallel port example
> verbatim, since there is only ever one of those devices
> in a system. There are more likely to be multiple GPIO ports,
> so the driver design would be generalized a little more.
> Look at the COBRA driver code. I have crates of cPCI equipment
> loaded with 10s of boards, with each board having multiple
> device nodes, transferring megabytes per second over
> multiple cPCI crates :)
>
> Anyway, stop thinking about signals, they'll just mess you up.
>
> Oh, the driver will also support sending SIGIO to the process,
> via the fasync() driver call, so you can try signals, and
> convince yourself that select() is much nicer.
>
> A GPIO driver seems like such an obvious thing to write. Are
> you sure the montavista driver doesn't already support these
> features? I have no idea of your experience with coding, so
> it could just be that you are unaware of what the driver
> implements. If you are allowed to post it, go ahead, and
> I'll comment on its features.
>
> Cheers
> Dave
>
>
>
>
>
>
>
>
> _______________________________________________
> Linuxppc-embedded mailing list
> Linuxppc-embedded@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-embedded
>
>
--
View this message in context: http://www.nabble.com/signals-handling-in-the-kernel-tf4229566.html#a12409543
Sent from the linuxppc-embedded mailing list archive at Nabble.com.
next prev parent reply other threads:[~2007-08-30 15:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-07 11:32 signals handling in the kernel Mirek23
2007-08-07 16:54 ` David Hawkins
2007-08-07 18:31 ` David Hawkins
2007-08-08 7:32 ` Mirek23
2007-08-08 17:19 ` David Hawkins
2007-08-30 15:23 ` Mirek23 [this message]
2007-08-30 15:57 ` David Hawkins
2007-08-08 8:15 ` Mirek23
2007-08-09 13:47 ` Detlev Zundel
2007-08-20 11:49 ` Mirek23
2007-08-20 16:53 ` David Hawkins
2007-08-23 10:57 ` Mirek23
2007-08-23 16:32 ` David Hawkins
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=12409543.post@talk.nabble.com \
--to=miroslaw.dach@psi.ch \
--cc=linuxppc-embedded@ozlabs.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).