eeh.c 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230
  1. /*
  2. * Copyright IBM Corporation 2001, 2005, 2006
  3. * Copyright Dave Engebretsen & Todd Inglett 2001
  4. * Copyright Linas Vepstas 2005, 2006
  5. * Copyright 2001-2012 IBM Corporation.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. * Please address comments and feedback to Linas Vepstas <linas@austin.ibm.com>
  22. */
  23. #include <linux/delay.h>
  24. #include <linux/sched.h>
  25. #include <linux/init.h>
  26. #include <linux/list.h>
  27. #include <linux/pci.h>
  28. #include <linux/proc_fs.h>
  29. #include <linux/rbtree.h>
  30. #include <linux/seq_file.h>
  31. #include <linux/spinlock.h>
  32. #include <linux/export.h>
  33. #include <linux/of.h>
  34. #include <linux/atomic.h>
  35. #include <asm/eeh.h>
  36. #include <asm/eeh_event.h>
  37. #include <asm/io.h>
  38. #include <asm/machdep.h>
  39. #include <asm/ppc-pci.h>
  40. #include <asm/rtas.h>
  41. /** Overview:
  42. * EEH, or "Extended Error Handling" is a PCI bridge technology for
  43. * dealing with PCI bus errors that can't be dealt with within the
  44. * usual PCI framework, except by check-stopping the CPU. Systems
  45. * that are designed for high-availability/reliability cannot afford
  46. * to crash due to a "mere" PCI error, thus the need for EEH.
  47. * An EEH-capable bridge operates by converting a detected error
  48. * into a "slot freeze", taking the PCI adapter off-line, making
  49. * the slot behave, from the OS'es point of view, as if the slot
  50. * were "empty": all reads return 0xff's and all writes are silently
  51. * ignored. EEH slot isolation events can be triggered by parity
  52. * errors on the address or data busses (e.g. during posted writes),
  53. * which in turn might be caused by low voltage on the bus, dust,
  54. * vibration, humidity, radioactivity or plain-old failed hardware.
  55. *
  56. * Note, however, that one of the leading causes of EEH slot
  57. * freeze events are buggy device drivers, buggy device microcode,
  58. * or buggy device hardware. This is because any attempt by the
  59. * device to bus-master data to a memory address that is not
  60. * assigned to the device will trigger a slot freeze. (The idea
  61. * is to prevent devices-gone-wild from corrupting system memory).
  62. * Buggy hardware/drivers will have a miserable time co-existing
  63. * with EEH.
  64. *
  65. * Ideally, a PCI device driver, when suspecting that an isolation
  66. * event has occurred (e.g. by reading 0xff's), will then ask EEH
  67. * whether this is the case, and then take appropriate steps to
  68. * reset the PCI slot, the PCI device, and then resume operations.
  69. * However, until that day, the checking is done here, with the
  70. * eeh_check_failure() routine embedded in the MMIO macros. If
  71. * the slot is found to be isolated, an "EEH Event" is synthesized
  72. * and sent out for processing.
  73. */
  74. /* If a device driver keeps reading an MMIO register in an interrupt
  75. * handler after a slot isolation event, it might be broken.
  76. * This sets the threshold for how many read attempts we allow
  77. * before printing an error message.
  78. */
  79. #define EEH_MAX_FAILS 2100000
  80. /* Time to wait for a PCI slot to report status, in milliseconds */
  81. #define PCI_BUS_RESET_WAIT_MSEC (60*1000)
  82. /* Platform dependent EEH operations */
  83. struct eeh_ops *eeh_ops = NULL;
  84. int eeh_subsystem_enabled;
  85. EXPORT_SYMBOL(eeh_subsystem_enabled);
  86. /* Global EEH mutex */
  87. DEFINE_MUTEX(eeh_mutex);
  88. /* Lock to avoid races due to multiple reports of an error */
  89. static DEFINE_RAW_SPINLOCK(confirm_error_lock);
  90. /* Buffer for reporting pci register dumps. Its here in BSS, and
  91. * not dynamically alloced, so that it ends up in RMO where RTAS
  92. * can access it.
  93. */
  94. #define EEH_PCI_REGS_LOG_LEN 4096
  95. static unsigned char pci_regs_buf[EEH_PCI_REGS_LOG_LEN];
  96. /*
  97. * The struct is used to maintain the EEH global statistic
  98. * information. Besides, the EEH global statistics will be
  99. * exported to user space through procfs
  100. */
  101. struct eeh_stats {
  102. u64 no_device; /* PCI device not found */
  103. u64 no_dn; /* OF node not found */
  104. u64 no_cfg_addr; /* Config address not found */
  105. u64 ignored_check; /* EEH check skipped */
  106. u64 total_mmio_ffs; /* Total EEH checks */
  107. u64 false_positives; /* Unnecessary EEH checks */
  108. u64 slot_resets; /* PE reset */
  109. };
  110. static struct eeh_stats eeh_stats;
  111. #define IS_BRIDGE(class_code) (((class_code)<<16) == PCI_BASE_CLASS_BRIDGE)
  112. /**
  113. * eeh_gather_pci_data - Copy assorted PCI config space registers to buff
  114. * @edev: device to report data for
  115. * @buf: point to buffer in which to log
  116. * @len: amount of room in buffer
  117. *
  118. * This routine captures assorted PCI configuration space data,
  119. * and puts them into a buffer for RTAS error logging.
  120. */
  121. static size_t eeh_gather_pci_data(struct eeh_dev *edev, char * buf, size_t len)
  122. {
  123. struct device_node *dn = eeh_dev_to_of_node(edev);
  124. struct pci_dev *dev = eeh_dev_to_pci_dev(edev);
  125. u32 cfg;
  126. int cap, i;
  127. int n = 0;
  128. n += scnprintf(buf+n, len-n, "%s\n", dn->full_name);
  129. printk(KERN_WARNING "EEH: of node=%s\n", dn->full_name);
  130. eeh_ops->read_config(dn, PCI_VENDOR_ID, 4, &cfg);
  131. n += scnprintf(buf+n, len-n, "dev/vend:%08x\n", cfg);
  132. printk(KERN_WARNING "EEH: PCI device/vendor: %08x\n", cfg);
  133. eeh_ops->read_config(dn, PCI_COMMAND, 4, &cfg);
  134. n += scnprintf(buf+n, len-n, "cmd/stat:%x\n", cfg);
  135. printk(KERN_WARNING "EEH: PCI cmd/status register: %08x\n", cfg);
  136. if (!dev) {
  137. printk(KERN_WARNING "EEH: no PCI device for this of node\n");
  138. return n;
  139. }
  140. /* Gather bridge-specific registers */
  141. if (dev->class >> 16 == PCI_BASE_CLASS_BRIDGE) {
  142. eeh_ops->read_config(dn, PCI_SEC_STATUS, 2, &cfg);
  143. n += scnprintf(buf+n, len-n, "sec stat:%x\n", cfg);
  144. printk(KERN_WARNING "EEH: Bridge secondary status: %04x\n", cfg);
  145. eeh_ops->read_config(dn, PCI_BRIDGE_CONTROL, 2, &cfg);
  146. n += scnprintf(buf+n, len-n, "brdg ctl:%x\n", cfg);
  147. printk(KERN_WARNING "EEH: Bridge control: %04x\n", cfg);
  148. }
  149. /* Dump out the PCI-X command and status regs */
  150. cap = pci_find_capability(dev, PCI_CAP_ID_PCIX);
  151. if (cap) {
  152. eeh_ops->read_config(dn, cap, 4, &cfg);
  153. n += scnprintf(buf+n, len-n, "pcix-cmd:%x\n", cfg);
  154. printk(KERN_WARNING "EEH: PCI-X cmd: %08x\n", cfg);
  155. eeh_ops->read_config(dn, cap+4, 4, &cfg);
  156. n += scnprintf(buf+n, len-n, "pcix-stat:%x\n", cfg);
  157. printk(KERN_WARNING "EEH: PCI-X status: %08x\n", cfg);
  158. }
  159. /* If PCI-E capable, dump PCI-E cap 10, and the AER */
  160. cap = pci_find_capability(dev, PCI_CAP_ID_EXP);
  161. if (cap) {
  162. n += scnprintf(buf+n, len-n, "pci-e cap10:\n");
  163. printk(KERN_WARNING
  164. "EEH: PCI-E capabilities and status follow:\n");
  165. for (i=0; i<=8; i++) {
  166. eeh_ops->read_config(dn, cap+4*i, 4, &cfg);
  167. n += scnprintf(buf+n, len-n, "%02x:%x\n", 4*i, cfg);
  168. printk(KERN_WARNING "EEH: PCI-E %02x: %08x\n", i, cfg);
  169. }
  170. cap = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
  171. if (cap) {
  172. n += scnprintf(buf+n, len-n, "pci-e AER:\n");
  173. printk(KERN_WARNING
  174. "EEH: PCI-E AER capability register set follows:\n");
  175. for (i=0; i<14; i++) {
  176. eeh_ops->read_config(dn, cap+4*i, 4, &cfg);
  177. n += scnprintf(buf+n, len-n, "%02x:%x\n", 4*i, cfg);
  178. printk(KERN_WARNING "EEH: PCI-E AER %02x: %08x\n", i, cfg);
  179. }
  180. }
  181. }
  182. /* Gather status on devices under the bridge */
  183. if (dev->class >> 16 == PCI_BASE_CLASS_BRIDGE) {
  184. struct device_node *child;
  185. for_each_child_of_node(dn, child) {
  186. if (of_node_to_eeh_dev(child))
  187. n += eeh_gather_pci_data(of_node_to_eeh_dev(child), buf+n, len-n);
  188. }
  189. }
  190. return n;
  191. }
  192. /**
  193. * eeh_slot_error_detail - Generate combined log including driver log and error log
  194. * @edev: device to report error log for
  195. * @severity: temporary or permanent error log
  196. *
  197. * This routine should be called to generate the combined log, which
  198. * is comprised of driver log and error log. The driver log is figured
  199. * out from the config space of the corresponding PCI device, while
  200. * the error log is fetched through platform dependent function call.
  201. */
  202. void eeh_slot_error_detail(struct eeh_dev *edev, int severity)
  203. {
  204. size_t loglen = 0;
  205. pci_regs_buf[0] = 0;
  206. eeh_pci_enable(edev, EEH_OPT_THAW_MMIO);
  207. eeh_ops->configure_bridge(eeh_dev_to_of_node(edev));
  208. eeh_restore_bars(edev);
  209. loglen = eeh_gather_pci_data(edev, pci_regs_buf, EEH_PCI_REGS_LOG_LEN);
  210. eeh_ops->get_log(eeh_dev_to_of_node(edev), severity, pci_regs_buf, loglen);
  211. }
  212. /**
  213. * eeh_token_to_phys - Convert EEH address token to phys address
  214. * @token: I/O token, should be address in the form 0xA....
  215. *
  216. * This routine should be called to convert virtual I/O address
  217. * to physical one.
  218. */
  219. static inline unsigned long eeh_token_to_phys(unsigned long token)
  220. {
  221. pte_t *ptep;
  222. unsigned long pa;
  223. ptep = find_linux_pte(init_mm.pgd, token);
  224. if (!ptep)
  225. return token;
  226. pa = pte_pfn(*ptep) << PAGE_SHIFT;
  227. return pa | (token & (PAGE_SIZE-1));
  228. }
  229. /**
  230. * eeh_find_device_pe - Retrieve the PE for the given device
  231. * @dn: device node
  232. *
  233. * Return the PE under which this device lies
  234. */
  235. struct device_node *eeh_find_device_pe(struct device_node *dn)
  236. {
  237. while (dn->parent && of_node_to_eeh_dev(dn->parent) &&
  238. (of_node_to_eeh_dev(dn->parent)->mode & EEH_MODE_SUPPORTED)) {
  239. dn = dn->parent;
  240. }
  241. return dn;
  242. }
  243. /**
  244. * __eeh_mark_slot - Mark all child devices as failed
  245. * @parent: parent device
  246. * @mode_flag: failure flag
  247. *
  248. * Mark all devices that are children of this device as failed.
  249. * Mark the device driver too, so that it can see the failure
  250. * immediately; this is critical, since some drivers poll
  251. * status registers in interrupts ... If a driver is polling,
  252. * and the slot is frozen, then the driver can deadlock in
  253. * an interrupt context, which is bad.
  254. */
  255. static void __eeh_mark_slot(struct device_node *parent, int mode_flag)
  256. {
  257. struct device_node *dn;
  258. for_each_child_of_node(parent, dn) {
  259. if (of_node_to_eeh_dev(dn)) {
  260. /* Mark the pci device driver too */
  261. struct pci_dev *dev = of_node_to_eeh_dev(dn)->pdev;
  262. of_node_to_eeh_dev(dn)->mode |= mode_flag;
  263. if (dev && dev->driver)
  264. dev->error_state = pci_channel_io_frozen;
  265. __eeh_mark_slot(dn, mode_flag);
  266. }
  267. }
  268. }
  269. /**
  270. * eeh_mark_slot - Mark the indicated device and its children as failed
  271. * @dn: parent device
  272. * @mode_flag: failure flag
  273. *
  274. * Mark the indicated device and its child devices as failed.
  275. * The device drivers are marked as failed as well.
  276. */
  277. void eeh_mark_slot(struct device_node *dn, int mode_flag)
  278. {
  279. struct pci_dev *dev;
  280. dn = eeh_find_device_pe(dn);
  281. /* Back up one, since config addrs might be shared */
  282. if (!pcibios_find_pci_bus(dn) && of_node_to_eeh_dev(dn->parent))
  283. dn = dn->parent;
  284. of_node_to_eeh_dev(dn)->mode |= mode_flag;
  285. /* Mark the pci device too */
  286. dev = of_node_to_eeh_dev(dn)->pdev;
  287. if (dev)
  288. dev->error_state = pci_channel_io_frozen;
  289. __eeh_mark_slot(dn, mode_flag);
  290. }
  291. /**
  292. * __eeh_clear_slot - Clear failure flag for the child devices
  293. * @parent: parent device
  294. * @mode_flag: flag to be cleared
  295. *
  296. * Clear failure flag for the child devices.
  297. */
  298. static void __eeh_clear_slot(struct device_node *parent, int mode_flag)
  299. {
  300. struct device_node *dn;
  301. for_each_child_of_node(parent, dn) {
  302. if (of_node_to_eeh_dev(dn)) {
  303. of_node_to_eeh_dev(dn)->mode &= ~mode_flag;
  304. of_node_to_eeh_dev(dn)->check_count = 0;
  305. __eeh_clear_slot(dn, mode_flag);
  306. }
  307. }
  308. }
  309. /**
  310. * eeh_clear_slot - Clear failure flag for the indicated device and its children
  311. * @dn: parent device
  312. * @mode_flag: flag to be cleared
  313. *
  314. * Clear failure flag for the indicated device and its children.
  315. */
  316. void eeh_clear_slot(struct device_node *dn, int mode_flag)
  317. {
  318. unsigned long flags;
  319. raw_spin_lock_irqsave(&confirm_error_lock, flags);
  320. dn = eeh_find_device_pe(dn);
  321. /* Back up one, since config addrs might be shared */
  322. if (!pcibios_find_pci_bus(dn) && of_node_to_eeh_dev(dn->parent))
  323. dn = dn->parent;
  324. of_node_to_eeh_dev(dn)->mode &= ~mode_flag;
  325. of_node_to_eeh_dev(dn)->check_count = 0;
  326. __eeh_clear_slot(dn, mode_flag);
  327. raw_spin_unlock_irqrestore(&confirm_error_lock, flags);
  328. }
  329. /**
  330. * eeh_dn_check_failure - Check if all 1's data is due to EEH slot freeze
  331. * @dn: device node
  332. * @dev: pci device, if known
  333. *
  334. * Check for an EEH failure for the given device node. Call this
  335. * routine if the result of a read was all 0xff's and you want to
  336. * find out if this is due to an EEH slot freeze. This routine
  337. * will query firmware for the EEH status.
  338. *
  339. * Returns 0 if there has not been an EEH error; otherwise returns
  340. * a non-zero value and queues up a slot isolation event notification.
  341. *
  342. * It is safe to call this routine in an interrupt context.
  343. */
  344. int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
  345. {
  346. int ret;
  347. unsigned long flags;
  348. struct eeh_dev *edev;
  349. int rc = 0;
  350. const char *location;
  351. eeh_stats.total_mmio_ffs++;
  352. if (!eeh_subsystem_enabled)
  353. return 0;
  354. if (!dn) {
  355. eeh_stats.no_dn++;
  356. return 0;
  357. }
  358. dn = eeh_find_device_pe(dn);
  359. edev = of_node_to_eeh_dev(dn);
  360. /* Access to IO BARs might get this far and still not want checking. */
  361. if (!(edev->mode & EEH_MODE_SUPPORTED) ||
  362. edev->mode & EEH_MODE_NOCHECK) {
  363. eeh_stats.ignored_check++;
  364. pr_debug("EEH: Ignored check (%x) for %s %s\n",
  365. edev->mode, eeh_pci_name(dev), dn->full_name);
  366. return 0;
  367. }
  368. if (!edev->config_addr && !edev->pe_config_addr) {
  369. eeh_stats.no_cfg_addr++;
  370. return 0;
  371. }
  372. /* If we already have a pending isolation event for this
  373. * slot, we know it's bad already, we don't need to check.
  374. * Do this checking under a lock; as multiple PCI devices
  375. * in one slot might report errors simultaneously, and we
  376. * only want one error recovery routine running.
  377. */
  378. raw_spin_lock_irqsave(&confirm_error_lock, flags);
  379. rc = 1;
  380. if (edev->mode & EEH_MODE_ISOLATED) {
  381. edev->check_count++;
  382. if (edev->check_count % EEH_MAX_FAILS == 0) {
  383. location = of_get_property(dn, "ibm,loc-code", NULL);
  384. printk(KERN_ERR "EEH: %d reads ignored for recovering device at "
  385. "location=%s driver=%s pci addr=%s\n",
  386. edev->check_count, location,
  387. eeh_driver_name(dev), eeh_pci_name(dev));
  388. printk(KERN_ERR "EEH: Might be infinite loop in %s driver\n",
  389. eeh_driver_name(dev));
  390. dump_stack();
  391. }
  392. goto dn_unlock;
  393. }
  394. /*
  395. * Now test for an EEH failure. This is VERY expensive.
  396. * Note that the eeh_config_addr may be a parent device
  397. * in the case of a device behind a bridge, or it may be
  398. * function zero of a multi-function device.
  399. * In any case they must share a common PHB.
  400. */
  401. ret = eeh_ops->get_state(dn, NULL);
  402. /* Note that config-io to empty slots may fail;
  403. * they are empty when they don't have children.
  404. * We will punt with the following conditions: Failure to get
  405. * PE's state, EEH not support and Permanently unavailable
  406. * state, PE is in good state.
  407. */
  408. if ((ret < 0) ||
  409. (ret == EEH_STATE_NOT_SUPPORT) ||
  410. (ret & (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE)) ==
  411. (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE)) {
  412. eeh_stats.false_positives++;
  413. edev->false_positives ++;
  414. rc = 0;
  415. goto dn_unlock;
  416. }
  417. eeh_stats.slot_resets++;
  418. /* Avoid repeated reports of this failure, including problems
  419. * with other functions on this device, and functions under
  420. * bridges.
  421. */
  422. eeh_mark_slot(dn, EEH_MODE_ISOLATED);
  423. raw_spin_unlock_irqrestore(&confirm_error_lock, flags);
  424. eeh_send_failure_event(edev);
  425. /* Most EEH events are due to device driver bugs. Having
  426. * a stack trace will help the device-driver authors figure
  427. * out what happened. So print that out.
  428. */
  429. WARN(1, "EEH: failure detected\n");
  430. return 1;
  431. dn_unlock:
  432. raw_spin_unlock_irqrestore(&confirm_error_lock, flags);
  433. return rc;
  434. }
  435. EXPORT_SYMBOL_GPL(eeh_dn_check_failure);
  436. /**
  437. * eeh_check_failure - Check if all 1's data is due to EEH slot freeze
  438. * @token: I/O token, should be address in the form 0xA....
  439. * @val: value, should be all 1's (XXX why do we need this arg??)
  440. *
  441. * Check for an EEH failure at the given token address. Call this
  442. * routine if the result of a read was all 0xff's and you want to
  443. * find out if this is due to an EEH slot freeze event. This routine
  444. * will query firmware for the EEH status.
  445. *
  446. * Note this routine is safe to call in an interrupt context.
  447. */
  448. unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned long val)
  449. {
  450. unsigned long addr;
  451. struct pci_dev *dev;
  452. struct device_node *dn;
  453. /* Finding the phys addr + pci device; this is pretty quick. */
  454. addr = eeh_token_to_phys((unsigned long __force) token);
  455. dev = pci_addr_cache_get_device(addr);
  456. if (!dev) {
  457. eeh_stats.no_device++;
  458. return val;
  459. }
  460. dn = pci_device_to_OF_node(dev);
  461. eeh_dn_check_failure(dn, dev);
  462. pci_dev_put(dev);
  463. return val;
  464. }
  465. EXPORT_SYMBOL(eeh_check_failure);
  466. /**
  467. * eeh_pci_enable - Enable MMIO or DMA transfers for this slot
  468. * @edev: pci device node
  469. *
  470. * This routine should be called to reenable frozen MMIO or DMA
  471. * so that it would work correctly again. It's useful while doing
  472. * recovery or log collection on the indicated device.
  473. */
  474. int eeh_pci_enable(struct eeh_dev *edev, int function)
  475. {
  476. int rc;
  477. struct device_node *dn = eeh_dev_to_of_node(edev);
  478. rc = eeh_ops->set_option(dn, function);
  479. if (rc)
  480. printk(KERN_WARNING "EEH: Unexpected state change %d, err=%d dn=%s\n",
  481. function, rc, dn->full_name);
  482. rc = eeh_ops->wait_state(dn, PCI_BUS_RESET_WAIT_MSEC);
  483. if (rc > 0 && (rc & EEH_STATE_MMIO_ENABLED) &&
  484. (function == EEH_OPT_THAW_MMIO))
  485. return 0;
  486. return rc;
  487. }
  488. /**
  489. * pcibios_set_pcie_slot_reset - Set PCI-E reset state
  490. * @dev: pci device struct
  491. * @state: reset state to enter
  492. *
  493. * Return value:
  494. * 0 if success
  495. */
  496. int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
  497. {
  498. struct device_node *dn = pci_device_to_OF_node(dev);
  499. switch (state) {
  500. case pcie_deassert_reset:
  501. eeh_ops->reset(dn, EEH_RESET_DEACTIVATE);
  502. break;
  503. case pcie_hot_reset:
  504. eeh_ops->reset(dn, EEH_RESET_HOT);
  505. break;
  506. case pcie_warm_reset:
  507. eeh_ops->reset(dn, EEH_RESET_FUNDAMENTAL);
  508. break;
  509. default:
  510. return -EINVAL;
  511. };
  512. return 0;
  513. }
  514. /**
  515. * __eeh_set_pe_freset - Check the required reset for child devices
  516. * @parent: parent device
  517. * @freset: return value
  518. *
  519. * Each device might have its preferred reset type: fundamental or
  520. * hot reset. The routine is used to collect the information from
  521. * the child devices so that they could be reset accordingly.
  522. */
  523. void __eeh_set_pe_freset(struct device_node *parent, unsigned int *freset)
  524. {
  525. struct device_node *dn;
  526. for_each_child_of_node(parent, dn) {
  527. if (of_node_to_eeh_dev(dn)) {
  528. struct pci_dev *dev = of_node_to_eeh_dev(dn)->pdev;
  529. if (dev && dev->driver)
  530. *freset |= dev->needs_freset;
  531. __eeh_set_pe_freset(dn, freset);
  532. }
  533. }
  534. }
  535. /**
  536. * eeh_set_pe_freset - Check the required reset for the indicated device and its children
  537. * @dn: parent device
  538. * @freset: return value
  539. *
  540. * Each device might have its preferred reset type: fundamental or
  541. * hot reset. The routine is used to collected the information for
  542. * the indicated device and its children so that the bunch of the
  543. * devices could be reset properly.
  544. */
  545. void eeh_set_pe_freset(struct device_node *dn, unsigned int *freset)
  546. {
  547. struct pci_dev *dev;
  548. dn = eeh_find_device_pe(dn);
  549. /* Back up one, since config addrs might be shared */
  550. if (!pcibios_find_pci_bus(dn) && of_node_to_eeh_dev(dn->parent))
  551. dn = dn->parent;
  552. dev = of_node_to_eeh_dev(dn)->pdev;
  553. if (dev)
  554. *freset |= dev->needs_freset;
  555. __eeh_set_pe_freset(dn, freset);
  556. }
  557. /**
  558. * eeh_reset_pe_once - Assert the pci #RST line for 1/4 second
  559. * @edev: pci device node to be reset.
  560. *
  561. * Assert the PCI #RST line for 1/4 second.
  562. */
  563. static void eeh_reset_pe_once(struct eeh_dev *edev)
  564. {
  565. unsigned int freset = 0;
  566. struct device_node *dn = eeh_dev_to_of_node(edev);
  567. /* Determine type of EEH reset required for
  568. * Partitionable Endpoint, a hot-reset (1)
  569. * or a fundamental reset (3).
  570. * A fundamental reset required by any device under
  571. * Partitionable Endpoint trumps hot-reset.
  572. */
  573. eeh_set_pe_freset(dn, &freset);
  574. if (freset)
  575. eeh_ops->reset(dn, EEH_RESET_FUNDAMENTAL);
  576. else
  577. eeh_ops->reset(dn, EEH_RESET_HOT);
  578. /* The PCI bus requires that the reset be held high for at least
  579. * a 100 milliseconds. We wait a bit longer 'just in case'.
  580. */
  581. #define PCI_BUS_RST_HOLD_TIME_MSEC 250
  582. msleep(PCI_BUS_RST_HOLD_TIME_MSEC);
  583. /* We might get hit with another EEH freeze as soon as the
  584. * pci slot reset line is dropped. Make sure we don't miss
  585. * these, and clear the flag now.
  586. */
  587. eeh_clear_slot(dn, EEH_MODE_ISOLATED);
  588. eeh_ops->reset(dn, EEH_RESET_DEACTIVATE);
  589. /* After a PCI slot has been reset, the PCI Express spec requires
  590. * a 1.5 second idle time for the bus to stabilize, before starting
  591. * up traffic.
  592. */
  593. #define PCI_BUS_SETTLE_TIME_MSEC 1800
  594. msleep(PCI_BUS_SETTLE_TIME_MSEC);
  595. }
  596. /**
  597. * eeh_reset_pe - Reset the indicated PE
  598. * @edev: PCI device associated EEH device
  599. *
  600. * This routine should be called to reset indicated device, including
  601. * PE. A PE might include multiple PCI devices and sometimes PCI bridges
  602. * might be involved as well.
  603. */
  604. int eeh_reset_pe(struct eeh_dev *edev)
  605. {
  606. int i, rc;
  607. struct device_node *dn = eeh_dev_to_of_node(edev);
  608. /* Take three shots at resetting the bus */
  609. for (i=0; i<3; i++) {
  610. eeh_reset_pe_once(edev);
  611. rc = eeh_ops->wait_state(dn, PCI_BUS_RESET_WAIT_MSEC);
  612. if (rc == (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE))
  613. return 0;
  614. if (rc < 0) {
  615. printk(KERN_ERR "EEH: unrecoverable slot failure %s\n",
  616. dn->full_name);
  617. return -1;
  618. }
  619. printk(KERN_ERR "EEH: bus reset %d failed on slot %s, rc=%d\n",
  620. i+1, dn->full_name, rc);
  621. }
  622. return -1;
  623. }
  624. /** Save and restore of PCI BARs
  625. *
  626. * Although firmware will set up BARs during boot, it doesn't
  627. * set up device BAR's after a device reset, although it will,
  628. * if requested, set up bridge configuration. Thus, we need to
  629. * configure the PCI devices ourselves.
  630. */
  631. /**
  632. * eeh_restore_one_device_bars - Restore the Base Address Registers for one device
  633. * @edev: PCI device associated EEH device
  634. *
  635. * Loads the PCI configuration space base address registers,
  636. * the expansion ROM base address, the latency timer, and etc.
  637. * from the saved values in the device node.
  638. */
  639. static inline void eeh_restore_one_device_bars(struct eeh_dev *edev)
  640. {
  641. int i;
  642. u32 cmd;
  643. struct device_node *dn = eeh_dev_to_of_node(edev);
  644. if (!edev->phb)
  645. return;
  646. for (i=4; i<10; i++) {
  647. eeh_ops->write_config(dn, i*4, 4, edev->config_space[i]);
  648. }
  649. /* 12 == Expansion ROM Address */
  650. eeh_ops->write_config(dn, 12*4, 4, edev->config_space[12]);
  651. #define BYTE_SWAP(OFF) (8*((OFF)/4)+3-(OFF))
  652. #define SAVED_BYTE(OFF) (((u8 *)(edev->config_space))[BYTE_SWAP(OFF)])
  653. eeh_ops->write_config(dn, PCI_CACHE_LINE_SIZE, 1,
  654. SAVED_BYTE(PCI_CACHE_LINE_SIZE));
  655. eeh_ops->write_config(dn, PCI_LATENCY_TIMER, 1,
  656. SAVED_BYTE(PCI_LATENCY_TIMER));
  657. /* max latency, min grant, interrupt pin and line */
  658. eeh_ops->write_config(dn, 15*4, 4, edev->config_space[15]);
  659. /* Restore PERR & SERR bits, some devices require it,
  660. * don't touch the other command bits
  661. */
  662. eeh_ops->read_config(dn, PCI_COMMAND, 4, &cmd);
  663. if (edev->config_space[1] & PCI_COMMAND_PARITY)
  664. cmd |= PCI_COMMAND_PARITY;
  665. else
  666. cmd &= ~PCI_COMMAND_PARITY;
  667. if (edev->config_space[1] & PCI_COMMAND_SERR)
  668. cmd |= PCI_COMMAND_SERR;
  669. else
  670. cmd &= ~PCI_COMMAND_SERR;
  671. eeh_ops->write_config(dn, PCI_COMMAND, 4, cmd);
  672. }
  673. /**
  674. * eeh_restore_bars - Restore the PCI config space info
  675. * @edev: EEH device
  676. *
  677. * This routine performs a recursive walk to the children
  678. * of this device as well.
  679. */
  680. void eeh_restore_bars(struct eeh_dev *edev)
  681. {
  682. struct device_node *dn;
  683. if (!edev)
  684. return;
  685. if ((edev->mode & EEH_MODE_SUPPORTED) && !IS_BRIDGE(edev->class_code))
  686. eeh_restore_one_device_bars(edev);
  687. for_each_child_of_node(eeh_dev_to_of_node(edev), dn)
  688. eeh_restore_bars(of_node_to_eeh_dev(dn));
  689. }
  690. /**
  691. * eeh_save_bars - Save device bars
  692. * @edev: PCI device associated EEH device
  693. *
  694. * Save the values of the device bars. Unlike the restore
  695. * routine, this routine is *not* recursive. This is because
  696. * PCI devices are added individually; but, for the restore,
  697. * an entire slot is reset at a time.
  698. */
  699. static void eeh_save_bars(struct eeh_dev *edev)
  700. {
  701. int i;
  702. struct device_node *dn;
  703. if (!edev)
  704. return;
  705. dn = eeh_dev_to_of_node(edev);
  706. for (i = 0; i < 16; i++)
  707. eeh_ops->read_config(dn, i * 4, 4, &edev->config_space[i]);
  708. }
  709. /**
  710. * eeh_early_enable - Early enable EEH on the indicated device
  711. * @dn: device node
  712. * @data: BUID
  713. *
  714. * Enable EEH functionality on the specified PCI device. The function
  715. * is expected to be called before real PCI probing is done. However,
  716. * the PHBs have been initialized at this point.
  717. */
  718. static void *eeh_early_enable(struct device_node *dn, void *data)
  719. {
  720. int ret;
  721. const u32 *class_code = of_get_property(dn, "class-code", NULL);
  722. const u32 *vendor_id = of_get_property(dn, "vendor-id", NULL);
  723. const u32 *device_id = of_get_property(dn, "device-id", NULL);
  724. const u32 *regs;
  725. int enable;
  726. struct eeh_dev *edev = of_node_to_eeh_dev(dn);
  727. edev->class_code = 0;
  728. edev->mode = 0;
  729. edev->check_count = 0;
  730. edev->freeze_count = 0;
  731. edev->false_positives = 0;
  732. if (!of_device_is_available(dn))
  733. return NULL;
  734. /* Ignore bad nodes. */
  735. if (!class_code || !vendor_id || !device_id)
  736. return NULL;
  737. /* There is nothing to check on PCI to ISA bridges */
  738. if (dn->type && !strcmp(dn->type, "isa")) {
  739. edev->mode |= EEH_MODE_NOCHECK;
  740. return NULL;
  741. }
  742. edev->class_code = *class_code;
  743. /* Ok... see if this device supports EEH. Some do, some don't,
  744. * and the only way to find out is to check each and every one.
  745. */
  746. regs = of_get_property(dn, "reg", NULL);
  747. if (regs) {
  748. /* First register entry is addr (00BBSS00) */
  749. /* Try to enable eeh */
  750. ret = eeh_ops->set_option(dn, EEH_OPT_ENABLE);
  751. enable = 0;
  752. if (ret == 0) {
  753. edev->config_addr = regs[0];
  754. /* If the newer, better, ibm,get-config-addr-info is supported,
  755. * then use that instead.
  756. */
  757. edev->pe_config_addr = eeh_ops->get_pe_addr(dn);
  758. /* Some older systems (Power4) allow the
  759. * ibm,set-eeh-option call to succeed even on nodes
  760. * where EEH is not supported. Verify support
  761. * explicitly.
  762. */
  763. ret = eeh_ops->get_state(dn, NULL);
  764. if (ret > 0 && ret != EEH_STATE_NOT_SUPPORT)
  765. enable = 1;
  766. }
  767. if (enable) {
  768. eeh_subsystem_enabled = 1;
  769. edev->mode |= EEH_MODE_SUPPORTED;
  770. eeh_add_to_parent_pe(edev);
  771. pr_debug("EEH: %s: eeh enabled, config=%x pe_config=%x\n",
  772. dn->full_name, edev->config_addr,
  773. edev->pe_config_addr);
  774. } else {
  775. /* This device doesn't support EEH, but it may have an
  776. * EEH parent, in which case we mark it as supported.
  777. */
  778. if (dn->parent && of_node_to_eeh_dev(dn->parent) &&
  779. (of_node_to_eeh_dev(dn->parent)->mode & EEH_MODE_SUPPORTED)) {
  780. /* Parent supports EEH. */
  781. edev->mode |= EEH_MODE_SUPPORTED;
  782. edev->config_addr = of_node_to_eeh_dev(dn->parent)->config_addr;
  783. edev->pe_config_addr = of_node_to_eeh_dev(dn->parent)->pe_config_addr;
  784. eeh_add_to_parent_pe(edev);
  785. return NULL;
  786. }
  787. }
  788. } else {
  789. printk(KERN_WARNING "EEH: %s: unable to get reg property.\n",
  790. dn->full_name);
  791. }
  792. eeh_save_bars(edev);
  793. return NULL;
  794. }
  795. /**
  796. * eeh_ops_register - Register platform dependent EEH operations
  797. * @ops: platform dependent EEH operations
  798. *
  799. * Register the platform dependent EEH operation callback
  800. * functions. The platform should call this function before
  801. * any other EEH operations.
  802. */
  803. int __init eeh_ops_register(struct eeh_ops *ops)
  804. {
  805. if (!ops->name) {
  806. pr_warning("%s: Invalid EEH ops name for %p\n",
  807. __func__, ops);
  808. return -EINVAL;
  809. }
  810. if (eeh_ops && eeh_ops != ops) {
  811. pr_warning("%s: EEH ops of platform %s already existing (%s)\n",
  812. __func__, eeh_ops->name, ops->name);
  813. return -EEXIST;
  814. }
  815. eeh_ops = ops;
  816. return 0;
  817. }
  818. /**
  819. * eeh_ops_unregister - Unreigster platform dependent EEH operations
  820. * @name: name of EEH platform operations
  821. *
  822. * Unregister the platform dependent EEH operation callback
  823. * functions.
  824. */
  825. int __exit eeh_ops_unregister(const char *name)
  826. {
  827. if (!name || !strlen(name)) {
  828. pr_warning("%s: Invalid EEH ops name\n",
  829. __func__);
  830. return -EINVAL;
  831. }
  832. if (eeh_ops && !strcmp(eeh_ops->name, name)) {
  833. eeh_ops = NULL;
  834. return 0;
  835. }
  836. return -EEXIST;
  837. }
  838. /**
  839. * eeh_init - EEH initialization
  840. *
  841. * Initialize EEH by trying to enable it for all of the adapters in the system.
  842. * As a side effect we can determine here if eeh is supported at all.
  843. * Note that we leave EEH on so failed config cycles won't cause a machine
  844. * check. If a user turns off EEH for a particular adapter they are really
  845. * telling Linux to ignore errors. Some hardware (e.g. POWER5) won't
  846. * grant access to a slot if EEH isn't enabled, and so we always enable
  847. * EEH for all slots/all devices.
  848. *
  849. * The eeh-force-off option disables EEH checking globally, for all slots.
  850. * Even if force-off is set, the EEH hardware is still enabled, so that
  851. * newer systems can boot.
  852. */
  853. static int __init eeh_init(void)
  854. {
  855. struct pci_controller *hose, *tmp;
  856. struct device_node *phb;
  857. int ret;
  858. /* call platform initialization function */
  859. if (!eeh_ops) {
  860. pr_warning("%s: Platform EEH operation not found\n",
  861. __func__);
  862. return -EEXIST;
  863. } else if ((ret = eeh_ops->init())) {
  864. pr_warning("%s: Failed to call platform init function (%d)\n",
  865. __func__, ret);
  866. return ret;
  867. }
  868. raw_spin_lock_init(&confirm_error_lock);
  869. /* Enable EEH for all adapters */
  870. list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
  871. phb = hose->dn;
  872. traverse_pci_devices(phb, eeh_early_enable, NULL);
  873. }
  874. if (eeh_subsystem_enabled)
  875. printk(KERN_INFO "EEH: PCI Enhanced I/O Error Handling Enabled\n");
  876. else
  877. printk(KERN_WARNING "EEH: No capable adapters found\n");
  878. return ret;
  879. }
  880. core_initcall_sync(eeh_init);
  881. /**
  882. * eeh_add_device_early - Enable EEH for the indicated device_node
  883. * @dn: device node for which to set up EEH
  884. *
  885. * This routine must be used to perform EEH initialization for PCI
  886. * devices that were added after system boot (e.g. hotplug, dlpar).
  887. * This routine must be called before any i/o is performed to the
  888. * adapter (inluding any config-space i/o).
  889. * Whether this actually enables EEH or not for this device depends
  890. * on the CEC architecture, type of the device, on earlier boot
  891. * command-line arguments & etc.
  892. */
  893. static void eeh_add_device_early(struct device_node *dn)
  894. {
  895. struct pci_controller *phb;
  896. if (!dn || !of_node_to_eeh_dev(dn))
  897. return;
  898. phb = of_node_to_eeh_dev(dn)->phb;
  899. /* USB Bus children of PCI devices will not have BUID's */
  900. if (NULL == phb || 0 == phb->buid)
  901. return;
  902. eeh_early_enable(dn, NULL);
  903. }
  904. /**
  905. * eeh_add_device_tree_early - Enable EEH for the indicated device
  906. * @dn: device node
  907. *
  908. * This routine must be used to perform EEH initialization for the
  909. * indicated PCI device that was added after system boot (e.g.
  910. * hotplug, dlpar).
  911. */
  912. void eeh_add_device_tree_early(struct device_node *dn)
  913. {
  914. struct device_node *sib;
  915. for_each_child_of_node(dn, sib)
  916. eeh_add_device_tree_early(sib);
  917. eeh_add_device_early(dn);
  918. }
  919. EXPORT_SYMBOL_GPL(eeh_add_device_tree_early);
  920. /**
  921. * eeh_add_device_late - Perform EEH initialization for the indicated pci device
  922. * @dev: pci device for which to set up EEH
  923. *
  924. * This routine must be used to complete EEH initialization for PCI
  925. * devices that were added after system boot (e.g. hotplug, dlpar).
  926. */
  927. static void eeh_add_device_late(struct pci_dev *dev)
  928. {
  929. struct device_node *dn;
  930. struct eeh_dev *edev;
  931. if (!dev || !eeh_subsystem_enabled)
  932. return;
  933. pr_debug("EEH: Adding device %s\n", pci_name(dev));
  934. dn = pci_device_to_OF_node(dev);
  935. edev = of_node_to_eeh_dev(dn);
  936. if (edev->pdev == dev) {
  937. pr_debug("EEH: Already referenced !\n");
  938. return;
  939. }
  940. WARN_ON(edev->pdev);
  941. pci_dev_get(dev);
  942. edev->pdev = dev;
  943. dev->dev.archdata.edev = edev;
  944. pci_addr_cache_insert_device(dev);
  945. eeh_sysfs_add_device(dev);
  946. }
  947. /**
  948. * eeh_add_device_tree_late - Perform EEH initialization for the indicated PCI bus
  949. * @bus: PCI bus
  950. *
  951. * This routine must be used to perform EEH initialization for PCI
  952. * devices which are attached to the indicated PCI bus. The PCI bus
  953. * is added after system boot through hotplug or dlpar.
  954. */
  955. void eeh_add_device_tree_late(struct pci_bus *bus)
  956. {
  957. struct pci_dev *dev;
  958. list_for_each_entry(dev, &bus->devices, bus_list) {
  959. eeh_add_device_late(dev);
  960. if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
  961. struct pci_bus *subbus = dev->subordinate;
  962. if (subbus)
  963. eeh_add_device_tree_late(subbus);
  964. }
  965. }
  966. }
  967. EXPORT_SYMBOL_GPL(eeh_add_device_tree_late);
  968. /**
  969. * eeh_remove_device - Undo EEH setup for the indicated pci device
  970. * @dev: pci device to be removed
  971. *
  972. * This routine should be called when a device is removed from
  973. * a running system (e.g. by hotplug or dlpar). It unregisters
  974. * the PCI device from the EEH subsystem. I/O errors affecting
  975. * this device will no longer be detected after this call; thus,
  976. * i/o errors affecting this slot may leave this device unusable.
  977. */
  978. static void eeh_remove_device(struct pci_dev *dev)
  979. {
  980. struct eeh_dev *edev;
  981. if (!dev || !eeh_subsystem_enabled)
  982. return;
  983. edev = pci_dev_to_eeh_dev(dev);
  984. /* Unregister the device with the EEH/PCI address search system */
  985. pr_debug("EEH: Removing device %s\n", pci_name(dev));
  986. if (!edev || !edev->pdev) {
  987. pr_debug("EEH: Not referenced !\n");
  988. return;
  989. }
  990. edev->pdev = NULL;
  991. dev->dev.archdata.edev = NULL;
  992. pci_dev_put(dev);
  993. pci_addr_cache_remove_device(dev);
  994. eeh_sysfs_remove_device(dev);
  995. }
  996. /**
  997. * eeh_remove_bus_device - Undo EEH setup for the indicated PCI device
  998. * @dev: PCI device
  999. *
  1000. * This routine must be called when a device is removed from the
  1001. * running system through hotplug or dlpar. The corresponding
  1002. * PCI address cache will be removed.
  1003. */
  1004. void eeh_remove_bus_device(struct pci_dev *dev)
  1005. {
  1006. struct pci_bus *bus = dev->subordinate;
  1007. struct pci_dev *child, *tmp;
  1008. eeh_remove_device(dev);
  1009. if (bus && dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
  1010. list_for_each_entry_safe(child, tmp, &bus->devices, bus_list)
  1011. eeh_remove_bus_device(child);
  1012. }
  1013. }
  1014. EXPORT_SYMBOL_GPL(eeh_remove_bus_device);
  1015. static int proc_eeh_show(struct seq_file *m, void *v)
  1016. {
  1017. if (0 == eeh_subsystem_enabled) {
  1018. seq_printf(m, "EEH Subsystem is globally disabled\n");
  1019. seq_printf(m, "eeh_total_mmio_ffs=%llu\n", eeh_stats.total_mmio_ffs);
  1020. } else {
  1021. seq_printf(m, "EEH Subsystem is enabled\n");
  1022. seq_printf(m,
  1023. "no device=%llu\n"
  1024. "no device node=%llu\n"
  1025. "no config address=%llu\n"
  1026. "check not wanted=%llu\n"
  1027. "eeh_total_mmio_ffs=%llu\n"
  1028. "eeh_false_positives=%llu\n"
  1029. "eeh_slot_resets=%llu\n",
  1030. eeh_stats.no_device,
  1031. eeh_stats.no_dn,
  1032. eeh_stats.no_cfg_addr,
  1033. eeh_stats.ignored_check,
  1034. eeh_stats.total_mmio_ffs,
  1035. eeh_stats.false_positives,
  1036. eeh_stats.slot_resets);
  1037. }
  1038. return 0;
  1039. }
  1040. static int proc_eeh_open(struct inode *inode, struct file *file)
  1041. {
  1042. return single_open(file, proc_eeh_show, NULL);
  1043. }
  1044. static const struct file_operations proc_eeh_operations = {
  1045. .open = proc_eeh_open,
  1046. .read = seq_read,
  1047. .llseek = seq_lseek,
  1048. .release = single_release,
  1049. };
  1050. static int __init eeh_init_proc(void)
  1051. {
  1052. if (machine_is(pseries))
  1053. proc_create("powerpc/eeh", 0, NULL, &proc_eeh_operations);
  1054. return 0;
  1055. }
  1056. __initcall(eeh_init_proc);