Should I use Linux to develop driver for specialized ISA card?
Hi,
I'd like to know your opinion on following problem:
I'm developing specialized plotter.
The moving parts of the plotter are controlled by ISA card that generates (and responds to) interrupts on each movement or printing event. The interrupts can be generated quite fast; up to frequency of 4kHz.
I need to write a driver for that.
The 1st prototype is developed in MS-DOS,but I hit problem with memory. The driver needs to use (and transfer) quite big chunks of memory. 1MB is not enough.
In NT you don't develop drivers so easily. It is actually a pain. Therefore I'm considering Linux. The machine would be probably dedicated and, may be later, embeded in the plotter.
Problems:
- It is unlikely that my driver would ever make it to main-stream kernel source.
- I'm just a C/C++ programmer, I have just rough idea what does it mean to 'develop a driver in Linux'. I'm pretty familiar with Linux as sys-admin though.
All I need is: to have piece of code executed on some interrupt, read/write IO ports of the card and be able to transfer big pieces of memory to the card.
What do you think? Is Linux the ideal platform for me?
Please, Cc: to [email protected], I'm not subscribed to the mailing list (yet).
---
bye
rastos
Quoted 8 lines · Rastislav Stanik
Hi,
I'd like to know your opinion on following problem:
I'm developing specialized plotter.
The moving parts of the plotter are controlled by ISA card that generates (and responds to) interrupts on each movement or printing event. The interrupts can be generated quite fast; up to frequency of 4kHz.
Linux drivers have no problem with interrupt-rates up to about 150,000 per second if the CPU is 130 MHz or faster and the ISR is small.
Quoted 6 lines
I need to write a driver for that.
The 1st prototype is developed in MS-DOS,but I hit problem with memory. The driver needs to use (and transfer) quite big chunks of memory. 1MB is not enough.
Normally, a Linux driver implements open/close/read/write/poll/ioctl. It transfers chunks of data so the large memory allocations are in user-space while the chunks are small buffers in kernel space.
Quoted 8 lines
In NT you don't develop drivers so easily. It is actually a pain. Therefore I'm considering Linux. The machine would be probably dedicated and, may be later, embeded in the plotter.
Problems:
- It is unlikely that my driver would ever make it to main-stream kernel source.
- I'm just a C/C++ programmer, I have just rough idea what does it mean to 'develop a driver in Linux'. I'm pretty familiar with Linux as sys-admin though.
Linux drivers are quite straight-forward and they can be inserted/removed from a running kernel (modules). This makes development run very quickly beause you can make small portions, test them, make more, etc., without ever having to re-boot. As long as you write code that behaves, i.e., no buffer overflows, and proper data allocation/deallocation, you will never have to re-boot.
Quoted 4 lines
All I need is: to have piece of code executed on some interrupt, read/write IO ports of the card and be able to transfer big pieces of memory to the card.
Trivial.
Quoted 2 lines
What do you think? Is Linux the ideal platform for me?
It's ideal. But, you have to start thinking like a Linux/Unix programmer. For instance, you do not allocate large buffers inside the kernel, you use poll() or select() to let user-mode code know that some event (like an interrupt) occurred so you can get/put data using read() or write(). You use ioctl() to send/receive control information to your device.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).
I was going to compile a list of innovations that could be attributed to Microsoft. Once I realized that Ctrl-Alt-Del was handled in the BIOS, I found that there aren't any.
Quoted 10 lines · Rastislav Stanik
I'm developing specialized plotter.
The moving parts of the plotter are controlled by ISA card that generates (and responds to) interrupts on each movement or printing event. The interrupts can be generated quite fast; up to frequency of 4kHz.I need to write a driver for that.
The 1st prototype is developed in MS-DOS,but I hit problem with memory. The driver needs to use (and transfer) quite big chunks of memory. 1MB is not enough.
Quoted 6 lines
In NT you don't develop drivers so easily. It is actually a pain. Therefore I'm considering Linux. The machine would be probably dedicated and, may be later, embeded in the plotter. Problems:
- It is unlikely that my driver would ever make it to main-stream kernel source.
Why should this is be a problem? - Considering you are talking embedded devices here you just need to take a stable kernel, write your driver for it and never change kernel. No need. Also you might want to consider one of the embedded/realtime Linux offerings out there.
Quoted 6 lines
- I'm just a C/C++ programmer, I have just rough idea what does it mean to 'develop a driver in Linux'. I'm pretty familiar with Linux as sys-admin though.
All I need is: to have piece of code executed on some interrupt, read/write IO ports of the card and be able to transfer big pieces of memory to the card.
Read A. Rubbini's Linux Device Drivers 2nd ed from O'Reilly. Have a look at http://www.oreilly.com/catalog/linuxdrive2/ where you can also find the online edition of the book.
Quoted 1 line
What do you think? Is Linux the ideal platform for me?
Of course! But then again I am biased. (-; To what other OS do you have all the source code with the rights modify it at will? And for what other OS can you get help while developing drivers in such an efficient manner as is possible with LKML and the other Linux mailinglists/newsgroups/irc? I have no idea about ISA handling and Linux so can't comment on technicallities of this but in view of embedding it, Linux is probably a good choice for you.
HTH,
Anton
Signature · 5 lines
"Nothing succeeds like success." - Alexandre Dumas -- Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @) Linux NTFS Maintainer / WWW: http://linux-ntfs.sf.net/ ICQ: 8561279 / WWW: http://www-stu.christs.cam.ac.uk/~aia21/
Quoted 4 lines · Rastislav Stanik
I'm developing specialized plotter.
The moving parts of the plotter are controlled by ISA card that generates (and responds to) interrupts on each movement or printing event. The interrupts can be generated quite fast; up to frequency of 4kHz.
I just made a driver for a couple of serial A/Ds that runs at 2kHz on a StrongARM platform. The system doesn't have any problems to keep up with that frequency, so I think 4kHz would still be OK.
Quoted 11 lines
I need to write a driver for that.
The 1st prototype is developed in MS-DOS,but I hit problem with memory. The driver needs to use (and transfer) quite big chunks of memory. 1MB is not enough.In NT you don't develop drivers so easily. It is actually a pain. Therefore I'm considering Linux. The machine would be probably dedicated and, may be later, embeded in the plotter. Problems:
- It is unlikely that my driver would ever make it to main-stream kernel source.
That's no problem, most of the embedded drivers never do.
Quoted 3 lines
- I'm just a C/C++ programmer, I have just rough idea what does it mean to 'develop a driver in Linux'. I'm pretty familiar with Linux as sys-admin though.
Forget about C++ for kernel programming, it simply doesn't work (see the lkml FAQ at http://www.tux.org/lkml/ ). A nice starting point for kernel programming is http://www.kernelnewbies.org/ together with its IRC channel #kernelnewbies. Also get a copy of the book "Linux device drivers (2nd edition)", there is a link in the books section on the kernelnewbies website.
Quoted 5 lines
All I need is: to have piece of code executed on some interrupt, read/write IO ports of the card and be able to transfer big pieces of memory to the card.
What do you think? Is Linux the ideal platform for me?
I don't know if Linux is the *ideal* platform, but driving a plotter could certainly be done in Linux.
Erik
Signature · 5 lines
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department of Electrical Engineering, Faculty of Information Technology and Systems, Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands Phone: +31-15-2783635 Fax: +31-15-2781843 Email: [email protected] WWW: http://www-ict.its.tudelft.nl/~erik/
Quoted 9 lines · Erik Mouw
Quoted 4 lines · Rastislav Stanik
I'm developing specialized plotter.
The moving parts of the plotter are controlled by ISA card that generates (and responds to) interrupts on each movement or printing event. The interrupts can be generated quite fast; up to frequency of 4kHz.I just made a driver for a couple of serial A/Ds that runs at 2kHz on a StrongARM platform. The system doesn't have any problems to keep up with that frequency, so I think 4kHz would still be OK.
I've had a waveform generator generate a square wave into an interrupt input of an ISA card. At 120k interrupts per second the system would noticably slow down, and at 140k interrupts it would stop. (and continue once the interrupt frequency was down below the threshold again).
So, you have about a factor of 25 of margin beyond "4kHz".
Roger.
Signature · 4 lines
** [email protected] ** http://www.BitWizard.nl/ ** +31-15-2137555 ** *-- BitWizard writes Linux device drivers for any device you may have! --* * There are old pilots, and there are bold pilots. * There are also old, bald pilots.
Quoted 3 lines
The moving parts of the plotter are controlled by ISA card that generates (and responds to) interrupts on each movement or printing event. The interrupts can be generated quite fast; up to frequency of 4kHz.
Thats fine. The issue you might need to consider is how long you can wait between an irq and actually excuting the handler. If that is very tight then you may want Victor Yodaiken's rtlinux
I'm curious, Alan, Why? I'm a hardware developer, and I would have assumed that linux would have been ideal for real time / embedded projects? (routers / controllers / etc.) Is there, for instance, a reason to suspect that linux would not be able to respond to interrupts at say 8Khz?
of course I know nothing of rtlinux so I'll read.
TIA
Fred
_________________________________________________
Quoted 12 lines · Alan Cox
Quoted 3 lines
The moving parts of the plotter are controlled by ISA card that generates (and responds to) interrupts on each movement or printing event. The interrupts can be generated quite fast; up to frequency of 4kHz.
Thats fine. The issue you might need to consider is how long you can wait between an irq and actually excuting the handler. If that is very tight then you may want Victor Yodaiken's rtlinux
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 5 lines
I'm curious, Alan, Why? I'm a hardware developer, and I would have assumed that linux would have been ideal for real time / embedded projects? (routers / controllers / etc.) Is there, for instance, a reason to suspect that linux would not be able to respond to interrupts at say 8Khz?
of course I know nothing of rtlinux so I'll read.
Routers aren't real time for example
The specific issues you have to watch are mostly from user space. Kernel irq handlers will run very rapidly providing another driver is not holding the interrupts off for a long time. Certain types of PC device require this (some IDE controllers for example). You also have to watch PCI graphics cards some of which will stall the PCI bus locking the CPU off it for milliseconds at a time [its a hack to get better benchmark numbers - sick isnt it]
So with the kernel you should be able to respond to irqs at 8Khz, with RtLinux you can make that a definitive mathematically hard guarantee
Depends which you need
Alan
Fred, I'd check out the faq on rtlinux...
"Worst-case times are
about 15microseconds between the assertion of an interrupt and the starting of the realtime handler on a generic x86 PC"
there where patches in the 2.2 era (some kind of midi related flamefest occured at that time) that would take the average in a 2.2 kenel down to 25Us but the worst case was still fairly large...
what a rtos buys is not generally performance but a much higher level determinism than what we can arrive at.
joelja
Quoted 30 lines · Fred
I'm curious, Alan, Why? I'm a hardware developer, and I would have assumed that linux would have been ideal for real time / embedded projects? (routers / controllers / etc.) Is there, for instance, a reason to suspect that linux would not be able to respond to interrupts at say 8Khz?
of course I know nothing of rtlinux so I'll read.TIA
Fred_________________________________________________
Quoted 4 lines · Alan Cox
Quoted 3 lines
The moving parts of the plotter are controlled by ISA card that generates (and responds to) interrupts on each movement or printing event. The interrupts can be generated quite fast; up to frequency of 4kHz.
Quoted 8 lines
Thats fine. The issue you might need to consider is how long you can wait between an irq and actually excuting the handler. If that is very tight then you may want Victor Yodaiken's rtlinux
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 8 lines
-------------------------------------------------------------------------- Joel Jaeggli [email protected] Academic User Services [email protected] PGP Key Fingerprint: 1DE9 8FCA 51FB 4195 B42A 9C32 A30D 121E -------------------------------------------------------------------------- It is clear that the arm of criticism cannot replace the criticism of arms. Karl Marx -- Introduction to the critique of Hegel's Philosophy of the right, 1843.
Quoted 6 lines · Fred
I'm curious, Alan, Why? I'm a hardware developer, and I would have assumed that linux would have been ideal for real time / embedded projects? (routers / controllers / etc.) Is there, for instance, a reason to suspect that linux would not be able to respond to interrupts at say 8Khz?
of course I know nothing of rtlinux so I'll read.
I'm involved in a project where we are using linux in an embedded application. We've got a gig of ram, no hard drives, no video, and the only I/O is serial, ethernet and fiberchannel.
We have a realtime process that tries to run every 50ms. We're seeing actual worst-case scheduling latencies upwards of 300-400ms.
So while interrupts can be handled pretty quickly, you'll want to make sure that your buffers are big enough that your userspace app only needs to run every half second or so.
You may be better off with rtlinux if you need better response. (Or if you're on x86 hardware you could look at the low-latency patches.)
Signature · 4 lines
Chris Friesen | MailStop: 043/33/F10 Nortel Networks | work: (613) 765-0557 3500 Carling Avenue | fax: (613) 765-2986 Nepean, ON K2H 8E9 Canada | email: [email protected]
With or without the low-latency patches?
Christopher Friesen <[email protected]> [01/09/04 12:29]:
Quoted 2 lines
We have a realtime process that tries to run every 50ms. We're seeing actual worst-case scheduling latencies upwards of 300-400ms.
Quoted 5 lines · Mark Frazer
Christopher Friesen <[email protected]> [01/09/04 12:29]:
Quoted 2 lines
We have a realtime process that tries to run every 50ms. We're seeing actual worst-case scheduling latencies upwards of 300-400ms.
With or without the low-latency patches?
Without. It's PPC hardware, and the lowlatency stuff that I've found seems to be x86-centric.
Signature · 4 lines
Chris Friesen | MailStop: 043/33/F10 Nortel Networks | work: (613) 765-0557 3500 Carling Avenue | fax: (613) 765-2986 Nepean, ON K2H 8E9 Canada | email: [email protected]
Quoted 15 lines · Christopher Friesen
Quoted 6 lines · Fred
I'm curious, Alan, Why? I'm a hardware developer, and I would have assumed that linux would have been ideal for real time / embedded projects? (routers / controllers / etc.) Is there, for instance, a reason to suspect that linux would not be able to respond to interrupts at say 8Khz?
of course I know nothing of rtlinux so I'll read.I'm involved in a project where we are using linux in an embedded application. We've got a gig of ram, no hard drives, no video, and the only I/O is serial, ethernet and fiberchannel.
We have a realtime process that tries to run every 50ms. We're seeing actual worst-case scheduling latencies upwards of 300-400ms.
Quoted 6 lines
So while interrupts can be handled pretty quickly, you'll want to make sure that your buffers are big enough that your userspace app only needs to run every half second or so.
You may be better off with rtlinux if you need better response. (Or if you're on x86 hardware you could look at the low-latency patches.)
1) Why shouldn't the low-latency patches work for another architecture? Andrew Morton might be interested to fix other architectures too. (but most patches are not in architecture specific code)
2) Montavistas reschedulable kernel is a very interesting approach, newly released an update by Robert Love
http://kpreempt.sourceforge.net/
http://tech9.net/rml/linux/patch-rml-2.4.10-pre2-preempt-kernel-1
(there are still some spikes, but the floor is smooth)
But note you with both approaches you want to run the latency critical process with a higher priority, and probably with the memory locked down.
See example code (latencytest) at:
http://www.gardena.net/benno/linux/audio/
(but there is no need to run at the maximum possible priority since your
process will be alone anyway...)
/RogerL
Signature · 3 lines
Roger Larsson Skellefteå Sweden
Quoted 10 lines · Roger Larsson
1) Why shouldn't the low-latency patches work for another architecture? Andrew Morton might be interested to fix other architectures too. (but most patches are not in architecture specific code)
2) Montavistas reschedulable kernel is a very interesting approach, newly released an update by Robert Love
http://kpreempt.sourceforge.net/
http://tech9.net/rml/linux/patch-rml-2.4.10-pre2-preempt-kernel-1
(there are still some spikes, but the floor is smooth)
Quoted 7 lines
But note you with both approaches you want to run the latency critical process with a higher priority, and probably with the memory locked down.
See example code (latencytest) at:
http://www.gardena.net/benno/linux/audio/
(but there is no need to run at the maximum possible priority since your
process will be alone anyway...)
Just a data point here -
The Andrew Morton patches have worked well for me here - I test it often with quake 3 arena, and am currently on 2.4.10-pre4 -
I was never successful in getting the kernel to compile and run with any of the the other low latency patches floating around -
cu
jjs
Quoted 14 lines · Roger Larsson
Quoted 12 lines · Christopher Friesen
Quoted 6 lines · Fred
I'm curious, Alan, Why? I'm a hardware developer, and I would have assumed that linux would have been ideal for real time / embedded projects? (routers / controllers / etc.) Is there, for instance, a reason to suspect that linux would not be able to respond to interrupts at say 8Khz?
of course I know nothing of rtlinux so I'll read.I'm involved in a project where we are using linux in an embedded application. We've got a gig of ram, no hard drives, no video, and the only I/O is serial, ethernet and fiberchannel.
Quoted 6 lines
Quoted 2 lines
We have a realtime process that tries to run every 50ms. We're seeing actual worst-case scheduling latencies upwards of 300-400ms.
1) Why shouldn't the low-latency patches work for another architecture? Andrew Morton might be interested to fix other architectures too. (but most patches are not in architecture specific code)
Well, a while back I took a look at the low latency patch and saw a bunch of arch-specific files being modified so I assumed that it wouldn't do much on a different architecture. I may have been wrong. I guess its time for me to do some testing.
Chris
Signature · 4 lines
Chris Friesen | MailStop: 043/33/F10 Nortel Networks | work: (613) 765-0557 3500 Carling Avenue | fax: (613) 765-2986 Nepean, ON K2H 8E9 Canada | email: [email protected]
Quoted 10 lines · Christopher Friesen
Quoted 4 lines
1) Why shouldn't the low-latency patches work for another architecture? Andrew Morton might be interested to fix other architectures too. (but most patches are not in architecture specific code)
Well, a while back I took a look at the low latency patch and saw a bunch of arch-specific files being modified so I assumed that it wouldn't do much on a different architecture. I may have been wrong. I guess its time for me to do some testing.
It is now arch-neutral. There used to be a couple of x86 tweaks,
but they became unnecessary when some softirq fixes were merged.
So for other architectures the only thing which needs changing is the actual config entries in arch/<arch>/config.in. If you do take a look at this, please send me the diffs for whatever your architecture is.
I haven't heard much from non-x86 people; there were some remaining latency problems with PPC many months ago, but they were never explained and I don't know if the problems remain, or if indeed they were ever real.
It's kind of amazing that you're seeing 300 millisec stalls on a system with no local disks - most problems occur in the VM list walking, dirty buffer writeout, etc. Unless you're performing a lot of fileystem work across that FC controller? It could be that there is an architecture- or driver-specific problem in your setup.
-