Re: Help with a driver im writing.
- From: "Peter Z" <peter.linux@xxxxxxxxx>
- Date: 6 Jan 2006 22:01:06 -0800
Tasklets don't interfere each other on single CPU with non-preemeptable
kernel. You may put the real read opreation into other tasklet and in
IRQ just to schedule it. If interrupt happens during a write
operation, read will be defered. But if your hardware dosen't support
this, for example, hardware clears data after receive a acknowledgement
from CPU, you may have to check write state before perform a read
operation. And If write operation is uninterruptable, you may have to
put it into a critical section with interrupt off anyway.
--Peter Z
Aceman wrote:
> Hello all,
>
> I am writing a driver for a custom piece of hardware I built.
> It's running on kernel version 2.6.14 single intel cpu, non-preemptable
> kernel.
>
> Im quite new to device driver writing but I know enough to be dangerous :)
>
>
> My driver uses interrupt driven reads, and non interrupt driven writes.
> It will have 1 reader and 1 writer, since it does not really make sense
> for this device to have more. At any rate my problem is I can't have
> the driver read and write at the same time because of the way the
> hardware is made.
>
> My write routine is a loop (4 times) in which i shift data out to the
> device in a series of outb's which selects output banks (because im
> multiplexing to 48 bits) and writes the data to each.
>
> My read routine is implemented in a workqueue and it loops 3 times using
> outb's to select and input bank and shift in data. Then of course
> waking up the sleeper and copying it to user space.
>
> Problem is if a proc is sleeping on the read, and the writer is in the
> middle of the outb loop (bank selecting and data output) when an
> interrupt is serviced it of course jumps out and does the input loop,
> possibly corrupting data because it was not finished with the write
> sequence. Basically the read and write loop must finish to completion.
>
> I was thinking something like when im in the bottom half check to see if
> a write is in progress - if so sleep for a while? or go back on the
> waitqueue with a timeout? and check again..
> Im not sure the best way to implement this.
>
>
> Any advice would be appreciated.
> Stan
.
- References:
- Help with a driver im writing.
- From: Aceman
- Help with a driver im writing.
- Prev by Date: Re: Help with a driver im writing.
- Next by Date: Re: multi threaded program locks up /proc, ps
- Previous by thread: Re: Help with a driver im writing.
- Next by thread: Re: Help with a driver im writing.
- Index(es):
Relevant Pages
|