"Flags mismatch irq" register interrupt handler error

Question :

When you see the log "Flags mismatch irq ............", maybe you use the same irq number to register different interrupt handler .

irq number ---> handler_1
|
|--> handler_2
|
|--> handler_3
|
|--> handler_4

log

01-01 00:00:17.887 I/SMBCHG  (    0): ovp_handler_init: chip->cd_ac_acok_n_gpio_irq = 101
01-01 00:00:17.893 E/genirq  (    0): Flags mismatch irq 101. 00002003 (cd_ac_acok_n) vs. 00002003 (cd_acok_n_irq_1)
01-01 00:00:17.902 I/SMBCHG  (    0): ovp_handler_init: request irq cd_ac_acok_nerror.
void xxx_init(void)
{
...
...
chip->cd_ac_acok_n_gpio_irq = gpio_to_irq(chip->cd_ac_acok_n_gpio_number);
pr_err("chip->cd_ac_acok_n_gpio_irq = %d
", chip->cd_ac_acok_n_gpio_irq);
rc = request_irq(chip->cd_ac_acok_n_gpio_irq,
                          cd_ac_acok_n_gpio_isr,
                          IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
                          "cd_acok_n_irq_1",
                          chip);
...
...
}
void yyy_init(void)
{
...
...
        rc = request_irq(chip->cd_ac_acok_n_gpio_irq 
                                   handler_name,
                                   IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
                                   "cd_ac_acok_n",                                                                            
                                   chip);
...
...
}
...
...
		/*
		 * Can't share interrupts unless both agree to and are
		 * the same type (level, edge, polarity). So both flag
		 * fields must have IRQF_SHARED set and the bits which
		 * set the trigger type must match. Also all must
		 * agree on ONESHOT.
		 */
		if (!((old->flags & new->flags) & IRQF_SHARED) ||
		    ((old->flags ^ new->flags) & IRQF_TRIGGER_MASK) ||
		    ((old->flags ^ new->flags) & IRQF_ONESHOT))
			goto mismatch;
...
...
mismatch:
	if (!(new->flags & IRQF_PROBE_SHARED)) {
		pr_err("Flags mismatch irq %d. %08x (%s) vs. %08x (%s)
",
		       irq, new->flags, new->name, old->flags, old->name);
#ifdef CONFIG_DEBUG_SHIRQ
		dump_stack();
#endif
	}
...
...

android/kernel/msm-3.18/kernel/irq/manage.c

Solve :

If you want to use the same irq number to register different interrupt handler, please use IRQ_SHARED flags.

void xxx_init(void)
{
...
...
chip->cd_ac_acok_n_gpio_irq = gpio_to_irq(chip->cd_ac_acok_n_gpio_number);
pr_err("chip->cd_ac_acok_n_gpio_irq = %d
", chip->cd_ac_acok_n_gpio_irq);
rc = request_irq(chip->cd_ac_acok_n_gpio_irq, cd_ac_acok_n_gpio_isr,
                          IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT | IRQF_SHARED ,
                          "cd_acok_n_irq_1",
                          chip);
...
...
}
void yyy_init(void)
{
...
...
        rc = request_irq(chip->cd_ac_acok_n_gpio_irq 
                                  handler_name,
                                  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT | IRQF_SHARED,
                                  "cd_ac_acok_n",                                                                            
                                  chip);
...
...
}

Extension 1 :

If you register isr successful, the system has related information in /proc/interrupts

adb root
adb shell
cat /proc/interrupts

The first column is irq number.
The second ~ fifth column is the number of some cpu that execute isr.
The sixth ~ 7th is the source of hardware.
The 8th is isr or handler name.
The below code respond to the last row of the above picture

irq_number = gpio_to_irq(48);
rc = request_irq(irq_number,     // 55
                          isr_1,
                          IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT | IRQ_SHARED,
                          "cd_acok_n_irq",
                          chip);

rc = request_irq(irq_number,   // 55
                          isr_2,
                          IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT | IRQ_SHARED,
                          "cd_acok_n",
                          chip);

Reference :

http://blog.51cto.com/noican/1355357

原文地址:https://www.cnblogs.com/youchihwang/p/9051675.html