[pso] Tema 2 Linux - Alocare IRQs & inregistrare handler
Octavian Purdila
pso@cursuri.cs.pub.ro
Thu, 31 Mar 2005 16:35:48 +0300
On Thursday 31 March 2005 16:24, Horia Geanta wrote:
> Nu-mi imi este clar care este momentul in care se aloca irq-urile
> pentru driver si se face inregistrarea handler-ului.
>
> Citez din Linux Device Drivers (capitolul 10):
>
> "A module is expected to request an interrupt channel (or IRQ, for
> interrupt request) before using it and to release it when
> finished.[...] The interrupt handler can be installed either at
> driver initialization or when the device is first opened. Although
> installing the interrupt handler from within the module's
> initialization function might sound like a good idea, it often isn't,
> especially if your device does not share interrupts. Because the
> number of interrupt lines is limited, you don't want to waste them.
> You can easily end up with more devices in your computer than there
> are interrupts. If a module requests an IRQ at initialization, it
> prevents any other driver from using the interrupt, even if the
> device holding it is
> never used. Requesting the interrupt at device open, on the other
> hand, allows some
> sharing of resources."
>
Chestia cu "some sharing" dupa parerea mea este trasa de par. Solutia
corecta pentru problema cu faptul ca exista putine intreruperi este sa
folositi rutine de tratare partajabile.
> Intreb deoarece am experimentat cu driverele de serial din
> Linux (serial_core.ko + 8250.ko) si daca nu le dau parametri (==>
> folosesc IRQ-uri nepartajabile in mod implicit) :
> La cat /proc/interrupts nu apar IRQ3 si/sau IRQ4 "in use"
> La cat /dev/ttyS0 si apoi cat /proc/interrupts (in alta
> consola), apare IRQ3 si/sau 4
>
> Din test rezulta ca trebuie alocate imediat dupa incarcarea
> modulului (in functia data parametru lui module_init), dar asa este
> corect in general ?
Intr-adevar, e mai bine sa le alocati la open.
tavi