Skip to contentSkip to conversation

Interrupts in modules

DISCUSSION Steve Papacharalambous 3 participants 3 messages Jul 21, 2001 – Jul 22, 2001 MIPS

lore
Share & tools
lore
#0 lore raw

Hi All,

Are there any limitations or precautions needed with interrupt handlers in loadable modules?

The reason for asking is that I have an interrupt handler which works fine when compiled into the kernel, but causes the kernel to crash when it is a loadable module,

Thanks,

Steve

#1 lore raw
Quoted 2 lines · Steve Papacharalambous

Are there any limitations or precautions needed with interrupt handlers in loadable modules?

There is a potential race condition when removing the module. rmmod will remove a module when its use count is zero. If the interrupt handler is invoked after the use count is tested but before the module cleanup routine is entered then the code can be removed while the interrupt handler is running. The 2.5 module load/unload system will remove this race.

In 2.4, your best option is to set a can_unload() function in the module. Unregister the interrupt handler in can_unload(), wait until the interrupt count goes to zero (might be running on another cpu) then return 0. See drivers/char/ftape/compressor/zftape-compress.c for an example.

Alternatively keep a use count for opens on the device. This assumes that the device does not generate interrupts while it is not open, not always true.

#2 lore raw
In reply to Steve Papacharalambous
Quoted 8 lines · Steve Papacharalambous

Hi All,

Are there any limitations or precautions needed with interrupt handlers in loadable modules?

The reason for asking is that I have an interrupt handler which works fine when compiled into the kernel, but causes the kernel to crash when it is a loadable module,

There are some gas bugs which may generate the bad binary code. It happened to me with the tulip driver. The current Linux binutils should be ok.

H.J.