blob: 4e9c5e596c6c20890f1c40b997a2d4fbcf9f46b3 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Borislav Petkov549d0422009-07-24 13:51:42 +02002#ifndef _EDAC_MCE_AMD_H
3#define _EDAC_MCE_AMD_H
4
Borislav Petkov9cdeb402010-09-02 18:33:24 +02005#include <linux/notifier.h>
6
Borislav Petkov549d0422009-07-24 13:51:42 +02007#include <asm/mce.h>
8
Borislav Petkov62452882010-09-22 16:08:37 +02009#define EC(x) ((x) & 0xffff)
10#define XEC(x, mask) (((x) >> 16) & mask)
Borislav Petkov5110dbd2009-06-25 19:51:04 +020011
Borislav Petkovb70ef012009-06-25 19:32:38 +020012#define LOW_SYNDROME(x) (((x) >> 15) & 0xff)
13#define HIGH_SYNDROME(x) (((x) >> 24) & 0xff)
14
15#define TLB_ERROR(x) (((x) & 0xFFF0) == 0x0010)
16#define MEM_ERROR(x) (((x) & 0xFF00) == 0x0100)
17#define BUS_ERROR(x) (((x) & 0xF800) == 0x0800)
Jacob Shin980eec82012-12-18 15:06:11 -060018#define INT_ERROR(x) (((x) & 0xF4FF) == 0x0400)
Borislav Petkovb70ef012009-06-25 19:32:38 +020019
20#define TT(x) (((x) >> 2) & 0x3)
21#define TT_MSG(x) tt_msgs[TT(x)]
22#define II(x) (((x) >> 2) & 0x3)
23#define II_MSG(x) ii_msgs[II(x)]
Borislav Petkov62452882010-09-22 16:08:37 +020024#define LL(x) ((x) & 0x3)
Borislav Petkovb70ef012009-06-25 19:32:38 +020025#define LL_MSG(x) ll_msgs[LL(x)]
Borislav Petkovb70ef012009-06-25 19:32:38 +020026#define TO(x) (((x) >> 8) & 0x1)
27#define TO_MSG(x) to_msgs[TO(x)]
28#define PP(x) (((x) >> 9) & 0x3)
29#define PP_MSG(x) pp_msgs[PP(x)]
Jacob Shin980eec82012-12-18 15:06:11 -060030#define UU(x) (((x) >> 8) & 0x3)
31#define UU_MSG(x) uu_msgs[UU(x)]
Borislav Petkovb70ef012009-06-25 19:32:38 +020032
Borislav Petkov62452882010-09-22 16:08:37 +020033#define R4(x) (((x) >> 4) & 0xf)
34#define R4_MSG(x) ((R4(x) < 9) ? rrrr_msgs[R4(x)] : "Wrong R4!")
Borislav Petkov63375832010-09-06 18:13:39 +020035
Borislav Petkov0f086692012-12-23 12:40:45 +010036extern const char * const pp_msgs[];
37
Borislav Petkov888ab8e2010-08-18 15:11:35 +020038enum tt_ids {
39 TT_INSTR = 0,
40 TT_DATA,
41 TT_GEN,
42 TT_RESV,
43};
44
45enum ll_ids {
46 LL_RESV = 0,
47 LL_L1,
48 LL_L2,
49 LL_LG,
50};
51
52enum ii_ids {
53 II_MEM = 0,
54 II_RESV,
55 II_IO,
56 II_GEN,
57};
58
59enum rrrr_ids {
60 R4_GEN = 0,
61 R4_RD,
62 R4_WR,
63 R4_DRD,
64 R4_DWR,
65 R4_IRD,
66 R4_PREF,
67 R4_EVICT,
68 R4_SNOOP,
69};
70
Borislav Petkov549d0422009-07-24 13:51:42 +020071/*
Borislav Petkov888ab8e2010-08-18 15:11:35 +020072 * per-family decoder ops
73 */
74struct amd_decoder_ops {
Borislav Petkovf05c41a2012-09-11 18:57:43 +020075 bool (*mc0_mce)(u16, u8);
76 bool (*mc1_mce)(u16, u8);
Jacob Shin4a73d3d2012-12-18 15:06:10 -060077 bool (*mc2_mce)(u16, u8);
Borislav Petkov888ab8e2010-08-18 15:11:35 +020078};
79
Borislav Petkov549d0422009-07-24 13:51:42 +020080void amd_report_gart_errors(bool);
Borislav Petkovb0b07a22011-08-24 18:44:22 +020081void amd_register_ecc_decoder(void (*f)(int, struct mce *));
82void amd_unregister_ecc_decoder(void (*f)(int, struct mce *));
Borislav Petkov549d0422009-07-24 13:51:42 +020083
84#endif /* _EDAC_MCE_AMD_H */