RE: User mode drivers: part 1, interrupt handling (patch for 2.6.11)

Stephen Warren
2005-03-15T19:25:27Z

From: linux-kernel-owner@vger.kernel.org
[mailto:linux-kernel-owner@vger.kernel.org] On Behalf Of Peter Chubb
> >>>>> "Jon" == Jon Smirl <jonsmirl@gmail.com> writes:
>
> >> The scenario I'm thinking about with these patches are things like
> >> low-latency user-level networking between nodes in a cluster, where
> >> for good performance even with a kernel driver you don't want to
> >> share your interrupt line with anything else.
>
> Jon> The code needs to refuse to install if the IRQ line is shared.
>
> It does. The request_irq() call explicitly does not include SA_SHARED
> in its flags, so if the line is shared, it'll return an error to user
> space when the driver tries to open the file representing the
interrupt.

I actually have a simple case of user-mode handling of shared IRQs
working, based off the Gelato work from maybe 6 months ago.

What I did was add a new IOCTL to tell the kernel code how to clear the
interrupt status (or disable the interrupt output on the card, as
appropriate).

This basically took the form of telling the kernel to map a specified
subsection of a specified BAR into kernel space for register access,
then execute a small configurable read-modify-write sequence for the
actual interrupt disable (configurable read/write address, optionally no
read, configurable and/or/shift of the read value (or initial constant)
before write etc.)

This would probably cover most situations.

Once the interrupt is disabled/cleared, user-space can handle it just
like a non-shared IRQ, and finally re-enable it if the kernel mode
twiddling was a disable rather than a status clear.

This is probably pretty generic, and at least will open the code up to
handling a lot more devices, even if not everthing.

Also, the kernel detects a release on the file-handle, and can execute a
different configurable register access sequence to permanently disable
interrupts and/or reset the device, for safety once the user-space app
quits.

--
Stephen Warren, Software Engineer, NVIDIA, Fort Collins, CO
swarren@nvidia.com http://www.nvidia.com/
swarren@wwwdotorg.org http://www.wwwdotorg.org/pgp.html