Skip to content

Commit b70ef01

Browse files
author
Borislav Petkov
committed
EDAC: move MCE error descriptions to EDAC core
This is in preparation of adding AMD-specific MCE decoding functionality to the EDAC core. The error decoding macros originate from the AMD64 EDAC driver albeit in a simplified and cleaned up version here. While at it, add macros to generate the error description strings and use them in the error type decoders directly which removes a bunch of code and makes the decoding functions much more readable. Also, fix strings and shorten macro names. Remove superfluous htlink_msgs. Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
1 parent 74fca6a commit b70ef01

5 files changed

Lines changed: 122 additions & 148 deletions

File tree

‎drivers/edac/Makefile‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ ifdef CONFIG_PCI
1717
edac_core-objs += edac_pci.o edac_pci_sysfs.o
1818
endif
1919

20+
ifdef CONFIG_CPU_SUP_AMD
21+
edac_core-objs += edac_mce_amd.o
22+
endif
23+
2024
obj-$(CONFIG_EDAC_AMD76X) += amd76x_edac.o
2125
obj-$(CONFIG_EDAC_CPC925) += cpc925_edac.o
2226
obj-$(CONFIG_EDAC_I5000) += i5000_edac.o
@@ -32,7 +36,7 @@ obj-$(CONFIG_EDAC_X38) += x38_edac.o
3236
obj-$(CONFIG_EDAC_I82860) += i82860_edac.o
3337
obj-$(CONFIG_EDAC_R82600) += r82600_edac.o
3438

35-
amd64_edac_mod-y := amd64_edac_err_types.o amd64_edac.o
39+
amd64_edac_mod-y := amd64_edac.o
3640
amd64_edac_mod-$(CONFIG_EDAC_DEBUG) += amd64_edac_dbg.o
3741
amd64_edac_mod-$(CONFIG_EDAC_AMD64_ERROR_INJECTION) += amd64_edac_inj.o
3842

‎drivers/edac/amd64_edac.c‎

Lines changed: 78 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,63 @@ struct amd64_pvt;
1818
static struct mem_ctl_info *mci_lookup[MAX_NUMNODES];
1919
static struct amd64_pvt *pvt_lookup[MAX_NUMNODES];
2020

21+
/*
22+
* See F2x80 for K8 and F2x[1,0]80 for Fam10 and later. The table below is only
23+
* for DDR2 DRAM mapping.
24+
*/
25+
u32 revf_quad_ddr2_shift[] = {
26+
0, /* 0000b NULL DIMM (128mb) */
27+
28, /* 0001b 256mb */
28+
29, /* 0010b 512mb */
29+
29, /* 0011b 512mb */
30+
29, /* 0100b 512mb */
31+
30, /* 0101b 1gb */
32+
30, /* 0110b 1gb */
33+
31, /* 0111b 2gb */
34+
31, /* 1000b 2gb */
35+
32, /* 1001b 4gb */
36+
32, /* 1010b 4gb */
37+
33, /* 1011b 8gb */
38+
0, /* 1100b future */
39+
0, /* 1101b future */
40+
0, /* 1110b future */
41+
0 /* 1111b future */
42+
};
43+
44+
/*
45+
* Valid scrub rates for the K8 hardware memory scrubber. We map the scrubbing
46+
* bandwidth to a valid bit pattern. The 'set' operation finds the 'matching-
47+
* or higher value'.
48+
*
49+
*FIXME: Produce a better mapping/linearisation.
50+
*/
51+
52+
struct scrubrate scrubrates[] = {
53+
{ 0x01, 1600000000UL},
54+
{ 0x02, 800000000UL},
55+
{ 0x03, 400000000UL},
56+
{ 0x04, 200000000UL},
57+
{ 0x05, 100000000UL},
58+
{ 0x06, 50000000UL},
59+
{ 0x07, 25000000UL},
60+
{ 0x08, 12284069UL},
61+
{ 0x09, 6274509UL},
62+
{ 0x0A, 3121951UL},
63+
{ 0x0B, 1560975UL},
64+
{ 0x0C, 781440UL},
65+
{ 0x0D, 390720UL},
66+
{ 0x0E, 195300UL},
67+
{ 0x0F, 97650UL},
68+
{ 0x10, 48854UL},
69+
{ 0x11, 24427UL},
70+
{ 0x12, 12213UL},
71+
{ 0x13, 6101UL},
72+
{ 0x14, 3051UL},
73+
{ 0x15, 1523UL},
74+
{ 0x16, 761UL},
75+
{ 0x00, 0UL}, /* scrubbing off */
76+
};
77+
2178
/*
2279
* Memory scrubber control interface. For K8, memory scrubbing is handled by
2380
* hardware and can involve L2 cache, dcache as well as the main memory. With
@@ -1101,8 +1158,8 @@ static void k8_map_sysaddr_to_csrow(struct mem_ctl_info *mci,
11011158
u32 page, offset;
11021159

11031160
/* Extract the syndrome parts and form a 16-bit syndrome */
1104-
syndrome = EXTRACT_HIGH_SYNDROME(info->nbsl) << 8;
1105-
syndrome |= EXTRACT_LOW_SYNDROME(info->nbsh);
1161+
syndrome = HIGH_SYNDROME(info->nbsl) << 8;
1162+
syndrome |= LOW_SYNDROME(info->nbsh);
11061163

11071164
/* CHIPKILL enabled */
11081165
if (info->nbcfg & K8_NBCFG_CHIPKILL) {
@@ -1701,8 +1758,8 @@ static void f10_map_sysaddr_to_csrow(struct mem_ctl_info *mci,
17011758
if (csrow >= 0) {
17021759
error_address_to_page_and_offset(sys_addr, &page, &offset);
17031760

1704-
syndrome = EXTRACT_HIGH_SYNDROME(info->nbsl) << 8;
1705-
syndrome |= EXTRACT_LOW_SYNDROME(info->nbsh);
1761+
syndrome = HIGH_SYNDROME(info->nbsl) << 8;
1762+
syndrome |= LOW_SYNDROME(info->nbsh);
17061763

17071764
/*
17081765
* Is CHIPKILL on? If so, then we can attempt to use the
@@ -2155,36 +2212,22 @@ static int amd64_get_error_info(struct mem_ctl_info *mci,
21552212
static inline void amd64_decode_gart_tlb_error(struct mem_ctl_info *mci,
21562213
struct amd64_error_info_regs *info)
21572214
{
2158-
u32 err_code;
2159-
u32 ec_tt; /* error code transaction type (2b) */
2160-
u32 ec_ll; /* error code cache level (2b) */
2161-
2162-
err_code = EXTRACT_ERROR_CODE(info->nbsl);
2163-
ec_ll = EXTRACT_LL_CODE(err_code);
2164-
ec_tt = EXTRACT_TT_CODE(err_code);
2215+
u32 ec = ERROR_CODE(info->nbsl);
21652216

21662217
amd64_mc_printk(mci, KERN_ERR,
21672218
"GART TLB event: transaction type(%s), "
2168-
"cache level(%s)\n", tt_msgs[ec_tt], ll_msgs[ec_ll]);
2219+
"cache level(%s)\n", TT_MSG(ec), LL_MSG(ec));
21692220
}
21702221

21712222
static inline void amd64_decode_mem_cache_error(struct mem_ctl_info *mci,
21722223
struct amd64_error_info_regs *info)
21732224
{
2174-
u32 err_code;
2175-
u32 ec_rrrr; /* error code memory transaction (4b) */
2176-
u32 ec_tt; /* error code transaction type (2b) */
2177-
u32 ec_ll; /* error code cache level (2b) */
2178-
2179-
err_code = EXTRACT_ERROR_CODE(info->nbsl);
2180-
ec_ll = EXTRACT_LL_CODE(err_code);
2181-
ec_tt = EXTRACT_TT_CODE(err_code);
2182-
ec_rrrr = EXTRACT_RRRR_CODE(err_code);
2225+
u32 ec = ERROR_CODE(info->nbsl);
21832226

21842227
amd64_mc_printk(mci, KERN_ERR,
21852228
"cache hierarchy error: memory transaction type(%s), "
21862229
"transaction type(%s), cache level(%s)\n",
2187-
rrrr_msgs[ec_rrrr], tt_msgs[ec_tt], ll_msgs[ec_ll]);
2230+
RRRR_MSG(ec), TT_MSG(ec), LL_MSG(ec));
21882231
}
21892232

21902233

@@ -2264,42 +2307,26 @@ static void amd64_handle_ue(struct mem_ctl_info *mci,
22642307
static void amd64_decode_bus_error(struct mem_ctl_info *mci,
22652308
struct amd64_error_info_regs *info)
22662309
{
2267-
u32 err_code, ext_ec;
2268-
u32 ec_pp; /* error code participating processor (2p) */
2269-
u32 ec_to; /* error code timed out (1b) */
2270-
u32 ec_rrrr; /* error code memory transaction (4b) */
2271-
u32 ec_ii; /* error code memory or I/O (2b) */
2272-
u32 ec_ll; /* error code cache level (2b) */
2273-
2274-
ext_ec = EXTRACT_EXT_ERROR_CODE(info->nbsl);
2275-
err_code = EXTRACT_ERROR_CODE(info->nbsl);
2276-
2277-
ec_ll = EXTRACT_LL_CODE(err_code);
2278-
ec_ii = EXTRACT_II_CODE(err_code);
2279-
ec_rrrr = EXTRACT_RRRR_CODE(err_code);
2280-
ec_to = EXTRACT_TO_CODE(err_code);
2281-
ec_pp = EXTRACT_PP_CODE(err_code);
2310+
u32 ec = ERROR_CODE(info->nbsl);
2311+
u32 xec = EXT_ERROR_CODE(info->nbsl);
22822312

22832313
amd64_mc_printk(mci, KERN_ERR,
22842314
"BUS ERROR:\n"
22852315
" time-out(%s) mem or i/o(%s)\n"
22862316
" participating processor(%s)\n"
22872317
" memory transaction type(%s)\n"
22882318
" cache level(%s) Error Found by: %s\n",
2289-
to_msgs[ec_to],
2290-
ii_msgs[ec_ii],
2291-
pp_msgs[ec_pp],
2292-
rrrr_msgs[ec_rrrr],
2293-
ll_msgs[ec_ll],
2319+
TO_MSG(ec), II_MSG(ec), PP_MSG(ec), RRRR_MSG(ec), LL_MSG(ec),
22942320
(info->nbsh & K8_NBSH_ERR_SCRUBER) ?
22952321
"Scrubber" : "Normal Operation");
22962322

2297-
/* If this was an 'observed' error, early out */
2298-
if (ec_pp == K8_NBSL_PP_OBS)
2299-
return; /* We aren't the node involved */
2323+
2324+
/* Bail early out if this was an 'observed' error */
2325+
if (PP(ec) == K8_NBSL_PP_OBS)
2326+
return;
23002327

23012328
/* Parse out the extended error code for ECC events */
2302-
switch (ext_ec) {
2329+
switch (xec) {
23032330
/* F10 changed to one Extended ECC error code */
23042331
case F10_NBSL_EXT_ERR_RES: /* Reserved field */
23052332
case F10_NBSL_EXT_ERR_ECC: /* F10 ECC ext err code */
@@ -2379,15 +2406,15 @@ int amd64_process_error_info(struct mem_ctl_info *mci,
23792406
(regs->nbsh & K8_NBSH_CORE3) ? "True" : "False");
23802407

23812408

2382-
err_code = EXTRACT_ERROR_CODE(regs->nbsl);
2409+
err_code = ERROR_CODE(regs->nbsl);
23832410

23842411
/* Determine which error type:
23852412
* 1) GART errors - non-fatal, developmental events
23862413
* 2) MEMORY errors
23872414
* 3) BUS errors
23882415
* 4) Unknown error
23892416
*/
2390-
if (TEST_TLB_ERROR(err_code)) {
2417+
if (TLB_ERROR(err_code)) {
23912418
/*
23922419
* GART errors are intended to help graphics driver developers
23932420
* to detect bad GART PTEs. It is recommended by AMD to disable
@@ -2411,10 +2438,10 @@ int amd64_process_error_info(struct mem_ctl_info *mci,
24112438

24122439
debugf1("GART TLB error\n");
24132440
amd64_decode_gart_tlb_error(mci, info);
2414-
} else if (TEST_MEM_ERROR(err_code)) {
2441+
} else if (MEM_ERROR(err_code)) {
24152442
debugf1("Memory/Cache error\n");
24162443
amd64_decode_mem_cache_error(mci, info);
2417-
} else if (TEST_BUS_ERROR(err_code)) {
2444+
} else if (BUS_ERROR(err_code)) {
24182445
debugf1("Bus (Link/DRAM) error\n");
24192446
amd64_decode_bus_error(mci, info);
24202447
} else {
@@ -2424,21 +2451,10 @@ int amd64_process_error_info(struct mem_ctl_info *mci,
24242451
err_code);
24252452
}
24262453

2427-
ext_ec = EXTRACT_EXT_ERROR_CODE(regs->nbsl);
2454+
ext_ec = EXT_ERROR_CODE(regs->nbsl);
24282455
amd64_mc_printk(mci, KERN_ERR,
24292456
"ExtErr=(0x%x) %s\n", ext_ec, ext_msgs[ext_ec]);
24302457

2431-
if (((ext_ec >= F10_NBSL_EXT_ERR_CRC &&
2432-
ext_ec <= F10_NBSL_EXT_ERR_TGT) ||
2433-
(ext_ec == F10_NBSL_EXT_ERR_RMW)) &&
2434-
EXTRACT_LDT_LINK(info->nbsh)) {
2435-
2436-
amd64_mc_printk(mci, KERN_ERR,
2437-
"Error on hypertransport link: %s\n",
2438-
htlink_msgs[
2439-
EXTRACT_LDT_LINK(info->nbsh)]);
2440-
}
2441-
24422458
/*
24432459
* Check the UE bit of the NB status high register, if set generate some
24442460
* logs. If NOT a GART error, then process the event as a NO-INFO event.

‎drivers/edac/amd64_edac.h‎

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
#include <linux/edac.h>
7373
#include <asm/msr.h>
7474
#include "edac_core.h"
75+
#include "edac_mce_amd.h"
7576

7677
#define amd64_printk(level, fmt, arg...) \
7778
edac_printk(level, "amd64", fmt, ##arg)
@@ -303,9 +304,6 @@ enum {
303304
#define K8_NBSL 0x48
304305

305306

306-
#define EXTRACT_HIGH_SYNDROME(x) (((x) >> 24) & 0xff)
307-
#define EXTRACT_EXT_ERROR_CODE(x) (((x) >> 16) & 0x1f)
308-
309307
/* Family F10h: Normalized Extended Error Codes */
310308
#define F10_NBSL_EXT_ERR_RES 0x0
311309
#define F10_NBSL_EXT_ERR_CRC 0x1
@@ -348,17 +346,6 @@ enum {
348346
#define K8_NBSL_EXT_ERR_CHIPKILL_ECC 0x8
349347
#define K8_NBSL_EXT_ERR_DRAM_PARITY 0xD
350348

351-
#define EXTRACT_ERROR_CODE(x) ((x) & 0xffff)
352-
#define TEST_TLB_ERROR(x) (((x) & 0xFFF0) == 0x0010)
353-
#define TEST_MEM_ERROR(x) (((x) & 0xFF00) == 0x0100)
354-
#define TEST_BUS_ERROR(x) (((x) & 0xF800) == 0x0800)
355-
#define EXTRACT_TT_CODE(x) (((x) >> 2) & 0x3)
356-
#define EXTRACT_II_CODE(x) (((x) >> 2) & 0x3)
357-
#define EXTRACT_LL_CODE(x) (((x) >> 0) & 0x3)
358-
#define EXTRACT_RRRR_CODE(x) (((x) >> 4) & 0xf)
359-
#define EXTRACT_TO_CODE(x) (((x) >> 8) & 0x1)
360-
#define EXTRACT_PP_CODE(x) (((x) >> 9) & 0x3)
361-
362349
/*
363350
* The following are for BUS type errors AFTER values have been normalized by
364351
* shifting right
@@ -386,9 +373,7 @@ enum {
386373
#define K8_NBSH_CORE1 BIT(1)
387374
#define K8_NBSH_CORE0 BIT(0)
388375

389-
#define EXTRACT_LDT_LINK(x) (((x) >> 4) & 0x7)
390376
#define EXTRACT_ERR_CPU_MAP(x) ((x) & 0xF)
391-
#define EXTRACT_LOW_SYNDROME(x) (((x) >> 15) & 0xff)
392377

393378

394379
#define K8_NBEAL 0x50

0 commit comments

Comments
 (0)