Commit 881d021a authored by David S. Miller's avatar David S. Miller

sparc64: Add generic interface for registering a dimm printing handler.

The way to do this varies by platform type and the exact memory
controller the cpu uses.

For Spitfire cpus we currently just use prom_getunumber() and hope
that works.

For Cheetah cpus we have a memory controller driver that can
compute this information.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 83ef64b9
#ifndef _SPARC_MEMCTRL_H
#define _SPARC_MEMCTRL_H
typedef int (*dimm_printer_t)(int synd_code, unsigned long paddr, char *buf, int buflen);
int register_dimm_printer(dimm_printer_t func);
void unregister_dimm_printer(dimm_printer_t func);
#endif /* _SPARC_MEMCTRL_H */
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/head.h> #include <asm/head.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/memctrl.h>
#define DRV_MODULE_NAME "chmc" #define DRV_MODULE_NAME "chmc"
#define PFX DRV_MODULE_NAME ": " #define PFX DRV_MODULE_NAME ": "
...@@ -158,9 +159,9 @@ static struct chmc_bank_info *chmc_find_bank(unsigned long phys_addr) ...@@ -158,9 +159,9 @@ static struct chmc_bank_info *chmc_find_bank(unsigned long phys_addr)
/* This is the main purpose of this driver. */ /* This is the main purpose of this driver. */
#define SYNDROME_MIN -1 #define SYNDROME_MIN -1
#define SYNDROME_MAX 144 #define SYNDROME_MAX 144
int chmc_getunumber(int syndrome_code, static int chmc_print_dimm(int syndrome_code,
unsigned long phys_addr, unsigned long phys_addr,
char *buf, int buflen) char *buf, int buflen)
{ {
struct chmc_bank_info *bp; struct chmc_bank_info *bp;
struct chmc_obp_mem_layout *prop; struct chmc_obp_mem_layout *prop;
...@@ -466,16 +467,26 @@ static inline bool chmc_platform(void) ...@@ -466,16 +467,26 @@ static inline bool chmc_platform(void)
static int __init chmc_init(void) static int __init chmc_init(void)
{ {
int ret;
if (!chmc_platform()) if (!chmc_platform())
return -ENODEV; return -ENODEV;
return of_register_driver(&chmc_driver, &of_bus_type); ret = register_dimm_printer(chmc_print_dimm);
if (!ret) {
ret = of_register_driver(&chmc_driver, &of_bus_type);
if (ret)
unregister_dimm_printer(chmc_print_dimm);
}
return ret;
} }
static void __exit chmc_cleanup(void) static void __exit chmc_cleanup(void)
{ {
if (chmc_platform()) if (chmc_platform()) {
unregister_dimm_printer(chmc_print_dimm);
of_unregister_driver(&chmc_driver); of_unregister_driver(&chmc_driver);
}
} }
module_init(chmc_init); module_init(chmc_init);
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <asm/timer.h> #include <asm/timer.h>
#include <asm/head.h> #include <asm/head.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/memctrl.h>
#include "entry.h" #include "entry.h"
#include "kstack.h" #include "kstack.h"
...@@ -128,6 +129,55 @@ void do_BUG(const char *file, int line) ...@@ -128,6 +129,55 @@ void do_BUG(const char *file, int line)
} }
#endif #endif
static DEFINE_SPINLOCK(dimm_handler_lock);
static dimm_printer_t dimm_handler;
static int sprintf_dimm(int synd_code, unsigned long paddr, char *buf, int buflen)
{
unsigned long flags;
int ret = -ENODEV;
spin_lock_irqsave(&dimm_handler_lock, flags);
if (dimm_handler) {
ret = dimm_handler(synd_code, paddr, buf, buflen);
} else if (tlb_type == spitfire) {
if (prom_getunumber(synd_code, paddr, buf, buflen) == -1)
ret = -EINVAL;
else
ret = 0;
} else
ret = -ENODEV;
spin_unlock_irqrestore(&dimm_handler_lock, flags);
return ret;
}
int register_dimm_printer(dimm_printer_t func)
{
unsigned long flags;
int ret = 0;
spin_lock_irqsave(&dimm_handler_lock, flags);
if (!dimm_handler)
dimm_handler = func;
else
ret = -EEXIST;
spin_unlock_irqrestore(&dimm_handler_lock, flags);
return ret;
}
void unregister_dimm_printer(dimm_printer_t func)
{
unsigned long flags;
spin_lock_irqsave(&dimm_handler_lock, flags);
if (dimm_handler == func)
dimm_handler = NULL;
spin_unlock_irqrestore(&dimm_handler_lock, flags);
}
void spitfire_insn_access_exception(struct pt_regs *regs, unsigned long sfsr, unsigned long sfar) void spitfire_insn_access_exception(struct pt_regs *regs, unsigned long sfsr, unsigned long sfar)
{ {
siginfo_t info; siginfo_t info;
...@@ -375,8 +425,7 @@ static void spitfire_log_udb_syndrome(unsigned long afar, unsigned long udbh, un ...@@ -375,8 +425,7 @@ static void spitfire_log_udb_syndrome(unsigned long afar, unsigned long udbh, un
if (udbl & bit) { if (udbl & bit) {
scode = ecc_syndrome_table[udbl & 0xff]; scode = ecc_syndrome_table[udbl & 0xff];
if (prom_getunumber(scode, afar, if (sprintf_dimm(scode, afar, memmod_str, sizeof(memmod_str)) < 0)
memmod_str, sizeof(memmod_str)) == -1)
p = syndrome_unknown; p = syndrome_unknown;
else else
p = memmod_str; p = memmod_str;
...@@ -387,8 +436,7 @@ static void spitfire_log_udb_syndrome(unsigned long afar, unsigned long udbh, un ...@@ -387,8 +436,7 @@ static void spitfire_log_udb_syndrome(unsigned long afar, unsigned long udbh, un
if (udbh & bit) { if (udbh & bit) {
scode = ecc_syndrome_table[udbh & 0xff]; scode = ecc_syndrome_table[udbh & 0xff];
if (prom_getunumber(scode, afar, if (sprintf_dimm(scode, afar, memmod_str, sizeof(memmod_str)) < 0)
memmod_str, sizeof(memmod_str)) == -1)
p = syndrome_unknown; p = syndrome_unknown;
else else
p = memmod_str; p = memmod_str;
...@@ -1061,8 +1109,6 @@ static const char *cheetah_get_string(unsigned long bit) ...@@ -1061,8 +1109,6 @@ static const char *cheetah_get_string(unsigned long bit)
return "???"; return "???";
} }
extern int chmc_getunumber(int, unsigned long, char *, int);
static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *info, static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *info,
unsigned long afsr, unsigned long afar, int recoverable) unsigned long afsr, unsigned long afar, int recoverable)
{ {
...@@ -1104,7 +1150,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in ...@@ -1104,7 +1150,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
syndrome = (afsr & CHAFSR_E_SYNDROME) >> CHAFSR_E_SYNDROME_SHIFT; syndrome = (afsr & CHAFSR_E_SYNDROME) >> CHAFSR_E_SYNDROME_SHIFT;
syndrome = cheetah_ecc_syntab[syndrome]; syndrome = cheetah_ecc_syntab[syndrome];
ret = chmc_getunumber(syndrome, afar, unum, sizeof(unum)); ret = sprintf_dimm(syndrome, afar, unum, sizeof(unum));
if (ret != -1) if (ret != -1)
printk("%s" "ERROR(%d): AFAR E-syndrome [%s]\n", printk("%s" "ERROR(%d): AFAR E-syndrome [%s]\n",
(recoverable ? KERN_WARNING : KERN_CRIT), (recoverable ? KERN_WARNING : KERN_CRIT),
...@@ -1115,7 +1161,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in ...@@ -1115,7 +1161,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
syndrome = (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT; syndrome = (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT;
syndrome = cheetah_mtag_syntab[syndrome]; syndrome = cheetah_mtag_syntab[syndrome];
ret = chmc_getunumber(syndrome, afar, unum, sizeof(unum)); ret = sprintf_dimm(syndrome, afar, unum, sizeof(unum));
if (ret != -1) if (ret != -1)
printk("%s" "ERROR(%d): AFAR M-syndrome [%s]\n", printk("%s" "ERROR(%d): AFAR M-syndrome [%s]\n",
(recoverable ? KERN_WARNING : KERN_CRIT), (recoverable ? KERN_WARNING : KERN_CRIT),
......
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