Re: Help with a driver im writing.



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

.



Relevant Pages

  • [PATCH] Update Documentation/DocBook/kernel-hacking.tmpl
    ... Kernel Hacking. ... not associated with any process, serving a softirq, tasklet or bh; ... For example, while a softirq is running on a CPU, no other ... but a hardware interrupt can. ...
    (Linux-Kernel)
  • Re: [parisc-linux] [patch 15/23] Add cmpxchg_local to parisc
    ... could be vastely used in the kernel. ... the local ops has just been standardized in 2.6.22 though a patchset I ... I always thought preemption required some sort of interrupt or trap. ... that only one CPU writes to the local_t data. ...
    (Linux-Kernel)
  • Re: Threads and processes on Linux
    ... > task runs in the same memory space as the parent task. ... > LinuxThreads and/or older 2.4.x kernel. ... CPU, and so a lot of time is being spent loading the memory accessed by the ... I only got thread affinity - I didn't get interrupt affinity. ...
    (comp.os.linux.misc)
  • Re: APIC error on SMP machine
    ... The kernel source implies ... > listen to the CPU? ... interrupt, it was not accepted by the target. ... Do any previous kernels boot? ...
    (Linux-Kernel)
  • Re: PATCH/RFC: [kdump] fix APIC shutdown sequence
    ... to the INT message on the bus, except for the EOI which comes much later. ... interrupt and the CPU receiving an interrupt. ... So I think the scenario which leaves IRR set when the kdump kernel ...
    (Linux-Kernel)