Help with a driver im writing.



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

  • [opensuse] openSUSE 10.3 not detecting SATA HD
    ... the sata_sis driver. ... I've tried turning off ACPI in bios and acpi=off which ... openSUSE 10.2 and all my hardware is working fine. ... info.product = 'USB Raw Device Access' ...
    (SuSE)
  • Re: 2008 SBS no longer boots
    ... driver issue initially, the fact that it seems to happen randomly now ... weird with a hardware problem that consistently doesn't get through boot ... other customer, even a 2 week old one, the problem immediately returned. ... There was a time when a server was fired up with a specialized OS and had a battery of tests run against each component to purposefully stress it. ...
    (microsoft.public.windows.server.sbs)
  • Re: Linux, X, ld, gcc, linking, shared libraries and stuff
    ... >> because, originally, video cards / system RAM could NOT afford to have ... > GL actually "copies" everything, but it's done by the graphics card, so ... > anyway if it's not hardware accelerated. ... installed the proper driver, then it zooms around the screen... ...
    (alt.lang.asm)
  • Re: 2008 SBS no longer boots
    ... Any thermal issues and a lot of other hardware problems should show up ... Happen to know a tool to determine driver load order by just having the ... other customer, even a 2 week old one, the problem immediately returned. ... There was a time when a server (even one that had been "burned ...
    (microsoft.public.windows.server.sbs)
  • Re: FreeBSD 7.0 problems
    ... Ergo I can't fault the hardware in any way. ... The wifi driver complains of timeout errors. ... vendor = 'Intel Corporation' ... ABI class: ...
    (freebsd-questions)