eeh.c 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252
  1. /*
  2. * eeh.c
  3. * Copyright (C) 2001 Dave Engebretsen & Todd Inglett IBM Corporation
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/delay.h>
  20. #include <linux/init.h>
  21. #include <linux/list.h>
  22. #include <linux/pci.h>
  23. #include <linux/proc_fs.h>
  24. #include <linux/rbtree.h>
  25. #include <linux/seq_file.h>
  26. #include <linux/spinlock.h>
  27. #include <asm/atomic.h>
  28. #include <asm/eeh.h>
  29. #include <asm/eeh_event.h>
  30. #include <asm/io.h>
  31. #include <asm/machdep.h>
  32. #include <asm/ppc-pci.h>
  33. #include <asm/rtas.h>
  34. #undef DEBUG
  35. /** Overview:
  36. * EEH, or "Extended Error Handling" is a PCI bridge technology for
  37. * dealing with PCI bus errors that can't be dealt with within the
  38. * usual PCI framework, except by check-stopping the CPU. Systems
  39. * that are designed for high-availability/reliability cannot afford
  40. * to crash due to a "mere" PCI error, thus the need for EEH.
  41. * An EEH-capable bridge operates by converting a detected error
  42. * into a "slot freeze", taking the PCI adapter off-line, making
  43. * the slot behave, from the OS'es point of view, as if the slot
  44. * were "empty": all reads return 0xff's and all writes are silently
  45. * ignored. EEH slot isolation events can be triggered by parity
  46. * errors on the address or data busses (e.g. during posted writes),
  47. * which in turn might be caused by low voltage on the bus, dust,
  48. * vibration, humidity, radioactivity or plain-old failed hardware.
  49. *
  50. * Note, however, that one of the leading causes of EEH slot
  51. * freeze events are buggy device drivers, buggy device microcode,
  52. * or buggy device hardware. This is because any attempt by the
  53. * device to bus-master data to a memory address that is not
  54. * assigned to the device will trigger a slot freeze. (The idea
  55. * is to prevent devices-gone-wild from corrupting system memory).
  56. * Buggy hardware/drivers will have a miserable time co-existing
  57. * with EEH.
  58. *
  59. * Ideally, a PCI device driver, when suspecting that an isolation
  60. * event has occured (e.g. by reading 0xff's), will then ask EEH
  61. * whether this is the case, and then take appropriate steps to
  62. * reset the PCI slot, the PCI device, and then resume operations.
  63. * However, until that day, the checking is done here, with the
  64. * eeh_check_failure() routine embedded in the MMIO macros. If
  65. * the slot is found to be isolated, an "EEH Event" is synthesized
  66. * and sent out for processing.
  67. */
  68. /* If a device driver keeps reading an MMIO register in an interrupt
  69. * handler after a slot isolation event has occurred, we assume it
  70. * is broken and panic. This sets the threshold for how many read
  71. * attempts we allow before panicking.
  72. */
  73. #define EEH_MAX_FAILS 100000
  74. /* Misc forward declaraions */
  75. static void eeh_save_bars(struct pci_dev * pdev, struct pci_dn *pdn);
  76. /* RTAS tokens */
  77. static int ibm_set_eeh_option;
  78. static int ibm_set_slot_reset;
  79. static int ibm_read_slot_reset_state;
  80. static int ibm_read_slot_reset_state2;
  81. static int ibm_slot_error_detail;
  82. int eeh_subsystem_enabled;
  83. EXPORT_SYMBOL(eeh_subsystem_enabled);
  84. /* Lock to avoid races due to multiple reports of an error */
  85. static DEFINE_SPINLOCK(confirm_error_lock);
  86. /* Buffer for reporting slot-error-detail rtas calls */
  87. static unsigned char slot_errbuf[RTAS_ERROR_LOG_MAX];
  88. static DEFINE_SPINLOCK(slot_errbuf_lock);
  89. static int eeh_error_buf_size;
  90. /* System monitoring statistics */
  91. static DEFINE_PER_CPU(unsigned long, no_device);
  92. static DEFINE_PER_CPU(unsigned long, no_dn);
  93. static DEFINE_PER_CPU(unsigned long, no_cfg_addr);
  94. static DEFINE_PER_CPU(unsigned long, ignored_check);
  95. static DEFINE_PER_CPU(unsigned long, total_mmio_ffs);
  96. static DEFINE_PER_CPU(unsigned long, false_positives);
  97. static DEFINE_PER_CPU(unsigned long, ignored_failures);
  98. static DEFINE_PER_CPU(unsigned long, slot_resets);
  99. /**
  100. * The pci address cache subsystem. This subsystem places
  101. * PCI device address resources into a red-black tree, sorted
  102. * according to the address range, so that given only an i/o
  103. * address, the corresponding PCI device can be **quickly**
  104. * found. It is safe to perform an address lookup in an interrupt
  105. * context; this ability is an important feature.
  106. *
  107. * Currently, the only customer of this code is the EEH subsystem;
  108. * thus, this code has been somewhat tailored to suit EEH better.
  109. * In particular, the cache does *not* hold the addresses of devices
  110. * for which EEH is not enabled.
  111. *
  112. * (Implementation Note: The RB tree seems to be better/faster
  113. * than any hash algo I could think of for this problem, even
  114. * with the penalty of slow pointer chases for d-cache misses).
  115. */
  116. struct pci_io_addr_range
  117. {
  118. struct rb_node rb_node;
  119. unsigned long addr_lo;
  120. unsigned long addr_hi;
  121. struct pci_dev *pcidev;
  122. unsigned int flags;
  123. };
  124. static struct pci_io_addr_cache
  125. {
  126. struct rb_root rb_root;
  127. spinlock_t piar_lock;
  128. } pci_io_addr_cache_root;
  129. static inline struct pci_dev *__pci_get_device_by_addr(unsigned long addr)
  130. {
  131. struct rb_node *n = pci_io_addr_cache_root.rb_root.rb_node;
  132. while (n) {
  133. struct pci_io_addr_range *piar;
  134. piar = rb_entry(n, struct pci_io_addr_range, rb_node);
  135. if (addr < piar->addr_lo) {
  136. n = n->rb_left;
  137. } else {
  138. if (addr > piar->addr_hi) {
  139. n = n->rb_right;
  140. } else {
  141. pci_dev_get(piar->pcidev);
  142. return piar->pcidev;
  143. }
  144. }
  145. }
  146. return NULL;
  147. }
  148. /**
  149. * pci_get_device_by_addr - Get device, given only address
  150. * @addr: mmio (PIO) phys address or i/o port number
  151. *
  152. * Given an mmio phys address, or a port number, find a pci device
  153. * that implements this address. Be sure to pci_dev_put the device
  154. * when finished. I/O port numbers are assumed to be offset
  155. * from zero (that is, they do *not* have pci_io_addr added in).
  156. * It is safe to call this function within an interrupt.
  157. */
  158. static struct pci_dev *pci_get_device_by_addr(unsigned long addr)
  159. {
  160. struct pci_dev *dev;
  161. unsigned long flags;
  162. spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
  163. dev = __pci_get_device_by_addr(addr);
  164. spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
  165. return dev;
  166. }
  167. #ifdef DEBUG
  168. /*
  169. * Handy-dandy debug print routine, does nothing more
  170. * than print out the contents of our addr cache.
  171. */
  172. static void pci_addr_cache_print(struct pci_io_addr_cache *cache)
  173. {
  174. struct rb_node *n;
  175. int cnt = 0;
  176. n = rb_first(&cache->rb_root);
  177. while (n) {
  178. struct pci_io_addr_range *piar;
  179. piar = rb_entry(n, struct pci_io_addr_range, rb_node);
  180. printk(KERN_DEBUG "PCI: %s addr range %d [%lx-%lx]: %s\n",
  181. (piar->flags & IORESOURCE_IO) ? "i/o" : "mem", cnt,
  182. piar->addr_lo, piar->addr_hi, pci_name(piar->pcidev));
  183. cnt++;
  184. n = rb_next(n);
  185. }
  186. }
  187. #endif
  188. /* Insert address range into the rb tree. */
  189. static struct pci_io_addr_range *
  190. pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo,
  191. unsigned long ahi, unsigned int flags)
  192. {
  193. struct rb_node **p = &pci_io_addr_cache_root.rb_root.rb_node;
  194. struct rb_node *parent = NULL;
  195. struct pci_io_addr_range *piar;
  196. /* Walk tree, find a place to insert into tree */
  197. while (*p) {
  198. parent = *p;
  199. piar = rb_entry(parent, struct pci_io_addr_range, rb_node);
  200. if (ahi < piar->addr_lo) {
  201. p = &parent->rb_left;
  202. } else if (alo > piar->addr_hi) {
  203. p = &parent->rb_right;
  204. } else {
  205. if (dev != piar->pcidev ||
  206. alo != piar->addr_lo || ahi != piar->addr_hi) {
  207. printk(KERN_WARNING "PIAR: overlapping address range\n");
  208. }
  209. return piar;
  210. }
  211. }
  212. piar = (struct pci_io_addr_range *)kmalloc(sizeof(struct pci_io_addr_range), GFP_ATOMIC);
  213. if (!piar)
  214. return NULL;
  215. piar->addr_lo = alo;
  216. piar->addr_hi = ahi;
  217. piar->pcidev = dev;
  218. piar->flags = flags;
  219. #ifdef DEBUG
  220. printk(KERN_DEBUG "PIAR: insert range=[%lx:%lx] dev=%s\n",
  221. alo, ahi, pci_name (dev));
  222. #endif
  223. rb_link_node(&piar->rb_node, parent, p);
  224. rb_insert_color(&piar->rb_node, &pci_io_addr_cache_root.rb_root);
  225. return piar;
  226. }
  227. static void __pci_addr_cache_insert_device(struct pci_dev *dev)
  228. {
  229. struct device_node *dn;
  230. struct pci_dn *pdn;
  231. int i;
  232. int inserted = 0;
  233. dn = pci_device_to_OF_node(dev);
  234. if (!dn) {
  235. printk(KERN_WARNING "PCI: no pci dn found for dev=%s\n", pci_name(dev));
  236. return;
  237. }
  238. /* Skip any devices for which EEH is not enabled. */
  239. pdn = PCI_DN(dn);
  240. if (!(pdn->eeh_mode & EEH_MODE_SUPPORTED) ||
  241. pdn->eeh_mode & EEH_MODE_NOCHECK) {
  242. #ifdef DEBUG
  243. printk(KERN_INFO "PCI: skip building address cache for=%s - %s\n",
  244. pci_name(dev), pdn->node->full_name);
  245. #endif
  246. return;
  247. }
  248. /* The cache holds a reference to the device... */
  249. pci_dev_get(dev);
  250. /* Walk resources on this device, poke them into the tree */
  251. for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
  252. unsigned long start = pci_resource_start(dev,i);
  253. unsigned long end = pci_resource_end(dev,i);
  254. unsigned int flags = pci_resource_flags(dev,i);
  255. /* We are interested only bus addresses, not dma or other stuff */
  256. if (0 == (flags & (IORESOURCE_IO | IORESOURCE_MEM)))
  257. continue;
  258. if (start == 0 || ~start == 0 || end == 0 || ~end == 0)
  259. continue;
  260. pci_addr_cache_insert(dev, start, end, flags);
  261. inserted = 1;
  262. }
  263. /* If there was nothing to add, the cache has no reference... */
  264. if (!inserted)
  265. pci_dev_put(dev);
  266. }
  267. /**
  268. * pci_addr_cache_insert_device - Add a device to the address cache
  269. * @dev: PCI device whose I/O addresses we are interested in.
  270. *
  271. * In order to support the fast lookup of devices based on addresses,
  272. * we maintain a cache of devices that can be quickly searched.
  273. * This routine adds a device to that cache.
  274. */
  275. static void pci_addr_cache_insert_device(struct pci_dev *dev)
  276. {
  277. unsigned long flags;
  278. spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
  279. __pci_addr_cache_insert_device(dev);
  280. spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
  281. }
  282. static inline void __pci_addr_cache_remove_device(struct pci_dev *dev)
  283. {
  284. struct rb_node *n;
  285. int removed = 0;
  286. restart:
  287. n = rb_first(&pci_io_addr_cache_root.rb_root);
  288. while (n) {
  289. struct pci_io_addr_range *piar;
  290. piar = rb_entry(n, struct pci_io_addr_range, rb_node);
  291. if (piar->pcidev == dev) {
  292. rb_erase(n, &pci_io_addr_cache_root.rb_root);
  293. removed = 1;
  294. kfree(piar);
  295. goto restart;
  296. }
  297. n = rb_next(n);
  298. }
  299. /* The cache no longer holds its reference to this device... */
  300. if (removed)
  301. pci_dev_put(dev);
  302. }
  303. /**
  304. * pci_addr_cache_remove_device - remove pci device from addr cache
  305. * @dev: device to remove
  306. *
  307. * Remove a device from the addr-cache tree.
  308. * This is potentially expensive, since it will walk
  309. * the tree multiple times (once per resource).
  310. * But so what; device removal doesn't need to be that fast.
  311. */
  312. static void pci_addr_cache_remove_device(struct pci_dev *dev)
  313. {
  314. unsigned long flags;
  315. spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags);
  316. __pci_addr_cache_remove_device(dev);
  317. spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags);
  318. }
  319. /**
  320. * pci_addr_cache_build - Build a cache of I/O addresses
  321. *
  322. * Build a cache of pci i/o addresses. This cache will be used to
  323. * find the pci device that corresponds to a given address.
  324. * This routine scans all pci busses to build the cache.
  325. * Must be run late in boot process, after the pci controllers
  326. * have been scaned for devices (after all device resources are known).
  327. */
  328. void __init pci_addr_cache_build(void)
  329. {
  330. struct device_node *dn;
  331. struct pci_dev *dev = NULL;
  332. if (!eeh_subsystem_enabled)
  333. return;
  334. spin_lock_init(&pci_io_addr_cache_root.piar_lock);
  335. while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
  336. /* Ignore PCI bridges ( XXX why ??) */
  337. if ((dev->class >> 16) == PCI_BASE_CLASS_BRIDGE) {
  338. continue;
  339. }
  340. pci_addr_cache_insert_device(dev);
  341. /* Save the BAR's; firmware doesn't restore these after EEH reset */
  342. dn = pci_device_to_OF_node(dev);
  343. eeh_save_bars(dev, PCI_DN(dn));
  344. }
  345. #ifdef DEBUG
  346. /* Verify tree built up above, echo back the list of addrs. */
  347. pci_addr_cache_print(&pci_io_addr_cache_root);
  348. #endif
  349. }
  350. /* --------------------------------------------------------------- */
  351. /* Above lies the PCI Address Cache. Below lies the EEH event infrastructure */
  352. void eeh_slot_error_detail (struct pci_dn *pdn, int severity)
  353. {
  354. unsigned long flags;
  355. int rc;
  356. /* Log the error with the rtas logger */
  357. spin_lock_irqsave(&slot_errbuf_lock, flags);
  358. memset(slot_errbuf, 0, eeh_error_buf_size);
  359. rc = rtas_call(ibm_slot_error_detail,
  360. 8, 1, NULL, pdn->eeh_config_addr,
  361. BUID_HI(pdn->phb->buid),
  362. BUID_LO(pdn->phb->buid), NULL, 0,
  363. virt_to_phys(slot_errbuf),
  364. eeh_error_buf_size,
  365. severity);
  366. if (rc == 0)
  367. log_error(slot_errbuf, ERR_TYPE_RTAS_LOG, 0);
  368. spin_unlock_irqrestore(&slot_errbuf_lock, flags);
  369. }
  370. /**
  371. * read_slot_reset_state - Read the reset state of a device node's slot
  372. * @dn: device node to read
  373. * @rets: array to return results in
  374. */
  375. static int read_slot_reset_state(struct pci_dn *pdn, int rets[])
  376. {
  377. int token, outputs;
  378. if (ibm_read_slot_reset_state2 != RTAS_UNKNOWN_SERVICE) {
  379. token = ibm_read_slot_reset_state2;
  380. outputs = 4;
  381. } else {
  382. token = ibm_read_slot_reset_state;
  383. rets[2] = 0; /* fake PE Unavailable info */
  384. outputs = 3;
  385. }
  386. return rtas_call(token, 3, outputs, rets, pdn->eeh_config_addr,
  387. BUID_HI(pdn->phb->buid), BUID_LO(pdn->phb->buid));
  388. }
  389. /**
  390. * eeh_token_to_phys - convert EEH address token to phys address
  391. * @token i/o token, should be address in the form 0xA....
  392. */
  393. static inline unsigned long eeh_token_to_phys(unsigned long token)
  394. {
  395. pte_t *ptep;
  396. unsigned long pa;
  397. ptep = find_linux_pte(init_mm.pgd, token);
  398. if (!ptep)
  399. return token;
  400. pa = pte_pfn(*ptep) << PAGE_SHIFT;
  401. return pa | (token & (PAGE_SIZE-1));
  402. }
  403. /**
  404. * Return the "partitionable endpoint" (pe) under which this device lies
  405. */
  406. static struct device_node * find_device_pe(struct device_node *dn)
  407. {
  408. while ((dn->parent) && PCI_DN(dn->parent) &&
  409. (PCI_DN(dn->parent)->eeh_mode & EEH_MODE_SUPPORTED)) {
  410. dn = dn->parent;
  411. }
  412. return dn;
  413. }
  414. /** Mark all devices that are peers of this device as failed.
  415. * Mark the device driver too, so that it can see the failure
  416. * immediately; this is critical, since some drivers poll
  417. * status registers in interrupts ... If a driver is polling,
  418. * and the slot is frozen, then the driver can deadlock in
  419. * an interrupt context, which is bad.
  420. */
  421. static void __eeh_mark_slot (struct device_node *dn, int mode_flag)
  422. {
  423. while (dn) {
  424. if (PCI_DN(dn)) {
  425. PCI_DN(dn)->eeh_mode |= mode_flag;
  426. /* Mark the pci device driver too */
  427. struct pci_dev *dev = PCI_DN(dn)->pcidev;
  428. if (dev && dev->driver)
  429. dev->error_state = pci_channel_io_frozen;
  430. if (dn->child)
  431. __eeh_mark_slot (dn->child, mode_flag);
  432. }
  433. dn = dn->sibling;
  434. }
  435. }
  436. void eeh_mark_slot (struct device_node *dn, int mode_flag)
  437. {
  438. dn = find_device_pe (dn);
  439. PCI_DN(dn)->eeh_mode |= mode_flag;
  440. __eeh_mark_slot (dn->child, mode_flag);
  441. }
  442. static void __eeh_clear_slot (struct device_node *dn, int mode_flag)
  443. {
  444. while (dn) {
  445. if (PCI_DN(dn)) {
  446. PCI_DN(dn)->eeh_mode &= ~mode_flag;
  447. PCI_DN(dn)->eeh_check_count = 0;
  448. if (dn->child)
  449. __eeh_clear_slot (dn->child, mode_flag);
  450. }
  451. dn = dn->sibling;
  452. }
  453. }
  454. void eeh_clear_slot (struct device_node *dn, int mode_flag)
  455. {
  456. unsigned long flags;
  457. spin_lock_irqsave(&confirm_error_lock, flags);
  458. dn = find_device_pe (dn);
  459. PCI_DN(dn)->eeh_mode &= ~mode_flag;
  460. PCI_DN(dn)->eeh_check_count = 0;
  461. __eeh_clear_slot (dn->child, mode_flag);
  462. spin_unlock_irqrestore(&confirm_error_lock, flags);
  463. }
  464. /**
  465. * eeh_dn_check_failure - check if all 1's data is due to EEH slot freeze
  466. * @dn device node
  467. * @dev pci device, if known
  468. *
  469. * Check for an EEH failure for the given device node. Call this
  470. * routine if the result of a read was all 0xff's and you want to
  471. * find out if this is due to an EEH slot freeze. This routine
  472. * will query firmware for the EEH status.
  473. *
  474. * Returns 0 if there has not been an EEH error; otherwise returns
  475. * a non-zero value and queues up a slot isolation event notification.
  476. *
  477. * It is safe to call this routine in an interrupt context.
  478. */
  479. int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
  480. {
  481. int ret;
  482. int rets[3];
  483. unsigned long flags;
  484. struct pci_dn *pdn;
  485. enum pci_channel_state state;
  486. int rc = 0;
  487. __get_cpu_var(total_mmio_ffs)++;
  488. if (!eeh_subsystem_enabled)
  489. return 0;
  490. if (!dn) {
  491. __get_cpu_var(no_dn)++;
  492. return 0;
  493. }
  494. pdn = PCI_DN(dn);
  495. /* Access to IO BARs might get this far and still not want checking. */
  496. if (!(pdn->eeh_mode & EEH_MODE_SUPPORTED) ||
  497. pdn->eeh_mode & EEH_MODE_NOCHECK) {
  498. __get_cpu_var(ignored_check)++;
  499. #ifdef DEBUG
  500. printk ("EEH:ignored check (%x) for %s %s\n",
  501. pdn->eeh_mode, pci_name (dev), dn->full_name);
  502. #endif
  503. return 0;
  504. }
  505. if (!pdn->eeh_config_addr) {
  506. __get_cpu_var(no_cfg_addr)++;
  507. return 0;
  508. }
  509. /* If we already have a pending isolation event for this
  510. * slot, we know it's bad already, we don't need to check.
  511. * Do this checking under a lock; as multiple PCI devices
  512. * in one slot might report errors simultaneously, and we
  513. * only want one error recovery routine running.
  514. */
  515. spin_lock_irqsave(&confirm_error_lock, flags);
  516. rc = 1;
  517. if (pdn->eeh_mode & EEH_MODE_ISOLATED) {
  518. pdn->eeh_check_count ++;
  519. if (pdn->eeh_check_count >= EEH_MAX_FAILS) {
  520. printk (KERN_ERR "EEH: Device driver ignored %d bad reads, panicing\n",
  521. pdn->eeh_check_count);
  522. dump_stack();
  523. /* re-read the slot reset state */
  524. if (read_slot_reset_state(pdn, rets) != 0)
  525. rets[0] = -1; /* reset state unknown */
  526. /* If we are here, then we hit an infinite loop. Stop. */
  527. panic("EEH: MMIO halt (%d) on device:%s\n", rets[0], pci_name(dev));
  528. }
  529. goto dn_unlock;
  530. }
  531. /*
  532. * Now test for an EEH failure. This is VERY expensive.
  533. * Note that the eeh_config_addr may be a parent device
  534. * in the case of a device behind a bridge, or it may be
  535. * function zero of a multi-function device.
  536. * In any case they must share a common PHB.
  537. */
  538. ret = read_slot_reset_state(pdn, rets);
  539. /* If the call to firmware failed, punt */
  540. if (ret != 0) {
  541. printk(KERN_WARNING "EEH: read_slot_reset_state() failed; rc=%d dn=%s\n",
  542. ret, dn->full_name);
  543. __get_cpu_var(false_positives)++;
  544. rc = 0;
  545. goto dn_unlock;
  546. }
  547. /* If EEH is not supported on this device, punt. */
  548. if (rets[1] != 1) {
  549. printk(KERN_WARNING "EEH: event on unsupported device, rc=%d dn=%s\n",
  550. ret, dn->full_name);
  551. __get_cpu_var(false_positives)++;
  552. rc = 0;
  553. goto dn_unlock;
  554. }
  555. /* If not the kind of error we know about, punt. */
  556. if (rets[0] != 2 && rets[0] != 4 && rets[0] != 5) {
  557. __get_cpu_var(false_positives)++;
  558. rc = 0;
  559. goto dn_unlock;
  560. }
  561. /* Note that config-io to empty slots may fail;
  562. * we recognize empty because they don't have children. */
  563. if ((rets[0] == 5) && (dn->child == NULL)) {
  564. __get_cpu_var(false_positives)++;
  565. rc = 0;
  566. goto dn_unlock;
  567. }
  568. __get_cpu_var(slot_resets)++;
  569. /* Avoid repeated reports of this failure, including problems
  570. * with other functions on this device, and functions under
  571. * bridges. */
  572. eeh_mark_slot (dn, EEH_MODE_ISOLATED);
  573. spin_unlock_irqrestore(&confirm_error_lock, flags);
  574. state = pci_channel_io_normal;
  575. if ((rets[0] == 2) || (rets[0] == 4))
  576. state = pci_channel_io_frozen;
  577. if (rets[0] == 5)
  578. state = pci_channel_io_perm_failure;
  579. eeh_send_failure_event (dn, dev, state, rets[2]);
  580. /* Most EEH events are due to device driver bugs. Having
  581. * a stack trace will help the device-driver authors figure
  582. * out what happened. So print that out. */
  583. if (rets[0] != 5) dump_stack();
  584. return 1;
  585. dn_unlock:
  586. spin_unlock_irqrestore(&confirm_error_lock, flags);
  587. return rc;
  588. }
  589. EXPORT_SYMBOL_GPL(eeh_dn_check_failure);
  590. /**
  591. * eeh_check_failure - check if all 1's data is due to EEH slot freeze
  592. * @token i/o token, should be address in the form 0xA....
  593. * @val value, should be all 1's (XXX why do we need this arg??)
  594. *
  595. * Check for an EEH failure at the given token address. Call this
  596. * routine if the result of a read was all 0xff's and you want to
  597. * find out if this is due to an EEH slot freeze event. This routine
  598. * will query firmware for the EEH status.
  599. *
  600. * Note this routine is safe to call in an interrupt context.
  601. */
  602. unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned long val)
  603. {
  604. unsigned long addr;
  605. struct pci_dev *dev;
  606. struct device_node *dn;
  607. /* Finding the phys addr + pci device; this is pretty quick. */
  608. addr = eeh_token_to_phys((unsigned long __force) token);
  609. dev = pci_get_device_by_addr(addr);
  610. if (!dev) {
  611. __get_cpu_var(no_device)++;
  612. return val;
  613. }
  614. dn = pci_device_to_OF_node(dev);
  615. eeh_dn_check_failure (dn, dev);
  616. pci_dev_put(dev);
  617. return val;
  618. }
  619. EXPORT_SYMBOL(eeh_check_failure);
  620. /* ------------------------------------------------------------- */
  621. /* The code below deals with error recovery */
  622. /** Return negative value if a permanent error, else return
  623. * a number of milliseconds to wait until the PCI slot is
  624. * ready to be used.
  625. */
  626. static int
  627. eeh_slot_availability(struct pci_dn *pdn)
  628. {
  629. int rc;
  630. int rets[3];
  631. rc = read_slot_reset_state(pdn, rets);
  632. if (rc) return rc;
  633. if (rets[1] == 0) return -1; /* EEH is not supported */
  634. if (rets[0] == 0) return 0; /* Oll Korrect */
  635. if (rets[0] == 5) {
  636. if (rets[2] == 0) return -1; /* permanently unavailable */
  637. return rets[2]; /* number of millisecs to wait */
  638. }
  639. return -1;
  640. }
  641. /** rtas_pci_slot_reset raises/lowers the pci #RST line
  642. * state: 1/0 to raise/lower the #RST
  643. *
  644. * Clear the EEH-frozen condition on a slot. This routine
  645. * asserts the PCI #RST line if the 'state' argument is '1',
  646. * and drops the #RST line if 'state is '0'. This routine is
  647. * safe to call in an interrupt context.
  648. *
  649. */
  650. static void
  651. rtas_pci_slot_reset(struct pci_dn *pdn, int state)
  652. {
  653. int rc;
  654. BUG_ON (pdn==NULL);
  655. if (!pdn->phb) {
  656. printk (KERN_WARNING "EEH: in slot reset, device node %s has no phb\n",
  657. pdn->node->full_name);
  658. return;
  659. }
  660. rc = rtas_call(ibm_set_slot_reset,4,1, NULL,
  661. pdn->eeh_config_addr,
  662. BUID_HI(pdn->phb->buid),
  663. BUID_LO(pdn->phb->buid),
  664. state);
  665. if (rc) {
  666. printk (KERN_WARNING "EEH: Unable to reset the failed slot, (%d) #RST=%d dn=%s\n",
  667. rc, state, pdn->node->full_name);
  668. return;
  669. }
  670. }
  671. /** rtas_set_slot_reset -- assert the pci #RST line for 1/4 second
  672. * dn -- device node to be reset.
  673. */
  674. void
  675. rtas_set_slot_reset(struct pci_dn *pdn)
  676. {
  677. int i, rc;
  678. rtas_pci_slot_reset (pdn, 1);
  679. /* The PCI bus requires that the reset be held high for at least
  680. * a 100 milliseconds. We wait a bit longer 'just in case'. */
  681. #define PCI_BUS_RST_HOLD_TIME_MSEC 250
  682. msleep (PCI_BUS_RST_HOLD_TIME_MSEC);
  683. /* We might get hit with another EEH freeze as soon as the
  684. * pci slot reset line is dropped. Make sure we don't miss
  685. * these, and clear the flag now. */
  686. eeh_clear_slot (pdn->node, EEH_MODE_ISOLATED);
  687. rtas_pci_slot_reset (pdn, 0);
  688. /* After a PCI slot has been reset, the PCI Express spec requires
  689. * a 1.5 second idle time for the bus to stabilize, before starting
  690. * up traffic. */
  691. #define PCI_BUS_SETTLE_TIME_MSEC 1800
  692. msleep (PCI_BUS_SETTLE_TIME_MSEC);
  693. /* Now double check with the firmware to make sure the device is
  694. * ready to be used; if not, wait for recovery. */
  695. for (i=0; i<10; i++) {
  696. rc = eeh_slot_availability (pdn);
  697. if (rc <= 0) break;
  698. msleep (rc+100);
  699. }
  700. }
  701. /* ------------------------------------------------------- */
  702. /** Save and restore of PCI BARs
  703. *
  704. * Although firmware will set up BARs during boot, it doesn't
  705. * set up device BAR's after a device reset, although it will,
  706. * if requested, set up bridge configuration. Thus, we need to
  707. * configure the PCI devices ourselves.
  708. */
  709. /**
  710. * __restore_bars - Restore the Base Address Registers
  711. * Loads the PCI configuration space base address registers,
  712. * the expansion ROM base address, the latency timer, and etc.
  713. * from the saved values in the device node.
  714. */
  715. static inline void __restore_bars (struct pci_dn *pdn)
  716. {
  717. int i;
  718. if (NULL==pdn->phb) return;
  719. for (i=4; i<10; i++) {
  720. rtas_write_config(pdn, i*4, 4, pdn->config_space[i]);
  721. }
  722. /* 12 == Expansion ROM Address */
  723. rtas_write_config(pdn, 12*4, 4, pdn->config_space[12]);
  724. #define BYTE_SWAP(OFF) (8*((OFF)/4)+3-(OFF))
  725. #define SAVED_BYTE(OFF) (((u8 *)(pdn->config_space))[BYTE_SWAP(OFF)])
  726. rtas_write_config (pdn, PCI_CACHE_LINE_SIZE, 1,
  727. SAVED_BYTE(PCI_CACHE_LINE_SIZE));
  728. rtas_write_config (pdn, PCI_LATENCY_TIMER, 1,
  729. SAVED_BYTE(PCI_LATENCY_TIMER));
  730. /* max latency, min grant, interrupt pin and line */
  731. rtas_write_config(pdn, 15*4, 4, pdn->config_space[15]);
  732. }
  733. /**
  734. * eeh_restore_bars - restore the PCI config space info
  735. *
  736. * This routine performs a recursive walk to the children
  737. * of this device as well.
  738. */
  739. void eeh_restore_bars(struct pci_dn *pdn)
  740. {
  741. struct device_node *dn;
  742. if (!pdn)
  743. return;
  744. if (! pdn->eeh_is_bridge)
  745. __restore_bars (pdn);
  746. dn = pdn->node->child;
  747. while (dn) {
  748. eeh_restore_bars (PCI_DN(dn));
  749. dn = dn->sibling;
  750. }
  751. }
  752. /**
  753. * eeh_save_bars - save device bars
  754. *
  755. * Save the values of the device bars. Unlike the restore
  756. * routine, this routine is *not* recursive. This is because
  757. * PCI devices are added individuallly; but, for the restore,
  758. * an entire slot is reset at a time.
  759. */
  760. static void eeh_save_bars(struct pci_dev * pdev, struct pci_dn *pdn)
  761. {
  762. int i;
  763. if (!pdev || !pdn )
  764. return;
  765. for (i = 0; i < 16; i++)
  766. pci_read_config_dword(pdev, i * 4, &pdn->config_space[i]);
  767. if (pdev->hdr_type == PCI_HEADER_TYPE_BRIDGE)
  768. pdn->eeh_is_bridge = 1;
  769. }
  770. void
  771. rtas_configure_bridge(struct pci_dn *pdn)
  772. {
  773. int token = rtas_token ("ibm,configure-bridge");
  774. int rc;
  775. if (token == RTAS_UNKNOWN_SERVICE)
  776. return;
  777. rc = rtas_call(token,3,1, NULL,
  778. pdn->eeh_config_addr,
  779. BUID_HI(pdn->phb->buid),
  780. BUID_LO(pdn->phb->buid));
  781. if (rc) {
  782. printk (KERN_WARNING "EEH: Unable to configure device bridge (%d) for %s\n",
  783. rc, pdn->node->full_name);
  784. }
  785. }
  786. /* ------------------------------------------------------------- */
  787. /* The code below deals with enabling EEH for devices during the
  788. * early boot sequence. EEH must be enabled before any PCI probing
  789. * can be done.
  790. */
  791. #define EEH_ENABLE 1
  792. struct eeh_early_enable_info {
  793. unsigned int buid_hi;
  794. unsigned int buid_lo;
  795. };
  796. /* Enable eeh for the given device node. */
  797. static void *early_enable_eeh(struct device_node *dn, void *data)
  798. {
  799. struct eeh_early_enable_info *info = data;
  800. int ret;
  801. char *status = get_property(dn, "status", NULL);
  802. u32 *class_code = (u32 *)get_property(dn, "class-code", NULL);
  803. u32 *vendor_id = (u32 *)get_property(dn, "vendor-id", NULL);
  804. u32 *device_id = (u32 *)get_property(dn, "device-id", NULL);
  805. u32 *regs;
  806. int enable;
  807. struct pci_dn *pdn = PCI_DN(dn);
  808. pdn->eeh_mode = 0;
  809. pdn->eeh_check_count = 0;
  810. pdn->eeh_freeze_count = 0;
  811. if (status && strcmp(status, "ok") != 0)
  812. return NULL; /* ignore devices with bad status */
  813. /* Ignore bad nodes. */
  814. if (!class_code || !vendor_id || !device_id)
  815. return NULL;
  816. /* There is nothing to check on PCI to ISA bridges */
  817. if (dn->type && !strcmp(dn->type, "isa")) {
  818. pdn->eeh_mode |= EEH_MODE_NOCHECK;
  819. return NULL;
  820. }
  821. /*
  822. * Now decide if we are going to "Disable" EEH checking
  823. * for this device. We still run with the EEH hardware active,
  824. * but we won't be checking for ff's. This means a driver
  825. * could return bad data (very bad!), an interrupt handler could
  826. * hang waiting on status bits that won't change, etc.
  827. * But there are a few cases like display devices that make sense.
  828. */
  829. enable = 1; /* i.e. we will do checking */
  830. #if 0
  831. if ((*class_code >> 16) == PCI_BASE_CLASS_DISPLAY)
  832. enable = 0;
  833. #endif
  834. if (!enable)
  835. pdn->eeh_mode |= EEH_MODE_NOCHECK;
  836. /* Ok... see if this device supports EEH. Some do, some don't,
  837. * and the only way to find out is to check each and every one. */
  838. regs = (u32 *)get_property(dn, "reg", NULL);
  839. if (regs) {
  840. /* First register entry is addr (00BBSS00) */
  841. /* Try to enable eeh */
  842. ret = rtas_call(ibm_set_eeh_option, 4, 1, NULL,
  843. regs[0], info->buid_hi, info->buid_lo,
  844. EEH_ENABLE);
  845. if (ret == 0) {
  846. eeh_subsystem_enabled = 1;
  847. pdn->eeh_mode |= EEH_MODE_SUPPORTED;
  848. pdn->eeh_config_addr = regs[0];
  849. #ifdef DEBUG
  850. printk(KERN_DEBUG "EEH: %s: eeh enabled\n", dn->full_name);
  851. #endif
  852. } else {
  853. /* This device doesn't support EEH, but it may have an
  854. * EEH parent, in which case we mark it as supported. */
  855. if (dn->parent && PCI_DN(dn->parent)
  856. && (PCI_DN(dn->parent)->eeh_mode & EEH_MODE_SUPPORTED)) {
  857. /* Parent supports EEH. */
  858. pdn->eeh_mode |= EEH_MODE_SUPPORTED;
  859. pdn->eeh_config_addr = PCI_DN(dn->parent)->eeh_config_addr;
  860. return NULL;
  861. }
  862. }
  863. } else {
  864. printk(KERN_WARNING "EEH: %s: unable to get reg property.\n",
  865. dn->full_name);
  866. }
  867. return NULL;
  868. }
  869. /*
  870. * Initialize EEH by trying to enable it for all of the adapters in the system.
  871. * As a side effect we can determine here if eeh is supported at all.
  872. * Note that we leave EEH on so failed config cycles won't cause a machine
  873. * check. If a user turns off EEH for a particular adapter they are really
  874. * telling Linux to ignore errors. Some hardware (e.g. POWER5) won't
  875. * grant access to a slot if EEH isn't enabled, and so we always enable
  876. * EEH for all slots/all devices.
  877. *
  878. * The eeh-force-off option disables EEH checking globally, for all slots.
  879. * Even if force-off is set, the EEH hardware is still enabled, so that
  880. * newer systems can boot.
  881. */
  882. void __init eeh_init(void)
  883. {
  884. struct device_node *phb, *np;
  885. struct eeh_early_enable_info info;
  886. spin_lock_init(&confirm_error_lock);
  887. spin_lock_init(&slot_errbuf_lock);
  888. np = of_find_node_by_path("/rtas");
  889. if (np == NULL)
  890. return;
  891. ibm_set_eeh_option = rtas_token("ibm,set-eeh-option");
  892. ibm_set_slot_reset = rtas_token("ibm,set-slot-reset");
  893. ibm_read_slot_reset_state2 = rtas_token("ibm,read-slot-reset-state2");
  894. ibm_read_slot_reset_state = rtas_token("ibm,read-slot-reset-state");
  895. ibm_slot_error_detail = rtas_token("ibm,slot-error-detail");
  896. if (ibm_set_eeh_option == RTAS_UNKNOWN_SERVICE)
  897. return;
  898. eeh_error_buf_size = rtas_token("rtas-error-log-max");
  899. if (eeh_error_buf_size == RTAS_UNKNOWN_SERVICE) {
  900. eeh_error_buf_size = 1024;
  901. }
  902. if (eeh_error_buf_size > RTAS_ERROR_LOG_MAX) {
  903. printk(KERN_WARNING "EEH: rtas-error-log-max is bigger than allocated "
  904. "buffer ! (%d vs %d)", eeh_error_buf_size, RTAS_ERROR_LOG_MAX);
  905. eeh_error_buf_size = RTAS_ERROR_LOG_MAX;
  906. }
  907. /* Enable EEH for all adapters. Note that eeh requires buid's */
  908. for (phb = of_find_node_by_name(NULL, "pci"); phb;
  909. phb = of_find_node_by_name(phb, "pci")) {
  910. unsigned long buid;
  911. buid = get_phb_buid(phb);
  912. if (buid == 0 || PCI_DN(phb) == NULL)
  913. continue;
  914. info.buid_lo = BUID_LO(buid);
  915. info.buid_hi = BUID_HI(buid);
  916. traverse_pci_devices(phb, early_enable_eeh, &info);
  917. }
  918. if (eeh_subsystem_enabled)
  919. printk(KERN_INFO "EEH: PCI Enhanced I/O Error Handling Enabled\n");
  920. else
  921. printk(KERN_WARNING "EEH: No capable adapters found\n");
  922. }
  923. /**
  924. * eeh_add_device_early - enable EEH for the indicated device_node
  925. * @dn: device node for which to set up EEH
  926. *
  927. * This routine must be used to perform EEH initialization for PCI
  928. * devices that were added after system boot (e.g. hotplug, dlpar).
  929. * This routine must be called before any i/o is performed to the
  930. * adapter (inluding any config-space i/o).
  931. * Whether this actually enables EEH or not for this device depends
  932. * on the CEC architecture, type of the device, on earlier boot
  933. * command-line arguments & etc.
  934. */
  935. void eeh_add_device_early(struct device_node *dn)
  936. {
  937. struct pci_controller *phb;
  938. struct eeh_early_enable_info info;
  939. if (!dn || !PCI_DN(dn))
  940. return;
  941. phb = PCI_DN(dn)->phb;
  942. if (NULL == phb || 0 == phb->buid) {
  943. printk(KERN_WARNING "EEH: Expected buid but found none for %s\n",
  944. dn->full_name);
  945. dump_stack();
  946. return;
  947. }
  948. info.buid_hi = BUID_HI(phb->buid);
  949. info.buid_lo = BUID_LO(phb->buid);
  950. early_enable_eeh(dn, &info);
  951. }
  952. EXPORT_SYMBOL_GPL(eeh_add_device_early);
  953. void eeh_add_device_tree_early(struct device_node *dn)
  954. {
  955. struct device_node *sib;
  956. for (sib = dn->child; sib; sib = sib->sibling)
  957. eeh_add_device_tree_early(sib);
  958. eeh_add_device_early(dn);
  959. }
  960. EXPORT_SYMBOL_GPL(eeh_add_device_tree_early);
  961. /**
  962. * eeh_add_device_late - perform EEH initialization for the indicated pci device
  963. * @dev: pci device for which to set up EEH
  964. *
  965. * This routine must be used to complete EEH initialization for PCI
  966. * devices that were added after system boot (e.g. hotplug, dlpar).
  967. */
  968. void eeh_add_device_late(struct pci_dev *dev)
  969. {
  970. struct device_node *dn;
  971. struct pci_dn *pdn;
  972. if (!dev || !eeh_subsystem_enabled)
  973. return;
  974. #ifdef DEBUG
  975. printk(KERN_DEBUG "EEH: adding device %s\n", pci_name(dev));
  976. #endif
  977. pci_dev_get (dev);
  978. dn = pci_device_to_OF_node(dev);
  979. pdn = PCI_DN(dn);
  980. pdn->pcidev = dev;
  981. pci_addr_cache_insert_device (dev);
  982. eeh_save_bars(dev, pdn);
  983. }
  984. EXPORT_SYMBOL_GPL(eeh_add_device_late);
  985. /**
  986. * eeh_remove_device - undo EEH setup for the indicated pci device
  987. * @dev: pci device to be removed
  988. *
  989. * This routine should be when a device is removed from a running
  990. * system (e.g. by hotplug or dlpar).
  991. */
  992. void eeh_remove_device(struct pci_dev *dev)
  993. {
  994. struct device_node *dn;
  995. if (!dev || !eeh_subsystem_enabled)
  996. return;
  997. /* Unregister the device with the EEH/PCI address search system */
  998. #ifdef DEBUG
  999. printk(KERN_DEBUG "EEH: remove device %s\n", pci_name(dev));
  1000. #endif
  1001. pci_addr_cache_remove_device(dev);
  1002. dn = pci_device_to_OF_node(dev);
  1003. PCI_DN(dn)->pcidev = NULL;
  1004. pci_dev_put (dev);
  1005. }
  1006. EXPORT_SYMBOL_GPL(eeh_remove_device);
  1007. void eeh_remove_bus_device(struct pci_dev *dev)
  1008. {
  1009. eeh_remove_device(dev);
  1010. if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
  1011. struct pci_bus *bus = dev->subordinate;
  1012. struct list_head *ln;
  1013. if (!bus)
  1014. return;
  1015. for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {
  1016. struct pci_dev *pdev = pci_dev_b(ln);
  1017. if (pdev)
  1018. eeh_remove_bus_device(pdev);
  1019. }
  1020. }
  1021. }
  1022. EXPORT_SYMBOL_GPL(eeh_remove_bus_device);
  1023. static int proc_eeh_show(struct seq_file *m, void *v)
  1024. {
  1025. unsigned int cpu;
  1026. unsigned long ffs = 0, positives = 0, failures = 0;
  1027. unsigned long resets = 0;
  1028. unsigned long no_dev = 0, no_dn = 0, no_cfg = 0, no_check = 0;
  1029. for_each_cpu(cpu) {
  1030. ffs += per_cpu(total_mmio_ffs, cpu);
  1031. positives += per_cpu(false_positives, cpu);
  1032. failures += per_cpu(ignored_failures, cpu);
  1033. resets += per_cpu(slot_resets, cpu);
  1034. no_dev += per_cpu(no_device, cpu);
  1035. no_dn += per_cpu(no_dn, cpu);
  1036. no_cfg += per_cpu(no_cfg_addr, cpu);
  1037. no_check += per_cpu(ignored_check, cpu);
  1038. }
  1039. if (0 == eeh_subsystem_enabled) {
  1040. seq_printf(m, "EEH Subsystem is globally disabled\n");
  1041. seq_printf(m, "eeh_total_mmio_ffs=%ld\n", ffs);
  1042. } else {
  1043. seq_printf(m, "EEH Subsystem is enabled\n");
  1044. seq_printf(m,
  1045. "no device=%ld\n"
  1046. "no device node=%ld\n"
  1047. "no config address=%ld\n"
  1048. "check not wanted=%ld\n"
  1049. "eeh_total_mmio_ffs=%ld\n"
  1050. "eeh_false_positives=%ld\n"
  1051. "eeh_ignored_failures=%ld\n"
  1052. "eeh_slot_resets=%ld\n",
  1053. no_dev, no_dn, no_cfg, no_check,
  1054. ffs, positives, failures, resets);
  1055. }
  1056. return 0;
  1057. }
  1058. static int proc_eeh_open(struct inode *inode, struct file *file)
  1059. {
  1060. return single_open(file, proc_eeh_show, NULL);
  1061. }
  1062. static struct file_operations proc_eeh_operations = {
  1063. .open = proc_eeh_open,
  1064. .read = seq_read,
  1065. .llseek = seq_lseek,
  1066. .release = single_release,
  1067. };
  1068. static int __init eeh_init_proc(void)
  1069. {
  1070. struct proc_dir_entry *e;
  1071. if (platform_is_pseries()) {
  1072. e = create_proc_entry("ppc64/eeh", 0, NULL);
  1073. if (e)
  1074. e->proc_fops = &proc_eeh_operations;
  1075. }
  1076. return 0;
  1077. }
  1078. __initcall(eeh_init_proc);