Commit c029e405 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp: (21 commits)
  EDAC, MCE: Fix shift warning on 32-bit
  EDAC, MCE: Add a BIT_64() macro
  EDAC, MCE: Enable MCE decoding on F12h
  EDAC, MCE: Add F12h NB MCE decoder
  EDAC, MCE: Add F12h IC MCE decoder
  EDAC, MCE: Add F12h DC MCE decoder
  EDAC, MCE: Add support for F11h MCEs
  EDAC, MCE: Enable MCE decoding on F14h
  EDAC, MCE: Fix FR MCEs decoding
  EDAC, MCE: Complete NB MCE decoders
  EDAC, MCE: Warn about LS MCEs on F14h
  EDAC, MCE: Adjust IC decoders to F14h
  EDAC, MCE: Adjust DC decoders to F14h
  EDAC, MCE: Rename files
  EDAC, MCE: Rework MCE injection
  EDAC: Export edac sysfs class to users.
  EDAC, MCE: Pass complete MCE info to decoders
  EDAC, MCE: Sanitize error codes
  EDAC, MCE: Remove unused function parameter
  EDAC, MCE: Add HW_ERR prefix
  ...
parents a9ccd80a 525906bc
...@@ -39,7 +39,7 @@ config EDAC_DEBUG ...@@ -39,7 +39,7 @@ config EDAC_DEBUG
there're four debug levels (x=0,1,2,3 from low to high). there're four debug levels (x=0,1,2,3 from low to high).
Usually you should select 'N'. Usually you should select 'N'.
config EDAC_DECODE_MCE config EDAC_DECODE_MCE
tristate "Decode MCEs in human-readable form (only on AMD for now)" tristate "Decode MCEs in human-readable form (only on AMD for now)"
depends on CPU_SUP_AMD && X86_MCE depends on CPU_SUP_AMD && X86_MCE
default y default y
...@@ -51,6 +51,16 @@ config EDAC_DEBUG ...@@ -51,6 +51,16 @@ config EDAC_DEBUG
which occur really early upon boot, before the module infrastructure which occur really early upon boot, before the module infrastructure
has been initialized. has been initialized.
config EDAC_MCE_INJ
tristate "Simple MCE injection interface over /sysfs"
depends on EDAC_DECODE_MCE
default n
help
This is a simple interface to inject MCEs over /sysfs and test
the MCE decoding code in EDAC.
This is currently AMD-only.
config EDAC_MM_EDAC config EDAC_MM_EDAC
tristate "Main Memory EDAC (Error Detection And Correction) reporting" tristate "Main Memory EDAC (Error Detection And Correction) reporting"
help help
...@@ -72,7 +82,7 @@ config EDAC_AMD64 ...@@ -72,7 +82,7 @@ config EDAC_AMD64
Families of Memory Controllers (K8, F10h and F11h) Families of Memory Controllers (K8, F10h and F11h)
config EDAC_AMD64_ERROR_INJECTION config EDAC_AMD64_ERROR_INJECTION
bool "Sysfs Error Injection facilities" bool "Sysfs HW Error injection facilities"
depends on EDAC_AMD64 depends on EDAC_AMD64
help help
Recent Opterons (Family 10h and later) provide for Memory Error Recent Opterons (Family 10h and later) provide for Memory Error
......
...@@ -17,6 +17,9 @@ ifdef CONFIG_PCI ...@@ -17,6 +17,9 @@ ifdef CONFIG_PCI
edac_core-objs += edac_pci.o edac_pci_sysfs.o edac_core-objs += edac_pci.o edac_pci_sysfs.o
endif endif
obj-$(CONFIG_EDAC_MCE_INJ) += mce_amd_inj.o
edac_mce_amd-objs := mce_amd.o
obj-$(CONFIG_EDAC_DECODE_MCE) += edac_mce_amd.o obj-$(CONFIG_EDAC_DECODE_MCE) += edac_mce_amd.o
obj-$(CONFIG_EDAC_AMD76X) += amd76x_edac.o obj-$(CONFIG_EDAC_AMD76X) += amd76x_edac.o
......
...@@ -2073,11 +2073,18 @@ static inline void __amd64_decode_bus_error(struct mem_ctl_info *mci, ...@@ -2073,11 +2073,18 @@ static inline void __amd64_decode_bus_error(struct mem_ctl_info *mci,
amd64_handle_ue(mci, info); amd64_handle_ue(mci, info);
} }
void amd64_decode_bus_error(int node_id, struct err_regs *regs) void amd64_decode_bus_error(int node_id, struct mce *m, u32 nbcfg)
{ {
struct mem_ctl_info *mci = mci_lookup[node_id]; struct mem_ctl_info *mci = mci_lookup[node_id];
struct err_regs regs;
__amd64_decode_bus_error(mci, regs); regs.nbsl = (u32) m->status;
regs.nbsh = (u32)(m->status >> 32);
regs.nbeal = (u32) m->addr;
regs.nbeah = (u32)(m->addr >> 32);
regs.nbcfg = nbcfg;
__amd64_decode_bus_error(mci, &regs);
/* /*
* Check the UE bit of the NB status high register, if set generate some * Check the UE bit of the NB status high register, if set generate some
...@@ -2086,7 +2093,7 @@ void amd64_decode_bus_error(int node_id, struct err_regs *regs) ...@@ -2086,7 +2093,7 @@ void amd64_decode_bus_error(int node_id, struct err_regs *regs)
* *
* FIXME: this should go somewhere else, if at all. * FIXME: this should go somewhere else, if at all.
*/ */
if (regs->nbsh & K8_NBSH_UC_ERR && !report_gart_errors) if (regs.nbsh & K8_NBSH_UC_ERR && !report_gart_errors)
edac_mc_handle_ue_no_info(mci, "UE bit is set"); edac_mc_handle_ue_no_info(mci, "UE bit is set");
} }
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
#include <linux/edac.h> #include <linux/edac.h>
#include <asm/msr.h> #include <asm/msr.h>
#include "edac_core.h" #include "edac_core.h"
#include "edac_mce_amd.h" #include "mce_amd.h"
#define amd64_printk(level, fmt, arg...) \ #define amd64_printk(level, fmt, arg...) \
edac_printk(level, "amd64", fmt, ##arg) edac_printk(level, "amd64", fmt, ##arg)
...@@ -482,11 +482,10 @@ extern const char *rrrr_msgs[16]; ...@@ -482,11 +482,10 @@ extern const char *rrrr_msgs[16];
extern const char *to_msgs[2]; extern const char *to_msgs[2];
extern const char *pp_msgs[4]; extern const char *pp_msgs[4];
extern const char *ii_msgs[4]; extern const char *ii_msgs[4];
extern const char *ext_msgs[32];
extern const char *htlink_msgs[8]; extern const char *htlink_msgs[8];
#ifdef CONFIG_EDAC_DEBUG #ifdef CONFIG_EDAC_DEBUG
#define NUM_DBG_ATTRS 9 #define NUM_DBG_ATTRS 5
#else #else
#define NUM_DBG_ATTRS 0 #define NUM_DBG_ATTRS 0
#endif #endif
......
#include "amd64_edac.h" #include "amd64_edac.h"
/* #define EDAC_DCT_ATTR_SHOW(reg) \
* accept a hex value and store it into the virtual error register file, field: static ssize_t amd64_##reg##_show(struct mem_ctl_info *mci, char *data) \
* nbeal and nbeah. Assume virtual error values have already been set for: NBSL, { \
* NBSH and NBCFG. Then proceed to map the error values to a MC, CSROW and struct amd64_pvt *pvt = mci->pvt_info; \
* CHANNEL return sprintf(data, "0x%016llx\n", (u64)pvt->reg); \
*/
static ssize_t amd64_nbea_store(struct mem_ctl_info *mci, const char *data,
size_t count)
{
struct amd64_pvt *pvt = mci->pvt_info;
unsigned long long value;
int ret = 0;
ret = strict_strtoull(data, 16, &value);
if (ret != -EINVAL) {
debugf0("received NBEA= 0x%llx\n", value);
/* place the value into the virtual error packet */
pvt->ctl_error_info.nbeal = (u32) value;
value >>= 32;
pvt->ctl_error_info.nbeah = (u32) value;
/* Process the Mapping request */
/* TODO: Add race prevention */
amd_decode_nb_mce(pvt->mc_node_id, &pvt->ctl_error_info, 1);
return count;
}
return ret;
}
/* display back what the last NBEA (MCA NB Address (MC4_ADDR)) was written */
static ssize_t amd64_nbea_show(struct mem_ctl_info *mci, char *data)
{
struct amd64_pvt *pvt = mci->pvt_info;
u64 value;
value = pvt->ctl_error_info.nbeah;
value <<= 32;
value |= pvt->ctl_error_info.nbeal;
return sprintf(data, "%llx\n", value);
}
/* store the NBSL (MCA NB Status Low (MC4_STATUS)) value user desires */
static ssize_t amd64_nbsl_store(struct mem_ctl_info *mci, const char *data,
size_t count)
{
struct amd64_pvt *pvt = mci->pvt_info;
unsigned long value;
int ret = 0;
ret = strict_strtoul(data, 16, &value);
if (ret != -EINVAL) {
debugf0("received NBSL= 0x%lx\n", value);
pvt->ctl_error_info.nbsl = (u32) value;
return count;
}
return ret;
}
/* display back what the last NBSL value written */
static ssize_t amd64_nbsl_show(struct mem_ctl_info *mci, char *data)
{
struct amd64_pvt *pvt = mci->pvt_info;
u32 value;
value = pvt->ctl_error_info.nbsl;
return sprintf(data, "%x\n", value);
}
/* store the NBSH (MCA NB Status High) value user desires */
static ssize_t amd64_nbsh_store(struct mem_ctl_info *mci, const char *data,
size_t count)
{
struct amd64_pvt *pvt = mci->pvt_info;
unsigned long value;
int ret = 0;
ret = strict_strtoul(data, 16, &value);
if (ret != -EINVAL) {
debugf0("received NBSH= 0x%lx\n", value);
pvt->ctl_error_info.nbsh = (u32) value;
return count;
}
return ret;
}
/* display back what the last NBSH value written */
static ssize_t amd64_nbsh_show(struct mem_ctl_info *mci, char *data)
{
struct amd64_pvt *pvt = mci->pvt_info;
u32 value;
value = pvt->ctl_error_info.nbsh;
return sprintf(data, "%x\n", value);
} }
/* accept and store the NBCFG (MCA NB Configuration) value user desires */ EDAC_DCT_ATTR_SHOW(dhar);
static ssize_t amd64_nbcfg_store(struct mem_ctl_info *mci, EDAC_DCT_ATTR_SHOW(dbam0);
const char *data, size_t count) EDAC_DCT_ATTR_SHOW(top_mem);
{ EDAC_DCT_ATTR_SHOW(top_mem2);
struct amd64_pvt *pvt = mci->pvt_info;
unsigned long value;
int ret = 0;
ret = strict_strtoul(data, 16, &value);
if (ret != -EINVAL) {
debugf0("received NBCFG= 0x%lx\n", value);
pvt->ctl_error_info.nbcfg = (u32) value;
return count;
}
return ret;
}
/* various show routines for the controls of a MCI */
static ssize_t amd64_nbcfg_show(struct mem_ctl_info *mci, char *data)
{
struct amd64_pvt *pvt = mci->pvt_info;
return sprintf(data, "%x\n", pvt->ctl_error_info.nbcfg);
}
static ssize_t amd64_dhar_show(struct mem_ctl_info *mci, char *data)
{
struct amd64_pvt *pvt = mci->pvt_info;
return sprintf(data, "%x\n", pvt->dhar);
}
static ssize_t amd64_dbam_show(struct mem_ctl_info *mci, char *data)
{
struct amd64_pvt *pvt = mci->pvt_info;
return sprintf(data, "%x\n", pvt->dbam0);
}
static ssize_t amd64_topmem_show(struct mem_ctl_info *mci, char *data)
{
struct amd64_pvt *pvt = mci->pvt_info;
return sprintf(data, "%llx\n", pvt->top_mem);
}
static ssize_t amd64_topmem2_show(struct mem_ctl_info *mci, char *data)
{
struct amd64_pvt *pvt = mci->pvt_info;
return sprintf(data, "%llx\n", pvt->top_mem2);
}
static ssize_t amd64_hole_show(struct mem_ctl_info *mci, char *data) static ssize_t amd64_hole_show(struct mem_ctl_info *mci, char *data)
{ {
...@@ -180,38 +29,6 @@ static ssize_t amd64_hole_show(struct mem_ctl_info *mci, char *data) ...@@ -180,38 +29,6 @@ static ssize_t amd64_hole_show(struct mem_ctl_info *mci, char *data)
*/ */
struct mcidev_sysfs_attribute amd64_dbg_attrs[] = { struct mcidev_sysfs_attribute amd64_dbg_attrs[] = {
{
.attr = {
.name = "nbea_ctl",
.mode = (S_IRUGO | S_IWUSR)
},
.show = amd64_nbea_show,
.store = amd64_nbea_store,
},
{
.attr = {
.name = "nbsl_ctl",
.mode = (S_IRUGO | S_IWUSR)
},
.show = amd64_nbsl_show,
.store = amd64_nbsl_store,
},
{
.attr = {
.name = "nbsh_ctl",
.mode = (S_IRUGO | S_IWUSR)
},
.show = amd64_nbsh_show,
.store = amd64_nbsh_store,
},
{
.attr = {
.name = "nbcfg_ctl",
.mode = (S_IRUGO | S_IWUSR)
},
.show = amd64_nbcfg_show,
.store = amd64_nbcfg_store,
},
{ {
.attr = { .attr = {
.name = "dhar", .name = "dhar",
...@@ -225,7 +42,7 @@ struct mcidev_sysfs_attribute amd64_dbg_attrs[] = { ...@@ -225,7 +42,7 @@ struct mcidev_sysfs_attribute amd64_dbg_attrs[] = {
.name = "dbam", .name = "dbam",
.mode = (S_IRUGO) .mode = (S_IRUGO)
}, },
.show = amd64_dbam_show, .show = amd64_dbam0_show,
.store = NULL, .store = NULL,
}, },
{ {
...@@ -233,7 +50,7 @@ struct mcidev_sysfs_attribute amd64_dbg_attrs[] = { ...@@ -233,7 +50,7 @@ struct mcidev_sysfs_attribute amd64_dbg_attrs[] = {
.name = "topmem", .name = "topmem",
.mode = (S_IRUGO) .mode = (S_IRUGO)
}, },
.show = amd64_topmem_show, .show = amd64_top_mem_show,
.store = NULL, .store = NULL,
}, },
{ {
...@@ -241,7 +58,7 @@ struct mcidev_sysfs_attribute amd64_dbg_attrs[] = { ...@@ -241,7 +58,7 @@ struct mcidev_sysfs_attribute amd64_dbg_attrs[] = {
.name = "topmem2", .name = "topmem2",
.mode = (S_IRUGO) .mode = (S_IRUGO)
}, },
.show = amd64_topmem2_show, .show = amd64_top_mem2_show,
.store = NULL, .store = NULL,
}, },
{ {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/edac.h>
#include "edac_core.h" #include "edac_core.h"
#include "edac_module.h" #include "edac_module.h"
...@@ -235,7 +236,7 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev) ...@@ -235,7 +236,7 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
debugf1("%s()\n", __func__); debugf1("%s()\n", __func__);
/* get the /sys/devices/system/edac reference */ /* get the /sys/devices/system/edac reference */
edac_class = edac_get_edac_class(); edac_class = edac_get_sysfs_class();
if (edac_class == NULL) { if (edac_class == NULL) {
debugf1("%s() no edac_class error\n", __func__); debugf1("%s() no edac_class error\n", __func__);
err = -ENODEV; err = -ENODEV;
...@@ -255,7 +256,7 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev) ...@@ -255,7 +256,7 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
if (!try_module_get(edac_dev->owner)) { if (!try_module_get(edac_dev->owner)) {
err = -ENODEV; err = -ENODEV;
goto err_out; goto err_mod_get;
} }
/* register */ /* register */
...@@ -282,6 +283,9 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev) ...@@ -282,6 +283,9 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
err_kobj_reg: err_kobj_reg:
module_put(edac_dev->owner); module_put(edac_dev->owner);
err_mod_get:
edac_put_sysfs_class();
err_out: err_out:
return err; return err;
} }
...@@ -290,12 +294,11 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev) ...@@ -290,12 +294,11 @@ int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
* edac_device_unregister_sysfs_main_kobj: * edac_device_unregister_sysfs_main_kobj:
* the '..../edac/<name>' kobject * the '..../edac/<name>' kobject
*/ */
void edac_device_unregister_sysfs_main_kobj( void edac_device_unregister_sysfs_main_kobj(struct edac_device_ctl_info *dev)
struct edac_device_ctl_info *edac_dev)
{ {
debugf0("%s()\n", __func__); debugf0("%s()\n", __func__);
debugf4("%s() name of kobject is: %s\n", debugf4("%s() name of kobject is: %s\n",
__func__, kobject_name(&edac_dev->kobj)); __func__, kobject_name(&dev->kobj));
/* /*
* Unregister the edac device's kobject and * Unregister the edac device's kobject and
...@@ -304,7 +307,8 @@ void edac_device_unregister_sysfs_main_kobj( ...@@ -304,7 +307,8 @@ void edac_device_unregister_sysfs_main_kobj(
* a) module_put() this module * a) module_put() this module
* b) 'kfree' the memory * b) 'kfree' the memory
*/ */
kobject_put(&edac_dev->kobj); kobject_put(&dev->kobj);
edac_put_sysfs_class();
} }
/* edac_dev -> instance information */ /* edac_dev -> instance information */
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/edac.h>
#include <linux/bug.h> #include <linux/bug.h>
#include "edac_core.h" #include "edac_core.h"
...@@ -1011,13 +1012,13 @@ void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci) ...@@ -1011,13 +1012,13 @@ void edac_remove_sysfs_mci_device(struct mem_ctl_info *mci)
*/ */
int edac_sysfs_setup_mc_kset(void) int edac_sysfs_setup_mc_kset(void)
{ {
int err = 0; int err = -EINVAL;
struct sysdev_class *edac_class; struct sysdev_class *edac_class;
debugf1("%s()\n", __func__); debugf1("%s()\n", __func__);
/* get the /sys/devices/system/edac class reference */ /* get the /sys/devices/system/edac class reference */
edac_class = edac_get_edac_class(); edac_class = edac_get_sysfs_class();
if (edac_class == NULL) { if (edac_class == NULL) {
debugf1("%s() no edac_class error=%d\n", __func__, err); debugf1("%s() no edac_class error=%d\n", __func__, err);
goto fail_out; goto fail_out;
...@@ -1028,15 +1029,16 @@ int edac_sysfs_setup_mc_kset(void) ...@@ -1028,15 +1029,16 @@ int edac_sysfs_setup_mc_kset(void)
if (!mc_kset) { if (!mc_kset) {
err = -ENOMEM; err = -ENOMEM;
debugf1("%s() Failed to register '.../edac/mc'\n", __func__); debugf1("%s() Failed to register '.../edac/mc'\n", __func__);
goto fail_out; goto fail_kset;
} }
debugf1("%s() Registered '.../edac/mc' kobject\n", __func__); debugf1("%s() Registered '.../edac/mc' kobject\n", __func__);
return 0; return 0;
fail_kset:
edac_put_sysfs_class();
/* error unwind stack */
fail_out: fail_out:
return err; return err;
} }
...@@ -1049,5 +1051,6 @@ int edac_sysfs_setup_mc_kset(void) ...@@ -1049,5 +1051,6 @@ int edac_sysfs_setup_mc_kset(void)
void edac_sysfs_teardown_mc_kset(void) void edac_sysfs_teardown_mc_kset(void)
{ {
kset_unregister(mc_kset); kset_unregister(mc_kset);
edac_put_sysfs_class();
} }
This diff is collapsed.
...@@ -26,15 +26,6 @@ EXPORT_SYMBOL_GPL(edac_debug_level); ...@@ -26,15 +26,6 @@ EXPORT_SYMBOL_GPL(edac_debug_level);
/* scope is to module level only */ /* scope is to module level only */
struct workqueue_struct *edac_workqueue; struct workqueue_struct *edac_workqueue;
/*
* sysfs object: /sys/devices/system/edac
* need to export to other files in this modules
*/
static struct sysdev_class edac_class = {
.name = "edac",
};
static int edac_class_valid;
/* /*
* edac_op_state_to_string() * edac_op_state_to_string()
*/ */
...@@ -54,60 +45,6 @@ char *edac_op_state_to_string(int opstate) ...@@ -54,60 +45,6 @@ char *edac_op_state_to_string(int opstate)
return "UNKNOWN"; return "UNKNOWN";
} }
/*
* edac_get_edac_class()
*
* return pointer to the edac class of 'edac'
*/
struct sysdev_class *edac_get_edac_class(void)
{
struct sysdev_class *classptr = NULL;
if (edac_class_valid)
classptr = &edac_class;
return classptr;
}
/*
* edac_register_sysfs_edac_name()
*
* register the 'edac' into /sys/devices/system
*
* return:
* 0 success
* !0 error
*/
static int edac_register_sysfs_edac_name(void)
{
int err;
/* create the /sys/devices/system/edac directory */
err = sysdev_class_register(&edac_class);
if (err) {
debugf1("%s() error=%d\n", __func__, err);
return err;
}
edac_class_valid = 1;
return 0;
}
/*
* sysdev_class_unregister()
*
* unregister the 'edac' from /sys/devices/system
*/
static void edac_unregister_sysfs_edac_name(void)
{
/* only if currently registered, then unregister it */
if (edac_class_valid)
sysdev_class_unregister(&edac_class);
edac_class_valid = 0;
}
/* /*
* edac_workqueue_setup * edac_workqueue_setup
* initialize the edac work queue for polling operations * initialize the edac work queue for polling operations
...@@ -153,22 +90,12 @@ static int __init edac_init(void) ...@@ -153,22 +90,12 @@ static int __init edac_init(void)
*/ */
edac_pci_clear_parity_errors(); edac_pci_clear_parity_errors();
/*
* perform the registration of the /sys/devices/system/edac class object
*/
if (edac_register_sysfs_edac_name()) {
edac_printk(KERN_ERR, EDAC_MC,
"Error initializing 'edac' kobject\n");
err = -ENODEV;
goto error;
}
/* /*
* now set up the mc_kset under the edac class object * now set up the mc_kset under the edac class object
*/ */
err = edac_sysfs_setup_mc_kset(); err = edac_sysfs_setup_mc_kset();
if (err) if (err)
goto sysfs_setup_fail; goto error;
/* Setup/Initialize the workq for this core */ /* Setup/Initialize the workq for this core */
err = edac_workqueue_setup(); err = edac_workqueue_setup();
...@@ -183,9 +110,6 @@ static int __init edac_init(void) ...@@ -183,9 +110,6 @@ static int __init edac_init(void)
workq_fail: workq_fail:
edac_sysfs_teardown_mc_kset(); edac_sysfs_teardown_mc_kset();
sysfs_setup_fail:
edac_unregister_sysfs_edac_name();
error: error:
return err; return err;
} }
...@@ -201,7 +125,6 @@ static void __exit edac_exit(void) ...@@ -201,7 +125,6 @@ static void __exit edac_exit(void)
/* tear down the various subsystems */ /* tear down the various subsystems */
edac_workqueue_teardown(); edac_workqueue_teardown();
edac_sysfs_teardown_mc_kset(); edac_sysfs_teardown_mc_kset();
edac_unregister_sysfs_edac_name();
} }
/* /*
......
...@@ -42,7 +42,6 @@ extern void edac_device_unregister_sysfs_main_kobj( ...@@ -42,7 +42,6 @@ extern void edac_device_unregister_sysfs_main_kobj(
struct edac_device_ctl_info *edac_dev); struct edac_device_ctl_info *edac_dev);
extern int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev); extern int edac_device_create_sysfs(struct edac_device_ctl_info *edac_dev);
extern void edac_device_remove_sysfs(struct edac_device_ctl_info *edac_dev); extern void edac_device_remove_sysfs(struct edac_device_ctl_info *edac_dev);
extern struct sysdev_class *edac_get_edac_class(void);
/* edac core workqueue: single CPU mode */ /* edac core workqueue: single CPU mode */
extern struct workqueue_struct *edac_workqueue; extern struct workqueue_struct *edac_workqueue;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/sysdev.h> #include <linux/edac.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/ctype.h> #include <linux/ctype.h>
...@@ -354,7 +354,7 @@ static int edac_pci_main_kobj_setup(void) ...@@ -354,7 +354,7 @@ static int edac_pci_main_kobj_setup(void)
/* First time, so create the main kobject and its /* First time, so create the main kobject and its
* controls and atributes * controls and atributes
*/ */
edac_class = edac_get_edac_class(); edac_class = edac_get_sysfs_class();
if (edac_class == NULL) { if (edac_class == NULL) {
debugf1("%s() no edac_class\n", __func__); debugf1("%s() no edac_class\n", __func__);
err = -ENODEV; err = -ENODEV;
...@@ -368,7 +368,7 @@ static int edac_pci_main_kobj_setup(void) ...@@ -368,7 +368,7 @@ static int edac_pci_main_kobj_setup(void)
if (!try_module_get(THIS_MODULE)) { if (!try_module_get(THIS_MODULE)) {
debugf1("%s() try_module_get() failed\n", __func__); debugf1("%s() try_module_get() failed\n", __func__);
err = -ENODEV; err = -ENODEV;
goto decrement_count_fail; goto mod_get_fail;
} }
edac_pci_top_main_kobj = kzalloc(sizeof(struct kobject), GFP_KERNEL); edac_pci_top_main_kobj = kzalloc(sizeof(struct kobject), GFP_KERNEL);
...@@ -403,6 +403,9 @@ static int edac_pci_main_kobj_setup(void) ...@@ -403,6 +403,9 @@ static int edac_pci_main_kobj_setup(void)
kzalloc_fail: kzalloc_fail:
module_put(THIS_MODULE); module_put(THIS_MODULE);
mod_get_fail:
edac_put_sysfs_class();
decrement_count_fail: decrement_count_fail:
/* if are on this error exit, nothing to tear down */ /* if are on this error exit, nothing to tear down */
atomic_dec(&edac_pci_sysfs_refcount); atomic_dec(&edac_pci_sysfs_refcount);
...@@ -429,6 +432,7 @@ static void edac_pci_main_kobj_teardown(void) ...@@ -429,6 +432,7 @@ static void edac_pci_main_kobj_teardown(void)
__func__); __func__);
kobject_put(edac_pci_top_main_kobj); kobject_put(edac_pci_top_main_kobj);
} }
edac_put_sysfs_class();
} }
/* /*
......
...@@ -3,10 +3,13 @@ ...@@ -3,10 +3,13 @@
* *
* Author: Dave Jiang <djiang@mvista.com> * Author: Dave Jiang <djiang@mvista.com>
* *
* 2007 (c) MontaVista Software, Inc. This file is licensed under * 2007 (c) MontaVista Software, Inc.
* the terms of the GNU General Public License version 2. This program * 2010 (c) Advanced Micro Devices Inc.
* is licensed "as is" without any warranty of any kind, whether express * Borislav Petkov <borislav.petkov@amd.com>
* or implied. *
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
* *
*/ */
#include <linux/module.h> #include <linux/module.h>
...@@ -23,6 +26,8 @@ EXPORT_SYMBOL_GPL(edac_handlers); ...@@ -23,6 +26,8 @@ EXPORT_SYMBOL_GPL(edac_handlers);
int edac_err_assert = 0; int edac_err_assert = 0;
EXPORT_SYMBOL_GPL(edac_err_assert); EXPORT_SYMBOL_GPL(edac_err_assert);
static atomic_t edac_class_valid = ATOMIC_INIT(0);
/* /*
* called to determine if there is an EDAC driver interested in * called to determine if there is an EDAC driver interested in
* knowing an event (such as NMI) occurred * knowing an event (such as NMI) occurred
...@@ -44,3 +49,41 @@ void edac_atomic_assert_error(void) ...@@ -44,3 +49,41 @@ void edac_atomic_assert_error(void)
edac_err_assert++; edac_err_assert++;
} }
EXPORT_SYMBOL_GPL(edac_atomic_assert_error); EXPORT_SYMBOL_GPL(edac_atomic_assert_error);
/*
* sysfs object: /sys/devices/system/edac
* need to export to other files
*/
struct sysdev_class edac_class = {
.name = "edac",
};
EXPORT_SYMBOL_GPL(edac_class);
/* return pointer to the 'edac' node in sysfs */
struct sysdev_class *edac_get_sysfs_class(void)
{
int err = 0;
if (atomic_read(&edac_class_valid))
goto out;
/* create the /sys/devices/system/edac directory */
err = sysdev_class_register(&edac_class);
if (err) {
printk(KERN_ERR "Error registering toplevel EDAC sysfs dir\n");
return NULL;
}
out:
atomic_inc(&edac_class_valid);
return &edac_class;
}
EXPORT_SYMBOL_GPL(edac_get_sysfs_class);
void edac_put_sysfs_class(void)
{
/* last user unregisters it */
if (atomic_dec_and_test(&edac_class_valid))
sysdev_class_unregister(&edac_class);
}
EXPORT_SYMBOL_GPL(edac_put_sysfs_class);
This diff is collapsed.
#ifndef _EDAC_MCE_AMD_H #ifndef _EDAC_MCE_AMD_H
#define _EDAC_MCE_AMD_H #define _EDAC_MCE_AMD_H
#include <linux/notifier.h>
#include <asm/mce.h> #include <asm/mce.h>
#define BIT_64(n) (U64_C(1) << (n))
#define ERROR_CODE(x) ((x) & 0xffff) #define ERROR_CODE(x) ((x) & 0xffff)
#define EXT_ERROR_CODE(x) (((x) >> 16) & 0x1f) #define EXT_ERROR_CODE(x) (((x) >> 16) & 0x1f)
#define EXT_ERR_MSG(x) ext_msgs[EXT_ERROR_CODE(x)]
#define LOW_SYNDROME(x) (((x) >> 15) & 0xff) #define LOW_SYNDROME(x) (((x) >> 15) & 0xff)
#define HIGH_SYNDROME(x) (((x) >> 24) & 0xff) #define HIGH_SYNDROME(x) (((x) >> 24) & 0xff)
...@@ -20,13 +23,14 @@ ...@@ -20,13 +23,14 @@
#define II_MSG(x) ii_msgs[II(x)] #define II_MSG(x) ii_msgs[II(x)]
#define LL(x) (((x) >> 0) & 0x3) #define LL(x) (((x) >> 0) & 0x3)
#define LL_MSG(x) ll_msgs[LL(x)] #define LL_MSG(x) ll_msgs[LL(x)]
#define RRRR(x) (((x) >> 4) & 0xf)
#define RRRR_MSG(x) rrrr_msgs[RRRR(x)]
#define TO(x) (((x) >> 8) & 0x1) #define TO(x) (((x) >> 8) & 0x1)
#define TO_MSG(x) to_msgs[TO(x)] #define TO_MSG(x) to_msgs[TO(x)]
#define PP(x) (((x) >> 9) & 0x3) #define PP(x) (((x) >> 9) & 0x3)
#define PP_MSG(x) pp_msgs[PP(x)] #define PP_MSG(x) pp_msgs[PP(x)]
#define RRRR(x) (((x) >> 4) & 0xf)
#define RRRR_MSG(x) ((RRRR(x) < 9) ? rrrr_msgs[RRRR(x)] : "Wrong R4!")
#define K8_NBSH 0x4C #define K8_NBSH 0x4C
#define K8_NBSH_VALID_BIT BIT(31) #define K8_NBSH_VALID_BIT BIT(31)
...@@ -41,13 +45,45 @@ ...@@ -41,13 +45,45 @@
#define K8_NBSH_UECC BIT(13) #define K8_NBSH_UECC BIT(13)
#define K8_NBSH_ERR_SCRUBER BIT(8) #define K8_NBSH_ERR_SCRUBER BIT(8)
enum tt_ids {
TT_INSTR = 0,
TT_DATA,
TT_GEN,
TT_RESV,
};
enum ll_ids {
LL_RESV = 0,
LL_L1,
LL_L2,
LL_LG,
};
enum ii_ids {
II_MEM = 0,
II_RESV,
II_IO,
II_GEN,
};
enum rrrr_ids {
R4_GEN = 0,
R4_RD,
R4_WR,
R4_DRD,
R4_DWR,
R4_IRD,
R4_PREF,
R4_EVICT,
R4_SNOOP,
};
extern const char *tt_msgs[]; extern const char *tt_msgs[];
extern const char *ll_msgs[]; extern const char *ll_msgs[];
extern const char *rrrr_msgs[]; extern const char *rrrr_msgs[];
extern const char *pp_msgs[]; extern const char *pp_msgs[];
extern const char *to_msgs[]; extern const char *to_msgs[];
extern const char *ii_msgs[]; extern const char *ii_msgs[];
extern const char *ext_msgs[];
/* /*
* relevant NB regs * relevant NB regs
...@@ -60,10 +96,19 @@ struct err_regs { ...@@ -60,10 +96,19 @@ struct err_regs {
u32 nbeal; u32 nbeal;
}; };
/*
* per-family decoder ops
*/
struct amd_decoder_ops {
bool (*dc_mce)(u16);
bool (*ic_mce)(u16);
bool (*nb_mce)(u16, u8);
};
void amd_report_gart_errors(bool); void amd_report_gart_errors(bool);
void amd_register_ecc_decoder(void (*f)(int, struct err_regs *)); void amd_register_ecc_decoder(void (*f)(int, struct mce *, u32));
void amd_unregister_ecc_decoder(void (*f)(int, struct err_regs *)); void amd_unregister_ecc_decoder(void (*f)(int, struct mce *, u32));
void amd_decode_nb_mce(int, struct err_regs *, int); void amd_decode_nb_mce(int, struct mce *, u32);
int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data);
#endif /* _EDAC_MCE_AMD_H */ #endif /* _EDAC_MCE_AMD_H */
/*
* A simple MCE injection facility for testing the MCE decoding code. This
* driver should be built as module so that it can be loaded on production
* kernels for testing purposes.
*
* This file may be distributed under the terms of the GNU General Public
* License version 2.
*
* Copyright (c) 2010: Borislav Petkov <borislav.petkov@amd.com>
* Advanced Micro Devices Inc.
*/
#include <linux/kobject.h>
#include <linux/sysdev.h>
#include <linux/edac.h>
#include <asm/mce.h>
#include "mce_amd.h"
struct edac_mce_attr {
struct attribute attr;
ssize_t (*show) (struct kobject *kobj, struct edac_mce_attr *attr, char *buf);
ssize_t (*store)(struct kobject *kobj, struct edac_mce_attr *attr,
const char *buf, size_t count);
};
#define EDAC_MCE_ATTR(_name, _mode, _show, _store) \
static struct edac_mce_attr mce_attr_##_name = __ATTR(_name, _mode, _show, _store)
static struct kobject *mce_kobj;
/*
* Collect all the MCi_XXX settings
*/
static struct mce i_mce;
#define MCE_INJECT_STORE(reg) \
static ssize_t edac_inject_##reg##_store(struct kobject *kobj, \
struct edac_mce_attr *attr, \
const char *data, size_t count)\
{ \
int ret = 0; \
unsigned long value; \
\
ret = strict_strtoul(data, 16, &value); \
if (ret < 0) \
printk(KERN_ERR "Error writing MCE " #reg " field.\n"); \
\
i_mce.reg = value; \
\
return count; \
}
MCE_INJECT_STORE(status);
MCE_INJECT_STORE(misc);
MCE_INJECT_STORE(addr);
#define MCE_INJECT_SHOW(reg) \
static ssize_t edac_inject_##reg##_show(struct kobject *kobj, \
struct edac_mce_attr *attr, \
char *buf) \
{ \
return sprintf(buf, "0x%016llx\n", i_mce.reg); \
}
MCE_INJECT_SHOW(status);
MCE_INJECT_SHOW(misc);
MCE_INJECT_SHOW(addr);
EDAC_MCE_ATTR(status, 0644, edac_inject_status_show, edac_inject_status_store);
EDAC_MCE_ATTR(misc, 0644, edac_inject_misc_show, edac_inject_misc_store);
EDAC_MCE_ATTR(addr, 0644, edac_inject_addr_show, edac_inject_addr_store);
/*
* This denotes into which bank we're injecting and triggers
* the injection, at the same time.
*/
static ssize_t edac_inject_bank_store(struct kobject *kobj,
struct edac_mce_attr *attr,
const char *data, size_t count)
{
int ret = 0;
unsigned long value;
ret = strict_strtoul(data, 10, &value);
if (ret < 0) {
printk(KERN_ERR "Invalid bank value!\n");
return -EINVAL;
}
if (value > 5) {
printk(KERN_ERR "Non-existant MCE bank: %lu\n", value);
return -EINVAL;
}
i_mce.bank = value;
amd_decode_mce(NULL, 0, &i_mce);
return count;
}
static ssize_t edac_inject_bank_show(struct kobject *kobj,
struct edac_mce_attr *attr, char *buf)
{
return sprintf(buf, "%d\n", i_mce.bank);
}
EDAC_MCE_ATTR(bank, 0644, edac_inject_bank_show, edac_inject_bank_store);
static struct edac_mce_attr *sysfs_attrs[] = { &mce_attr_status, &mce_attr_misc,
&mce_attr_addr, &mce_attr_bank
};
static int __init edac_init_mce_inject(void)
{
struct sysdev_class *edac_class = NULL;
int i, err = 0;
edac_class = edac_get_sysfs_class();
if (!edac_class)
return -EINVAL;
mce_kobj = kobject_create_and_add("mce", &edac_class->kset.kobj);
if (!mce_kobj) {
printk(KERN_ERR "Error creating a mce kset.\n");
err = -ENOMEM;
goto err_mce_kobj;
}
for (i = 0; i < ARRAY_SIZE(sysfs_attrs); i++) {
err = sysfs_create_file(mce_kobj, &sysfs_attrs[i]->attr);
if (err) {
printk(KERN_ERR "Error creating %s in sysfs.\n",
sysfs_attrs[i]->attr.name);
goto err_sysfs_create;
}
}
return 0;
err_sysfs_create:
while (i-- >= 0)
sysfs_remove_file(mce_kobj, &sysfs_attrs[i]->attr);
kobject_del(mce_kobj);
err_mce_kobj:
edac_put_sysfs_class();
return err;
}
static void __exit edac_exit_mce_inject(void)
{
int i;
for (i = 0; i < ARRAY_SIZE(sysfs_attrs); i++)
sysfs_remove_file(mce_kobj, &sysfs_attrs[i]->attr);
kobject_del(mce_kobj);
edac_put_sysfs_class();
}
module_init(edac_init_mce_inject);
module_exit(edac_exit_mce_inject);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Borislav Petkov <borislav.petkov@amd.com>");
MODULE_AUTHOR("AMD Inc.");
MODULE_DESCRIPTION("MCE injection facility for testing MCE decoding");
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#define _LINUX_EDAC_H_ #define _LINUX_EDAC_H_
#include <asm/atomic.h> #include <asm/atomic.h>
#include <linux/sysdev.h>
#define EDAC_OPSTATE_INVAL -1 #define EDAC_OPSTATE_INVAL -1
#define EDAC_OPSTATE_POLL 0 #define EDAC_OPSTATE_POLL 0
...@@ -22,9 +23,12 @@ ...@@ -22,9 +23,12 @@
extern int edac_op_state; extern int edac_op_state;
extern int edac_err_assert; extern int edac_err_assert;
extern atomic_t edac_handlers; extern atomic_t edac_handlers;
extern struct sysdev_class edac_class;
extern int edac_handler_set(void); extern int edac_handler_set(void);
extern void edac_atomic_assert_error(void); extern void edac_atomic_assert_error(void);
extern struct sysdev_class *edac_get_sysfs_class(void);
extern void edac_put_sysfs_class(void);
static inline void opstate_init(void) static inline void opstate_init(void)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment