eeh.c 35 KB

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