Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ab86e576 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6:
  Driver Core: devtmpfs - kernel-maintained tmpfs-based /dev
  debugfs: Modify default debugfs directory for debugging pktcdvd.
  debugfs: Modified default dir of debugfs for debugging UHCI.
  debugfs: Change debugfs directory of IWMC3200
  debugfs: Change debuhgfs directory of trace-events-sample.h
  debugfs: Fix mount directory of debugfs by default in events.txt
  hpilo: add poll f_op
  hpilo: add interrupt handler
  hpilo: staging for interrupt handling
  driver core: platform_device_add_data(): use kmemdup()
  Driver core: Add support for compatibility classes
  uio: add generic driver for PCI 2.3 devices
  driver-core: move dma-coherent.c from kernel to driver/base
  mem_class: fix bug
  mem_class: use minor as index instead of searching the array
  driver model: constify attribute groups
  UIO: remove 'default n' from Kconfig
  Driver core: Add accessor for device platform data
  Driver core: move dev_get/set_drvdata to drivers/base/dd.c
  Driver core: add new device to bus's list before probing
parents 7ea61767 2b2af54a
Loading
Loading
Loading
Loading
+163 −0
Original line number Original line Diff line number Diff line
@@ -25,6 +25,10 @@
	<year>2006-2008</year>
	<year>2006-2008</year>
	<holder>Hans-Jürgen Koch.</holder>
	<holder>Hans-Jürgen Koch.</holder>
</copyright>
</copyright>
<copyright>
	<year>2009</year>
	<holder>Red Hat Inc, Michael S. Tsirkin (mst@redhat.com)</holder>
</copyright>


<legalnotice>
<legalnotice>
<para>
<para>
@@ -41,6 +45,13 @@ GPL version 2.
</abstract>
</abstract>


<revhistory>
<revhistory>
	<revision>
	<revnumber>0.9</revnumber>
	<date>2009-07-16</date>
	<authorinitials>mst</authorinitials>
	<revremark>Added generic pci driver
		</revremark>
	</revision>
	<revision>
	<revision>
	<revnumber>0.8</revnumber>
	<revnumber>0.8</revnumber>
	<date>2008-12-24</date>
	<date>2008-12-24</date>
@@ -809,6 +820,158 @@ framework to set up sysfs files for this region. Simply leave it alone.


</chapter>
</chapter>


<chapter id="uio_pci_generic" xreflabel="Using Generic driver for PCI cards">
<?dbhtml filename="uio_pci_generic.html"?>
<title>Generic PCI UIO driver</title>
	<para>
	The generic driver is a kernel module named uio_pci_generic.
	It can work with any device compliant to PCI 2.3 (circa 2002) and
	any compliant PCI Express device. Using this, you only need to
        write the userspace driver, removing the need to write
        a hardware-specific kernel module.
	</para>

<sect1 id="uio_pci_generic_binding">
<title>Making the driver recognize the device</title>
	<para>
Since the driver does not declare any device ids, it will not get loaded
automatically and will not automatically bind to any devices, you must load it
and allocate id to the driver yourself. For example:
	<programlisting>
 modprobe uio_pci_generic
 echo &quot;8086 10f5&quot; &gt; /sys/bus/pci/drivers/uio_pci_generic/new_id
	</programlisting>
	</para>
	<para>
If there already is a hardware specific kernel driver for your device, the
generic driver still won't bind to it, in this case if you want to use the
generic driver (why would you?) you'll have to manually unbind the hardware
specific driver and bind the generic driver, like this:
	<programlisting>
    echo -n 0000:00:19.0 &gt; /sys/bus/pci/drivers/e1000e/unbind
    echo -n 0000:00:19.0 &gt; /sys/bus/pci/drivers/uio_pci_generic/bind
	</programlisting>
	</para>
	<para>
You can verify that the device has been bound to the driver
by looking for it in sysfs, for example like the following:
	<programlisting>
    ls -l /sys/bus/pci/devices/0000:00:19.0/driver
	</programlisting>
Which if successful should print
	<programlisting>
  .../0000:00:19.0/driver -&gt; ../../../bus/pci/drivers/uio_pci_generic
	</programlisting>
Note that the generic driver will not bind to old PCI 2.2 devices.
If binding the device failed, run the following command:
	<programlisting>
  dmesg
	</programlisting>
and look in the output for failure reasons
	</para>
</sect1>

<sect1 id="uio_pci_generic_internals">
<title>Things to know about uio_pci_generic</title>
	<para>
Interrupts are handled using the Interrupt Disable bit in the PCI command
register and Interrupt Status bit in the PCI status register.  All devices
compliant to PCI 2.3 (circa 2002) and all compliant PCI Express devices should
support these bits.  uio_pci_generic detects this support, and won't bind to
devices which do not support the Interrupt Disable Bit in the command register.
	</para>
	<para>
On each interrupt, uio_pci_generic sets the Interrupt Disable bit.
This prevents the device from generating further interrupts
until the bit is cleared. The userspace driver should clear this
bit before blocking and waiting for more interrupts.
	</para>
</sect1>
<sect1 id="uio_pci_generic_userspace">
<title>Writing userspace driver using uio_pci_generic</title>
	<para>
Userspace driver can use pci sysfs interface, or the
libpci libray that wraps it, to talk to the device and to
re-enable interrupts by writing to the command register.
	</para>
</sect1>
<sect1 id="uio_pci_generic_example">
<title>Example code using uio_pci_generic</title>
	<para>
Here is some sample userspace driver code using uio_pci_generic:
<programlisting>
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;sys/stat.h&gt;
#include &lt;fcntl.h&gt;
#include &lt;errno.h&gt;

int main()
{
	int uiofd;
	int configfd;
	int err;
	int i;
	unsigned icount;
	unsigned char command_high;

	uiofd = open(&quot;/dev/uio0&quot;, O_RDONLY);
	if (uiofd &lt; 0) {
		perror(&quot;uio open:&quot;);
		return errno;
	}
	configfd = open(&quot;/sys/class/uio/uio0/device/config&quot;, O_RDWR);
	if (uiofd &lt; 0) {
		perror(&quot;config open:&quot;);
		return errno;
	}

	/* Read and cache command value */
	err = pread(configfd, &amp;command_high, 1, 5);
	if (err != 1) {
		perror(&quot;command config read:&quot;);
		return errno;
	}
	command_high &amp;= ~0x4;

	for(i = 0;; ++i) {
		/* Print out a message, for debugging. */
		if (i == 0)
			fprintf(stderr, &quot;Started uio test driver.\n&quot;);
		else
			fprintf(stderr, &quot;Interrupts: %d\n&quot;, icount);

		/****************************************/
		/* Here we got an interrupt from the
		   device. Do something to it. */
		/****************************************/

		/* Re-enable interrupts. */
		err = pwrite(configfd, &amp;command_high, 1, 5);
		if (err != 1) {
			perror(&quot;config write:&quot;);
			break;
		}

		/* Wait for next interrupt. */
		err = read(uiofd, &amp;icount, 4);
		if (err != 4) {
			perror(&quot;uio read:&quot;);
			break;
		}

	}
	return errno;
}

</programlisting>
	</para>
</sect1>

</chapter>

<appendix id="app1">
<appendix id="app1">
<title>Further information</title>
<title>Further information</title>
<itemizedlist>
<itemizedlist>
+12 −12
Original line number Original line Diff line number Diff line
@@ -22,12 +22,12 @@ tracing information should be printed.
---------------------------------
---------------------------------


The events which are available for tracing can be found in the file
The events which are available for tracing can be found in the file
/debug/tracing/available_events.
/sys/kernel/debug/tracing/available_events.


To enable a particular event, such as 'sched_wakeup', simply echo it
To enable a particular event, such as 'sched_wakeup', simply echo it
to /debug/tracing/set_event. For example:
to /sys/kernel/debug/tracing/set_event. For example:


	# echo sched_wakeup >> /debug/tracing/set_event
	# echo sched_wakeup >> /sys/kernel/debug/tracing/set_event


[ Note: '>>' is necessary, otherwise it will firstly disable
[ Note: '>>' is necessary, otherwise it will firstly disable
  all the events. ]
  all the events. ]
@@ -35,15 +35,15 @@ to /debug/tracing/set_event. For example:
To disable an event, echo the event name to the set_event file prefixed
To disable an event, echo the event name to the set_event file prefixed
with an exclamation point:
with an exclamation point:


	# echo '!sched_wakeup' >> /debug/tracing/set_event
	# echo '!sched_wakeup' >> /sys/kernel/debug/tracing/set_event


To disable all events, echo an empty line to the set_event file:
To disable all events, echo an empty line to the set_event file:


	# echo > /debug/tracing/set_event
	# echo > /sys/kernel/debug/tracing/set_event


To enable all events, echo '*:*' or '*:' to the set_event file:
To enable all events, echo '*:*' or '*:' to the set_event file:


	# echo *:* > /debug/tracing/set_event
	# echo *:* > /sys/kernel/debug/tracing/set_event


The events are organized into subsystems, such as ext4, irq, sched,
The events are organized into subsystems, such as ext4, irq, sched,
etc., and a full event name looks like this: <subsystem>:<event>.  The
etc., and a full event name looks like this: <subsystem>:<event>.  The
@@ -52,29 +52,29 @@ file. All of the events in a subsystem can be specified via the syntax
"<subsystem>:*"; for example, to enable all irq events, you can use the
"<subsystem>:*"; for example, to enable all irq events, you can use the
command:
command:


	# echo 'irq:*' > /debug/tracing/set_event
	# echo 'irq:*' > /sys/kernel/debug/tracing/set_event


2.2 Via the 'enable' toggle
2.2 Via the 'enable' toggle
---------------------------
---------------------------


The events available are also listed in /debug/tracing/events/ hierarchy
The events available are also listed in /sys/kernel/debug/tracing/events/ hierarchy
of directories.
of directories.


To enable event 'sched_wakeup':
To enable event 'sched_wakeup':


	# echo 1 > /debug/tracing/events/sched/sched_wakeup/enable
	# echo 1 > /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable


To disable it:
To disable it:


	# echo 0 > /debug/tracing/events/sched/sched_wakeup/enable
	# echo 0 > /sys/kernel/debug/tracing/events/sched/sched_wakeup/enable


To enable all events in sched subsystem:
To enable all events in sched subsystem:


	# echo 1 > /debug/tracing/events/sched/enable
	# echo 1 > /sys/kernel/debug/tracing/events/sched/enable


To eanble all events:
To eanble all events:


	# echo 1 > /debug/tracing/events/enable
	# echo 1 > /sys/kernel/debug/tracing/events/enable


When reading one of these enable files, there are four results:
When reading one of these enable files, there are four results:


+7 −0
Original line number Original line Diff line number Diff line
@@ -2218,6 +2218,13 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git
S:	Maintained
S:	Maintained
F:	include/asm-generic
F:	include/asm-generic


GENERIC UIO DRIVER FOR PCI DEVICES
M:	Michael S. Tsirkin <mst@redhat.com>
L:	kvm@vger.kernel.org
L:	linux-kernel@vger.kernel.org
S:	Supported
F:	drivers/uio/uio_pci_generic.c

GFS2 FILE SYSTEM
GFS2 FILE SYSTEM
M:	Steven Whitehouse <swhiteho@redhat.com>
M:	Steven Whitehouse <swhiteho@redhat.com>
L:	cluster-devel@redhat.com
L:	cluster-devel@redhat.com
+1 −1
Original line number Original line Diff line number Diff line
@@ -903,7 +903,7 @@ static struct attribute_group disk_attr_group = {
	.attrs = disk_attrs,
	.attrs = disk_attrs,
};
};


static struct attribute_group *disk_attr_groups[] = {
static const struct attribute_group *disk_attr_groups[] = {
	&disk_attr_group,
	&disk_attr_group,
	NULL
	NULL
};
};
+25 −0
Original line number Original line Diff line number Diff line
@@ -8,6 +8,31 @@ config UEVENT_HELPER_PATH
	  Path to uevent helper program forked by the kernel for
	  Path to uevent helper program forked by the kernel for
	  every uevent.
	  every uevent.


config DEVTMPFS
	bool "Create a kernel maintained /dev tmpfs (EXPERIMENTAL)"
	depends on HOTPLUG && SHMEM && TMPFS
	help
	  This creates a tmpfs filesystem, and mounts it at bootup
	  and mounts it at /dev. The kernel driver core creates device
	  nodes for all registered devices in that filesystem. All device
	  nodes are owned by root and have the default mode of 0600.
	  Userspace can add and delete the nodes as needed. This is
	  intended to simplify bootup, and make it possible to delay
	  the initial coldplug at bootup done by udev in userspace.
	  It should also provide a simpler way for rescue systems
	  to bring up a kernel with dynamic major/minor numbers.
	  Meaningful symlinks, permissions and device ownership must
	  still be handled by userspace.
	  If unsure, say N here.

config DEVTMPFS_MOUNT
	bool "Automount devtmpfs at /dev"
	depends on DEVTMPFS
	help
	  This will mount devtmpfs at /dev if the kernel mounts the root
	  filesystem. It will not affect initramfs based mounting.
	  If unsure, say N here.

config STANDALONE
config STANDALONE
	bool "Select only drivers that don't need compile-time external firmware" if EXPERIMENTAL
	bool "Select only drivers that don't need compile-time external firmware" if EXPERIMENTAL
	default y
	default y
Loading