eeh.c 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213
  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. /**
  942. * eeh_add_device_late - perform EEH initialization for the indicated pci device
  943. * @dev: pci device for which to set up EEH
  944. *
  945. * This routine must be used to complete EEH initialization for PCI
  946. * devices that were added after system boot (e.g. hotplug, dlpar).
  947. */
  948. void eeh_add_device_late(struct pci_dev *dev)
  949. {
  950. struct device_node *dn;
  951. struct pci_dn *pdn;
  952. if (!dev || !eeh_subsystem_enabled)
  953. return;
  954. #ifdef DEBUG
  955. printk(KERN_DEBUG "EEH: adding device %s\n", pci_name(dev));
  956. #endif
  957. pci_dev_get (dev);
  958. dn = pci_device_to_OF_node(dev);
  959. pdn = PCI_DN(dn);
  960. pdn->pcidev = dev;
  961. pci_addr_cache_insert_device (dev);
  962. eeh_save_bars(dev, pdn);
  963. }
  964. EXPORT_SYMBOL_GPL(eeh_add_device_late);
  965. /**
  966. * eeh_remove_device - undo EEH setup for the indicated pci device
  967. * @dev: pci device to be removed
  968. *
  969. * This routine should be when a device is removed from a running
  970. * system (e.g. by hotplug or dlpar).
  971. */
  972. void eeh_remove_device(struct pci_dev *dev)
  973. {
  974. struct device_node *dn;
  975. if (!dev || !eeh_subsystem_enabled)
  976. return;
  977. /* Unregister the device with the EEH/PCI address search system */
  978. #ifdef DEBUG
  979. printk(KERN_DEBUG "EEH: remove device %s\n", pci_name(dev));
  980. #endif
  981. pci_addr_cache_remove_device(dev);
  982. dn = pci_device_to_OF_node(dev);
  983. PCI_DN(dn)->pcidev = NULL;
  984. pci_dev_put (dev);
  985. }
  986. EXPORT_SYMBOL_GPL(eeh_remove_device);
  987. static int proc_eeh_show(struct seq_file *m, void *v)
  988. {
  989. unsigned int cpu;
  990. unsigned long ffs = 0, positives = 0, failures = 0;
  991. unsigned long resets = 0;
  992. unsigned long no_dev = 0, no_dn = 0, no_cfg = 0, no_check = 0;
  993. for_each_cpu(cpu) {
  994. ffs += per_cpu(total_mmio_ffs, cpu);
  995. positives += per_cpu(false_positives, cpu);
  996. failures += per_cpu(ignored_failures, cpu);
  997. resets += per_cpu(slot_resets, cpu);
  998. no_dev += per_cpu(no_device, cpu);
  999. no_dn += per_cpu(no_dn, cpu);
  1000. no_cfg += per_cpu(no_cfg_addr, cpu);
  1001. no_check += per_cpu(ignored_check, cpu);
  1002. }
  1003. if (0 == eeh_subsystem_enabled) {
  1004. seq_printf(m, "EEH Subsystem is globally disabled\n");
  1005. seq_printf(m, "eeh_total_mmio_ffs=%ld\n", ffs);
  1006. } else {
  1007. seq_printf(m, "EEH Subsystem is enabled\n");
  1008. seq_printf(m,
  1009. "no device=%ld\n"
  1010. "no device node=%ld\n"
  1011. "no config address=%ld\n"
  1012. "check not wanted=%ld\n"
  1013. "eeh_total_mmio_ffs=%ld\n"
  1014. "eeh_false_positives=%ld\n"
  1015. "eeh_ignored_failures=%ld\n"
  1016. "eeh_slot_resets=%ld\n",
  1017. no_dev, no_dn, no_cfg, no_check,
  1018. ffs, positives, failures, resets);
  1019. }
  1020. return 0;
  1021. }
  1022. static int proc_eeh_open(struct inode *inode, struct file *file)
  1023. {
  1024. return single_open(file, proc_eeh_show, NULL);
  1025. }
  1026. static struct file_operations proc_eeh_operations = {
  1027. .open = proc_eeh_open,
  1028. .read = seq_read,
  1029. .llseek = seq_lseek,
  1030. .release = single_release,
  1031. };
  1032. static int __init eeh_init_proc(void)
  1033. {
  1034. struct proc_dir_entry *e;
  1035. if (platform_is_pseries()) {
  1036. e = create_proc_entry("ppc64/eeh", 0, NULL);
  1037. if (e)
  1038. e->proc_fops = &proc_eeh_operations;
  1039. }
  1040. return 0;
  1041. }
  1042. __initcall(eeh_init_proc);