eeh.c 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259
  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. pdn->eeh_false_positives ++;
  437. rc = 0;
  438. goto dn_unlock;
  439. }
  440. /* Note that config-io to empty slots may fail;
  441. * they are empty when they don't have children. */
  442. if ((rets[0] == 5) && (dn->child == NULL)) {
  443. false_positives++;
  444. pdn->eeh_false_positives ++;
  445. rc = 0;
  446. goto dn_unlock;
  447. }
  448. /* If EEH is not supported on this device, punt. */
  449. if (rets[1] != 1) {
  450. printk(KERN_WARNING "EEH: event on unsupported device, rc=%d dn=%s\n",
  451. ret, dn->full_name);
  452. false_positives++;
  453. pdn->eeh_false_positives ++;
  454. rc = 0;
  455. goto dn_unlock;
  456. }
  457. /* If not the kind of error we know about, punt. */
  458. if (rets[0] != 1 && rets[0] != 2 && rets[0] != 4 && rets[0] != 5) {
  459. false_positives++;
  460. pdn->eeh_false_positives ++;
  461. rc = 0;
  462. goto dn_unlock;
  463. }
  464. slot_resets++;
  465. /* Avoid repeated reports of this failure, including problems
  466. * with other functions on this device, and functions under
  467. * bridges. */
  468. eeh_mark_slot (dn, EEH_MODE_ISOLATED);
  469. spin_unlock_irqrestore(&confirm_error_lock, flags);
  470. eeh_send_failure_event (dn, dev);
  471. /* Most EEH events are due to device driver bugs. Having
  472. * a stack trace will help the device-driver authors figure
  473. * out what happened. So print that out. */
  474. dump_stack();
  475. return 1;
  476. dn_unlock:
  477. spin_unlock_irqrestore(&confirm_error_lock, flags);
  478. return rc;
  479. }
  480. EXPORT_SYMBOL_GPL(eeh_dn_check_failure);
  481. /**
  482. * eeh_check_failure - check if all 1's data is due to EEH slot freeze
  483. * @token i/o token, should be address in the form 0xA....
  484. * @val value, should be all 1's (XXX why do we need this arg??)
  485. *
  486. * Check for an EEH failure at the given token address. Call this
  487. * routine if the result of a read was all 0xff's and you want to
  488. * find out if this is due to an EEH slot freeze event. This routine
  489. * will query firmware for the EEH status.
  490. *
  491. * Note this routine is safe to call in an interrupt context.
  492. */
  493. unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned long val)
  494. {
  495. unsigned long addr;
  496. struct pci_dev *dev;
  497. struct device_node *dn;
  498. /* Finding the phys addr + pci device; this is pretty quick. */
  499. addr = eeh_token_to_phys((unsigned long __force) token);
  500. dev = pci_get_device_by_addr(addr);
  501. if (!dev) {
  502. no_device++;
  503. return val;
  504. }
  505. dn = pci_device_to_OF_node(dev);
  506. eeh_dn_check_failure (dn, dev);
  507. pci_dev_put(dev);
  508. return val;
  509. }
  510. EXPORT_SYMBOL(eeh_check_failure);
  511. /* ------------------------------------------------------------- */
  512. /* The code below deals with error recovery */
  513. /**
  514. * rtas_pci_enable - enable MMIO or DMA transfers for this slot
  515. * @pdn pci device node
  516. */
  517. int
  518. rtas_pci_enable(struct pci_dn *pdn, int function)
  519. {
  520. int config_addr;
  521. int rc;
  522. /* Use PE configuration address, if present */
  523. config_addr = pdn->eeh_config_addr;
  524. if (pdn->eeh_pe_config_addr)
  525. config_addr = pdn->eeh_pe_config_addr;
  526. rc = rtas_call(ibm_set_eeh_option, 4, 1, NULL,
  527. config_addr,
  528. BUID_HI(pdn->phb->buid),
  529. BUID_LO(pdn->phb->buid),
  530. function);
  531. if (rc)
  532. printk(KERN_WARNING "EEH: Unexpected state change %d, err=%d dn=%s\n",
  533. function, rc, pdn->node->full_name);
  534. rc = eeh_wait_for_slot_status (pdn, PCI_BUS_RESET_WAIT_MSEC);
  535. if ((rc == 4) && (function == EEH_THAW_MMIO))
  536. return 0;
  537. return rc;
  538. }
  539. /**
  540. * rtas_pci_slot_reset - raises/lowers the pci #RST line
  541. * @pdn pci device node
  542. * @state: 1/0 to raise/lower the #RST
  543. *
  544. * Clear the EEH-frozen condition on a slot. This routine
  545. * asserts the PCI #RST line if the 'state' argument is '1',
  546. * and drops the #RST line if 'state is '0'. This routine is
  547. * safe to call in an interrupt context.
  548. *
  549. */
  550. static void
  551. rtas_pci_slot_reset(struct pci_dn *pdn, int state)
  552. {
  553. int config_addr;
  554. int rc;
  555. BUG_ON (pdn==NULL);
  556. if (!pdn->phb) {
  557. printk (KERN_WARNING "EEH: in slot reset, device node %s has no phb\n",
  558. pdn->node->full_name);
  559. return;
  560. }
  561. /* Use PE configuration address, if present */
  562. config_addr = pdn->eeh_config_addr;
  563. if (pdn->eeh_pe_config_addr)
  564. config_addr = pdn->eeh_pe_config_addr;
  565. rc = rtas_call(ibm_set_slot_reset,4,1, NULL,
  566. config_addr,
  567. BUID_HI(pdn->phb->buid),
  568. BUID_LO(pdn->phb->buid),
  569. state);
  570. if (rc)
  571. printk (KERN_WARNING "EEH: Unable to reset the failed slot,"
  572. " (%d) #RST=%d dn=%s\n",
  573. rc, state, pdn->node->full_name);
  574. }
  575. /**
  576. * pcibios_set_pcie_slot_reset - Set PCI-E reset state
  577. * @dev: pci device struct
  578. * @state: reset state to enter
  579. *
  580. * Return value:
  581. * 0 if success
  582. **/
  583. int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
  584. {
  585. struct device_node *dn = pci_device_to_OF_node(dev);
  586. struct pci_dn *pdn = PCI_DN(dn);
  587. switch (state) {
  588. case pcie_deassert_reset:
  589. rtas_pci_slot_reset(pdn, 0);
  590. break;
  591. case pcie_hot_reset:
  592. rtas_pci_slot_reset(pdn, 1);
  593. break;
  594. case pcie_warm_reset:
  595. rtas_pci_slot_reset(pdn, 3);
  596. break;
  597. default:
  598. return -EINVAL;
  599. };
  600. return 0;
  601. }
  602. /**
  603. * rtas_set_slot_reset -- assert the pci #RST line for 1/4 second
  604. * @pdn: pci device node to be reset.
  605. *
  606. * Return 0 if success, else a non-zero value.
  607. */
  608. static void __rtas_set_slot_reset(struct pci_dn *pdn)
  609. {
  610. rtas_pci_slot_reset (pdn, 1);
  611. /* The PCI bus requires that the reset be held high for at least
  612. * a 100 milliseconds. We wait a bit longer 'just in case'. */
  613. #define PCI_BUS_RST_HOLD_TIME_MSEC 250
  614. msleep (PCI_BUS_RST_HOLD_TIME_MSEC);
  615. /* We might get hit with another EEH freeze as soon as the
  616. * pci slot reset line is dropped. Make sure we don't miss
  617. * these, and clear the flag now. */
  618. eeh_clear_slot (pdn->node, EEH_MODE_ISOLATED);
  619. rtas_pci_slot_reset (pdn, 0);
  620. /* After a PCI slot has been reset, the PCI Express spec requires
  621. * a 1.5 second idle time for the bus to stabilize, before starting
  622. * up traffic. */
  623. #define PCI_BUS_SETTLE_TIME_MSEC 1800
  624. msleep (PCI_BUS_SETTLE_TIME_MSEC);
  625. }
  626. int rtas_set_slot_reset(struct pci_dn *pdn)
  627. {
  628. int i, rc;
  629. /* Take three shots at resetting the bus */
  630. for (i=0; i<3; i++) {
  631. __rtas_set_slot_reset(pdn);
  632. rc = eeh_wait_for_slot_status(pdn, PCI_BUS_RESET_WAIT_MSEC);
  633. if (rc == 0)
  634. return 0;
  635. if (rc < 0) {
  636. printk (KERN_ERR "EEH: unrecoverable slot failure %s\n",
  637. pdn->node->full_name);
  638. return -1;
  639. }
  640. printk (KERN_ERR "EEH: bus reset %d failed on slot %s\n",
  641. i+1, pdn->node->full_name);
  642. }
  643. return -1;
  644. }
  645. /* ------------------------------------------------------- */
  646. /** Save and restore of PCI BARs
  647. *
  648. * Although firmware will set up BARs during boot, it doesn't
  649. * set up device BAR's after a device reset, although it will,
  650. * if requested, set up bridge configuration. Thus, we need to
  651. * configure the PCI devices ourselves.
  652. */
  653. /**
  654. * __restore_bars - Restore the Base Address Registers
  655. * @pdn: pci device node
  656. *
  657. * Loads the PCI configuration space base address registers,
  658. * the expansion ROM base address, the latency timer, and etc.
  659. * from the saved values in the device node.
  660. */
  661. static inline void __restore_bars (struct pci_dn *pdn)
  662. {
  663. int i;
  664. if (NULL==pdn->phb) return;
  665. for (i=4; i<10; i++) {
  666. rtas_write_config(pdn, i*4, 4, pdn->config_space[i]);
  667. }
  668. /* 12 == Expansion ROM Address */
  669. rtas_write_config(pdn, 12*4, 4, pdn->config_space[12]);
  670. #define BYTE_SWAP(OFF) (8*((OFF)/4)+3-(OFF))
  671. #define SAVED_BYTE(OFF) (((u8 *)(pdn->config_space))[BYTE_SWAP(OFF)])
  672. rtas_write_config (pdn, PCI_CACHE_LINE_SIZE, 1,
  673. SAVED_BYTE(PCI_CACHE_LINE_SIZE));
  674. rtas_write_config (pdn, PCI_LATENCY_TIMER, 1,
  675. SAVED_BYTE(PCI_LATENCY_TIMER));
  676. /* max latency, min grant, interrupt pin and line */
  677. rtas_write_config(pdn, 15*4, 4, pdn->config_space[15]);
  678. }
  679. /**
  680. * eeh_restore_bars - restore the PCI config space info
  681. *
  682. * This routine performs a recursive walk to the children
  683. * of this device as well.
  684. */
  685. void eeh_restore_bars(struct pci_dn *pdn)
  686. {
  687. struct device_node *dn;
  688. if (!pdn)
  689. return;
  690. if ((pdn->eeh_mode & EEH_MODE_SUPPORTED) && !IS_BRIDGE(pdn->class_code))
  691. __restore_bars (pdn);
  692. dn = pdn->node->child;
  693. while (dn) {
  694. eeh_restore_bars (PCI_DN(dn));
  695. dn = dn->sibling;
  696. }
  697. }
  698. /**
  699. * eeh_save_bars - save device bars
  700. *
  701. * Save the values of the device bars. Unlike the restore
  702. * routine, this routine is *not* recursive. This is because
  703. * PCI devices are added individuallly; but, for the restore,
  704. * an entire slot is reset at a time.
  705. */
  706. static void eeh_save_bars(struct pci_dn *pdn)
  707. {
  708. int i;
  709. if (!pdn )
  710. return;
  711. for (i = 0; i < 16; i++)
  712. rtas_read_config(pdn, i * 4, 4, &pdn->config_space[i]);
  713. }
  714. void
  715. rtas_configure_bridge(struct pci_dn *pdn)
  716. {
  717. int config_addr;
  718. int rc;
  719. /* Use PE configuration address, if present */
  720. config_addr = pdn->eeh_config_addr;
  721. if (pdn->eeh_pe_config_addr)
  722. config_addr = pdn->eeh_pe_config_addr;
  723. rc = rtas_call(ibm_configure_bridge,3,1, NULL,
  724. config_addr,
  725. BUID_HI(pdn->phb->buid),
  726. BUID_LO(pdn->phb->buid));
  727. if (rc) {
  728. printk (KERN_WARNING "EEH: Unable to configure device bridge (%d) for %s\n",
  729. rc, pdn->node->full_name);
  730. }
  731. }
  732. /* ------------------------------------------------------------- */
  733. /* The code below deals with enabling EEH for devices during the
  734. * early boot sequence. EEH must be enabled before any PCI probing
  735. * can be done.
  736. */
  737. #define EEH_ENABLE 1
  738. struct eeh_early_enable_info {
  739. unsigned int buid_hi;
  740. unsigned int buid_lo;
  741. };
  742. static int get_pe_addr (int config_addr,
  743. struct eeh_early_enable_info *info)
  744. {
  745. unsigned int rets[3];
  746. int ret;
  747. /* Use latest config-addr token on power6 */
  748. if (ibm_get_config_addr_info2 != RTAS_UNKNOWN_SERVICE) {
  749. /* Make sure we have a PE in hand */
  750. ret = rtas_call (ibm_get_config_addr_info2, 4, 2, rets,
  751. config_addr, info->buid_hi, info->buid_lo, 1);
  752. if (ret || (rets[0]==0))
  753. return 0;
  754. ret = rtas_call (ibm_get_config_addr_info2, 4, 2, rets,
  755. config_addr, info->buid_hi, info->buid_lo, 0);
  756. if (ret)
  757. return 0;
  758. return rets[0];
  759. }
  760. /* Use older config-addr token on power5 */
  761. if (ibm_get_config_addr_info != RTAS_UNKNOWN_SERVICE) {
  762. ret = rtas_call (ibm_get_config_addr_info, 4, 2, rets,
  763. config_addr, info->buid_hi, info->buid_lo, 0);
  764. if (ret)
  765. return 0;
  766. return rets[0];
  767. }
  768. return 0;
  769. }
  770. /* Enable eeh for the given device node. */
  771. static void *early_enable_eeh(struct device_node *dn, void *data)
  772. {
  773. unsigned int rets[3];
  774. struct eeh_early_enable_info *info = data;
  775. int ret;
  776. const char *status = of_get_property(dn, "status", NULL);
  777. const u32 *class_code = of_get_property(dn, "class-code", NULL);
  778. const u32 *vendor_id = of_get_property(dn, "vendor-id", NULL);
  779. const u32 *device_id = of_get_property(dn, "device-id", NULL);
  780. const u32 *regs;
  781. int enable;
  782. struct pci_dn *pdn = PCI_DN(dn);
  783. pdn->class_code = 0;
  784. pdn->eeh_mode = 0;
  785. pdn->eeh_check_count = 0;
  786. pdn->eeh_freeze_count = 0;
  787. pdn->eeh_false_positives = 0;
  788. if (status && strcmp(status, "ok") != 0)
  789. return NULL; /* ignore devices with bad status */
  790. /* Ignore bad nodes. */
  791. if (!class_code || !vendor_id || !device_id)
  792. return NULL;
  793. /* There is nothing to check on PCI to ISA bridges */
  794. if (dn->type && !strcmp(dn->type, "isa")) {
  795. pdn->eeh_mode |= EEH_MODE_NOCHECK;
  796. return NULL;
  797. }
  798. pdn->class_code = *class_code;
  799. /*
  800. * Now decide if we are going to "Disable" EEH checking
  801. * for this device. We still run with the EEH hardware active,
  802. * but we won't be checking for ff's. This means a driver
  803. * could return bad data (very bad!), an interrupt handler could
  804. * hang waiting on status bits that won't change, etc.
  805. * But there are a few cases like display devices that make sense.
  806. */
  807. enable = 1; /* i.e. we will do checking */
  808. #if 0
  809. if ((*class_code >> 16) == PCI_BASE_CLASS_DISPLAY)
  810. enable = 0;
  811. #endif
  812. if (!enable)
  813. pdn->eeh_mode |= EEH_MODE_NOCHECK;
  814. /* Ok... see if this device supports EEH. Some do, some don't,
  815. * and the only way to find out is to check each and every one. */
  816. regs = of_get_property(dn, "reg", NULL);
  817. if (regs) {
  818. /* First register entry is addr (00BBSS00) */
  819. /* Try to enable eeh */
  820. ret = rtas_call(ibm_set_eeh_option, 4, 1, NULL,
  821. regs[0], info->buid_hi, info->buid_lo,
  822. EEH_ENABLE);
  823. enable = 0;
  824. if (ret == 0) {
  825. pdn->eeh_config_addr = regs[0];
  826. /* If the newer, better, ibm,get-config-addr-info is supported,
  827. * then use that instead. */
  828. pdn->eeh_pe_config_addr = get_pe_addr(pdn->eeh_config_addr, info);
  829. /* Some older systems (Power4) allow the
  830. * ibm,set-eeh-option call to succeed even on nodes
  831. * where EEH is not supported. Verify support
  832. * explicitly. */
  833. ret = read_slot_reset_state(pdn, rets);
  834. if ((ret == 0) && (rets[1] == 1))
  835. enable = 1;
  836. }
  837. if (enable) {
  838. eeh_subsystem_enabled = 1;
  839. pdn->eeh_mode |= EEH_MODE_SUPPORTED;
  840. #ifdef DEBUG
  841. printk(KERN_DEBUG "EEH: %s: eeh enabled, config=%x pe_config=%x\n",
  842. dn->full_name, pdn->eeh_config_addr, pdn->eeh_pe_config_addr);
  843. #endif
  844. } else {
  845. /* This device doesn't support EEH, but it may have an
  846. * EEH parent, in which case we mark it as supported. */
  847. if (dn->parent && PCI_DN(dn->parent)
  848. && (PCI_DN(dn->parent)->eeh_mode & EEH_MODE_SUPPORTED)) {
  849. /* Parent supports EEH. */
  850. pdn->eeh_mode |= EEH_MODE_SUPPORTED;
  851. pdn->eeh_config_addr = PCI_DN(dn->parent)->eeh_config_addr;
  852. return NULL;
  853. }
  854. }
  855. } else {
  856. printk(KERN_WARNING "EEH: %s: unable to get reg property.\n",
  857. dn->full_name);
  858. }
  859. eeh_save_bars(pdn);
  860. return NULL;
  861. }
  862. /*
  863. * Initialize EEH by trying to enable it for all of the adapters in the system.
  864. * As a side effect we can determine here if eeh is supported at all.
  865. * Note that we leave EEH on so failed config cycles won't cause a machine
  866. * check. If a user turns off EEH for a particular adapter they are really
  867. * telling Linux to ignore errors. Some hardware (e.g. POWER5) won't
  868. * grant access to a slot if EEH isn't enabled, and so we always enable
  869. * EEH for all slots/all devices.
  870. *
  871. * The eeh-force-off option disables EEH checking globally, for all slots.
  872. * Even if force-off is set, the EEH hardware is still enabled, so that
  873. * newer systems can boot.
  874. */
  875. void __init eeh_init(void)
  876. {
  877. struct device_node *phb, *np;
  878. struct eeh_early_enable_info info;
  879. spin_lock_init(&confirm_error_lock);
  880. spin_lock_init(&slot_errbuf_lock);
  881. np = of_find_node_by_path("/rtas");
  882. if (np == NULL)
  883. return;
  884. ibm_set_eeh_option = rtas_token("ibm,set-eeh-option");
  885. ibm_set_slot_reset = rtas_token("ibm,set-slot-reset");
  886. ibm_read_slot_reset_state2 = rtas_token("ibm,read-slot-reset-state2");
  887. ibm_read_slot_reset_state = rtas_token("ibm,read-slot-reset-state");
  888. ibm_slot_error_detail = rtas_token("ibm,slot-error-detail");
  889. ibm_get_config_addr_info = rtas_token("ibm,get-config-addr-info");
  890. ibm_get_config_addr_info2 = rtas_token("ibm,get-config-addr-info2");
  891. ibm_configure_bridge = rtas_token ("ibm,configure-bridge");
  892. if (ibm_set_eeh_option == RTAS_UNKNOWN_SERVICE)
  893. return;
  894. eeh_error_buf_size = rtas_token("rtas-error-log-max");
  895. if (eeh_error_buf_size == RTAS_UNKNOWN_SERVICE) {
  896. eeh_error_buf_size = 1024;
  897. }
  898. if (eeh_error_buf_size > RTAS_ERROR_LOG_MAX) {
  899. printk(KERN_WARNING "EEH: rtas-error-log-max is bigger than allocated "
  900. "buffer ! (%d vs %d)", eeh_error_buf_size, RTAS_ERROR_LOG_MAX);
  901. eeh_error_buf_size = RTAS_ERROR_LOG_MAX;
  902. }
  903. /* Enable EEH for all adapters. Note that eeh requires buid's */
  904. for (phb = of_find_node_by_name(NULL, "pci"); phb;
  905. phb = of_find_node_by_name(phb, "pci")) {
  906. unsigned long buid;
  907. buid = get_phb_buid(phb);
  908. if (buid == 0 || PCI_DN(phb) == NULL)
  909. continue;
  910. info.buid_lo = BUID_LO(buid);
  911. info.buid_hi = BUID_HI(buid);
  912. traverse_pci_devices(phb, early_enable_eeh, &info);
  913. }
  914. if (eeh_subsystem_enabled)
  915. printk(KERN_INFO "EEH: PCI Enhanced I/O Error Handling Enabled\n");
  916. else
  917. printk(KERN_WARNING "EEH: No capable adapters found\n");
  918. }
  919. /**
  920. * eeh_add_device_early - enable EEH for the indicated device_node
  921. * @dn: device node for which to set up EEH
  922. *
  923. * This routine must be used to perform EEH initialization for PCI
  924. * devices that were added after system boot (e.g. hotplug, dlpar).
  925. * This routine must be called before any i/o is performed to the
  926. * adapter (inluding any config-space i/o).
  927. * Whether this actually enables EEH or not for this device depends
  928. * on the CEC architecture, type of the device, on earlier boot
  929. * command-line arguments & etc.
  930. */
  931. static void eeh_add_device_early(struct device_node *dn)
  932. {
  933. struct pci_controller *phb;
  934. struct eeh_early_enable_info info;
  935. if (!dn || !PCI_DN(dn))
  936. return;
  937. phb = PCI_DN(dn)->phb;
  938. /* USB Bus children of PCI devices will not have BUID's */
  939. if (NULL == phb || 0 == phb->buid)
  940. return;
  941. info.buid_hi = BUID_HI(phb->buid);
  942. info.buid_lo = BUID_LO(phb->buid);
  943. early_enable_eeh(dn, &info);
  944. }
  945. void eeh_add_device_tree_early(struct device_node *dn)
  946. {
  947. struct device_node *sib;
  948. for (sib = dn->child; sib; sib = sib->sibling)
  949. eeh_add_device_tree_early(sib);
  950. eeh_add_device_early(dn);
  951. }
  952. EXPORT_SYMBOL_GPL(eeh_add_device_tree_early);
  953. /**
  954. * eeh_add_device_late - perform EEH initialization for the indicated pci device
  955. * @dev: pci device for which to set up EEH
  956. *
  957. * This routine must be used to complete EEH initialization for PCI
  958. * devices that were added after system boot (e.g. hotplug, dlpar).
  959. */
  960. static void eeh_add_device_late(struct pci_dev *dev)
  961. {
  962. struct device_node *dn;
  963. struct pci_dn *pdn;
  964. if (!dev || !eeh_subsystem_enabled)
  965. return;
  966. #ifdef DEBUG
  967. printk(KERN_DEBUG "EEH: adding device %s\n", pci_name(dev));
  968. #endif
  969. pci_dev_get (dev);
  970. dn = pci_device_to_OF_node(dev);
  971. pdn = PCI_DN(dn);
  972. pdn->pcidev = dev;
  973. pci_addr_cache_insert_device(dev);
  974. eeh_sysfs_add_device(dev);
  975. }
  976. void eeh_add_device_tree_late(struct pci_bus *bus)
  977. {
  978. struct pci_dev *dev;
  979. list_for_each_entry(dev, &bus->devices, bus_list) {
  980. eeh_add_device_late(dev);
  981. if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
  982. struct pci_bus *subbus = dev->subordinate;
  983. if (subbus)
  984. eeh_add_device_tree_late(subbus);
  985. }
  986. }
  987. }
  988. EXPORT_SYMBOL_GPL(eeh_add_device_tree_late);
  989. /**
  990. * eeh_remove_device - undo EEH setup for the indicated pci device
  991. * @dev: pci device to be removed
  992. *
  993. * This routine should be called when a device is removed from
  994. * a running system (e.g. by hotplug or dlpar). It unregisters
  995. * the PCI device from the EEH subsystem. I/O errors affecting
  996. * this device will no longer be detected after this call; thus,
  997. * i/o errors affecting this slot may leave this device unusable.
  998. */
  999. static void eeh_remove_device(struct pci_dev *dev)
  1000. {
  1001. struct device_node *dn;
  1002. if (!dev || !eeh_subsystem_enabled)
  1003. return;
  1004. /* Unregister the device with the EEH/PCI address search system */
  1005. #ifdef DEBUG
  1006. printk(KERN_DEBUG "EEH: remove device %s\n", pci_name(dev));
  1007. #endif
  1008. pci_addr_cache_remove_device(dev);
  1009. eeh_sysfs_remove_device(dev);
  1010. dn = pci_device_to_OF_node(dev);
  1011. if (PCI_DN(dn)->pcidev) {
  1012. PCI_DN(dn)->pcidev = NULL;
  1013. pci_dev_put (dev);
  1014. }
  1015. }
  1016. void eeh_remove_bus_device(struct pci_dev *dev)
  1017. {
  1018. struct pci_bus *bus = dev->subordinate;
  1019. struct pci_dev *child, *tmp;
  1020. eeh_remove_device(dev);
  1021. if (bus && dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
  1022. list_for_each_entry_safe(child, tmp, &bus->devices, bus_list)
  1023. eeh_remove_bus_device(child);
  1024. }
  1025. }
  1026. EXPORT_SYMBOL_GPL(eeh_remove_bus_device);
  1027. static int proc_eeh_show(struct seq_file *m, void *v)
  1028. {
  1029. if (0 == eeh_subsystem_enabled) {
  1030. seq_printf(m, "EEH Subsystem is globally disabled\n");
  1031. seq_printf(m, "eeh_total_mmio_ffs=%ld\n", total_mmio_ffs);
  1032. } else {
  1033. seq_printf(m, "EEH Subsystem is enabled\n");
  1034. seq_printf(m,
  1035. "no device=%ld\n"
  1036. "no device node=%ld\n"
  1037. "no config address=%ld\n"
  1038. "check not wanted=%ld\n"
  1039. "eeh_total_mmio_ffs=%ld\n"
  1040. "eeh_false_positives=%ld\n"
  1041. "eeh_ignored_failures=%ld\n"
  1042. "eeh_slot_resets=%ld\n",
  1043. no_device, no_dn, no_cfg_addr,
  1044. ignored_check, total_mmio_ffs,
  1045. false_positives, ignored_failures,
  1046. slot_resets);
  1047. }
  1048. return 0;
  1049. }
  1050. static int proc_eeh_open(struct inode *inode, struct file *file)
  1051. {
  1052. return single_open(file, proc_eeh_show, NULL);
  1053. }
  1054. static const struct file_operations proc_eeh_operations = {
  1055. .open = proc_eeh_open,
  1056. .read = seq_read,
  1057. .llseek = seq_lseek,
  1058. .release = single_release,
  1059. };
  1060. static int __init eeh_init_proc(void)
  1061. {
  1062. struct proc_dir_entry *e;
  1063. if (machine_is(pseries)) {
  1064. e = create_proc_entry("ppc64/eeh", 0, NULL);
  1065. if (e)
  1066. e->proc_fops = &proc_eeh_operations;
  1067. }
  1068. return 0;
  1069. }
  1070. __initcall(eeh_init_proc);