简体   繁体   中英

Why will a scheduled tasklet from an interrupt handler not run

I have an interrupt handler which schedules a tasklet as follows (pseudo code) -

struct tasklet_struct mytasklet;

void my_tasklet_function(unsigned long arg1) {
    ...
    pr_alert("Inside tasklet function\n");
    ...
}

int my_probe() {
    ....
    ....
    tasklet_init(&mytasklet, my_tasklet_function, arg1);
    ....
    /* Register interrupt handler my_irq_handler*/
    ....
}

irqreturn_t my_irq_handler(int irq, void *data) {
    ...
    status = read_reg(base_addr, intr_status_reg_offset)
    write_reg(base_addr, intr_status_reg_offset, status);

    if (status & INTR_MASK_1) {
         ....
         pr_alert("intr 1 came\n");
    }
    ...
    ...
    pr_alert("Schedule tasklet\n");
    tasklet_schedule(&mytasklet);
    pr_alert("Exit irq\n");

    return IRQ_HANDLED;
}

It is observed that the kernel hangs after the following prints

intr 1 came
Schedule tasklet

The "Exit irq" print never shows up. The prints in the tasklet function are not printed.

  • What can be the reason for this tasklet not getting scheduled?

  • What can possibly cause the kernel to hang?

tasklet scheduling should NOT be done in IRQ handler. You can check the schedule_tasklet() code in lxr. In the IRQ handler, calling schedule_tasklet() only set the bit for the softirq, and link your tasklet.

When irq_exit() is called, it will check if it is still in interrupt context (nested interrupt). If not, and there is any tasklet enabled, it will call the softirq handlers, which in turn will call tasklet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM