eeh.c 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833
  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/iommu.h>
  29. #include <linux/proc_fs.h>
  30. #include <linux/rbtree.h>
  31. #include <linux/reboot.h>
  32. #include <linux/seq_file.h>
  33. #include <linux/spinlock.h>
  34. #include <linux/export.h>
  35. #include <linux/of.h>
  36. #include <linux/atomic.h>
  37. #include <asm/debugfs.h>
  38. #include <asm/eeh.h>
  39. #include <asm/eeh_event.h>
  40. #include <asm/io.h>
  41. #include <asm/iommu.h>
  42. #include <asm/machdep.h>
  43. #include <asm/ppc-pci.h>
  44. #include <asm/rtas.h>
  45. #include <asm/pte-walk.h>
  46. /** Overview:
  47. * EEH, or "Enhanced Error Handling" is a PCI bridge technology for
  48. * dealing with PCI bus errors that can't be dealt with within the
  49. * usual PCI framework, except by check-stopping the CPU. Systems
  50. * that are designed for high-availability/reliability cannot afford
  51. * to crash due to a "mere" PCI error, thus the need for EEH.
  52. * An EEH-capable bridge operates by converting a detected error
  53. * into a "slot freeze", taking the PCI adapter off-line, making
  54. * the slot behave, from the OS'es point of view, as if the slot
  55. * were "empty": all reads return 0xff's and all writes are silently
  56. * ignored. EEH slot isolation events can be triggered by parity
  57. * errors on the address or data busses (e.g. during posted writes),
  58. * which in turn might be caused by low voltage on the bus, dust,
  59. * vibration, humidity, radioactivity or plain-old failed hardware.
  60. *
  61. * Note, however, that one of the leading causes of EEH slot
  62. * freeze events are buggy device drivers, buggy device microcode,
  63. * or buggy device hardware. This is because any attempt by the
  64. * device to bus-master data to a memory address that is not
  65. * assigned to the device will trigger a slot freeze. (The idea
  66. * is to prevent devices-gone-wild from corrupting system memory).
  67. * Buggy hardware/drivers will have a miserable time co-existing
  68. * with EEH.
  69. *
  70. * Ideally, a PCI device driver, when suspecting that an isolation
  71. * event has occurred (e.g. by reading 0xff's), will then ask EEH
  72. * whether this is the case, and then take appropriate steps to
  73. * reset the PCI slot, the PCI device, and then resume operations.
  74. * However, until that day, the checking is done here, with the
  75. * eeh_check_failure() routine embedded in the MMIO macros. If
  76. * the slot is found to be isolated, an "EEH Event" is synthesized
  77. * and sent out for processing.
  78. */
  79. /* If a device driver keeps reading an MMIO register in an interrupt
  80. * handler after a slot isolation event, it might be broken.
  81. * This sets the threshold for how many read attempts we allow
  82. * before printing an error message.
  83. */
  84. #define EEH_MAX_FAILS 2100000
  85. /* Time to wait for a PCI slot to report status, in milliseconds */
  86. #define PCI_BUS_RESET_WAIT_MSEC (5*60*1000)
  87. /*
  88. * EEH probe mode support, which is part of the flags,
  89. * is to support multiple platforms for EEH. Some platforms
  90. * like pSeries do PCI emunation based on device tree.
  91. * However, other platforms like powernv probe PCI devices
  92. * from hardware. The flag is used to distinguish that.
  93. * In addition, struct eeh_ops::probe would be invoked for
  94. * particular OF node or PCI device so that the corresponding
  95. * PE would be created there.
  96. */
  97. int eeh_subsystem_flags;
  98. EXPORT_SYMBOL(eeh_subsystem_flags);
  99. /*
  100. * EEH allowed maximal frozen times. If one particular PE's
  101. * frozen count in last hour exceeds this limit, the PE will
  102. * be forced to be offline permanently.
  103. */
  104. int eeh_max_freezes = 5;
  105. /* Platform dependent EEH operations */
  106. struct eeh_ops *eeh_ops = NULL;
  107. /* Lock to avoid races due to multiple reports of an error */
  108. DEFINE_RAW_SPINLOCK(confirm_error_lock);
  109. EXPORT_SYMBOL_GPL(confirm_error_lock);
  110. /* Lock to protect passed flags */
  111. static DEFINE_MUTEX(eeh_dev_mutex);
  112. /* Buffer for reporting pci register dumps. Its here in BSS, and
  113. * not dynamically alloced, so that it ends up in RMO where RTAS
  114. * can access it.
  115. */
  116. #define EEH_PCI_REGS_LOG_LEN 8192
  117. static unsigned char pci_regs_buf[EEH_PCI_REGS_LOG_LEN];
  118. /*
  119. * The struct is used to maintain the EEH global statistic
  120. * information. Besides, the EEH global statistics will be
  121. * exported to user space through procfs
  122. */
  123. struct eeh_stats {
  124. u64 no_device; /* PCI device not found */
  125. u64 no_dn; /* OF node not found */
  126. u64 no_cfg_addr; /* Config address not found */
  127. u64 ignored_check; /* EEH check skipped */
  128. u64 total_mmio_ffs; /* Total EEH checks */
  129. u64 false_positives; /* Unnecessary EEH checks */
  130. u64 slot_resets; /* PE reset */
  131. };
  132. static struct eeh_stats eeh_stats;
  133. static int __init eeh_setup(char *str)
  134. {
  135. if (!strcmp(str, "off"))
  136. eeh_add_flag(EEH_FORCE_DISABLED);
  137. else if (!strcmp(str, "early_log"))
  138. eeh_add_flag(EEH_EARLY_DUMP_LOG);
  139. return 1;
  140. }
  141. __setup("eeh=", eeh_setup);
  142. /*
  143. * This routine captures assorted PCI configuration space data
  144. * for the indicated PCI device, and puts them into a buffer
  145. * for RTAS error logging.
  146. */
  147. static size_t eeh_dump_dev_log(struct eeh_dev *edev, char *buf, size_t len)
  148. {
  149. struct pci_dn *pdn = eeh_dev_to_pdn(edev);
  150. u32 cfg;
  151. int cap, i;
  152. int n = 0, l = 0;
  153. char buffer[128];
  154. if (!pdn) {
  155. pr_warn("EEH: Note: No error log for absent device.\n");
  156. return 0;
  157. }
  158. n += scnprintf(buf+n, len-n, "%04x:%02x:%02x.%01x\n",
  159. pdn->phb->global_number, pdn->busno,
  160. PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));
  161. pr_warn("EEH: of node=%04x:%02x:%02x.%01x\n",
  162. pdn->phb->global_number, pdn->busno,
  163. PCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));
  164. eeh_ops->read_config(pdn, PCI_VENDOR_ID, 4, &cfg);
  165. n += scnprintf(buf+n, len-n, "dev/vend:%08x\n", cfg);
  166. pr_warn("EEH: PCI device/vendor: %08x\n", cfg);
  167. eeh_ops->read_config(pdn, PCI_COMMAND, 4, &cfg);
  168. n += scnprintf(buf+n, len-n, "cmd/stat:%x\n", cfg);
  169. pr_warn("EEH: PCI cmd/status register: %08x\n", cfg);
  170. /* Gather bridge-specific registers */
  171. if (edev->mode & EEH_DEV_BRIDGE) {
  172. eeh_ops->read_config(pdn, PCI_SEC_STATUS, 2, &cfg);
  173. n += scnprintf(buf+n, len-n, "sec stat:%x\n", cfg);
  174. pr_warn("EEH: Bridge secondary status: %04x\n", cfg);
  175. eeh_ops->read_config(pdn, PCI_BRIDGE_CONTROL, 2, &cfg);
  176. n += scnprintf(buf+n, len-n, "brdg ctl:%x\n", cfg);
  177. pr_warn("EEH: Bridge control: %04x\n", cfg);
  178. }
  179. /* Dump out the PCI-X command and status regs */
  180. cap = edev->pcix_cap;
  181. if (cap) {
  182. eeh_ops->read_config(pdn, cap, 4, &cfg);
  183. n += scnprintf(buf+n, len-n, "pcix-cmd:%x\n", cfg);
  184. pr_warn("EEH: PCI-X cmd: %08x\n", cfg);
  185. eeh_ops->read_config(pdn, cap+4, 4, &cfg);
  186. n += scnprintf(buf+n, len-n, "pcix-stat:%x\n", cfg);
  187. pr_warn("EEH: PCI-X status: %08x\n", cfg);
  188. }
  189. /* If PCI-E capable, dump PCI-E cap 10 */
  190. cap = edev->pcie_cap;
  191. if (cap) {
  192. n += scnprintf(buf+n, len-n, "pci-e cap10:\n");
  193. pr_warn("EEH: PCI-E capabilities and status follow:\n");
  194. for (i=0; i<=8; i++) {
  195. eeh_ops->read_config(pdn, cap+4*i, 4, &cfg);
  196. n += scnprintf(buf+n, len-n, "%02x:%x\n", 4*i, cfg);
  197. if ((i % 4) == 0) {
  198. if (i != 0)
  199. pr_warn("%s\n", buffer);
  200. l = scnprintf(buffer, sizeof(buffer),
  201. "EEH: PCI-E %02x: %08x ",
  202. 4*i, cfg);
  203. } else {
  204. l += scnprintf(buffer+l, sizeof(buffer)-l,
  205. "%08x ", cfg);
  206. }
  207. }
  208. pr_warn("%s\n", buffer);
  209. }
  210. /* If AER capable, dump it */
  211. cap = edev->aer_cap;
  212. if (cap) {
  213. n += scnprintf(buf+n, len-n, "pci-e AER:\n");
  214. pr_warn("EEH: PCI-E AER capability register set follows:\n");
  215. for (i=0; i<=13; i++) {
  216. eeh_ops->read_config(pdn, cap+4*i, 4, &cfg);
  217. n += scnprintf(buf+n, len-n, "%02x:%x\n", 4*i, cfg);
  218. if ((i % 4) == 0) {
  219. if (i != 0)
  220. pr_warn("%s\n", buffer);
  221. l = scnprintf(buffer, sizeof(buffer),
  222. "EEH: PCI-E AER %02x: %08x ",
  223. 4*i, cfg);
  224. } else {
  225. l += scnprintf(buffer+l, sizeof(buffer)-l,
  226. "%08x ", cfg);
  227. }
  228. }
  229. pr_warn("%s\n", buffer);
  230. }
  231. return n;
  232. }
  233. static void *eeh_dump_pe_log(struct eeh_pe *pe, void *flag)
  234. {
  235. struct eeh_dev *edev, *tmp;
  236. size_t *plen = flag;
  237. eeh_pe_for_each_dev(pe, edev, tmp)
  238. *plen += eeh_dump_dev_log(edev, pci_regs_buf + *plen,
  239. EEH_PCI_REGS_LOG_LEN - *plen);
  240. return NULL;
  241. }
  242. /**
  243. * eeh_slot_error_detail - Generate combined log including driver log and error log
  244. * @pe: EEH PE
  245. * @severity: temporary or permanent error log
  246. *
  247. * This routine should be called to generate the combined log, which
  248. * is comprised of driver log and error log. The driver log is figured
  249. * out from the config space of the corresponding PCI device, while
  250. * the error log is fetched through platform dependent function call.
  251. */
  252. void eeh_slot_error_detail(struct eeh_pe *pe, int severity)
  253. {
  254. size_t loglen = 0;
  255. /*
  256. * When the PHB is fenced or dead, it's pointless to collect
  257. * the data from PCI config space because it should return
  258. * 0xFF's. For ER, we still retrieve the data from the PCI
  259. * config space.
  260. *
  261. * For pHyp, we have to enable IO for log retrieval. Otherwise,
  262. * 0xFF's is always returned from PCI config space.
  263. *
  264. * When the @severity is EEH_LOG_PERM, the PE is going to be
  265. * removed. Prior to that, the drivers for devices included in
  266. * the PE will be closed. The drivers rely on working IO path
  267. * to bring the devices to quiet state. Otherwise, PCI traffic
  268. * from those devices after they are removed is like to cause
  269. * another unexpected EEH error.
  270. */
  271. if (!(pe->type & EEH_PE_PHB)) {
  272. if (eeh_has_flag(EEH_ENABLE_IO_FOR_LOG) ||
  273. severity == EEH_LOG_PERM)
  274. eeh_pci_enable(pe, EEH_OPT_THAW_MMIO);
  275. /*
  276. * The config space of some PCI devices can't be accessed
  277. * when their PEs are in frozen state. Otherwise, fenced
  278. * PHB might be seen. Those PEs are identified with flag
  279. * EEH_PE_CFG_RESTRICTED, indicating EEH_PE_CFG_BLOCKED
  280. * is set automatically when the PE is put to EEH_PE_ISOLATED.
  281. *
  282. * Restoring BARs possibly triggers PCI config access in
  283. * (OPAL) firmware and then causes fenced PHB. If the
  284. * PCI config is blocked with flag EEH_PE_CFG_BLOCKED, it's
  285. * pointless to restore BARs and dump config space.
  286. */
  287. eeh_ops->configure_bridge(pe);
  288. if (!(pe->state & EEH_PE_CFG_BLOCKED)) {
  289. eeh_pe_restore_bars(pe);
  290. pci_regs_buf[0] = 0;
  291. eeh_pe_traverse(pe, eeh_dump_pe_log, &loglen);
  292. }
  293. }
  294. eeh_ops->get_log(pe, severity, pci_regs_buf, loglen);
  295. }
  296. /**
  297. * eeh_token_to_phys - Convert EEH address token to phys address
  298. * @token: I/O token, should be address in the form 0xA....
  299. *
  300. * This routine should be called to convert virtual I/O address
  301. * to physical one.
  302. */
  303. static inline unsigned long eeh_token_to_phys(unsigned long token)
  304. {
  305. pte_t *ptep;
  306. unsigned long pa;
  307. int hugepage_shift;
  308. /*
  309. * We won't find hugepages here(this is iomem). Hence we are not
  310. * worried about _PAGE_SPLITTING/collapse. Also we will not hit
  311. * page table free, because of init_mm.
  312. */
  313. ptep = find_init_mm_pte(token, &hugepage_shift);
  314. if (!ptep)
  315. return token;
  316. WARN_ON(hugepage_shift);
  317. pa = pte_pfn(*ptep) << PAGE_SHIFT;
  318. return pa | (token & (PAGE_SIZE-1));
  319. }
  320. /*
  321. * On PowerNV platform, we might already have fenced PHB there.
  322. * For that case, it's meaningless to recover frozen PE. Intead,
  323. * We have to handle fenced PHB firstly.
  324. */
  325. static int eeh_phb_check_failure(struct eeh_pe *pe)
  326. {
  327. struct eeh_pe *phb_pe;
  328. unsigned long flags;
  329. int ret;
  330. if (!eeh_has_flag(EEH_PROBE_MODE_DEV))
  331. return -EPERM;
  332. /* Find the PHB PE */
  333. phb_pe = eeh_phb_pe_get(pe->phb);
  334. if (!phb_pe) {
  335. pr_warn("%s Can't find PE for PHB#%x\n",
  336. __func__, pe->phb->global_number);
  337. return -EEXIST;
  338. }
  339. /* If the PHB has been in problematic state */
  340. eeh_serialize_lock(&flags);
  341. if (phb_pe->state & EEH_PE_ISOLATED) {
  342. ret = 0;
  343. goto out;
  344. }
  345. /* Check PHB state */
  346. ret = eeh_ops->get_state(phb_pe, NULL);
  347. if ((ret < 0) ||
  348. (ret == EEH_STATE_NOT_SUPPORT) || eeh_state_active(ret)) {
  349. ret = 0;
  350. goto out;
  351. }
  352. /* Isolate the PHB and send event */
  353. eeh_pe_mark_isolated(phb_pe);
  354. eeh_serialize_unlock(flags);
  355. pr_err("EEH: PHB#%x failure detected, location: %s\n",
  356. phb_pe->phb->global_number, eeh_pe_loc_get(phb_pe));
  357. dump_stack();
  358. eeh_send_failure_event(phb_pe);
  359. return 1;
  360. out:
  361. eeh_serialize_unlock(flags);
  362. return ret;
  363. }
  364. /**
  365. * eeh_dev_check_failure - Check if all 1's data is due to EEH slot freeze
  366. * @edev: eeh device
  367. *
  368. * Check for an EEH failure for the given device node. Call this
  369. * routine if the result of a read was all 0xff's and you want to
  370. * find out if this is due to an EEH slot freeze. This routine
  371. * will query firmware for the EEH status.
  372. *
  373. * Returns 0 if there has not been an EEH error; otherwise returns
  374. * a non-zero value and queues up a slot isolation event notification.
  375. *
  376. * It is safe to call this routine in an interrupt context.
  377. */
  378. int eeh_dev_check_failure(struct eeh_dev *edev)
  379. {
  380. int ret;
  381. unsigned long flags;
  382. struct device_node *dn;
  383. struct pci_dev *dev;
  384. struct eeh_pe *pe, *parent_pe, *phb_pe;
  385. int rc = 0;
  386. const char *location = NULL;
  387. eeh_stats.total_mmio_ffs++;
  388. if (!eeh_enabled())
  389. return 0;
  390. if (!edev) {
  391. eeh_stats.no_dn++;
  392. return 0;
  393. }
  394. dev = eeh_dev_to_pci_dev(edev);
  395. pe = eeh_dev_to_pe(edev);
  396. /* Access to IO BARs might get this far and still not want checking. */
  397. if (!pe) {
  398. eeh_stats.ignored_check++;
  399. pr_debug("EEH: Ignored check for %s\n",
  400. eeh_pci_name(dev));
  401. return 0;
  402. }
  403. if (!pe->addr && !pe->config_addr) {
  404. eeh_stats.no_cfg_addr++;
  405. return 0;
  406. }
  407. /*
  408. * On PowerNV platform, we might already have fenced PHB
  409. * there and we need take care of that firstly.
  410. */
  411. ret = eeh_phb_check_failure(pe);
  412. if (ret > 0)
  413. return ret;
  414. /*
  415. * If the PE isn't owned by us, we shouldn't check the
  416. * state. Instead, let the owner handle it if the PE has
  417. * been frozen.
  418. */
  419. if (eeh_pe_passed(pe))
  420. return 0;
  421. /* If we already have a pending isolation event for this
  422. * slot, we know it's bad already, we don't need to check.
  423. * Do this checking under a lock; as multiple PCI devices
  424. * in one slot might report errors simultaneously, and we
  425. * only want one error recovery routine running.
  426. */
  427. eeh_serialize_lock(&flags);
  428. rc = 1;
  429. if (pe->state & EEH_PE_ISOLATED) {
  430. pe->check_count++;
  431. if (pe->check_count % EEH_MAX_FAILS == 0) {
  432. dn = pci_device_to_OF_node(dev);
  433. if (dn)
  434. location = of_get_property(dn, "ibm,loc-code",
  435. NULL);
  436. printk(KERN_ERR "EEH: %d reads ignored for recovering device at "
  437. "location=%s driver=%s pci addr=%s\n",
  438. pe->check_count,
  439. location ? location : "unknown",
  440. eeh_driver_name(dev), eeh_pci_name(dev));
  441. printk(KERN_ERR "EEH: Might be infinite loop in %s driver\n",
  442. eeh_driver_name(dev));
  443. dump_stack();
  444. }
  445. goto dn_unlock;
  446. }
  447. /*
  448. * Now test for an EEH failure. This is VERY expensive.
  449. * Note that the eeh_config_addr may be a parent device
  450. * in the case of a device behind a bridge, or it may be
  451. * function zero of a multi-function device.
  452. * In any case they must share a common PHB.
  453. */
  454. ret = eeh_ops->get_state(pe, NULL);
  455. /* Note that config-io to empty slots may fail;
  456. * they are empty when they don't have children.
  457. * We will punt with the following conditions: Failure to get
  458. * PE's state, EEH not support and Permanently unavailable
  459. * state, PE is in good state.
  460. */
  461. if ((ret < 0) ||
  462. (ret == EEH_STATE_NOT_SUPPORT) || eeh_state_active(ret)) {
  463. eeh_stats.false_positives++;
  464. pe->false_positives++;
  465. rc = 0;
  466. goto dn_unlock;
  467. }
  468. /*
  469. * It should be corner case that the parent PE has been
  470. * put into frozen state as well. We should take care
  471. * that at first.
  472. */
  473. parent_pe = pe->parent;
  474. while (parent_pe) {
  475. /* Hit the ceiling ? */
  476. if (parent_pe->type & EEH_PE_PHB)
  477. break;
  478. /* Frozen parent PE ? */
  479. ret = eeh_ops->get_state(parent_pe, NULL);
  480. if (ret > 0 && !eeh_state_active(ret)) {
  481. pe = parent_pe;
  482. pr_err("EEH: Failure of PHB#%x-PE#%x will be handled at parent PHB#%x-PE#%x.\n",
  483. pe->phb->global_number, pe->addr,
  484. pe->phb->global_number, parent_pe->addr);
  485. }
  486. /* Next parent level */
  487. parent_pe = parent_pe->parent;
  488. }
  489. eeh_stats.slot_resets++;
  490. /* Avoid repeated reports of this failure, including problems
  491. * with other functions on this device, and functions under
  492. * bridges.
  493. */
  494. eeh_pe_mark_isolated(pe);
  495. eeh_serialize_unlock(flags);
  496. /* Most EEH events are due to device driver bugs. Having
  497. * a stack trace will help the device-driver authors figure
  498. * out what happened. So print that out.
  499. */
  500. phb_pe = eeh_phb_pe_get(pe->phb);
  501. pr_err("EEH: Frozen PHB#%x-PE#%x detected\n",
  502. pe->phb->global_number, pe->addr);
  503. pr_err("EEH: PE location: %s, PHB location: %s\n",
  504. eeh_pe_loc_get(pe), eeh_pe_loc_get(phb_pe));
  505. dump_stack();
  506. eeh_send_failure_event(pe);
  507. return 1;
  508. dn_unlock:
  509. eeh_serialize_unlock(flags);
  510. return rc;
  511. }
  512. EXPORT_SYMBOL_GPL(eeh_dev_check_failure);
  513. /**
  514. * eeh_check_failure - Check if all 1's data is due to EEH slot freeze
  515. * @token: I/O address
  516. *
  517. * Check for an EEH failure at the given I/O address. Call this
  518. * routine if the result of a read was all 0xff's and you want to
  519. * find out if this is due to an EEH slot freeze event. This routine
  520. * will query firmware for the EEH status.
  521. *
  522. * Note this routine is safe to call in an interrupt context.
  523. */
  524. int eeh_check_failure(const volatile void __iomem *token)
  525. {
  526. unsigned long addr;
  527. struct eeh_dev *edev;
  528. /* Finding the phys addr + pci device; this is pretty quick. */
  529. addr = eeh_token_to_phys((unsigned long __force) token);
  530. edev = eeh_addr_cache_get_dev(addr);
  531. if (!edev) {
  532. eeh_stats.no_device++;
  533. return 0;
  534. }
  535. return eeh_dev_check_failure(edev);
  536. }
  537. EXPORT_SYMBOL(eeh_check_failure);
  538. /**
  539. * eeh_pci_enable - Enable MMIO or DMA transfers for this slot
  540. * @pe: EEH PE
  541. *
  542. * This routine should be called to reenable frozen MMIO or DMA
  543. * so that it would work correctly again. It's useful while doing
  544. * recovery or log collection on the indicated device.
  545. */
  546. int eeh_pci_enable(struct eeh_pe *pe, int function)
  547. {
  548. int active_flag, rc;
  549. /*
  550. * pHyp doesn't allow to enable IO or DMA on unfrozen PE.
  551. * Also, it's pointless to enable them on unfrozen PE. So
  552. * we have to check before enabling IO or DMA.
  553. */
  554. switch (function) {
  555. case EEH_OPT_THAW_MMIO:
  556. active_flag = EEH_STATE_MMIO_ACTIVE | EEH_STATE_MMIO_ENABLED;
  557. break;
  558. case EEH_OPT_THAW_DMA:
  559. active_flag = EEH_STATE_DMA_ACTIVE;
  560. break;
  561. case EEH_OPT_DISABLE:
  562. case EEH_OPT_ENABLE:
  563. case EEH_OPT_FREEZE_PE:
  564. active_flag = 0;
  565. break;
  566. default:
  567. pr_warn("%s: Invalid function %d\n",
  568. __func__, function);
  569. return -EINVAL;
  570. }
  571. /*
  572. * Check if IO or DMA has been enabled before
  573. * enabling them.
  574. */
  575. if (active_flag) {
  576. rc = eeh_ops->get_state(pe, NULL);
  577. if (rc < 0)
  578. return rc;
  579. /* Needn't enable it at all */
  580. if (rc == EEH_STATE_NOT_SUPPORT)
  581. return 0;
  582. /* It's already enabled */
  583. if (rc & active_flag)
  584. return 0;
  585. }
  586. /* Issue the request */
  587. rc = eeh_ops->set_option(pe, function);
  588. if (rc)
  589. pr_warn("%s: Unexpected state change %d on "
  590. "PHB#%x-PE#%x, err=%d\n",
  591. __func__, function, pe->phb->global_number,
  592. pe->addr, rc);
  593. /* Check if the request is finished successfully */
  594. if (active_flag) {
  595. rc = eeh_wait_state(pe, PCI_BUS_RESET_WAIT_MSEC);
  596. if (rc < 0)
  597. return rc;
  598. if (rc & active_flag)
  599. return 0;
  600. return -EIO;
  601. }
  602. return rc;
  603. }
  604. static void *eeh_disable_and_save_dev_state(struct eeh_dev *edev,
  605. void *userdata)
  606. {
  607. struct pci_dev *pdev = eeh_dev_to_pci_dev(edev);
  608. struct pci_dev *dev = userdata;
  609. /*
  610. * The caller should have disabled and saved the
  611. * state for the specified device
  612. */
  613. if (!pdev || pdev == dev)
  614. return NULL;
  615. /* Ensure we have D0 power state */
  616. pci_set_power_state(pdev, PCI_D0);
  617. /* Save device state */
  618. pci_save_state(pdev);
  619. /*
  620. * Disable device to avoid any DMA traffic and
  621. * interrupt from the device
  622. */
  623. pci_write_config_word(pdev, PCI_COMMAND, PCI_COMMAND_INTX_DISABLE);
  624. return NULL;
  625. }
  626. static void *eeh_restore_dev_state(struct eeh_dev *edev, void *userdata)
  627. {
  628. struct pci_dn *pdn = eeh_dev_to_pdn(edev);
  629. struct pci_dev *pdev = eeh_dev_to_pci_dev(edev);
  630. struct pci_dev *dev = userdata;
  631. if (!pdev)
  632. return NULL;
  633. /* Apply customization from firmware */
  634. if (pdn && eeh_ops->restore_config)
  635. eeh_ops->restore_config(pdn);
  636. /* The caller should restore state for the specified device */
  637. if (pdev != dev)
  638. pci_restore_state(pdev);
  639. return NULL;
  640. }
  641. int eeh_restore_vf_config(struct pci_dn *pdn)
  642. {
  643. struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
  644. u32 devctl, cmd, cap2, aer_capctl;
  645. int old_mps;
  646. if (edev->pcie_cap) {
  647. /* Restore MPS */
  648. old_mps = (ffs(pdn->mps) - 8) << 5;
  649. eeh_ops->read_config(pdn, edev->pcie_cap + PCI_EXP_DEVCTL,
  650. 2, &devctl);
  651. devctl &= ~PCI_EXP_DEVCTL_PAYLOAD;
  652. devctl |= old_mps;
  653. eeh_ops->write_config(pdn, edev->pcie_cap + PCI_EXP_DEVCTL,
  654. 2, devctl);
  655. /* Disable Completion Timeout if possible */
  656. eeh_ops->read_config(pdn, edev->pcie_cap + PCI_EXP_DEVCAP2,
  657. 4, &cap2);
  658. if (cap2 & PCI_EXP_DEVCAP2_COMP_TMOUT_DIS) {
  659. eeh_ops->read_config(pdn,
  660. edev->pcie_cap + PCI_EXP_DEVCTL2,
  661. 4, &cap2);
  662. cap2 |= PCI_EXP_DEVCTL2_COMP_TMOUT_DIS;
  663. eeh_ops->write_config(pdn,
  664. edev->pcie_cap + PCI_EXP_DEVCTL2,
  665. 4, cap2);
  666. }
  667. }
  668. /* Enable SERR and parity checking */
  669. eeh_ops->read_config(pdn, PCI_COMMAND, 2, &cmd);
  670. cmd |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR);
  671. eeh_ops->write_config(pdn, PCI_COMMAND, 2, cmd);
  672. /* Enable report various errors */
  673. if (edev->pcie_cap) {
  674. eeh_ops->read_config(pdn, edev->pcie_cap + PCI_EXP_DEVCTL,
  675. 2, &devctl);
  676. devctl &= ~PCI_EXP_DEVCTL_CERE;
  677. devctl |= (PCI_EXP_DEVCTL_NFERE |
  678. PCI_EXP_DEVCTL_FERE |
  679. PCI_EXP_DEVCTL_URRE);
  680. eeh_ops->write_config(pdn, edev->pcie_cap + PCI_EXP_DEVCTL,
  681. 2, devctl);
  682. }
  683. /* Enable ECRC generation and check */
  684. if (edev->pcie_cap && edev->aer_cap) {
  685. eeh_ops->read_config(pdn, edev->aer_cap + PCI_ERR_CAP,
  686. 4, &aer_capctl);
  687. aer_capctl |= (PCI_ERR_CAP_ECRC_GENE | PCI_ERR_CAP_ECRC_CHKE);
  688. eeh_ops->write_config(pdn, edev->aer_cap + PCI_ERR_CAP,
  689. 4, aer_capctl);
  690. }
  691. return 0;
  692. }
  693. /**
  694. * pcibios_set_pcie_reset_state - Set PCI-E reset state
  695. * @dev: pci device struct
  696. * @state: reset state to enter
  697. *
  698. * Return value:
  699. * 0 if success
  700. */
  701. int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
  702. {
  703. struct eeh_dev *edev = pci_dev_to_eeh_dev(dev);
  704. struct eeh_pe *pe = eeh_dev_to_pe(edev);
  705. if (!pe) {
  706. pr_err("%s: No PE found on PCI device %s\n",
  707. __func__, pci_name(dev));
  708. return -EINVAL;
  709. }
  710. switch (state) {
  711. case pcie_deassert_reset:
  712. eeh_ops->reset(pe, EEH_RESET_DEACTIVATE);
  713. eeh_unfreeze_pe(pe, false);
  714. if (!(pe->type & EEH_PE_VF))
  715. eeh_pe_state_clear(pe, EEH_PE_CFG_BLOCKED);
  716. eeh_pe_dev_traverse(pe, eeh_restore_dev_state, dev);
  717. eeh_pe_state_clear(pe, EEH_PE_ISOLATED);
  718. break;
  719. case pcie_hot_reset:
  720. eeh_pe_mark_isolated(pe);
  721. eeh_pe_state_clear(pe, EEH_PE_CFG_BLOCKED);
  722. eeh_ops->set_option(pe, EEH_OPT_FREEZE_PE);
  723. eeh_pe_dev_traverse(pe, eeh_disable_and_save_dev_state, dev);
  724. if (!(pe->type & EEH_PE_VF))
  725. eeh_pe_state_mark(pe, EEH_PE_CFG_BLOCKED);
  726. eeh_ops->reset(pe, EEH_RESET_HOT);
  727. break;
  728. case pcie_warm_reset:
  729. eeh_pe_mark_isolated(pe);
  730. eeh_pe_state_clear(pe, EEH_PE_CFG_BLOCKED);
  731. eeh_ops->set_option(pe, EEH_OPT_FREEZE_PE);
  732. eeh_pe_dev_traverse(pe, eeh_disable_and_save_dev_state, dev);
  733. if (!(pe->type & EEH_PE_VF))
  734. eeh_pe_state_mark(pe, EEH_PE_CFG_BLOCKED);
  735. eeh_ops->reset(pe, EEH_RESET_FUNDAMENTAL);
  736. break;
  737. default:
  738. eeh_pe_state_clear(pe, EEH_PE_ISOLATED | EEH_PE_CFG_BLOCKED);
  739. return -EINVAL;
  740. };
  741. return 0;
  742. }
  743. /**
  744. * eeh_set_pe_freset - Check the required reset for the indicated device
  745. * @data: EEH device
  746. * @flag: return value
  747. *
  748. * Each device might have its preferred reset type: fundamental or
  749. * hot reset. The routine is used to collected the information for
  750. * the indicated device and its children so that the bunch of the
  751. * devices could be reset properly.
  752. */
  753. static void *eeh_set_dev_freset(struct eeh_dev *edev, void *flag)
  754. {
  755. struct pci_dev *dev;
  756. unsigned int *freset = (unsigned int *)flag;
  757. dev = eeh_dev_to_pci_dev(edev);
  758. if (dev)
  759. *freset |= dev->needs_freset;
  760. return NULL;
  761. }
  762. /**
  763. * eeh_pe_reset_full - Complete a full reset process on the indicated PE
  764. * @pe: EEH PE
  765. *
  766. * This function executes a full reset procedure on a PE, including setting
  767. * the appropriate flags, performing a fundamental or hot reset, and then
  768. * deactivating the reset status. It is designed to be used within the EEH
  769. * subsystem, as opposed to eeh_pe_reset which is exported to drivers and
  770. * only performs a single operation at a time.
  771. *
  772. * This function will attempt to reset a PE three times before failing.
  773. */
  774. int eeh_pe_reset_full(struct eeh_pe *pe)
  775. {
  776. int reset_state = (EEH_PE_RESET | EEH_PE_CFG_BLOCKED);
  777. int type = EEH_RESET_HOT;
  778. unsigned int freset = 0;
  779. int i, state, ret;
  780. /*
  781. * Determine the type of reset to perform - hot or fundamental.
  782. * Hot reset is the default operation, unless any device under the
  783. * PE requires a fundamental reset.
  784. */
  785. eeh_pe_dev_traverse(pe, eeh_set_dev_freset, &freset);
  786. if (freset)
  787. type = EEH_RESET_FUNDAMENTAL;
  788. /* Mark the PE as in reset state and block config space accesses */
  789. eeh_pe_state_mark(pe, reset_state);
  790. /* Make three attempts at resetting the bus */
  791. for (i = 0; i < 3; i++) {
  792. ret = eeh_pe_reset(pe, type);
  793. if (ret)
  794. break;
  795. ret = eeh_pe_reset(pe, EEH_RESET_DEACTIVATE);
  796. if (ret)
  797. break;
  798. /* Wait until the PE is in a functioning state */
  799. state = eeh_wait_state(pe, PCI_BUS_RESET_WAIT_MSEC);
  800. if (state < 0) {
  801. pr_warn("%s: Unrecoverable slot failure on PHB#%x-PE#%x",
  802. __func__, pe->phb->global_number, pe->addr);
  803. ret = -ENOTRECOVERABLE;
  804. break;
  805. }
  806. if (eeh_state_active(state))
  807. break;
  808. /* Set error in case this is our last attempt */
  809. ret = -EIO;
  810. pr_warn("%s: Failure %d resetting PHB#%x-PE#%x\n (%d)\n",
  811. __func__, state, pe->phb->global_number, pe->addr, (i + 1));
  812. }
  813. eeh_pe_state_clear(pe, reset_state);
  814. return ret;
  815. }
  816. /**
  817. * eeh_save_bars - Save device bars
  818. * @edev: PCI device associated EEH device
  819. *
  820. * Save the values of the device bars. Unlike the restore
  821. * routine, this routine is *not* recursive. This is because
  822. * PCI devices are added individually; but, for the restore,
  823. * an entire slot is reset at a time.
  824. */
  825. void eeh_save_bars(struct eeh_dev *edev)
  826. {
  827. struct pci_dn *pdn;
  828. int i;
  829. pdn = eeh_dev_to_pdn(edev);
  830. if (!pdn)
  831. return;
  832. for (i = 0; i < 16; i++)
  833. eeh_ops->read_config(pdn, i * 4, 4, &edev->config_space[i]);
  834. /*
  835. * For PCI bridges including root port, we need enable bus
  836. * master explicitly. Otherwise, it can't fetch IODA table
  837. * entries correctly. So we cache the bit in advance so that
  838. * we can restore it after reset, either PHB range or PE range.
  839. */
  840. if (edev->mode & EEH_DEV_BRIDGE)
  841. edev->config_space[1] |= PCI_COMMAND_MASTER;
  842. }
  843. /**
  844. * eeh_ops_register - Register platform dependent EEH operations
  845. * @ops: platform dependent EEH operations
  846. *
  847. * Register the platform dependent EEH operation callback
  848. * functions. The platform should call this function before
  849. * any other EEH operations.
  850. */
  851. int __init eeh_ops_register(struct eeh_ops *ops)
  852. {
  853. if (!ops->name) {
  854. pr_warn("%s: Invalid EEH ops name for %p\n",
  855. __func__, ops);
  856. return -EINVAL;
  857. }
  858. if (eeh_ops && eeh_ops != ops) {
  859. pr_warn("%s: EEH ops of platform %s already existing (%s)\n",
  860. __func__, eeh_ops->name, ops->name);
  861. return -EEXIST;
  862. }
  863. eeh_ops = ops;
  864. return 0;
  865. }
  866. /**
  867. * eeh_ops_unregister - Unreigster platform dependent EEH operations
  868. * @name: name of EEH platform operations
  869. *
  870. * Unregister the platform dependent EEH operation callback
  871. * functions.
  872. */
  873. int __exit eeh_ops_unregister(const char *name)
  874. {
  875. if (!name || !strlen(name)) {
  876. pr_warn("%s: Invalid EEH ops name\n",
  877. __func__);
  878. return -EINVAL;
  879. }
  880. if (eeh_ops && !strcmp(eeh_ops->name, name)) {
  881. eeh_ops = NULL;
  882. return 0;
  883. }
  884. return -EEXIST;
  885. }
  886. static int eeh_reboot_notifier(struct notifier_block *nb,
  887. unsigned long action, void *unused)
  888. {
  889. eeh_clear_flag(EEH_ENABLED);
  890. return NOTIFY_DONE;
  891. }
  892. static struct notifier_block eeh_reboot_nb = {
  893. .notifier_call = eeh_reboot_notifier,
  894. };
  895. void eeh_probe_devices(void)
  896. {
  897. struct pci_controller *hose, *tmp;
  898. struct pci_dn *pdn;
  899. /* Enable EEH for all adapters */
  900. list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
  901. pdn = hose->pci_data;
  902. traverse_pci_dn(pdn, eeh_ops->probe, NULL);
  903. }
  904. if (eeh_enabled())
  905. pr_info("EEH: PCI Enhanced I/O Error Handling Enabled\n");
  906. else
  907. pr_info("EEH: No capable adapters found\n");
  908. }
  909. /**
  910. * eeh_init - EEH initialization
  911. *
  912. * Initialize EEH by trying to enable it for all of the adapters in the system.
  913. * As a side effect we can determine here if eeh is supported at all.
  914. * Note that we leave EEH on so failed config cycles won't cause a machine
  915. * check. If a user turns off EEH for a particular adapter they are really
  916. * telling Linux to ignore errors. Some hardware (e.g. POWER5) won't
  917. * grant access to a slot if EEH isn't enabled, and so we always enable
  918. * EEH for all slots/all devices.
  919. *
  920. * The eeh-force-off option disables EEH checking globally, for all slots.
  921. * Even if force-off is set, the EEH hardware is still enabled, so that
  922. * newer systems can boot.
  923. */
  924. static int eeh_init(void)
  925. {
  926. struct pci_controller *hose, *tmp;
  927. int ret = 0;
  928. /* Register reboot notifier */
  929. ret = register_reboot_notifier(&eeh_reboot_nb);
  930. if (ret) {
  931. pr_warn("%s: Failed to register notifier (%d)\n",
  932. __func__, ret);
  933. return ret;
  934. }
  935. /* call platform initialization function */
  936. if (!eeh_ops) {
  937. pr_warn("%s: Platform EEH operation not found\n",
  938. __func__);
  939. return -EEXIST;
  940. } else if ((ret = eeh_ops->init()))
  941. return ret;
  942. /* Initialize PHB PEs */
  943. list_for_each_entry_safe(hose, tmp, &hose_list, list_node)
  944. eeh_dev_phb_init_dynamic(hose);
  945. /* Initialize EEH event */
  946. return eeh_event_init();
  947. }
  948. core_initcall_sync(eeh_init);
  949. /**
  950. * eeh_add_device_early - Enable EEH for the indicated device node
  951. * @pdn: PCI device node for which to set up EEH
  952. *
  953. * This routine must be used to perform EEH initialization for PCI
  954. * devices that were added after system boot (e.g. hotplug, dlpar).
  955. * This routine must be called before any i/o is performed to the
  956. * adapter (inluding any config-space i/o).
  957. * Whether this actually enables EEH or not for this device depends
  958. * on the CEC architecture, type of the device, on earlier boot
  959. * command-line arguments & etc.
  960. */
  961. void eeh_add_device_early(struct pci_dn *pdn)
  962. {
  963. struct pci_controller *phb = pdn ? pdn->phb : NULL;
  964. struct eeh_dev *edev = pdn_to_eeh_dev(pdn);
  965. if (!edev)
  966. return;
  967. if (!eeh_has_flag(EEH_PROBE_MODE_DEVTREE))
  968. return;
  969. /* USB Bus children of PCI devices will not have BUID's */
  970. if (NULL == phb ||
  971. (eeh_has_flag(EEH_PROBE_MODE_DEVTREE) && 0 == phb->buid))
  972. return;
  973. eeh_ops->probe(pdn, NULL);
  974. }
  975. /**
  976. * eeh_add_device_tree_early - Enable EEH for the indicated device
  977. * @pdn: PCI device node
  978. *
  979. * This routine must be used to perform EEH initialization for the
  980. * indicated PCI device that was added after system boot (e.g.
  981. * hotplug, dlpar).
  982. */
  983. void eeh_add_device_tree_early(struct pci_dn *pdn)
  984. {
  985. struct pci_dn *n;
  986. if (!pdn)
  987. return;
  988. list_for_each_entry(n, &pdn->child_list, list)
  989. eeh_add_device_tree_early(n);
  990. eeh_add_device_early(pdn);
  991. }
  992. EXPORT_SYMBOL_GPL(eeh_add_device_tree_early);
  993. /**
  994. * eeh_add_device_late - Perform EEH initialization for the indicated pci device
  995. * @dev: pci device for which to set up EEH
  996. *
  997. * This routine must be used to complete EEH initialization for PCI
  998. * devices that were added after system boot (e.g. hotplug, dlpar).
  999. */
  1000. void eeh_add_device_late(struct pci_dev *dev)
  1001. {
  1002. struct pci_dn *pdn;
  1003. struct eeh_dev *edev;
  1004. if (!dev || !eeh_enabled())
  1005. return;
  1006. pr_debug("EEH: Adding device %s\n", pci_name(dev));
  1007. pdn = pci_get_pdn_by_devfn(dev->bus, dev->devfn);
  1008. edev = pdn_to_eeh_dev(pdn);
  1009. if (edev->pdev == dev) {
  1010. pr_debug("EEH: Already referenced !\n");
  1011. return;
  1012. }
  1013. /*
  1014. * The EEH cache might not be removed correctly because of
  1015. * unbalanced kref to the device during unplug time, which
  1016. * relies on pcibios_release_device(). So we have to remove
  1017. * that here explicitly.
  1018. */
  1019. if (edev->pdev) {
  1020. eeh_rmv_from_parent_pe(edev);
  1021. eeh_addr_cache_rmv_dev(edev->pdev);
  1022. eeh_sysfs_remove_device(edev->pdev);
  1023. edev->mode &= ~EEH_DEV_SYSFS;
  1024. /*
  1025. * We definitely should have the PCI device removed
  1026. * though it wasn't correctly. So we needn't call
  1027. * into error handler afterwards.
  1028. */
  1029. edev->mode |= EEH_DEV_NO_HANDLER;
  1030. edev->pdev = NULL;
  1031. dev->dev.archdata.edev = NULL;
  1032. }
  1033. if (eeh_has_flag(EEH_PROBE_MODE_DEV))
  1034. eeh_ops->probe(pdn, NULL);
  1035. edev->pdev = dev;
  1036. dev->dev.archdata.edev = edev;
  1037. eeh_addr_cache_insert_dev(dev);
  1038. }
  1039. /**
  1040. * eeh_add_device_tree_late - Perform EEH initialization for the indicated PCI bus
  1041. * @bus: PCI bus
  1042. *
  1043. * This routine must be used to perform EEH initialization for PCI
  1044. * devices which are attached to the indicated PCI bus. The PCI bus
  1045. * is added after system boot through hotplug or dlpar.
  1046. */
  1047. void eeh_add_device_tree_late(struct pci_bus *bus)
  1048. {
  1049. struct pci_dev *dev;
  1050. list_for_each_entry(dev, &bus->devices, bus_list) {
  1051. eeh_add_device_late(dev);
  1052. if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
  1053. struct pci_bus *subbus = dev->subordinate;
  1054. if (subbus)
  1055. eeh_add_device_tree_late(subbus);
  1056. }
  1057. }
  1058. }
  1059. EXPORT_SYMBOL_GPL(eeh_add_device_tree_late);
  1060. /**
  1061. * eeh_add_sysfs_files - Add EEH sysfs files for the indicated PCI bus
  1062. * @bus: PCI bus
  1063. *
  1064. * This routine must be used to add EEH sysfs files for PCI
  1065. * devices which are attached to the indicated PCI bus. The PCI bus
  1066. * is added after system boot through hotplug or dlpar.
  1067. */
  1068. void eeh_add_sysfs_files(struct pci_bus *bus)
  1069. {
  1070. struct pci_dev *dev;
  1071. list_for_each_entry(dev, &bus->devices, bus_list) {
  1072. eeh_sysfs_add_device(dev);
  1073. if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
  1074. struct pci_bus *subbus = dev->subordinate;
  1075. if (subbus)
  1076. eeh_add_sysfs_files(subbus);
  1077. }
  1078. }
  1079. }
  1080. EXPORT_SYMBOL_GPL(eeh_add_sysfs_files);
  1081. /**
  1082. * eeh_remove_device - Undo EEH setup for the indicated pci device
  1083. * @dev: pci device to be removed
  1084. *
  1085. * This routine should be called when a device is removed from
  1086. * a running system (e.g. by hotplug or dlpar). It unregisters
  1087. * the PCI device from the EEH subsystem. I/O errors affecting
  1088. * this device will no longer be detected after this call; thus,
  1089. * i/o errors affecting this slot may leave this device unusable.
  1090. */
  1091. void eeh_remove_device(struct pci_dev *dev)
  1092. {
  1093. struct eeh_dev *edev;
  1094. if (!dev || !eeh_enabled())
  1095. return;
  1096. edev = pci_dev_to_eeh_dev(dev);
  1097. /* Unregister the device with the EEH/PCI address search system */
  1098. pr_debug("EEH: Removing device %s\n", pci_name(dev));
  1099. if (!edev || !edev->pdev || !edev->pe) {
  1100. pr_debug("EEH: Not referenced !\n");
  1101. return;
  1102. }
  1103. /*
  1104. * During the hotplug for EEH error recovery, we need the EEH
  1105. * device attached to the parent PE in order for BAR restore
  1106. * a bit later. So we keep it for BAR restore and remove it
  1107. * from the parent PE during the BAR resotre.
  1108. */
  1109. edev->pdev = NULL;
  1110. /*
  1111. * The flag "in_error" is used to trace EEH devices for VFs
  1112. * in error state or not. It's set in eeh_report_error(). If
  1113. * it's not set, eeh_report_{reset,resume}() won't be called
  1114. * for the VF EEH device.
  1115. */
  1116. edev->in_error = false;
  1117. dev->dev.archdata.edev = NULL;
  1118. if (!(edev->pe->state & EEH_PE_KEEP))
  1119. eeh_rmv_from_parent_pe(edev);
  1120. else
  1121. edev->mode |= EEH_DEV_DISCONNECTED;
  1122. /*
  1123. * We're removing from the PCI subsystem, that means
  1124. * the PCI device driver can't support EEH or not
  1125. * well. So we rely on hotplug completely to do recovery
  1126. * for the specific PCI device.
  1127. */
  1128. edev->mode |= EEH_DEV_NO_HANDLER;
  1129. eeh_addr_cache_rmv_dev(dev);
  1130. eeh_sysfs_remove_device(dev);
  1131. edev->mode &= ~EEH_DEV_SYSFS;
  1132. }
  1133. int eeh_unfreeze_pe(struct eeh_pe *pe, bool sw_state)
  1134. {
  1135. int ret;
  1136. ret = eeh_pci_enable(pe, EEH_OPT_THAW_MMIO);
  1137. if (ret) {
  1138. pr_warn("%s: Failure %d enabling IO on PHB#%x-PE#%x\n",
  1139. __func__, ret, pe->phb->global_number, pe->addr);
  1140. return ret;
  1141. }
  1142. ret = eeh_pci_enable(pe, EEH_OPT_THAW_DMA);
  1143. if (ret) {
  1144. pr_warn("%s: Failure %d enabling DMA on PHB#%x-PE#%x\n",
  1145. __func__, ret, pe->phb->global_number, pe->addr);
  1146. return ret;
  1147. }
  1148. /* Clear software isolated state */
  1149. if (sw_state && (pe->state & EEH_PE_ISOLATED))
  1150. eeh_pe_state_clear(pe, EEH_PE_ISOLATED);
  1151. return ret;
  1152. }
  1153. static struct pci_device_id eeh_reset_ids[] = {
  1154. { PCI_DEVICE(0x19a2, 0x0710) }, /* Emulex, BE */
  1155. { PCI_DEVICE(0x10df, 0xe220) }, /* Emulex, Lancer */
  1156. { PCI_DEVICE(0x14e4, 0x1657) }, /* Broadcom BCM5719 */
  1157. { 0 }
  1158. };
  1159. static int eeh_pe_change_owner(struct eeh_pe *pe)
  1160. {
  1161. struct eeh_dev *edev, *tmp;
  1162. struct pci_dev *pdev;
  1163. struct pci_device_id *id;
  1164. int ret;
  1165. /* Check PE state */
  1166. ret = eeh_ops->get_state(pe, NULL);
  1167. if (ret < 0 || ret == EEH_STATE_NOT_SUPPORT)
  1168. return 0;
  1169. /* Unfrozen PE, nothing to do */
  1170. if (eeh_state_active(ret))
  1171. return 0;
  1172. /* Frozen PE, check if it needs PE level reset */
  1173. eeh_pe_for_each_dev(pe, edev, tmp) {
  1174. pdev = eeh_dev_to_pci_dev(edev);
  1175. if (!pdev)
  1176. continue;
  1177. for (id = &eeh_reset_ids[0]; id->vendor != 0; id++) {
  1178. if (id->vendor != PCI_ANY_ID &&
  1179. id->vendor != pdev->vendor)
  1180. continue;
  1181. if (id->device != PCI_ANY_ID &&
  1182. id->device != pdev->device)
  1183. continue;
  1184. if (id->subvendor != PCI_ANY_ID &&
  1185. id->subvendor != pdev->subsystem_vendor)
  1186. continue;
  1187. if (id->subdevice != PCI_ANY_ID &&
  1188. id->subdevice != pdev->subsystem_device)
  1189. continue;
  1190. return eeh_pe_reset_and_recover(pe);
  1191. }
  1192. }
  1193. return eeh_unfreeze_pe(pe, true);
  1194. }
  1195. /**
  1196. * eeh_dev_open - Increase count of pass through devices for PE
  1197. * @pdev: PCI device
  1198. *
  1199. * Increase count of passed through devices for the indicated
  1200. * PE. In the result, the EEH errors detected on the PE won't be
  1201. * reported. The PE owner will be responsible for detection
  1202. * and recovery.
  1203. */
  1204. int eeh_dev_open(struct pci_dev *pdev)
  1205. {
  1206. struct eeh_dev *edev;
  1207. int ret = -ENODEV;
  1208. mutex_lock(&eeh_dev_mutex);
  1209. /* No PCI device ? */
  1210. if (!pdev)
  1211. goto out;
  1212. /* No EEH device or PE ? */
  1213. edev = pci_dev_to_eeh_dev(pdev);
  1214. if (!edev || !edev->pe)
  1215. goto out;
  1216. /*
  1217. * The PE might have been put into frozen state, but we
  1218. * didn't detect that yet. The passed through PCI devices
  1219. * in frozen PE won't work properly. Clear the frozen state
  1220. * in advance.
  1221. */
  1222. ret = eeh_pe_change_owner(edev->pe);
  1223. if (ret)
  1224. goto out;
  1225. /* Increase PE's pass through count */
  1226. atomic_inc(&edev->pe->pass_dev_cnt);
  1227. mutex_unlock(&eeh_dev_mutex);
  1228. return 0;
  1229. out:
  1230. mutex_unlock(&eeh_dev_mutex);
  1231. return ret;
  1232. }
  1233. EXPORT_SYMBOL_GPL(eeh_dev_open);
  1234. /**
  1235. * eeh_dev_release - Decrease count of pass through devices for PE
  1236. * @pdev: PCI device
  1237. *
  1238. * Decrease count of pass through devices for the indicated PE. If
  1239. * there is no passed through device in PE, the EEH errors detected
  1240. * on the PE will be reported and handled as usual.
  1241. */
  1242. void eeh_dev_release(struct pci_dev *pdev)
  1243. {
  1244. struct eeh_dev *edev;
  1245. mutex_lock(&eeh_dev_mutex);
  1246. /* No PCI device ? */
  1247. if (!pdev)
  1248. goto out;
  1249. /* No EEH device ? */
  1250. edev = pci_dev_to_eeh_dev(pdev);
  1251. if (!edev || !edev->pe || !eeh_pe_passed(edev->pe))
  1252. goto out;
  1253. /* Decrease PE's pass through count */
  1254. WARN_ON(atomic_dec_if_positive(&edev->pe->pass_dev_cnt) < 0);
  1255. eeh_pe_change_owner(edev->pe);
  1256. out:
  1257. mutex_unlock(&eeh_dev_mutex);
  1258. }
  1259. EXPORT_SYMBOL(eeh_dev_release);
  1260. #ifdef CONFIG_IOMMU_API
  1261. static int dev_has_iommu_table(struct device *dev, void *data)
  1262. {
  1263. struct pci_dev *pdev = to_pci_dev(dev);
  1264. struct pci_dev **ppdev = data;
  1265. if (!dev)
  1266. return 0;
  1267. if (dev->iommu_group) {
  1268. *ppdev = pdev;
  1269. return 1;
  1270. }
  1271. return 0;
  1272. }
  1273. /**
  1274. * eeh_iommu_group_to_pe - Convert IOMMU group to EEH PE
  1275. * @group: IOMMU group
  1276. *
  1277. * The routine is called to convert IOMMU group to EEH PE.
  1278. */
  1279. struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group)
  1280. {
  1281. struct pci_dev *pdev = NULL;
  1282. struct eeh_dev *edev;
  1283. int ret;
  1284. /* No IOMMU group ? */
  1285. if (!group)
  1286. return NULL;
  1287. ret = iommu_group_for_each_dev(group, &pdev, dev_has_iommu_table);
  1288. if (!ret || !pdev)
  1289. return NULL;
  1290. /* No EEH device or PE ? */
  1291. edev = pci_dev_to_eeh_dev(pdev);
  1292. if (!edev || !edev->pe)
  1293. return NULL;
  1294. return edev->pe;
  1295. }
  1296. EXPORT_SYMBOL_GPL(eeh_iommu_group_to_pe);
  1297. #endif /* CONFIG_IOMMU_API */
  1298. /**
  1299. * eeh_pe_set_option - Set options for the indicated PE
  1300. * @pe: EEH PE
  1301. * @option: requested option
  1302. *
  1303. * The routine is called to enable or disable EEH functionality
  1304. * on the indicated PE, to enable IO or DMA for the frozen PE.
  1305. */
  1306. int eeh_pe_set_option(struct eeh_pe *pe, int option)
  1307. {
  1308. int ret = 0;
  1309. /* Invalid PE ? */
  1310. if (!pe)
  1311. return -ENODEV;
  1312. /*
  1313. * EEH functionality could possibly be disabled, just
  1314. * return error for the case. And the EEH functinality
  1315. * isn't expected to be disabled on one specific PE.
  1316. */
  1317. switch (option) {
  1318. case EEH_OPT_ENABLE:
  1319. if (eeh_enabled()) {
  1320. ret = eeh_pe_change_owner(pe);
  1321. break;
  1322. }
  1323. ret = -EIO;
  1324. break;
  1325. case EEH_OPT_DISABLE:
  1326. break;
  1327. case EEH_OPT_THAW_MMIO:
  1328. case EEH_OPT_THAW_DMA:
  1329. case EEH_OPT_FREEZE_PE:
  1330. if (!eeh_ops || !eeh_ops->set_option) {
  1331. ret = -ENOENT;
  1332. break;
  1333. }
  1334. ret = eeh_pci_enable(pe, option);
  1335. break;
  1336. default:
  1337. pr_debug("%s: Option %d out of range (%d, %d)\n",
  1338. __func__, option, EEH_OPT_DISABLE, EEH_OPT_THAW_DMA);
  1339. ret = -EINVAL;
  1340. }
  1341. return ret;
  1342. }
  1343. EXPORT_SYMBOL_GPL(eeh_pe_set_option);
  1344. /**
  1345. * eeh_pe_get_state - Retrieve PE's state
  1346. * @pe: EEH PE
  1347. *
  1348. * Retrieve the PE's state, which includes 3 aspects: enabled
  1349. * DMA, enabled IO and asserted reset.
  1350. */
  1351. int eeh_pe_get_state(struct eeh_pe *pe)
  1352. {
  1353. int result, ret = 0;
  1354. bool rst_active, dma_en, mmio_en;
  1355. /* Existing PE ? */
  1356. if (!pe)
  1357. return -ENODEV;
  1358. if (!eeh_ops || !eeh_ops->get_state)
  1359. return -ENOENT;
  1360. /*
  1361. * If the parent PE is owned by the host kernel and is undergoing
  1362. * error recovery, we should return the PE state as temporarily
  1363. * unavailable so that the error recovery on the guest is suspended
  1364. * until the recovery completes on the host.
  1365. */
  1366. if (pe->parent &&
  1367. !(pe->state & EEH_PE_REMOVED) &&
  1368. (pe->parent->state & (EEH_PE_ISOLATED | EEH_PE_RECOVERING)))
  1369. return EEH_PE_STATE_UNAVAIL;
  1370. result = eeh_ops->get_state(pe, NULL);
  1371. rst_active = !!(result & EEH_STATE_RESET_ACTIVE);
  1372. dma_en = !!(result & EEH_STATE_DMA_ENABLED);
  1373. mmio_en = !!(result & EEH_STATE_MMIO_ENABLED);
  1374. if (rst_active)
  1375. ret = EEH_PE_STATE_RESET;
  1376. else if (dma_en && mmio_en)
  1377. ret = EEH_PE_STATE_NORMAL;
  1378. else if (!dma_en && !mmio_en)
  1379. ret = EEH_PE_STATE_STOPPED_IO_DMA;
  1380. else if (!dma_en && mmio_en)
  1381. ret = EEH_PE_STATE_STOPPED_DMA;
  1382. else
  1383. ret = EEH_PE_STATE_UNAVAIL;
  1384. return ret;
  1385. }
  1386. EXPORT_SYMBOL_GPL(eeh_pe_get_state);
  1387. static int eeh_pe_reenable_devices(struct eeh_pe *pe)
  1388. {
  1389. struct eeh_dev *edev, *tmp;
  1390. struct pci_dev *pdev;
  1391. int ret = 0;
  1392. /* Restore config space */
  1393. eeh_pe_restore_bars(pe);
  1394. /*
  1395. * Reenable PCI devices as the devices passed
  1396. * through are always enabled before the reset.
  1397. */
  1398. eeh_pe_for_each_dev(pe, edev, tmp) {
  1399. pdev = eeh_dev_to_pci_dev(edev);
  1400. if (!pdev)
  1401. continue;
  1402. ret = pci_reenable_device(pdev);
  1403. if (ret) {
  1404. pr_warn("%s: Failure %d reenabling %s\n",
  1405. __func__, ret, pci_name(pdev));
  1406. return ret;
  1407. }
  1408. }
  1409. /* The PE is still in frozen state */
  1410. return eeh_unfreeze_pe(pe, true);
  1411. }
  1412. /**
  1413. * eeh_pe_reset - Issue PE reset according to specified type
  1414. * @pe: EEH PE
  1415. * @option: reset type
  1416. *
  1417. * The routine is called to reset the specified PE with the
  1418. * indicated type, either fundamental reset or hot reset.
  1419. * PE reset is the most important part for error recovery.
  1420. */
  1421. int eeh_pe_reset(struct eeh_pe *pe, int option)
  1422. {
  1423. int ret = 0;
  1424. /* Invalid PE ? */
  1425. if (!pe)
  1426. return -ENODEV;
  1427. if (!eeh_ops || !eeh_ops->set_option || !eeh_ops->reset)
  1428. return -ENOENT;
  1429. switch (option) {
  1430. case EEH_RESET_DEACTIVATE:
  1431. ret = eeh_ops->reset(pe, option);
  1432. eeh_pe_state_clear(pe, EEH_PE_CFG_BLOCKED);
  1433. if (ret)
  1434. break;
  1435. ret = eeh_pe_reenable_devices(pe);
  1436. break;
  1437. case EEH_RESET_HOT:
  1438. case EEH_RESET_FUNDAMENTAL:
  1439. /*
  1440. * Proactively freeze the PE to drop all MMIO access
  1441. * during reset, which should be banned as it's always
  1442. * cause recursive EEH error.
  1443. */
  1444. eeh_ops->set_option(pe, EEH_OPT_FREEZE_PE);
  1445. eeh_pe_state_mark(pe, EEH_PE_CFG_BLOCKED);
  1446. ret = eeh_ops->reset(pe, option);
  1447. break;
  1448. default:
  1449. pr_debug("%s: Unsupported option %d\n",
  1450. __func__, option);
  1451. ret = -EINVAL;
  1452. }
  1453. return ret;
  1454. }
  1455. EXPORT_SYMBOL_GPL(eeh_pe_reset);
  1456. /**
  1457. * eeh_pe_configure - Configure PCI bridges after PE reset
  1458. * @pe: EEH PE
  1459. *
  1460. * The routine is called to restore the PCI config space for
  1461. * those PCI devices, especially PCI bridges affected by PE
  1462. * reset issued previously.
  1463. */
  1464. int eeh_pe_configure(struct eeh_pe *pe)
  1465. {
  1466. int ret = 0;
  1467. /* Invalid PE ? */
  1468. if (!pe)
  1469. return -ENODEV;
  1470. return ret;
  1471. }
  1472. EXPORT_SYMBOL_GPL(eeh_pe_configure);
  1473. /**
  1474. * eeh_pe_inject_err - Injecting the specified PCI error to the indicated PE
  1475. * @pe: the indicated PE
  1476. * @type: error type
  1477. * @function: error function
  1478. * @addr: address
  1479. * @mask: address mask
  1480. *
  1481. * The routine is called to inject the specified PCI error, which
  1482. * is determined by @type and @function, to the indicated PE for
  1483. * testing purpose.
  1484. */
  1485. int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func,
  1486. unsigned long addr, unsigned long mask)
  1487. {
  1488. /* Invalid PE ? */
  1489. if (!pe)
  1490. return -ENODEV;
  1491. /* Unsupported operation ? */
  1492. if (!eeh_ops || !eeh_ops->err_inject)
  1493. return -ENOENT;
  1494. /* Check on PCI error type */
  1495. if (type != EEH_ERR_TYPE_32 && type != EEH_ERR_TYPE_64)
  1496. return -EINVAL;
  1497. /* Check on PCI error function */
  1498. if (func < EEH_ERR_FUNC_MIN || func > EEH_ERR_FUNC_MAX)
  1499. return -EINVAL;
  1500. return eeh_ops->err_inject(pe, type, func, addr, mask);
  1501. }
  1502. EXPORT_SYMBOL_GPL(eeh_pe_inject_err);
  1503. static int proc_eeh_show(struct seq_file *m, void *v)
  1504. {
  1505. if (!eeh_enabled()) {
  1506. seq_printf(m, "EEH Subsystem is globally disabled\n");
  1507. seq_printf(m, "eeh_total_mmio_ffs=%llu\n", eeh_stats.total_mmio_ffs);
  1508. } else {
  1509. seq_printf(m, "EEH Subsystem is enabled\n");
  1510. seq_printf(m,
  1511. "no device=%llu\n"
  1512. "no device node=%llu\n"
  1513. "no config address=%llu\n"
  1514. "check not wanted=%llu\n"
  1515. "eeh_total_mmio_ffs=%llu\n"
  1516. "eeh_false_positives=%llu\n"
  1517. "eeh_slot_resets=%llu\n",
  1518. eeh_stats.no_device,
  1519. eeh_stats.no_dn,
  1520. eeh_stats.no_cfg_addr,
  1521. eeh_stats.ignored_check,
  1522. eeh_stats.total_mmio_ffs,
  1523. eeh_stats.false_positives,
  1524. eeh_stats.slot_resets);
  1525. }
  1526. return 0;
  1527. }
  1528. #ifdef CONFIG_DEBUG_FS
  1529. static int eeh_enable_dbgfs_set(void *data, u64 val)
  1530. {
  1531. if (val)
  1532. eeh_clear_flag(EEH_FORCE_DISABLED);
  1533. else
  1534. eeh_add_flag(EEH_FORCE_DISABLED);
  1535. return 0;
  1536. }
  1537. static int eeh_enable_dbgfs_get(void *data, u64 *val)
  1538. {
  1539. if (eeh_enabled())
  1540. *val = 0x1ul;
  1541. else
  1542. *val = 0x0ul;
  1543. return 0;
  1544. }
  1545. static int eeh_freeze_dbgfs_set(void *data, u64 val)
  1546. {
  1547. eeh_max_freezes = val;
  1548. return 0;
  1549. }
  1550. static int eeh_freeze_dbgfs_get(void *data, u64 *val)
  1551. {
  1552. *val = eeh_max_freezes;
  1553. return 0;
  1554. }
  1555. DEFINE_SIMPLE_ATTRIBUTE(eeh_enable_dbgfs_ops, eeh_enable_dbgfs_get,
  1556. eeh_enable_dbgfs_set, "0x%llx\n");
  1557. DEFINE_SIMPLE_ATTRIBUTE(eeh_freeze_dbgfs_ops, eeh_freeze_dbgfs_get,
  1558. eeh_freeze_dbgfs_set, "0x%llx\n");
  1559. #endif
  1560. static int __init eeh_init_proc(void)
  1561. {
  1562. if (machine_is(pseries) || machine_is(powernv)) {
  1563. proc_create_single("powerpc/eeh", 0, NULL, proc_eeh_show);
  1564. #ifdef CONFIG_DEBUG_FS
  1565. debugfs_create_file("eeh_enable", 0600,
  1566. powerpc_debugfs_root, NULL,
  1567. &eeh_enable_dbgfs_ops);
  1568. debugfs_create_file("eeh_max_freezes", 0600,
  1569. powerpc_debugfs_root, NULL,
  1570. &eeh_freeze_dbgfs_ops);
  1571. #endif
  1572. }
  1573. return 0;
  1574. }
  1575. __initcall(eeh_init_proc);