edac.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. /*
  2. * Generic EDAC defs
  3. *
  4. * Author: Dave Jiang <djiang@mvista.com>
  5. *
  6. * 2006-2008 (c) MontaVista Software, Inc. This file is licensed under
  7. * the terms of the GNU General Public License version 2. This program
  8. * is licensed "as is" without any warranty of any kind, whether express
  9. * or implied.
  10. *
  11. */
  12. #ifndef _LINUX_EDAC_H_
  13. #define _LINUX_EDAC_H_
  14. #include <linux/atomic.h>
  15. #include <linux/device.h>
  16. #include <linux/completion.h>
  17. #include <linux/workqueue.h>
  18. #include <linux/debugfs.h>
  19. #define EDAC_DEVICE_NAME_LEN 31
  20. struct device;
  21. #define EDAC_OPSTATE_INVAL -1
  22. #define EDAC_OPSTATE_POLL 0
  23. #define EDAC_OPSTATE_NMI 1
  24. #define EDAC_OPSTATE_INT 2
  25. extern int edac_op_state;
  26. extern int edac_err_assert;
  27. extern atomic_t edac_handlers;
  28. extern int edac_handler_set(void);
  29. extern void edac_atomic_assert_error(void);
  30. extern struct bus_type *edac_get_sysfs_subsys(void);
  31. enum {
  32. EDAC_REPORTING_ENABLED,
  33. EDAC_REPORTING_DISABLED,
  34. EDAC_REPORTING_FORCE
  35. };
  36. extern int edac_report_status;
  37. #ifdef CONFIG_EDAC
  38. static inline int get_edac_report_status(void)
  39. {
  40. return edac_report_status;
  41. }
  42. static inline void set_edac_report_status(int new)
  43. {
  44. edac_report_status = new;
  45. }
  46. #else
  47. static inline int get_edac_report_status(void)
  48. {
  49. return EDAC_REPORTING_DISABLED;
  50. }
  51. static inline void set_edac_report_status(int new)
  52. {
  53. }
  54. #endif
  55. static inline void opstate_init(void)
  56. {
  57. switch (edac_op_state) {
  58. case EDAC_OPSTATE_POLL:
  59. case EDAC_OPSTATE_NMI:
  60. break;
  61. default:
  62. edac_op_state = EDAC_OPSTATE_POLL;
  63. }
  64. return;
  65. }
  66. /* Max length of a DIMM label*/
  67. #define EDAC_MC_LABEL_LEN 31
  68. /* Maximum size of the location string */
  69. #define LOCATION_SIZE 256
  70. /* Defines the maximum number of labels that can be reported */
  71. #define EDAC_MAX_LABELS 8
  72. /* String used to join two or more labels */
  73. #define OTHER_LABEL " or "
  74. /**
  75. * enum dev_type - describe the type of memory DRAM chips used at the stick
  76. * @DEV_UNKNOWN: Can't be determined, or MC doesn't support detect it
  77. * @DEV_X1: 1 bit for data
  78. * @DEV_X2: 2 bits for data
  79. * @DEV_X4: 4 bits for data
  80. * @DEV_X8: 8 bits for data
  81. * @DEV_X16: 16 bits for data
  82. * @DEV_X32: 32 bits for data
  83. * @DEV_X64: 64 bits for data
  84. *
  85. * Typical values are x4 and x8.
  86. */
  87. enum dev_type {
  88. DEV_UNKNOWN = 0,
  89. DEV_X1,
  90. DEV_X2,
  91. DEV_X4,
  92. DEV_X8,
  93. DEV_X16,
  94. DEV_X32, /* Do these parts exist? */
  95. DEV_X64 /* Do these parts exist? */
  96. };
  97. #define DEV_FLAG_UNKNOWN BIT(DEV_UNKNOWN)
  98. #define DEV_FLAG_X1 BIT(DEV_X1)
  99. #define DEV_FLAG_X2 BIT(DEV_X2)
  100. #define DEV_FLAG_X4 BIT(DEV_X4)
  101. #define DEV_FLAG_X8 BIT(DEV_X8)
  102. #define DEV_FLAG_X16 BIT(DEV_X16)
  103. #define DEV_FLAG_X32 BIT(DEV_X32)
  104. #define DEV_FLAG_X64 BIT(DEV_X64)
  105. /**
  106. * enum hw_event_mc_err_type - type of the detected error
  107. *
  108. * @HW_EVENT_ERR_CORRECTED: Corrected Error - Indicates that an ECC
  109. * corrected error was detected
  110. * @HW_EVENT_ERR_UNCORRECTED: Uncorrected Error - Indicates an error that
  111. * can't be corrected by ECC, but it is not
  112. * fatal (maybe it is on an unused memory area,
  113. * or the memory controller could recover from
  114. * it for example, by re-trying the operation).
  115. * @HW_EVENT_ERR_FATAL: Fatal Error - Uncorrected error that could not
  116. * be recovered.
  117. * @HW_EVENT_ERR_INFO: Informational - The CPER spec defines a forth
  118. * type of error: informational logs.
  119. */
  120. enum hw_event_mc_err_type {
  121. HW_EVENT_ERR_CORRECTED,
  122. HW_EVENT_ERR_UNCORRECTED,
  123. HW_EVENT_ERR_DEFERRED,
  124. HW_EVENT_ERR_FATAL,
  125. HW_EVENT_ERR_INFO,
  126. };
  127. static inline char *mc_event_error_type(const unsigned int err_type)
  128. {
  129. switch (err_type) {
  130. case HW_EVENT_ERR_CORRECTED:
  131. return "Corrected";
  132. case HW_EVENT_ERR_UNCORRECTED:
  133. return "Uncorrected";
  134. case HW_EVENT_ERR_DEFERRED:
  135. return "Deferred";
  136. case HW_EVENT_ERR_FATAL:
  137. return "Fatal";
  138. default:
  139. case HW_EVENT_ERR_INFO:
  140. return "Info";
  141. }
  142. }
  143. /**
  144. * enum mem_type - memory types. For a more detailed reference, please see
  145. * http://en.wikipedia.org/wiki/DRAM
  146. *
  147. * @MEM_EMPTY: Empty csrow
  148. * @MEM_RESERVED: Reserved csrow type
  149. * @MEM_UNKNOWN: Unknown csrow type
  150. * @MEM_FPM: FPM - Fast Page Mode, used on systems up to 1995.
  151. * @MEM_EDO: EDO - Extended data out, used on systems up to 1998.
  152. * @MEM_BEDO: BEDO - Burst Extended data out, an EDO variant.
  153. * @MEM_SDR: SDR - Single data rate SDRAM
  154. * http://en.wikipedia.org/wiki/Synchronous_dynamic_random-access_memory
  155. * They use 3 pins for chip select: Pins 0 and 2 are
  156. * for rank 0; pins 1 and 3 are for rank 1, if the memory
  157. * is dual-rank.
  158. * @MEM_RDR: Registered SDR SDRAM
  159. * @MEM_DDR: Double data rate SDRAM
  160. * http://en.wikipedia.org/wiki/DDR_SDRAM
  161. * @MEM_RDDR: Registered Double data rate SDRAM
  162. * This is a variant of the DDR memories.
  163. * A registered memory has a buffer inside it, hiding
  164. * part of the memory details to the memory controller.
  165. * @MEM_RMBS: Rambus DRAM, used on a few Pentium III/IV controllers.
  166. * @MEM_DDR2: DDR2 RAM, as described at JEDEC JESD79-2F.
  167. * Those memories are labed as "PC2-" instead of "PC" to
  168. * differenciate from DDR.
  169. * @MEM_FB_DDR2: Fully-Buffered DDR2, as described at JEDEC Std No. 205
  170. * and JESD206.
  171. * Those memories are accessed per DIMM slot, and not by
  172. * a chip select signal.
  173. * @MEM_RDDR2: Registered DDR2 RAM
  174. * This is a variant of the DDR2 memories.
  175. * @MEM_XDR: Rambus XDR
  176. * It is an evolution of the original RAMBUS memories,
  177. * created to compete with DDR2. Weren't used on any
  178. * x86 arch, but cell_edac PPC memory controller uses it.
  179. * @MEM_DDR3: DDR3 RAM
  180. * @MEM_RDDR3: Registered DDR3 RAM
  181. * This is a variant of the DDR3 memories.
  182. * @MEM_LRDDR3: Load-Reduced DDR3 memory.
  183. * @MEM_DDR4: Unbuffered DDR4 RAM
  184. * @MEM_RDDR4: Registered DDR4 RAM
  185. * This is a variant of the DDR4 memories.
  186. * @MEM_LRDDR4: Load-Reduced DDR4 memory.
  187. */
  188. enum mem_type {
  189. MEM_EMPTY = 0,
  190. MEM_RESERVED,
  191. MEM_UNKNOWN,
  192. MEM_FPM,
  193. MEM_EDO,
  194. MEM_BEDO,
  195. MEM_SDR,
  196. MEM_RDR,
  197. MEM_DDR,
  198. MEM_RDDR,
  199. MEM_RMBS,
  200. MEM_DDR2,
  201. MEM_FB_DDR2,
  202. MEM_RDDR2,
  203. MEM_XDR,
  204. MEM_DDR3,
  205. MEM_RDDR3,
  206. MEM_LRDDR3,
  207. MEM_DDR4,
  208. MEM_RDDR4,
  209. MEM_LRDDR4,
  210. };
  211. #define MEM_FLAG_EMPTY BIT(MEM_EMPTY)
  212. #define MEM_FLAG_RESERVED BIT(MEM_RESERVED)
  213. #define MEM_FLAG_UNKNOWN BIT(MEM_UNKNOWN)
  214. #define MEM_FLAG_FPM BIT(MEM_FPM)
  215. #define MEM_FLAG_EDO BIT(MEM_EDO)
  216. #define MEM_FLAG_BEDO BIT(MEM_BEDO)
  217. #define MEM_FLAG_SDR BIT(MEM_SDR)
  218. #define MEM_FLAG_RDR BIT(MEM_RDR)
  219. #define MEM_FLAG_DDR BIT(MEM_DDR)
  220. #define MEM_FLAG_RDDR BIT(MEM_RDDR)
  221. #define MEM_FLAG_RMBS BIT(MEM_RMBS)
  222. #define MEM_FLAG_DDR2 BIT(MEM_DDR2)
  223. #define MEM_FLAG_FB_DDR2 BIT(MEM_FB_DDR2)
  224. #define MEM_FLAG_RDDR2 BIT(MEM_RDDR2)
  225. #define MEM_FLAG_XDR BIT(MEM_XDR)
  226. #define MEM_FLAG_DDR3 BIT(MEM_DDR3)
  227. #define MEM_FLAG_RDDR3 BIT(MEM_RDDR3)
  228. #define MEM_FLAG_DDR4 BIT(MEM_DDR4)
  229. #define MEM_FLAG_RDDR4 BIT(MEM_RDDR4)
  230. #define MEM_FLAG_LRDDR4 BIT(MEM_LRDDR4)
  231. /**
  232. * enum edac-type - Error Detection and Correction capabilities and mode
  233. * @EDAC_UNKNOWN: Unknown if ECC is available
  234. * @EDAC_NONE: Doesn't support ECC
  235. * @EDAC_RESERVED: Reserved ECC type
  236. * @EDAC_PARITY: Detects parity errors
  237. * @EDAC_EC: Error Checking - no correction
  238. * @EDAC_SECDED: Single bit error correction, Double detection
  239. * @EDAC_S2ECD2ED: Chipkill x2 devices - do these exist?
  240. * @EDAC_S4ECD4ED: Chipkill x4 devices
  241. * @EDAC_S8ECD8ED: Chipkill x8 devices
  242. * @EDAC_S16ECD16ED: Chipkill x16 devices
  243. */
  244. enum edac_type {
  245. EDAC_UNKNOWN = 0,
  246. EDAC_NONE,
  247. EDAC_RESERVED,
  248. EDAC_PARITY,
  249. EDAC_EC,
  250. EDAC_SECDED,
  251. EDAC_S2ECD2ED,
  252. EDAC_S4ECD4ED,
  253. EDAC_S8ECD8ED,
  254. EDAC_S16ECD16ED,
  255. };
  256. #define EDAC_FLAG_UNKNOWN BIT(EDAC_UNKNOWN)
  257. #define EDAC_FLAG_NONE BIT(EDAC_NONE)
  258. #define EDAC_FLAG_PARITY BIT(EDAC_PARITY)
  259. #define EDAC_FLAG_EC BIT(EDAC_EC)
  260. #define EDAC_FLAG_SECDED BIT(EDAC_SECDED)
  261. #define EDAC_FLAG_S2ECD2ED BIT(EDAC_S2ECD2ED)
  262. #define EDAC_FLAG_S4ECD4ED BIT(EDAC_S4ECD4ED)
  263. #define EDAC_FLAG_S8ECD8ED BIT(EDAC_S8ECD8ED)
  264. #define EDAC_FLAG_S16ECD16ED BIT(EDAC_S16ECD16ED)
  265. /**
  266. * enum scrub_type - scrubbing capabilities
  267. * @SCRUB_UNKNOWN: Unknown if scrubber is available
  268. * @SCRUB_NONE: No scrubber
  269. * @SCRUB_SW_PROG: SW progressive (sequential) scrubbing
  270. * @SCRUB_SW_SRC: Software scrub only errors
  271. * @SCRUB_SW_PROG_SRC: Progressive software scrub from an error
  272. * @SCRUB_SW_TUNABLE: Software scrub frequency is tunable
  273. * @SCRUB_HW_PROG: HW progressive (sequential) scrubbing
  274. * @SCRUB_HW_SRC: Hardware scrub only errors
  275. * @SCRUB_HW_PROG_SRC: Progressive hardware scrub from an error
  276. * @SCRUB_HW_TUNABLE: Hardware scrub frequency is tunable
  277. */
  278. enum scrub_type {
  279. SCRUB_UNKNOWN = 0,
  280. SCRUB_NONE,
  281. SCRUB_SW_PROG,
  282. SCRUB_SW_SRC,
  283. SCRUB_SW_PROG_SRC,
  284. SCRUB_SW_TUNABLE,
  285. SCRUB_HW_PROG,
  286. SCRUB_HW_SRC,
  287. SCRUB_HW_PROG_SRC,
  288. SCRUB_HW_TUNABLE
  289. };
  290. #define SCRUB_FLAG_SW_PROG BIT(SCRUB_SW_PROG)
  291. #define SCRUB_FLAG_SW_SRC BIT(SCRUB_SW_SRC)
  292. #define SCRUB_FLAG_SW_PROG_SRC BIT(SCRUB_SW_PROG_SRC)
  293. #define SCRUB_FLAG_SW_TUN BIT(SCRUB_SW_SCRUB_TUNABLE)
  294. #define SCRUB_FLAG_HW_PROG BIT(SCRUB_HW_PROG)
  295. #define SCRUB_FLAG_HW_SRC BIT(SCRUB_HW_SRC)
  296. #define SCRUB_FLAG_HW_PROG_SRC BIT(SCRUB_HW_PROG_SRC)
  297. #define SCRUB_FLAG_HW_TUN BIT(SCRUB_HW_TUNABLE)
  298. /* FIXME - should have notify capabilities: NMI, LOG, PROC, etc */
  299. /* EDAC internal operation states */
  300. #define OP_ALLOC 0x100
  301. #define OP_RUNNING_POLL 0x201
  302. #define OP_RUNNING_INTERRUPT 0x202
  303. #define OP_RUNNING_POLL_INTR 0x203
  304. #define OP_OFFLINE 0x300
  305. /**
  306. * enum edac_mc_layer - memory controller hierarchy layer
  307. *
  308. * @EDAC_MC_LAYER_BRANCH: memory layer is named "branch"
  309. * @EDAC_MC_LAYER_CHANNEL: memory layer is named "channel"
  310. * @EDAC_MC_LAYER_SLOT: memory layer is named "slot"
  311. * @EDAC_MC_LAYER_CHIP_SELECT: memory layer is named "chip select"
  312. * @EDAC_MC_LAYER_ALL_MEM: memory layout is unknown. All memory is mapped
  313. * as a single memory area. This is used when
  314. * retrieving errors from a firmware driven driver.
  315. *
  316. * This enum is used by the drivers to tell edac_mc_sysfs what name should
  317. * be used when describing a memory stick location.
  318. */
  319. enum edac_mc_layer_type {
  320. EDAC_MC_LAYER_BRANCH,
  321. EDAC_MC_LAYER_CHANNEL,
  322. EDAC_MC_LAYER_SLOT,
  323. EDAC_MC_LAYER_CHIP_SELECT,
  324. EDAC_MC_LAYER_ALL_MEM,
  325. };
  326. /**
  327. * struct edac_mc_layer - describes the memory controller hierarchy
  328. * @type: layer type
  329. * @size: number of components per layer. For example,
  330. * if the channel layer has two channels, size = 2
  331. * @is_virt_csrow: This layer is part of the "csrow" when old API
  332. * compatibility mode is enabled. Otherwise, it is
  333. * a channel
  334. */
  335. struct edac_mc_layer {
  336. enum edac_mc_layer_type type;
  337. unsigned size;
  338. bool is_virt_csrow;
  339. };
  340. /*
  341. * Maximum number of layers used by the memory controller to uniquely
  342. * identify a single memory stick.
  343. * NOTE: Changing this constant requires not only to change the constant
  344. * below, but also to change the existing code at the core, as there are
  345. * some code there that are optimized for 3 layers.
  346. */
  347. #define EDAC_MAX_LAYERS 3
  348. /**
  349. * EDAC_DIMM_OFF - Macro responsible to get a pointer offset inside a pointer
  350. * array for the element given by [layer0,layer1,layer2]
  351. * position
  352. *
  353. * @layers: a struct edac_mc_layer array, describing how many elements
  354. * were allocated for each layer
  355. * @nlayers: Number of layers at the @layers array
  356. * @layer0: layer0 position
  357. * @layer1: layer1 position. Unused if n_layers < 2
  358. * @layer2: layer2 position. Unused if n_layers < 3
  359. *
  360. * For 1 layer, this macro returns "var[layer0] - var";
  361. *
  362. * For 2 layers, this macro is similar to allocate a bi-dimensional array
  363. * and to return "var[layer0][layer1] - var";
  364. *
  365. * For 3 layers, this macro is similar to allocate a tri-dimensional array
  366. * and to return "var[layer0][layer1][layer2] - var".
  367. *
  368. * A loop could be used here to make it more generic, but, as we only have
  369. * 3 layers, this is a little faster.
  370. *
  371. * By design, layers can never be 0 or more than 3. If that ever happens,
  372. * a NULL is returned, causing an OOPS during the memory allocation routine,
  373. * with would point to the developer that he's doing something wrong.
  374. */
  375. #define EDAC_DIMM_OFF(layers, nlayers, layer0, layer1, layer2) ({ \
  376. int __i; \
  377. if ((nlayers) == 1) \
  378. __i = layer0; \
  379. else if ((nlayers) == 2) \
  380. __i = (layer1) + ((layers[1]).size * (layer0)); \
  381. else if ((nlayers) == 3) \
  382. __i = (layer2) + ((layers[2]).size * ((layer1) + \
  383. ((layers[1]).size * (layer0)))); \
  384. else \
  385. __i = -EINVAL; \
  386. __i; \
  387. })
  388. /**
  389. * EDAC_DIMM_PTR - Macro responsible to get a pointer inside a pointer array
  390. * for the element given by [layer0,layer1,layer2] position
  391. *
  392. * @layers: a struct edac_mc_layer array, describing how many elements
  393. * were allocated for each layer
  394. * @var: name of the var where we want to get the pointer
  395. * (like mci->dimms)
  396. * @nlayers: Number of layers at the @layers array
  397. * @layer0: layer0 position
  398. * @layer1: layer1 position. Unused if n_layers < 2
  399. * @layer2: layer2 position. Unused if n_layers < 3
  400. *
  401. * For 1 layer, this macro returns "var[layer0]";
  402. *
  403. * For 2 layers, this macro is similar to allocate a bi-dimensional array
  404. * and to return "var[layer0][layer1]";
  405. *
  406. * For 3 layers, this macro is similar to allocate a tri-dimensional array
  407. * and to return "var[layer0][layer1][layer2]";
  408. */
  409. #define EDAC_DIMM_PTR(layers, var, nlayers, layer0, layer1, layer2) ({ \
  410. typeof(*var) __p; \
  411. int ___i = EDAC_DIMM_OFF(layers, nlayers, layer0, layer1, layer2); \
  412. if (___i < 0) \
  413. __p = NULL; \
  414. else \
  415. __p = (var)[___i]; \
  416. __p; \
  417. })
  418. struct dimm_info {
  419. struct device dev;
  420. char label[EDAC_MC_LABEL_LEN + 1]; /* DIMM label on motherboard */
  421. /* Memory location data */
  422. unsigned location[EDAC_MAX_LAYERS];
  423. struct mem_ctl_info *mci; /* the parent */
  424. u32 grain; /* granularity of reported error in bytes */
  425. enum dev_type dtype; /* memory device type */
  426. enum mem_type mtype; /* memory dimm type */
  427. enum edac_type edac_mode; /* EDAC mode for this dimm */
  428. u32 nr_pages; /* number of pages on this dimm */
  429. unsigned csrow, cschannel; /* Points to the old API data */
  430. };
  431. /**
  432. * struct rank_info - contains the information for one DIMM rank
  433. *
  434. * @chan_idx: channel number where the rank is (typically, 0 or 1)
  435. * @ce_count: number of correctable errors for this rank
  436. * @csrow: A pointer to the chip select row structure (the parent
  437. * structure). The location of the rank is given by
  438. * the (csrow->csrow_idx, chan_idx) vector.
  439. * @dimm: A pointer to the DIMM structure, where the DIMM label
  440. * information is stored.
  441. *
  442. * FIXME: Currently, the EDAC core model will assume one DIMM per rank.
  443. * This is a bad assumption, but it makes this patch easier. Later
  444. * patches in this series will fix this issue.
  445. */
  446. struct rank_info {
  447. int chan_idx;
  448. struct csrow_info *csrow;
  449. struct dimm_info *dimm;
  450. u32 ce_count; /* Correctable Errors for this csrow */
  451. };
  452. struct csrow_info {
  453. struct device dev;
  454. /* Used only by edac_mc_find_csrow_by_page() */
  455. unsigned long first_page; /* first page number in csrow */
  456. unsigned long last_page; /* last page number in csrow */
  457. unsigned long page_mask; /* used for interleaving -
  458. * 0UL for non intlv */
  459. int csrow_idx; /* the chip-select row */
  460. u32 ue_count; /* Uncorrectable Errors for this csrow */
  461. u32 ce_count; /* Correctable Errors for this csrow */
  462. struct mem_ctl_info *mci; /* the parent */
  463. /* channel information for this csrow */
  464. u32 nr_channels;
  465. struct rank_info **channels;
  466. };
  467. /*
  468. * struct errcount_attribute - used to store the several error counts
  469. */
  470. struct errcount_attribute_data {
  471. int n_layers;
  472. int pos[EDAC_MAX_LAYERS];
  473. int layer0, layer1, layer2;
  474. };
  475. /**
  476. * struct edac_raw_error_desc - Raw error report structure
  477. * @grain: minimum granularity for an error report, in bytes
  478. * @error_count: number of errors of the same type
  479. * @top_layer: top layer of the error (layer[0])
  480. * @mid_layer: middle layer of the error (layer[1])
  481. * @low_layer: low layer of the error (layer[2])
  482. * @page_frame_number: page where the error happened
  483. * @offset_in_page: page offset
  484. * @syndrome: syndrome of the error (or 0 if unknown or if
  485. * the syndrome is not applicable)
  486. * @msg: error message
  487. * @location: location of the error
  488. * @label: label of the affected DIMM(s)
  489. * @other_detail: other driver-specific detail about the error
  490. * @enable_per_layer_report: if false, the error affects all layers
  491. * (typically, a memory controller error)
  492. */
  493. struct edac_raw_error_desc {
  494. /*
  495. * NOTE: everything before grain won't be cleaned by
  496. * edac_raw_error_desc_clean()
  497. */
  498. char location[LOCATION_SIZE];
  499. char label[(EDAC_MC_LABEL_LEN + 1 + sizeof(OTHER_LABEL)) * EDAC_MAX_LABELS];
  500. long grain;
  501. /* the vars below and grain will be cleaned on every new error report */
  502. u16 error_count;
  503. int top_layer;
  504. int mid_layer;
  505. int low_layer;
  506. unsigned long page_frame_number;
  507. unsigned long offset_in_page;
  508. unsigned long syndrome;
  509. const char *msg;
  510. const char *other_detail;
  511. bool enable_per_layer_report;
  512. };
  513. /* MEMORY controller information structure
  514. */
  515. struct mem_ctl_info {
  516. struct device dev;
  517. struct bus_type *bus;
  518. struct list_head link; /* for global list of mem_ctl_info structs */
  519. struct module *owner; /* Module owner of this control struct */
  520. unsigned long mtype_cap; /* memory types supported by mc */
  521. unsigned long edac_ctl_cap; /* Mem controller EDAC capabilities */
  522. unsigned long edac_cap; /* configuration capabilities - this is
  523. * closely related to edac_ctl_cap. The
  524. * difference is that the controller may be
  525. * capable of s4ecd4ed which would be listed
  526. * in edac_ctl_cap, but if channels aren't
  527. * capable of s4ecd4ed then the edac_cap would
  528. * not have that capability.
  529. */
  530. unsigned long scrub_cap; /* chipset scrub capabilities */
  531. enum scrub_type scrub_mode; /* current scrub mode */
  532. /* Translates sdram memory scrub rate given in bytes/sec to the
  533. internal representation and configures whatever else needs
  534. to be configured.
  535. */
  536. int (*set_sdram_scrub_rate) (struct mem_ctl_info * mci, u32 bw);
  537. /* Get the current sdram memory scrub rate from the internal
  538. representation and converts it to the closest matching
  539. bandwidth in bytes/sec.
  540. */
  541. int (*get_sdram_scrub_rate) (struct mem_ctl_info * mci);
  542. /* pointer to edac checking routine */
  543. void (*edac_check) (struct mem_ctl_info * mci);
  544. /*
  545. * Remaps memory pages: controller pages to physical pages.
  546. * For most MC's, this will be NULL.
  547. */
  548. /* FIXME - why not send the phys page to begin with? */
  549. unsigned long (*ctl_page_to_phys) (struct mem_ctl_info * mci,
  550. unsigned long page);
  551. int mc_idx;
  552. struct csrow_info **csrows;
  553. unsigned nr_csrows, num_cschannel;
  554. /*
  555. * Memory Controller hierarchy
  556. *
  557. * There are basically two types of memory controller: the ones that
  558. * sees memory sticks ("dimms"), and the ones that sees memory ranks.
  559. * All old memory controllers enumerate memories per rank, but most
  560. * of the recent drivers enumerate memories per DIMM, instead.
  561. * When the memory controller is per rank, csbased is true.
  562. */
  563. unsigned n_layers;
  564. struct edac_mc_layer *layers;
  565. bool csbased;
  566. /*
  567. * DIMM info. Will eventually remove the entire csrows_info some day
  568. */
  569. unsigned tot_dimms;
  570. struct dimm_info **dimms;
  571. /*
  572. * FIXME - what about controllers on other busses? - IDs must be
  573. * unique. dev pointer should be sufficiently unique, but
  574. * BUS:SLOT.FUNC numbers may not be unique.
  575. */
  576. struct device *pdev;
  577. const char *mod_name;
  578. const char *mod_ver;
  579. const char *ctl_name;
  580. const char *dev_name;
  581. void *pvt_info;
  582. unsigned long start_time; /* mci load start time (in jiffies) */
  583. /*
  584. * drivers shouldn't access those fields directly, as the core
  585. * already handles that.
  586. */
  587. u32 ce_noinfo_count, ue_noinfo_count;
  588. u32 ue_mc, ce_mc;
  589. u32 *ce_per_layer[EDAC_MAX_LAYERS], *ue_per_layer[EDAC_MAX_LAYERS];
  590. struct completion complete;
  591. /* Additional top controller level attributes, but specified
  592. * by the low level driver.
  593. *
  594. * Set by the low level driver to provide attributes at the
  595. * controller level.
  596. * An array of structures, NULL terminated
  597. *
  598. * If attributes are desired, then set to array of attributes
  599. * If no attributes are desired, leave NULL
  600. */
  601. const struct mcidev_sysfs_attribute *mc_driver_sysfs_attributes;
  602. /* work struct for this MC */
  603. struct delayed_work work;
  604. /*
  605. * Used to report an error - by being at the global struct
  606. * makes the memory allocated by the EDAC core
  607. */
  608. struct edac_raw_error_desc error_desc;
  609. /* the internal state of this controller instance */
  610. int op_state;
  611. struct dentry *debugfs;
  612. u8 fake_inject_layer[EDAC_MAX_LAYERS];
  613. bool fake_inject_ue;
  614. u16 fake_inject_count;
  615. };
  616. /*
  617. * Maximum number of memory controllers in the coherent fabric.
  618. */
  619. #define EDAC_MAX_MCS 16
  620. #endif