edac_mc.c 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829
  1. /*
  2. * edac_mc kernel module
  3. * (C) 2005, 2006 Linux Networx (http://lnxi.com)
  4. * This file may be distributed under the terms of the
  5. * GNU General Public License.
  6. *
  7. * Written by Thayne Harbaugh
  8. * Based on work by Dan Hollis <goemon at anime dot net> and others.
  9. * http://www.anime.net/~goemon/linux-ecc/
  10. *
  11. * Modified by Dave Peterson and Doug Thompson
  12. *
  13. */
  14. #include <linux/module.h>
  15. #include <linux/proc_fs.h>
  16. #include <linux/kernel.h>
  17. #include <linux/types.h>
  18. #include <linux/smp.h>
  19. #include <linux/init.h>
  20. #include <linux/sysctl.h>
  21. #include <linux/highmem.h>
  22. #include <linux/timer.h>
  23. #include <linux/slab.h>
  24. #include <linux/jiffies.h>
  25. #include <linux/spinlock.h>
  26. #include <linux/list.h>
  27. #include <linux/sysdev.h>
  28. #include <linux/ctype.h>
  29. #include <linux/kthread.h>
  30. #include <asm/uaccess.h>
  31. #include <asm/page.h>
  32. #include <asm/edac.h>
  33. #include "edac_mc.h"
  34. #define EDAC_MC_VERSION "Ver: 2.0.1 " __DATE__
  35. #ifdef CONFIG_EDAC_DEBUG
  36. /* Values of 0 to 4 will generate output */
  37. int edac_debug_level = 1;
  38. EXPORT_SYMBOL_GPL(edac_debug_level);
  39. #endif
  40. /* EDAC Controls, setable by module parameter, and sysfs */
  41. static int log_ue = 1;
  42. static int log_ce = 1;
  43. static int panic_on_ue;
  44. static int poll_msec = 1000;
  45. /* lock to memory controller's control array */
  46. static DECLARE_MUTEX(mem_ctls_mutex);
  47. static struct list_head mc_devices = LIST_HEAD_INIT(mc_devices);
  48. static struct task_struct *edac_thread;
  49. #ifdef CONFIG_PCI
  50. static int check_pci_parity = 0; /* default YES check PCI parity */
  51. static int panic_on_pci_parity; /* default no panic on PCI Parity */
  52. static atomic_t pci_parity_count = ATOMIC_INIT(0);
  53. static struct kobject edac_pci_kobj; /* /sys/devices/system/edac/pci */
  54. static struct completion edac_pci_kobj_complete;
  55. #endif /* CONFIG_PCI */
  56. /* START sysfs data and methods */
  57. static const char *mem_types[] = {
  58. [MEM_EMPTY] = "Empty",
  59. [MEM_RESERVED] = "Reserved",
  60. [MEM_UNKNOWN] = "Unknown",
  61. [MEM_FPM] = "FPM",
  62. [MEM_EDO] = "EDO",
  63. [MEM_BEDO] = "BEDO",
  64. [MEM_SDR] = "Unbuffered-SDR",
  65. [MEM_RDR] = "Registered-SDR",
  66. [MEM_DDR] = "Unbuffered-DDR",
  67. [MEM_RDDR] = "Registered-DDR",
  68. [MEM_RMBS] = "RMBS"
  69. };
  70. static const char *dev_types[] = {
  71. [DEV_UNKNOWN] = "Unknown",
  72. [DEV_X1] = "x1",
  73. [DEV_X2] = "x2",
  74. [DEV_X4] = "x4",
  75. [DEV_X8] = "x8",
  76. [DEV_X16] = "x16",
  77. [DEV_X32] = "x32",
  78. [DEV_X64] = "x64"
  79. };
  80. static const char *edac_caps[] = {
  81. [EDAC_UNKNOWN] = "Unknown",
  82. [EDAC_NONE] = "None",
  83. [EDAC_RESERVED] = "Reserved",
  84. [EDAC_PARITY] = "PARITY",
  85. [EDAC_EC] = "EC",
  86. [EDAC_SECDED] = "SECDED",
  87. [EDAC_S2ECD2ED] = "S2ECD2ED",
  88. [EDAC_S4ECD4ED] = "S4ECD4ED",
  89. [EDAC_S8ECD8ED] = "S8ECD8ED",
  90. [EDAC_S16ECD16ED] = "S16ECD16ED"
  91. };
  92. /* sysfs object: /sys/devices/system/edac */
  93. static struct sysdev_class edac_class = {
  94. set_kset_name("edac"),
  95. };
  96. /* sysfs object:
  97. * /sys/devices/system/edac/mc
  98. */
  99. static struct kobject edac_memctrl_kobj;
  100. /* We use these to wait for the reference counts on edac_memctrl_kobj and
  101. * edac_pci_kobj to reach 0.
  102. */
  103. static struct completion edac_memctrl_kobj_complete;
  104. /*
  105. * /sys/devices/system/edac/mc;
  106. * data structures and methods
  107. */
  108. static ssize_t memctrl_int_show(void *ptr, char *buffer)
  109. {
  110. int *value = (int*) ptr;
  111. return sprintf(buffer, "%u\n", *value);
  112. }
  113. static ssize_t memctrl_int_store(void *ptr, const char *buffer, size_t count)
  114. {
  115. int *value = (int*) ptr;
  116. if (isdigit(*buffer))
  117. *value = simple_strtoul(buffer, NULL, 0);
  118. return count;
  119. }
  120. struct memctrl_dev_attribute {
  121. struct attribute attr;
  122. void *value;
  123. ssize_t (*show)(void *,char *);
  124. ssize_t (*store)(void *, const char *, size_t);
  125. };
  126. /* Set of show/store abstract level functions for memory control object */
  127. static ssize_t memctrl_dev_show(struct kobject *kobj,
  128. struct attribute *attr, char *buffer)
  129. {
  130. struct memctrl_dev_attribute *memctrl_dev;
  131. memctrl_dev = (struct memctrl_dev_attribute*)attr;
  132. if (memctrl_dev->show)
  133. return memctrl_dev->show(memctrl_dev->value, buffer);
  134. return -EIO;
  135. }
  136. static ssize_t memctrl_dev_store(struct kobject *kobj, struct attribute *attr,
  137. const char *buffer, size_t count)
  138. {
  139. struct memctrl_dev_attribute *memctrl_dev;
  140. memctrl_dev = (struct memctrl_dev_attribute*)attr;
  141. if (memctrl_dev->store)
  142. return memctrl_dev->store(memctrl_dev->value, buffer, count);
  143. return -EIO;
  144. }
  145. static struct sysfs_ops memctrlfs_ops = {
  146. .show = memctrl_dev_show,
  147. .store = memctrl_dev_store
  148. };
  149. #define MEMCTRL_ATTR(_name,_mode,_show,_store) \
  150. struct memctrl_dev_attribute attr_##_name = { \
  151. .attr = {.name = __stringify(_name), .mode = _mode }, \
  152. .value = &_name, \
  153. .show = _show, \
  154. .store = _store, \
  155. };
  156. #define MEMCTRL_STRING_ATTR(_name,_data,_mode,_show,_store) \
  157. struct memctrl_dev_attribute attr_##_name = { \
  158. .attr = {.name = __stringify(_name), .mode = _mode }, \
  159. .value = _data, \
  160. .show = _show, \
  161. .store = _store, \
  162. };
  163. /* csrow<id> control files */
  164. MEMCTRL_ATTR(panic_on_ue,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store);
  165. MEMCTRL_ATTR(log_ue,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store);
  166. MEMCTRL_ATTR(log_ce,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store);
  167. MEMCTRL_ATTR(poll_msec,S_IRUGO|S_IWUSR,memctrl_int_show,memctrl_int_store);
  168. /* Base Attributes of the memory ECC object */
  169. static struct memctrl_dev_attribute *memctrl_attr[] = {
  170. &attr_panic_on_ue,
  171. &attr_log_ue,
  172. &attr_log_ce,
  173. &attr_poll_msec,
  174. NULL,
  175. };
  176. /* Main MC kobject release() function */
  177. static void edac_memctrl_master_release(struct kobject *kobj)
  178. {
  179. debugf1("%s()\n", __func__);
  180. complete(&edac_memctrl_kobj_complete);
  181. }
  182. static struct kobj_type ktype_memctrl = {
  183. .release = edac_memctrl_master_release,
  184. .sysfs_ops = &memctrlfs_ops,
  185. .default_attrs = (struct attribute **) memctrl_attr,
  186. };
  187. /* Initialize the main sysfs entries for edac:
  188. * /sys/devices/system/edac
  189. *
  190. * and children
  191. *
  192. * Return: 0 SUCCESS
  193. * !0 FAILURE
  194. */
  195. static int edac_sysfs_memctrl_setup(void)
  196. {
  197. int err=0;
  198. debugf1("%s()\n", __func__);
  199. /* create the /sys/devices/system/edac directory */
  200. err = sysdev_class_register(&edac_class);
  201. if (!err) {
  202. /* Init the MC's kobject */
  203. memset(&edac_memctrl_kobj, 0, sizeof (edac_memctrl_kobj));
  204. edac_memctrl_kobj.parent = &edac_class.kset.kobj;
  205. edac_memctrl_kobj.ktype = &ktype_memctrl;
  206. /* generate sysfs "..../edac/mc" */
  207. err = kobject_set_name(&edac_memctrl_kobj,"mc");
  208. if (!err) {
  209. /* FIXME: maybe new sysdev_create_subdir() */
  210. err = kobject_register(&edac_memctrl_kobj);
  211. if (err)
  212. debugf1("Failed to register '.../edac/mc'\n");
  213. else
  214. debugf1("Registered '.../edac/mc' kobject\n");
  215. }
  216. } else
  217. debugf1("%s() error=%d\n", __func__, err);
  218. return err;
  219. }
  220. /*
  221. * MC teardown:
  222. * the '..../edac/mc' kobject followed by '..../edac' itself
  223. */
  224. static void edac_sysfs_memctrl_teardown(void)
  225. {
  226. debugf0("MC: " __FILE__ ": %s()\n", __func__);
  227. /* Unregister the MC's kobject and wait for reference count to reach
  228. * 0.
  229. */
  230. init_completion(&edac_memctrl_kobj_complete);
  231. kobject_unregister(&edac_memctrl_kobj);
  232. wait_for_completion(&edac_memctrl_kobj_complete);
  233. /* Unregister the 'edac' object */
  234. sysdev_class_unregister(&edac_class);
  235. }
  236. #ifdef CONFIG_PCI
  237. static ssize_t edac_pci_int_show(void *ptr, char *buffer)
  238. {
  239. int *value = ptr;
  240. return sprintf(buffer,"%d\n",*value);
  241. }
  242. static ssize_t edac_pci_int_store(void *ptr, const char *buffer, size_t count)
  243. {
  244. int *value = ptr;
  245. if (isdigit(*buffer))
  246. *value = simple_strtoul(buffer,NULL,0);
  247. return count;
  248. }
  249. struct edac_pci_dev_attribute {
  250. struct attribute attr;
  251. void *value;
  252. ssize_t (*show)(void *,char *);
  253. ssize_t (*store)(void *, const char *,size_t);
  254. };
  255. /* Set of show/store abstract level functions for PCI Parity object */
  256. static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
  257. char *buffer)
  258. {
  259. struct edac_pci_dev_attribute *edac_pci_dev;
  260. edac_pci_dev= (struct edac_pci_dev_attribute*)attr;
  261. if (edac_pci_dev->show)
  262. return edac_pci_dev->show(edac_pci_dev->value, buffer);
  263. return -EIO;
  264. }
  265. static ssize_t edac_pci_dev_store(struct kobject *kobj,
  266. struct attribute *attr, const char *buffer, size_t count)
  267. {
  268. struct edac_pci_dev_attribute *edac_pci_dev;
  269. edac_pci_dev= (struct edac_pci_dev_attribute*)attr;
  270. if (edac_pci_dev->show)
  271. return edac_pci_dev->store(edac_pci_dev->value, buffer, count);
  272. return -EIO;
  273. }
  274. static struct sysfs_ops edac_pci_sysfs_ops = {
  275. .show = edac_pci_dev_show,
  276. .store = edac_pci_dev_store
  277. };
  278. #define EDAC_PCI_ATTR(_name,_mode,_show,_store) \
  279. struct edac_pci_dev_attribute edac_pci_attr_##_name = { \
  280. .attr = {.name = __stringify(_name), .mode = _mode }, \
  281. .value = &_name, \
  282. .show = _show, \
  283. .store = _store, \
  284. };
  285. #define EDAC_PCI_STRING_ATTR(_name,_data,_mode,_show,_store) \
  286. struct edac_pci_dev_attribute edac_pci_attr_##_name = { \
  287. .attr = {.name = __stringify(_name), .mode = _mode }, \
  288. .value = _data, \
  289. .show = _show, \
  290. .store = _store, \
  291. };
  292. /* PCI Parity control files */
  293. EDAC_PCI_ATTR(check_pci_parity, S_IRUGO|S_IWUSR, edac_pci_int_show,
  294. edac_pci_int_store);
  295. EDAC_PCI_ATTR(panic_on_pci_parity, S_IRUGO|S_IWUSR, edac_pci_int_show,
  296. edac_pci_int_store);
  297. EDAC_PCI_ATTR(pci_parity_count, S_IRUGO, edac_pci_int_show, NULL);
  298. /* Base Attributes of the memory ECC object */
  299. static struct edac_pci_dev_attribute *edac_pci_attr[] = {
  300. &edac_pci_attr_check_pci_parity,
  301. &edac_pci_attr_panic_on_pci_parity,
  302. &edac_pci_attr_pci_parity_count,
  303. NULL,
  304. };
  305. /* No memory to release */
  306. static void edac_pci_release(struct kobject *kobj)
  307. {
  308. debugf1("%s()\n", __func__);
  309. complete(&edac_pci_kobj_complete);
  310. }
  311. static struct kobj_type ktype_edac_pci = {
  312. .release = edac_pci_release,
  313. .sysfs_ops = &edac_pci_sysfs_ops,
  314. .default_attrs = (struct attribute **) edac_pci_attr,
  315. };
  316. /**
  317. * edac_sysfs_pci_setup()
  318. *
  319. */
  320. static int edac_sysfs_pci_setup(void)
  321. {
  322. int err;
  323. debugf1("%s()\n", __func__);
  324. memset(&edac_pci_kobj, 0, sizeof(edac_pci_kobj));
  325. edac_pci_kobj.parent = &edac_class.kset.kobj;
  326. edac_pci_kobj.ktype = &ktype_edac_pci;
  327. err = kobject_set_name(&edac_pci_kobj, "pci");
  328. if (!err) {
  329. /* Instanstiate the csrow object */
  330. /* FIXME: maybe new sysdev_create_subdir() */
  331. err = kobject_register(&edac_pci_kobj);
  332. if (err)
  333. debugf1("Failed to register '.../edac/pci'\n");
  334. else
  335. debugf1("Registered '.../edac/pci' kobject\n");
  336. }
  337. return err;
  338. }
  339. static void edac_sysfs_pci_teardown(void)
  340. {
  341. debugf0("%s()\n", __func__);
  342. init_completion(&edac_pci_kobj_complete);
  343. kobject_unregister(&edac_pci_kobj);
  344. wait_for_completion(&edac_pci_kobj_complete);
  345. }
  346. static u16 get_pci_parity_status(struct pci_dev *dev, int secondary)
  347. {
  348. int where;
  349. u16 status;
  350. where = secondary ? PCI_SEC_STATUS : PCI_STATUS;
  351. pci_read_config_word(dev, where, &status);
  352. /* If we get back 0xFFFF then we must suspect that the card has been
  353. * pulled but the Linux PCI layer has not yet finished cleaning up.
  354. * We don't want to report on such devices
  355. */
  356. if (status == 0xFFFF) {
  357. u32 sanity;
  358. pci_read_config_dword(dev, 0, &sanity);
  359. if (sanity == 0xFFFFFFFF)
  360. return 0;
  361. }
  362. status &= PCI_STATUS_DETECTED_PARITY | PCI_STATUS_SIG_SYSTEM_ERROR |
  363. PCI_STATUS_PARITY;
  364. if (status)
  365. /* reset only the bits we are interested in */
  366. pci_write_config_word(dev, where, status);
  367. return status;
  368. }
  369. typedef void (*pci_parity_check_fn_t) (struct pci_dev *dev);
  370. /* Clear any PCI parity errors logged by this device. */
  371. static void edac_pci_dev_parity_clear(struct pci_dev *dev)
  372. {
  373. u8 header_type;
  374. get_pci_parity_status(dev, 0);
  375. /* read the device TYPE, looking for bridges */
  376. pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
  377. if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE)
  378. get_pci_parity_status(dev, 1);
  379. }
  380. /*
  381. * PCI Parity polling
  382. *
  383. */
  384. static void edac_pci_dev_parity_test(struct pci_dev *dev)
  385. {
  386. u16 status;
  387. u8 header_type;
  388. /* read the STATUS register on this device
  389. */
  390. status = get_pci_parity_status(dev, 0);
  391. debugf2("PCI STATUS= 0x%04x %s\n", status, dev->dev.bus_id );
  392. /* check the status reg for errors */
  393. if (status) {
  394. if (status & (PCI_STATUS_SIG_SYSTEM_ERROR))
  395. edac_printk(KERN_CRIT, EDAC_PCI,
  396. "Signaled System Error on %s\n",
  397. pci_name(dev));
  398. if (status & (PCI_STATUS_PARITY)) {
  399. edac_printk(KERN_CRIT, EDAC_PCI,
  400. "Master Data Parity Error on %s\n",
  401. pci_name(dev));
  402. atomic_inc(&pci_parity_count);
  403. }
  404. if (status & (PCI_STATUS_DETECTED_PARITY)) {
  405. edac_printk(KERN_CRIT, EDAC_PCI,
  406. "Detected Parity Error on %s\n",
  407. pci_name(dev));
  408. atomic_inc(&pci_parity_count);
  409. }
  410. }
  411. /* read the device TYPE, looking for bridges */
  412. pci_read_config_byte(dev, PCI_HEADER_TYPE, &header_type);
  413. debugf2("PCI HEADER TYPE= 0x%02x %s\n", header_type, dev->dev.bus_id );
  414. if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
  415. /* On bridges, need to examine secondary status register */
  416. status = get_pci_parity_status(dev, 1);
  417. debugf2("PCI SEC_STATUS= 0x%04x %s\n",
  418. status, dev->dev.bus_id );
  419. /* check the secondary status reg for errors */
  420. if (status) {
  421. if (status & (PCI_STATUS_SIG_SYSTEM_ERROR))
  422. edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
  423. "Signaled System Error on %s\n",
  424. pci_name(dev));
  425. if (status & (PCI_STATUS_PARITY)) {
  426. edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
  427. "Master Data Parity Error on "
  428. "%s\n", pci_name(dev));
  429. atomic_inc(&pci_parity_count);
  430. }
  431. if (status & (PCI_STATUS_DETECTED_PARITY)) {
  432. edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
  433. "Detected Parity Error on %s\n",
  434. pci_name(dev));
  435. atomic_inc(&pci_parity_count);
  436. }
  437. }
  438. }
  439. }
  440. /*
  441. * pci_dev parity list iterator
  442. * Scan the PCI device list for one iteration, looking for SERRORs
  443. * Master Parity ERRORS or Parity ERRORs on primary or secondary devices
  444. */
  445. static inline void edac_pci_dev_parity_iterator(pci_parity_check_fn_t fn)
  446. {
  447. struct pci_dev *dev = NULL;
  448. /* request for kernel access to the next PCI device, if any,
  449. * and while we are looking at it have its reference count
  450. * bumped until we are done with it
  451. */
  452. while((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
  453. fn(dev);
  454. }
  455. }
  456. static void do_pci_parity_check(void)
  457. {
  458. unsigned long flags;
  459. int before_count;
  460. debugf3("%s()\n", __func__);
  461. if (!check_pci_parity)
  462. return;
  463. before_count = atomic_read(&pci_parity_count);
  464. /* scan all PCI devices looking for a Parity Error on devices and
  465. * bridges
  466. */
  467. local_irq_save(flags);
  468. edac_pci_dev_parity_iterator(edac_pci_dev_parity_test);
  469. local_irq_restore(flags);
  470. /* Only if operator has selected panic on PCI Error */
  471. if (panic_on_pci_parity) {
  472. /* If the count is different 'after' from 'before' */
  473. if (before_count != atomic_read(&pci_parity_count))
  474. panic("EDAC: PCI Parity Error");
  475. }
  476. }
  477. static inline void clear_pci_parity_errors(void)
  478. {
  479. /* Clear any PCI bus parity errors that devices initially have logged
  480. * in their registers.
  481. */
  482. edac_pci_dev_parity_iterator(edac_pci_dev_parity_clear);
  483. }
  484. #else /* CONFIG_PCI */
  485. /* pre-process these away */
  486. #define do_pci_parity_check()
  487. #define clear_pci_parity_errors()
  488. #define edac_sysfs_pci_teardown()
  489. #define edac_sysfs_pci_setup() (0)
  490. #endif /* CONFIG_PCI */
  491. /* EDAC sysfs CSROW data structures and methods
  492. */
  493. /* Set of more default csrow<id> attribute show/store functions */
  494. static ssize_t csrow_ue_count_show(struct csrow_info *csrow, char *data, int private)
  495. {
  496. return sprintf(data,"%u\n", csrow->ue_count);
  497. }
  498. static ssize_t csrow_ce_count_show(struct csrow_info *csrow, char *data, int private)
  499. {
  500. return sprintf(data,"%u\n", csrow->ce_count);
  501. }
  502. static ssize_t csrow_size_show(struct csrow_info *csrow, char *data, int private)
  503. {
  504. return sprintf(data,"%u\n", PAGES_TO_MiB(csrow->nr_pages));
  505. }
  506. static ssize_t csrow_mem_type_show(struct csrow_info *csrow, char *data, int private)
  507. {
  508. return sprintf(data,"%s\n", mem_types[csrow->mtype]);
  509. }
  510. static ssize_t csrow_dev_type_show(struct csrow_info *csrow, char *data, int private)
  511. {
  512. return sprintf(data,"%s\n", dev_types[csrow->dtype]);
  513. }
  514. static ssize_t csrow_edac_mode_show(struct csrow_info *csrow, char *data, int private)
  515. {
  516. return sprintf(data,"%s\n", edac_caps[csrow->edac_mode]);
  517. }
  518. /* show/store functions for DIMM Label attributes */
  519. static ssize_t channel_dimm_label_show(struct csrow_info *csrow,
  520. char *data, int channel)
  521. {
  522. return snprintf(data, EDAC_MC_LABEL_LEN,"%s",
  523. csrow->channels[channel].label);
  524. }
  525. static ssize_t channel_dimm_label_store(struct csrow_info *csrow,
  526. const char *data,
  527. size_t count,
  528. int channel)
  529. {
  530. ssize_t max_size = 0;
  531. max_size = min((ssize_t)count,(ssize_t)EDAC_MC_LABEL_LEN-1);
  532. strncpy(csrow->channels[channel].label, data, max_size);
  533. csrow->channels[channel].label[max_size] = '\0';
  534. return max_size;
  535. }
  536. /* show function for dynamic chX_ce_count attribute */
  537. static ssize_t channel_ce_count_show(struct csrow_info *csrow,
  538. char *data,
  539. int channel)
  540. {
  541. return sprintf(data, "%u\n", csrow->channels[channel].ce_count);
  542. }
  543. /* csrow specific attribute structure */
  544. struct csrowdev_attribute {
  545. struct attribute attr;
  546. ssize_t (*show)(struct csrow_info *,char *,int);
  547. ssize_t (*store)(struct csrow_info *, const char *,size_t,int);
  548. int private;
  549. };
  550. #define to_csrow(k) container_of(k, struct csrow_info, kobj)
  551. #define to_csrowdev_attr(a) container_of(a, struct csrowdev_attribute, attr)
  552. /* Set of show/store higher level functions for default csrow attributes */
  553. static ssize_t csrowdev_show(struct kobject *kobj,
  554. struct attribute *attr,
  555. char *buffer)
  556. {
  557. struct csrow_info *csrow = to_csrow(kobj);
  558. struct csrowdev_attribute *csrowdev_attr = to_csrowdev_attr(attr);
  559. if (csrowdev_attr->show)
  560. return csrowdev_attr->show(csrow,
  561. buffer,
  562. csrowdev_attr->private);
  563. return -EIO;
  564. }
  565. static ssize_t csrowdev_store(struct kobject *kobj, struct attribute *attr,
  566. const char *buffer, size_t count)
  567. {
  568. struct csrow_info *csrow = to_csrow(kobj);
  569. struct csrowdev_attribute * csrowdev_attr = to_csrowdev_attr(attr);
  570. if (csrowdev_attr->store)
  571. return csrowdev_attr->store(csrow,
  572. buffer,
  573. count,
  574. csrowdev_attr->private);
  575. return -EIO;
  576. }
  577. static struct sysfs_ops csrowfs_ops = {
  578. .show = csrowdev_show,
  579. .store = csrowdev_store
  580. };
  581. #define CSROWDEV_ATTR(_name,_mode,_show,_store,_private) \
  582. struct csrowdev_attribute attr_##_name = { \
  583. .attr = {.name = __stringify(_name), .mode = _mode }, \
  584. .show = _show, \
  585. .store = _store, \
  586. .private = _private, \
  587. };
  588. /* default cwrow<id>/attribute files */
  589. CSROWDEV_ATTR(size_mb,S_IRUGO,csrow_size_show,NULL,0);
  590. CSROWDEV_ATTR(dev_type,S_IRUGO,csrow_dev_type_show,NULL,0);
  591. CSROWDEV_ATTR(mem_type,S_IRUGO,csrow_mem_type_show,NULL,0);
  592. CSROWDEV_ATTR(edac_mode,S_IRUGO,csrow_edac_mode_show,NULL,0);
  593. CSROWDEV_ATTR(ue_count,S_IRUGO,csrow_ue_count_show,NULL,0);
  594. CSROWDEV_ATTR(ce_count,S_IRUGO,csrow_ce_count_show,NULL,0);
  595. /* default attributes of the CSROW<id> object */
  596. static struct csrowdev_attribute *default_csrow_attr[] = {
  597. &attr_dev_type,
  598. &attr_mem_type,
  599. &attr_edac_mode,
  600. &attr_size_mb,
  601. &attr_ue_count,
  602. &attr_ce_count,
  603. NULL,
  604. };
  605. /* possible dynamic channel DIMM Label attribute files */
  606. CSROWDEV_ATTR(ch0_dimm_label,S_IRUGO|S_IWUSR,
  607. channel_dimm_label_show,
  608. channel_dimm_label_store,
  609. 0 );
  610. CSROWDEV_ATTR(ch1_dimm_label,S_IRUGO|S_IWUSR,
  611. channel_dimm_label_show,
  612. channel_dimm_label_store,
  613. 1 );
  614. CSROWDEV_ATTR(ch2_dimm_label,S_IRUGO|S_IWUSR,
  615. channel_dimm_label_show,
  616. channel_dimm_label_store,
  617. 2 );
  618. CSROWDEV_ATTR(ch3_dimm_label,S_IRUGO|S_IWUSR,
  619. channel_dimm_label_show,
  620. channel_dimm_label_store,
  621. 3 );
  622. CSROWDEV_ATTR(ch4_dimm_label,S_IRUGO|S_IWUSR,
  623. channel_dimm_label_show,
  624. channel_dimm_label_store,
  625. 4 );
  626. CSROWDEV_ATTR(ch5_dimm_label,S_IRUGO|S_IWUSR,
  627. channel_dimm_label_show,
  628. channel_dimm_label_store,
  629. 5 );
  630. /* Total possible dynamic DIMM Label attribute file table */
  631. static struct csrowdev_attribute *dynamic_csrow_dimm_attr[] = {
  632. &attr_ch0_dimm_label,
  633. &attr_ch1_dimm_label,
  634. &attr_ch2_dimm_label,
  635. &attr_ch3_dimm_label,
  636. &attr_ch4_dimm_label,
  637. &attr_ch5_dimm_label
  638. };
  639. /* possible dynamic channel ce_count attribute files */
  640. CSROWDEV_ATTR(ch0_ce_count,S_IRUGO|S_IWUSR,
  641. channel_ce_count_show,
  642. NULL,
  643. 0 );
  644. CSROWDEV_ATTR(ch1_ce_count,S_IRUGO|S_IWUSR,
  645. channel_ce_count_show,
  646. NULL,
  647. 1 );
  648. CSROWDEV_ATTR(ch2_ce_count,S_IRUGO|S_IWUSR,
  649. channel_ce_count_show,
  650. NULL,
  651. 2 );
  652. CSROWDEV_ATTR(ch3_ce_count,S_IRUGO|S_IWUSR,
  653. channel_ce_count_show,
  654. NULL,
  655. 3 );
  656. CSROWDEV_ATTR(ch4_ce_count,S_IRUGO|S_IWUSR,
  657. channel_ce_count_show,
  658. NULL,
  659. 4 );
  660. CSROWDEV_ATTR(ch5_ce_count,S_IRUGO|S_IWUSR,
  661. channel_ce_count_show,
  662. NULL,
  663. 5 );
  664. /* Total possible dynamic ce_count attribute file table */
  665. static struct csrowdev_attribute *dynamic_csrow_ce_count_attr[] = {
  666. &attr_ch0_ce_count,
  667. &attr_ch1_ce_count,
  668. &attr_ch2_ce_count,
  669. &attr_ch3_ce_count,
  670. &attr_ch4_ce_count,
  671. &attr_ch5_ce_count
  672. };
  673. #define EDAC_NR_CHANNELS 6
  674. /* Create dynamic CHANNEL files, indexed by 'chan', under specifed CSROW */
  675. static int edac_create_channel_files(struct kobject *kobj, int chan)
  676. {
  677. int err=-ENODEV;
  678. if (chan >= EDAC_NR_CHANNELS)
  679. return err;
  680. /* create the DIMM label attribute file */
  681. err = sysfs_create_file(kobj,
  682. (struct attribute *) dynamic_csrow_dimm_attr[chan]);
  683. if (!err) {
  684. /* create the CE Count attribute file */
  685. err = sysfs_create_file(kobj,
  686. (struct attribute *) dynamic_csrow_ce_count_attr[chan]);
  687. } else {
  688. debugf1("%s() dimm labels and ce_count files created", __func__);
  689. }
  690. return err;
  691. }
  692. /* No memory to release for this kobj */
  693. static void edac_csrow_instance_release(struct kobject *kobj)
  694. {
  695. struct csrow_info *cs;
  696. cs = container_of(kobj, struct csrow_info, kobj);
  697. complete(&cs->kobj_complete);
  698. }
  699. /* the kobj_type instance for a CSROW */
  700. static struct kobj_type ktype_csrow = {
  701. .release = edac_csrow_instance_release,
  702. .sysfs_ops = &csrowfs_ops,
  703. .default_attrs = (struct attribute **) default_csrow_attr,
  704. };
  705. /* Create a CSROW object under specifed edac_mc_device */
  706. static int edac_create_csrow_object(
  707. struct kobject *edac_mci_kobj,
  708. struct csrow_info *csrow,
  709. int index)
  710. {
  711. int err = 0;
  712. int chan;
  713. memset(&csrow->kobj, 0, sizeof(csrow->kobj));
  714. /* generate ..../edac/mc/mc<id>/csrow<index> */
  715. csrow->kobj.parent = edac_mci_kobj;
  716. csrow->kobj.ktype = &ktype_csrow;
  717. /* name this instance of csrow<id> */
  718. err = kobject_set_name(&csrow->kobj,"csrow%d",index);
  719. if (err)
  720. goto error_exit;
  721. /* Instanstiate the csrow object */
  722. err = kobject_register(&csrow->kobj);
  723. if (!err) {
  724. /* Create the dyanmic attribute files on this csrow,
  725. * namely, the DIMM labels and the channel ce_count
  726. */
  727. for (chan = 0; chan < csrow->nr_channels; chan++) {
  728. err = edac_create_channel_files(&csrow->kobj,chan);
  729. if (err)
  730. break;
  731. }
  732. }
  733. error_exit:
  734. return err;
  735. }
  736. /* default sysfs methods and data structures for the main MCI kobject */
  737. static ssize_t mci_reset_counters_store(struct mem_ctl_info *mci,
  738. const char *data, size_t count)
  739. {
  740. int row, chan;
  741. mci->ue_noinfo_count = 0;
  742. mci->ce_noinfo_count = 0;
  743. mci->ue_count = 0;
  744. mci->ce_count = 0;
  745. for (row = 0; row < mci->nr_csrows; row++) {
  746. struct csrow_info *ri = &mci->csrows[row];
  747. ri->ue_count = 0;
  748. ri->ce_count = 0;
  749. for (chan = 0; chan < ri->nr_channels; chan++)
  750. ri->channels[chan].ce_count = 0;
  751. }
  752. mci->start_time = jiffies;
  753. return count;
  754. }
  755. /* default attribute files for the MCI object */
  756. static ssize_t mci_ue_count_show(struct mem_ctl_info *mci, char *data)
  757. {
  758. return sprintf(data,"%d\n", mci->ue_count);
  759. }
  760. static ssize_t mci_ce_count_show(struct mem_ctl_info *mci, char *data)
  761. {
  762. return sprintf(data,"%d\n", mci->ce_count);
  763. }
  764. static ssize_t mci_ce_noinfo_show(struct mem_ctl_info *mci, char *data)
  765. {
  766. return sprintf(data,"%d\n", mci->ce_noinfo_count);
  767. }
  768. static ssize_t mci_ue_noinfo_show(struct mem_ctl_info *mci, char *data)
  769. {
  770. return sprintf(data,"%d\n", mci->ue_noinfo_count);
  771. }
  772. static ssize_t mci_seconds_show(struct mem_ctl_info *mci, char *data)
  773. {
  774. return sprintf(data,"%ld\n", (jiffies - mci->start_time) / HZ);
  775. }
  776. static ssize_t mci_ctl_name_show(struct mem_ctl_info *mci, char *data)
  777. {
  778. return sprintf(data,"%s\n", mci->ctl_name);
  779. }
  780. static ssize_t mci_size_mb_show(struct mem_ctl_info *mci, char *data)
  781. {
  782. int total_pages, csrow_idx;
  783. for (total_pages = csrow_idx = 0; csrow_idx < mci->nr_csrows;
  784. csrow_idx++) {
  785. struct csrow_info *csrow = &mci->csrows[csrow_idx];
  786. if (!csrow->nr_pages)
  787. continue;
  788. total_pages += csrow->nr_pages;
  789. }
  790. return sprintf(data,"%u\n", PAGES_TO_MiB(total_pages));
  791. }
  792. struct mcidev_attribute {
  793. struct attribute attr;
  794. ssize_t (*show)(struct mem_ctl_info *,char *);
  795. ssize_t (*store)(struct mem_ctl_info *, const char *,size_t);
  796. };
  797. #define to_mci(k) container_of(k, struct mem_ctl_info, edac_mci_kobj)
  798. #define to_mcidev_attr(a) container_of(a, struct mcidev_attribute, attr)
  799. /* MCI show/store functions for top most object */
  800. static ssize_t mcidev_show(struct kobject *kobj, struct attribute *attr,
  801. char *buffer)
  802. {
  803. struct mem_ctl_info *mem_ctl_info = to_mci(kobj);
  804. struct mcidev_attribute * mcidev_attr = to_mcidev_attr(attr);
  805. if (mcidev_attr->show)
  806. return mcidev_attr->show(mem_ctl_info, buffer);
  807. return -EIO;
  808. }
  809. static ssize_t mcidev_store(struct kobject *kobj, struct attribute *attr,
  810. const char *buffer, size_t count)
  811. {
  812. struct mem_ctl_info *mem_ctl_info = to_mci(kobj);
  813. struct mcidev_attribute * mcidev_attr = to_mcidev_attr(attr);
  814. if (mcidev_attr->store)
  815. return mcidev_attr->store(mem_ctl_info, buffer, count);
  816. return -EIO;
  817. }
  818. static struct sysfs_ops mci_ops = {
  819. .show = mcidev_show,
  820. .store = mcidev_store
  821. };
  822. #define MCIDEV_ATTR(_name,_mode,_show,_store) \
  823. struct mcidev_attribute mci_attr_##_name = { \
  824. .attr = {.name = __stringify(_name), .mode = _mode }, \
  825. .show = _show, \
  826. .store = _store, \
  827. };
  828. /* default Control file */
  829. MCIDEV_ATTR(reset_counters,S_IWUSR,NULL,mci_reset_counters_store);
  830. /* default Attribute files */
  831. MCIDEV_ATTR(mc_name,S_IRUGO,mci_ctl_name_show,NULL);
  832. MCIDEV_ATTR(size_mb,S_IRUGO,mci_size_mb_show,NULL);
  833. MCIDEV_ATTR(seconds_since_reset,S_IRUGO,mci_seconds_show,NULL);
  834. MCIDEV_ATTR(ue_noinfo_count,S_IRUGO,mci_ue_noinfo_show,NULL);
  835. MCIDEV_ATTR(ce_noinfo_count,S_IRUGO,mci_ce_noinfo_show,NULL);
  836. MCIDEV_ATTR(ue_count,S_IRUGO,mci_ue_count_show,NULL);
  837. MCIDEV_ATTR(ce_count,S_IRUGO,mci_ce_count_show,NULL);
  838. static struct mcidev_attribute *mci_attr[] = {
  839. &mci_attr_reset_counters,
  840. &mci_attr_mc_name,
  841. &mci_attr_size_mb,
  842. &mci_attr_seconds_since_reset,
  843. &mci_attr_ue_noinfo_count,
  844. &mci_attr_ce_noinfo_count,
  845. &mci_attr_ue_count,
  846. &mci_attr_ce_count,
  847. NULL
  848. };
  849. /*
  850. * Release of a MC controlling instance
  851. */
  852. static void edac_mci_instance_release(struct kobject *kobj)
  853. {
  854. struct mem_ctl_info *mci;
  855. mci = to_mci(kobj);
  856. debugf0("%s() idx=%d\n", __func__, mci->mc_idx);
  857. complete(&mci->kobj_complete);
  858. }
  859. static struct kobj_type ktype_mci = {
  860. .release = edac_mci_instance_release,
  861. .sysfs_ops = &mci_ops,
  862. .default_attrs = (struct attribute **) mci_attr,
  863. };
  864. #define EDAC_DEVICE_SYMLINK "device"
  865. /*
  866. * Create a new Memory Controller kobject instance,
  867. * mc<id> under the 'mc' directory
  868. *
  869. * Return:
  870. * 0 Success
  871. * !0 Failure
  872. */
  873. static int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
  874. {
  875. int i;
  876. int err;
  877. struct csrow_info *csrow;
  878. struct kobject *edac_mci_kobj=&mci->edac_mci_kobj;
  879. debugf0("%s() idx=%d\n", __func__, mci->mc_idx);
  880. memset(edac_mci_kobj, 0, sizeof(*edac_mci_kobj));
  881. /* set the name of the mc<id> object */
  882. err = kobject_set_name(edac_mci_kobj,"mc%d",mci->mc_idx);
  883. if (err)
  884. return err;
  885. /* link to our parent the '..../edac/mc' object */
  886. edac_mci_kobj->parent = &edac_memctrl_kobj;
  887. edac_mci_kobj->ktype = &ktype_mci;
  888. /* register the mc<id> kobject */
  889. err = kobject_register(edac_mci_kobj);
  890. if (err)
  891. return err;
  892. /* create a symlink for the device */
  893. err = sysfs_create_link(edac_mci_kobj, &mci->dev->kobj,
  894. EDAC_DEVICE_SYMLINK);
  895. if (err)
  896. goto fail0;
  897. /* Make directories for each CSROW object
  898. * under the mc<id> kobject
  899. */
  900. for (i = 0; i < mci->nr_csrows; i++) {
  901. csrow = &mci->csrows[i];
  902. /* Only expose populated CSROWs */
  903. if (csrow->nr_pages > 0) {
  904. err = edac_create_csrow_object(edac_mci_kobj,csrow,i);
  905. if (err)
  906. goto fail1;
  907. }
  908. }
  909. return 0;
  910. /* CSROW error: backout what has already been registered, */
  911. fail1:
  912. for ( i--; i >= 0; i--) {
  913. if (csrow->nr_pages > 0) {
  914. init_completion(&csrow->kobj_complete);
  915. kobject_unregister(&mci->csrows[i].kobj);
  916. wait_for_completion(&csrow->kobj_complete);
  917. }
  918. }
  919. fail0:
  920. init_completion(&mci->kobj_complete);
  921. kobject_unregister(edac_mci_kobj);
  922. wait_for_completion(&mci->kobj_complete);
  923. return err;
  924. }
  925. /*
  926. * remove a Memory Controller instance
  927. */
  928. static void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci)
  929. {
  930. int i;
  931. debugf0("%s()\n", __func__);
  932. /* remove all csrow kobjects */
  933. for (i = 0; i < mci->nr_csrows; i++) {
  934. if (mci->csrows[i].nr_pages > 0) {
  935. init_completion(&mci->csrows[i].kobj_complete);
  936. kobject_unregister(&mci->csrows[i].kobj);
  937. wait_for_completion(&mci->csrows[i].kobj_complete);
  938. }
  939. }
  940. sysfs_remove_link(&mci->edac_mci_kobj, EDAC_DEVICE_SYMLINK);
  941. init_completion(&mci->kobj_complete);
  942. kobject_unregister(&mci->edac_mci_kobj);
  943. wait_for_completion(&mci->kobj_complete);
  944. }
  945. /* END OF sysfs data and methods */
  946. #ifdef CONFIG_EDAC_DEBUG
  947. void edac_mc_dump_channel(struct channel_info *chan)
  948. {
  949. debugf4("\tchannel = %p\n", chan);
  950. debugf4("\tchannel->chan_idx = %d\n", chan->chan_idx);
  951. debugf4("\tchannel->ce_count = %d\n", chan->ce_count);
  952. debugf4("\tchannel->label = '%s'\n", chan->label);
  953. debugf4("\tchannel->csrow = %p\n\n", chan->csrow);
  954. }
  955. EXPORT_SYMBOL_GPL(edac_mc_dump_channel);
  956. void edac_mc_dump_csrow(struct csrow_info *csrow)
  957. {
  958. debugf4("\tcsrow = %p\n", csrow);
  959. debugf4("\tcsrow->csrow_idx = %d\n", csrow->csrow_idx);
  960. debugf4("\tcsrow->first_page = 0x%lx\n",
  961. csrow->first_page);
  962. debugf4("\tcsrow->last_page = 0x%lx\n", csrow->last_page);
  963. debugf4("\tcsrow->page_mask = 0x%lx\n", csrow->page_mask);
  964. debugf4("\tcsrow->nr_pages = 0x%x\n", csrow->nr_pages);
  965. debugf4("\tcsrow->nr_channels = %d\n",
  966. csrow->nr_channels);
  967. debugf4("\tcsrow->channels = %p\n", csrow->channels);
  968. debugf4("\tcsrow->mci = %p\n\n", csrow->mci);
  969. }
  970. EXPORT_SYMBOL_GPL(edac_mc_dump_csrow);
  971. void edac_mc_dump_mci(struct mem_ctl_info *mci)
  972. {
  973. debugf3("\tmci = %p\n", mci);
  974. debugf3("\tmci->mtype_cap = %lx\n", mci->mtype_cap);
  975. debugf3("\tmci->edac_ctl_cap = %lx\n", mci->edac_ctl_cap);
  976. debugf3("\tmci->edac_cap = %lx\n", mci->edac_cap);
  977. debugf4("\tmci->edac_check = %p\n", mci->edac_check);
  978. debugf3("\tmci->nr_csrows = %d, csrows = %p\n",
  979. mci->nr_csrows, mci->csrows);
  980. debugf3("\tdev = %p\n", mci->dev);
  981. debugf3("\tmod_name:ctl_name = %s:%s\n",
  982. mci->mod_name, mci->ctl_name);
  983. debugf3("\tpvt_info = %p\n\n", mci->pvt_info);
  984. }
  985. EXPORT_SYMBOL_GPL(edac_mc_dump_mci);
  986. #endif /* CONFIG_EDAC_DEBUG */
  987. /* 'ptr' points to a possibly unaligned item X such that sizeof(X) is 'size'.
  988. * Adjust 'ptr' so that its alignment is at least as stringent as what the
  989. * compiler would provide for X and return the aligned result.
  990. *
  991. * If 'size' is a constant, the compiler will optimize this whole function
  992. * down to either a no-op or the addition of a constant to the value of 'ptr'.
  993. */
  994. static inline char * align_ptr(void *ptr, unsigned size)
  995. {
  996. unsigned align, r;
  997. /* Here we assume that the alignment of a "long long" is the most
  998. * stringent alignment that the compiler will ever provide by default.
  999. * As far as I know, this is a reasonable assumption.
  1000. */
  1001. if (size > sizeof(long))
  1002. align = sizeof(long long);
  1003. else if (size > sizeof(int))
  1004. align = sizeof(long);
  1005. else if (size > sizeof(short))
  1006. align = sizeof(int);
  1007. else if (size > sizeof(char))
  1008. align = sizeof(short);
  1009. else
  1010. return (char *) ptr;
  1011. r = size % align;
  1012. if (r == 0)
  1013. return (char *) ptr;
  1014. return (char *) (((unsigned long) ptr) + align - r);
  1015. }
  1016. /**
  1017. * edac_mc_alloc: Allocate a struct mem_ctl_info structure
  1018. * @size_pvt: size of private storage needed
  1019. * @nr_csrows: Number of CWROWS needed for this MC
  1020. * @nr_chans: Number of channels for the MC
  1021. *
  1022. * Everything is kmalloc'ed as one big chunk - more efficient.
  1023. * Only can be used if all structures have the same lifetime - otherwise
  1024. * you have to allocate and initialize your own structures.
  1025. *
  1026. * Use edac_mc_free() to free mc structures allocated by this function.
  1027. *
  1028. * Returns:
  1029. * NULL allocation failed
  1030. * struct mem_ctl_info pointer
  1031. */
  1032. struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows,
  1033. unsigned nr_chans)
  1034. {
  1035. struct mem_ctl_info *mci;
  1036. struct csrow_info *csi, *csrow;
  1037. struct channel_info *chi, *chp, *chan;
  1038. void *pvt;
  1039. unsigned size;
  1040. int row, chn;
  1041. /* Figure out the offsets of the various items from the start of an mc
  1042. * structure. We want the alignment of each item to be at least as
  1043. * stringent as what the compiler would provide if we could simply
  1044. * hardcode everything into a single struct.
  1045. */
  1046. mci = (struct mem_ctl_info *) 0;
  1047. csi = (struct csrow_info *)align_ptr(&mci[1], sizeof(*csi));
  1048. chi = (struct channel_info *)
  1049. align_ptr(&csi[nr_csrows], sizeof(*chi));
  1050. pvt = align_ptr(&chi[nr_chans * nr_csrows], sz_pvt);
  1051. size = ((unsigned long) pvt) + sz_pvt;
  1052. if ((mci = kmalloc(size, GFP_KERNEL)) == NULL)
  1053. return NULL;
  1054. /* Adjust pointers so they point within the memory we just allocated
  1055. * rather than an imaginary chunk of memory located at address 0.
  1056. */
  1057. csi = (struct csrow_info *) (((char *) mci) + ((unsigned long) csi));
  1058. chi = (struct channel_info *) (((char *) mci) + ((unsigned long) chi));
  1059. pvt = sz_pvt ? (((char *) mci) + ((unsigned long) pvt)) : NULL;
  1060. memset(mci, 0, size); /* clear all fields */
  1061. mci->csrows = csi;
  1062. mci->pvt_info = pvt;
  1063. mci->nr_csrows = nr_csrows;
  1064. for (row = 0; row < nr_csrows; row++) {
  1065. csrow = &csi[row];
  1066. csrow->csrow_idx = row;
  1067. csrow->mci = mci;
  1068. csrow->nr_channels = nr_chans;
  1069. chp = &chi[row * nr_chans];
  1070. csrow->channels = chp;
  1071. for (chn = 0; chn < nr_chans; chn++) {
  1072. chan = &chp[chn];
  1073. chan->chan_idx = chn;
  1074. chan->csrow = csrow;
  1075. }
  1076. }
  1077. return mci;
  1078. }
  1079. EXPORT_SYMBOL_GPL(edac_mc_alloc);
  1080. /**
  1081. * edac_mc_free: Free a previously allocated 'mci' structure
  1082. * @mci: pointer to a struct mem_ctl_info structure
  1083. */
  1084. void edac_mc_free(struct mem_ctl_info *mci)
  1085. {
  1086. kfree(mci);
  1087. }
  1088. EXPORT_SYMBOL_GPL(edac_mc_free);
  1089. static struct mem_ctl_info *find_mci_by_dev(struct device *dev)
  1090. {
  1091. struct mem_ctl_info *mci;
  1092. struct list_head *item;
  1093. debugf3("%s()\n", __func__);
  1094. list_for_each(item, &mc_devices) {
  1095. mci = list_entry(item, struct mem_ctl_info, link);
  1096. if (mci->dev == dev)
  1097. return mci;
  1098. }
  1099. return NULL;
  1100. }
  1101. /* Return 0 on success, 1 on failure.
  1102. * Before calling this function, caller must
  1103. * assign a unique value to mci->mc_idx.
  1104. */
  1105. static int add_mc_to_global_list (struct mem_ctl_info *mci)
  1106. {
  1107. struct list_head *item, *insert_before;
  1108. struct mem_ctl_info *p;
  1109. insert_before = &mc_devices;
  1110. if (unlikely((p = find_mci_by_dev(mci->dev)) != NULL))
  1111. goto fail0;
  1112. list_for_each(item, &mc_devices) {
  1113. p = list_entry(item, struct mem_ctl_info, link);
  1114. if (p->mc_idx >= mci->mc_idx) {
  1115. if (unlikely(p->mc_idx == mci->mc_idx))
  1116. goto fail1;
  1117. insert_before = item;
  1118. break;
  1119. }
  1120. }
  1121. list_add_tail_rcu(&mci->link, insert_before);
  1122. return 0;
  1123. fail0:
  1124. edac_printk(KERN_WARNING, EDAC_MC,
  1125. "%s (%s) %s %s already assigned %d\n", p->dev->bus_id,
  1126. dev_name(p->dev), p->mod_name, p->ctl_name, p->mc_idx);
  1127. return 1;
  1128. fail1:
  1129. edac_printk(KERN_WARNING, EDAC_MC,
  1130. "bug in low-level driver: attempt to assign\n"
  1131. " duplicate mc_idx %d in %s()\n", p->mc_idx, __func__);
  1132. return 1;
  1133. }
  1134. static void complete_mc_list_del(struct rcu_head *head)
  1135. {
  1136. struct mem_ctl_info *mci;
  1137. mci = container_of(head, struct mem_ctl_info, rcu);
  1138. INIT_LIST_HEAD(&mci->link);
  1139. complete(&mci->complete);
  1140. }
  1141. static void del_mc_from_global_list(struct mem_ctl_info *mci)
  1142. {
  1143. list_del_rcu(&mci->link);
  1144. init_completion(&mci->complete);
  1145. call_rcu(&mci->rcu, complete_mc_list_del);
  1146. wait_for_completion(&mci->complete);
  1147. }
  1148. /**
  1149. * edac_mc_add_mc: Insert the 'mci' structure into the mci global list and
  1150. * create sysfs entries associated with mci structure
  1151. * @mci: pointer to the mci structure to be added to the list
  1152. * @mc_idx: A unique numeric identifier to be assigned to the 'mci' structure.
  1153. *
  1154. * Return:
  1155. * 0 Success
  1156. * !0 Failure
  1157. */
  1158. /* FIXME - should a warning be printed if no error detection? correction? */
  1159. int edac_mc_add_mc(struct mem_ctl_info *mci, int mc_idx)
  1160. {
  1161. debugf0("%s()\n", __func__);
  1162. mci->mc_idx = mc_idx;
  1163. #ifdef CONFIG_EDAC_DEBUG
  1164. if (edac_debug_level >= 3)
  1165. edac_mc_dump_mci(mci);
  1166. if (edac_debug_level >= 4) {
  1167. int i;
  1168. for (i = 0; i < mci->nr_csrows; i++) {
  1169. int j;
  1170. edac_mc_dump_csrow(&mci->csrows[i]);
  1171. for (j = 0; j < mci->csrows[i].nr_channels; j++)
  1172. edac_mc_dump_channel(
  1173. &mci->csrows[i].channels[j]);
  1174. }
  1175. }
  1176. #endif
  1177. down(&mem_ctls_mutex);
  1178. if (add_mc_to_global_list(mci))
  1179. goto fail0;
  1180. /* set load time so that error rate can be tracked */
  1181. mci->start_time = jiffies;
  1182. if (edac_create_sysfs_mci_device(mci)) {
  1183. edac_mc_printk(mci, KERN_WARNING,
  1184. "failed to create sysfs device\n");
  1185. goto fail1;
  1186. }
  1187. /* Report action taken */
  1188. edac_mc_printk(mci, KERN_INFO, "Giving out device to %s %s: DEV %s\n",
  1189. mci->mod_name, mci->ctl_name, dev_name(mci->dev));
  1190. up(&mem_ctls_mutex);
  1191. return 0;
  1192. fail1:
  1193. del_mc_from_global_list(mci);
  1194. fail0:
  1195. up(&mem_ctls_mutex);
  1196. return 1;
  1197. }
  1198. EXPORT_SYMBOL_GPL(edac_mc_add_mc);
  1199. /**
  1200. * edac_mc_del_mc: Remove sysfs entries for specified mci structure and
  1201. * remove mci structure from global list
  1202. * @pdev: Pointer to 'struct device' representing mci structure to remove.
  1203. *
  1204. * Return pointer to removed mci structure, or NULL if device not found.
  1205. */
  1206. struct mem_ctl_info * edac_mc_del_mc(struct device *dev)
  1207. {
  1208. struct mem_ctl_info *mci;
  1209. debugf0("MC: %s()\n", __func__);
  1210. down(&mem_ctls_mutex);
  1211. if ((mci = find_mci_by_dev(dev)) == NULL) {
  1212. up(&mem_ctls_mutex);
  1213. return NULL;
  1214. }
  1215. edac_remove_sysfs_mci_device(mci);
  1216. del_mc_from_global_list(mci);
  1217. up(&mem_ctls_mutex);
  1218. edac_printk(KERN_INFO, EDAC_MC,
  1219. "Removed device %d for %s %s: DEV %s\n", mci->mc_idx,
  1220. mci->mod_name, mci->ctl_name, dev_name(mci->dev));
  1221. return mci;
  1222. }
  1223. EXPORT_SYMBOL_GPL(edac_mc_del_mc);
  1224. void edac_mc_scrub_block(unsigned long page, unsigned long offset, u32 size)
  1225. {
  1226. struct page *pg;
  1227. void *virt_addr;
  1228. unsigned long flags = 0;
  1229. debugf3("%s()\n", __func__);
  1230. /* ECC error page was not in our memory. Ignore it. */
  1231. if(!pfn_valid(page))
  1232. return;
  1233. /* Find the actual page structure then map it and fix */
  1234. pg = pfn_to_page(page);
  1235. if (PageHighMem(pg))
  1236. local_irq_save(flags);
  1237. virt_addr = kmap_atomic(pg, KM_BOUNCE_READ);
  1238. /* Perform architecture specific atomic scrub operation */
  1239. atomic_scrub(virt_addr + offset, size);
  1240. /* Unmap and complete */
  1241. kunmap_atomic(virt_addr, KM_BOUNCE_READ);
  1242. if (PageHighMem(pg))
  1243. local_irq_restore(flags);
  1244. }
  1245. EXPORT_SYMBOL_GPL(edac_mc_scrub_block);
  1246. /* FIXME - should return -1 */
  1247. int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci, unsigned long page)
  1248. {
  1249. struct csrow_info *csrows = mci->csrows;
  1250. int row, i;
  1251. debugf1("MC%d: %s(): 0x%lx\n", mci->mc_idx, __func__, page);
  1252. row = -1;
  1253. for (i = 0; i < mci->nr_csrows; i++) {
  1254. struct csrow_info *csrow = &csrows[i];
  1255. if (csrow->nr_pages == 0)
  1256. continue;
  1257. debugf3("MC%d: %s(): first(0x%lx) page(0x%lx) last(0x%lx) "
  1258. "mask(0x%lx)\n", mci->mc_idx, __func__,
  1259. csrow->first_page, page, csrow->last_page,
  1260. csrow->page_mask);
  1261. if ((page >= csrow->first_page) &&
  1262. (page <= csrow->last_page) &&
  1263. ((page & csrow->page_mask) ==
  1264. (csrow->first_page & csrow->page_mask))) {
  1265. row = i;
  1266. break;
  1267. }
  1268. }
  1269. if (row == -1)
  1270. edac_mc_printk(mci, KERN_ERR,
  1271. "could not look up page error address %lx\n",
  1272. (unsigned long) page);
  1273. return row;
  1274. }
  1275. EXPORT_SYMBOL_GPL(edac_mc_find_csrow_by_page);
  1276. /* FIXME - setable log (warning/emerg) levels */
  1277. /* FIXME - integrate with evlog: http://evlog.sourceforge.net/ */
  1278. void edac_mc_handle_ce(struct mem_ctl_info *mci,
  1279. unsigned long page_frame_number, unsigned long offset_in_page,
  1280. unsigned long syndrome, int row, int channel, const char *msg)
  1281. {
  1282. unsigned long remapped_page;
  1283. debugf3("MC%d: %s()\n", mci->mc_idx, __func__);
  1284. /* FIXME - maybe make panic on INTERNAL ERROR an option */
  1285. if (row >= mci->nr_csrows || row < 0) {
  1286. /* something is wrong */
  1287. edac_mc_printk(mci, KERN_ERR,
  1288. "INTERNAL ERROR: row out of range "
  1289. "(%d >= %d)\n", row, mci->nr_csrows);
  1290. edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR");
  1291. return;
  1292. }
  1293. if (channel >= mci->csrows[row].nr_channels || channel < 0) {
  1294. /* something is wrong */
  1295. edac_mc_printk(mci, KERN_ERR,
  1296. "INTERNAL ERROR: channel out of range "
  1297. "(%d >= %d)\n", channel,
  1298. mci->csrows[row].nr_channels);
  1299. edac_mc_handle_ce_no_info(mci, "INTERNAL ERROR");
  1300. return;
  1301. }
  1302. if (log_ce)
  1303. /* FIXME - put in DIMM location */
  1304. edac_mc_printk(mci, KERN_WARNING,
  1305. "CE page 0x%lx, offset 0x%lx, grain %d, syndrome "
  1306. "0x%lx, row %d, channel %d, label \"%s\": %s\n",
  1307. page_frame_number, offset_in_page,
  1308. mci->csrows[row].grain, syndrome, row, channel,
  1309. mci->csrows[row].channels[channel].label, msg);
  1310. mci->ce_count++;
  1311. mci->csrows[row].ce_count++;
  1312. mci->csrows[row].channels[channel].ce_count++;
  1313. if (mci->scrub_mode & SCRUB_SW_SRC) {
  1314. /*
  1315. * Some MC's can remap memory so that it is still available
  1316. * at a different address when PCI devices map into memory.
  1317. * MC's that can't do this lose the memory where PCI devices
  1318. * are mapped. This mapping is MC dependant and so we call
  1319. * back into the MC driver for it to map the MC page to
  1320. * a physical (CPU) page which can then be mapped to a virtual
  1321. * page - which can then be scrubbed.
  1322. */
  1323. remapped_page = mci->ctl_page_to_phys ?
  1324. mci->ctl_page_to_phys(mci, page_frame_number) :
  1325. page_frame_number;
  1326. edac_mc_scrub_block(remapped_page, offset_in_page,
  1327. mci->csrows[row].grain);
  1328. }
  1329. }
  1330. EXPORT_SYMBOL_GPL(edac_mc_handle_ce);
  1331. void edac_mc_handle_ce_no_info(struct mem_ctl_info *mci, const char *msg)
  1332. {
  1333. if (log_ce)
  1334. edac_mc_printk(mci, KERN_WARNING,
  1335. "CE - no information available: %s\n", msg);
  1336. mci->ce_noinfo_count++;
  1337. mci->ce_count++;
  1338. }
  1339. EXPORT_SYMBOL_GPL(edac_mc_handle_ce_no_info);
  1340. void edac_mc_handle_ue(struct mem_ctl_info *mci,
  1341. unsigned long page_frame_number, unsigned long offset_in_page,
  1342. int row, const char *msg)
  1343. {
  1344. int len = EDAC_MC_LABEL_LEN * 4;
  1345. char labels[len + 1];
  1346. char *pos = labels;
  1347. int chan;
  1348. int chars;
  1349. debugf3("MC%d: %s()\n", mci->mc_idx, __func__);
  1350. /* FIXME - maybe make panic on INTERNAL ERROR an option */
  1351. if (row >= mci->nr_csrows || row < 0) {
  1352. /* something is wrong */
  1353. edac_mc_printk(mci, KERN_ERR,
  1354. "INTERNAL ERROR: row out of range "
  1355. "(%d >= %d)\n", row, mci->nr_csrows);
  1356. edac_mc_handle_ue_no_info(mci, "INTERNAL ERROR");
  1357. return;
  1358. }
  1359. chars = snprintf(pos, len + 1, "%s",
  1360. mci->csrows[row].channels[0].label);
  1361. len -= chars;
  1362. pos += chars;
  1363. for (chan = 1; (chan < mci->csrows[row].nr_channels) && (len > 0);
  1364. chan++) {
  1365. chars = snprintf(pos, len + 1, ":%s",
  1366. mci->csrows[row].channels[chan].label);
  1367. len -= chars;
  1368. pos += chars;
  1369. }
  1370. if (log_ue)
  1371. edac_mc_printk(mci, KERN_EMERG,
  1372. "UE page 0x%lx, offset 0x%lx, grain %d, row %d, "
  1373. "labels \"%s\": %s\n", page_frame_number,
  1374. offset_in_page, mci->csrows[row].grain, row, labels,
  1375. msg);
  1376. if (panic_on_ue)
  1377. panic("EDAC MC%d: UE page 0x%lx, offset 0x%lx, grain %d, "
  1378. "row %d, labels \"%s\": %s\n", mci->mc_idx,
  1379. page_frame_number, offset_in_page,
  1380. mci->csrows[row].grain, row, labels, msg);
  1381. mci->ue_count++;
  1382. mci->csrows[row].ue_count++;
  1383. }
  1384. EXPORT_SYMBOL_GPL(edac_mc_handle_ue);
  1385. void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci, const char *msg)
  1386. {
  1387. if (panic_on_ue)
  1388. panic("EDAC MC%d: Uncorrected Error", mci->mc_idx);
  1389. if (log_ue)
  1390. edac_mc_printk(mci, KERN_WARNING,
  1391. "UE - no information available: %s\n", msg);
  1392. mci->ue_noinfo_count++;
  1393. mci->ue_count++;
  1394. }
  1395. EXPORT_SYMBOL_GPL(edac_mc_handle_ue_no_info);
  1396. /*
  1397. * Iterate over all MC instances and check for ECC, et al, errors
  1398. */
  1399. static inline void check_mc_devices(void)
  1400. {
  1401. struct list_head *item;
  1402. struct mem_ctl_info *mci;
  1403. debugf3("%s()\n", __func__);
  1404. down(&mem_ctls_mutex);
  1405. list_for_each(item, &mc_devices) {
  1406. mci = list_entry(item, struct mem_ctl_info, link);
  1407. if (mci->edac_check != NULL)
  1408. mci->edac_check(mci);
  1409. }
  1410. up(&mem_ctls_mutex);
  1411. }
  1412. /*
  1413. * Check MC status every poll_msec.
  1414. * Check PCI status every poll_msec as well.
  1415. *
  1416. * This where the work gets done for edac.
  1417. *
  1418. * SMP safe, doesn't use NMI, and auto-rate-limits.
  1419. */
  1420. static void do_edac_check(void)
  1421. {
  1422. debugf3("%s()\n", __func__);
  1423. check_mc_devices();
  1424. do_pci_parity_check();
  1425. }
  1426. static int edac_kernel_thread(void *arg)
  1427. {
  1428. while (!kthread_should_stop()) {
  1429. do_edac_check();
  1430. /* goto sleep for the interval */
  1431. schedule_timeout_interruptible((HZ * poll_msec) / 1000);
  1432. try_to_freeze();
  1433. }
  1434. return 0;
  1435. }
  1436. /*
  1437. * edac_mc_init
  1438. * module initialization entry point
  1439. */
  1440. static int __init edac_mc_init(void)
  1441. {
  1442. edac_printk(KERN_INFO, EDAC_MC, EDAC_MC_VERSION "\n");
  1443. /*
  1444. * Harvest and clear any boot/initialization PCI parity errors
  1445. *
  1446. * FIXME: This only clears errors logged by devices present at time of
  1447. * module initialization. We should also do an initial clear
  1448. * of each newly hotplugged device.
  1449. */
  1450. clear_pci_parity_errors();
  1451. /* Create the MC sysfs entries */
  1452. if (edac_sysfs_memctrl_setup()) {
  1453. edac_printk(KERN_ERR, EDAC_MC,
  1454. "Error initializing sysfs code\n");
  1455. return -ENODEV;
  1456. }
  1457. /* Create the PCI parity sysfs entries */
  1458. if (edac_sysfs_pci_setup()) {
  1459. edac_sysfs_memctrl_teardown();
  1460. edac_printk(KERN_ERR, EDAC_MC,
  1461. "EDAC PCI: Error initializing sysfs code\n");
  1462. return -ENODEV;
  1463. }
  1464. /* create our kernel thread */
  1465. edac_thread = kthread_run(edac_kernel_thread, NULL, "kedac");
  1466. if (IS_ERR(edac_thread)) {
  1467. /* remove the sysfs entries */
  1468. edac_sysfs_memctrl_teardown();
  1469. edac_sysfs_pci_teardown();
  1470. return PTR_ERR(edac_thread);
  1471. }
  1472. return 0;
  1473. }
  1474. /*
  1475. * edac_mc_exit()
  1476. * module exit/termination functioni
  1477. */
  1478. static void __exit edac_mc_exit(void)
  1479. {
  1480. debugf0("%s()\n", __func__);
  1481. kthread_stop(edac_thread);
  1482. /* tear down the sysfs device */
  1483. edac_sysfs_memctrl_teardown();
  1484. edac_sysfs_pci_teardown();
  1485. }
  1486. module_init(edac_mc_init);
  1487. module_exit(edac_mc_exit);
  1488. MODULE_LICENSE("GPL");
  1489. MODULE_AUTHOR("Linux Networx (http://lnxi.com) Thayne Harbaugh et al\n"
  1490. "Based on work by Dan Hollis et al");
  1491. MODULE_DESCRIPTION("Core library routines for MC reporting");
  1492. module_param(panic_on_ue, int, 0644);
  1493. MODULE_PARM_DESC(panic_on_ue, "Panic on uncorrected error: 0=off 1=on");
  1494. #ifdef CONFIG_PCI
  1495. module_param(check_pci_parity, int, 0644);
  1496. MODULE_PARM_DESC(check_pci_parity, "Check for PCI bus parity errors: 0=off 1=on");
  1497. module_param(panic_on_pci_parity, int, 0644);
  1498. MODULE_PARM_DESC(panic_on_pci_parity, "Panic on PCI Bus Parity error: 0=off 1=on");
  1499. #endif
  1500. module_param(log_ue, int, 0644);
  1501. MODULE_PARM_DESC(log_ue, "Log uncorrectable error to console: 0=off 1=on");
  1502. module_param(log_ce, int, 0644);
  1503. MODULE_PARM_DESC(log_ce, "Log correctable error to console: 0=off 1=on");
  1504. module_param(poll_msec, int, 0644);
  1505. MODULE_PARM_DESC(poll_msec, "Polling period in milliseconds");
  1506. #ifdef CONFIG_EDAC_DEBUG
  1507. module_param(edac_debug_level, int, 0644);
  1508. MODULE_PARM_DESC(edac_debug_level, "Debug level");
  1509. #endif