Skip to contentSkip to conversation

request_irq() usage in wm8350_register_irq().

DISCUSSION Sebastian Andrzej Siewior 5 participants 14 messages Jan 21

lore
Share & tools
lore
#0 lore raw

Hi,

I've been staring wm8350_register_irq(). It does

| request_threaded_irq(irq + wm8350->irq_base, NULL,
| handler, flags, name, data);

and every single user passes 0 as flags. This means it asks for a threaded IRQ and does not pass IRQF_ONESHOT.

So either this is not working because it triggers the warnings
Threaded irq requested with handler=NULL and !ONESHOT

followed by -EINVAL _or_ every single user of this driver sits in system where the irqchip is IRQCHIP_ONESHOT_SAFE marked. Which is it?

Sebastian

#1 lore raw
Quoted 10 lines · Sebastian Andrzej Siewior

Hi,

I've been staring wm8350_register_irq(). It does

| request_threaded_irq(irq + wm8350->irq_base, NULL,
| handler, flags, name, data);

and every single user passes 0 as flags. This means it asks for a threaded IRQ and does not pass IRQF_ONESHOT.

Quoted 8 lines

So either this is not working because it triggers the warnings
Threaded irq requested with handler=NULL and !ONESHOT

followed by -EINVAL _or_ every single user of this driver sits in system where the irqchip is IRQCHIP_ONESHOT_SAFE marked. Which is it?

Sebastian

Or because request_threaded_irq() supplies a default handler, so handler!=NULL when it calls __setup_irq().

int request_threaded_irq(unsigned int irq, irq_handler_t handler,
irq_handler_t thread_fn, unsigned long irqflags, const char *devname, void *dev_id)
{

...

	if (!handler) {
		if (!thread_fn)
			return -EINVAL;
		handler = irq_default_primary_handler;
	}

...

	retval = __setup_irq(irq, desc, action);

...
}

#2 lore raw
Quoted 17 lines · Richard Fitzgerald

Or because request_threaded_irq() supplies a default handler, so handler!=NULL when it calls __setup_irq().

int request_threaded_irq(unsigned int irq, irq_handler_t handler,
irq_handler_t thread_fn, unsigned long irqflags, const char *devname, void *dev_id)
{

...

	if (!handler) {
		if (!thread_fn)
			return -EINVAL;
		handler = irq_default_primary_handler;
	}
Quoted 7 lines

...

	retval = __setup_irq(irq, desc, action);

...
}

->

| } else if (new->handler == irq_default_primary_handler &&
| !(desc->irq_data.chip->flags & IRQCHIP_ONESHOT_SAFE)) {
…

|                 pr_err("Threaded irq requested with handler=NULL and !ONESHOT for %s (irq %d)\n",
|                        new->name, irq);
|                 ret = -EINVAL;

Sebastian

#3 lore raw
Quoted 28 lines · Sebastian Andrzej Siewior
Quoted 17 lines · Richard Fitzgerald

Or because request_threaded_irq() supplies a default handler, so handler!=NULL when it calls __setup_irq().

int request_threaded_irq(unsigned int irq, irq_handler_t handler,
irq_handler_t thread_fn, unsigned long irqflags, const char *devname, void *dev_id)
{

...

	if (!handler) {
		if (!thread_fn)
			return -EINVAL;
		handler = irq_default_primary_handler;
	}
Quoted 7 lines

...

	retval = __setup_irq(irq, desc, action);

...
}

->

Quoted 8 lines

| } else if (new->handler == irq_default_primary_handler &&
| !(desc->irq_data.chip->flags & IRQCHIP_ONESHOT_SAFE)) {
…

|                 pr_err("Threaded irq requested with handler=NULL and !ONESHOT for %s (irq %d)\n",
|                        new->name, irq);
|                 ret = -EINVAL;

Sebastian

Ah. I didn't notice that. Confusing error message. It says "handler=NULL" but handler != NULL. More like "handler=default".

#4 lore raw
Quoted 2 lines · Richard Fitzgerald

Ah. I didn't notice that. Confusing error message. It says "handler=NULL" but handler != NULL. More like "handler=default".

The supplied argument was NULL.
Anyway. Do you happen to have an answer to my original question.

Sebastian

#5 lore raw
Quoted 6 lines · Sebastian Andrzej Siewior
Quoted 2 lines · Richard Fitzgerald

Ah. I didn't notice that. Confusing error message. It says "handler=NULL" but handler != NULL. More like "handler=default".

The supplied argument was NULL.
Anyway. Do you happen to have an answer to my original question.

Why not asking Mark? I think he might know more about this HW.

Btw, Mark, I noticed that your old addresses appear in Git history, are they working? Or do you want to add them into .mailmap?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw
Quoted 9 lines · Andy Shevchenko
Quoted 6 lines · Sebastian Andrzej Siewior
Quoted 2 lines · Richard Fitzgerald

Ah. I didn't notice that. Confusing error message. It says "handler=NULL" but handler != NULL. More like "handler=default".

The supplied argument was NULL.
Anyway. Do you happen to have an answer to my original question.

Why not asking Mark? I think he might know more about this HW.

What was the question?

Quoted 2 lines

Btw, Mark, I noticed that your old addresses appear in Git history, are they working? Or do you want to add them into .mailmap?

They'll be broken but I'm not sure I care.

#7 lore raw
Quoted 1 line · Mark Brown

What was the question?

to quote myself:

I've been staring wm8350_register_irq(). It does

| request_threaded_irq(irq + wm8350->irq_base, NULL,
| handler, flags, name, data);

and every single user passes 0 as flags. This means it asks for a threaded IRQ and does not pass IRQF_ONESHOT.

So either this is not working because it triggers the warnings
Threaded irq requested with handler=NULL and !ONESHOT

followed by -EINVAL _or_ every single user of this driver sits in system where the irqchip is IRQCHIP_ONESHOT_SAFE marked. Which is it?

Sebastian

#8 lore raw
Quoted 8 lines · Sebastian Andrzej Siewior

I've been staring wm8350_register_irq(). It does

| request_threaded_irq(irq + wm8350->irq_base, NULL,
| handler, flags, name, data);

and every single user passes 0 as flags. This means it asks for a threaded IRQ and does not pass IRQF_ONESHOT.

Quoted 6 lines

So either this is not working because it triggers the warnings
Threaded irq requested with handler=NULL and !ONESHOT

followed by -EINVAL _or_ every single user of this driver sits in system where the irqchip is IRQCHIP_ONESHOT_SAFE marked. Which is it?

The chip is only accessable via I2C or SPI so the primary interrupt handler is itself always running and reporting child interrupts in threaded context. They can't really deliver a hardirq context interrupt.

#9 lore raw
Quoted 13 lines · Mark Brown
Quoted 10 lines · Sebastian Andrzej Siewior

I've been staring wm8350_register_irq(). It does

| request_threaded_irq(irq + wm8350->irq_base, NULL,
| handler, flags, name, data);

and every single user passes 0 as flags. This means it asks for a threaded IRQ and does not pass IRQF_ONESHOT.

So either this is not working because it triggers the warnings
Threaded irq requested with handler=NULL and !ONESHOT

Quoted 8 lines
Quoted 3 lines

followed by -EINVAL _or_ every single user of this driver sits in system where the irqchip is IRQCHIP_ONESHOT_SAFE marked. Which is it?

The chip is only accessable via I2C or SPI so the primary interrupt handler is itself always running and reporting child interrupts in threaded context. They can't really deliver a hardirq context interrupt.

In that case it lacks the needed IRQF_ONEHOST flag and nobody noticed that request_irq() fails for a few years now. I add a patch to my stack…

Thanks Mark.

Sebastian

#10 lore raw
Quoted 10 lines · Sebastian Andrzej Siewior
Quoted 4 lines · Mark Brown

The chip is only accessable via I2C or SPI so the primary interrupt handler is itself always running and reporting child interrupts in threaded context. They can't really deliver a hardirq context interrupt.

In that case it lacks the needed IRQF_ONEHOST flag and nobody noticed that request_irq() fails for a few years now. I add a patch to my stack…

Thanks.

#11 lore raw
In reply to Mark Brown
Quoted 3 lines · Mark Brown
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Sebastian Andrzej Siewior

On 2026-01-21 11:53:28 [+0000], Richard Fitzgerald wrote:

...

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Ah. I didn't notice that. Confusing error message. It says "handler=NULL" but handler != NULL. More like "handler=default".

The supplied argument was NULL.
Anyway. Do you happen to have an answer to my original question.

Why not asking Mark? I think he might know more about this HW.

What was the question?

How does the IRQ handling work in this multifunctional device for its children? @bigeasy is puzzled here and he started this thread.

Quoted 4 lines
Quoted 2 lines

Btw, Mark, I noticed that your old addresses appear in Git history, are they working? Or do you want to add them into .mailmap?

They'll be broken but I'm not sure I care.

Hmm... I would have sent this email to your wolfsonmicro address :-)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#12 lore raw
In reply to Sebastian Andrzej Siewior
Quoted 8 lines · Sebastian Andrzej Siewior
Quoted 2 lines · Richard Fitzgerald

Ah. I didn't notice that. Confusing error message. It says "handler=NULL" but handler != NULL. More like "handler=default".

The supplied argument was NULL.
Anyway. Do you happen to have an answer to my original question.

Sebastian

Afraid I'm not familiar with the WM8350.

But I note that call is not registering against a real interrupt pin. It's registering against a virtual irqchip that is itself a threaded IRQ handler. Maybe that makes a difference. That top-level virtual IRQ handler is ONESHOT.

#13 lore raw
Quoted 8 lines · Richard Fitzgerald
Quoted 7 lines · Sebastian Andrzej Siewior
Quoted 2 lines · Richard Fitzgerald

Ah. I didn't notice that. Confusing error message. It says "handler=NULL" but handler != NULL. More like "handler=default".

The supplied argument was NULL.
Anyway. Do you happen to have an answer to my original question.

Quoted 8 lines
Quoted 1 line

Sebastian

Afraid I'm not familiar with the WM8350.

But I note that call is not registering against a real interrupt pin. It's registering against a virtual irqchip that is itself a threaded IRQ handler. Maybe that makes a difference. That top-level virtual IRQ handler is ONESHOT.

Yeah I suspect there is some trickery like this which means this doesn't actually cause a problem in practice, since these are internal IRQs to the chip, and the IRQ coming out of the chip is marked as one shot. So the alluded to IRQ storm probably can't happen as the chip level IRQ is still masked.

I also note the driver predates the check by a good few years, so it wouldn't have generated any errors whilst being developed. To be fair it has also never been the most heavily used driver, so quite plausible no one has noticed the error message since. I would wager the correct thing to do here is just to add the ONESHOT flag in.

Thanks,
Charles