eeh.c 35 KB

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