Re: [PATCH 1/1] UIO: Add a write() function to enable/disable interrupts

Randy Dunlap
2008-05-23T18:37:34Z

On Fri, 23 May 2008 13:55:57 +0200 Hans J. Koch wrote:

> Documentation/DocBook/uio-howto.tmpl | 40 ++++++++++++++++++++++++++++++++++-
> drivers/uio/uio.c | 26 ++++++++++++++++++++++
> include/linux/uio_driver.h | 2 +
> 3 files changed, 67 insertions(+), 1 deletion(-)
>
> Index: linux-2.6.26-rc/Documentation/DocBook/uio-howto.tmpl
> ===================================================================
> --- linux-2.6.26-rc.orig/Documentation/DocBook/uio-howto.tmpl 2008-05-22 20:22:57.000000000 +0200
> +++ linux-2.6.26-rc/Documentation/DocBook/uio-howto.tmpl 2008-05-23 11:57:23.000000000 +0200
> @@ -30,6 +30,12 @@
>
> <revhistory>
> <revision>
> + <revnumber>0.5</revnumber>
> + <date>2008-05-22</date>
> + <authorinitials>hjk</authorinitials>
> + <revremark>Added description of write() function.</revremark>
> + </revision>
> + <revision>
> <revnumber>0.4</revnumber>
> <date>2007-11-26</date>
> <authorinitials>hjk</authorinitials>
> @@ -64,7 +70,7 @@
> <?dbhtml filename="copyright.html"?>
> Copyright and License
>
> - Copyright (c) 2006 by Hans-Jürgen Koch.
> + Copyright (c) 2006-2008 by Hans-Jürgen Koch.
>
> This documentation is Free Software licensed under the terms of the
> GPL version 2.
> @@ -189,6 +195,30 @@
> represents the total interrupt count. You can use this number
> to figure out if you missed some interrupts.
>
> +
> + For some hardware that has more than one interrupt source internally,
> + but not seperate IRQ mask and status registers, there might be

separate

> + situations where userspace cannot determine what the interrupt source
> + was if the kernel handler disables them by writing to the chip's IRQ
> + register. In such a case, the kernel has to disable the IRQ completely
> + to leave the chip's register untouched. Now the userspace part can
> + determine the cause of the interrupt, but it cannot re-enable
> + interrupts. Another cornercase are chips where re-enabling interrupts

is

> + is a read-modify-write operation to a combined IRQ status/acknowledge
> + register. This would be racy if a new interrupt occured

occurred

> + simultaneously.
> +
> +
> + To address these problems, UIO also implements a write() function. It
> + is normally not used and can be ignored for hardware that has only a
> + single interrupt source or has seperate IRQ mask and status registers.

separate
["There's <a rat> in separate."]

> + If you need it, however, a write to <filename>/dev/uioX</filename>
> + will call the <function>irqcontrol()</function> function implemented
> + by the driver. You have to write a 32-bit value that is usually either
> + 0 or 1 do disable or enable interrupts. If a driver does not implement

to

> + <function>irqcontrol()</function>, <function>write()</function> will
> + return with <varname>-ENOSYS</varname>.
> +

---
~Randy