edac.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  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/kobject.h>
  16. #include <linux/completion.h>
  17. #include <linux/workqueue.h>
  18. struct device;
  19. #define EDAC_OPSTATE_INVAL -1
  20. #define EDAC_OPSTATE_POLL 0
  21. #define EDAC_OPSTATE_NMI 1
  22. #define EDAC_OPSTATE_INT 2
  23. extern int edac_op_state;
  24. extern int edac_err_assert;
  25. extern atomic_t edac_handlers;
  26. extern struct bus_type edac_subsys;
  27. extern int edac_handler_set(void);
  28. extern void edac_atomic_assert_error(void);
  29. extern struct bus_type *edac_get_sysfs_subsys(void);
  30. extern void edac_put_sysfs_subsys(void);
  31. static inline void opstate_init(void)
  32. {
  33. switch (edac_op_state) {
  34. case EDAC_OPSTATE_POLL:
  35. case EDAC_OPSTATE_NMI:
  36. break;
  37. default:
  38. edac_op_state = EDAC_OPSTATE_POLL;
  39. }
  40. return;
  41. }
  42. #define EDAC_MC_LABEL_LEN 31
  43. #define MC_PROC_NAME_MAX_LEN 7
  44. /* memory devices */
  45. enum dev_type {
  46. DEV_UNKNOWN = 0,
  47. DEV_X1,
  48. DEV_X2,
  49. DEV_X4,
  50. DEV_X8,
  51. DEV_X16,
  52. DEV_X32, /* Do these parts exist? */
  53. DEV_X64 /* Do these parts exist? */
  54. };
  55. #define DEV_FLAG_UNKNOWN BIT(DEV_UNKNOWN)
  56. #define DEV_FLAG_X1 BIT(DEV_X1)
  57. #define DEV_FLAG_X2 BIT(DEV_X2)
  58. #define DEV_FLAG_X4 BIT(DEV_X4)
  59. #define DEV_FLAG_X8 BIT(DEV_X8)
  60. #define DEV_FLAG_X16 BIT(DEV_X16)
  61. #define DEV_FLAG_X32 BIT(DEV_X32)
  62. #define DEV_FLAG_X64 BIT(DEV_X64)
  63. /**
  64. * enum hw_event_mc_err_type - type of the detected error
  65. *
  66. * @HW_EVENT_ERR_CORRECTED: Corrected Error - Indicates that an ECC
  67. * corrected error was detected
  68. * @HW_EVENT_ERR_UNCORRECTED: Uncorrected Error - Indicates an error that
  69. * can't be corrected by ECC, but it is not
  70. * fatal (maybe it is on an unused memory area,
  71. * or the memory controller could recover from
  72. * it for example, by re-trying the operation).
  73. * @HW_EVENT_ERR_FATAL: Fatal Error - Uncorrected error that could not
  74. * be recovered.
  75. */
  76. enum hw_event_mc_err_type {
  77. HW_EVENT_ERR_CORRECTED,
  78. HW_EVENT_ERR_UNCORRECTED,
  79. HW_EVENT_ERR_FATAL,
  80. };
  81. /**
  82. * enum mem_type - memory types. For a more detailed reference, please see
  83. * http://en.wikipedia.org/wiki/DRAM
  84. *
  85. * @MEM_EMPTY Empty csrow
  86. * @MEM_RESERVED: Reserved csrow type
  87. * @MEM_UNKNOWN: Unknown csrow type
  88. * @MEM_FPM: FPM - Fast Page Mode, used on systems up to 1995.
  89. * @MEM_EDO: EDO - Extended data out, used on systems up to 1998.
  90. * @MEM_BEDO: BEDO - Burst Extended data out, an EDO variant.
  91. * @MEM_SDR: SDR - Single data rate SDRAM
  92. * http://en.wikipedia.org/wiki/Synchronous_dynamic_random-access_memory
  93. * They use 3 pins for chip select: Pins 0 and 2 are
  94. * for rank 0; pins 1 and 3 are for rank 1, if the memory
  95. * is dual-rank.
  96. * @MEM_RDR: Registered SDR SDRAM
  97. * @MEM_DDR: Double data rate SDRAM
  98. * http://en.wikipedia.org/wiki/DDR_SDRAM
  99. * @MEM_RDDR: Registered Double data rate SDRAM
  100. * This is a variant of the DDR memories.
  101. * A registered memory has a buffer inside it, hiding
  102. * part of the memory details to the memory controller.
  103. * @MEM_RMBS: Rambus DRAM, used on a few Pentium III/IV controllers.
  104. * @MEM_DDR2: DDR2 RAM, as described at JEDEC JESD79-2F.
  105. * Those memories are labed as "PC2-" instead of "PC" to
  106. * differenciate from DDR.
  107. * @MEM_FB_DDR2: Fully-Buffered DDR2, as described at JEDEC Std No. 205
  108. * and JESD206.
  109. * Those memories are accessed per DIMM slot, and not by
  110. * a chip select signal.
  111. * @MEM_RDDR2: Registered DDR2 RAM
  112. * This is a variant of the DDR2 memories.
  113. * @MEM_XDR: Rambus XDR
  114. * It is an evolution of the original RAMBUS memories,
  115. * created to compete with DDR2. Weren't used on any
  116. * x86 arch, but cell_edac PPC memory controller uses it.
  117. * @MEM_DDR3: DDR3 RAM
  118. * @MEM_RDDR3: Registered DDR3 RAM
  119. * This is a variant of the DDR3 memories.
  120. */
  121. enum mem_type {
  122. MEM_EMPTY = 0,
  123. MEM_RESERVED,
  124. MEM_UNKNOWN,
  125. MEM_FPM,
  126. MEM_EDO,
  127. MEM_BEDO,
  128. MEM_SDR,
  129. MEM_RDR,
  130. MEM_DDR,
  131. MEM_RDDR,
  132. MEM_RMBS,
  133. MEM_DDR2,
  134. MEM_FB_DDR2,
  135. MEM_RDDR2,
  136. MEM_XDR,
  137. MEM_DDR3,
  138. MEM_RDDR3,
  139. };
  140. #define MEM_FLAG_EMPTY BIT(MEM_EMPTY)
  141. #define MEM_FLAG_RESERVED BIT(MEM_RESERVED)
  142. #define MEM_FLAG_UNKNOWN BIT(MEM_UNKNOWN)
  143. #define MEM_FLAG_FPM BIT(MEM_FPM)
  144. #define MEM_FLAG_EDO BIT(MEM_EDO)
  145. #define MEM_FLAG_BEDO BIT(MEM_BEDO)
  146. #define MEM_FLAG_SDR BIT(MEM_SDR)
  147. #define MEM_FLAG_RDR BIT(MEM_RDR)
  148. #define MEM_FLAG_DDR BIT(MEM_DDR)
  149. #define MEM_FLAG_RDDR BIT(MEM_RDDR)
  150. #define MEM_FLAG_RMBS BIT(MEM_RMBS)
  151. #define MEM_FLAG_DDR2 BIT(MEM_DDR2)
  152. #define MEM_FLAG_FB_DDR2 BIT(MEM_FB_DDR2)
  153. #define MEM_FLAG_RDDR2 BIT(MEM_RDDR2)
  154. #define MEM_FLAG_XDR BIT(MEM_XDR)
  155. #define MEM_FLAG_DDR3 BIT(MEM_DDR3)
  156. #define MEM_FLAG_RDDR3 BIT(MEM_RDDR3)
  157. /* chipset Error Detection and Correction capabilities and mode */
  158. enum edac_type {
  159. EDAC_UNKNOWN = 0, /* Unknown if ECC is available */
  160. EDAC_NONE, /* Doesn't support ECC */
  161. EDAC_RESERVED, /* Reserved ECC type */
  162. EDAC_PARITY, /* Detects parity errors */
  163. EDAC_EC, /* Error Checking - no correction */
  164. EDAC_SECDED, /* Single bit error correction, Double detection */
  165. EDAC_S2ECD2ED, /* Chipkill x2 devices - do these exist? */
  166. EDAC_S4ECD4ED, /* Chipkill x4 devices */
  167. EDAC_S8ECD8ED, /* Chipkill x8 devices */
  168. EDAC_S16ECD16ED, /* Chipkill x16 devices */
  169. };
  170. #define EDAC_FLAG_UNKNOWN BIT(EDAC_UNKNOWN)
  171. #define EDAC_FLAG_NONE BIT(EDAC_NONE)
  172. #define EDAC_FLAG_PARITY BIT(EDAC_PARITY)
  173. #define EDAC_FLAG_EC BIT(EDAC_EC)
  174. #define EDAC_FLAG_SECDED BIT(EDAC_SECDED)
  175. #define EDAC_FLAG_S2ECD2ED BIT(EDAC_S2ECD2ED)
  176. #define EDAC_FLAG_S4ECD4ED BIT(EDAC_S4ECD4ED)
  177. #define EDAC_FLAG_S8ECD8ED BIT(EDAC_S8ECD8ED)
  178. #define EDAC_FLAG_S16ECD16ED BIT(EDAC_S16ECD16ED)
  179. /* scrubbing capabilities */
  180. enum scrub_type {
  181. SCRUB_UNKNOWN = 0, /* Unknown if scrubber is available */
  182. SCRUB_NONE, /* No scrubber */
  183. SCRUB_SW_PROG, /* SW progressive (sequential) scrubbing */
  184. SCRUB_SW_SRC, /* Software scrub only errors */
  185. SCRUB_SW_PROG_SRC, /* Progressive software scrub from an error */
  186. SCRUB_SW_TUNABLE, /* Software scrub frequency is tunable */
  187. SCRUB_HW_PROG, /* HW progressive (sequential) scrubbing */
  188. SCRUB_HW_SRC, /* Hardware scrub only errors */
  189. SCRUB_HW_PROG_SRC, /* Progressive hardware scrub from an error */
  190. SCRUB_HW_TUNABLE /* Hardware scrub frequency is tunable */
  191. };
  192. #define SCRUB_FLAG_SW_PROG BIT(SCRUB_SW_PROG)
  193. #define SCRUB_FLAG_SW_SRC BIT(SCRUB_SW_SRC)
  194. #define SCRUB_FLAG_SW_PROG_SRC BIT(SCRUB_SW_PROG_SRC)
  195. #define SCRUB_FLAG_SW_TUN BIT(SCRUB_SW_SCRUB_TUNABLE)
  196. #define SCRUB_FLAG_HW_PROG BIT(SCRUB_HW_PROG)
  197. #define SCRUB_FLAG_HW_SRC BIT(SCRUB_HW_SRC)
  198. #define SCRUB_FLAG_HW_PROG_SRC BIT(SCRUB_HW_PROG_SRC)
  199. #define SCRUB_FLAG_HW_TUN BIT(SCRUB_HW_TUNABLE)
  200. /* FIXME - should have notify capabilities: NMI, LOG, PROC, etc */
  201. /* EDAC internal operation states */
  202. #define OP_ALLOC 0x100
  203. #define OP_RUNNING_POLL 0x201
  204. #define OP_RUNNING_INTERRUPT 0x202
  205. #define OP_RUNNING_POLL_INTR 0x203
  206. #define OP_OFFLINE 0x300
  207. /*
  208. * Concepts used at the EDAC subsystem
  209. *
  210. * There are several things to be aware of that aren't at all obvious:
  211. *
  212. * SOCKETS, SOCKET SETS, BANKS, ROWS, CHIP-SELECT ROWS, CHANNELS, etc..
  213. *
  214. * These are some of the many terms that are thrown about that don't always
  215. * mean what people think they mean (Inconceivable!). In the interest of
  216. * creating a common ground for discussion, terms and their definitions
  217. * will be established.
  218. *
  219. * Memory devices: The individual DRAM chips on a memory stick. These
  220. * devices commonly output 4 and 8 bits each (x4, x8).
  221. * Grouping several of these in parallel provides the
  222. * number of bits that the memory controller expects:
  223. * typically 72 bits, in order to provide 64 bits +
  224. * 8 bits of ECC data.
  225. *
  226. * Memory Stick: A printed circuit board that aggregates multiple
  227. * memory devices in parallel. In general, this is the
  228. * Field Replaceable Unit (FRU) which gets replaced, in
  229. * the case of excessive errors. Most often it is also
  230. * called DIMM (Dual Inline Memory Module).
  231. *
  232. * Memory Socket: A physical connector on the motherboard that accepts
  233. * a single memory stick. Also called as "slot" on several
  234. * datasheets.
  235. *
  236. * Channel: A memory controller channel, responsible to communicate
  237. * with a group of DIMMs. Each channel has its own
  238. * independent control (command) and data bus, and can
  239. * be used independently or grouped with other channels.
  240. *
  241. * Branch: It is typically the highest hierarchy on a
  242. * Fully-Buffered DIMM memory controller.
  243. * Typically, it contains two channels.
  244. * Two channels at the same branch can be used in single
  245. * mode or in lockstep mode.
  246. * When lockstep is enabled, the cacheline is doubled,
  247. * but it generally brings some performance penalty.
  248. * Also, it is generally not possible to point to just one
  249. * memory stick when an error occurs, as the error
  250. * correction code is calculated using two DIMMs instead
  251. * of one. Due to that, it is capable of correcting more
  252. * errors than on single mode.
  253. *
  254. * Single-channel: The data accessed by the memory controller is contained
  255. * into one dimm only. E. g. if the data is 64 bits-wide,
  256. * the data flows to the CPU using one 64 bits parallel
  257. * access.
  258. * Typically used with SDR, DDR, DDR2 and DDR3 memories.
  259. * FB-DIMM and RAMBUS use a different concept for channel,
  260. * so this concept doesn't apply there.
  261. *
  262. * Double-channel: The data size accessed by the memory controller is
  263. * interlaced into two dimms, accessed at the same time.
  264. * E. g. if the DIMM is 64 bits-wide (72 bits with ECC),
  265. * the data flows to the CPU using a 128 bits parallel
  266. * access.
  267. *
  268. * Chip-select row: This is the name of the DRAM signal used to select the
  269. * DRAM ranks to be accessed. Common chip-select rows for
  270. * single channel are 64 bits, for dual channel 128 bits.
  271. * It may not be visible by the memory controller, as some
  272. * DIMM types have a memory buffer that can hide direct
  273. * access to it from the Memory Controller.
  274. *
  275. * Single-Ranked stick: A Single-ranked stick has 1 chip-select row of memory.
  276. * Motherboards commonly drive two chip-select pins to
  277. * a memory stick. A single-ranked stick, will occupy
  278. * only one of those rows. The other will be unused.
  279. *
  280. * Double-Ranked stick: A double-ranked stick has two chip-select rows which
  281. * access different sets of memory devices. The two
  282. * rows cannot be accessed concurrently.
  283. *
  284. * Double-sided stick: DEPRECATED TERM, see Double-Ranked stick.
  285. * A double-sided stick has two chip-select rows which
  286. * access different sets of memory devices. The two
  287. * rows cannot be accessed concurrently. "Double-sided"
  288. * is irrespective of the memory devices being mounted
  289. * on both sides of the memory stick.
  290. *
  291. * Socket set: All of the memory sticks that are required for
  292. * a single memory access or all of the memory sticks
  293. * spanned by a chip-select row. A single socket set
  294. * has two chip-select rows and if double-sided sticks
  295. * are used these will occupy those chip-select rows.
  296. *
  297. * Bank: This term is avoided because it is unclear when
  298. * needing to distinguish between chip-select rows and
  299. * socket sets.
  300. *
  301. * Controller pages:
  302. *
  303. * Physical pages:
  304. *
  305. * Virtual pages:
  306. *
  307. *
  308. * STRUCTURE ORGANIZATION AND CHOICES
  309. *
  310. *
  311. *
  312. * PS - I enjoyed writing all that about as much as you enjoyed reading it.
  313. */
  314. /**
  315. * enum edac_mc_layer - memory controller hierarchy layer
  316. *
  317. * @EDAC_MC_LAYER_BRANCH: memory layer is named "branch"
  318. * @EDAC_MC_LAYER_CHANNEL: memory layer is named "channel"
  319. * @EDAC_MC_LAYER_SLOT: memory layer is named "slot"
  320. * @EDAC_MC_LAYER_CHIP_SELECT: memory layer is named "chip select"
  321. *
  322. * This enum is used by the drivers to tell edac_mc_sysfs what name should
  323. * be used when describing a memory stick location.
  324. */
  325. enum edac_mc_layer_type {
  326. EDAC_MC_LAYER_BRANCH,
  327. EDAC_MC_LAYER_CHANNEL,
  328. EDAC_MC_LAYER_SLOT,
  329. EDAC_MC_LAYER_CHIP_SELECT,
  330. };
  331. /**
  332. * struct edac_mc_layer - describes the memory controller hierarchy
  333. * @layer: layer type
  334. * @size: number of components per layer. For example,
  335. * if the channel layer has two channels, size = 2
  336. * @is_virt_csrow: This layer is part of the "csrow" when old API
  337. * compatibility mode is enabled. Otherwise, it is
  338. * a channel
  339. */
  340. struct edac_mc_layer {
  341. enum edac_mc_layer_type type;
  342. unsigned size;
  343. bool is_virt_csrow;
  344. };
  345. /*
  346. * Maximum number of layers used by the memory controller to uniquely
  347. * identify a single memory stick.
  348. * NOTE: Changing this constant requires not only to change the constant
  349. * below, but also to change the existing code at the core, as there are
  350. * some code there that are optimized for 3 layers.
  351. */
  352. #define EDAC_MAX_LAYERS 3
  353. /**
  354. * EDAC_DIMM_PTR - Macro responsible to find a pointer inside a pointer array
  355. * for the element given by [layer0,layer1,layer2] position
  356. *
  357. * @layers: a struct edac_mc_layer array, describing how many elements
  358. * were allocated for each layer
  359. * @var: name of the var where we want to get the pointer
  360. * (like mci->dimms)
  361. * @n_layers: Number of layers at the @layers array
  362. * @layer0: layer0 position
  363. * @layer1: layer1 position. Unused if n_layers < 2
  364. * @layer2: layer2 position. Unused if n_layers < 3
  365. *
  366. * For 1 layer, this macro returns &var[layer0]
  367. * For 2 layers, this macro is similar to allocate a bi-dimensional array
  368. * and to return "&var[layer0][layer1]"
  369. * For 3 layers, this macro is similar to allocate a tri-dimensional array
  370. * and to return "&var[layer0][layer1][layer2]"
  371. *
  372. * A loop could be used here to make it more generic, but, as we only have
  373. * 3 layers, this is a little faster.
  374. * By design, layers can never be 0 or more than 3. If that ever happens,
  375. * a NULL is returned, causing an OOPS during the memory allocation routine,
  376. * with would point to the developer that he's doing something wrong.
  377. */
  378. #define EDAC_DIMM_PTR(layers, var, nlayers, layer0, layer1, layer2) ({ \
  379. typeof(var) __p; \
  380. if ((nlayers) == 1) \
  381. __p = &var[layer0]; \
  382. else if ((nlayers) == 2) \
  383. __p = &var[(layer1) + ((layers[1]).size * (layer0))]; \
  384. else if ((nlayers) == 3) \
  385. __p = &var[(layer2) + ((layers[2]).size * ((layer1) + \
  386. ((layers[1]).size * (layer0))))]; \
  387. else \
  388. __p = NULL; \
  389. __p; \
  390. })
  391. /* FIXME: add the proper per-location error counts */
  392. struct dimm_info {
  393. char label[EDAC_MC_LABEL_LEN + 1]; /* DIMM label on motherboard */
  394. /* Memory location data */
  395. unsigned location[EDAC_MAX_LAYERS];
  396. struct mem_ctl_info *mci; /* the parent */
  397. u32 grain; /* granularity of reported error in bytes */
  398. enum dev_type dtype; /* memory device type */
  399. enum mem_type mtype; /* memory dimm type */
  400. enum edac_type edac_mode; /* EDAC mode for this dimm */
  401. u32 nr_pages; /* number of pages on this dimm */
  402. unsigned csrow, cschannel; /* Points to the old API data */
  403. };
  404. /**
  405. * struct rank_info - contains the information for one DIMM rank
  406. *
  407. * @chan_idx: channel number where the rank is (typically, 0 or 1)
  408. * @ce_count: number of correctable errors for this rank
  409. * @csrow: A pointer to the chip select row structure (the parent
  410. * structure). The location of the rank is given by
  411. * the (csrow->csrow_idx, chan_idx) vector.
  412. * @dimm: A pointer to the DIMM structure, where the DIMM label
  413. * information is stored.
  414. *
  415. * FIXME: Currently, the EDAC core model will assume one DIMM per rank.
  416. * This is a bad assumption, but it makes this patch easier. Later
  417. * patches in this series will fix this issue.
  418. */
  419. struct rank_info {
  420. int chan_idx;
  421. struct csrow_info *csrow;
  422. struct dimm_info *dimm;
  423. u32 ce_count; /* Correctable Errors for this csrow */
  424. };
  425. struct csrow_info {
  426. /* Used only by edac_mc_find_csrow_by_page() */
  427. unsigned long first_page; /* first page number in csrow */
  428. unsigned long last_page; /* last page number in csrow */
  429. unsigned long page_mask; /* used for interleaving -
  430. * 0UL for non intlv */
  431. int csrow_idx; /* the chip-select row */
  432. u32 ue_count; /* Uncorrectable Errors for this csrow */
  433. u32 ce_count; /* Correctable Errors for this csrow */
  434. struct mem_ctl_info *mci; /* the parent */
  435. struct kobject kobj; /* sysfs kobject for this csrow */
  436. /* channel information for this csrow */
  437. u32 nr_channels;
  438. struct rank_info *channels;
  439. };
  440. struct mcidev_sysfs_group {
  441. const char *name; /* group name */
  442. const struct mcidev_sysfs_attribute *mcidev_attr; /* group attributes */
  443. };
  444. struct mcidev_sysfs_group_kobj {
  445. struct list_head list; /* list for all instances within a mc */
  446. struct kobject kobj; /* kobj for the group */
  447. const struct mcidev_sysfs_group *grp; /* group description table */
  448. struct mem_ctl_info *mci; /* the parent */
  449. };
  450. /* mcidev_sysfs_attribute structure
  451. * used for driver sysfs attributes and in mem_ctl_info
  452. * sysfs top level entries
  453. */
  454. struct mcidev_sysfs_attribute {
  455. /* It should use either attr or grp */
  456. struct attribute attr;
  457. const struct mcidev_sysfs_group *grp; /* Points to a group of attributes */
  458. /* Ops for show/store values at the attribute - not used on group */
  459. ssize_t (*show)(struct mem_ctl_info *,char *);
  460. ssize_t (*store)(struct mem_ctl_info *, const char *,size_t);
  461. };
  462. /* MEMORY controller information structure
  463. */
  464. struct mem_ctl_info {
  465. struct list_head link; /* for global list of mem_ctl_info structs */
  466. struct module *owner; /* Module owner of this control struct */
  467. unsigned long mtype_cap; /* memory types supported by mc */
  468. unsigned long edac_ctl_cap; /* Mem controller EDAC capabilities */
  469. unsigned long edac_cap; /* configuration capabilities - this is
  470. * closely related to edac_ctl_cap. The
  471. * difference is that the controller may be
  472. * capable of s4ecd4ed which would be listed
  473. * in edac_ctl_cap, but if channels aren't
  474. * capable of s4ecd4ed then the edac_cap would
  475. * not have that capability.
  476. */
  477. unsigned long scrub_cap; /* chipset scrub capabilities */
  478. enum scrub_type scrub_mode; /* current scrub mode */
  479. /* Translates sdram memory scrub rate given in bytes/sec to the
  480. internal representation and configures whatever else needs
  481. to be configured.
  482. */
  483. int (*set_sdram_scrub_rate) (struct mem_ctl_info * mci, u32 bw);
  484. /* Get the current sdram memory scrub rate from the internal
  485. representation and converts it to the closest matching
  486. bandwidth in bytes/sec.
  487. */
  488. int (*get_sdram_scrub_rate) (struct mem_ctl_info * mci);
  489. /* pointer to edac checking routine */
  490. void (*edac_check) (struct mem_ctl_info * mci);
  491. /*
  492. * Remaps memory pages: controller pages to physical pages.
  493. * For most MC's, this will be NULL.
  494. */
  495. /* FIXME - why not send the phys page to begin with? */
  496. unsigned long (*ctl_page_to_phys) (struct mem_ctl_info * mci,
  497. unsigned long page);
  498. int mc_idx;
  499. struct csrow_info *csrows;
  500. unsigned nr_csrows, num_cschannel;
  501. /* Memory Controller hierarchy */
  502. unsigned n_layers;
  503. struct edac_mc_layer *layers;
  504. bool mem_is_per_rank;
  505. /*
  506. * DIMM info. Will eventually remove the entire csrows_info some day
  507. */
  508. unsigned tot_dimms;
  509. struct dimm_info *dimms;
  510. /*
  511. * FIXME - what about controllers on other busses? - IDs must be
  512. * unique. dev pointer should be sufficiently unique, but
  513. * BUS:SLOT.FUNC numbers may not be unique.
  514. */
  515. struct device *dev;
  516. const char *mod_name;
  517. const char *mod_ver;
  518. const char *ctl_name;
  519. const char *dev_name;
  520. char proc_name[MC_PROC_NAME_MAX_LEN + 1];
  521. void *pvt_info;
  522. unsigned long start_time; /* mci load start time (in jiffies) */
  523. /*
  524. * drivers shouldn't access those fields directly, as the core
  525. * already handles that.
  526. */
  527. u32 ce_noinfo_count, ue_noinfo_count;
  528. u32 ue_mc, ce_mc;
  529. u32 *ce_per_layer[EDAC_MAX_LAYERS], *ue_per_layer[EDAC_MAX_LAYERS];
  530. struct completion complete;
  531. /* edac sysfs device control */
  532. struct kobject edac_mci_kobj;
  533. /* list for all grp instances within a mc */
  534. struct list_head grp_kobj_list;
  535. /* Additional top controller level attributes, but specified
  536. * by the low level driver.
  537. *
  538. * Set by the low level driver to provide attributes at the
  539. * controller level.
  540. * An array of structures, NULL terminated
  541. *
  542. * If attributes are desired, then set to array of attributes
  543. * If no attributes are desired, leave NULL
  544. */
  545. const struct mcidev_sysfs_attribute *mc_driver_sysfs_attributes;
  546. /* work struct for this MC */
  547. struct delayed_work work;
  548. /* the internal state of this controller instance */
  549. int op_state;
  550. };
  551. #endif