mpparse_32.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190
  1. /*
  2. * Intel Multiprocessor Specification 1.1 and 1.4
  3. * compliant MP-table parsing routines.
  4. *
  5. * (c) 1995 Alan Cox, Building #3 <alan@redhat.com>
  6. * (c) 1998, 1999, 2000 Ingo Molnar <mingo@redhat.com>
  7. *
  8. * Fixes
  9. * Erich Boleyn : MP v1.4 and additional changes.
  10. * Alan Cox : Added EBDA scanning
  11. * Ingo Molnar : various cleanups and rewrites
  12. * Maciej W. Rozycki: Bits for default MP configurations
  13. * Paul Diefenbaugh: Added full ACPI support
  14. */
  15. #include <linux/mm.h>
  16. #include <linux/init.h>
  17. #include <linux/acpi.h>
  18. #include <linux/delay.h>
  19. #include <linux/bootmem.h>
  20. #include <linux/kernel_stat.h>
  21. #include <linux/mc146818rtc.h>
  22. #include <linux/bitops.h>
  23. #include <asm/smp.h>
  24. #include <asm/acpi.h>
  25. #include <asm/mtrr.h>
  26. #include <asm/mpspec.h>
  27. #include <asm/io_apic.h>
  28. #include <asm/bios_ebda.h>
  29. #include <mach_apic.h>
  30. #include <mach_apicdef.h>
  31. #include <mach_mpparse.h>
  32. /* Have we found an MP table */
  33. int smp_found_config;
  34. unsigned int __cpuinitdata maxcpus = NR_CPUS;
  35. /*
  36. * Various Linux-internal data structures created from the
  37. * MP-table.
  38. */
  39. int apic_version [MAX_APICS];
  40. #if defined (CONFIG_MCA) || defined (CONFIG_EISA)
  41. int mp_bus_id_to_type [MAX_MP_BUSSES];
  42. #endif
  43. DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
  44. int mp_bus_id_to_pci_bus [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 };
  45. static int mp_current_pci_id;
  46. /* I/O APIC entries */
  47. struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
  48. /* # of MP IRQ source entries */
  49. struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
  50. /* MP IRQ source entries */
  51. int mp_irq_entries;
  52. int nr_ioapics;
  53. int pic_mode;
  54. unsigned long mp_lapic_addr;
  55. unsigned int def_to_bigsmp = 0;
  56. /* Processor that is doing the boot up */
  57. unsigned int boot_cpu_physical_apicid = -1U;
  58. /* Internal processor count */
  59. unsigned int num_processors;
  60. unsigned disabled_cpus __cpuinitdata;
  61. /* Bitmask of physically existing CPUs */
  62. physid_mask_t phys_cpu_present_map;
  63. #ifndef CONFIG_SMP
  64. DEFINE_PER_CPU(u16, x86_bios_cpu_apicid) = BAD_APICID;
  65. #endif
  66. /*
  67. * Intel MP BIOS table parsing routines:
  68. */
  69. /*
  70. * Checksum an MP configuration block.
  71. */
  72. static int __init mpf_checksum(unsigned char *mp, int len)
  73. {
  74. int sum = 0;
  75. while (len--)
  76. sum += *mp++;
  77. return sum & 0xFF;
  78. }
  79. /*
  80. * Have to match translation table entries to main table entries by counter
  81. * hence the mpc_record variable .... can't see a less disgusting way of
  82. * doing this ....
  83. */
  84. static int mpc_record;
  85. static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY] __cpuinitdata;
  86. static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
  87. {
  88. int ver, apicid, cpu;
  89. cpumask_t tmp_map;
  90. physid_mask_t phys_cpu;
  91. if (!(m->mpc_cpuflag & CPU_ENABLED)) {
  92. disabled_cpus++;
  93. return;
  94. }
  95. #ifdef CONFIG_X86_NUMAQ
  96. apicid = mpc_apic_id(m, translation_table[mpc_record]);
  97. #else
  98. Dprintk("Processor #%d %u:%u APIC version %d\n",
  99. m->mpc_apicid,
  100. (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
  101. (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
  102. m->mpc_apicver);
  103. apicid = m->mpc_apicid;
  104. #endif
  105. if (m->mpc_featureflag&(1<<0))
  106. Dprintk(" Floating point unit present.\n");
  107. if (m->mpc_featureflag&(1<<7))
  108. Dprintk(" Machine Exception supported.\n");
  109. if (m->mpc_featureflag&(1<<8))
  110. Dprintk(" 64 bit compare & exchange supported.\n");
  111. if (m->mpc_featureflag&(1<<9))
  112. Dprintk(" Internal APIC present.\n");
  113. if (m->mpc_featureflag&(1<<11))
  114. Dprintk(" SEP present.\n");
  115. if (m->mpc_featureflag&(1<<12))
  116. Dprintk(" MTRR present.\n");
  117. if (m->mpc_featureflag&(1<<13))
  118. Dprintk(" PGE present.\n");
  119. if (m->mpc_featureflag&(1<<14))
  120. Dprintk(" MCA present.\n");
  121. if (m->mpc_featureflag&(1<<15))
  122. Dprintk(" CMOV present.\n");
  123. if (m->mpc_featureflag&(1<<16))
  124. Dprintk(" PAT present.\n");
  125. if (m->mpc_featureflag&(1<<17))
  126. Dprintk(" PSE present.\n");
  127. if (m->mpc_featureflag&(1<<18))
  128. Dprintk(" PSN present.\n");
  129. if (m->mpc_featureflag&(1<<19))
  130. Dprintk(" Cache Line Flush Instruction present.\n");
  131. /* 20 Reserved */
  132. if (m->mpc_featureflag&(1<<21))
  133. Dprintk(" Debug Trace and EMON Store present.\n");
  134. if (m->mpc_featureflag&(1<<22))
  135. Dprintk(" ACPI Thermal Throttle Registers present.\n");
  136. if (m->mpc_featureflag&(1<<23))
  137. Dprintk(" MMX present.\n");
  138. if (m->mpc_featureflag&(1<<24))
  139. Dprintk(" FXSR present.\n");
  140. if (m->mpc_featureflag&(1<<25))
  141. Dprintk(" XMM present.\n");
  142. if (m->mpc_featureflag&(1<<26))
  143. Dprintk(" Willamette New Instructions present.\n");
  144. if (m->mpc_featureflag&(1<<27))
  145. Dprintk(" Self Snoop present.\n");
  146. if (m->mpc_featureflag&(1<<28))
  147. Dprintk(" HT present.\n");
  148. if (m->mpc_featureflag&(1<<29))
  149. Dprintk(" Thermal Monitor present.\n");
  150. /* 30, 31 Reserved */
  151. if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
  152. Dprintk(" Bootup CPU\n");
  153. boot_cpu_physical_apicid = m->mpc_apicid;
  154. }
  155. ver = m->mpc_apicver;
  156. /*
  157. * Validate version
  158. */
  159. if (ver == 0x0) {
  160. printk(KERN_WARNING "BIOS bug, APIC version is 0 for CPU#%d! "
  161. "fixing up to 0x10. (tell your hw vendor)\n",
  162. m->mpc_apicid);
  163. ver = 0x10;
  164. }
  165. apic_version[m->mpc_apicid] = ver;
  166. phys_cpu = apicid_to_cpu_present(apicid);
  167. physids_or(phys_cpu_present_map, phys_cpu_present_map, phys_cpu);
  168. if (num_processors >= NR_CPUS) {
  169. printk(KERN_WARNING "WARNING: NR_CPUS limit of %i reached."
  170. " Processor ignored.\n", NR_CPUS);
  171. return;
  172. }
  173. if (num_processors >= maxcpus) {
  174. printk(KERN_WARNING "WARNING: maxcpus limit of %i reached."
  175. " Processor ignored.\n", maxcpus);
  176. return;
  177. }
  178. cpu_set(num_processors, cpu_possible_map);
  179. num_processors++;
  180. cpus_complement(tmp_map, cpu_present_map);
  181. cpu = first_cpu(tmp_map);
  182. if (m->mpc_cpuflag & CPU_BOOTPROCESSOR)
  183. /*
  184. * x86_bios_cpu_apicid is required to have processors listed
  185. * in same order as logical cpu numbers. Hence the first
  186. * entry is BSP, and so on.
  187. */
  188. cpu = 0;
  189. /*
  190. * Would be preferable to switch to bigsmp when CONFIG_HOTPLUG_CPU=y
  191. * but we need to work other dependencies like SMP_SUSPEND etc
  192. * before this can be done without some confusion.
  193. * if (CPU_HOTPLUG_ENABLED || num_processors > 8)
  194. * - Ashok Raj <ashok.raj@intel.com>
  195. */
  196. if (num_processors > 8) {
  197. switch (boot_cpu_data.x86_vendor) {
  198. case X86_VENDOR_INTEL:
  199. if (!APIC_XAPIC(ver)) {
  200. def_to_bigsmp = 0;
  201. break;
  202. }
  203. /* If P4 and above fall through */
  204. case X86_VENDOR_AMD:
  205. def_to_bigsmp = 1;
  206. }
  207. }
  208. #ifdef CONFIG_SMP
  209. /* are we being called early in kernel startup? */
  210. if (x86_cpu_to_apicid_early_ptr) {
  211. u16 *cpu_to_apicid = x86_cpu_to_apicid_early_ptr;
  212. u16 *bios_cpu_apicid = x86_bios_cpu_apicid_early_ptr;
  213. cpu_to_apicid[cpu] = m->mpc_apicid;
  214. bios_cpu_apicid[num_processors - 1] = m->mpc_apicid;
  215. } else {
  216. per_cpu(x86_cpu_to_apicid, cpu) = m->mpc_apicid;
  217. per_cpu(x86_bios_cpu_apicid, cpu) = m->mpc_apicid;
  218. }
  219. #endif
  220. cpu_set(cpu, cpu_present_map);
  221. }
  222. static void __init MP_bus_info (struct mpc_config_bus *m)
  223. {
  224. char str[7];
  225. memcpy(str, m->mpc_bustype, 6);
  226. str[6] = 0;
  227. mpc_oem_bus_info(m, str, translation_table[mpc_record]);
  228. #if MAX_MP_BUSSES < 256
  229. if (m->mpc_busid >= MAX_MP_BUSSES) {
  230. printk(KERN_WARNING "MP table busid value (%d) for bustype %s "
  231. " is too large, max. supported is %d\n",
  232. m->mpc_busid, str, MAX_MP_BUSSES - 1);
  233. return;
  234. }
  235. #endif
  236. set_bit(m->mpc_busid, mp_bus_not_pci);
  237. if (strncmp(str, BUSTYPE_PCI, sizeof(BUSTYPE_PCI)-1) == 0) {
  238. #ifdef CONFIG_X86_NUMAQ
  239. mpc_oem_pci_bus(m, translation_table[mpc_record]);
  240. #endif
  241. clear_bit(m->mpc_busid, mp_bus_not_pci);
  242. mp_bus_id_to_pci_bus[m->mpc_busid] = mp_current_pci_id;
  243. mp_current_pci_id++;
  244. #if defined(CONFIG_EISA) || defined (CONFIG_MCA)
  245. mp_bus_id_to_type[m->mpc_busid] = MP_BUS_PCI;
  246. } else if (strncmp(str, BUSTYPE_ISA, sizeof(BUSTYPE_ISA)-1) == 0) {
  247. mp_bus_id_to_type[m->mpc_busid] = MP_BUS_ISA;
  248. } else if (strncmp(str, BUSTYPE_EISA, sizeof(BUSTYPE_EISA)-1) == 0) {
  249. mp_bus_id_to_type[m->mpc_busid] = MP_BUS_EISA;
  250. } else if (strncmp(str, BUSTYPE_MCA, sizeof(BUSTYPE_MCA)-1) == 0) {
  251. mp_bus_id_to_type[m->mpc_busid] = MP_BUS_MCA;
  252. } else {
  253. printk(KERN_WARNING "Unknown bustype %s - ignoring\n", str);
  254. #endif
  255. }
  256. }
  257. static int bad_ioapic(unsigned long address)
  258. {
  259. if (nr_ioapics >= MAX_IO_APICS) {
  260. printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
  261. "(found %d)\n", MAX_IO_APICS, nr_ioapics);
  262. panic("Recompile kernel with bigger MAX_IO_APICS!\n");
  263. }
  264. if (!address) {
  265. printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address"
  266. " found in table, skipping!\n");
  267. return 1;
  268. }
  269. return 0;
  270. }
  271. static void __init MP_ioapic_info (struct mpc_config_ioapic *m)
  272. {
  273. if (!(m->mpc_flags & MPC_APIC_USABLE))
  274. return;
  275. printk(KERN_INFO "I/O APIC #%d Version %d at 0x%X.\n",
  276. m->mpc_apicid, m->mpc_apicver, m->mpc_apicaddr);
  277. if (bad_ioapic(m->mpc_apicaddr))
  278. return;
  279. mp_ioapics[nr_ioapics] = *m;
  280. nr_ioapics++;
  281. }
  282. static void __init MP_intsrc_info (struct mpc_config_intsrc *m)
  283. {
  284. mp_irqs [mp_irq_entries] = *m;
  285. Dprintk("Int: type %d, pol %d, trig %d, bus %d,"
  286. " IRQ %02x, APIC ID %x, APIC INT %02x\n",
  287. m->mpc_irqtype, m->mpc_irqflag & 3,
  288. (m->mpc_irqflag >> 2) & 3, m->mpc_srcbus,
  289. m->mpc_srcbusirq, m->mpc_dstapic, m->mpc_dstirq);
  290. if (++mp_irq_entries == MAX_IRQ_SOURCES)
  291. panic("Max # of irq sources exceeded!!\n");
  292. }
  293. static void __init MP_lintsrc_info (struct mpc_config_lintsrc *m)
  294. {
  295. Dprintk("Lint: type %d, pol %d, trig %d, bus %d,"
  296. " IRQ %02x, APIC ID %x, APIC LINT %02x\n",
  297. m->mpc_irqtype, m->mpc_irqflag & 3,
  298. (m->mpc_irqflag >> 2) &3, m->mpc_srcbusid,
  299. m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint);
  300. }
  301. #ifdef CONFIG_X86_NUMAQ
  302. static void __init MP_translation_info (struct mpc_config_translation *m)
  303. {
  304. printk(KERN_INFO "Translation: record %d, type %d, quad %d, global %d, local %d\n", mpc_record, m->trans_type, m->trans_quad, m->trans_global, m->trans_local);
  305. if (mpc_record >= MAX_MPC_ENTRY)
  306. printk(KERN_ERR "MAX_MPC_ENTRY exceeded!\n");
  307. else
  308. translation_table[mpc_record] = m; /* stash this for later */
  309. if (m->trans_quad < MAX_NUMNODES && !node_online(m->trans_quad))
  310. node_set_online(m->trans_quad);
  311. }
  312. /*
  313. * Read/parse the MPC oem tables
  314. */
  315. static void __init smp_read_mpc_oem(struct mp_config_oemtable *oemtable, \
  316. unsigned short oemsize)
  317. {
  318. int count = sizeof (*oemtable); /* the header size */
  319. unsigned char *oemptr = ((unsigned char *)oemtable)+count;
  320. mpc_record = 0;
  321. printk(KERN_INFO "Found an OEM MPC table at %8p - parsing it ... \n", oemtable);
  322. if (memcmp(oemtable->oem_signature,MPC_OEM_SIGNATURE,4))
  323. {
  324. printk(KERN_WARNING "SMP mpc oemtable: bad signature [%c%c%c%c]!\n",
  325. oemtable->oem_signature[0],
  326. oemtable->oem_signature[1],
  327. oemtable->oem_signature[2],
  328. oemtable->oem_signature[3]);
  329. return;
  330. }
  331. if (mpf_checksum((unsigned char *)oemtable,oemtable->oem_length))
  332. {
  333. printk(KERN_WARNING "SMP oem mptable: checksum error!\n");
  334. return;
  335. }
  336. while (count < oemtable->oem_length) {
  337. switch (*oemptr) {
  338. case MP_TRANSLATION:
  339. {
  340. struct mpc_config_translation *m=
  341. (struct mpc_config_translation *)oemptr;
  342. MP_translation_info(m);
  343. oemptr += sizeof(*m);
  344. count += sizeof(*m);
  345. ++mpc_record;
  346. break;
  347. }
  348. default:
  349. {
  350. printk(KERN_WARNING "Unrecognised OEM table entry type! - %d\n", (int) *oemptr);
  351. return;
  352. }
  353. }
  354. }
  355. }
  356. static inline void mps_oem_check(struct mp_config_table *mpc, char *oem,
  357. char *productid)
  358. {
  359. if (strncmp(oem, "IBM NUMA", 8))
  360. printk("Warning! May not be a NUMA-Q system!\n");
  361. if (mpc->mpc_oemptr)
  362. smp_read_mpc_oem((struct mp_config_oemtable *) mpc->mpc_oemptr,
  363. mpc->mpc_oemsize);
  364. }
  365. #endif /* CONFIG_X86_NUMAQ */
  366. /*
  367. * Read/parse the MPC
  368. */
  369. static int __init smp_read_mpc(struct mp_config_table *mpc)
  370. {
  371. char str[16];
  372. char oem[10];
  373. int count=sizeof(*mpc);
  374. unsigned char *mpt=((unsigned char *)mpc)+count;
  375. if (memcmp(mpc->mpc_signature,MPC_SIGNATURE,4)) {
  376. printk(KERN_ERR "SMP mptable: bad signature [0x%x]!\n",
  377. *(u32 *)mpc->mpc_signature);
  378. return 0;
  379. }
  380. if (mpf_checksum((unsigned char *)mpc,mpc->mpc_length)) {
  381. printk(KERN_ERR "SMP mptable: checksum error!\n");
  382. return 0;
  383. }
  384. if (mpc->mpc_spec!=0x01 && mpc->mpc_spec!=0x04) {
  385. printk(KERN_ERR "SMP mptable: bad table version (%d)!!\n",
  386. mpc->mpc_spec);
  387. return 0;
  388. }
  389. if (!mpc->mpc_lapic) {
  390. printk(KERN_ERR "SMP mptable: null local APIC address!\n");
  391. return 0;
  392. }
  393. memcpy(oem,mpc->mpc_oem,8);
  394. oem[8]=0;
  395. printk(KERN_INFO "OEM ID: %s ",oem);
  396. memcpy(str,mpc->mpc_productid,12);
  397. str[12]=0;
  398. printk("Product ID: %s ",str);
  399. mps_oem_check(mpc, oem, str);
  400. printk("APIC at: 0x%X\n", mpc->mpc_lapic);
  401. /*
  402. * Save the local APIC address (it might be non-default) -- but only
  403. * if we're not using ACPI.
  404. */
  405. if (!acpi_lapic)
  406. mp_lapic_addr = mpc->mpc_lapic;
  407. /*
  408. * Now process the configuration blocks.
  409. */
  410. mpc_record = 0;
  411. while (count < mpc->mpc_length) {
  412. switch(*mpt) {
  413. case MP_PROCESSOR:
  414. {
  415. struct mpc_config_processor *m=
  416. (struct mpc_config_processor *)mpt;
  417. /* ACPI may have already provided this data */
  418. if (!acpi_lapic)
  419. MP_processor_info(m);
  420. mpt += sizeof(*m);
  421. count += sizeof(*m);
  422. break;
  423. }
  424. case MP_BUS:
  425. {
  426. struct mpc_config_bus *m=
  427. (struct mpc_config_bus *)mpt;
  428. MP_bus_info(m);
  429. mpt += sizeof(*m);
  430. count += sizeof(*m);
  431. break;
  432. }
  433. case MP_IOAPIC:
  434. {
  435. struct mpc_config_ioapic *m=
  436. (struct mpc_config_ioapic *)mpt;
  437. MP_ioapic_info(m);
  438. mpt+=sizeof(*m);
  439. count+=sizeof(*m);
  440. break;
  441. }
  442. case MP_INTSRC:
  443. {
  444. struct mpc_config_intsrc *m=
  445. (struct mpc_config_intsrc *)mpt;
  446. MP_intsrc_info(m);
  447. mpt+=sizeof(*m);
  448. count+=sizeof(*m);
  449. break;
  450. }
  451. case MP_LINTSRC:
  452. {
  453. struct mpc_config_lintsrc *m=
  454. (struct mpc_config_lintsrc *)mpt;
  455. MP_lintsrc_info(m);
  456. mpt+=sizeof(*m);
  457. count+=sizeof(*m);
  458. break;
  459. }
  460. default:
  461. {
  462. count = mpc->mpc_length;
  463. break;
  464. }
  465. }
  466. ++mpc_record;
  467. }
  468. setup_apic_routing();
  469. if (!num_processors)
  470. printk(KERN_ERR "SMP mptable: no processors registered!\n");
  471. return num_processors;
  472. }
  473. static int __init ELCR_trigger(unsigned int irq)
  474. {
  475. unsigned int port;
  476. port = 0x4d0 + (irq >> 3);
  477. return (inb(port) >> (irq & 7)) & 1;
  478. }
  479. static void __init construct_default_ioirq_mptable(int mpc_default_type)
  480. {
  481. struct mpc_config_intsrc intsrc;
  482. int i;
  483. int ELCR_fallback = 0;
  484. intsrc.mpc_type = MP_INTSRC;
  485. intsrc.mpc_irqflag = 0; /* conforming */
  486. intsrc.mpc_srcbus = 0;
  487. intsrc.mpc_dstapic = mp_ioapics[0].mpc_apicid;
  488. intsrc.mpc_irqtype = mp_INT;
  489. /*
  490. * If true, we have an ISA/PCI system with no IRQ entries
  491. * in the MP table. To prevent the PCI interrupts from being set up
  492. * incorrectly, we try to use the ELCR. The sanity check to see if
  493. * there is good ELCR data is very simple - IRQ0, 1, 2 and 13 can
  494. * never be level sensitive, so we simply see if the ELCR agrees.
  495. * If it does, we assume it's valid.
  496. */
  497. if (mpc_default_type == 5) {
  498. printk(KERN_INFO "ISA/PCI bus type with no IRQ information... falling back to ELCR\n");
  499. if (ELCR_trigger(0) || ELCR_trigger(1) || ELCR_trigger(2) || ELCR_trigger(13))
  500. printk(KERN_WARNING "ELCR contains invalid data... not using ELCR\n");
  501. else {
  502. printk(KERN_INFO "Using ELCR to identify PCI interrupts\n");
  503. ELCR_fallback = 1;
  504. }
  505. }
  506. for (i = 0; i < 16; i++) {
  507. switch (mpc_default_type) {
  508. case 2:
  509. if (i == 0 || i == 13)
  510. continue; /* IRQ0 & IRQ13 not connected */
  511. /* fall through */
  512. default:
  513. if (i == 2)
  514. continue; /* IRQ2 is never connected */
  515. }
  516. if (ELCR_fallback) {
  517. /*
  518. * If the ELCR indicates a level-sensitive interrupt, we
  519. * copy that information over to the MP table in the
  520. * irqflag field (level sensitive, active high polarity).
  521. */
  522. if (ELCR_trigger(i))
  523. intsrc.mpc_irqflag = 13;
  524. else
  525. intsrc.mpc_irqflag = 0;
  526. }
  527. intsrc.mpc_srcbusirq = i;
  528. intsrc.mpc_dstirq = i ? i : 2; /* IRQ0 to INTIN2 */
  529. MP_intsrc_info(&intsrc);
  530. }
  531. intsrc.mpc_irqtype = mp_ExtINT;
  532. intsrc.mpc_srcbusirq = 0;
  533. intsrc.mpc_dstirq = 0; /* 8259A to INTIN0 */
  534. MP_intsrc_info(&intsrc);
  535. }
  536. static inline void __init construct_default_ISA_mptable(int mpc_default_type)
  537. {
  538. struct mpc_config_processor processor;
  539. struct mpc_config_bus bus;
  540. struct mpc_config_ioapic ioapic;
  541. struct mpc_config_lintsrc lintsrc;
  542. int linttypes[2] = { mp_ExtINT, mp_NMI };
  543. int i;
  544. /*
  545. * local APIC has default address
  546. */
  547. mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
  548. /*
  549. * 2 CPUs, numbered 0 & 1.
  550. */
  551. processor.mpc_type = MP_PROCESSOR;
  552. /* Either an integrated APIC or a discrete 82489DX. */
  553. processor.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01;
  554. processor.mpc_cpuflag = CPU_ENABLED;
  555. processor.mpc_cpufeature = (boot_cpu_data.x86 << 8) |
  556. (boot_cpu_data.x86_model << 4) |
  557. boot_cpu_data.x86_mask;
  558. processor.mpc_featureflag = boot_cpu_data.x86_capability[0];
  559. processor.mpc_reserved[0] = 0;
  560. processor.mpc_reserved[1] = 0;
  561. for (i = 0; i < 2; i++) {
  562. processor.mpc_apicid = i;
  563. MP_processor_info(&processor);
  564. }
  565. bus.mpc_type = MP_BUS;
  566. bus.mpc_busid = 0;
  567. switch (mpc_default_type) {
  568. default:
  569. printk("???\n");
  570. printk(KERN_ERR "Unknown standard configuration %d\n",
  571. mpc_default_type);
  572. /* fall through */
  573. case 1:
  574. case 5:
  575. memcpy(bus.mpc_bustype, "ISA ", 6);
  576. break;
  577. case 2:
  578. case 6:
  579. case 3:
  580. memcpy(bus.mpc_bustype, "EISA ", 6);
  581. break;
  582. case 4:
  583. case 7:
  584. memcpy(bus.mpc_bustype, "MCA ", 6);
  585. }
  586. MP_bus_info(&bus);
  587. if (mpc_default_type > 4) {
  588. bus.mpc_busid = 1;
  589. memcpy(bus.mpc_bustype, "PCI ", 6);
  590. MP_bus_info(&bus);
  591. }
  592. ioapic.mpc_type = MP_IOAPIC;
  593. ioapic.mpc_apicid = 2;
  594. ioapic.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01;
  595. ioapic.mpc_flags = MPC_APIC_USABLE;
  596. ioapic.mpc_apicaddr = 0xFEC00000;
  597. MP_ioapic_info(&ioapic);
  598. /*
  599. * We set up most of the low 16 IO-APIC pins according to MPS rules.
  600. */
  601. construct_default_ioirq_mptable(mpc_default_type);
  602. lintsrc.mpc_type = MP_LINTSRC;
  603. lintsrc.mpc_irqflag = 0; /* conforming */
  604. lintsrc.mpc_srcbusid = 0;
  605. lintsrc.mpc_srcbusirq = 0;
  606. lintsrc.mpc_destapic = MP_APIC_ALL;
  607. for (i = 0; i < 2; i++) {
  608. lintsrc.mpc_irqtype = linttypes[i];
  609. lintsrc.mpc_destapiclint = i;
  610. MP_lintsrc_info(&lintsrc);
  611. }
  612. }
  613. static struct intel_mp_floating *mpf_found;
  614. /*
  615. * Scan the memory blocks for an SMP configuration block.
  616. */
  617. void __init get_smp_config (void)
  618. {
  619. struct intel_mp_floating *mpf = mpf_found;
  620. /*
  621. * ACPI supports both logical (e.g. Hyper-Threading) and physical
  622. * processors, where MPS only supports physical.
  623. */
  624. if (acpi_lapic && acpi_ioapic) {
  625. printk(KERN_INFO "Using ACPI (MADT) for SMP configuration information\n");
  626. return;
  627. }
  628. else if (acpi_lapic)
  629. printk(KERN_INFO "Using ACPI for processor (LAPIC) configuration information\n");
  630. printk(KERN_INFO "Intel MultiProcessor Specification v1.%d\n", mpf->mpf_specification);
  631. if (mpf->mpf_feature2 & (1<<7)) {
  632. printk(KERN_INFO " IMCR and PIC compatibility mode.\n");
  633. pic_mode = 1;
  634. } else {
  635. printk(KERN_INFO " Virtual Wire compatibility mode.\n");
  636. pic_mode = 0;
  637. }
  638. /*
  639. * Now see if we need to read further.
  640. */
  641. if (mpf->mpf_feature1 != 0) {
  642. printk(KERN_INFO "Default MP configuration #%d\n", mpf->mpf_feature1);
  643. construct_default_ISA_mptable(mpf->mpf_feature1);
  644. } else if (mpf->mpf_physptr) {
  645. /*
  646. * Read the physical hardware table. Anything here will
  647. * override the defaults.
  648. */
  649. if (!smp_read_mpc(phys_to_virt(mpf->mpf_physptr))) {
  650. smp_found_config = 0;
  651. printk(KERN_ERR "BIOS bug, MP table errors detected!...\n");
  652. printk(KERN_ERR "... disabling SMP support. (tell your hw vendor)\n");
  653. return;
  654. }
  655. /*
  656. * If there are no explicit MP IRQ entries, then we are
  657. * broken. We set up most of the low 16 IO-APIC pins to
  658. * ISA defaults and hope it will work.
  659. */
  660. if (!mp_irq_entries) {
  661. struct mpc_config_bus bus;
  662. printk(KERN_ERR "BIOS bug, no explicit IRQ entries, using default mptable. (tell your hw vendor)\n");
  663. bus.mpc_type = MP_BUS;
  664. bus.mpc_busid = 0;
  665. memcpy(bus.mpc_bustype, "ISA ", 6);
  666. MP_bus_info(&bus);
  667. construct_default_ioirq_mptable(0);
  668. }
  669. } else
  670. BUG();
  671. printk(KERN_INFO "Processors: %d\n", num_processors);
  672. /*
  673. * Only use the first configuration found.
  674. */
  675. }
  676. static int __init smp_scan_config (unsigned long base, unsigned long length)
  677. {
  678. unsigned long *bp = phys_to_virt(base);
  679. struct intel_mp_floating *mpf;
  680. printk(KERN_INFO "Scan SMP from %p for %ld bytes.\n", bp,length);
  681. if (sizeof(*mpf) != 16)
  682. printk("Error: MPF size\n");
  683. while (length > 0) {
  684. mpf = (struct intel_mp_floating *)bp;
  685. if ((*bp == SMP_MAGIC_IDENT) &&
  686. (mpf->mpf_length == 1) &&
  687. !mpf_checksum((unsigned char *)bp, 16) &&
  688. ((mpf->mpf_specification == 1)
  689. || (mpf->mpf_specification == 4)) ) {
  690. smp_found_config = 1;
  691. printk(KERN_INFO "found SMP MP-table at [%p] %08lx\n",
  692. mpf, virt_to_phys(mpf));
  693. reserve_bootmem(virt_to_phys(mpf), PAGE_SIZE,
  694. BOOTMEM_DEFAULT);
  695. if (mpf->mpf_physptr) {
  696. /*
  697. * We cannot access to MPC table to compute
  698. * table size yet, as only few megabytes from
  699. * the bottom is mapped now.
  700. * PC-9800's MPC table places on the very last
  701. * of physical memory; so that simply reserving
  702. * PAGE_SIZE from mpg->mpf_physptr yields BUG()
  703. * in reserve_bootmem.
  704. */
  705. unsigned long size = PAGE_SIZE;
  706. unsigned long end = max_low_pfn * PAGE_SIZE;
  707. if (mpf->mpf_physptr + size > end)
  708. size = end - mpf->mpf_physptr;
  709. reserve_bootmem(mpf->mpf_physptr, size,
  710. BOOTMEM_DEFAULT);
  711. }
  712. mpf_found = mpf;
  713. return 1;
  714. }
  715. bp += 4;
  716. length -= 16;
  717. }
  718. return 0;
  719. }
  720. void __init find_smp_config (void)
  721. {
  722. unsigned int address;
  723. /*
  724. * FIXME: Linux assumes you have 640K of base ram..
  725. * this continues the error...
  726. *
  727. * 1) Scan the bottom 1K for a signature
  728. * 2) Scan the top 1K of base RAM
  729. * 3) Scan the 64K of bios
  730. */
  731. if (smp_scan_config(0x0,0x400) ||
  732. smp_scan_config(639*0x400,0x400) ||
  733. smp_scan_config(0xF0000,0x10000))
  734. return;
  735. /*
  736. * If it is an SMP machine we should know now, unless the
  737. * configuration is in an EISA/MCA bus machine with an
  738. * extended bios data area.
  739. *
  740. * there is a real-mode segmented pointer pointing to the
  741. * 4K EBDA area at 0x40E, calculate and scan it here.
  742. *
  743. * NOTE! There are Linux loaders that will corrupt the EBDA
  744. * area, and as such this kind of SMP config may be less
  745. * trustworthy, simply because the SMP table may have been
  746. * stomped on during early boot. These loaders are buggy and
  747. * should be fixed.
  748. *
  749. * MP1.4 SPEC states to only scan first 1K of 4K EBDA.
  750. */
  751. address = get_bios_ebda();
  752. if (address)
  753. smp_scan_config(address, 0x400);
  754. }
  755. int es7000_plat;
  756. /* --------------------------------------------------------------------------
  757. ACPI-based MP Configuration
  758. -------------------------------------------------------------------------- */
  759. #ifdef CONFIG_ACPI
  760. void __init mp_register_lapic_address(u64 address)
  761. {
  762. mp_lapic_addr = (unsigned long) address;
  763. set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr);
  764. if (boot_cpu_physical_apicid == -1U)
  765. boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID));
  766. Dprintk("Boot CPU = %d\n", boot_cpu_physical_apicid);
  767. }
  768. void __cpuinit mp_register_lapic (u8 id, u8 enabled)
  769. {
  770. struct mpc_config_processor processor;
  771. int boot_cpu = 0;
  772. if (MAX_APICS - id <= 0) {
  773. printk(KERN_WARNING "Processor #%d invalid (max %d)\n",
  774. id, MAX_APICS);
  775. return;
  776. }
  777. if (id == boot_cpu_physical_apicid)
  778. boot_cpu = 1;
  779. processor.mpc_type = MP_PROCESSOR;
  780. processor.mpc_apicid = id;
  781. processor.mpc_apicver = GET_APIC_VERSION(apic_read(APIC_LVR));
  782. processor.mpc_cpuflag = (enabled ? CPU_ENABLED : 0);
  783. processor.mpc_cpuflag |= (boot_cpu ? CPU_BOOTPROCESSOR : 0);
  784. processor.mpc_cpufeature = (boot_cpu_data.x86 << 8) |
  785. (boot_cpu_data.x86_model << 4) | boot_cpu_data.x86_mask;
  786. processor.mpc_featureflag = boot_cpu_data.x86_capability[0];
  787. processor.mpc_reserved[0] = 0;
  788. processor.mpc_reserved[1] = 0;
  789. MP_processor_info(&processor);
  790. }
  791. #ifdef CONFIG_X86_IO_APIC
  792. #define MP_ISA_BUS 0
  793. #define MP_MAX_IOAPIC_PIN 127
  794. static struct mp_ioapic_routing {
  795. int apic_id;
  796. int gsi_base;
  797. int gsi_end;
  798. u32 pin_programmed[4];
  799. } mp_ioapic_routing[MAX_IO_APICS];
  800. static int mp_find_ioapic (int gsi)
  801. {
  802. int i = 0;
  803. /* Find the IOAPIC that manages this GSI. */
  804. for (i = 0; i < nr_ioapics; i++) {
  805. if ((gsi >= mp_ioapic_routing[i].gsi_base)
  806. && (gsi <= mp_ioapic_routing[i].gsi_end))
  807. return i;
  808. }
  809. printk(KERN_ERR "ERROR: Unable to locate IOAPIC for GSI %d\n", gsi);
  810. return -1;
  811. }
  812. static u8 uniq_ioapic_id(u8 id)
  813. {
  814. if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) &&
  815. !APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
  816. return io_apic_get_unique_id(nr_ioapics, id);
  817. else
  818. return id;
  819. }
  820. void __init mp_register_ioapic(u8 id, u32 address, u32 gsi_base)
  821. {
  822. int idx = 0;
  823. if (bad_ioapic(address))
  824. return;
  825. idx = nr_ioapics;
  826. mp_ioapics[idx].mpc_type = MP_IOAPIC;
  827. mp_ioapics[idx].mpc_flags = MPC_APIC_USABLE;
  828. mp_ioapics[idx].mpc_apicaddr = address;
  829. set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
  830. mp_ioapics[idx].mpc_apicid = uniq_ioapic_id(id);
  831. mp_ioapics[idx].mpc_apicver = io_apic_get_version(idx);
  832. /*
  833. * Build basic GSI lookup table to facilitate gsi->io_apic lookups
  834. * and to prevent reprogramming of IOAPIC pins (PCI GSIs).
  835. */
  836. mp_ioapic_routing[idx].apic_id = mp_ioapics[idx].mpc_apicid;
  837. mp_ioapic_routing[idx].gsi_base = gsi_base;
  838. mp_ioapic_routing[idx].gsi_end = gsi_base +
  839. io_apic_get_redir_entries(idx);
  840. printk("IOAPIC[%d]: apic_id %d, version %d, address 0x%x, "
  841. "GSI %d-%d\n", idx, mp_ioapics[idx].mpc_apicid,
  842. mp_ioapics[idx].mpc_apicver,
  843. mp_ioapics[idx].mpc_apicaddr,
  844. mp_ioapic_routing[idx].gsi_base,
  845. mp_ioapic_routing[idx].gsi_end);
  846. nr_ioapics++;
  847. }
  848. void __init
  849. mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
  850. {
  851. struct mpc_config_intsrc intsrc;
  852. int ioapic = -1;
  853. int pin = -1;
  854. /*
  855. * Convert 'gsi' to 'ioapic.pin'.
  856. */
  857. ioapic = mp_find_ioapic(gsi);
  858. if (ioapic < 0)
  859. return;
  860. pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
  861. /*
  862. * TBD: This check is for faulty timer entries, where the override
  863. * erroneously sets the trigger to level, resulting in a HUGE
  864. * increase of timer interrupts!
  865. */
  866. if ((bus_irq == 0) && (trigger == 3))
  867. trigger = 1;
  868. intsrc.mpc_type = MP_INTSRC;
  869. intsrc.mpc_irqtype = mp_INT;
  870. intsrc.mpc_irqflag = (trigger << 2) | polarity;
  871. intsrc.mpc_srcbus = MP_ISA_BUS;
  872. intsrc.mpc_srcbusirq = bus_irq; /* IRQ */
  873. intsrc.mpc_dstapic = mp_ioapics[ioapic].mpc_apicid; /* APIC ID */
  874. intsrc.mpc_dstirq = pin; /* INTIN# */
  875. Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, %d-%d\n",
  876. intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3,
  877. (intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus,
  878. intsrc.mpc_srcbusirq, intsrc.mpc_dstapic, intsrc.mpc_dstirq);
  879. mp_irqs[mp_irq_entries] = intsrc;
  880. if (++mp_irq_entries == MAX_IRQ_SOURCES)
  881. panic("Max # of irq sources exceeded!\n");
  882. }
  883. void __init mp_config_acpi_legacy_irqs (void)
  884. {
  885. struct mpc_config_intsrc intsrc;
  886. int i = 0;
  887. int ioapic = -1;
  888. #if defined (CONFIG_MCA) || defined (CONFIG_EISA)
  889. /*
  890. * Fabricate the legacy ISA bus (bus #31).
  891. */
  892. mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA;
  893. #endif
  894. set_bit(MP_ISA_BUS, mp_bus_not_pci);
  895. Dprintk("Bus #%d is ISA\n", MP_ISA_BUS);
  896. /*
  897. * Older generations of ES7000 have no legacy identity mappings
  898. */
  899. if (es7000_plat == 1)
  900. return;
  901. /*
  902. * Locate the IOAPIC that manages the ISA IRQs (0-15).
  903. */
  904. ioapic = mp_find_ioapic(0);
  905. if (ioapic < 0)
  906. return;
  907. intsrc.mpc_type = MP_INTSRC;
  908. intsrc.mpc_irqflag = 0; /* Conforming */
  909. intsrc.mpc_srcbus = MP_ISA_BUS;
  910. intsrc.mpc_dstapic = mp_ioapics[ioapic].mpc_apicid;
  911. /*
  912. * Use the default configuration for the IRQs 0-15. Unless
  913. * overridden by (MADT) interrupt source override entries.
  914. */
  915. for (i = 0; i < 16; i++) {
  916. int idx;
  917. for (idx = 0; idx < mp_irq_entries; idx++) {
  918. struct mpc_config_intsrc *irq = mp_irqs + idx;
  919. /* Do we already have a mapping for this ISA IRQ? */
  920. if (irq->mpc_srcbus == MP_ISA_BUS && irq->mpc_srcbusirq == i)
  921. break;
  922. /* Do we already have a mapping for this IOAPIC pin */
  923. if ((irq->mpc_dstapic == intsrc.mpc_dstapic) &&
  924. (irq->mpc_dstirq == i))
  925. break;
  926. }
  927. if (idx != mp_irq_entries) {
  928. printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i);
  929. continue; /* IRQ already used */
  930. }
  931. intsrc.mpc_irqtype = mp_INT;
  932. intsrc.mpc_srcbusirq = i; /* Identity mapped */
  933. intsrc.mpc_dstirq = i;
  934. Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, "
  935. "%d-%d\n", intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3,
  936. (intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus,
  937. intsrc.mpc_srcbusirq, intsrc.mpc_dstapic,
  938. intsrc.mpc_dstirq);
  939. mp_irqs[mp_irq_entries] = intsrc;
  940. if (++mp_irq_entries == MAX_IRQ_SOURCES)
  941. panic("Max # of irq sources exceeded!\n");
  942. }
  943. }
  944. #define MAX_GSI_NUM 4096
  945. #define IRQ_COMPRESSION_START 64
  946. int mp_register_gsi(u32 gsi, int triggering, int polarity)
  947. {
  948. int ioapic = -1;
  949. int ioapic_pin = 0;
  950. int idx, bit = 0;
  951. static int pci_irq = IRQ_COMPRESSION_START;
  952. /*
  953. * Mapping between Global System Interrupts, which
  954. * represent all possible interrupts, and IRQs
  955. * assigned to actual devices.
  956. */
  957. static int gsi_to_irq[MAX_GSI_NUM];
  958. /* Don't set up the ACPI SCI because it's already set up */
  959. if (acpi_gbl_FADT.sci_interrupt == gsi)
  960. return gsi;
  961. ioapic = mp_find_ioapic(gsi);
  962. if (ioapic < 0) {
  963. printk(KERN_WARNING "No IOAPIC for GSI %u\n", gsi);
  964. return gsi;
  965. }
  966. ioapic_pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
  967. if (ioapic_renumber_irq)
  968. gsi = ioapic_renumber_irq(ioapic, gsi);
  969. /*
  970. * Avoid pin reprogramming. PRTs typically include entries
  971. * with redundant pin->gsi mappings (but unique PCI devices);
  972. * we only program the IOAPIC on the first.
  973. */
  974. bit = ioapic_pin % 32;
  975. idx = (ioapic_pin < 32) ? 0 : (ioapic_pin / 32);
  976. if (idx > 3) {
  977. printk(KERN_ERR "Invalid reference to IOAPIC pin "
  978. "%d-%d\n", mp_ioapic_routing[ioapic].apic_id,
  979. ioapic_pin);
  980. return gsi;
  981. }
  982. if ((1<<bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) {
  983. Dprintk(KERN_DEBUG "Pin %d-%d already programmed\n",
  984. mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
  985. return (gsi < IRQ_COMPRESSION_START ? gsi : gsi_to_irq[gsi]);
  986. }
  987. mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit);
  988. /*
  989. * For GSI >= 64, use IRQ compression
  990. */
  991. if ((gsi >= IRQ_COMPRESSION_START)
  992. && (triggering == ACPI_LEVEL_SENSITIVE)) {
  993. /*
  994. * For PCI devices assign IRQs in order, avoiding gaps
  995. * due to unused I/O APIC pins.
  996. */
  997. int irq = gsi;
  998. if (gsi < MAX_GSI_NUM) {
  999. /*
  1000. * Retain the VIA chipset work-around (gsi > 15), but
  1001. * avoid a problem where the 8254 timer (IRQ0) is setup
  1002. * via an override (so it's not on pin 0 of the ioapic),
  1003. * and at the same time, the pin 0 interrupt is a PCI
  1004. * type. The gsi > 15 test could cause these two pins
  1005. * to be shared as IRQ0, and they are not shareable.
  1006. * So test for this condition, and if necessary, avoid
  1007. * the pin collision.
  1008. */
  1009. if (gsi > 15 || (gsi == 0 && !timer_uses_ioapic_pin_0))
  1010. gsi = pci_irq++;
  1011. /*
  1012. * Don't assign IRQ used by ACPI SCI
  1013. */
  1014. if (gsi == acpi_gbl_FADT.sci_interrupt)
  1015. gsi = pci_irq++;
  1016. gsi_to_irq[irq] = gsi;
  1017. } else {
  1018. printk(KERN_ERR "GSI %u is too high\n", gsi);
  1019. return gsi;
  1020. }
  1021. }
  1022. io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
  1023. triggering == ACPI_EDGE_SENSITIVE ? 0 : 1,
  1024. polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
  1025. return gsi;
  1026. }
  1027. #endif /* CONFIG_X86_IO_APIC */
  1028. #endif /* CONFIG_ACPI */