如何知道 IRQ 值是否可以自由使用

如何知道 IRQ 值是否可以自由使用

如果我们添加一个不支持 PNP(即插即用)的设备,制造商有望提供有关如何为其分配 IRQ 值的明确指示。

但是,如果我们不知道要指定什么 IRQ 值,应该使用什么命令行来检查 IRQ 值是否空闲?

lsdev显示有关设备的信息:

$lsdev 
Device            DMA   IRQ  I/O Ports
------------------------------------------------
0000:00:02.0                   7000-703f
0000:00:1f.2                   7060-707f   7080-7087   7088-708f   7090-7093   7094-7097
0000:00:1f.3                   efa0-efbf
0000:01:00.0                     6000-607f
0000:04:00.0                     4000-40ff
0000:05:00.0                     3000-30ff
acpi                      9 
ACPI                           1800-1803   1804-1805   1808-180b   1810-1815   1820-182f   1850-1850
ahci                     43      7060-707f     7080-7087     7088-708f     7090-7093     7094-7097
cascade             4       

这个 cmd 怎么样lsdev,足以完成这个任务吗?例如,如果我们想知道 1233 是否空闲,我们可以运行以下命令:

lsdev | awk '{print $3}'|grep 1233  

笔记: $3使用上面的方法是因为 IRQ 值打印在输出的第三列中lsdev

那么如果没有输出,就代表可以免费给我们使用了?

答案1

查看手册页,lsdev有这样的评论:

该程序仅显示内核对存在的硬件的想法,而不是实际物理上可用的硬件。

的输出lsdev实际上只是文件的内容/proc/interrupts

摘自man proc

   /proc/interrupts
        This  is  used to record the number of interrupts per CPU per IO 
        device.  Since Linux 2.6.24, for the i386 and x86_64 architectures,
        at least, this also includes interrupts internal to the system (that 
        is, not associated with a device as such), such  as  NMI  (non‐
        maskable  interrupt), LOC (local timer interrupt), and for SMP 
        systems, TLB (TLB flush interrupt), RES (rescheduling interrupt), 
        CAL (remote function call interrupt), and possibly others.  Very 
        easy to read formatting, done in ASCII.

所以我可能会放弃以下内容/proc/interrupts

$ cat /proc/interrupts 
           CPU0       CPU1       CPU2       CPU3       
  0:        157          0          0          0   IO-APIC-edge      timer
  1:     114046      13823      22163      22418   IO-APIC-edge      i8042
  8:          0          0          0          1   IO-APIC-edge      rtc0
  9:     863103     151734     155913     156348   IO-APIC-fasteoi   acpi
 12:    2401994     396391     512623     477252   IO-APIC-edge      i8042
 16:        555        593        598        626   IO-APIC-fasteoi   mmc0
 19:        127         31         83         71   IO-APIC-fasteoi   ehci_hcd:usb2, firewire_ohci, ips
 23:         32          8         21         16   IO-APIC-fasteoi   ehci_hcd:usb1, i801_smbus
 40:       5467       4735    1518263    1230227   PCI-MSI-edge      ahci
 41:    1206772    1363618    2193180    1477903   PCI-MSI-edge      i915
 42:        267    5142231        817        590   PCI-MSI-edge      iwlwifi
 43:          5          8          6          4   PCI-MSI-edge      mei_me
 44:          0          2          2      23405   PCI-MSI-edge      em1
 45:         19         66         39         23   PCI-MSI-edge      snd_hda_intel
NMI:      12126      25353      28874      26600   Non-maskable interrupts
LOC:   29927091   27300830   30247245   26674337   Local timer interrupts
SPU:          0          0          0          0   Spurious interrupts
PMI:      12126      25353      28874      26600   Performance monitoring interrupts
IWI:     634179     806528     600811     632305   IRQ work interrupts
RTR:          5          1          1          0   APIC ICR read retries
RES:    4083290    3763061    3806592    3539082   Rescheduling interrupts
CAL:      16375        624      25561        737   Function call interrupts
TLB:     806653     778539     828520     806776   TLB shootdowns
TRM:          0          0          0          0   Thermal event interrupts
THR:          0          0          0          0   Threshold APIC interrupts
MCE:          0          0          0          0   Machine check exceptions
MCP:        416        416        416        416   Machine check polls
ERR:          0
MIS:          0

参考

相关内容