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

From: Stephen Warren
Date: Tue Mar 15 2005 - 14:29:18 EST


From: linux-kernel-owner@xxxxxxxxxxxxxxx
[mailto:linux-kernel-owner@xxxxxxxxxxxxxxx] On Behalf Of Peter Chubb
> >>>>> "Jon" == Jon Smirl <jonsmirl@xxxxxxxxx> 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@xxxxxxxxxx http://www.nvidia.com/
swarren@xxxxxxxxxxxxx http://www.wwwdotorg.org/pgp.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/