UIO patches for 2.6.21
Subsystems (3)
PATCH 1/1 UIO patches for 2.6.21
Here are the updated UIO (Userspace I/O driver framework) patches for 2.6.21.
They have been revamped from the last time you have seen them, and they include a real driver, the Hilscher CIF DeviceNet and Profibus card controller, which is being used in production systems with this driver framework right now. The kernel driver they replaced was a total mess, with over 60+ ioctls to try to control the different aspects of the device. See the last patch in this series for more details on this driver.
These patches include full documentation, are self-contained from the rest of the kernel, and have been in the -mm tree for the past few months with no complaints.
Please pull from:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/uio-2.6.git/
Patches will be sent as a follow-on to this message to lkml for people to see.
thanks,
greg k-h
Documentation/DocBook/kernel-api.tmpl | 4 + Documentation/DocBook/uio-howto.tmpl | 498 +++++++++++++++++++++++ drivers/Kconfig | 1 + drivers/Makefile | 1 + drivers/uio/Kconfig | 27 ++ drivers/uio/Makefile | 2 + drivers/uio/uio.c | 702 +++++++++++++++++++++++++++++++++ drivers/uio/uio_cif.c | 156 ++++++++ include/linux/uio_driver.h | 91 +++++ 9 files changed, 1482 insertions(+), 0 deletions(-) create mode 100644 Documentation/DocBook/uio-howto.tmpl create mode 100644 drivers/uio/Kconfig create mode 100644 drivers/uio/Makefile create mode 100644 drivers/uio/uio.c create mode 100644 drivers/uio/uio_cif.c create mode 100644 include/linux/uio_driver.h
---------------
Hans J. Koch (2):
UIO: Add the User IO core code
UIO: Documentation
Hans-Jürgen Koch (1):
UIO: Hilscher CIF card driver
PATCH 1/3 UIO: Add the User IO core code
From: Hans J. Koch <[email protected]>
This interface allows the ability to write the majority of a driver in userspace with only a very small shell of a driver in the kernel itself. It uses a char device and sysfs to interact with a userspace process to process interrupts and control memory accesses.
See the docbook documentation for more details on how to use this interface.
From: Hans J. Koch <[email protected]>
--- drivers/Kconfig | 1 + drivers/Makefile | 1 + drivers/uio/Kconfig | 14 + drivers/uio/Makefile | 1 + drivers/uio/uio.c | 702 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/uio_driver.h | 91 ++++++ 6 files changed, 810 insertions(+), 0 deletions(-) create mode 100644 drivers/uio/Kconfig create mode 100644 drivers/uio/Makefile create mode 100644 drivers/uio/uio.c create mode 100644 include/linux/uio_driver.h
drivers/Kconfig +1 -0
@@ -84,4 +84,5 @@ source "drivers/auxdisplay/Kconfig" source "drivers/kvm/Kconfig" +source "drivers/uio/Kconfig" endmenu
drivers/Makefile +1 -0
@@ -37,6 +37,7 @@ obj-$(CONFIG_SCSI) += scsi/ obj-$(CONFIG_ATA) += ata/ obj-$(CONFIG_FUSION) += message/ obj-$(CONFIG_IEEE1394) += ieee1394/ +obj-$(CONFIG_UIO) += uio/ obj-y += cdrom/ obj-y += auxdisplay/ obj-$(CONFIG_MTD) += mtd/
drivers/uio/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +menu "Userspace I/O" +config UIO + tristate "Userspace I/O drivers" + default n + help + Enable this to allow the userspace driver core code to be + built. This code allows userspace programs easy access to + kernel interrupts and memory locations, allowing some drivers + to be written in userspace. Note that a small kernel driver + is also required for interrupt handling to work properly. + + If you don't know what to do here, say N. + +endmenu
drivers/uio/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_UIO) += uio.o
drivers/uio/uio.c new file +702 -0
702 lines not on this page · raw message
include/linux/uio_driver.h new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
1.5.1.2
PATCH 2/3 UIO: Documentation
From: Hans J. Koch <[email protected]>
Documentation for the UIO interface
From: Hans J. Koch <[email protected]>
--- Documentation/DocBook/kernel-api.tmpl | 4 + Documentation/DocBook/uio-howto.tmpl | 498 +++++++++++++++++++++++++++++++++ 2 files changed, 502 insertions(+), 0 deletions(-) create mode 100644 Documentation/DocBook/uio-howto.tmpl
Documentation/DocBook/kernel-api.tmpl +4 -0
@@ -396,6 +396,10 @@ X!Edrivers/pnp/system.c !Edrivers/pnp/manager.c !Edrivers/pnp/support.c </sect1> + <sect1><title>Userspace IO devices</title> +!Edrivers/uio/uio.c +!Iinclude/linux/uio_driver.h + </sect1> </chapter> <chapter id="blkdev">
Documentation/DocBook/uio-howto.tmpl new file +498 -0
498 lines not on this page · raw message
Signature · 1 line
1.5.1.2
PATCH 3/3 UIO: Hilscher CIF card driver
From: Hans-Jürgen Koch <[email protected]>
this is a patch that adds support for Hilscher CIF DeviceNet and Profibus cards. I tested it on a Kontron CPX board, and Thomas reviewed it.
You can find the user space part here:
http://www.osadl.org/projects/downloads/UIO/user/cif-0.1.0.tar.gz
Notes: cif_api.c is the main file you want to look at. It contains the functions to open, close, mmap and so on. cif_dps.c adds functions specific to Profibus cards, and cif_dn.c contains functions for DeviceNet cards. cif.c is a universal playground, it's just a small test program. The user space part of this UIO driver is still work in progress, and not everything is tested yet. At the moment, the thread in cif_api.c contains some code that artificially makes the card generate interrupts, this was added for testing and will be removed later. But the driver already contains all the functions needed for useful operation, so it gives a good idea of how such a thing looks like.
For comparison, here's what you get from the manufacturer (www.hilscher.com) when you ask for a Linux 2.6 driver:
http://www.tglx.de/private/hjk/cif-orig-2.6.tar.bz2
WARNING: Don't look at the code for too long, you might become sick :-)
--- drivers/uio/Kconfig | 13 ++++ drivers/uio/Makefile | 3 +- drivers/uio/uio_cif.c | 156 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 171 insertions(+), 1 deletions(-) create mode 100644 drivers/uio/uio_cif.c
drivers/uio/Kconfig +13 -0
@@ -11,4 +11,17 @@ config UIO If you don't know what to do here, say N. +config UIO_CIF + tristate "generic Hilscher CIF Card driver" + depends on UIO && PCI + default n + help + Driver for Hilscher CIF DeviceNet and Profibus cards. This + driver requires a userspace component that handles all of the + heavy lifting and can be found at: + http://www.osadl.org/projects/downloads/UIO/user/cif-* + + To compile this driver as a module, choose M here: the module + will be called uio_cif. + endmenu
drivers/uio/Makefile +2 -1
@@ -1 +1,2 @@ -obj-$(CONFIG_UIO) += uio.o +obj-$(CONFIG_UIO) += uio.o +obj-$(CONFIG_UIO_CIF) += uio_cif.o
drivers/uio/uio_cif.c new file +156 -0
156 lines not on this page · raw message
Signature · 1 line
1.5.1.2
Re: [PATCH 3/3] UIO: Hilscher CIF card driver (with patch)
Am Samstag 28 April 2007 00:50 schrieb Greg Kroah-Hartman:
Quoted 12 lines
(quoted diff) +12
-0+static int __devinit hilscher_pci_probe(struct pci_dev *dev, + const struct pci_device_id *id) +{ + struct uio_info *info; + + info = kzalloc(sizeof(struct uio_info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + if (pci_enable_device(dev)) + goto out_free; +
Review
Quoted 10 lines
(quoted diff) +10
-0+ if (pci_request_regions(dev, "hilscher")) + goto out_disable; + + info->mem[0].addr = pci_resource_start(dev, 0); + if (!info->mem[0].addr) + goto out_release; + info->mem[0].internal_addr = ioremap_nocache(pci_resource_start(dev, 0), + pci_resource_len(dev, 0)); + if (!info->mem[0].internal_addr) + goto out_release;
Alan Cox pointed out (offlist) that ioremap_nocache() is unneccessary here. This patch replaces it with ioremap():
Thanks, Alan!
hjk
drivers/uio/uio_cif.c +2 -3
@@ -64,9 +64,8 @@ info->mem[0 ].addr =pci_resource_start (dev,0 );if (!info->mem[0 ].addr) goto out_release; - info->mem[0 ].internal_addr =ioremap_nocache ( -pci_resource_start (dev,0 ), -pci_resource_len (dev,0 ) ); + info->mem[0 ].internal_addr =ioremap (pci_resource_start (dev,0 ), +pci_resource_len (dev,0 ) );if (!info->mem[0 ].internal_addr) goto out_release;
Re: [PATCH 2/3] UIO: Documentation
In reply to Greg Kroah-HartmanQuoted 18 lines · On Fri, 27 Apr 2007 15:50:57 -0700 Greg Kroah-Hartman wrote:
From: Hans J. Koch <[email protected]>
Documentation for the UIO interface
From: Hans J. Koch <[email protected]>
Signed-off-by Greg Kroah-Hartman <[email protected]>--- Documentation/DocBook/kernel-api.tmpl | 4 + Documentation/DocBook/uio-howto.tmpl | 498 +++++++++++++++++++++++++++++++++ 2 files changed, 502 insertions(+), 0 deletions(-) create mode 100644 Documentation/DocBook/uio-howto.tmplDocumentation/DocBook/uio-howto.tmpl new file +0
-0
Documentation/DocBook/uio-howto.tmpl line 7
Quoted 7 lines
Documentation/DocBook/uio-howto.tmpl new file +7
-0@@ -0,0 +1,498 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" +"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> + +<article id="index"> +<articleinfo> +<title>The Userspace I/O HOWTO</title>
Most of this reads well. Thanks.
A few typo corrections are below...
But it doesn't build for me with 'make htmldocs'.
Did you test it?
Warning(/tester/linsrc/linux-2.6.21-rc7-mm2//drivers/uio/uio.c:240): No description found for parameter 'info' Warning(/tester/linsrc/linux-2.6.21-rc7-mm2//drivers/uio/uio.c:594): No description found for parameter 'owner' Warning(/tester/linsrc/linux-2.6.21-rc7-mm2//drivers/uio/uio.c:594): No description found for parameter 'info' Warning(/tester/linsrc/linux-2.6.21-rc7-mm2//drivers/uio/uio.c:667): No description found for parameter 'info' Error(/tester/linsrc/linux-2.6.21-rc7-mm2//include/linux/uio_driver.h:29): cannot understand prototype: 'struct uio_mem ' Error(/tester/linsrc/linux-2.6.21-rc7-mm2//include/linux/uio_driver.h:55): cannot understand prototype: 'struct uio_info ' Warning(/tester/linsrc/linux-2.6.21-rc7-mm2//include/linux/uio_driver.h): no structured comments found
Patch below for all of is these (including typos).
However, it still fails 'make htmldocs' for me. What am I missing? How did it work for you?
My DTD doesn't like to see <varname> inside a <listitem>:
linux-2.6.21-rc7-mm2/Documentation/DocBook/uio-howto.xml:333: element listitem: validity error : Element listitem content does not follow the DTD, expecting (calloutlist | glosslist | itemizedlist | orderedlist | segmentedlist | simplelist | variablelist | caution | important | note | tip | warning | literallayout | programlisting | programlistingco | screen | screenco | screenshot | synopsis | cmdsynopsis | funcsynopsis | classsynopsis | fieldsynopsis | constructorsynopsis | destructorsynopsis | methodsynopsis | formalpara | para | simpara | address | blockquote | graphic | graphicco | mediaobject | mediaobjectco | informalequation | informalexample | informalfigure | informaltable | equation | example | figure | table | msgset | procedure | sidebar | qandaset | anchor | bridgehead | remark | highlights | abstract | authorblurb | epigraph | indexterm | beginpage)+, got (varname CDATA)
so I removed most of the <varname>s and still had errors. Any suggestions?
...
Documentation/DocBook/uio-howto.tmpl line 14
Quoted 7 lines
Documentation/DocBook/uio-howto.tmpl new file +7
-0+ <para> + Each driver provides attributes that are used to read or write + variables. These attributes are accessible through sysfs + files. A custom kernel driver module can add its own + attributes to the device owned by the uio driver, but not added + to the UIO device itself at this time. This might change in the + future if it would be found to be useful
Period at end of sentence.
Documentation/DocBook/uio-howto.tmpl
Quoted 12 lines
Documentation/DocBook/uio-howto.tmpl new file +6
-0+ </para> + + <para> + The following standard attributes are provided by the UIO + framework: + </para><listitem>
+<varname>void *internal_addr</varname>: If you have to access this memoryDocumentation/DocBook/uio-howto.tmpl new file +3
-0+region from within your kernel module, you will want to map it internally by +using something like <function>ioremap_nocache()</function>. Addresses +returned by this function can not be mapped to user space, so you must not
cannot
Quoted 8 lines
Documentation/DocBook/uio-howto.tmpl new file +7
-0+store it in <varname>addr</varname>. Use <varname>internal_addr</varname> +instead to remember such an address. +</listitem> +</itemizedlist> +<sect2 id="adding_irq_handler"> +<title>Adding an interrupt handler</title> + <para>
Documentation/DocBook/uio-howto.tmpl
Quoted 10 lines
Documentation/DocBook/uio-howto.tmpl new file +10
-0+ What you need to do in your interrupt handler depends on your + hardware and on how you want to handle it. You should try to + keep the amount of code in your kernel interrupt handler low. + If your hardware requires no action that you + <emphasis>have</emphasis> to perform after each interrupt, + then your handler can be empty.</para> <para>If, on the other + hand, your hardware <emphasis>needs</emphasis> some action to + be performed after each interrupt, then you + <emphasis>must</emphasis> do it in your kernel module. Note + that you cannot rely on the userspace part of your driver.Your
. Your
Documentation/DocBook/uio-howto.tmpl
Quoted 4 lines
Documentation/DocBook/uio-howto.tmpl new file +4
-0+ userspace program can terminate at any time, possibly leaving + your hardware in a state where proper interrupt handling is + still required. + </para>
Some fixes:
From: Randy Dunlap <[email protected]>
Fix UIO kernel-doc typos and warnings.
Include uio-howto in list of docbook files. Change DOCTYPE version to same as all other docbook files.
--- Documentation/DocBook/Makefile | 2 +- Documentation/DocBook/uio-howto.tmpl | 10 +++++----- drivers/uio/uio.c | 10 +++++----- include/linux/uio_driver.h | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-)
include/linux/uio_driver.h +4 -4
@@ -19,7 +19,7 @@#include <linux/interrupt.h> /** -* uio_mem - description of a UIO memory region +* struct uio_mem - description of a UIO memory region * @kobj: kobject for this mapping * @addr: address of the device's memory * @size: size of IO
@@ -39,13 +39,13 @@ struct uio_mem {struct uio_device ;/** -* uio_info - UIO device capabilities +* struct uio_info - UIO device capabilities * @uio_dev: the UIO device this info belongs to * @name: device name * @version: device driver version * @mem: list of mappable memory regions, size==0 for end of list * @irq: interrupt number or UIO_IRQ_CUSTOM -* @irq_flags flags for request_irq() +* @irq_flags: flags for request_irq() * @priv: optional private data * @handler: the device's irq handler * @mmap: mmap operation for this uio device
@@ -56,7 +56,7 @@ struct uio_info {struct uio_device *uio_dev;char *name;char *version; -struct uio_mem mem[MAX_UIO_MAPS ]; +struct uio_mem mem[MAX_UIO_MAPS ];long irq;unsigned long irq_flags;void *priv;
drivers/uio/uio.c +5 -5
@@ -234,7 +234,7 @@ static void uio_free_minor(struct uio_de/** * uio_event_notify - trigger an interrupt event -* @idev: UIO device where the event occured +* @info: UIO device capabilities */ void uio_event_notify (struct uio_info *info) {
@@ -582,9 +582,9 @@ static void uio_class_destroy(void)/** * uio_register_device - register a new userspace IO device -* +* @owner: module pointer * @parent: parent device -* @idev: device capabilities +* @info: device capabilities * * returns zero on success or a negative error code. */
@@ -658,8 +658,8 @@ err_kzalloc:EXPORT_SYMBOL_GPL (__uio_register_device);/** -* uio_unregister_device - unregister a industrial IO device -* @uiodev: UIO device driver identifier +* uio_unregister_device - unregister an industrial IO device +* @info: UIO device driver capabilities * * returns 0 on success */
Documentation/DocBook/uio-howto.tmpl +5 -5
@@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" -"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> +<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" +"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> <article id="index"> <articleinfo>
@@ -182,7 +182,7 @@ interested in translating it, please ema files. A custom kernel driver module can add its own attributes to the device owned by the uio driver, but not added to the UIO device itself at this time. This might change in the - future if it would be found to be useful + future if it would be found to be useful. </para> <para>
@@ -422,7 +422,7 @@ all unused mappings. <varname>void *internal_addr</varname>: If you have to access this memory region from within your kernel module, you will want to map it internally by using something like <function>ioremap_nocache()</function>. Addresses -returned by this function can not be mapped to user space, so you must not +returned by this function cannot be mapped to user space, so you must not store it in <varname>addr</varname>. Use <varname>internal_addr</varname> instead to remember such an address. </listitem>
@@ -447,7 +447,7 @@ to set up sysfs files for this mapping. hand, your hardware <emphasis>needs</emphasis> some action to be performed after each interrupt, then you <emphasis>must</emphasis> do it in your kernel module. Note - that you cannot rely on the userspace part of your driver.Your + that you cannot rely on the userspace part of your driver. Your userspace program can terminate at any time, possibly leaving your hardware in a state where proper interrupt handling is still required.
Documentation/DocBook/Makefile +1 -1
@@ -11,7 +11,7 @@ DOCBOOKS := wanbook.xml z8530book.xml mc procfs-guide.xml writing_usb_driver.xml \ kernel-api.xml filesystems.xml lsm.xml usb.xml \ gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \ - genericirq.xml + genericirq.xml uio-howto.xml ### # The build process is as follows (targets):
Re: [PATCH 2/3] UIO: Documentation
Am Mittwoch 02 Mai 2007 01:42 schrieb Randy Dunlap:
Quoted 4 lines
Quoted 1 line
+<title>The Userspace I/O HOWTO</title>
Most of this reads well. Thanks.
A few typo corrections are below...
Thank you for your work. I generated a new patch that includes all your suggestions and also fixes the build problems.
[...]
Quoted 11 lines
However, it still fails 'make htmldocs' for me. What am I missing? How did it work for you?
My DTD doesn't like to see <varname> inside a <listitem>:
linux-2.6.21-rc7-mm2/Documentation/DocBook/uio-howto.xml:333: element listitem: validity error : Element listitem content does not follow the DTD, expecting (calloutlist | glosslist | itemizedlist | orderedlist | segmentedlist | simplelist | variablelist | caution | important | note | tip | warning | literallayout | programlisting | programlistingco | screen | screenco | screenshot | synopsis | cmdsynopsis | funcsynopsis | classsynopsis | fieldsynopsis | constructorsynopsis | destructorsynopsis | methodsynopsis | formalpara | para | simpara | address | blockquote | graphic | graphicco | mediaobject | mediaobjectco | informalequation | informalexample | informalfigure | informaltable | equation | example | figure | table | msgset | procedure | sidebar | qandaset | anchor | bridgehead | remark | highlights | abstract | authorblurb | epigraph | indexterm | beginpage)+, got (varname CDATA)so I removed most of the <varname>s and still had errors. Any suggestions?
Yes, this only occurs when the <listitem> content is not surrounded by <para></para>. I fixed that. I also changed the whole thing from "article" to "book" as all the other *.tmpl files are books.
[...]
Quoted 7 lines
Review
Quoted 5 lines
<listitem>
+<varname>void *internal_addr</varname>: If you have to access this memory(quoted diff) +3
-0+region from within your kernel module, you will want to map it internally by +using something like <function>ioremap_nocache()</function>. Addresses +returned by this function can not be mapped to user space, so you must notcannot
Here I also replaced ioremap_nocache() by ioremap(). I just fixed that in uio_cif.c and don't want to encourage other people to write the same nonsense.
Here's my patch, as I said, it should include your fixes as well:
drivers/uio/uio.c +4 -4
@@ -234,7 +234,7 @@/** * uio_event_notify - trigger an interrupt event -* @idev: UIO device where the event occured +* @info: UIO device capabilities */ void uio_event_notify (struct uio_info *info) {
@@ -583,8 +583,9 @@/** * uio_register_device - register a new userspace IO device * +* @owner: module that creates the new device * @parent: parent device -* @idev: device capabilities +* @info: UIO device capabilities * * returns zero on success or a negative error code. */
@@ -660,9 +661,8 @@/** * uio_unregister_device - unregister a industrial IO device -* @uiodev: UIO device driver identifier +* @info: UIO device capabilities * -* returns 0 on success */ void uio_unregister_device (struct uio_info *info) {
include/linux/uio_driver.h +4 -4
@@ -19,7 +19,7 @@#include <linux/interrupt.h> /** -* uio_mem - description of a UIO memory region +* struct uio_mem - description of a UIO memory region * @kobj: kobject for this mapping * @addr: address of the device's memory * @size: size of IO
@@ -39,13 +39,13 @@struct uio_device ;/** -* uio_info - UIO device capabilities +* struct uio_info - UIO device capabilities * @uio_dev: the UIO device this info belongs to * @name: device name * @version: device driver version * @mem: list of mappable memory regions, size==0 for end of list * @irq: interrupt number or UIO_IRQ_CUSTOM -* @irq_flags flags for request_irq() +* @irq_flags: flags for request_irq() * @priv: optional private data * @handler: the device's irq handler * @mmap: mmap operation for this uio device
@@ -56,7 +56,7 @@struct uio_device *uio_dev;char *name;char *version; -struct uio_mem mem[MAX_UIO_MAPS ]; +struct uio_mem mem[MAX_UIO_MAPS ];long irq;unsigned long irq_flags;void *priv;
Documentation/DocBook/Makefile +1 -1
@@ -11,7 +11,7 @@ procfs-guide.xml writing_usb_driver.xml \ kernel-api.xml filesystems.xml lsm.xml usb.xml \ gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \ - genericirq.xml + genericirq.xml uio-howto.xml ### # The build process is as follows (targets):
Documentation/DocBook/uio-howto.tmpl +65 -65
339 lines not on this page · raw message
Re: [PATCH 2/3] UIO: Documentation
Quoted 9 lines · On Wed, 2 May 2007 10:41:35 +0200 Hans-Jürgen Koch wrote:
Am Mittwoch 02 Mai 2007 01:42 schrieb Randy Dunlap:
Quoted 4 lines
Quoted 1 line
+<title>The Userspace I/O HOWTO</title>
Most of this reads well. Thanks.
A few typo corrections are below...Thank you for your work. I generated a new patch that includes all your suggestions and also fixes the build problems.
Hi,
What does your patch apply to, please? I get patch errors with it.
Quoted 27 lines
[...]
Quoted 11 lines
However, it still fails 'make htmldocs' for me. What am I missing? How did it work for you?
My DTD doesn't like to see <varname> inside a <listitem>:
linux-2.6.21-rc7-mm2/Documentation/DocBook/uio-howto.xml:333: element listitem: validity error : Element listitem content does not follow the DTD, expecting (calloutlist | glosslist | itemizedlist | orderedlist | segmentedlist | simplelist | variablelist | caution | important | note | tip | warning | literallayout | programlisting | programlistingco | screen | screenco | screenshot | synopsis | cmdsynopsis | funcsynopsis | classsynopsis | fieldsynopsis | constructorsynopsis | destructorsynopsis | methodsynopsis | formalpara | para | simpara | address | blockquote | graphic | graphicco | mediaobject | mediaobjectco | informalequation | informalexample | informalfigure | informaltable | equation | example | figure | table | msgset | procedure | sidebar | qandaset | anchor | bridgehead | remark | highlights | abstract | authorblurb | epigraph | indexterm | beginpage)+, got (varname CDATA)so I removed most of the <varname>s and still had errors. Any suggestions?
Yes, this only occurs when the <listitem> content is not surrounded by <para></para>. I fixed that. I also changed the whole thing from "article" to "book" as all the other *.tmpl files are books.
[...]
Quoted 7 lines
Review
Quoted 5 lines
<listitem>
+<varname>void *internal_addr</varname>: If you have to access this memory(quoted diff) +3
-0+region from within your kernel module, you will want to map it internally by +using something like <function>ioremap_nocache()</function>. Addresses +returned by this function can not be mapped to user space, so you must notcannot
Quoted 6 lines
Here I also replaced
ioremap_nocache()byioremap(). I just fixed that inuio_cif.cand don't want to encourage other people to write the same nonsense.Here's my patch, as I said, it should include your fixes as well:
Index:
linux-2.6.22-rc/drivers/uio/uio.c
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
Re: [PATCH 2/3] UIO: Documentation
Am Mittwoch 02 Mai 2007 schrieb Randy Dunlap:
Quoted 13 lines · On Wed, 2 May 2007 10:41:35 +0200 Hans-Jürgen Koch wrote:
Quoted 8 lines
Am Mittwoch 02 Mai 2007 01:42 schrieb Randy Dunlap:
Quoted 4 lines
Quoted 1 line
+<title>The Userspace I/O HOWTO</title>
Most of this reads well. Thanks.
A few typo corrections are below...Thank you for your work. I generated a new patch that includes all your suggestions and also fixes the build problems.
Hi,
What does your patch apply to, please? I get patch errors with it.
The patch goes on top of Greg's original patch plus the one I recently sent (adding the chapter about the userspace driver part). If you haven't got it handy, I mean this one:
http://marc.info/?l=linux-kernel&m=117788526325956&w=2
Thanks,
Hans
Randy Dunlap
Acked-byRe: [PATCH 2/3] UIO: Documentation
Quoted 10 lines · On Thu, 3 May 2007 00:00:28 +0200 Hans-Jürgen Koch wrote:
Am Mittwoch 02 Mai 2007 schrieb Randy Dunlap:
Quoted 9 lines · On Wed, 2 May 2007 10:41:35 +0200 Hans-Jürgen Koch wrote:
Quoted 8 lines
Am Mittwoch 02 Mai 2007 01:42 schrieb Randy Dunlap:
Quoted 4 lines
Quoted 1 line
+<title>The Userspace I/O HOWTO</title>
Most of this reads well. Thanks.
A few typo corrections are below...Thank you for your work. I generated a new patch that includes all your suggestions and also fixes the build problems.
OK, your fixes all look good, but still needs one minor fix (below).
---
From: Randy Dunlap <[email protected]>
Fix last UIO kernel-doc problem.
--- drivers/uio/uio.c | 1 - 1 file changed, 1 deletion(-)
drivers/uio/uio.c +0 -1
@@ -582,7 +582,6 @@ static void uio_class_destroy(void)/** * uio_register_device - register a new userspace IO device -* * @owner: module that creates the new device * @parent: parent device * @info: UIO device capabilities
Re: [PATCH 2/3] UIO: Documentation
Quoted 10 lines · Randy Dunlap
Quoted 8 lines · On Thu, 3 May 2007 00:00:28 +0200 Hans-J?rgen Koch wrote:
Am Mittwoch 02 Mai 2007 schrieb Randy Dunlap:
Quoted 7 lines · On Wed, 2 May 2007 10:41:35 +0200 Hans-J?rgen Koch wrote:
Quoted 6 lines
Am Mittwoch 02 Mai 2007 01:42 schrieb Randy Dunlap:
Quoted 4 lines
Quoted 1 line
+<title>The Userspace I/O HOWTO</title>
Most of this reads well. Thanks.
A few typo corrections are below...
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Thank you for your work. I generated a new patch that includes all your suggestions and also fixes the build problems.
OK, your fixes all look good, but still needs one minor fix (below).
Acked-by Randy Dunlap <[email protected]>
Hm, I have about 3 different patches here now, all dependant on each other, yet I can't tell which goes first :(
Can someone just send me 1, or 3 with the correct order in which to apply them?
thanks,
greg k-h
Re: [PATCH 2/3] UIO: Documentation
Am Donnerstag 03 Mai 2007 07:37 schrieb Greg KH:
Quoted 21 lines · Randy Dunlap
Quoted 10 lines · On Thu, 3 May 2007 00:00:28 +0200 Hans-J?rgen Koch wrote:
Quoted 9 lines
Am Mittwoch 02 Mai 2007 schrieb Randy Dunlap:
Quoted 7 lines · On Wed, 2 May 2007 10:41:35 +0200 Hans-J?rgen Koch wrote:
Quoted 6 lines
Am Mittwoch 02 Mai 2007 01:42 schrieb Randy Dunlap:
Quoted 4 lines
Quoted 1 line
+<title>The Userspace I/O HOWTO</title>
Most of this reads well. Thanks.
A few typo corrections are below...Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Thank you for your work. I generated a new patch that includes all your suggestions and also fixes the build problems.
OK, your fixes all look good, but still needs one minor fix (below).
Acked-by Randy Dunlap <[email protected]>Hm, I have about 3 different patches here now, all dependant on each other, yet I can't tell which goes first :(
Quoted 7 lines
Can someone just send me 1, or 3 with the correct order in which to apply them?
thanks,
greg k-h
Hi Greg,
I attached all the UIO patches I collected so far. This is my series file:
uio.patch
fix-early-irq-problem-in-uio.patch
uio-documentation.patch
fix-uio_read-type-problem.patch
uio-dummy.patch
uio-hilscher-cif-card-driver.patch
ioremap-in-uio-hilscher-cif.patch
add-userspace-howto-to-uio-doc.patch
fix-uio-doc-build-problems.patch
It should also work without uio-dummy.patch.
I added Randy's last one-line patch to fix-uio-doc-build-problems.patch.
All patches are
fix-uio-doc-build-problems.patch is also
Thanks,
Hans
drivers/uio/uio.c +4 -5
@@ -234,7 +234,7 @@/** * uio_event_notify - trigger an interrupt event -* @idev: UIO device where the event occured +* @info: UIO device capabilities */ void uio_event_notify (struct uio_info *info) {
@@ -582,9 +582,9 @@/** * uio_register_device - register a new userspace IO device -* +* @owner: module that creates the new device * @parent: parent device -* @idev: device capabilities +* @info: UIO device capabilities * * returns zero on success or a negative error code. */
@@ -660,9 +660,8 @@/** * uio_unregister_device - unregister a industrial IO device -* @uiodev: UIO device driver identifier +* @info: UIO device capabilities * -* returns 0 on success */ void uio_unregister_device (struct uio_info *info) {
include/linux/uio_driver.h +4 -4
@@ -19,7 +19,7 @@#include <linux/interrupt.h> /** -* uio_mem - description of a UIO memory region +* struct uio_mem - description of a UIO memory region * @kobj: kobject for this mapping * @addr: address of the device's memory * @size: size of IO
@@ -39,13 +39,13 @@struct uio_device ;/** -* uio_info - UIO device capabilities +* struct uio_info - UIO device capabilities * @uio_dev: the UIO device this info belongs to * @name: device name * @version: device driver version * @mem: list of mappable memory regions, size==0 for end of list * @irq: interrupt number or UIO_IRQ_CUSTOM -* @irq_flags flags for request_irq() +* @irq_flags: flags for request_irq() * @priv: optional private data * @handler: the device's irq handler * @mmap: mmap operation for this uio device
@@ -56,7 +56,7 @@struct uio_device *uio_dev;char *name;char *version; -struct uio_mem mem[MAX_UIO_MAPS ]; +struct uio_mem mem[MAX_UIO_MAPS ];long irq;unsigned long irq_flags;void *priv;
Documentation/DocBook/Makefile +1 -1
@@ -11,7 +11,7 @@ procfs-guide.xml writing_usb_driver.xml \ kernel-api.xml filesystems.xml lsm.xml usb.xml \ gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \ - genericirq.xml + genericirq.xml uio-howto.xml ### # The build process is as follows (targets):
Documentation/DocBook/uio-howto.tmpl +65 -65
339 lines not on this page · raw message
drivers/uio/uio.c +2 -1
@@ -633,6 +633,8 @@if (ret) goto err_uio_dev_add_attributes; + info->uio_dev = idev; +if (idev->info->irq >=0 ) { ret =request_irq (idev->info->irq, uio_interrupt, idev->info->irq_flags, idev->info->name, idev);
@@ -640,7 +642,6 @@ goto err_request_irq; } - info->uio_dev = idev;return 0 ; err_request_irq:
Documentation/DocBook/uio-howto.tmpl +114 -1
134 lines not on this page · raw message
drivers/uio/uio_cif.c +2 -3
@@ -64,9 +64,8 @@ info->mem[0 ].addr =pci_resource_start (dev,0 );if (!info->mem[0 ].addr) goto out_release; - info->mem[0 ].internal_addr =ioremap_nocache ( -pci_resource_start (dev,0 ), -pci_resource_len (dev,0 ) ); + info->mem[0 ].internal_addr =ioremap (pci_resource_start (dev,0 ), +pci_resource_len (dev,0 ) );if (!info->mem[0 ].internal_addr) goto out_release;
drivers/uio/uio.c +3 -3
@@ -264,7 +264,7 @@struct uio_listener {struct uio_device *dev; -int event_count; +s32 event_count; };static int uio_open (struct inode *inode,struct file *filep)
@@ -345,12 +345,12 @@struct uio_device *idev = listener->dev;DECLARE_WAITQUEUE (wait, current);ssize_t retval; -int event_count; +s32 event_count;if (idev->info->irq ==UIO_IRQ_NONE )return -EIO ; -if (count !=sizeof (int )) +if (count !=sizeof (s32))return -EINVAL ;add_wait_queue (&idev->wait, &wait);
Re: [PATCH 2/3] UIO: Documentation
Am Donnerstag 03 Mai 2007 08:39 schrieb Hans-Jürgen Koch:
Quoted 25 lines
Quoted 11 lines
Hm, I have about 3 different patches here now, all dependant on each other, yet I can't tell which goes first :(
Can someone just send me 1, or 3 with the correct order in which to apply them?
thanks,
greg k-h
Hi Greg,
I attached all the UIO patches I collected so far. This is my series file:uio.patch
fix-early-irq-problem-in-uio.patch
uio-documentation.patch
fix-uio_read-type-problem.patch
uio-dummy.patch
uio-hilscher-cif-card-driver.patch
ioremap-in-uio-hilscher-cif.patch
add-userspace-howto-to-uio-doc.patch
fix-uio-doc-build-problems.patch
Quoted 9 lines
It should also work without uio-dummy.patch.
I added Randy's last one-line patch to fix-uio-doc-build-problems.patch.All patches are
Signed-off-by Hans J. Koch <[email protected]>fix-uio-doc-build-problems.patch is also
Signed-off-by Randy Dunlap <[email protected]>
I also updated the original patch set with all these changes. They can be found here:
http://www.osadl.org/projects/downloads/UIO/kernel/
Thanks,
Hans
Re: [PATCH 2/3] UIO: Documentation
Quoted 32 lines · On Fri, 4 May 2007 11:37:09 +0200 Hans-Jürgen Koch wrote:
Am Donnerstag 03 Mai 2007 08:39 schrieb Hans-Jürgen Koch:
Quoted 31 lines
Quoted 11 lines
Hm, I have about 3 different patches here now, all dependant on each other, yet I can't tell which goes first :(
Can someone just send me 1, or 3 with the correct order in which to apply them?
thanks,
greg k-h
Hi Greg,
I attached all the UIO patches I collected so far. This is my series file:uio.patch
fix-early-irq-problem-in-uio.patch
uio-documentation.patch
fix-uio_read-type-problem.patch
uio-dummy.patch
uio-hilscher-cif-card-driver.patch
ioremap-in-uio-hilscher-cif.patch
add-userspace-howto-to-uio-doc.patch
fix-uio-doc-build-problems.patchIt should also work without uio-dummy.patch.
I added Randy's last one-line patch to fix-uio-doc-build-problems.patch.All patches are
Signed-off-by Hans J. Koch <[email protected]>
Quoted 8 lines
Quoted 3 lines
fix-uio-doc-build-problems.patch is also
Signed-off-by Randy Dunlap <[email protected]>I also updated the original patch set with all these changes. They can be found here:
Can one of you make sure that Andrew has a version in -mm that will build without bombing? Current 2.6.21-mm1 does this on UIO docs, but all of these have been fixed via email AFAIK:
Warning(/tester/linsrc/linux-2621-mm1//drivers/uio/uio.c:240): No description found for parameter 'info' Warning(/tester/linsrc/linux-2621-mm1//drivers/uio/uio.c:594): No description found for parameter 'owner' Warning(/tester/linsrc/linux-2621-mm1//drivers/uio/uio.c:594): No description found for parameter 'info' Warning(/tester/linsrc/linux-2621-mm1//drivers/uio/uio.c:667): No description found for parameter 'info' Error(/tester/linsrc/linux-2621-mm1//include/linux/uio_driver.h:29): cannot understand prototype: 'struct uio_mem ' Error(/tester/linsrc/linux-2621-mm1//include/linux/uio_driver.h:55): cannot understand prototype: 'struct uio_info ' Warning(/tester/linsrc/linux-2621-mm1//include/linux/uio_driver.h): no structured comments found make[1]: *** [Documentation/DocBook/kernel-api.xml] Error 2
make: *** [mandocs] Error 2
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
Re: [PATCH 2/3] UIO: Documentation
Am Montag 07 Mai 2007 19:46 schrieb Randy Dunlap:
Quoted 38 lines · On Fri, 4 May 2007 11:37:09 +0200 Hans-Jürgen Koch wrote:
Quoted 37 lines
Am Donnerstag 03 Mai 2007 08:39 schrieb Hans-Jürgen Koch:
Quoted 34 lines
Quoted 11 lines
Hm, I have about 3 different patches here now, all dependant on each other, yet I can't tell which goes first :(
Can someone just send me 1, or 3 with the correct order in which to apply them?
thanks,
greg k-h
Hi Greg,
I attached all the UIO patches I collected so far. This is my series file:uio.patch
fix-early-irq-problem-in-uio.patch
uio-documentation.patch
fix-uio_read-type-problem.patch
uio-dummy.patch
uio-hilscher-cif-card-driver.patch
ioremap-in-uio-hilscher-cif.patch
add-userspace-howto-to-uio-doc.patch
fix-uio-doc-build-problems.patchIt should also work without uio-dummy.patch.
I added Randy's last one-line patch to fix-uio-doc-build-problems.patch.All patches are
Signed-off-by Hans J. Koch <[email protected]>fix-uio-doc-build-problems.patch is also
Signed-off-by Randy Dunlap <[email protected]>
Quoted 7 lines
Quoted 4 lines
I also updated the original patch set with all these changes. They can be found here:
Can one of you make sure that Andrew has a version in -mm that will build without bombing?
Andrew usually takes Greg's patches AFAIK. The patches in
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/driver/
are definitely out of date. Greg, could you update them?
Quoted 12 lines
Current 2.6.21-mm1 does this on UIO docs,
but all of these have been fixed via email AFAIK:Warning(/tester/linsrc/linux-2621-mm1//drivers/uio/uio.c:240): No description found for parameter 'info' Warning(/tester/linsrc/linux-2621-mm1//drivers/uio/uio.c:594): No description found for parameter 'owner' Warning(/tester/linsrc/linux-2621-mm1//drivers/uio/uio.c:594): No description found for parameter 'info' Warning(/tester/linsrc/linux-2621-mm1//drivers/uio/uio.c:667): No description found for parameter 'info'
Error(/tester/linsrc/linux-2621-mm1//include/linux/uio_driver.h:29): cannot understand prototype: 'structuio_mem'Error(/tester/linsrc/linux-2621-mm1//include/linux/uio_driver.h:55): cannot understand prototype: 'structuio_info'Warning(/tester/linsrc/linux-2621-mm1//include/linux/uio_driver.h): no structured comments found make[1]: *** [Documentation/DocBook/kernel-api.xml] Error 2
make: *** [mandocs] Error 2
Yes, all of these are fixed in the patches I sent.
Thanks,
Hans
Flaws with "UIO: Add the User IO core code"
In reply to Greg Kroah-HartmanQuoted 4 lines
drivers/uio/uio.c new file +4
-0+static ssize_t uio_read (struct file *filep,char __user *buf, +size_t count,loff_t *ppos) +{ +struct uio_listener *listener = filep->private_data;
drivers/uio/uio.c line 354
Quoted 10 lines
drivers/uio/uio.c new file +10
-0+struct uio_device *idev = listener->dev; +DECLARE_WAITQUEUE (wait, current); +ssize_t retval; +int event_count; + +if (idev->info->irq ==UIO_IRQ_NONE ) +return -EIO ; + +if (count !=sizeof (int )) +return -EINVAL ;
AFAIK we don't currently have any platform that runs binaries with different sizes of "int" but this is a) an unsigned value anyway, and b) should be a fixed type (eg u32)
Otherwise it looks ok at the momenmt, although there is a real nasty waiting for anyone who tries to use it. At the point open is possible or IRQs can be enabled you are safe in the core merged as idev->info is always valid, but any driver module trying to go back via info->uio_dev has a NULL pointer for an early IRQ or open event.
This means that the fasync support in the current code is basically unusable until this is fixed
Alan
Re: Flaws with "UIO: Add the User IO core code"
Quoted 10 lines · Alan Cox
Quoted 10 lines
drivers/uio/uio.c new file +10
-0+static ssize_t uio_read (struct file *filep,char __user *buf, +size_t count,loff_t *ppos) +{ +struct uio_listener *listener = filep->private_data; +struct uio_device *idev = listener->dev; +DECLARE_WAITQUEUE (wait, current); +ssize_t retval; +int event_count; + +if (idev->info->irq ==UIO_IRQ_NONE )
Quoted 8 lines
drivers/uio/uio.c line 354
Quoted 4 lines
drivers/uio/uio.c new file +4
-0+return -EIO ; + +if (count !=sizeof (int )) +return -EINVAL ;AFAIK we don't currently have any platform that runs binaries with different sizes of "int" but this is a) an unsigned value anyway, and b) should be a fixed type (eg u32)
Good point.
Quoted 8 lines
Otherwise it looks ok at the momenmt, although there is a real nasty waiting for anyone who tries to use it. At the point open is possible or IRQs can be enabled you are safe in the core merged as
idev->infois always valid, but any driver module trying to go back viainfo->uio_devhas a NULL pointer for an early IRQ or open event.This means that the fasync support in the current code is basically unusable until this is fixed
We'll fix that ASAP.
tglx
Re: Flaws with "UIO: Add the User IO core code" (with patch)
In reply to Alan CoxAm Samstag 28 April 2007 01:19 schrieb Alan Cox:
Quoted 10 lines
Quoted 10 lines
(quoted diff) +10
-0+static ssize_t uio_read(struct file *filep, char __user *buf, + size_t count, loff_t *ppos) +{ + struct uio_listener *listener = filep->private_data; + struct uio_device *idev = listener->dev; + DECLARE_WAITQUEUE(wait, current); + ssize_t retval; + int event_count; + + if (idev->info->irq == UIO_IRQ_NONE)
Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ return -EIO; + + if (count != sizeof(int)) + return -EINVAL;AFAIK we don't currently have any platform that runs binaries with different sizes of "int" but this is a) an unsigned value anyway, and b) should be a fixed type (eg u32)
I reviewed the code once more and find it OK. There is only one legal value for the parameter "count" of uio_read(), and that's sizeof(int). The data that is actually read is the element "event" of struct uio_device, which is of type atomic_t. The latter has the size of an int.
Unfortunately, the fact that the read count _must_ be sizeof(int) is not mentioned in the documentation. I'll send a patch for that ASAP.
Quoted 6 lines
Otherwise it looks ok at the momenmt, although there is a real nasty waiting for anyone who tries to use it. At the point open is possible or IRQs can be enabled you are safe in the core merged as
idev->infois always valid, but any driver module trying to go back viainfo->uio_devhas a NULL pointer for an early IRQ or open event.
This patch should fix it:
drivers/uio/uio.c +2 -1
@@ -633,6 +633,8 @@if (ret) goto err_uio_dev_add_attributes; + info->uio_dev = idev; +if (idev->info->irq >=0 ) { ret =request_irq (idev->info->irq, uio_interrupt, idev->info->irq_flags, idev->info->name, idev);
@@ -640,7 +642,6 @@ goto err_request_irq; } - info->uio_dev = idev;return 0 ; err_request_irq:
Thanks for your review,
Hans
Re: Flaws with "UIO: Add the User IO core code" (with patch)
Quoted 6 lines
Quoted 3 lines
AFAIK we don't currently have any platform that runs binaries with different sizes of "int" but this is a) an unsigned value anyway, and b) should be a fixed type (eg u32)
I reviewed the code once more and find it OK. There is only one legal value for the parameter "count" of
uio_read(), and that's sizeof(int).
If you are a box with multiple supported binary types how big is an "int". We use explicit sizes to ensure that uio_read() will work when/if we get platforms which support binaries with differing ideas of the size of "int". Thus it should use s32 or s64 or similar.
Quoted 2 lines
The data that is actually read is the element "event" of struct
uio_device, which is of typeatomic_t. The latter has the size of an int.
The latter is the size of a kernel "int".
Other patch looks fine.
Re: Flaws with "UIO: Add the User IO core code" (with patch)
Quoted 11 lines · Alan Cox
Quoted 6 lines
Quoted 3 lines
AFAIK we don't currently have any platform that runs binaries with different sizes of "int" but this is a) an unsigned value anyway, and b) should be a fixed type (eg u32)
I reviewed the code once more and find it OK. There is only one legal value for the parameter "count" of
uio_read(), and that's sizeof(int).If you are a box with multiple supported binary types how big is an "int". We use explicit sizes to ensure that
uio_read()will work when/if we get platforms which support binaries with differing ideas of the size of "int". Thus it should use s32 or s64 or similar.
Well, it is kind of academic, as probably half of the user space interfaces will explode, but in theory you are right.
Hans, let's change it to u32 to get this out of the way.
tglx
Re: Flaws with "UIO: Add the User IO core code" (with patch)
In reply to Alan CoxAm Samstag 28 April 2007 22:24 schrieb Alan Cox:
Quoted 11 lines
Quoted 6 lines
Quoted 3 lines
AFAIK we don't currently have any platform that runs binaries with different sizes of "int" but this is a) an unsigned value anyway, and b) should be a fixed type (eg u32)
I reviewed the code once more and find it OK. There is only one legal value for the parameter "count" of
uio_read(), and that's sizeof(int).If you are a box with multiple supported binary types how big is an "int". We use explicit sizes to ensure that
uio_read()will work when/if we get platforms which support binaries with differing ideas of the size of "int". Thus it should use s32 or s64 or similar.
Here's a fix to that effect:
drivers/uio/uio.c +3 -3
@@ -264,7 +264,7 @@struct uio_listener {struct uio_device *dev; -int event_count; +s32 event_count; };static int uio_open (struct inode *inode,struct file *filep)
@@ -345,12 +345,12 @@struct uio_device *idev = listener->dev;DECLARE_WAITQUEUE (wait, current);ssize_t retval; -int event_count; +s32 event_count;if (idev->info->irq ==UIO_IRQ_NONE )return -EIO ; -if (count !=sizeof (int )) +if (count !=sizeof (s32))return -EINVAL ;add_wait_queue (&idev->wait, &wait);
Thanks,
Hans
Re: Flaws with "UIO: Add the User IO core code" (with patch)
Quoted 8 lines · Hans-Jürgen Koch
Am Samstag 28 April 2007 22:24 schrieb Alan Cox:
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
AFAIK we don't currently have any platform that runs binaries with different sizes of "int" but this is a) an unsigned value anyway, and b) should be a fixed type (eg u32)
I reviewed the code once more and find it OK. There is only one legal value for the parameter "count" of
uio_read(), and that's sizeof(int).
Quoted 6 lines
Quoted 4 lines
If you are a box with multiple supported binary types how big is an "int". We use explicit sizes to ensure that
uio_read()will work when/if we get platforms which support binaries with differing ideas of the size of "int". Thus it should use s32 or s64 or similar.Here's a fix to that effect:
Can you please add a matching paragraph to the documentation ?
tglx
Re: Flaws with "UIO: Add the User IO core code"
Am Samstag 28 April 2007 23:08 schrieb Thomas Gleixner:
Quoted 9 lines · Hans-Jürgen Koch
Quoted 8 lines
Am Samstag 28 April 2007 22:24 schrieb Alan Cox:
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
AFAIK we don't currently have any platform that runs binaries with different sizes of "int" but this is a) an unsigned value anyway, and b) should be a fixed type (eg u32)
I reviewed the code once more and find it OK. There is only one legal value for the parameter "count" of
uio_read(), and that's sizeof(int).
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
If you are a box with multiple supported binary types how big is an "int". We use explicit sizes to ensure that
uio_read()will work when/if we get platforms which support binaries with differing ideas of the size of "int". Thus it should use s32 or s64 or similar.Here's a fix to that effect:
Can you please add a matching paragraph to the documentation ?
Yes, I'll add a "How to write userspace code" section tomorrow. I'll send a patch as soon as it's ready.
Hans
Re: Flaws with "UIO: Add the User IO core code" (with patch)
Am Samstag 28 April 2007 23:14 schrieb Hans-Jürgen Koch:
Quoted 17 lines
Am Samstag 28 April 2007 23:08 schrieb Thomas Gleixner:
Quoted 16 lines · Hans-Jürgen Koch
Quoted 14 lines
Am Samstag 28 April 2007 22:24 schrieb Alan Cox:
Quoted 11 lines
Quoted 6 lines
Quoted 3 lines
AFAIK we don't currently have any platform that runs binaries with different sizes of "int" but this is a) an unsigned value anyway, and b) should be a fixed type (eg u32)
I reviewed the code once more and find it OK. There is only one legal value for the parameter "count" of
uio_read(), and that's sizeof(int).If you are a box with multiple supported binary types how big is an "int". We use explicit sizes to ensure that
uio_read()will work when/if we get platforms which support binaries with differing ideas of the size of "int". Thus it should use s32 or s64 or similar.Here's a fix to that effect:
Quoted 8 lines
Quoted 2 lines
Can you please add a matching paragraph to the documentation ?
Yes, I'll add a "How to write userspace code" section tomorrow. I'll send a patch as soon as it's ready.
Hans
Here's the promised update for the documentation:
Hans
Documentation/DocBook/uio-howto.tmpl +114 -1
@@ -30,6 +30,12 @@ <revhistory> <revision> + <revnumber>0.3</revnumber> + <date>2007-04-29</date> + <authorinitials>hjk</authorinitials> + <revremark>Added section about userspace drivers.</revremark> + </revision> + <revision> <revnumber>0.2</revnumber> <date>2007-02-13</date> <authorinitials>hjk</authorinitials>
@@ -484,14 +490,121 @@ </sect1> +<sect1 id="userspace_driver" xreflabel="Writing a driver in user space"> +<?dbhtml filename="userspace_driver.html"?> +<title>Writing a driver in userspace</title> + <para> + Once you have a working kernel module for your hardware, you can + write the userspace part of your driver. You don't need any special + libraries, your driver can be written in any reasonable language, + you can use floating point numbers and so on. In short, you can + use all the tools and libraries you'd normally use for writing a + userspace application. + </para> + +<sect2 id="getting_uio_information"> +<title>Getting information about your UIO device</title> + <para> + Information about all UIO devices is available in sysfs. The + first thing you should do in your driver is check + <varname>name</varname> and <varname>version</varname> to + make sure your talking to the right device and that its kernel + driver has the version you expect. + </para> + <para> + You should also make sure that the memory mapping you need + exists and has the size you expect. + </para> + <para> + There is a tool called <varname>lsuio</varname> that lists + UIO devices and their attributes. It is available here: + </para> + <para> + <ulink url="http://www.osadl.org/projects/downloads/UIO/user/"> + http://www.osadl.org/projects/downloads/UIO/user/</ulink> + </para> + <para> + With <varname>lsuio</varname> you can quickly check if your + kernel module is loaded and which attributes it exports. + Have a look at the manpage for details. + </para> + <para> + The source code of <varname>lsuio</varname> can serve as an + example for getting information about an UIO device. + The file <filename>uio_helper.c</filename> contains a lot of + functions you could use in your userspace driver code. + </para> +</sect2> + +<sect2 id="mmap_device_memory"> +<title>mmap() device memory</title> + <para> + After you made sure you've got the right device with the + memory mappings you need, all you have to do is to call + <function>mmap()</function> to map the device's memory + to userspace. + </para> + <para> + The parameter <varname>offset</varname> of the + <function>mmap()</function> call has a special meaning + for UIO devices: It is used to select which mapping of + your device you want to map. To map the memory of + mapping N, you have to use N times the page size as + your offset: + </para> +<programlisting format="linespecific"> + offset = N * getpagesize(); +</programlisting> + <para> + N starts from zero, so if you've got only one memory + range to map, set <varname>offset = 0</varname>. + A drawback of this technique is that memory is always + mapped beginning with its start address. + </para> +</sect2> + +<sect2 id="wait_for_interrupts"> +<title>Waiting for interrupts</title> + <para> + After you successfully mapped your devices memory, you + can access it like an ordinary array. Usually, you will + perform some initialization. After that, your hardware + starts working and will generate an interrupt as soon + as it's finished, has some data available, or needs your + attention because an error occured. + </para> + <para> + <filename>/dev/uioX</filename> is a read-only file. A + <function>read()</function> will always block until an + interrupt occurs. There is only one legal value for the + <varname>count</varname> parameter of + <function>read()</function>, and that is the size of a + signed 32 bit integer (4). Any other value for + <varname>count</varname> causes <function>read()</function> + to fail. The signed 32 bit integer read is the interrupt + count of your device. If the value is one more than the value + you read the last time, everything is OK. If the difference + is greater than one, you missed interrupts. + </para> + <para> + You can also use <function>select()</function> on + <filename>/dev/uioX</filename>. + </para> +</sect2> + +</sect1> + <appendix id="app1"> <title>Further information</title> <itemizedlist> <listitem><para> + <ulink url="http://www.osadl.org"> + OSADL homepage.</ulink> + </para></listitem> + <listitem><para> <ulink url="http://www.linutronix.de"> Linutronix homepage.</ulink> </para></listitem> - <listitem><para>...</para></listitem> </itemizedlist> </appendix>
Quoted 2 lines · On Fri, 27 Apr 2007 15:49:57 -0700 Greg KH <[email protected]> wrote:
Here are the updated UIO (Userspace I/O driver framework) patches for 2.6.21.
I'm a bit uncertain about the whole UIO idea, really. I have this vague feeling that we'd prefer to encourage people to move device drivers into GPL'ed kernel rather than encouraging them to do closed-source userspace implementations which will probably end up being slower, less reliable and unavailable on various architectures, distros, etc.
But I don't think I have the capacity to actually think about this further
- just tossing it out there ;)
Quoted 12 lines
They have been revamped from the last time you have seen them, and they include a real driver, the Hilscher CIF DeviceNet and Profibus card controller, which is being used in production systems with this driver framework right now. The kernel driver they replaced was a total mess, with over 60+ ioctls to try to control the different aspects of the device. See the last patch in this series for more details on this driver.
These patches include full documentation, are self-contained from the rest of the kernel, and have been in the -mm tree for the past few months with no complaints.
Quoted 7 lines
Please pull from:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/uio-2.6.git/Patches will be sent as a follow-on to this message to lkml for people to see.
drivers/uio/uio_cif.c | 156 ++++++++
eh? How come a particular device requires 156 lines of kernel code to support a userspace driver? Doesn't that kind of defeat the point?
Quoted 11 lines · Andrew Morton
Quoted 2 lines · On Fri, 27 Apr 2007 15:49:57 -0700 Greg KH <[email protected]> wrote:
Here are the updated UIO (Userspace I/O driver framework) patches for 2.6.21.
I'm a bit uncertain about the whole UIO idea, really. I have this vague feeling that we'd prefer to encourage people to move device drivers into GPL'ed kernel rather than encouraging them to do closed-source userspace implementations which will probably end up being slower, less reliable and unavailable on various architectures, distros, etc.
It's not a closed vs. open issue, it just turns out that a lot of people keep trying to write PCI drivers in userspace (how many different papers were published on this topic alone in the past year...). This framework is to allow this to happen in a sane and correct way.
Lots of different types of odd devices do not fit into the "kernelspace driver" framework very well for a variety of reasons:
- zillions of different controls in the card
- floating point is needed to compute the next step of an operation in moving a physical object
With this framework, we provide a solid and simple way to provide for these kinds of devices. The Linutronix guys have had a lot of experience in supporting this kind of hardware in the past and can provide better examples if you need.
But yes, it does allow you to write a PCI driver in userspace, being closed source, if you really want to. But if you do that, then you get _no_ advantages of being in the kernel (caching, common userspace interface, resource management, etc.) and need to handle that all yourself. Heck, that's pretty much what X does today for lots of old video cards :)
Quoted 15 lines
Quoted 15 lines
They have been revamped from the last time you have seen them, and they include a real driver, the Hilscher CIF DeviceNet and Profibus card controller, which is being used in production systems with this driver framework right now. The kernel driver they replaced was a total mess, with over 60+ ioctls to try to control the different aspects of the device. See the last patch in this series for more details on this driver.
These patches include full documentation, are self-contained from the rest of the kernel, and have been in the -mm tree for the past few months with no complaints.
Please pull from:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/uio-2.6.git/
Quoted 7 lines
Quoted 4 lines
Patches will be sent as a follow-on to this message to lkml for people to see.
drivers/uio/uio_cif.c | 156 ++++++++eh? How come a particular device requires 156 lines of kernel code to support a userspace driver? Doesn't that kind of defeat the point?
No, you still need kernel code to handle the interrupt properly, we do not want userspace to do this as it would slow the system down and do all sorts of other bad things. That's the main problem with all of those other proposals that people have for trying to do this kind of work in the past (can't share irqs, can't block on userspace in an interrupt handler, etc.)
thanks,
greg k-h
Quoted 10 lines · Greg KH
Quoted 5 lines
I'm a bit uncertain about the whole UIO idea, really. I have this vague feeling that we'd prefer to encourage people to move device drivers into GPL'ed kernel rather than encouraging them to do closed-source userspace implementations which will probably end up being slower, less reliable and unavailable on various architectures, distros, etc.
It's not a closed vs. open issue, it just turns out that a lot of people keep trying to write PCI drivers in userspace (how many different papers were published on this topic alone in the past year...). This framework is to allow this to happen in a sane and correct way.
Right, we don't need another dozen of attempts to get it wrong.
Interestingly enough some talks at ELC were using UIO already for testing and prototyping and the feedback from these guys was positive on the technical side and not at all focussed on the ability to do closed source hackery.
Quoted 5 lines
Lots of different types of odd devices do not fit into the "kernelspace driver" framework very well for a variety of reasons:
- zillions of different controls in the card
- floating point is needed to compute the next step of an operation in moving a physical object
It's not necessarily slower. We were able to optimize an application by using UIO and we got >20% performance gain, due to the fact that we can operate on the device directly instead of copying data back and forth between kernel and userspace for no good reason.
Removing the insane amount of 68 ioctls of the original in kernel driver, which are just there to flip some bit in the chip registers is definitely a win.
Having a sane user space driver instead of an eye-cancer causing kernel driver and a user space library, which needs to hide the ioctl madness away from the application programmer reduced the overall code size from
5264 lines of kernel code + 3275 lines of user space code
to
156 lines of kernel code + 2970 lines of user space code.
Quoted 4 lines
With this framework, we provide a solid and simple way to provide for these kinds of devices. The Linutronix guys have had a lot of experience in supporting this kind of hardware in the past and can provide better examples if you need.
UIO is not targeted on devices which are part of a kernel subsystem, it is targeted for self contained special devices, which have currently tons of out of tree drivers with an average quality of 0. Those devices do not fit in the in kernel driver landscape at all and we really should give those folks something sane to work from.
Quoted 6 lines
But yes, it does allow you to write a PCI driver in userspace, being closed source, if you really want to. But if you do that, then you get _no_ advantages of being in the kernel (caching, common userspace interface, resource management, etc.) and need to handle that all yourself. Heck, that's pretty much what X does today for lots of old video cards :)
Right, you can do closed source drivers and I prefer when people use this interface instead of fiddling with faked licenses and creating legal bordercases.
All drivers we did so far have LGPL user space counterparts and that's the preferred way to go.
Also we have the user space driver support for USB already and I have not seen negative impact from this one yet.
Quoted 11 lines
Quoted 4 lines
Quoted 1 line
drivers/uio/uio_cif.c | 156 ++++++++eh? How come a particular device requires 156 lines of kernel code to support a userspace driver? Doesn't that kind of defeat the point?
No, you still need kernel code to handle the interrupt properly, we do not want userspace to do this as it would slow the system down and do all sorts of other bad things. That's the main problem with all of those other proposals that people have for trying to do this kind of work in the past (can't share irqs, can't block on userspace in an interrupt handler, etc.)
Ack.
tglx
Quoted 5 lines
I'm a bit uncertain about the whole UIO idea, really. I have this vague feeling that we'd prefer to encourage people to move device drivers into GPL'ed kernel rather than encouraging them to do closed-source userspace implementations which will probably end up being slower, less reliable and unavailable on various architectures, distros, etc.
UIO is suprisingly close to chunks of the drm driver so the basic design seems to have some sanity to it.
Alan
Am Samstag 28 April 2007 01:04 schrieb Andrew Morton:
Quoted 6 lines
On Fri, 27 Apr 2007 15:49:57 -0700
Quoted 2 lines · Greg KH
Here are the updated UIO (Userspace I/O driver framework) patches for 2.6.21.
Quoted 8 lines
I'm a bit uncertain about the whole UIO idea, really. I have this vague feeling that we'd prefer to encourage people to move device drivers into GPL'ed kernel rather than encouraging them to do closed-source userspace implementations which will probably end up being slower, less reliable and unavailable on various architectures, distros, etc.
But I don't think I have the capacity to actually think about this further
- just tossing it out there ;)
Thanks for tossing it out ;-) I understand your uncertainty and I share your opinion about encouraging industry developers to GPL their drivers. It really took me some time until I understood that sometimes there are _good_ reasons for a closed driver. UIO is not intended for mass products like graphic cards. We're talking about companies who developed special hardware for use in special applications like machine control. They sometimes need to keep a part of their driver closed, at least for some time. Sometimes it's because they want to protect themselves, sometimes because their customer demands it. Usually, they know about the disadvantages you mentioned (if they're our customers, be sure we tell them!).
Anyway, UIO is not just a system to allow closed drivers. There are enough other reasons why these industry developers want userspace drivers. The most important one is that they're usually no experienced kernel developers. They can let somebody write the kernel part for them, and then write their driver using the tools and libraries they know, with floating point and all that stuff. It's just convenient. If I had to write a driver for a fieldbus card today, I'd use UIO. And I'd make it free software. UIO doesn't force anybody to close his drivers.
Quoted 16 lines
Quoted 16 lines
They have been revamped from the last time you have seen them, and they include a real driver, the Hilscher CIF DeviceNet and Profibus card controller, which is being used in production systems with this driver framework right now. The kernel driver they replaced was a total mess, with over 60+ ioctls to try to control the different aspects of the device. See the last patch in this series for more details on this driver.
These patches include full documentation, are self-contained from the rest of the kernel, and have been in the -mm tree for the past few months with no complaints.
Please pull from:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/uio-2.6.git/
Quoted 7 lines
Quoted 4 lines
Patches will be sent as a follow-on to this message to lkml for people to see.
drivers/uio/uio_cif.c | 156 ++++++++eh? How come a particular device requires 156 lines of kernel code to support a userspace driver? Doesn't that kind of defeat the point?
This is quite a large kernel module for an UIO device due to quite stupid hardware design. It needs two memory mappings, and the interrupt handler is not the simplest thing possible. BTW, I don't think that 156 lines is so much. It allows to handle quite a complex PCI card. And it's so simple that it can be even explained to industry programmers who are no kernel gurus.
Thanks,
Hans
Hi,
Quoted 18 lines · Greg KH
Here are the updated UIO (Userspace I/O driver framework) patches for 2.6.21.
Documentation/DocBook/kernel-api.tmpl | 4 + Documentation/DocBook/uio-howto.tmpl | 498 +++++++++++++++++++++++ drivers/Kconfig | 1 + drivers/Makefile | 1 + drivers/uio/Kconfig | 27 ++ drivers/uio/Makefile | 2 + drivers/uio/uio.c | 702 +++++++++++++++++++++++++++++++++ drivers/uio/uio_cif.c | 156 ++++++++ include/linux/uio_driver.h | 91 +++++ 9 files changed, 1482 insertions(+), 0 deletions(-) create mode 100644 Documentation/DocBook/uio-howto.tmpl create mode 100644 drivers/uio/Kconfig create mode 100644 drivers/uio/Makefile create mode 100644 drivers/uio/uio.c create mode 100644 drivers/uio/uio_cif.c create mode 100644
Quoted 2 lines
include/linux/uio_driver.h
uio_dummy.c (that should be present according documentation) seems missing.
I find the doc not very clear for the devices where there is no interrupt : they speak of some kernel timer, but a userspace timer could be used (and even the userspace driver could be written without kernel support at all).
At the end of the doc there is something about IRQ_HANDLED vs IRQ_NONE. Last time I check kernel irq code, in both case next irq handler are called. The only difference was that if all handler reply IRQ_NONE, the kernel gave an error about an unexpected interrupt.
Also why sysfs is used for describing the mapping instead of something like an ioctl ?
UIO could be useful in embedded system where sysfs is not always desirable.
Matthieu
Am Samstag 28 April 2007 15:00 schrieb Matthieu CASTET:
Quoted 3 lines
uio_dummy.c(that should be present according documentation) seems missing.
Well, uio_dummy was created during development to have something to test with. It calls uio_event_notify() from a timer routine to simulate interrupts without having a real hardware device.
Besides that, uio_dummy has no real use. It might or might not be useful to put it in mainline. IMHO, we should include it because it shows ow UIO works and gives developers the possibility to test at least parts of their userspace code without having the real hardware (e.g. on their laptop).
Quoted 5 lines
I find the doc not very clear for the devices where there is no interrupt : they speak of some kernel timer, but a userspace timer could be used (and even the userspace driver could be written without kernel support at all).
I'm afraid the doc too much emphasizes that timer. The reason was probably that I worked with uio_dummy at the time I wrote the doc. Fact is that you will rarely use a timer to generate interrupts. The only application I can think of is something where you want to poll a device, say, every 10msec. Then it might sometimes be the simplest solution to do it that way. But even then there are probably userspace-only solutions most of the time.
But in general you're right, if a device doesn't generate hardware interrupts, you don't need UIO.
Quoted 5 lines
At the end of the doc there is something about
IRQ_HANDLEDvsIRQ_NONE. Last time I check kernel irq code, in both case next irq handler are called. The only difference was that if all handler replyIRQ_NONE, the kernel gave an error about an unexpected interrupt.
It works like any other driver that handles interrupts. If you want to support shared interrupts, your handler needs to be able to find out whether its device caused the interrupt or something else. You return IRQ_HANDLED in the first case and IRQ_NONE in the second. If an interrupt occurs and there's no driver that handles it, then the kernel has every right to complain. Whoever enabled the interrupt must also be able to handle it. That's one of the reasons why we need a kernel module to handle interrupts, you can't do that from userspace.
Quoted 3 lines
Also why sysfs is used for describing the mapping instead of something like an ioctl ?
Introducing new ioctls is ugly.
Quoted 2 lines
UIO could be useful in embedded system where sysfs is not always desirable.
I see your point. But we need to make some information available for userspace, in a standardized way. It was a design decision, and I still find it quite good.
Thanks,
Hans
Quoted 11 lines · Greg KH
Here are the updated UIO (Userspace I/O driver framework) patches for 2.6.21.
They have been revamped from the last time you have seen them, and they include a real driver, the Hilscher CIF DeviceNet and Profibus card controller, which is being used in production systems with this driver framework right now. The kernel driver they replaced was a total mess, with over 60+ ioctls to try to control the different aspects of the device. See the last patch in this series for more details on this driver.
I have a political question, if I have a user space driver, is my kernel tainted or not? Does this open another multi-month flame war around GPL, BSD, NDA, source available but not GPL, and all the other things we talked to death about inserting non-GPL modules?
Signature · 3 lines
Bill Davidsen <[email protected]> "We have more to fear from the bungling of the incompetent than from the machinations of the wicked." - from Slashdot
Quoted 12 lines · Bill Davidsen
Quoted 11 lines · Greg KH
Here are the updated UIO (Userspace I/O driver framework) patches for 2.6.21.
They have been revamped from the last time you have seen them, and they include a real driver, the Hilscher CIF DeviceNet and Profibus card controller, which is being used in production systems with this driver framework right now. The kernel driver they replaced was a total mess, with over 60+ ioctls to try to control the different aspects of the device. See the last patch in this series for more details on this driver.
Quoted 4 lines
I have a political question, if I have a user space driver, is my kernel tainted or not? Does this open another multi-month flame war around GPL, BSD, NDA, source available but not GPL, and all the other things we talked to death about inserting non-GPL modules?
The kernel driver has to be GPL, the user space part can be as any user space code closed source. Of course we recommend to make it open as those user space drivers which we did so far are all licensed under LPGL.
There is nothing to flame, the user space boundary is entirely clear.
tglx
Am Samstag 28 April 2007 21:56 schrieb Bill Davidsen:
Quoted 12 lines
Quoted 11 lines · Greg KH
Here are the updated UIO (Userspace I/O driver framework) patches for 2.6.21.
They have been revamped from the last time you have seen them, and they include a real driver, the Hilscher CIF DeviceNet and Profibus card controller, which is being used in production systems with this driver framework right now. The kernel driver they replaced was a total mess, with over 60+ ioctls to try to control the different aspects of the device. See the last patch in this series for more details on this driver.
Quoted 2 lines
I have a political question, if I have a user space driver, is my kernel tainted or not?
Surely not. By using the kernel's userspace interface, you create no "derived work" of the kernel. See COPYING in the root directory of the kernel sources for details.
Quoted 3 lines
Does this open another multi-month flame war around GPL, BSD, NDA, source available but not GPL, and all the other things we talked to death about inserting non-GPL modules?
Hopefully not. BTW, all existing UIO userspace drivers I know about are GPL or LGPL.
Hans
Quoted 6 lines
Quoted 2 lines
I have a political question, if I have a user space driver, is my kernel tainted or not?
Surely not. By using the kernel's userspace interface, you create no "derived work" of the kernel. See COPYING in the root directory of the kernel sources for details.
That only covers normal system calls - but I don't think thats what is relevant, taints are for debug assistance not politics.
I think we should have a taint flag for UIO type drivers. Not for any licensing or political reason but for the simple fact it means that there may be other complexities to debugging - and not the same one as a binary module. Probably we want the same marker for mmap /dev/mem too.
Alan
Quoted 7 lines · Alan Cox
Quoted 6 lines
Quoted 2 lines
I have a political question, if I have a user space driver, is my kernel tainted or not?
Surely not. By using the kernel's userspace interface, you create no "derived work" of the kernel. See COPYING in the root directory of the kernel sources for details.
Quoted 7 lines
That only covers normal system calls - but I don't think thats what is relevant, taints are for debug assistance not politics.
I think we should have a taint flag for UIO type drivers. Not for any licensing or political reason but for the simple fact it means that there may be other complexities to debugging - and not the same one as a binary module. Probably we want the same marker for mmap
/dev/memtoo.
I agree, if we make it entirely clear that the flag is nonpolitical.
tglx
Quoted 11 lines · Thomas Gleixner
Quoted 10 lines · Alan Cox
Quoted 6 lines
Quoted 2 lines
I have a political question, if I have a user space driver, is my kernel tainted or not?
Surely not. By using the kernel's userspace interface, you create no "derived work" of the kernel. See COPYING in the root directory of the kernel sources for details.
That only covers normal system calls - but I don't think thats what is relevant, taints are for debug assistance not politics.
Quoted 6 lines
Quoted 4 lines
I think we should have a taint flag for UIO type drivers. Not for any licensing or political reason but for the simple fact it means that there may be other complexities to debugging - and not the same one as a binary module. Probably we want the same marker for mmap
/dev/memtoo.I agree, if we make it entirely clear that the flag is nonpolitical.
Hm, I don't know, what makes this different from the fact that we can mmap PCI device space today through the proc and sysfs entries? That's how X gets direct access to the hardware for a number of different cards, and that's pretty much the same thing as the UIO interface is doing.
Unless you think we should also use the same "taint" flag on those accesses too, and if so, I have no objection.
thanks,
greg k-h
Quoted 19 lines · Greg KH
Quoted 11 lines · Thomas Gleixner
Quoted 10 lines · Alan Cox
Quoted 6 lines
Quoted 2 lines
I have a political question, if I have a user space driver, is my kernel tainted or not?
Surely not. By using the kernel's userspace interface, you create no "derived work" of the kernel. See COPYING in the root directory of the kernel sources for details.
That only covers normal system calls - but I don't think thats what is relevant, taints are for debug assistance not politics.
Quoted 6 lines
Quoted 4 lines
I think we should have a taint flag for UIO type drivers. Not for any licensing or political reason but for the simple fact it means that there may be other complexities to debugging - and not the same one as a binary module. Probably we want the same marker for mmap
/dev/memtoo.I agree, if we make it entirely clear that the flag is nonpolitical.
Quoted 8 lines
Hm, I don't know, what makes this different from the fact that we can mmap PCI device space today through the proc and sysfs entries? That's how X gets direct access to the hardware for a number of different cards, and that's pretty much the same thing as the UIO interface is doing.
Unless you think we should also use the same "taint" flag on those accesses too, and if so, I have no objection.
Right, this is just a hint, that something in user space is accessing the hardware directly. Not a too bad idea, but pretty much useless when we add X to the picture as it will be set always :)
tglx
Quoted 7 lines · Thomas Gleixner
Quoted 3 lines
Unless you think we should also use the same "taint" flag on those accesses too, and if so, I have no objection.
Right, this is just a hint, that something in user space is accessing the hardware directly. Not a too bad idea, but pretty much useless when we add X to the picture as it will be set always :)
drivers/char/mem.c +3 -0
@@ -274,6 +274,9 @@ static int mmap_mem(struct file * file,if (!private_mapping_ok (vma))return -ENOSYS ; +if (strcmp (current->comm,"Xorg" ) !=0 ) + tainted |=TAINT_USER ; + vma->vm_page_prot =phys_mem_access_prot (file, vma->vm_pgoff, size, vma->vm_page_prot);
#<EOF>
Jan
Quoted 9 lines
Quoted 3 lines
Right, this is just a hint, that something in user space is accessing the hardware directly. Not a too bad idea, but pretty much useless when we add X to the picture as it will be set always :)
Index:
linux-2.6.21-mm_20040728/drivers/char/mem.c
===================================================================
drivers/char/mem.c static int mmap_mem(struct file * file, · line 279
Quoted 6 lines
drivers/char/mem.c +3
-0@@ -274,6 +274,9 @@ static int mmap_mem(struct file * file,if (!private_mapping_ok (vma))return -ENOSYS ; +if (strcmp (current->comm,"Xorg" ) !=0 ) + tainted |=TAINT_USER ; +
The X server has many names. Xorg isn't the name of the server here for example (its "X").
Alan
Hi!
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
I agree, if we make it entirely clear that the flag is nonpolitical.
Hm, I don't know, what makes this different from the fact that we can mmap PCI device space today through the proc and sysfs entries? That's how X gets direct access to the hardware for a number of different cards, and that's pretty much the same thing as the UIO interface is doing.
Quoted 6 lines
Quoted 2 lines
Unless you think we should also use the same "taint" flag on those accesses too, and if so, I have no objection.
Right, this is just a hint, that something in user space is accessing the hardware directly. Not a too bad idea, but pretty much useless when we add X to the picture as it will be set always :)
Some people -- like me -- use X68_fbcon over vesafb, in order not to be tainted this way.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html