eeh.c 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239
  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. if (dn->child)
  427. __eeh_mark_slot (dn->child, mode_flag);
  428. }
  429. dn = dn->sibling;
  430. }
  431. }
  432. void eeh_mark_slot (struct device_node *dn, int mode_flag)
  433. {
  434. dn = find_device_pe (dn);
  435. PCI_DN(dn)->eeh_mode |= mode_flag;
  436. __eeh_mark_slot (dn->child, mode_flag);
  437. }
  438. static void __eeh_clear_slot (struct device_node *dn, int mode_flag)
  439. {
  440. while (dn) {
  441. if (PCI_DN(dn)) {
  442. PCI_DN(dn)->eeh_mode &= ~mode_flag;
  443. PCI_DN(dn)->eeh_check_count = 0;
  444. if (dn->child)
  445. __eeh_clear_slot (dn->child, mode_flag);
  446. }
  447. dn = dn->sibling;
  448. }
  449. }
  450. void eeh_clear_slot (struct device_node *dn, int mode_flag)
  451. {
  452. unsigned long flags;
  453. spin_lock_irqsave(&confirm_error_lock, flags);
  454. dn = find_device_pe (dn);
  455. PCI_DN(dn)->eeh_mode &= ~mode_flag;
  456. PCI_DN(dn)->eeh_check_count = 0;
  457. __eeh_clear_slot (dn->child, mode_flag);
  458. spin_unlock_irqrestore(&confirm_error_lock, flags);
  459. }
  460. /**
  461. * eeh_dn_check_failure - check if all 1's data is due to EEH slot freeze
  462. * @dn device node
  463. * @dev pci device, if known
  464. *
  465. * Check for an EEH failure for the given device node. Call this
  466. * routine if the result of a read was all 0xff's and you want to
  467. * find out if this is due to an EEH slot freeze. This routine
  468. * will query firmware for the EEH status.
  469. *
  470. * Returns 0 if there has not been an EEH error; otherwise returns
  471. * a non-zero value and queues up a slot isolation event notification.
  472. *
  473. * It is safe to call this routine in an interrupt context.
  474. */
  475. int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
  476. {
  477. int ret;
  478. int rets[3];
  479. unsigned long flags;
  480. struct pci_dn *pdn;
  481. int rc = 0;
  482. __get_cpu_var(total_mmio_ffs)++;
  483. if (!eeh_subsystem_enabled)
  484. return 0;
  485. if (!dn) {
  486. __get_cpu_var(no_dn)++;
  487. return 0;
  488. }
  489. pdn = PCI_DN(dn);
  490. /* Access to IO BARs might get this far and still not want checking. */
  491. if (!(pdn->eeh_mode & EEH_MODE_SUPPORTED) ||
  492. pdn->eeh_mode & EEH_MODE_NOCHECK) {
  493. __get_cpu_var(ignored_check)++;
  494. #ifdef DEBUG
  495. printk ("EEH:ignored check (%x) for %s %s\n",
  496. pdn->eeh_mode, pci_name (dev), dn->full_name);
  497. #endif
  498. return 0;
  499. }
  500. if (!pdn->eeh_config_addr) {
  501. __get_cpu_var(no_cfg_addr)++;
  502. return 0;
  503. }
  504. /* If we already have a pending isolation event for this
  505. * slot, we know it's bad already, we don't need to check.
  506. * Do this checking under a lock; as multiple PCI devices
  507. * in one slot might report errors simultaneously, and we
  508. * only want one error recovery routine running.
  509. */
  510. spin_lock_irqsave(&confirm_error_lock, flags);
  511. rc = 1;
  512. if (pdn->eeh_mode & EEH_MODE_ISOLATED) {
  513. pdn->eeh_check_count ++;
  514. if (pdn->eeh_check_count >= EEH_MAX_FAILS) {
  515. printk (KERN_ERR "EEH: Device driver ignored %d bad reads, panicing\n",
  516. pdn->eeh_check_count);
  517. dump_stack();
  518. /* re-read the slot reset state */
  519. if (read_slot_reset_state(pdn, rets) != 0)
  520. rets[0] = -1; /* reset state unknown */
  521. /* If we are here, then we hit an infinite loop. Stop. */
  522. panic("EEH: MMIO halt (%d) on device:%s\n", rets[0], pci_name(dev));
  523. }
  524. goto dn_unlock;
  525. }
  526. /*
  527. * Now test for an EEH failure. This is VERY expensive.
  528. * Note that the eeh_config_addr may be a parent device
  529. * in the case of a device behind a bridge, or it may be
  530. * function zero of a multi-function device.
  531. * In any case they must share a common PHB.
  532. */
  533. ret = read_slot_reset_state(pdn, rets);
  534. /* If the call to firmware failed, punt */
  535. if (ret != 0) {
  536. printk(KERN_WARNING "EEH: read_slot_reset_state() failed; rc=%d dn=%s\n",
  537. ret, dn->full_name);
  538. __get_cpu_var(false_positives)++;
  539. rc = 0;
  540. goto dn_unlock;
  541. }
  542. /* If EEH is not supported on this device, punt. */
  543. if (rets[1] != 1) {
  544. printk(KERN_WARNING "EEH: event on unsupported device, rc=%d dn=%s\n",
  545. ret, dn->full_name);
  546. __get_cpu_var(false_positives)++;
  547. rc = 0;
  548. goto dn_unlock;
  549. }
  550. /* If not the kind of error we know about, punt. */
  551. if (rets[0] != 2 && rets[0] != 4 && rets[0] != 5) {
  552. __get_cpu_var(false_positives)++;
  553. rc = 0;
  554. goto dn_unlock;
  555. }
  556. /* Note that config-io to empty slots may fail;
  557. * we recognize empty because they don't have children. */
  558. if ((rets[0] == 5) && (dn->child == NULL)) {
  559. __get_cpu_var(false_positives)++;
  560. rc = 0;
  561. goto dn_unlock;
  562. }
  563. __get_cpu_var(slot_resets)++;
  564. /* Avoid repeated reports of this failure, including problems
  565. * with other functions on this device, and functions under
  566. * bridges. */
  567. eeh_mark_slot (dn, EEH_MODE_ISOLATED);
  568. spin_unlock_irqrestore(&confirm_error_lock, flags);
  569. eeh_send_failure_event (dn, dev, rets[0], rets[2]);
  570. /* Most EEH events are due to device driver bugs. Having
  571. * a stack trace will help the device-driver authors figure
  572. * out what happened. So print that out. */
  573. if (rets[0] != 5) dump_stack();
  574. return 1;
  575. dn_unlock:
  576. spin_unlock_irqrestore(&confirm_error_lock, flags);
  577. return rc;
  578. }
  579. EXPORT_SYMBOL_GPL(eeh_dn_check_failure);
  580. /**
  581. * eeh_check_failure - check if all 1's data is due to EEH slot freeze
  582. * @token i/o token, should be address in the form 0xA....
  583. * @val value, should be all 1's (XXX why do we need this arg??)
  584. *
  585. * Check for an EEH failure at the given token address. Call this
  586. * routine if the result of a read was all 0xff's and you want to
  587. * find out if this is due to an EEH slot freeze event. This routine
  588. * will query firmware for the EEH status.
  589. *
  590. * Note this routine is safe to call in an interrupt context.
  591. */
  592. unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned long val)
  593. {
  594. unsigned long addr;
  595. struct pci_dev *dev;
  596. struct device_node *dn;
  597. /* Finding the phys addr + pci device; this is pretty quick. */
  598. addr = eeh_token_to_phys((unsigned long __force) token);
  599. dev = pci_get_device_by_addr(addr);
  600. if (!dev) {
  601. __get_cpu_var(no_device)++;
  602. return val;
  603. }
  604. dn = pci_device_to_OF_node(dev);
  605. eeh_dn_check_failure (dn, dev);
  606. pci_dev_put(dev);
  607. return val;
  608. }
  609. EXPORT_SYMBOL(eeh_check_failure);
  610. /* ------------------------------------------------------------- */
  611. /* The code below deals with error recovery */
  612. /** Return negative value if a permanent error, else return
  613. * a number of milliseconds to wait until the PCI slot is
  614. * ready to be used.
  615. */
  616. static int
  617. eeh_slot_availability(struct pci_dn *pdn)
  618. {
  619. int rc;
  620. int rets[3];
  621. rc = read_slot_reset_state(pdn, rets);
  622. if (rc) return rc;
  623. if (rets[1] == 0) return -1; /* EEH is not supported */
  624. if (rets[0] == 0) return 0; /* Oll Korrect */
  625. if (rets[0] == 5) {
  626. if (rets[2] == 0) return -1; /* permanently unavailable */
  627. return rets[2]; /* number of millisecs to wait */
  628. }
  629. return -1;
  630. }
  631. /** rtas_pci_slot_reset raises/lowers the pci #RST line
  632. * state: 1/0 to raise/lower the #RST
  633. *
  634. * Clear the EEH-frozen condition on a slot. This routine
  635. * asserts the PCI #RST line if the 'state' argument is '1',
  636. * and drops the #RST line if 'state is '0'. This routine is
  637. * safe to call in an interrupt context.
  638. *
  639. */
  640. static void
  641. rtas_pci_slot_reset(struct pci_dn *pdn, int state)
  642. {
  643. int rc;
  644. BUG_ON (pdn==NULL);
  645. if (!pdn->phb) {
  646. printk (KERN_WARNING "EEH: in slot reset, device node %s has no phb\n",
  647. pdn->node->full_name);
  648. return;
  649. }
  650. rc = rtas_call(ibm_set_slot_reset,4,1, NULL,
  651. pdn->eeh_config_addr,
  652. BUID_HI(pdn->phb->buid),
  653. BUID_LO(pdn->phb->buid),
  654. state);
  655. if (rc) {
  656. printk (KERN_WARNING "EEH: Unable to reset the failed slot, (%d) #RST=%d dn=%s\n",
  657. rc, state, pdn->node->full_name);
  658. return;
  659. }
  660. }
  661. /** rtas_set_slot_reset -- assert the pci #RST line for 1/4 second
  662. * dn -- device node to be reset.
  663. */
  664. void
  665. rtas_set_slot_reset(struct pci_dn *pdn)
  666. {
  667. int i, rc;
  668. rtas_pci_slot_reset (pdn, 1);
  669. /* The PCI bus requires that the reset be held high for at least
  670. * a 100 milliseconds. We wait a bit longer 'just in case'. */
  671. #define PCI_BUS_RST_HOLD_TIME_MSEC 250
  672. msleep (PCI_BUS_RST_HOLD_TIME_MSEC);
  673. /* We might get hit with another EEH freeze as soon as the
  674. * pci slot reset line is dropped. Make sure we don't miss
  675. * these, and clear the flag now. */
  676. eeh_clear_slot (pdn->node, EEH_MODE_ISOLATED);
  677. rtas_pci_slot_reset (pdn, 0);
  678. /* After a PCI slot has been reset, the PCI Express spec requires
  679. * a 1.5 second idle time for the bus to stabilize, before starting
  680. * up traffic. */
  681. #define PCI_BUS_SETTLE_TIME_MSEC 1800
  682. msleep (PCI_BUS_SETTLE_TIME_MSEC);
  683. /* Now double check with the firmware to make sure the device is
  684. * ready to be used; if not, wait for recovery. */
  685. for (i=0; i<10; i++) {
  686. rc = eeh_slot_availability (pdn);
  687. if (rc <= 0) break;
  688. msleep (rc+100);
  689. }
  690. }
  691. /* ------------------------------------------------------- */
  692. /** Save and restore of PCI BARs
  693. *
  694. * Although firmware will set up BARs during boot, it doesn't
  695. * set up device BAR's after a device reset, although it will,
  696. * if requested, set up bridge configuration. Thus, we need to
  697. * configure the PCI devices ourselves.
  698. */
  699. /**
  700. * __restore_bars - Restore the Base Address Registers
  701. * Loads the PCI configuration space base address registers,
  702. * the expansion ROM base address, the latency timer, and etc.
  703. * from the saved values in the device node.
  704. */
  705. static inline void __restore_bars (struct pci_dn *pdn)
  706. {
  707. int i;
  708. if (NULL==pdn->phb) return;
  709. for (i=4; i<10; i++) {
  710. rtas_write_config(pdn, i*4, 4, pdn->config_space[i]);
  711. }
  712. /* 12 == Expansion ROM Address */
  713. rtas_write_config(pdn, 12*4, 4, pdn->config_space[12]);
  714. #define BYTE_SWAP(OFF) (8*((OFF)/4)+3-(OFF))
  715. #define SAVED_BYTE(OFF) (((u8 *)(pdn->config_space))[BYTE_SWAP(OFF)])
  716. rtas_write_config (pdn, PCI_CACHE_LINE_SIZE, 1,
  717. SAVED_BYTE(PCI_CACHE_LINE_SIZE));
  718. rtas_write_config (pdn, PCI_LATENCY_TIMER, 1,
  719. SAVED_BYTE(PCI_LATENCY_TIMER));
  720. /* max latency, min grant, interrupt pin and line */
  721. rtas_write_config(pdn, 15*4, 4, pdn->config_space[15]);
  722. }
  723. /**
  724. * eeh_restore_bars - restore the PCI config space info
  725. *
  726. * This routine performs a recursive walk to the children
  727. * of this device as well.
  728. */
  729. void eeh_restore_bars(struct pci_dn *pdn)
  730. {
  731. struct device_node *dn;
  732. if (!pdn)
  733. return;
  734. if (! pdn->eeh_is_bridge)
  735. __restore_bars (pdn);
  736. dn = pdn->node->child;
  737. while (dn) {
  738. eeh_restore_bars (PCI_DN(dn));
  739. dn = dn->sibling;
  740. }
  741. }
  742. /**
  743. * eeh_save_bars - save device bars
  744. *
  745. * Save the values of the device bars. Unlike the restore
  746. * routine, this routine is *not* recursive. This is because
  747. * PCI devices are added individuallly; but, for the restore,
  748. * an entire slot is reset at a time.
  749. */
  750. static void eeh_save_bars(struct pci_dev * pdev, struct pci_dn *pdn)
  751. {
  752. int i;
  753. if (!pdev || !pdn )
  754. return;
  755. for (i = 0; i < 16; i++)
  756. pci_read_config_dword(pdev, i * 4, &pdn->config_space[i]);
  757. if (pdev->hdr_type == PCI_HEADER_TYPE_BRIDGE)
  758. pdn->eeh_is_bridge = 1;
  759. }
  760. void
  761. rtas_configure_bridge(struct pci_dn *pdn)
  762. {
  763. int token = rtas_token ("ibm,configure-bridge");
  764. int rc;
  765. if (token == RTAS_UNKNOWN_SERVICE)
  766. return;
  767. rc = rtas_call(token,3,1, NULL,
  768. pdn->eeh_config_addr,
  769. BUID_HI(pdn->phb->buid),
  770. BUID_LO(pdn->phb->buid));
  771. if (rc) {
  772. printk (KERN_WARNING "EEH: Unable to configure device bridge (%d) for %s\n",
  773. rc, pdn->node->full_name);
  774. }
  775. }
  776. /* ------------------------------------------------------------- */
  777. /* The code below deals with enabling EEH for devices during the
  778. * early boot sequence. EEH must be enabled before any PCI probing
  779. * can be done.
  780. */
  781. #define EEH_ENABLE 1
  782. struct eeh_early_enable_info {
  783. unsigned int buid_hi;
  784. unsigned int buid_lo;
  785. };
  786. /* Enable eeh for the given device node. */
  787. static void *early_enable_eeh(struct device_node *dn, void *data)
  788. {
  789. struct eeh_early_enable_info *info = data;
  790. int ret;
  791. char *status = get_property(dn, "status", NULL);
  792. u32 *class_code = (u32 *)get_property(dn, "class-code", NULL);
  793. u32 *vendor_id = (u32 *)get_property(dn, "vendor-id", NULL);
  794. u32 *device_id = (u32 *)get_property(dn, "device-id", NULL);
  795. u32 *regs;
  796. int enable;
  797. struct pci_dn *pdn = PCI_DN(dn);
  798. pdn->eeh_mode = 0;
  799. pdn->eeh_check_count = 0;
  800. pdn->eeh_freeze_count = 0;
  801. if (status && strcmp(status, "ok") != 0)
  802. return NULL; /* ignore devices with bad status */
  803. /* Ignore bad nodes. */
  804. if (!class_code || !vendor_id || !device_id)
  805. return NULL;
  806. /* There is nothing to check on PCI to ISA bridges */
  807. if (dn->type && !strcmp(dn->type, "isa")) {
  808. pdn->eeh_mode |= EEH_MODE_NOCHECK;
  809. return NULL;
  810. }
  811. /*
  812. * Now decide if we are going to "Disable" EEH checking
  813. * for this device. We still run with the EEH hardware active,
  814. * but we won't be checking for ff's. This means a driver
  815. * could return bad data (very bad!), an interrupt handler could
  816. * hang waiting on status bits that won't change, etc.
  817. * But there are a few cases like display devices that make sense.
  818. */
  819. enable = 1; /* i.e. we will do checking */
  820. if ((*class_code >> 16) == PCI_BASE_CLASS_DISPLAY)
  821. enable = 0;
  822. if (!enable)
  823. pdn->eeh_mode |= EEH_MODE_NOCHECK;
  824. /* Ok... see if this device supports EEH. Some do, some don't,
  825. * and the only way to find out is to check each and every one. */
  826. regs = (u32 *)get_property(dn, "reg", NULL);
  827. if (regs) {
  828. /* First register entry is addr (00BBSS00) */
  829. /* Try to enable eeh */
  830. ret = rtas_call(ibm_set_eeh_option, 4, 1, NULL,
  831. regs[0], info->buid_hi, info->buid_lo,
  832. EEH_ENABLE);
  833. if (ret == 0) {
  834. eeh_subsystem_enabled = 1;
  835. pdn->eeh_mode |= EEH_MODE_SUPPORTED;
  836. pdn->eeh_config_addr = regs[0];
  837. #ifdef DEBUG
  838. printk(KERN_DEBUG "EEH: %s: eeh enabled\n", dn->full_name);
  839. #endif
  840. } else {
  841. /* This device doesn't support EEH, but it may have an
  842. * EEH parent, in which case we mark it as supported. */
  843. if (dn->parent && PCI_DN(dn->parent)
  844. && (PCI_DN(dn->parent)->eeh_mode & EEH_MODE_SUPPORTED)) {
  845. /* Parent supports EEH. */
  846. pdn->eeh_mode |= EEH_MODE_SUPPORTED;
  847. pdn->eeh_config_addr = PCI_DN(dn->parent)->eeh_config_addr;
  848. return NULL;
  849. }
  850. }
  851. } else {
  852. printk(KERN_WARNING "EEH: %s: unable to get reg property.\n",
  853. dn->full_name);
  854. }
  855. return NULL;
  856. }
  857. /*
  858. * Initialize EEH by trying to enable it for all of the adapters in the system.
  859. * As a side effect we can determine here if eeh is supported at all.
  860. * Note that we leave EEH on so failed config cycles won't cause a machine
  861. * check. If a user turns off EEH for a particular adapter they are really
  862. * telling Linux to ignore errors. Some hardware (e.g. POWER5) won't
  863. * grant access to a slot if EEH isn't enabled, and so we always enable
  864. * EEH for all slots/all devices.
  865. *
  866. * The eeh-force-off option disables EEH checking globally, for all slots.
  867. * Even if force-off is set, the EEH hardware is still enabled, so that
  868. * newer systems can boot.
  869. */
  870. void __init eeh_init(void)
  871. {
  872. struct device_node *phb, *np;
  873. struct eeh_early_enable_info info;
  874. spin_lock_init(&confirm_error_lock);
  875. spin_lock_init(&slot_errbuf_lock);
  876. np = of_find_node_by_path("/rtas");
  877. if (np == NULL)
  878. return;
  879. ibm_set_eeh_option = rtas_token("ibm,set-eeh-option");
  880. ibm_set_slot_reset = rtas_token("ibm,set-slot-reset");
  881. ibm_read_slot_reset_state2 = rtas_token("ibm,read-slot-reset-state2");
  882. ibm_read_slot_reset_state = rtas_token("ibm,read-slot-reset-state");
  883. ibm_slot_error_detail = rtas_token("ibm,slot-error-detail");
  884. if (ibm_set_eeh_option == RTAS_UNKNOWN_SERVICE)
  885. return;
  886. eeh_error_buf_size = rtas_token("rtas-error-log-max");
  887. if (eeh_error_buf_size == RTAS_UNKNOWN_SERVICE) {
  888. eeh_error_buf_size = 1024;
  889. }
  890. if (eeh_error_buf_size > RTAS_ERROR_LOG_MAX) {
  891. printk(KERN_WARNING "EEH: rtas-error-log-max is bigger than allocated "
  892. "buffer ! (%d vs %d)", eeh_error_buf_size, RTAS_ERROR_LOG_MAX);
  893. eeh_error_buf_size = RTAS_ERROR_LOG_MAX;
  894. }
  895. /* Enable EEH for all adapters. Note that eeh requires buid's */
  896. for (phb = of_find_node_by_name(NULL, "pci"); phb;
  897. phb = of_find_node_by_name(phb, "pci")) {
  898. unsigned long buid;
  899. buid = get_phb_buid(phb);
  900. if (buid == 0 || PCI_DN(phb) == NULL)
  901. continue;
  902. info.buid_lo = BUID_LO(buid);
  903. info.buid_hi = BUID_HI(buid);
  904. traverse_pci_devices(phb, early_enable_eeh, &info);
  905. }
  906. if (eeh_subsystem_enabled)
  907. printk(KERN_INFO "EEH: PCI Enhanced I/O Error Handling Enabled\n");
  908. else
  909. printk(KERN_WARNING "EEH: No capable adapters found\n");
  910. }
  911. /**
  912. * eeh_add_device_early - enable EEH for the indicated device_node
  913. * @dn: device node for which to set up EEH
  914. *
  915. * This routine must be used to perform EEH initialization for PCI
  916. * devices that were added after system boot (e.g. hotplug, dlpar).
  917. * This routine must be called before any i/o is performed to the
  918. * adapter (inluding any config-space i/o).
  919. * Whether this actually enables EEH or not for this device depends
  920. * on the CEC architecture, type of the device, on earlier boot
  921. * command-line arguments & etc.
  922. */
  923. void eeh_add_device_early(struct device_node *dn)
  924. {
  925. struct pci_controller *phb;
  926. struct eeh_early_enable_info info;
  927. if (!dn || !PCI_DN(dn))
  928. return;
  929. phb = PCI_DN(dn)->phb;
  930. if (NULL == phb || 0 == phb->buid) {
  931. printk(KERN_WARNING "EEH: Expected buid but found none for %s\n",
  932. dn->full_name);
  933. dump_stack();
  934. return;
  935. }
  936. info.buid_hi = BUID_HI(phb->buid);
  937. info.buid_lo = BUID_LO(phb->buid);
  938. early_enable_eeh(dn, &info);
  939. }
  940. EXPORT_SYMBOL_GPL(eeh_add_device_early);
  941. void eeh_add_device_tree_early(struct device_node *dn)
  942. {
  943. struct device_node *sib;
  944. for (sib = dn->child; sib; sib = sib->sibling)
  945. eeh_add_device_tree_early(sib);
  946. eeh_add_device_early(dn);
  947. }
  948. EXPORT_SYMBOL_GPL(eeh_add_device_tree_early);
  949. /**
  950. * eeh_add_device_late - perform EEH initialization for the indicated pci device
  951. * @dev: pci device for which to set up EEH
  952. *
  953. * This routine must be used to complete EEH initialization for PCI
  954. * devices that were added after system boot (e.g. hotplug, dlpar).
  955. */
  956. void eeh_add_device_late(struct pci_dev *dev)
  957. {
  958. struct device_node *dn;
  959. struct pci_dn *pdn;
  960. if (!dev || !eeh_subsystem_enabled)
  961. return;
  962. #ifdef DEBUG
  963. printk(KERN_DEBUG "EEH: adding device %s\n", pci_name(dev));
  964. #endif
  965. pci_dev_get (dev);
  966. dn = pci_device_to_OF_node(dev);
  967. pdn = PCI_DN(dn);
  968. pdn->pcidev = dev;
  969. pci_addr_cache_insert_device (dev);
  970. eeh_save_bars(dev, pdn);
  971. }
  972. EXPORT_SYMBOL_GPL(eeh_add_device_late);
  973. /**
  974. * eeh_remove_device - undo EEH setup for the indicated pci device
  975. * @dev: pci device to be removed
  976. *
  977. * This routine should be when a device is removed from a running
  978. * system (e.g. by hotplug or dlpar).
  979. */
  980. void eeh_remove_device(struct pci_dev *dev)
  981. {
  982. struct device_node *dn;
  983. if (!dev || !eeh_subsystem_enabled)
  984. return;
  985. /* Unregister the device with the EEH/PCI address search system */
  986. #ifdef DEBUG
  987. printk(KERN_DEBUG "EEH: remove device %s\n", pci_name(dev));
  988. #endif
  989. pci_addr_cache_remove_device(dev);
  990. dn = pci_device_to_OF_node(dev);
  991. PCI_DN(dn)->pcidev = NULL;
  992. pci_dev_put (dev);
  993. }
  994. EXPORT_SYMBOL_GPL(eeh_remove_device);
  995. void eeh_remove_bus_device(struct pci_dev *dev)
  996. {
  997. eeh_remove_device(dev);
  998. if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
  999. struct pci_bus *bus = dev->subordinate;
  1000. struct list_head *ln;
  1001. if (!bus)
  1002. return;
  1003. for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {
  1004. struct pci_dev *pdev = pci_dev_b(ln);
  1005. if (pdev)
  1006. eeh_remove_bus_device(pdev);
  1007. }
  1008. }
  1009. }
  1010. EXPORT_SYMBOL_GPL(eeh_remove_bus_device);
  1011. static int proc_eeh_show(struct seq_file *m, void *v)
  1012. {
  1013. unsigned int cpu;
  1014. unsigned long ffs = 0, positives = 0, failures = 0;
  1015. unsigned long resets = 0;
  1016. unsigned long no_dev = 0, no_dn = 0, no_cfg = 0, no_check = 0;
  1017. for_each_cpu(cpu) {
  1018. ffs += per_cpu(total_mmio_ffs, cpu);
  1019. positives += per_cpu(false_positives, cpu);
  1020. failures += per_cpu(ignored_failures, cpu);
  1021. resets += per_cpu(slot_resets, cpu);
  1022. no_dev += per_cpu(no_device, cpu);
  1023. no_dn += per_cpu(no_dn, cpu);
  1024. no_cfg += per_cpu(no_cfg_addr, cpu);
  1025. no_check += per_cpu(ignored_check, cpu);
  1026. }
  1027. if (0 == eeh_subsystem_enabled) {
  1028. seq_printf(m, "EEH Subsystem is globally disabled\n");
  1029. seq_printf(m, "eeh_total_mmio_ffs=%ld\n", ffs);
  1030. } else {
  1031. seq_printf(m, "EEH Subsystem is enabled\n");
  1032. seq_printf(m,
  1033. "no device=%ld\n"
  1034. "no device node=%ld\n"
  1035. "no config address=%ld\n"
  1036. "check not wanted=%ld\n"
  1037. "eeh_total_mmio_ffs=%ld\n"
  1038. "eeh_false_positives=%ld\n"
  1039. "eeh_ignored_failures=%ld\n"
  1040. "eeh_slot_resets=%ld\n",
  1041. no_dev, no_dn, no_cfg, no_check,
  1042. ffs, positives, failures, resets);
  1043. }
  1044. return 0;
  1045. }
  1046. static int proc_eeh_open(struct inode *inode, struct file *file)
  1047. {
  1048. return single_open(file, proc_eeh_show, NULL);
  1049. }
  1050. static struct file_operations proc_eeh_operations = {
  1051. .open = proc_eeh_open,
  1052. .read = seq_read,
  1053. .llseek = seq_lseek,
  1054. .release = single_release,
  1055. };
  1056. static int __init eeh_init_proc(void)
  1057. {
  1058. struct proc_dir_entry *e;
  1059. if (platform_is_pseries()) {
  1060. e = create_proc_entry("ppc64/eeh", 0, NULL);
  1061. if (e)
  1062. e->proc_fops = &proc_eeh_operations;
  1063. }
  1064. return 0;
  1065. }
  1066. __initcall(eeh_init_proc);