Interrupt Sharing
A well-known ``feature'' of the PC is its inability to attach different devices to the same interrupt line. However, Linux 2.0 broke the spell. Even though my ISA hardware manual--a Linux-unaware book--says that ``at most one device'' can be attached to an IRQ line, the electrical signals don’t have these restrictions unless the device hardware is unfriendly by design. The problem is with the software.
Linux software support for sharing was developed for PCI devices, but it works with ISA boards as well. Needless to say, non-PC platforms and buses support interrupt sharing too.
In order to develop a driver that can manage a shared interrupt line, there are some details that need to be considered. As discussed below, some of the features described in this chapter are not available for devices using interrupt sharing. Whenever possible, it’s better to support sharing because it presents fewer problems for the final user.
Installing a Shared Handler
Shared interrupts are installed through request_irq just like owned ones, but there are two differences:
The
SA_SHIRQ
bit must be specified in theflags
argument when requesting the interrupt.The
dev_id
argument must be unique. Any pointer into the module’s address space will do, butdev_id
definitely cannot be set toNULL
.
The kernel keeps a list of shared handlers associated with the
interrupt, and dev_id
differentiates between them, like a driver’s signature. If two
drivers were to register NULL
as their signature ...
Get Linux Device Drivers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.