core_mcpcia.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. /*
  2. * linux/arch/alpha/kernel/core_mcpcia.c
  3. *
  4. * Based on code written by David A Rusling (david.rusling@reo.mts.dec.com).
  5. *
  6. * Code common to all MCbus-PCI Adaptor core logic chipsets
  7. */
  8. #define __EXTERN_INLINE inline
  9. #include <asm/io.h>
  10. #include <asm/core_mcpcia.h>
  11. #undef __EXTERN_INLINE
  12. #include <linux/types.h>
  13. #include <linux/pci.h>
  14. #include <linux/sched.h>
  15. #include <linux/init.h>
  16. #include <linux/delay.h>
  17. #include <asm/ptrace.h>
  18. #include "proto.h"
  19. #include "pci_impl.h"
  20. /*
  21. * NOTE: Herein lie back-to-back mb instructions. They are magic.
  22. * One plausible explanation is that the i/o controller does not properly
  23. * handle the system transaction. Another involves timing. Ho hum.
  24. */
  25. /*
  26. * BIOS32-style PCI interface:
  27. */
  28. #define DEBUG_CFG 0
  29. #if DEBUG_CFG
  30. # define DBG_CFG(args) printk args
  31. #else
  32. # define DBG_CFG(args)
  33. #endif
  34. #define MCPCIA_MAX_HOSES 4
  35. /*
  36. * Given a bus, device, and function number, compute resulting
  37. * configuration space address and setup the MCPCIA_HAXR2 register
  38. * accordingly. It is therefore not safe to have concurrent
  39. * invocations to configuration space access routines, but there
  40. * really shouldn't be any need for this.
  41. *
  42. * Type 0:
  43. *
  44. * 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1
  45. * 3 2|1 0 9 8|7 6 5 4|3 2 1 0|9 8 7 6|5 4 3 2|1 0 9 8|7 6 5 4|3 2 1 0
  46. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  47. * | | |D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|D|F|F|F|R|R|R|R|R|R|0|0|
  48. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  49. *
  50. * 31:11 Device select bit.
  51. * 10:8 Function number
  52. * 7:2 Register number
  53. *
  54. * Type 1:
  55. *
  56. * 3 3|3 3 2 2|2 2 2 2|2 2 2 2|1 1 1 1|1 1 1 1|1 1
  57. * 3 2|1 0 9 8|7 6 5 4|3 2 1 0|9 8 7 6|5 4 3 2|1 0 9 8|7 6 5 4|3 2 1 0
  58. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  59. * | | | | | | | | | | |B|B|B|B|B|B|B|B|D|D|D|D|D|F|F|F|R|R|R|R|R|R|0|1|
  60. * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  61. *
  62. * 31:24 reserved
  63. * 23:16 bus number (8 bits = 128 possible buses)
  64. * 15:11 Device number (5 bits)
  65. * 10:8 function number
  66. * 7:2 register number
  67. *
  68. * Notes:
  69. * The function number selects which function of a multi-function device
  70. * (e.g., SCSI and Ethernet).
  71. *
  72. * The register selects a DWORD (32 bit) register offset. Hence it
  73. * doesn't get shifted by 2 bits as we want to "drop" the bottom two
  74. * bits.
  75. */
  76. static unsigned int
  77. conf_read(unsigned long addr, unsigned char type1,
  78. struct pci_controller *hose)
  79. {
  80. unsigned long flags;
  81. unsigned long mid = MCPCIA_HOSE2MID(hose->index);
  82. unsigned int stat0, value, temp, cpu;
  83. cpu = smp_processor_id();
  84. local_irq_save(flags);
  85. DBG_CFG(("conf_read(addr=0x%lx, type1=%d, hose=%d)\n",
  86. addr, type1, mid));
  87. /* Reset status register to avoid losing errors. */
  88. stat0 = *(vuip)MCPCIA_CAP_ERR(mid);
  89. *(vuip)MCPCIA_CAP_ERR(mid) = stat0;
  90. mb();
  91. temp = *(vuip)MCPCIA_CAP_ERR(mid);
  92. DBG_CFG(("conf_read: MCPCIA_CAP_ERR(%d) was 0x%x\n", mid, stat0));
  93. mb();
  94. draina();
  95. mcheck_expected(cpu) = 1;
  96. mcheck_taken(cpu) = 0;
  97. mcheck_extra(cpu) = mid;
  98. mb();
  99. /* Access configuration space. */
  100. value = *((vuip)addr);
  101. mb();
  102. mb(); /* magic */
  103. if (mcheck_taken(cpu)) {
  104. mcheck_taken(cpu) = 0;
  105. value = 0xffffffffU;
  106. mb();
  107. }
  108. mcheck_expected(cpu) = 0;
  109. mb();
  110. DBG_CFG(("conf_read(): finished\n"));
  111. local_irq_restore(flags);
  112. return value;
  113. }
  114. static void
  115. conf_write(unsigned long addr, unsigned int value, unsigned char type1,
  116. struct pci_controller *hose)
  117. {
  118. unsigned long flags;
  119. unsigned long mid = MCPCIA_HOSE2MID(hose->index);
  120. unsigned int stat0, temp, cpu;
  121. cpu = smp_processor_id();
  122. local_irq_save(flags); /* avoid getting hit by machine check */
  123. /* Reset status register to avoid losing errors. */
  124. stat0 = *(vuip)MCPCIA_CAP_ERR(mid);
  125. *(vuip)MCPCIA_CAP_ERR(mid) = stat0; mb();
  126. temp = *(vuip)MCPCIA_CAP_ERR(mid);
  127. DBG_CFG(("conf_write: MCPCIA CAP_ERR(%d) was 0x%x\n", mid, stat0));
  128. draina();
  129. mcheck_expected(cpu) = 1;
  130. mcheck_extra(cpu) = mid;
  131. mb();
  132. /* Access configuration space. */
  133. *((vuip)addr) = value;
  134. mb();
  135. mb(); /* magic */
  136. temp = *(vuip)MCPCIA_CAP_ERR(mid); /* read to force the write */
  137. mcheck_expected(cpu) = 0;
  138. mb();
  139. DBG_CFG(("conf_write(): finished\n"));
  140. local_irq_restore(flags);
  141. }
  142. static int
  143. mk_conf_addr(struct pci_bus *pbus, unsigned int devfn, int where,
  144. struct pci_controller *hose, unsigned long *pci_addr,
  145. unsigned char *type1)
  146. {
  147. u8 bus = pbus->number;
  148. unsigned long addr;
  149. DBG_CFG(("mk_conf_addr(bus=%d,devfn=0x%x,hose=%d,where=0x%x,"
  150. " pci_addr=0x%p, type1=0x%p)\n",
  151. bus, devfn, hose->index, where, pci_addr, type1));
  152. /* Type 1 configuration cycle for *ALL* busses. */
  153. *type1 = 1;
  154. if (!pbus->parent) /* No parent means peer PCI bus. */
  155. bus = 0;
  156. addr = (bus << 16) | (devfn << 8) | (where);
  157. addr <<= 5; /* swizzle for SPARSE */
  158. addr |= hose->config_space_base;
  159. *pci_addr = addr;
  160. DBG_CFG(("mk_conf_addr: returning pci_addr 0x%lx\n", addr));
  161. return 0;
  162. }
  163. static int
  164. mcpcia_read_config(struct pci_bus *bus, unsigned int devfn, int where,
  165. int size, u32 *value)
  166. {
  167. struct pci_controller *hose = bus->sysdata;
  168. unsigned long addr, w;
  169. unsigned char type1;
  170. if (mk_conf_addr(bus, devfn, where, hose, &addr, &type1))
  171. return PCIBIOS_DEVICE_NOT_FOUND;
  172. addr |= (size - 1) * 8;
  173. w = conf_read(addr, type1, hose);
  174. switch (size) {
  175. case 1:
  176. *value = __kernel_extbl(w, where & 3);
  177. break;
  178. case 2:
  179. *value = __kernel_extwl(w, where & 3);
  180. break;
  181. case 4:
  182. *value = w;
  183. break;
  184. }
  185. return PCIBIOS_SUCCESSFUL;
  186. }
  187. static int
  188. mcpcia_write_config(struct pci_bus *bus, unsigned int devfn, int where,
  189. int size, u32 value)
  190. {
  191. struct pci_controller *hose = bus->sysdata;
  192. unsigned long addr;
  193. unsigned char type1;
  194. if (mk_conf_addr(bus, devfn, where, hose, &addr, &type1))
  195. return PCIBIOS_DEVICE_NOT_FOUND;
  196. addr |= (size - 1) * 8;
  197. value = __kernel_insql(value, where & 3);
  198. conf_write(addr, value, type1, hose);
  199. return PCIBIOS_SUCCESSFUL;
  200. }
  201. struct pci_ops mcpcia_pci_ops =
  202. {
  203. .read = mcpcia_read_config,
  204. .write = mcpcia_write_config,
  205. };
  206. void
  207. mcpcia_pci_tbi(struct pci_controller *hose, dma_addr_t start, dma_addr_t end)
  208. {
  209. wmb();
  210. *(vuip)MCPCIA_SG_TBIA(MCPCIA_HOSE2MID(hose->index)) = 0;
  211. mb();
  212. }
  213. static int __init
  214. mcpcia_probe_hose(int h)
  215. {
  216. int cpu = smp_processor_id();
  217. int mid = MCPCIA_HOSE2MID(h);
  218. unsigned int pci_rev;
  219. /* Gotta be REAL careful. If hose is absent, we get an mcheck. */
  220. mb();
  221. mb();
  222. draina();
  223. wrmces(7);
  224. mcheck_expected(cpu) = 2; /* indicates probing */
  225. mcheck_taken(cpu) = 0;
  226. mcheck_extra(cpu) = mid;
  227. mb();
  228. /* Access the bus revision word. */
  229. pci_rev = *(vuip)MCPCIA_REV(mid);
  230. mb();
  231. mb(); /* magic */
  232. if (mcheck_taken(cpu)) {
  233. mcheck_taken(cpu) = 0;
  234. pci_rev = 0xffffffff;
  235. mb();
  236. }
  237. mcheck_expected(cpu) = 0;
  238. mb();
  239. return (pci_rev >> 16) == PCI_CLASS_BRIDGE_HOST;
  240. }
  241. static void __init
  242. mcpcia_new_hose(int h)
  243. {
  244. struct pci_controller *hose;
  245. struct resource *io, *mem, *hae_mem;
  246. int mid = MCPCIA_HOSE2MID(h);
  247. hose = alloc_pci_controller();
  248. if (h == 0)
  249. pci_isa_hose = hose;
  250. io = alloc_resource();
  251. mem = alloc_resource();
  252. hae_mem = alloc_resource();
  253. hose->io_space = io;
  254. hose->mem_space = hae_mem;
  255. hose->sparse_mem_base = MCPCIA_SPARSE(mid) - IDENT_ADDR;
  256. hose->dense_mem_base = MCPCIA_DENSE(mid) - IDENT_ADDR;
  257. hose->sparse_io_base = MCPCIA_IO(mid) - IDENT_ADDR;
  258. hose->dense_io_base = 0;
  259. hose->config_space_base = MCPCIA_CONF(mid);
  260. hose->index = h;
  261. io->start = MCPCIA_IO(mid) - MCPCIA_IO_BIAS;
  262. io->end = io->start + 0xffff;
  263. io->name = pci_io_names[h];
  264. io->flags = IORESOURCE_IO;
  265. mem->start = MCPCIA_DENSE(mid) - MCPCIA_MEM_BIAS;
  266. mem->end = mem->start + 0xffffffff;
  267. mem->name = pci_mem_names[h];
  268. mem->flags = IORESOURCE_MEM;
  269. hae_mem->start = mem->start;
  270. hae_mem->end = mem->start + MCPCIA_MEM_MASK;
  271. hae_mem->name = pci_hae0_name;
  272. hae_mem->flags = IORESOURCE_MEM;
  273. if (request_resource(&ioport_resource, io) < 0)
  274. printk(KERN_ERR "Failed to request IO on hose %d\n", h);
  275. if (request_resource(&iomem_resource, mem) < 0)
  276. printk(KERN_ERR "Failed to request MEM on hose %d\n", h);
  277. if (request_resource(mem, hae_mem) < 0)
  278. printk(KERN_ERR "Failed to request HAE_MEM on hose %d\n", h);
  279. }
  280. static void
  281. mcpcia_pci_clr_err(int mid)
  282. {
  283. *(vuip)MCPCIA_CAP_ERR(mid);
  284. *(vuip)MCPCIA_CAP_ERR(mid) = 0xffffffff; /* Clear them all. */
  285. mb();
  286. *(vuip)MCPCIA_CAP_ERR(mid); /* Re-read for force write. */
  287. }
  288. static void __init
  289. mcpcia_startup_hose(struct pci_controller *hose)
  290. {
  291. int mid = MCPCIA_HOSE2MID(hose->index);
  292. unsigned int tmp;
  293. mcpcia_pci_clr_err(mid);
  294. /*
  295. * Set up error reporting.
  296. */
  297. tmp = *(vuip)MCPCIA_CAP_ERR(mid);
  298. tmp |= 0x0006; /* master/target abort */
  299. *(vuip)MCPCIA_CAP_ERR(mid) = tmp;
  300. mb();
  301. tmp = *(vuip)MCPCIA_CAP_ERR(mid);
  302. /*
  303. * Set up the PCI->physical memory translation windows.
  304. *
  305. * Window 0 is scatter-gather 8MB at 8MB (for isa)
  306. * Window 1 is scatter-gather (up to) 1GB at 1GB (for pci)
  307. * Window 2 is direct access 2GB at 2GB
  308. */
  309. hose->sg_isa = iommu_arena_new(hose, 0x00800000, 0x00800000, 0);
  310. hose->sg_pci = iommu_arena_new(hose, 0x40000000,
  311. size_for_memory(0x40000000), 0);
  312. __direct_map_base = 0x80000000;
  313. __direct_map_size = 0x80000000;
  314. *(vuip)MCPCIA_W0_BASE(mid) = hose->sg_isa->dma_base | 3;
  315. *(vuip)MCPCIA_W0_MASK(mid) = (hose->sg_isa->size - 1) & 0xfff00000;
  316. *(vuip)MCPCIA_T0_BASE(mid) = virt_to_phys(hose->sg_isa->ptes) >> 8;
  317. *(vuip)MCPCIA_W1_BASE(mid) = hose->sg_pci->dma_base | 3;
  318. *(vuip)MCPCIA_W1_MASK(mid) = (hose->sg_pci->size - 1) & 0xfff00000;
  319. *(vuip)MCPCIA_T1_BASE(mid) = virt_to_phys(hose->sg_pci->ptes) >> 8;
  320. *(vuip)MCPCIA_W2_BASE(mid) = __direct_map_base | 1;
  321. *(vuip)MCPCIA_W2_MASK(mid) = (__direct_map_size - 1) & 0xfff00000;
  322. *(vuip)MCPCIA_T2_BASE(mid) = 0;
  323. *(vuip)MCPCIA_W3_BASE(mid) = 0x0;
  324. mcpcia_pci_tbi(hose, 0, -1);
  325. *(vuip)MCPCIA_HBASE(mid) = 0x0;
  326. mb();
  327. *(vuip)MCPCIA_HAE_MEM(mid) = 0U;
  328. mb();
  329. *(vuip)MCPCIA_HAE_MEM(mid); /* read it back. */
  330. *(vuip)MCPCIA_HAE_IO(mid) = 0;
  331. mb();
  332. *(vuip)MCPCIA_HAE_IO(mid); /* read it back. */
  333. }
  334. void __init
  335. mcpcia_init_arch(void)
  336. {
  337. /* With multiple PCI busses, we play with I/O as physical addrs. */
  338. ioport_resource.end = ~0UL;
  339. /* Allocate hose 0. That's the one that all the ISA junk hangs
  340. off of, from which we'll be registering stuff here in a bit.
  341. Other hose detection is done in mcpcia_init_hoses, which is
  342. called from init_IRQ. */
  343. mcpcia_new_hose(0);
  344. }
  345. /* This is called from init_IRQ, since we cannot take interrupts
  346. before then. Which means we cannot do this in init_arch. */
  347. void __init
  348. mcpcia_init_hoses(void)
  349. {
  350. struct pci_controller *hose;
  351. int hose_count;
  352. int h;
  353. /* First, find how many hoses we have. */
  354. hose_count = 0;
  355. for (h = 0; h < MCPCIA_MAX_HOSES; ++h) {
  356. if (mcpcia_probe_hose(h)) {
  357. if (h != 0)
  358. mcpcia_new_hose(h);
  359. hose_count++;
  360. }
  361. }
  362. printk("mcpcia_init_hoses: found %d hoses\n", hose_count);
  363. /* Now do init for each hose. */
  364. for (hose = hose_head; hose; hose = hose->next)
  365. mcpcia_startup_hose(hose);
  366. }
  367. static void
  368. mcpcia_print_uncorrectable(struct el_MCPCIA_uncorrected_frame_mcheck *logout)
  369. {
  370. struct el_common_EV5_uncorrectable_mcheck *frame;
  371. int i;
  372. frame = &logout->procdata;
  373. /* Print PAL fields */
  374. for (i = 0; i < 24; i += 2) {
  375. printk(" paltmp[%d-%d] = %16lx %16lx\n",
  376. i, i+1, frame->paltemp[i], frame->paltemp[i+1]);
  377. }
  378. for (i = 0; i < 8; i += 2) {
  379. printk(" shadow[%d-%d] = %16lx %16lx\n",
  380. i, i+1, frame->shadow[i],
  381. frame->shadow[i+1]);
  382. }
  383. printk(" Addr of excepting instruction = %16lx\n",
  384. frame->exc_addr);
  385. printk(" Summary of arithmetic traps = %16lx\n",
  386. frame->exc_sum);
  387. printk(" Exception mask = %16lx\n",
  388. frame->exc_mask);
  389. printk(" Base address for PALcode = %16lx\n",
  390. frame->pal_base);
  391. printk(" Interrupt Status Reg = %16lx\n",
  392. frame->isr);
  393. printk(" CURRENT SETUP OF EV5 IBOX = %16lx\n",
  394. frame->icsr);
  395. printk(" I-CACHE Reg %s parity error = %16lx\n",
  396. (frame->ic_perr_stat & 0x800L) ?
  397. "Data" : "Tag",
  398. frame->ic_perr_stat);
  399. printk(" D-CACHE error Reg = %16lx\n",
  400. frame->dc_perr_stat);
  401. if (frame->dc_perr_stat & 0x2) {
  402. switch (frame->dc_perr_stat & 0x03c) {
  403. case 8:
  404. printk(" Data error in bank 1\n");
  405. break;
  406. case 4:
  407. printk(" Data error in bank 0\n");
  408. break;
  409. case 20:
  410. printk(" Tag error in bank 1\n");
  411. break;
  412. case 10:
  413. printk(" Tag error in bank 0\n");
  414. break;
  415. }
  416. }
  417. printk(" Effective VA = %16lx\n",
  418. frame->va);
  419. printk(" Reason for D-stream = %16lx\n",
  420. frame->mm_stat);
  421. printk(" EV5 SCache address = %16lx\n",
  422. frame->sc_addr);
  423. printk(" EV5 SCache TAG/Data parity = %16lx\n",
  424. frame->sc_stat);
  425. printk(" EV5 BC_TAG_ADDR = %16lx\n",
  426. frame->bc_tag_addr);
  427. printk(" EV5 EI_ADDR: Phys addr of Xfer = %16lx\n",
  428. frame->ei_addr);
  429. printk(" Fill Syndrome = %16lx\n",
  430. frame->fill_syndrome);
  431. printk(" EI_STAT reg = %16lx\n",
  432. frame->ei_stat);
  433. printk(" LD_LOCK = %16lx\n",
  434. frame->ld_lock);
  435. }
  436. static void
  437. mcpcia_print_system_area(unsigned long la_ptr)
  438. {
  439. struct el_common *frame;
  440. struct pci_controller *hose;
  441. struct IOD_subpacket {
  442. unsigned long base;
  443. unsigned int whoami;
  444. unsigned int rsvd1;
  445. unsigned int pci_rev;
  446. unsigned int cap_ctrl;
  447. unsigned int hae_mem;
  448. unsigned int hae_io;
  449. unsigned int int_ctl;
  450. unsigned int int_reg;
  451. unsigned int int_mask0;
  452. unsigned int int_mask1;
  453. unsigned int mc_err0;
  454. unsigned int mc_err1;
  455. unsigned int cap_err;
  456. unsigned int rsvd2;
  457. unsigned int pci_err1;
  458. unsigned int mdpa_stat;
  459. unsigned int mdpa_syn;
  460. unsigned int mdpb_stat;
  461. unsigned int mdpb_syn;
  462. unsigned int rsvd3;
  463. unsigned int rsvd4;
  464. unsigned int rsvd5;
  465. } *iodpp;
  466. frame = (struct el_common *)la_ptr;
  467. iodpp = (struct IOD_subpacket *) (la_ptr + frame->sys_offset);
  468. for (hose = hose_head; hose; hose = hose->next, iodpp++) {
  469. printk("IOD %d Register Subpacket - Bridge Base Address %16lx\n",
  470. hose->index, iodpp->base);
  471. printk(" WHOAMI = %8x\n", iodpp->whoami);
  472. printk(" PCI_REV = %8x\n", iodpp->pci_rev);
  473. printk(" CAP_CTRL = %8x\n", iodpp->cap_ctrl);
  474. printk(" HAE_MEM = %8x\n", iodpp->hae_mem);
  475. printk(" HAE_IO = %8x\n", iodpp->hae_io);
  476. printk(" INT_CTL = %8x\n", iodpp->int_ctl);
  477. printk(" INT_REG = %8x\n", iodpp->int_reg);
  478. printk(" INT_MASK0 = %8x\n", iodpp->int_mask0);
  479. printk(" INT_MASK1 = %8x\n", iodpp->int_mask1);
  480. printk(" MC_ERR0 = %8x\n", iodpp->mc_err0);
  481. printk(" MC_ERR1 = %8x\n", iodpp->mc_err1);
  482. printk(" CAP_ERR = %8x\n", iodpp->cap_err);
  483. printk(" PCI_ERR1 = %8x\n", iodpp->pci_err1);
  484. printk(" MDPA_STAT = %8x\n", iodpp->mdpa_stat);
  485. printk(" MDPA_SYN = %8x\n", iodpp->mdpa_syn);
  486. printk(" MDPB_STAT = %8x\n", iodpp->mdpb_stat);
  487. printk(" MDPB_SYN = %8x\n", iodpp->mdpb_syn);
  488. }
  489. }
  490. void
  491. mcpcia_machine_check(unsigned long vector, unsigned long la_ptr,
  492. struct pt_regs * regs)
  493. {
  494. struct el_common *mchk_header;
  495. struct el_MCPCIA_uncorrected_frame_mcheck *mchk_logout;
  496. unsigned int cpu = smp_processor_id();
  497. int expected;
  498. mchk_header = (struct el_common *)la_ptr;
  499. mchk_logout = (struct el_MCPCIA_uncorrected_frame_mcheck *)la_ptr;
  500. expected = mcheck_expected(cpu);
  501. mb();
  502. mb(); /* magic */
  503. draina();
  504. switch (expected) {
  505. case 0:
  506. {
  507. /* FIXME: how do we figure out which hose the
  508. error was on? */
  509. struct pci_controller *hose;
  510. for (hose = hose_head; hose; hose = hose->next)
  511. mcpcia_pci_clr_err(MCPCIA_HOSE2MID(hose->index));
  512. break;
  513. }
  514. case 1:
  515. mcpcia_pci_clr_err(mcheck_extra(cpu));
  516. break;
  517. default:
  518. /* Otherwise, we're being called from mcpcia_probe_hose
  519. and there's no hose clear an error from. */
  520. break;
  521. }
  522. wrmces(0x7);
  523. mb();
  524. process_mcheck_info(vector, la_ptr, regs, "MCPCIA", expected != 0);
  525. if (!expected && vector != 0x620 && vector != 0x630) {
  526. mcpcia_print_uncorrectable(mchk_logout);
  527. mcpcia_print_system_area(la_ptr);
  528. }
  529. }