1

I am going through the driver kernel modules in Linux kernel and usually request_irq() is called from the probe function. drivers/net/ethernet/natsemi/ns83820.ko can be one such example.

request_irq() calls request_threaded_irq() and this is mentioned in the comments:

This call allocates interrupt resources and enables the
interrupt line and IRQ handling. From the point this
call is made your handler function may be invoked.

link: https://elixir.bootlin.com/linux/latest/source/kernel/irq/manage.c#L1984

That means that handler can be invoked even before probe completes.

But I have noticed in many drivers that no care is taken for shared variables or fields of dev that can be read and modified simultaneously in probe and interrupt handler.

I want to know how often does this case occurs that probe and interrupt handler run in parallel.

1 Answer 1

1

The interrupt handler can be called while probe still hasn't finished. However, to have that happen, the device needs to be initialized and generate an interrupt. Quite often, the probe function will first initialize the device and ensure that it won't generate interrupts before requesting the irq. This ensures the handler will not be called until the driver is ready to handle the interrupts.

One common exception are the RTC drivers and I've been fixed some of those recently. This happens because the RTC is still running while linux is not and the driver must not reinitialize the device every times it boots. Here is one example:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=10d0c768cc6d581523d673b9d1b54213f8a5eb24

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.