Interrupt

如何知道一個 IRQ 值是否可以免費使用

  • June 6, 2014

如果我們添加一個不支持 PNP(Plug-an Play)的設備,製造商將希望提供關於如何為其分配 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輸出的第 3 列中。

那麼如果沒有輸出,是否意味著我們可以免費使用呢?

查看手冊頁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

參考

引用自:https://unix.stackexchange.com/questions/134778