如何确保我的内核配置为使用线程IRQ?

时间:2017-06-27 22:26:19

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

我正在尝试在我的4.11 Linux内核中的平台驱动程序代码中使用线程中断。我现在面临随机内核崩溃。在调试问题时,我如何确保我的内核实际上已准备好处理线程IRQ。为了安装中断处理程序,我使用的是devm_request_threaded_irq()。是否有一个补丁列表来检查是否已应用和/或CONFIG_选项列表以检查我的内核配置?

"aa"

/ * Kernel Crash * /

ret = devm_request_threaded_irq(dev,
                data->irq,  /* irq number */
                &abc_handle_irq,  /* top half handler */
                &abc_thread_irq,  /* threaded bottom half */
                IRQF_SHARED,
                DEVICE_NAME,
                (void *)pdev);
if (ret) {
    dev_err(dev, "devm_request_threaded_irq() failed: %d\n", ret);
    goto error;
}

/* Top Half */
irqreturn_t abc_handle_irq(struct device *dev)
{
    struct xxx_dev *xxx = dev_get_drvdata(dev);
    int ret = IRQ_HANDLED;
    u32 int_status;

    if (!xxx)
        return IRQ_NONE;
    ...
    ...    
    int_status = ioread32(xxx->reg_base + xxx_INTERRUPT_STATUS);

    if(/* int_status indicates error */) {
        /* ERROR case */
        dev_info(dev, "%s: Got ERROR!\n", __func__);
        /* clear the interrupt */
    }

    if (/* int_status has PICTURE_DONE_IRQ bit set */) {
        /* clear the interrupt */
        ....
        ret = IRQ_WAKE_THREAD;
    } else
        return IRQ_NONE;  /* spurious interrupt not interested */

    return ret;
}

/* Bottom Half */
irqreturn_t xxx_thread_irq(struct device *dev)
{
    struct xxx_dev *xxx = dev_get_drvdata(dev);
    irqreturn_t ret = IRQ_HANDLED;

    if (!xxx)
        return IRQ_NONE;

    dev_info(dev, "%s: IRQ\n", __func__);

    mutex_lock(&xxx->lock); /* lock is shared between the bottom half and a process context */

    /* Spurious interrupt */
    if (unlikely(!xxx->cmd)) {
        dev_err(dev, "%s: No pending encode\n", __func__);

        ret = IRQ_NONE;
        goto out_unlock;
    }

    xxx_yyy_command_completed(abc, pqr, 0);

    kfree(xxx->cmd);
    xxx->cmd = NULL;

out_unlock:
    mutex_unlock(&xxx->lock);
    dev_info(dev, "%s: exiting\n", __func__);
    return ret;
}

0 个答案:

没有答案