linux --中断管理 -- irq的自动探测机制

本文详细解释了Linux内核中的irq自动探测机制,当驱动程序不确定设备的中断号时,如何通过probe_irq_on和probe_irq_off函数进行中断检测和选择。这两个函数涉及中断扫描、状态管理和优化的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

irq自动探测机制

如果一个设备的驱动程序无法确定它说管理的设备的软件中断号irq,此时设备驱动程序可以使用irq的自动探测机制来获取其正在使用的irq。

使用自动探测机制的条件

  1. 内核与驱动,必须共同努力才能完成
  2. 只限于非共享中断的情况

探测前,驱动的设备关联到了某个irq,但是因为设备驱动程序还不清楚是哪个irq,因此无法调用request_irq来向该irq安装中断处理例程,所以对应irq的action为空,下面是一个设备驱动程序的使用示例:
在这里插入图片描述
probe_irq_on和probe_irq_off是内核为驱动程序员设计的两个自动探测的接口函数

irq自动探测的原理描述

在这里插入图片描述

probe_irq_on


/**
 *	probe_irq_on	- begin an interrupt autodetect
 *
 *	Commence probing for an interrupt. The interrupts are scanned
 *	and a mask of potential interrupt lines is returned.
 *
 * 开始探测中断,扫描中断并返回潜在中断线的mask
 */
unsigned long probe_irq_on(void)
{
   
   
	struct irq_desc *desc;
	unsigned long mask = 0;
	int i;

	/*
	 * quiesce the kernel, or at least the asynchronous portion
	 */
	async_synchronize_full();
	mutex_lock(&probing_active);
	/*
	 * something may have generated an irq long ago and we want to
	 * flush such a longstanding irq before considering it as spurious.
	 */
	for_each_irq_desc_reverse(i, desc) {
   
   
		raw_spin_lock_irq(&desc->lock);
		if (
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值