Linux Driver help needed (Polled interface)

Linux Driver help needed (Polled interface)

Post by jharrel » Sat, 20 Mar 1999 04:00:00



General driver development question for the linux community:

I am currently working on a device driver for a modem card that has a
"back door" to allow data to be passed through "attribute memory" in a
PCMCIA interface.  The problem is that no interrupt is available to
allow
me to know when data is available from the device.  Is there a good
method
to implement a "polled" interface within a device driver?  It seems that
if
the driver is character device and needs to be acted upon by a
user-space
program (i.e. a read,write, etc.) I can't implement an interface that is
fast enough to catch all incoming data.  Is there a way to have the
driver
periodically go and read from the attribute memory and move the data to
a
circular buffer in user space?  Can I use jiffies or wait queues or
something
along that lines to read the interface?   Any help would be greatly
appreciated.

Thank,
Jeff Harrell

 
 
 

Linux Driver help needed (Polled interface)

Post by jharrel » Sat, 20 Mar 1999 04:00:00


General driver development question for the linux community:

I am currently working on a device driver for a modem card that has a
"back door" to allow data to be passed through "attribute memory" in a
PCMCIA interface.  The problem is that no interrupt is available to
allow
me to know when data is available from the device.  Is there a good
method
to implement a "polled" interface within a device driver?  It seems that
if the driver is character device and needs to be acted upon by a
user-space program (i.e. a read,write, etc.) I can't implement an
interface that is
fast enough to catch all incoming data.  Is there a way to have the
driver
periodically go and read from the attribute memory and move the data to
a circular buffer in user space?  Can I use jiffies or wait queues or
something along that lines to read the interface?   Any help would be
greatly
appreciated.

Thanks,
Jeff Harrell

 
 
 

Linux Driver help needed (Polled interface)

Post by Gerard van der Se » Tue, 23 Mar 1999 04:00:00



> General driver development question for the linux community:

> I am currently working on a device driver for a modem card that has a
> "back door" to allow data to be passed through "attribute memory" in a
> PCMCIA interface.  The problem is that no interrupt is available to
> allow
> me to know when data is available from the device.  Is there a good
> method
> to implement a "polled" interface within a device driver?  It seems that
> if the driver is character device and needs to be acted upon by a
> user-space program (i.e. a read,write, etc.) I can't implement an
> interface that is
> fast enough to catch all incoming data.  Is there a way to have the
> driver
> periodically go and read from the attribute memory and move the data to
> a circular buffer in user space?  Can I use jiffies or wait queues or
> something along that lines to read the interface?   Any help would be
> greatly
> appreciated.

> Thanks,
> Jeff Harrell

I'am currently working on a devicedriver for my modelrailtrack.
I found some interesting points with the device /dev/rtc.
If you access it from user space (just a read) your program is scheduled
in a wait cue for an user configurable time. So If you have a reasonable
wait time you can look there. In user space you can go all the way up to
128 interrupts per second. If you are root you can go all the way up
8192 interrupts per second.

Keywords rtc, mc146818rtc, irq 8
--
Met vriendelijke groet,

Gerard van der Sel

"De dinosaurussen hadden hun komeet, wij hebben de Windows computer" -
me

 
 
 

Linux Driver help needed (Polled interface)

Post by jaco » Fri, 26 Mar 1999 04:00:00


If you have no interupts? Dont touch it.
 (because the kernel is not pre-emptive multitasked, a polling mechanism
could slow down the kernel significantly!!)
Do it in user space instead!



Quote:> General driver development question for the linux community:

> I am currently working on a device driver for a modem card that has a
> "back door" to allow data to be passed through "attribute memory" in a
> PCMCIA interface.  The problem is that no interrupt is available to
> allow
> me to know when data is available from the device.  Is there a good
> method
> to implement a "polled" interface within a device driver?  It seems that
> if the driver is character device and needs to be acted upon by a
> user-space program (i.e. a read,write, etc.) I can't implement an
> interface that is
> fast enough to catch all incoming data.  Is there a way to have the
> driver
> periodically go and read from the attribute memory and move the data to
> a circular buffer in user space?  Can I use jiffies or wait queues or
> something along that lines to read the interface?   Any help would be
> greatly
> appreciated.

> Thanks,
> Jeff Harrell

 
 
 

Linux Driver help needed (Polled interface)

Post by jharrel » Fri, 26 Mar 1999 04:00:00



> If you have no interupts? Dont touch it.
>  (because the kernel is not pre-emptive multitasked, a polling mechanism
> could slow down the kernel significantly!!)
> Do it in user space instead!



> > General driver development question for the linux community:

> > I am currently working on a device driver for a modem card that has a
> > "back door" to allow data to be passed through "attribute memory" in a
> > PCMCIA interface.  The problem is that no interrupt is available to
> > allow
> > me to know when data is available from the device.  Is there a good
> > method
> > to implement a "polled" interface within a device driver?  It seems that
> > if the driver is character device and needs to be acted upon by a
> > user-space program (i.e. a read,write, etc.) I can't implement an
> > interface that is
> > fast enough to catch all incoming data.  Is there a way to have the
> > driver
> > periodically go and read from the attribute memory and move the data to
> > a circular buffer in user space?  Can I use jiffies or wait queues or
> > something along that lines to read the interface?   Any help would be
> > greatly
> > appreciated.

> > Thanks,
> > Jeff Harrell

If I was to access this memory that is mapped from kernel space to user space
and was using
a GUI (GTK, for example).  Does polling in user space give me enough
real-time to get at the
memory at an 8Khz rate?  (What about 9.6Khz  or  11Khz rate).  Possibly data
could be coming
at me at these rates.  I thought perhaps using a  sleep, schedule type of
structure in kernel space
I could gain increased throughput.

Jeff

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|

3Com/MCD                work: 801-320-7668        |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 
 
 

Linux Driver help needed (Polled interface)

Post by Gerard van der Se » Sat, 27 Mar 1999 04:00:00



>      > I am currently working on a device driver for a modem card
>      that has a
>      > "back door" to allow data to be passed through "attribute
>      memory" in a
>      > PCMCIA interface.  The problem is that no interrupt is
>      available to
<knip>
>      > periodically go and read from the attribute memory and
>      move the data to
>      > a circular buffer in user space?  Can I use jiffies or
>      wait queues or
>      > something along that lines to read the interface?   Any
>      help would be
>      > greatly
>      > appreciated.

>      > Thanks,
>      > Jeff Harrell

From user space you can use read (on /dev/rtc). It gives you a suspended
read for 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192 Hz.
(from 256 upward as root only). The rtc hardware in a PC is used to give
a X-tal stable interrupt (irq 8).

(the documentation of the rtc-chip mentions also the posibility for
16384 an 32764 Hz interrupt rate.)
--
Met vriendelijke groet,

Gerard van der Sel

"De dinosaurussen hadden hun komeet, wij hebben de Windows computer" -
me

 
 
 

1. My Freebsd driver hangs in poll function after some time (problem with poll)

Hello everyone,

I have the following problem. I've ported a Linux driver  for small device
(led, keypad and lcd in-one on PPBUS)  on Freebsd. 8 hours of intensive
usage shown no errors. But later I've found that this driver can hang the
system. But experimenting I've found that the reason is somewhere in 'poll'
function. I'm using it with Freebsd 4.5, single cpu and single process that
select on /dev/kpd0 (keypad) with timeout 1 sec. Aproximately after 4 days
system hangs. If I start more processes and call select more intensively it
hangs on the second day.
Here is this nasty poll function. Maybe you can see something. I'm not an
advanced Freebsd driver writer , simply read handbook and looked into
sources:
...
struct selinfo mysip;
int mainlock; // for my fake MUTEX
...
static  int
lcd_kpd_poll(
 dev_t dev,
 int events,
 struct proc *p) {

 int revents=0;
 MUTEX_ENTER(mainlock);
/*
I've not found mutexes in kernel so I used a simple spinlock.  Could this be
a reason in single cpu machine ?
    #define MUTEX_ENTER(x) {while(x) DELAY(1);x=1;}
    #define MUTEX_EXIT(x) {x=0;}
*/
 if (!kpd_dev) revents =  POLLHUP;
else{
     if (events & (POLLIN | POLLRDNORM)) {
        /*  check if there are already keys in the queue */
         if (lcd_keyevents_pending(&key_queue)) {
             revents =events & (POLLIN | POLLRDNORM);}
         else{
                 selrecord(p, &mysip);
                /*
                This selrecord is a black box for me :)  When I query keypad
and key is pressed I put it in query and
                do selwakeup(&mysip);
                */
                if (lcd_keyevents_pending(&key_queue)) {                 //
here I check if I have a key in queue
                   revents =events & (POLLIN | POLLRDNORM);
                }
         }
    }
MUTEX_EXIT(mainlock); // release mutex
return revents;

Thank you for your attention

--
Best regards,
Andrey Koubychev

2. Partition Magic doesn't see second HD

3. ARCNET Drivers Needed for Linux...help help help!

4. using LDAP with Exchange Server?

5. need help: rz with Mac ZTerm

6. poll/select in udprelay - anyone have poll.c(h) code for linux?

7. Korn: setting -o vi ????

8. Need help in Microsoft poll !

9. Need help with a multiplexer (poll call).

10. Need help with Agilent 82357A USB / GPIB interface on Linux

11. Need help with poll and select!

12. Siemens S5 interface driver needed