2007-07-19 02:49:33 -06:00
|
|
|
/*
|
|
|
|
* Defines, structures, APIs for edac_core module
|
|
|
|
*
|
|
|
|
* (C) 2007 Linux Networx (http://lnxi.com)
|
|
|
|
* This file may be distributed under the terms of the
|
|
|
|
* GNU General Public License.
|
|
|
|
*
|
|
|
|
* Written by Thayne Harbaugh
|
|
|
|
* Based on work by Dan Hollis <goemon at anime dot net> and others.
|
|
|
|
* http://www.anime.net/~goemon/linux-ecc/
|
|
|
|
*
|
|
|
|
* NMI handling support added by
|
|
|
|
* Dave Peterson <dsp@llnl.gov> <dave_peterson@pobox.com>
|
|
|
|
*
|
|
|
|
* Refactored for multi-source files:
|
|
|
|
* Doug Thompson <norsk5@xmission.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _EDAC_CORE_H_
|
|
|
|
#define _EDAC_CORE_H_
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/time.h>
|
|
|
|
#include <linux/nmi.h>
|
|
|
|
#include <linux/rcupdate.h>
|
|
|
|
#include <linux/completion.h>
|
|
|
|
#include <linux/kobject.h>
|
|
|
|
#include <linux/platform_device.h>
|
2007-07-19 02:49:36 -06:00
|
|
|
#include <linux/workqueue.h>
|
2011-03-04 11:11:29 -07:00
|
|
|
#include <linux/edac.h>
|
2007-07-19 02:49:33 -06:00
|
|
|
|
2007-07-19 02:49:36 -06:00
|
|
|
#define EDAC_DEVICE_NAME_LEN 31
|
|
|
|
#define EDAC_ATTRIB_VALUE_LEN 15
|
2007-07-19 02:49:33 -06:00
|
|
|
|
|
|
|
#if PAGE_SHIFT < 20
|
2010-12-07 05:48:00 -07:00
|
|
|
#define PAGES_TO_MiB(pages) ((pages) >> (20 - PAGE_SHIFT))
|
|
|
|
#define MiB_TO_PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
|
2007-07-19 02:49:33 -06:00
|
|
|
#else /* PAGE_SHIFT > 20 */
|
2010-12-07 05:48:00 -07:00
|
|
|
#define PAGES_TO_MiB(pages) ((pages) << (PAGE_SHIFT - 20))
|
2010-08-10 17:26:35 -06:00
|
|
|
#define MiB_TO_PAGES(mb) ((mb) >> (PAGE_SHIFT - 20))
|
2007-07-19 02:49:33 -06:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define edac_printk(level, prefix, fmt, arg...) \
|
|
|
|
printk(level "EDAC " prefix ": " fmt, ##arg)
|
|
|
|
|
|
|
|
#define edac_mc_printk(mci, level, fmt, arg...) \
|
|
|
|
printk(level "EDAC MC%d: " fmt, mci->mc_idx, ##arg)
|
|
|
|
|
|
|
|
#define edac_mc_chipset_printk(mci, level, prefix, fmt, arg...) \
|
|
|
|
printk(level "EDAC " prefix " MC%d: " fmt, mci->mc_idx, ##arg)
|
|
|
|
|
2007-07-19 02:49:36 -06:00
|
|
|
#define edac_device_printk(ctl, level, fmt, arg...) \
|
|
|
|
printk(level "EDAC DEVICE%d: " fmt, ctl->dev_idx, ##arg)
|
|
|
|
|
2007-07-19 02:49:52 -06:00
|
|
|
#define edac_pci_printk(ctl, level, fmt, arg...) \
|
|
|
|
printk(level "EDAC PCI%d: " fmt, ctl->pci_idx, ##arg)
|
|
|
|
|
2007-07-19 02:49:33 -06:00
|
|
|
/* prefixes for edac_printk() and edac_mc_printk() */
|
|
|
|
#define EDAC_MC "MC"
|
|
|
|
#define EDAC_PCI "PCI"
|
|
|
|
#define EDAC_DEBUG "DEBUG"
|
|
|
|
|
2010-10-07 10:29:15 -06:00
|
|
|
extern const char *edac_mem_types[];
|
|
|
|
|
2007-07-19 02:49:33 -06:00
|
|
|
#ifdef CONFIG_EDAC_DEBUG
|
|
|
|
extern int edac_debug_level;
|
|
|
|
|
2012-04-29 14:08:39 -06:00
|
|
|
#define edac_dbg(level, fmt, ...) \
|
2012-04-28 13:41:46 -06:00
|
|
|
do { \
|
|
|
|
if (level <= edac_debug_level) \
|
|
|
|
edac_printk(KERN_DEBUG, EDAC_DEBUG, \
|
|
|
|
"%s: " fmt, __func__, ##__VA_ARGS__); \
|
|
|
|
} while (0)
|
2007-07-19 02:49:33 -06:00
|
|
|
|
2007-07-19 02:49:58 -06:00
|
|
|
#else /* !CONFIG_EDAC_DEBUG */
|
2007-07-19 02:49:33 -06:00
|
|
|
|
2012-04-29 14:08:39 -06:00
|
|
|
#define edac_dbg(level, fmt, ...) \
|
2012-04-28 13:41:46 -06:00
|
|
|
do { \
|
|
|
|
if (0) \
|
|
|
|
edac_printk(KERN_DEBUG, EDAC_DEBUG, \
|
|
|
|
"%s: " fmt, __func__, ##__VA_ARGS__); \
|
|
|
|
} while (0)
|
2007-07-19 02:49:33 -06:00
|
|
|
|
2007-07-19 02:49:58 -06:00
|
|
|
#endif /* !CONFIG_EDAC_DEBUG */
|
2007-07-19 02:49:33 -06:00
|
|
|
|
|
|
|
#define PCI_VEND_DEV(vend, dev) PCI_VENDOR_ID_ ## vend, \
|
|
|
|
PCI_DEVICE_ID_ ## vend ## _ ## dev
|
|
|
|
|
2008-05-04 21:54:19 -06:00
|
|
|
#define edac_dev_name(dev) (dev)->dev_name
|
2007-07-19 02:49:33 -06:00
|
|
|
|
2007-07-19 02:49:36 -06:00
|
|
|
/*
|
2007-07-19 02:50:10 -06:00
|
|
|
* The following are the structures to provide for a generic
|
2007-07-19 02:49:36 -06:00
|
|
|
* or abstract 'edac_device'. This set of structures and the
|
|
|
|
* code that implements the APIs for the same, provide for
|
|
|
|
* registering EDAC type devices which are NOT standard memory.
|
|
|
|
*
|
|
|
|
* CPU caches (L1 and L2)
|
|
|
|
* DMA engines
|
2012-04-17 12:30:52 -06:00
|
|
|
* Core CPU switches
|
2007-07-19 02:49:36 -06:00
|
|
|
* Fabric switch units
|
|
|
|
* PCIe interface controllers
|
|
|
|
* other EDAC/ECC type devices that can be monitored for
|
|
|
|
* errors, etc.
|
|
|
|
*
|
2012-04-17 12:30:52 -06:00
|
|
|
* It allows for a 2 level set of hierarchy. For example:
|
2007-07-19 02:49:36 -06:00
|
|
|
*
|
|
|
|
* cache could be composed of L1, L2 and L3 levels of cache.
|
|
|
|
* Each CPU core would have its own L1 cache, while sharing
|
|
|
|
* L2 and maybe L3 caches.
|
|
|
|
*
|
|
|
|
* View them arranged, via the sysfs presentation:
|
|
|
|
* /sys/devices/system/edac/..
|
|
|
|
*
|
|
|
|
* mc/ <existing memory device directory>
|
|
|
|
* cpu/cpu0/.. <L1 and L2 block directory>
|
|
|
|
* /L1-cache/ce_count
|
|
|
|
* /ue_count
|
|
|
|
* /L2-cache/ce_count
|
|
|
|
* /ue_count
|
|
|
|
* cpu/cpu1/.. <L1 and L2 block directory>
|
|
|
|
* /L1-cache/ce_count
|
|
|
|
* /ue_count
|
|
|
|
* /L2-cache/ce_count
|
|
|
|
* /ue_count
|
|
|
|
* ...
|
|
|
|
*
|
|
|
|
* the L1 and L2 directories would be "edac_device_block's"
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct edac_device_counter {
|
2007-07-19 02:49:58 -06:00
|
|
|
u32 ue_count;
|
|
|
|
u32 ce_count;
|
2007-07-19 02:49:36 -06:00
|
|
|
};
|
|
|
|
|
2007-07-19 02:50:25 -06:00
|
|
|
/* forward reference */
|
|
|
|
struct edac_device_ctl_info;
|
|
|
|
struct edac_device_block;
|
2007-07-19 02:49:36 -06:00
|
|
|
|
2007-07-19 02:50:25 -06:00
|
|
|
/* edac_dev_sysfs_attribute structure
|
|
|
|
* used for driver sysfs attributes in mem_ctl_info
|
|
|
|
* for extra controls and attributes:
|
|
|
|
* like high level error Injection controls
|
|
|
|
*/
|
|
|
|
struct edac_dev_sysfs_attribute {
|
|
|
|
struct attribute attr;
|
|
|
|
ssize_t (*show)(struct edac_device_ctl_info *, char *);
|
|
|
|
ssize_t (*store)(struct edac_device_ctl_info *, const char *, size_t);
|
2007-07-19 02:49:36 -06:00
|
|
|
};
|
|
|
|
|
2007-07-19 02:50:25 -06:00
|
|
|
/* edac_dev_sysfs_block_attribute structure
|
2007-07-19 02:50:33 -06:00
|
|
|
*
|
2007-07-19 02:50:25 -06:00
|
|
|
* used in leaf 'block' nodes for adding controls/attributes
|
2007-07-19 02:50:33 -06:00
|
|
|
*
|
|
|
|
* each block in each instance of the containing control structure
|
|
|
|
* can have an array of the following. The show and store functions
|
|
|
|
* will be filled in with the show/store function in the
|
|
|
|
* low level driver.
|
|
|
|
*
|
|
|
|
* The 'value' field will be the actual value field used for
|
|
|
|
* counting
|
2007-07-19 02:49:36 -06:00
|
|
|
*/
|
2007-07-19 02:50:25 -06:00
|
|
|
struct edac_dev_sysfs_block_attribute {
|
|
|
|
struct attribute attr;
|
|
|
|
ssize_t (*show)(struct kobject *, struct attribute *, char *);
|
|
|
|
ssize_t (*store)(struct kobject *, struct attribute *,
|
|
|
|
const char *, size_t);
|
|
|
|
struct edac_device_block *block;
|
|
|
|
|
|
|
|
unsigned int value;
|
2007-07-19 02:49:36 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
/* device block control structure */
|
|
|
|
struct edac_device_block {
|
|
|
|
struct edac_device_instance *instance; /* Up Pointer */
|
2007-07-19 02:49:58 -06:00
|
|
|
char name[EDAC_DEVICE_NAME_LEN + 1];
|
2007-07-19 02:49:36 -06:00
|
|
|
|
|
|
|
struct edac_device_counter counters; /* basic UE and CE counters */
|
|
|
|
|
2007-07-19 02:49:58 -06:00
|
|
|
int nr_attribs; /* how many attributes */
|
2007-07-19 02:50:25 -06:00
|
|
|
|
|
|
|
/* this block's attributes, could be NULL */
|
|
|
|
struct edac_dev_sysfs_block_attribute *block_attributes;
|
2007-07-19 02:49:36 -06:00
|
|
|
|
|
|
|
/* edac sysfs device control */
|
|
|
|
struct kobject kobj;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* device instance control structure */
|
|
|
|
struct edac_device_instance {
|
|
|
|
struct edac_device_ctl_info *ctl; /* Up pointer */
|
|
|
|
char name[EDAC_DEVICE_NAME_LEN + 4];
|
|
|
|
|
|
|
|
struct edac_device_counter counters; /* instance counters */
|
|
|
|
|
2007-07-19 02:49:58 -06:00
|
|
|
u32 nr_blocks; /* how many blocks */
|
2007-07-19 02:49:36 -06:00
|
|
|
struct edac_device_block *blocks; /* block array */
|
|
|
|
|
|
|
|
/* edac sysfs device control */
|
|
|
|
struct kobject kobj;
|
|
|
|
};
|
|
|
|
|
2007-07-19 02:50:10 -06:00
|
|
|
|
2007-07-19 02:49:36 -06:00
|
|
|
/*
|
|
|
|
* Abstract edac_device control info structure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
struct edac_device_ctl_info {
|
|
|
|
/* for global list of edac_device_ctl_info structs */
|
|
|
|
struct list_head link;
|
|
|
|
|
2007-07-19 02:50:29 -06:00
|
|
|
struct module *owner; /* Module owner of this control struct */
|
|
|
|
|
2007-07-19 02:49:36 -06:00
|
|
|
int dev_idx;
|
|
|
|
|
|
|
|
/* Per instance controls for this edac_device */
|
|
|
|
int log_ue; /* boolean for logging UEs */
|
|
|
|
int log_ce; /* boolean for logging CEs */
|
|
|
|
int panic_on_ue; /* boolean for panic'ing on an UE */
|
|
|
|
unsigned poll_msec; /* number of milliseconds to poll interval */
|
|
|
|
unsigned long delay; /* number of jiffies for poll_msec */
|
|
|
|
|
2007-07-19 02:50:10 -06:00
|
|
|
/* Additional top controller level attributes, but specified
|
|
|
|
* by the low level driver.
|
|
|
|
*
|
|
|
|
* Set by the low level driver to provide attributes at the
|
|
|
|
* controller level, same level as 'ue_count' and 'ce_count' above.
|
|
|
|
* An array of structures, NULL terminated
|
|
|
|
*
|
|
|
|
* If attributes are desired, then set to array of attributes
|
|
|
|
* If no attributes are desired, leave NULL
|
|
|
|
*/
|
|
|
|
struct edac_dev_sysfs_attribute *sysfs_attributes;
|
|
|
|
|
2011-12-14 16:21:07 -07:00
|
|
|
/* pointer to main 'edac' subsys in sysfs */
|
|
|
|
struct bus_type *edac_subsys;
|
2007-07-19 02:49:36 -06:00
|
|
|
|
|
|
|
/* the internal state of this controller instance */
|
|
|
|
int op_state;
|
|
|
|
/* work struct for this instance */
|
|
|
|
struct delayed_work work;
|
|
|
|
|
|
|
|
/* pointer to edac polling checking routine:
|
2007-07-19 02:49:58 -06:00
|
|
|
* If NOT NULL: points to polling check routine
|
|
|
|
* If NULL: Then assumes INTERRUPT operation, where
|
|
|
|
* MC driver will receive events
|
2007-07-19 02:49:36 -06:00
|
|
|
*/
|
|
|
|
void (*edac_check) (struct edac_device_ctl_info * edac_dev);
|
|
|
|
|
|
|
|
struct device *dev; /* pointer to device structure */
|
|
|
|
|
|
|
|
const char *mod_name; /* module name */
|
|
|
|
const char *ctl_name; /* edac controller name */
|
2007-07-19 02:49:47 -06:00
|
|
|
const char *dev_name; /* pci/platform/etc... name */
|
2007-07-19 02:49:36 -06:00
|
|
|
|
|
|
|
void *pvt_info; /* pointer to 'private driver' info */
|
|
|
|
|
2007-07-19 02:49:58 -06:00
|
|
|
unsigned long start_time; /* edac_device load start time (jiffies) */
|
2007-07-19 02:49:36 -06:00
|
|
|
|
2007-07-19 02:50:29 -06:00
|
|
|
struct completion removal_complete;
|
2007-07-19 02:49:36 -06:00
|
|
|
|
|
|
|
/* sysfs top name under 'edac' directory
|
|
|
|
* and instance name:
|
2007-07-19 02:49:58 -06:00
|
|
|
* cpu/cpu0/...
|
|
|
|
* cpu/cpu1/...
|
|
|
|
* cpu/cpu2/...
|
|
|
|
* ...
|
2007-07-19 02:49:36 -06:00
|
|
|
*/
|
|
|
|
char name[EDAC_DEVICE_NAME_LEN + 1];
|
|
|
|
|
|
|
|
/* Number of instances supported on this control structure
|
|
|
|
* and the array of those instances
|
|
|
|
*/
|
|
|
|
u32 nr_instances;
|
|
|
|
struct edac_device_instance *instances;
|
|
|
|
|
|
|
|
/* Event counters for the this whole EDAC Device */
|
|
|
|
struct edac_device_counter counters;
|
|
|
|
|
|
|
|
/* edac sysfs device control for the 'name'
|
|
|
|
* device this structure controls
|
|
|
|
*/
|
|
|
|
struct kobject kobj;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* To get from the instance's wq to the beginning of the ctl structure */
|
2007-07-19 02:49:52 -06:00
|
|
|
#define to_edac_mem_ctl_work(w) \
|
|
|
|
container_of(w, struct mem_ctl_info, work)
|
|
|
|
|
2007-07-19 02:49:36 -06:00
|
|
|
#define to_edac_device_ctl_work(w) \
|
|
|
|
container_of(w,struct edac_device_ctl_info,work)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The alloc() and free() functions for the 'edac_device' control info
|
|
|
|
* structure. A MC driver will allocate one of these for each edac_device
|
|
|
|
* it is going to control/register with the EDAC CORE.
|
|
|
|
*/
|
|
|
|
extern struct edac_device_ctl_info *edac_device_alloc_ctl_info(
|
2007-07-19 02:49:58 -06:00
|
|
|
unsigned sizeof_private,
|
2007-07-19 02:50:25 -06:00
|
|
|
char *edac_device_name, unsigned nr_instances,
|
|
|
|
char *edac_block_name, unsigned nr_blocks,
|
2007-07-19 02:49:58 -06:00
|
|
|
unsigned offset_value,
|
2007-07-19 02:50:25 -06:00
|
|
|
struct edac_dev_sysfs_block_attribute *block_attributes,
|
2007-07-19 02:50:27 -06:00
|
|
|
unsigned nr_attribs,
|
|
|
|
int device_index);
|
2007-07-19 02:49:36 -06:00
|
|
|
|
|
|
|
/* The offset value can be:
|
|
|
|
* -1 indicating no offset value
|
|
|
|
* 0 for zero-based block numbers
|
|
|
|
* 1 for 1-based block number
|
|
|
|
* other for other-based block number
|
|
|
|
*/
|
|
|
|
#define BLOCK_OFFSET_VALUE_OFF ((unsigned) -1)
|
|
|
|
|
2007-07-19 02:49:58 -06:00
|
|
|
extern void edac_device_free_ctl_info(struct edac_device_ctl_info *ctl_info);
|
2007-07-19 02:49:36 -06:00
|
|
|
|
2007-07-19 02:49:33 -06:00
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
|
2007-07-19 02:49:52 -06:00
|
|
|
struct edac_pci_counter {
|
2007-07-19 02:49:58 -06:00
|
|
|
atomic_t pe_count;
|
|
|
|
atomic_t npe_count;
|
2007-07-19 02:49:52 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Abstract edac_pci control info structure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
struct edac_pci_ctl_info {
|
|
|
|
/* for global list of edac_pci_ctl_info structs */
|
|
|
|
struct list_head link;
|
|
|
|
|
|
|
|
int pci_idx;
|
|
|
|
|
2011-12-14 16:21:07 -07:00
|
|
|
struct bus_type *edac_subsys; /* pointer to subsystem */
|
2007-07-19 02:49:52 -06:00
|
|
|
|
|
|
|
/* the internal state of this controller instance */
|
|
|
|
int op_state;
|
|
|
|
/* work struct for this instance */
|
|
|
|
struct delayed_work work;
|
|
|
|
|
|
|
|
/* pointer to edac polling checking routine:
|
2007-07-19 02:49:58 -06:00
|
|
|
* If NOT NULL: points to polling check routine
|
|
|
|
* If NULL: Then assumes INTERRUPT operation, where
|
|
|
|
* MC driver will receive events
|
2007-07-19 02:49:52 -06:00
|
|
|
*/
|
|
|
|
void (*edac_check) (struct edac_pci_ctl_info * edac_dev);
|
|
|
|
|
|
|
|
struct device *dev; /* pointer to device structure */
|
|
|
|
|
|
|
|
const char *mod_name; /* module name */
|
|
|
|
const char *ctl_name; /* edac controller name */
|
|
|
|
const char *dev_name; /* pci/platform/etc... name */
|
|
|
|
|
|
|
|
void *pvt_info; /* pointer to 'private driver' info */
|
|
|
|
|
2007-07-19 02:49:58 -06:00
|
|
|
unsigned long start_time; /* edac_pci load start time (jiffies) */
|
2007-07-19 02:49:52 -06:00
|
|
|
|
|
|
|
struct completion complete;
|
|
|
|
|
|
|
|
/* sysfs top name under 'edac' directory
|
|
|
|
* and instance name:
|
2007-07-19 02:49:58 -06:00
|
|
|
* cpu/cpu0/...
|
|
|
|
* cpu/cpu1/...
|
|
|
|
* cpu/cpu2/...
|
|
|
|
* ...
|
2007-07-19 02:49:52 -06:00
|
|
|
*/
|
|
|
|
char name[EDAC_DEVICE_NAME_LEN + 1];
|
|
|
|
|
|
|
|
/* Event counters for the this whole EDAC Device */
|
|
|
|
struct edac_pci_counter counters;
|
|
|
|
|
|
|
|
/* edac sysfs device control for the 'name'
|
|
|
|
* device this structure controls
|
|
|
|
*/
|
|
|
|
struct kobject kobj;
|
|
|
|
struct completion kobj_complete;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define to_edac_pci_ctl_work(w) \
|
|
|
|
container_of(w, struct edac_pci_ctl_info,work)
|
|
|
|
|
2007-07-19 02:49:33 -06:00
|
|
|
/* write all or some bits in a byte-register*/
|
|
|
|
static inline void pci_write_bits8(struct pci_dev *pdev, int offset, u8 value,
|
2007-07-19 02:49:58 -06:00
|
|
|
u8 mask)
|
2007-07-19 02:49:33 -06:00
|
|
|
{
|
|
|
|
if (mask != 0xff) {
|
|
|
|
u8 buf;
|
|
|
|
|
|
|
|
pci_read_config_byte(pdev, offset, &buf);
|
|
|
|
value &= mask;
|
|
|
|
buf &= ~mask;
|
|
|
|
value |= buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
pci_write_config_byte(pdev, offset, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write all or some bits in a word-register*/
|
|
|
|
static inline void pci_write_bits16(struct pci_dev *pdev, int offset,
|
2007-07-19 02:49:58 -06:00
|
|
|
u16 value, u16 mask)
|
2007-07-19 02:49:33 -06:00
|
|
|
{
|
|
|
|
if (mask != 0xffff) {
|
|
|
|
u16 buf;
|
|
|
|
|
|
|
|
pci_read_config_word(pdev, offset, &buf);
|
|
|
|
value &= mask;
|
|
|
|
buf &= ~mask;
|
|
|
|
value |= buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
pci_write_config_word(pdev, offset, value);
|
|
|
|
}
|
|
|
|
|
2009-04-13 15:40:20 -06:00
|
|
|
/*
|
|
|
|
* pci_write_bits32
|
|
|
|
*
|
|
|
|
* edac local routine to do pci_write_config_dword, but adds
|
|
|
|
* a mask parameter. If mask is all ones, ignore the mask.
|
|
|
|
* Otherwise utilize the mask to isolate specified bits
|
|
|
|
*
|
|
|
|
* write all or some bits in a dword-register
|
|
|
|
*/
|
2007-07-19 02:49:33 -06:00
|
|
|
static inline void pci_write_bits32(struct pci_dev *pdev, int offset,
|
2007-07-19 02:49:58 -06:00
|
|
|
u32 value, u32 mask)
|
2007-07-19 02:49:33 -06:00
|
|
|
{
|
2009-04-13 15:40:20 -06:00
|
|
|
if (mask != 0xffffffff) {
|
2007-07-19 02:49:33 -06:00
|
|
|
u32 buf;
|
|
|
|
|
|
|
|
pci_read_config_dword(pdev, offset, &buf);
|
|
|
|
value &= mask;
|
|
|
|
buf &= ~mask;
|
|
|
|
value |= buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
pci_write_config_dword(pdev, offset, value);
|
|
|
|
}
|
|
|
|
|
2007-07-19 02:49:58 -06:00
|
|
|
#endif /* CONFIG_PCI */
|
2007-07-19 02:49:33 -06:00
|
|
|
|
2012-05-02 11:37:00 -06:00
|
|
|
struct mem_ctl_info *edac_mc_alloc(unsigned mc_num,
|
edac: Change internal representation to work with layers
Change the EDAC internal representation to work with non-csrow
based memory controllers.
There are lots of those memory controllers nowadays, and more
are coming. So, the EDAC internal representation needs to be
changed, in order to work with those memory controllers, while
preserving backward compatibility with the old ones.
The edac core was written with the idea that memory controllers
are able to directly access csrows.
This is not true for FB-DIMM and RAMBUS memory controllers.
Also, some recent advanced memory controllers don't present a per-csrows
view. Instead, they view memories as DIMMs, instead of ranks.
So, change the allocation and error report routines to allow
them to work with all types of architectures.
This will allow the removal of several hacks with FB-DIMM and RAMBUS
memory controllers.
Also, several tests were done on different platforms using different
x86 drivers.
TODO: a multi-rank DIMMs are currently represented by multiple DIMM
entries in struct dimm_info. That means that changing a label for one
rank won't change the same label for the other ranks at the same DIMM.
This bug is present since the beginning of the EDAC, so it is not a big
deal. However, on several drivers, it is possible to fix this issue, but
it should be a per-driver fix, as the csrow => DIMM arrangement may not
be equal for all. So, don't try to fix it here yet.
I tried to make this patch as short as possible, preceding it with
several other patches that simplified the logic here. Yet, as the
internal API changes, all drivers need changes. The changes are
generally bigger in the drivers for FB-DIMMs.
Cc: Aristeu Rozanski <arozansk@redhat.com>
Cc: Doug Thompson <norsk5@yahoo.com>
Cc: Borislav Petkov <borislav.petkov@amd.com>
Cc: Mark Gross <mark.gross@intel.com>
Cc: Jason Uhlenkott <juhlenko@akamai.com>
Cc: Tim Small <tim@buttersideup.com>
Cc: Ranganathan Desikan <ravi@jetztechnologies.com>
Cc: "Arvind R." <arvino55@gmail.com>
Cc: Olof Johansson <olof@lixom.net>
Cc: Egor Martovetsky <egor@pasemi.com>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Joe Perches <joe@perches.com>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Hitoshi Mitake <h.mitake@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: "Niklas Söderlund" <niklas.soderlund@ericsson.com>
Cc: Shaohui Xie <Shaohui.Xie@freescale.com>
Cc: Josh Boyer <jwboyer@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-04-18 12:20:50 -06:00
|
|
|
unsigned n_layers,
|
|
|
|
struct edac_mc_layer *layers,
|
|
|
|
unsigned sz_pvt);
|
2007-07-19 02:50:26 -06:00
|
|
|
extern int edac_mc_add_mc(struct mem_ctl_info *mci);
|
|
|
|
extern void edac_mc_free(struct mem_ctl_info *mci);
|
2007-07-19 02:49:58 -06:00
|
|
|
extern struct mem_ctl_info *edac_mc_find(int idx);
|
2010-08-10 08:22:01 -06:00
|
|
|
extern struct mem_ctl_info *find_mci_by_dev(struct device *dev);
|
2007-07-19 02:49:58 -06:00
|
|
|
extern struct mem_ctl_info *edac_mc_del_mc(struct device *dev);
|
2007-07-19 02:49:33 -06:00
|
|
|
extern int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci,
|
2007-07-19 02:49:58 -06:00
|
|
|
unsigned long page);
|
2012-10-31 10:46:11 -06:00
|
|
|
|
|
|
|
void edac_raw_mc_handle_error(const enum hw_event_mc_err_type type,
|
|
|
|
struct mem_ctl_info *mci,
|
|
|
|
struct edac_raw_error_desc *e);
|
|
|
|
|
edac: Change internal representation to work with layers
Change the EDAC internal representation to work with non-csrow
based memory controllers.
There are lots of those memory controllers nowadays, and more
are coming. So, the EDAC internal representation needs to be
changed, in order to work with those memory controllers, while
preserving backward compatibility with the old ones.
The edac core was written with the idea that memory controllers
are able to directly access csrows.
This is not true for FB-DIMM and RAMBUS memory controllers.
Also, some recent advanced memory controllers don't present a per-csrows
view. Instead, they view memories as DIMMs, instead of ranks.
So, change the allocation and error report routines to allow
them to work with all types of architectures.
This will allow the removal of several hacks with FB-DIMM and RAMBUS
memory controllers.
Also, several tests were done on different platforms using different
x86 drivers.
TODO: a multi-rank DIMMs are currently represented by multiple DIMM
entries in struct dimm_info. That means that changing a label for one
rank won't change the same label for the other ranks at the same DIMM.
This bug is present since the beginning of the EDAC, so it is not a big
deal. However, on several drivers, it is possible to fix this issue, but
it should be a per-driver fix, as the csrow => DIMM arrangement may not
be equal for all. So, don't try to fix it here yet.
I tried to make this patch as short as possible, preceding it with
several other patches that simplified the logic here. Yet, as the
internal API changes, all drivers need changes. The changes are
generally bigger in the drivers for FB-DIMMs.
Cc: Aristeu Rozanski <arozansk@redhat.com>
Cc: Doug Thompson <norsk5@yahoo.com>
Cc: Borislav Petkov <borislav.petkov@amd.com>
Cc: Mark Gross <mark.gross@intel.com>
Cc: Jason Uhlenkott <juhlenko@akamai.com>
Cc: Tim Small <tim@buttersideup.com>
Cc: Ranganathan Desikan <ravi@jetztechnologies.com>
Cc: "Arvind R." <arvino55@gmail.com>
Cc: Olof Johansson <olof@lixom.net>
Cc: Egor Martovetsky <egor@pasemi.com>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Joe Perches <joe@perches.com>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Hitoshi Mitake <h.mitake@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: "Niklas Söderlund" <niklas.soderlund@ericsson.com>
Cc: Shaohui Xie <Shaohui.Xie@freescale.com>
Cc: Josh Boyer <jwboyer@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-04-18 12:20:50 -06:00
|
|
|
void edac_mc_handle_error(const enum hw_event_mc_err_type type,
|
|
|
|
struct mem_ctl_info *mci,
|
2012-06-04 10:27:43 -06:00
|
|
|
const u16 error_count,
|
edac: Change internal representation to work with layers
Change the EDAC internal representation to work with non-csrow
based memory controllers.
There are lots of those memory controllers nowadays, and more
are coming. So, the EDAC internal representation needs to be
changed, in order to work with those memory controllers, while
preserving backward compatibility with the old ones.
The edac core was written with the idea that memory controllers
are able to directly access csrows.
This is not true for FB-DIMM and RAMBUS memory controllers.
Also, some recent advanced memory controllers don't present a per-csrows
view. Instead, they view memories as DIMMs, instead of ranks.
So, change the allocation and error report routines to allow
them to work with all types of architectures.
This will allow the removal of several hacks with FB-DIMM and RAMBUS
memory controllers.
Also, several tests were done on different platforms using different
x86 drivers.
TODO: a multi-rank DIMMs are currently represented by multiple DIMM
entries in struct dimm_info. That means that changing a label for one
rank won't change the same label for the other ranks at the same DIMM.
This bug is present since the beginning of the EDAC, so it is not a big
deal. However, on several drivers, it is possible to fix this issue, but
it should be a per-driver fix, as the csrow => DIMM arrangement may not
be equal for all. So, don't try to fix it here yet.
I tried to make this patch as short as possible, preceding it with
several other patches that simplified the logic here. Yet, as the
internal API changes, all drivers need changes. The changes are
generally bigger in the drivers for FB-DIMMs.
Cc: Aristeu Rozanski <arozansk@redhat.com>
Cc: Doug Thompson <norsk5@yahoo.com>
Cc: Borislav Petkov <borislav.petkov@amd.com>
Cc: Mark Gross <mark.gross@intel.com>
Cc: Jason Uhlenkott <juhlenko@akamai.com>
Cc: Tim Small <tim@buttersideup.com>
Cc: Ranganathan Desikan <ravi@jetztechnologies.com>
Cc: "Arvind R." <arvino55@gmail.com>
Cc: Olof Johansson <olof@lixom.net>
Cc: Egor Martovetsky <egor@pasemi.com>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Joe Perches <joe@perches.com>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Hitoshi Mitake <h.mitake@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: "Niklas Söderlund" <niklas.soderlund@ericsson.com>
Cc: Shaohui Xie <Shaohui.Xie@freescale.com>
Cc: Josh Boyer <jwboyer@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-04-18 12:20:50 -06:00
|
|
|
const unsigned long page_frame_number,
|
|
|
|
const unsigned long offset_in_page,
|
|
|
|
const unsigned long syndrome,
|
RAS: Add a tracepoint for reporting memory controller events
Add a new tracepoint-based hardware events report method for
reporting Memory Controller events.
Part of the description bellow is shamelessly copied from Tony
Luck's notes about the Hardware Error BoF during LPC 2010 [1].
Tony, thanks for your notes and discussions to generate the
h/w error reporting requirements.
[1] http://lwn.net/Articles/416669/
We have several subsystems & methods for reporting hardware errors:
1) EDAC ("Error Detection and Correction"). In its original form
this consisted of a platform specific driver that read topology
information and error counts from chipset registers and reported
the results via a sysfs interface.
2) mcelog - x86 specific decoding of machine check bank registers
reporting in binary form via /dev/mcelog. Recent additions make use
of the APEI extensions that were documented in version 4.0a of the
ACPI specification to acquire more information about errors without
having to rely reading chipset registers directly. A user level
programs decodes into somewhat human readable format.
3) drivers/edac/mce_amd.c - this driver hooks into the mcelog path and
decodes errors reported via machine check bank registers in AMD
processors to the console log using printk();
Each of these mechanisms has a band of followers ... and none
of them appear to meet all the needs of all users.
As part of a RAS subsystem, let's encapsulate the memory error hardware
events into a trace facility.
The tracepoint printk will be displayed like:
mc_event: [quant] (Corrected|Uncorrected|Fatal) error:[error msg] on [label] ([location] [edac_mc detail] [driver_detail]
Where:
[quant] is the quantity of errors
[error msg] is the driver-specific error message
(e. g. "memory read", "bus error", ...);
[location] is the location in terms of memory controller and
branch/channel/slot, channel/slot or csrow/channel;
[label] is the memory stick label;
[edac_mc detail] describes the address location of the error
and the syndrome;
[driver detail] is driver-specifig error message details,
when needed/provided (e. g. "area:DMA", ...)
For example:
mc_event: 1 Corrected error:memory read on memory stick DIMM_1A (mc:0 location:0:0:0 page:0x586b6e offset:0xa66 grain:32 syndrome:0x0 area:DMA)
Of course, any userspace tools meant to handle errors should not parse
the above data. They should, instead, use the binary fields provided by
the tracepoint, mapping them directly into their Management Information
Base.
NOTE: The original patch was providing an additional mechanism for
MCA-based trace events that also contained MCA error register data.
However, as no agreement was reached so far for the MCA-based trace
events, for now, let's add events only for memory errors.
A latter patch is planned to change the tracepoint, for those types
of event.
Cc: Aristeu Rozanski <arozansk@redhat.com>
Cc: Doug Thompson <norsk5@yahoo.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-02-23 04:10:34 -07:00
|
|
|
const int top_layer,
|
|
|
|
const int mid_layer,
|
|
|
|
const int low_layer,
|
edac: Change internal representation to work with layers
Change the EDAC internal representation to work with non-csrow
based memory controllers.
There are lots of those memory controllers nowadays, and more
are coming. So, the EDAC internal representation needs to be
changed, in order to work with those memory controllers, while
preserving backward compatibility with the old ones.
The edac core was written with the idea that memory controllers
are able to directly access csrows.
This is not true for FB-DIMM and RAMBUS memory controllers.
Also, some recent advanced memory controllers don't present a per-csrows
view. Instead, they view memories as DIMMs, instead of ranks.
So, change the allocation and error report routines to allow
them to work with all types of architectures.
This will allow the removal of several hacks with FB-DIMM and RAMBUS
memory controllers.
Also, several tests were done on different platforms using different
x86 drivers.
TODO: a multi-rank DIMMs are currently represented by multiple DIMM
entries in struct dimm_info. That means that changing a label for one
rank won't change the same label for the other ranks at the same DIMM.
This bug is present since the beginning of the EDAC, so it is not a big
deal. However, on several drivers, it is possible to fix this issue, but
it should be a per-driver fix, as the csrow => DIMM arrangement may not
be equal for all. So, don't try to fix it here yet.
I tried to make this patch as short as possible, preceding it with
several other patches that simplified the logic here. Yet, as the
internal API changes, all drivers need changes. The changes are
generally bigger in the drivers for FB-DIMMs.
Cc: Aristeu Rozanski <arozansk@redhat.com>
Cc: Doug Thompson <norsk5@yahoo.com>
Cc: Borislav Petkov <borislav.petkov@amd.com>
Cc: Mark Gross <mark.gross@intel.com>
Cc: Jason Uhlenkott <juhlenko@akamai.com>
Cc: Tim Small <tim@buttersideup.com>
Cc: Ranganathan Desikan <ravi@jetztechnologies.com>
Cc: "Arvind R." <arvino55@gmail.com>
Cc: Olof Johansson <olof@lixom.net>
Cc: Egor Martovetsky <egor@pasemi.com>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Joe Perches <joe@perches.com>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Hitoshi Mitake <h.mitake@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: "Niklas Söderlund" <niklas.soderlund@ericsson.com>
Cc: Shaohui Xie <Shaohui.Xie@freescale.com>
Cc: Josh Boyer <jwboyer@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-04-18 12:20:50 -06:00
|
|
|
const char *msg,
|
2012-06-04 08:29:25 -06:00
|
|
|
const char *other_detail);
|
2007-07-19 02:49:33 -06:00
|
|
|
|
|
|
|
/*
|
2007-07-19 02:49:36 -06:00
|
|
|
* edac_device APIs
|
2007-07-19 02:49:33 -06:00
|
|
|
*/
|
2007-07-19 02:50:27 -06:00
|
|
|
extern int edac_device_add_device(struct edac_device_ctl_info *edac_dev);
|
2007-07-19 02:49:58 -06:00
|
|
|
extern struct edac_device_ctl_info *edac_device_del_device(struct device *dev);
|
2007-07-19 02:49:36 -06:00
|
|
|
extern void edac_device_handle_ue(struct edac_device_ctl_info *edac_dev,
|
2007-07-19 02:50:26 -06:00
|
|
|
int inst_nr, int block_nr, const char *msg);
|
2007-07-19 02:49:36 -06:00
|
|
|
extern void edac_device_handle_ce(struct edac_device_ctl_info *edac_dev,
|
2007-07-19 02:50:26 -06:00
|
|
|
int inst_nr, int block_nr, const char *msg);
|
2009-06-17 17:27:59 -06:00
|
|
|
extern int edac_device_alloc_index(void);
|
edac: Change internal representation to work with layers
Change the EDAC internal representation to work with non-csrow
based memory controllers.
There are lots of those memory controllers nowadays, and more
are coming. So, the EDAC internal representation needs to be
changed, in order to work with those memory controllers, while
preserving backward compatibility with the old ones.
The edac core was written with the idea that memory controllers
are able to directly access csrows.
This is not true for FB-DIMM and RAMBUS memory controllers.
Also, some recent advanced memory controllers don't present a per-csrows
view. Instead, they view memories as DIMMs, instead of ranks.
So, change the allocation and error report routines to allow
them to work with all types of architectures.
This will allow the removal of several hacks with FB-DIMM and RAMBUS
memory controllers.
Also, several tests were done on different platforms using different
x86 drivers.
TODO: a multi-rank DIMMs are currently represented by multiple DIMM
entries in struct dimm_info. That means that changing a label for one
rank won't change the same label for the other ranks at the same DIMM.
This bug is present since the beginning of the EDAC, so it is not a big
deal. However, on several drivers, it is possible to fix this issue, but
it should be a per-driver fix, as the csrow => DIMM arrangement may not
be equal for all. So, don't try to fix it here yet.
I tried to make this patch as short as possible, preceding it with
several other patches that simplified the logic here. Yet, as the
internal API changes, all drivers need changes. The changes are
generally bigger in the drivers for FB-DIMMs.
Cc: Aristeu Rozanski <arozansk@redhat.com>
Cc: Doug Thompson <norsk5@yahoo.com>
Cc: Borislav Petkov <borislav.petkov@amd.com>
Cc: Mark Gross <mark.gross@intel.com>
Cc: Jason Uhlenkott <juhlenko@akamai.com>
Cc: Tim Small <tim@buttersideup.com>
Cc: Ranganathan Desikan <ravi@jetztechnologies.com>
Cc: "Arvind R." <arvino55@gmail.com>
Cc: Olof Johansson <olof@lixom.net>
Cc: Egor Martovetsky <egor@pasemi.com>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Joe Perches <joe@perches.com>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Hitoshi Mitake <h.mitake@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: "Niklas Söderlund" <niklas.soderlund@ericsson.com>
Cc: Shaohui Xie <Shaohui.Xie@freescale.com>
Cc: Josh Boyer <jwboyer@gmail.com>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-04-18 12:20:50 -06:00
|
|
|
extern const char *edac_layer_name[];
|
2007-07-19 02:49:36 -06:00
|
|
|
|
2007-07-19 02:49:52 -06:00
|
|
|
/*
|
|
|
|
* edac_pci APIs
|
|
|
|
*/
|
2007-07-19 02:50:26 -06:00
|
|
|
extern struct edac_pci_ctl_info *edac_pci_alloc_ctl_info(unsigned int sz_pvt,
|
|
|
|
const char *edac_pci_name);
|
2007-07-19 02:49:52 -06:00
|
|
|
|
|
|
|
extern void edac_pci_free_ctl_info(struct edac_pci_ctl_info *pci);
|
|
|
|
|
2007-07-19 02:50:26 -06:00
|
|
|
extern void edac_pci_reset_delay_period(struct edac_pci_ctl_info *pci,
|
|
|
|
unsigned long value);
|
2007-07-19 02:49:52 -06:00
|
|
|
|
2009-04-02 17:58:47 -06:00
|
|
|
extern int edac_pci_alloc_index(void);
|
2007-07-19 02:49:52 -06:00
|
|
|
extern int edac_pci_add_device(struct edac_pci_ctl_info *pci, int edac_idx);
|
2007-07-19 02:49:58 -06:00
|
|
|
extern struct edac_pci_ctl_info *edac_pci_del_device(struct device *dev);
|
2007-07-19 02:49:52 -06:00
|
|
|
|
2007-07-19 02:50:26 -06:00
|
|
|
extern struct edac_pci_ctl_info *edac_pci_create_generic_ctl(
|
|
|
|
struct device *dev,
|
|
|
|
const char *mod_name);
|
2007-07-19 02:49:52 -06:00
|
|
|
|
|
|
|
extern void edac_pci_release_generic_ctl(struct edac_pci_ctl_info *pci);
|
|
|
|
extern int edac_pci_create_sysfs(struct edac_pci_ctl_info *pci);
|
|
|
|
extern void edac_pci_remove_sysfs(struct edac_pci_ctl_info *pci);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* edac misc APIs
|
|
|
|
*/
|
2007-07-19 02:50:21 -06:00
|
|
|
extern char *edac_op_state_to_string(int op_state);
|
2007-07-19 02:49:33 -06:00
|
|
|
|
|
|
|
#endif /* _EDAC_CORE_H_ */
|