【问题标题】:Problem with IRQ handler: Flags mismatch irqIRQ 处理程序的问题:标志不匹配 irq
【发布时间】:2021-12-18 11:19:15
【问题描述】:

我正在使用线程 irq 实现一个中断处理模块。 我正面临这个错误:

1983.150961] Shut down eMMC app module init.
[ 1983.151115] genirq: Flags mismatch irq 49. 00000004 (eMMC_power_shutdown_irq_
handler) vs. 00000004 (xuartps)
fio@uz3cg-dgw:~$ (edited) 

我选择的标志是 #define IRQF_TRIGGER_HIGH 0x00000004 并在这种情况下分配给 IRQ 号 49。

这是我的代码:

static int __init shutdownemmc_module_init(void)
{
    printk("Shut down eMMC app module init. ");
    if (request_threaded_irq( IRQ_NO,                       //IRQ number
                            (void *) emmc_irq_handler,      //IRQ handler (Top half)
                            emmc_interrupt_thread_fn,       //IRQ Thread handler (Bottom half).When the handler function returns IRQ_WAKE_THREAD
                            IRQF_TRIGGER_HIGH,                    //Handler will be called in raising edge
                            "eMMC_power_shutdown_irq_handler",    //used to identify the device name using this IRQ
                            (void *)(emmc_irq_handler)))    //device id for shared IRQ
    {
        pr_err("Cannot register IRQ ");
        pr_err(" EIO %d , EINVAL %d\n", EIO, EINVAL);
        return 0;
    }
    pr_info("Interrupt handler...Done!!!\n");
    return 0;
}

有人可以解释什么是 Flags mismatch irq 问题以及如何解决这个问题吗? 谢谢, 安赫

【问题讨论】:

    标签: linux linux-kernel kernel interrupt interrupt-handling


    【解决方案1】:

    这是因为“xuartps”已经请求了IRQ号,并没有请求共享。

    从“kernel/irq/manage.c”中的__setup_irq() 中提取:

            /*
             * If nobody did set the configuration before, inherit
             * the one provided by the requester.
             */
            if (irqd_trigger_type_was_set(&desc->irq_data)) {
                oldtype = irqd_get_trigger_type(&desc->irq_data);
            } else {
                oldtype = new->flags & IRQF_TRIGGER_MASK;
                irqd_set_trigger_type(&desc->irq_data, oldtype);
            }
    
            if (!((old->flags & new->flags) & IRQF_SHARED) ||
                (oldtype != (new->flags & IRQF_TRIGGER_MASK)) ||
                ((old->flags ^ new->flags) & IRQF_ONESHOT))
                goto mismatch;
    

    在上面,old 是“xuartps”设置的现有处理程序。 new 是您的代码设置的新处理程序。为了共享 IRQ,上述条件之一是旧处理程序和新处理程序都需要使用 IRQF_SHARED 标志请求 IRQ。但是,如果底层中断应该是可共享的,驱动程序应该只设置IRQF_SHARED;例如:所有 PCI 中断都是可共享的,PCI 设备的驱动程序应请求设置了IRQF_SHARED 的中断。

    mismatch:
        if (!(new->flags & IRQF_PROBE_SHARED)) {
            pr_err("Flags mismatch irq %d. %08x (%s) vs. %08x (%s)\n",
                   irq, new->flags, new->name, old->flags, old->name);
    #ifdef CONFIG_DEBUG_SHIRQ
            dump_stack();
    #endif
        }
        ret = -EBUSY;
    

    上面是“标志不匹配”消息打印到内核日志的地方。

    如果您不希望已请求 IRQ,请检查您是否请求了正确的 IRQ。

    【讨论】:

      猜你喜欢
      • 2012-11-26
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多