blob: 4861542163d704fe4f629777b04df791b5c790ea [file] [log] [blame]
Douglas Thompson7c9281d2007-07-19 01:49:33 -07001/*
2 * Defines, structures, APIs for edac_core module
3 *
4 * (C) 2007 Linux Networx (http://lnxi.com)
5 * This file may be distributed under the terms of the
6 * GNU General Public License.
7 *
8 * Written by Thayne Harbaugh
9 * Based on work by Dan Hollis <goemon at anime dot net> and others.
10 * http://www.anime.net/~goemon/linux-ecc/
11 *
12 * NMI handling support added by
13 * Dave Peterson <dsp@llnl.gov> <dave_peterson@pobox.com>
14 *
15 * Refactored for multi-source files:
16 * Doug Thompson <norsk5@xmission.com>
17 *
18 */
19
20#ifndef _EDAC_CORE_H_
21#define _EDAC_CORE_H_
22
23#include <linux/kernel.h>
24#include <linux/types.h>
25#include <linux/module.h>
26#include <linux/spinlock.h>
27#include <linux/smp.h>
28#include <linux/pci.h>
29#include <linux/time.h>
30#include <linux/nmi.h>
31#include <linux/rcupdate.h>
32#include <linux/completion.h>
33#include <linux/kobject.h>
34#include <linux/platform_device.h>
Douglas Thompsone27e3da2007-07-19 01:49:36 -070035#include <linux/workqueue.h>
Mauro Carvalho Chehabddeb3542011-03-04 15:11:29 -030036#include <linux/edac.h>
Douglas Thompson7c9281d2007-07-19 01:49:33 -070037
Douglas Thompsone27e3da2007-07-19 01:49:36 -070038#define EDAC_DEVICE_NAME_LEN 31
39#define EDAC_ATTRIB_VALUE_LEN 15
Douglas Thompson7c9281d2007-07-19 01:49:33 -070040
41#if PAGE_SHIFT < 20
Andrei Konovalov76f04f22010-12-07 07:48:00 -050042#define PAGES_TO_MiB(pages) ((pages) >> (20 - PAGE_SHIFT))
43#define MiB_TO_PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
Douglas Thompson7c9281d2007-07-19 01:49:33 -070044#else /* PAGE_SHIFT > 20 */
Andrei Konovalov76f04f22010-12-07 07:48:00 -050045#define PAGES_TO_MiB(pages) ((pages) << (PAGE_SHIFT - 20))
Mauro Carvalho Chehabe9144602010-08-10 20:26:35 -030046#define MiB_TO_PAGES(mb) ((mb) >> (PAGE_SHIFT - 20))
Douglas Thompson7c9281d2007-07-19 01:49:33 -070047#endif
48
49#define edac_printk(level, prefix, fmt, arg...) \
50 printk(level "EDAC " prefix ": " fmt, ##arg)
51
52#define edac_mc_printk(mci, level, fmt, arg...) \
53 printk(level "EDAC MC%d: " fmt, mci->mc_idx, ##arg)
54
55#define edac_mc_chipset_printk(mci, level, prefix, fmt, arg...) \
56 printk(level "EDAC " prefix " MC%d: " fmt, mci->mc_idx, ##arg)
57
Douglas Thompsone27e3da2007-07-19 01:49:36 -070058#define edac_device_printk(ctl, level, fmt, arg...) \
59 printk(level "EDAC DEVICE%d: " fmt, ctl->dev_idx, ##arg)
60
Dave Jiang91b99042007-07-19 01:49:52 -070061#define edac_pci_printk(ctl, level, fmt, arg...) \
62 printk(level "EDAC PCI%d: " fmt, ctl->pci_idx, ##arg)
63
Douglas Thompson7c9281d2007-07-19 01:49:33 -070064/* prefixes for edac_printk() and edac_mc_printk() */
65#define EDAC_MC "MC"
66#define EDAC_PCI "PCI"
67#define EDAC_DEBUG "DEBUG"
68
Borislav Petkovf4ce6ec2014-08-13 23:27:55 +020069extern const char * const edac_mem_types[];
Borislav Petkov24f9a7f2010-10-07 18:29:15 +020070
Douglas Thompson7c9281d2007-07-19 01:49:33 -070071#ifdef CONFIG_EDAC_DEBUG
72extern int edac_debug_level;
73
Joe Perches956b9ba12012-04-29 17:08:39 -030074#define edac_dbg(level, fmt, ...) \
Joe Perches7e881852012-04-28 16:41:46 -030075do { \
76 if (level <= edac_debug_level) \
77 edac_printk(KERN_DEBUG, EDAC_DEBUG, \
78 "%s: " fmt, __func__, ##__VA_ARGS__); \
79} while (0)
Douglas Thompson7c9281d2007-07-19 01:49:33 -070080
Douglas Thompson079708b2007-07-19 01:49:58 -070081#else /* !CONFIG_EDAC_DEBUG */
Douglas Thompson7c9281d2007-07-19 01:49:33 -070082
Joe Perches956b9ba12012-04-29 17:08:39 -030083#define edac_dbg(level, fmt, ...) \
Joe Perches7e881852012-04-28 16:41:46 -030084do { \
85 if (0) \
86 edac_printk(KERN_DEBUG, EDAC_DEBUG, \
87 "%s: " fmt, __func__, ##__VA_ARGS__); \
88} while (0)
Douglas Thompson7c9281d2007-07-19 01:49:33 -070089
Douglas Thompson079708b2007-07-19 01:49:58 -070090#endif /* !CONFIG_EDAC_DEBUG */
Douglas Thompson7c9281d2007-07-19 01:49:33 -070091
Douglas Thompson7c9281d2007-07-19 01:49:33 -070092#define PCI_VEND_DEV(vend, dev) PCI_VENDOR_ID_ ## vend, \
93 PCI_DEVICE_ID_ ## vend ## _ ## dev
94
Stephen Rothwell17aa7e02008-05-05 13:54:19 +100095#define edac_dev_name(dev) (dev)->dev_name
Douglas Thompson7c9281d2007-07-19 01:49:33 -070096
Borislav Petkov7ac8bf92015-09-22 11:56:04 +020097#define to_mci(k) container_of(k, struct mem_ctl_info, dev)
98
Douglas Thompsone27e3da2007-07-19 01:49:36 -070099/*
Douglas Thompson42a8e392007-07-19 01:50:10 -0700100 * The following are the structures to provide for a generic
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700101 * or abstract 'edac_device'. This set of structures and the
102 * code that implements the APIs for the same, provide for
103 * registering EDAC type devices which are NOT standard memory.
104 *
105 * CPU caches (L1 and L2)
106 * DMA engines
David Mackey15ed1032012-04-17 11:30:52 -0700107 * Core CPU switches
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700108 * Fabric switch units
109 * PCIe interface controllers
110 * other EDAC/ECC type devices that can be monitored for
111 * errors, etc.
112 *
David Mackey15ed1032012-04-17 11:30:52 -0700113 * It allows for a 2 level set of hierarchy. For example:
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700114 *
115 * cache could be composed of L1, L2 and L3 levels of cache.
116 * Each CPU core would have its own L1 cache, while sharing
117 * L2 and maybe L3 caches.
118 *
119 * View them arranged, via the sysfs presentation:
120 * /sys/devices/system/edac/..
121 *
122 * mc/ <existing memory device directory>
123 * cpu/cpu0/.. <L1 and L2 block directory>
124 * /L1-cache/ce_count
125 * /ue_count
126 * /L2-cache/ce_count
127 * /ue_count
128 * cpu/cpu1/.. <L1 and L2 block directory>
129 * /L1-cache/ce_count
130 * /ue_count
131 * /L2-cache/ce_count
132 * /ue_count
133 * ...
134 *
135 * the L1 and L2 directories would be "edac_device_block's"
136 */
137
138struct edac_device_counter {
Douglas Thompson079708b2007-07-19 01:49:58 -0700139 u32 ue_count;
140 u32 ce_count;
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700141};
142
Douglas Thompsonfd309a9d2007-07-19 01:50:25 -0700143/* forward reference */
144struct edac_device_ctl_info;
145struct edac_device_block;
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700146
Douglas Thompsonfd309a9d2007-07-19 01:50:25 -0700147/* edac_dev_sysfs_attribute structure
148 * used for driver sysfs attributes in mem_ctl_info
149 * for extra controls and attributes:
150 * like high level error Injection controls
151 */
152struct edac_dev_sysfs_attribute {
153 struct attribute attr;
154 ssize_t (*show)(struct edac_device_ctl_info *, char *);
155 ssize_t (*store)(struct edac_device_ctl_info *, const char *, size_t);
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700156};
157
Douglas Thompsonfd309a9d2007-07-19 01:50:25 -0700158/* edac_dev_sysfs_block_attribute structure
Doug Thompsonb2a4ac02007-07-19 01:50:33 -0700159 *
Douglas Thompsonfd309a9d2007-07-19 01:50:25 -0700160 * used in leaf 'block' nodes for adding controls/attributes
Doug Thompsonb2a4ac02007-07-19 01:50:33 -0700161 *
162 * each block in each instance of the containing control structure
163 * can have an array of the following. The show and store functions
164 * will be filled in with the show/store function in the
165 * low level driver.
166 *
167 * The 'value' field will be the actual value field used for
168 * counting
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700169 */
Douglas Thompsonfd309a9d2007-07-19 01:50:25 -0700170struct edac_dev_sysfs_block_attribute {
171 struct attribute attr;
172 ssize_t (*show)(struct kobject *, struct attribute *, char *);
173 ssize_t (*store)(struct kobject *, struct attribute *,
174 const char *, size_t);
175 struct edac_device_block *block;
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700176
Douglas Thompsonfd309a9d2007-07-19 01:50:25 -0700177 unsigned int value;
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700178};
179
180/* device block control structure */
181struct edac_device_block {
182 struct edac_device_instance *instance; /* Up Pointer */
Douglas Thompson079708b2007-07-19 01:49:58 -0700183 char name[EDAC_DEVICE_NAME_LEN + 1];
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700184
185 struct edac_device_counter counters; /* basic UE and CE counters */
186
Douglas Thompson079708b2007-07-19 01:49:58 -0700187 int nr_attribs; /* how many attributes */
Douglas Thompsonfd309a9d2007-07-19 01:50:25 -0700188
189 /* this block's attributes, could be NULL */
190 struct edac_dev_sysfs_block_attribute *block_attributes;
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700191
192 /* edac sysfs device control */
193 struct kobject kobj;
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700194};
195
196/* device instance control structure */
197struct edac_device_instance {
198 struct edac_device_ctl_info *ctl; /* Up pointer */
199 char name[EDAC_DEVICE_NAME_LEN + 4];
200
201 struct edac_device_counter counters; /* instance counters */
202
Douglas Thompson079708b2007-07-19 01:49:58 -0700203 u32 nr_blocks; /* how many blocks */
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700204 struct edac_device_block *blocks; /* block array */
205
206 /* edac sysfs device control */
207 struct kobject kobj;
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700208};
209
Douglas Thompson42a8e392007-07-19 01:50:10 -0700210
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700211/*
212 * Abstract edac_device control info structure
213 *
214 */
215struct edac_device_ctl_info {
216 /* for global list of edac_device_ctl_info structs */
217 struct list_head link;
218
Douglas Thompson1c3631f2007-07-19 01:50:29 -0700219 struct module *owner; /* Module owner of this control struct */
220
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700221 int dev_idx;
222
223 /* Per instance controls for this edac_device */
224 int log_ue; /* boolean for logging UEs */
225 int log_ce; /* boolean for logging CEs */
226 int panic_on_ue; /* boolean for panic'ing on an UE */
227 unsigned poll_msec; /* number of milliseconds to poll interval */
228 unsigned long delay; /* number of jiffies for poll_msec */
229
Douglas Thompson42a8e392007-07-19 01:50:10 -0700230 /* Additional top controller level attributes, but specified
231 * by the low level driver.
232 *
233 * Set by the low level driver to provide attributes at the
234 * controller level, same level as 'ue_count' and 'ce_count' above.
235 * An array of structures, NULL terminated
236 *
237 * If attributes are desired, then set to array of attributes
238 * If no attributes are desired, leave NULL
239 */
240 struct edac_dev_sysfs_attribute *sysfs_attributes;
241
Kay Sieversfe5ff8b2011-12-14 15:21:07 -0800242 /* pointer to main 'edac' subsys in sysfs */
243 struct bus_type *edac_subsys;
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700244
245 /* the internal state of this controller instance */
246 int op_state;
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700247 /* work struct for this instance */
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700248 struct delayed_work work;
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700249
250 /* pointer to edac polling checking routine:
Douglas Thompson079708b2007-07-19 01:49:58 -0700251 * If NOT NULL: points to polling check routine
252 * If NULL: Then assumes INTERRUPT operation, where
253 * MC driver will receive events
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700254 */
255 void (*edac_check) (struct edac_device_ctl_info * edac_dev);
256
257 struct device *dev; /* pointer to device structure */
258
259 const char *mod_name; /* module name */
260 const char *ctl_name; /* edac controller name */
Dave Jiangc4192702007-07-19 01:49:47 -0700261 const char *dev_name; /* pci/platform/etc... name */
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700262
263 void *pvt_info; /* pointer to 'private driver' info */
264
Douglas Thompson079708b2007-07-19 01:49:58 -0700265 unsigned long start_time; /* edac_device load start time (jiffies) */
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700266
Douglas Thompson1c3631f2007-07-19 01:50:29 -0700267 struct completion removal_complete;
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700268
269 /* sysfs top name under 'edac' directory
270 * and instance name:
Douglas Thompson079708b2007-07-19 01:49:58 -0700271 * cpu/cpu0/...
272 * cpu/cpu1/...
273 * cpu/cpu2/...
274 * ...
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700275 */
276 char name[EDAC_DEVICE_NAME_LEN + 1];
277
278 /* Number of instances supported on this control structure
279 * and the array of those instances
280 */
281 u32 nr_instances;
282 struct edac_device_instance *instances;
283
284 /* Event counters for the this whole EDAC Device */
285 struct edac_device_counter counters;
286
287 /* edac sysfs device control for the 'name'
288 * device this structure controls
289 */
290 struct kobject kobj;
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700291};
292
293/* To get from the instance's wq to the beginning of the ctl structure */
Dave Jiang81d87cb2007-07-19 01:49:52 -0700294#define to_edac_mem_ctl_work(w) \
295 container_of(w, struct mem_ctl_info, work)
296
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700297#define to_edac_device_ctl_work(w) \
298 container_of(w,struct edac_device_ctl_info,work)
299
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700300/*
301 * The alloc() and free() functions for the 'edac_device' control info
302 * structure. A MC driver will allocate one of these for each edac_device
303 * it is going to control/register with the EDAC CORE.
304 */
305extern struct edac_device_ctl_info *edac_device_alloc_ctl_info(
Douglas Thompson079708b2007-07-19 01:49:58 -0700306 unsigned sizeof_private,
Douglas Thompsonfd309a9d2007-07-19 01:50:25 -0700307 char *edac_device_name, unsigned nr_instances,
308 char *edac_block_name, unsigned nr_blocks,
Douglas Thompson079708b2007-07-19 01:49:58 -0700309 unsigned offset_value,
Douglas Thompsonfd309a9d2007-07-19 01:50:25 -0700310 struct edac_dev_sysfs_block_attribute *block_attributes,
Doug Thompsond45e7822007-07-19 01:50:27 -0700311 unsigned nr_attribs,
312 int device_index);
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700313
314/* The offset value can be:
315 * -1 indicating no offset value
316 * 0 for zero-based block numbers
317 * 1 for 1-based block number
318 * other for other-based block number
319 */
320#define BLOCK_OFFSET_VALUE_OFF ((unsigned) -1)
321
Douglas Thompson079708b2007-07-19 01:49:58 -0700322extern void edac_device_free_ctl_info(struct edac_device_ctl_info *ctl_info);
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700323
Douglas Thompson7c9281d2007-07-19 01:49:33 -0700324#ifdef CONFIG_PCI
325
Dave Jiang91b99042007-07-19 01:49:52 -0700326struct edac_pci_counter {
Douglas Thompson079708b2007-07-19 01:49:58 -0700327 atomic_t pe_count;
328 atomic_t npe_count;
Dave Jiang91b99042007-07-19 01:49:52 -0700329};
330
331/*
332 * Abstract edac_pci control info structure
333 *
334 */
335struct edac_pci_ctl_info {
336 /* for global list of edac_pci_ctl_info structs */
337 struct list_head link;
338
339 int pci_idx;
340
Kay Sieversfe5ff8b2011-12-14 15:21:07 -0800341 struct bus_type *edac_subsys; /* pointer to subsystem */
Dave Jiang91b99042007-07-19 01:49:52 -0700342
343 /* the internal state of this controller instance */
344 int op_state;
345 /* work struct for this instance */
Dave Jiang91b99042007-07-19 01:49:52 -0700346 struct delayed_work work;
Dave Jiang91b99042007-07-19 01:49:52 -0700347
348 /* pointer to edac polling checking routine:
Douglas Thompson079708b2007-07-19 01:49:58 -0700349 * If NOT NULL: points to polling check routine
350 * If NULL: Then assumes INTERRUPT operation, where
351 * MC driver will receive events
Dave Jiang91b99042007-07-19 01:49:52 -0700352 */
353 void (*edac_check) (struct edac_pci_ctl_info * edac_dev);
354
355 struct device *dev; /* pointer to device structure */
356
357 const char *mod_name; /* module name */
358 const char *ctl_name; /* edac controller name */
359 const char *dev_name; /* pci/platform/etc... name */
360
361 void *pvt_info; /* pointer to 'private driver' info */
362
Douglas Thompson079708b2007-07-19 01:49:58 -0700363 unsigned long start_time; /* edac_pci load start time (jiffies) */
Dave Jiang91b99042007-07-19 01:49:52 -0700364
Dave Jiang91b99042007-07-19 01:49:52 -0700365 struct completion complete;
366
367 /* sysfs top name under 'edac' directory
368 * and instance name:
Douglas Thompson079708b2007-07-19 01:49:58 -0700369 * cpu/cpu0/...
370 * cpu/cpu1/...
371 * cpu/cpu2/...
372 * ...
Dave Jiang91b99042007-07-19 01:49:52 -0700373 */
374 char name[EDAC_DEVICE_NAME_LEN + 1];
375
376 /* Event counters for the this whole EDAC Device */
377 struct edac_pci_counter counters;
378
379 /* edac sysfs device control for the 'name'
380 * device this structure controls
381 */
382 struct kobject kobj;
383 struct completion kobj_complete;
384};
385
386#define to_edac_pci_ctl_work(w) \
387 container_of(w, struct edac_pci_ctl_info,work)
388
Douglas Thompson7c9281d2007-07-19 01:49:33 -0700389/* write all or some bits in a byte-register*/
390static inline void pci_write_bits8(struct pci_dev *pdev, int offset, u8 value,
Douglas Thompson079708b2007-07-19 01:49:58 -0700391 u8 mask)
Douglas Thompson7c9281d2007-07-19 01:49:33 -0700392{
393 if (mask != 0xff) {
394 u8 buf;
395
396 pci_read_config_byte(pdev, offset, &buf);
397 value &= mask;
398 buf &= ~mask;
399 value |= buf;
400 }
401
402 pci_write_config_byte(pdev, offset, value);
403}
404
405/* write all or some bits in a word-register*/
406static inline void pci_write_bits16(struct pci_dev *pdev, int offset,
Douglas Thompson079708b2007-07-19 01:49:58 -0700407 u16 value, u16 mask)
Douglas Thompson7c9281d2007-07-19 01:49:33 -0700408{
409 if (mask != 0xffff) {
410 u16 buf;
411
412 pci_read_config_word(pdev, offset, &buf);
413 value &= mask;
414 buf &= ~mask;
415 value |= buf;
416 }
417
418 pci_write_config_word(pdev, offset, value);
419}
420
Jeff Harane6da46b2009-04-13 14:40:20 -0700421/*
422 * pci_write_bits32
423 *
424 * edac local routine to do pci_write_config_dword, but adds
425 * a mask parameter. If mask is all ones, ignore the mask.
426 * Otherwise utilize the mask to isolate specified bits
427 *
428 * write all or some bits in a dword-register
429 */
Douglas Thompson7c9281d2007-07-19 01:49:33 -0700430static inline void pci_write_bits32(struct pci_dev *pdev, int offset,
Douglas Thompson079708b2007-07-19 01:49:58 -0700431 u32 value, u32 mask)
Douglas Thompson7c9281d2007-07-19 01:49:33 -0700432{
Jeff Harane6da46b2009-04-13 14:40:20 -0700433 if (mask != 0xffffffff) {
Douglas Thompson7c9281d2007-07-19 01:49:33 -0700434 u32 buf;
435
436 pci_read_config_dword(pdev, offset, &buf);
437 value &= mask;
438 buf &= ~mask;
439 value |= buf;
440 }
441
442 pci_write_config_dword(pdev, offset, value);
443}
444
Douglas Thompson079708b2007-07-19 01:49:58 -0700445#endif /* CONFIG_PCI */
Douglas Thompson7c9281d2007-07-19 01:49:33 -0700446
Mauro Carvalho Chehabca0907b2012-05-02 14:37:00 -0300447struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
Mauro Carvalho Chehab4275be62012-04-18 15:20:50 -0300448 unsigned n_layers,
449 struct edac_mc_layer *layers,
450 unsigned sz_pvt);
Takashi Iwai4e8d2302015-02-04 11:48:52 +0100451extern int edac_mc_add_mc_with_groups(struct mem_ctl_info *mci,
452 const struct attribute_group **groups);
453#define edac_mc_add_mc(mci) edac_mc_add_mc_with_groups(mci, NULL)
Doug Thompsonb8f6f972007-07-19 01:50:26 -0700454extern void edac_mc_free(struct mem_ctl_info *mci);
Douglas Thompson079708b2007-07-19 01:49:58 -0700455extern struct mem_ctl_info *edac_mc_find(int idx);
Mauro Carvalho Chehab939747bd2010-08-10 11:22:01 -0300456extern struct mem_ctl_info *find_mci_by_dev(struct device *dev);
Douglas Thompson079708b2007-07-19 01:49:58 -0700457extern struct mem_ctl_info *edac_mc_del_mc(struct device *dev);
Douglas Thompson7c9281d2007-07-19 01:49:33 -0700458extern int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci,
Douglas Thompson079708b2007-07-19 01:49:58 -0700459 unsigned long page);
Mauro Carvalho Chehabe7e24832012-10-31 13:46:11 -0300460
461void edac_raw_mc_handle_error(const enum hw_event_mc_err_type type,
462 struct mem_ctl_info *mci,
463 struct edac_raw_error_desc *e);
464
Mauro Carvalho Chehab4275be62012-04-18 15:20:50 -0300465void edac_mc_handle_error(const enum hw_event_mc_err_type type,
466 struct mem_ctl_info *mci,
Mauro Carvalho Chehab9eb07a72012-06-04 13:27:43 -0300467 const u16 error_count,
Mauro Carvalho Chehab4275be62012-04-18 15:20:50 -0300468 const unsigned long page_frame_number,
469 const unsigned long offset_in_page,
470 const unsigned long syndrome,
Mauro Carvalho Chehab53f2d022012-02-23 08:10:34 -0300471 const int top_layer,
472 const int mid_layer,
473 const int low_layer,
Mauro Carvalho Chehab4275be62012-04-18 15:20:50 -0300474 const char *msg,
Mauro Carvalho Chehab03f7eae2012-06-04 11:29:25 -0300475 const char *other_detail);
Douglas Thompson7c9281d2007-07-19 01:49:33 -0700476
477/*
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700478 * edac_device APIs
Douglas Thompson7c9281d2007-07-19 01:49:33 -0700479 */
Doug Thompsond45e7822007-07-19 01:50:27 -0700480extern int edac_device_add_device(struct edac_device_ctl_info *edac_dev);
Douglas Thompson079708b2007-07-19 01:49:58 -0700481extern struct edac_device_ctl_info *edac_device_del_device(struct device *dev);
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700482extern void edac_device_handle_ue(struct edac_device_ctl_info *edac_dev,
Doug Thompsonb8f6f972007-07-19 01:50:26 -0700483 int inst_nr, int block_nr, const char *msg);
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700484extern void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev,
Doug Thompsonb8f6f972007-07-19 01:50:26 -0700485 int inst_nr, int block_nr, const char *msg);
Harry Ciao1dc9b702009-06-17 16:27:59 -0700486extern int edac_device_alloc_index(void);
Mauro Carvalho Chehab4275be62012-04-18 15:20:50 -0300487extern const char *edac_layer_name[];
Douglas Thompsone27e3da2007-07-19 01:49:36 -0700488
Dave Jiang91b99042007-07-19 01:49:52 -0700489/*
490 * edac_pci APIs
491 */
Doug Thompsonb8f6f972007-07-19 01:50:26 -0700492extern struct edac_pci_ctl_info *edac_pci_alloc_ctl_info(unsigned int sz_pvt,
493 const char *edac_pci_name);
Dave Jiang91b99042007-07-19 01:49:52 -0700494
495extern void edac_pci_free_ctl_info(struct edac_pci_ctl_info *pci);
496
Doug Thompsonb8f6f972007-07-19 01:50:26 -0700497extern void edac_pci_reset_delay_period(struct edac_pci_ctl_info *pci,
498 unsigned long value);
Dave Jiang91b99042007-07-19 01:49:52 -0700499
Harry Ciao8641a382009-04-02 16:58:47 -0700500extern int edac_pci_alloc_index(void);
Dave Jiang91b99042007-07-19 01:49:52 -0700501extern int edac_pci_add_device(struct edac_pci_ctl_info *pci, int edac_idx);
Douglas Thompson079708b2007-07-19 01:49:58 -0700502extern struct edac_pci_ctl_info *edac_pci_del_device(struct device *dev);
Dave Jiang91b99042007-07-19 01:49:52 -0700503
Doug Thompsonb8f6f972007-07-19 01:50:26 -0700504extern struct edac_pci_ctl_info *edac_pci_create_generic_ctl(
505 struct device *dev,
506 const char *mod_name);
Dave Jiang91b99042007-07-19 01:49:52 -0700507
508extern void edac_pci_release_generic_ctl(struct edac_pci_ctl_info *pci);
509extern int edac_pci_create_sysfs(struct edac_pci_ctl_info *pci);
510extern void edac_pci_remove_sysfs(struct edac_pci_ctl_info *pci);
511
512/*
513 * edac misc APIs
514 */
Douglas Thompson494d0d52007-07-19 01:50:21 -0700515extern char *edac_op_state_to_string(int op_state);
Douglas Thompson7c9281d2007-07-19 01:49:33 -0700516
517#endif /* _EDAC_CORE_H_ */