18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci=======
48c2ecf20Sopenharmony_ciIO-APIC
58c2ecf20Sopenharmony_ci=======
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci:Author: Ingo Molnar <mingo@kernel.org>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ciMost (all) Intel-MP compliant SMP boards have the so-called 'IO-APIC',
108c2ecf20Sopenharmony_ciwhich is an enhanced interrupt controller. It enables us to route
118c2ecf20Sopenharmony_cihardware interrupts to multiple CPUs, or to CPU groups. Without an
128c2ecf20Sopenharmony_ciIO-APIC, interrupts from hardware will be delivered only to the
138c2ecf20Sopenharmony_ciCPU which boots the operating system (usually CPU#0).
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ciLinux supports all variants of compliant SMP boards, including ones with
168c2ecf20Sopenharmony_cimultiple IO-APICs. Multiple IO-APICs are used in high-end servers to
178c2ecf20Sopenharmony_cidistribute IRQ load further.
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ciThere are (a few) known breakages in certain older boards, such bugs are
208c2ecf20Sopenharmony_ciusually worked around by the kernel. If your MP-compliant SMP board does
218c2ecf20Sopenharmony_cinot boot Linux, then consult the linux-smp mailing list archives first.
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ciIf your box boots fine with enabled IO-APIC IRQs, then your
248c2ecf20Sopenharmony_ci/proc/interrupts will look like this one::
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci  hell:~> cat /proc/interrupts
278c2ecf20Sopenharmony_ci             CPU0
288c2ecf20Sopenharmony_ci    0:    1360293    IO-APIC-edge  timer
298c2ecf20Sopenharmony_ci    1:          4    IO-APIC-edge  keyboard
308c2ecf20Sopenharmony_ci    2:          0          XT-PIC  cascade
318c2ecf20Sopenharmony_ci   13:          1          XT-PIC  fpu
328c2ecf20Sopenharmony_ci   14:       1448    IO-APIC-edge  ide0
338c2ecf20Sopenharmony_ci   16:      28232   IO-APIC-level  Intel EtherExpress Pro 10/100 Ethernet
348c2ecf20Sopenharmony_ci   17:      51304   IO-APIC-level  eth0
358c2ecf20Sopenharmony_ci  NMI:          0
368c2ecf20Sopenharmony_ci  ERR:          0
378c2ecf20Sopenharmony_ci  hell:~>
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ciSome interrupts are still listed as 'XT PIC', but this is not a problem;
408c2ecf20Sopenharmony_cinone of those IRQ sources is performance-critical.
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ciIn the unlikely case that your board does not create a working mp-table,
448c2ecf20Sopenharmony_ciyou can use the pirq= boot parameter to 'hand-construct' IRQ entries. This
458c2ecf20Sopenharmony_ciis non-trivial though and cannot be automated. One sample /etc/lilo.conf
468c2ecf20Sopenharmony_cientry::
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci	append="pirq=15,11,10"
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ciThe actual numbers depend on your system, on your PCI cards and on their
518c2ecf20Sopenharmony_ciPCI slot position. Usually PCI slots are 'daisy chained' before they are
528c2ecf20Sopenharmony_ciconnected to the PCI chipset IRQ routing facility (the incoming PIRQ1-4
538c2ecf20Sopenharmony_cilines)::
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci               ,-.        ,-.        ,-.        ,-.        ,-.
568c2ecf20Sopenharmony_ci     PIRQ4 ----| |-.    ,-| |-.    ,-| |-.    ,-| |--------| |
578c2ecf20Sopenharmony_ci               |S|  \  /  |S|  \  /  |S|  \  /  |S|        |S|
588c2ecf20Sopenharmony_ci     PIRQ3 ----|l|-. `/---|l|-. `/---|l|-. `/---|l|--------|l|
598c2ecf20Sopenharmony_ci               |o|  \/    |o|  \/    |o|  \/    |o|        |o|
608c2ecf20Sopenharmony_ci     PIRQ2 ----|t|-./`----|t|-./`----|t|-./`----|t|--------|t|
618c2ecf20Sopenharmony_ci               |1| /\     |2| /\     |3| /\     |4|        |5|
628c2ecf20Sopenharmony_ci     PIRQ1 ----| |-  `----| |-  `----| |-  `----| |--------| |
638c2ecf20Sopenharmony_ci               `-'        `-'        `-'        `-'        `-'
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ciEvery PCI card emits a PCI IRQ, which can be INTA, INTB, INTC or INTD::
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci                               ,-.
688c2ecf20Sopenharmony_ci                         INTD--| |
698c2ecf20Sopenharmony_ci                               |S|
708c2ecf20Sopenharmony_ci                         INTC--|l|
718c2ecf20Sopenharmony_ci                               |o|
728c2ecf20Sopenharmony_ci                         INTB--|t|
738c2ecf20Sopenharmony_ci                               |x|
748c2ecf20Sopenharmony_ci                         INTA--| |
758c2ecf20Sopenharmony_ci                               `-'
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ciThese INTA-D PCI IRQs are always 'local to the card', their real meaning
788c2ecf20Sopenharmony_cidepends on which slot they are in. If you look at the daisy chaining diagram,
798c2ecf20Sopenharmony_cia card in slot4, issuing INTA IRQ, it will end up as a signal on PIRQ4 of
808c2ecf20Sopenharmony_cithe PCI chipset. Most cards issue INTA, this creates optimal distribution
818c2ecf20Sopenharmony_cibetween the PIRQ lines. (distributing IRQ sources properly is not a
828c2ecf20Sopenharmony_cinecessity, PCI IRQs can be shared at will, but it's a good for performance
838c2ecf20Sopenharmony_cito have non shared interrupts). Slot5 should be used for videocards, they
848c2ecf20Sopenharmony_cido not use interrupts normally, thus they are not daisy chained either.
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ciso if you have your SCSI card (IRQ11) in Slot1, Tulip card (IRQ9) in
878c2ecf20Sopenharmony_ciSlot2, then you'll have to specify this pirq= line::
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci	append="pirq=11,9"
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_cithe following script tries to figure out such a default pirq= line from
928c2ecf20Sopenharmony_ciyour PCI configuration::
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci	echo -n pirq=; echo `scanpci | grep T_L | cut -c56-` | sed 's/ /,/g'
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_cinote that this script won't work if you have skipped a few slots or if your
978c2ecf20Sopenharmony_ciboard does not do default daisy-chaining. (or the IO-APIC has the PIRQ pins
988c2ecf20Sopenharmony_ciconnected in some strange way). E.g. if in the above case you have your SCSI
998c2ecf20Sopenharmony_cicard (IRQ11) in Slot3, and have Slot1 empty::
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci	append="pirq=0,9,11"
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci[value '0' is a generic 'placeholder', reserved for empty (or non-IRQ emitting)
1048c2ecf20Sopenharmony_cislots.]
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ciGenerally, it's always possible to find out the correct pirq= settings, just
1078c2ecf20Sopenharmony_cipermute all IRQ numbers properly ... it will take some time though. An
1088c2ecf20Sopenharmony_ci'incorrect' pirq line will cause the booting process to hang, or a device
1098c2ecf20Sopenharmony_ciwon't function properly (e.g. if it's inserted as a module).
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ciIf you have 2 PCI buses, then you can use up to 8 pirq values, although such
1128c2ecf20Sopenharmony_ciboards tend to have a good configuration.
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ciBe prepared that it might happen that you need some strange pirq line::
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci	append="pirq=0,0,0,0,0,0,9,11"
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ciUse smart trial-and-error techniques to find out the correct pirq line ...
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ciGood luck and mail to linux-smp@vger.kernel.org or
1218c2ecf20Sopenharmony_cilinux-kernel@vger.kernel.org if you have any problems that are not covered
1228c2ecf20Sopenharmony_ciby this document.
1238c2ecf20Sopenharmony_ci
124