本文介绍了当我们使用 irq_set_chained_handler 时,irq 行是否会被禁用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们使用 irq_set_chained_handler 时,当我们为相关的处理程序提供服务时,irq 行不会被禁用,就像 request_irq 一样.

When we use irq_set_chained_handler the irq line will not be disabled or not, when we are servicing the associated handler, as in case of request_irq.

推荐答案

中断是如何设置的并不重要.当发生任何中断时,在中断处理程序期间将禁用所有中断(对于该 CPU).例如,在 ARM 架构上,在 C 代码中找到中断处理的第一个位置是 asm_do_IRQ() 函数(在 arch/arm/kernel/irq.c 中定义).它是从汇编代码中调用的.对于任何中断(无论是由 request_irq() 还是由 irq_set_chained_handler() 请求),都会调用相同的 asm_do_IRQ() 函数,并且中断由 ARM CPU 自动禁用.请参阅这个答案 了解详情.

It doesn't matter how the interrupt was setup. When any interrupt occurred, all interrupts (for this CPU) will be disabled during the interrupt handler. For example, on ARM architecture first place in C code where interrupt handling is found is asm_do_IRQ() function (defined in arch/arm/kernel/irq.c). It's being called from assembler code. For any interrupt (whether it was requested by request_irq() or by irq_set_chained_handler()) the same asm_do_IRQ() function is called, and interrupts are disabled automatically by ARM CPU. See this answer for details.

另外,值得一提的是,前段时间Linux内核提供了两种类型的中断:快"和慢".快速中断(当使用 IRQF_DISABLEDSA_INTERRUPT 标志时)在禁用中断的情况下运行,并且这些处理程序应该非常短且快速.另一方面,慢中断在重新启用中断的情况下运行,因为慢中断的处理程序可能需要大量时间来处理.

Also, it worth to be mentioned that some time ago Linux kernel was providing two types of interrupts: "fast" and "slow" ones. Fast interrupts (when using IRQF_DISABLED or SA_INTERRUPT flag) were running with disabled interrupts, and those handlers supposed to be very short and quick. Slow interrupts, on the other hand, were running with re-enabled interrupts, because handlers for slow interrupts may take much of time to be handled.

在现代版本的 Linux 内核上,所有中断都被认为是快速"的,并且在禁用中断的情况下运行.具有巨大处理程序的中断必须以线程方式实现(或使用 local_irq_enable_in_hardirq() 在 ISR 中手动启用中断).

On modern versions of Linux kernel all interrupts are considered as "fast" and are running with interrupts disabled. Interrupts with huge handlers must be implemented as threaded (or enable interrupts manually in ISR using local_irq_enable_in_hardirq()).

该行为在 Linux 内核 v2.6.35 中被 这个 提交.您可以在此处找到更多详细信息.

That behavior was changed in Linux kernel v2.6.35 by this commit. You can find more details about this here.

这篇关于当我们使用 irq_set_chained_handler 时,irq 行是否会被禁用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-08 08:08