eeh.c 35 KB

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