]> git.karo-electronics.de Git - karo-tx-linux.git/blob - include/acpi/ghes.h
Merge tag 'char-misc-4.13-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/gregk...
[karo-tx-linux.git] / include / acpi / ghes.h
1 #ifndef GHES_H
2 #define GHES_H
3
4 #include <acpi/apei.h>
5 #include <acpi/hed.h>
6
7 /*
8  * One struct ghes is created for each generic hardware error source.
9  * It provides the context for APEI hardware error timer/IRQ/SCI/NMI
10  * handler.
11  *
12  * estatus: memory buffer for error status block, allocated during
13  * HEST parsing.
14  */
15 #define GHES_TO_CLEAR           0x0001
16 #define GHES_EXITING            0x0002
17
18 struct ghes {
19         union {
20                 struct acpi_hest_generic *generic;
21                 struct acpi_hest_generic_v2 *generic_v2;
22         };
23         struct acpi_hest_generic_status *estatus;
24         u64 buffer_paddr;
25         unsigned long flags;
26         union {
27                 struct list_head list;
28                 struct timer_list timer;
29                 unsigned int irq;
30         };
31 };
32
33 struct ghes_estatus_node {
34         struct llist_node llnode;
35         struct acpi_hest_generic *generic;
36         struct ghes *ghes;
37 };
38
39 struct ghes_estatus_cache {
40         u32 estatus_len;
41         atomic_t count;
42         struct acpi_hest_generic *generic;
43         unsigned long long time_in;
44         struct rcu_head rcu;
45 };
46
47 enum {
48         GHES_SEV_NO = 0x0,
49         GHES_SEV_CORRECTED = 0x1,
50         GHES_SEV_RECOVERABLE = 0x2,
51         GHES_SEV_PANIC = 0x3,
52 };
53
54 /* From drivers/edac/ghes_edac.c */
55
56 #ifdef CONFIG_EDAC_GHES
57 void ghes_edac_report_mem_error(struct ghes *ghes, int sev,
58                                 struct cper_sec_mem_err *mem_err);
59
60 int ghes_edac_register(struct ghes *ghes, struct device *dev);
61
62 void ghes_edac_unregister(struct ghes *ghes);
63
64 #else
65 static inline void ghes_edac_report_mem_error(struct ghes *ghes, int sev,
66                                        struct cper_sec_mem_err *mem_err)
67 {
68 }
69
70 static inline int ghes_edac_register(struct ghes *ghes, struct device *dev)
71 {
72         return 0;
73 }
74
75 static inline void ghes_edac_unregister(struct ghes *ghes)
76 {
77 }
78 #endif
79
80 static inline int acpi_hest_get_version(struct acpi_hest_generic_data *gdata)
81 {
82         return gdata->revision >> 8;
83 }
84
85 static inline void *acpi_hest_get_payload(struct acpi_hest_generic_data *gdata)
86 {
87         if (acpi_hest_get_version(gdata) >= 3)
88                 return (void *)(((struct acpi_hest_generic_data_v300 *)(gdata)) + 1);
89
90         return gdata + 1;
91 }
92
93 static inline int acpi_hest_get_error_length(struct acpi_hest_generic_data *gdata)
94 {
95         return ((struct acpi_hest_generic_data *)(gdata))->error_data_length;
96 }
97
98 static inline int acpi_hest_get_size(struct acpi_hest_generic_data *gdata)
99 {
100         if (acpi_hest_get_version(gdata) >= 3)
101                 return sizeof(struct acpi_hest_generic_data_v300);
102
103         return sizeof(struct acpi_hest_generic_data);
104 }
105
106 static inline int acpi_hest_get_record_size(struct acpi_hest_generic_data *gdata)
107 {
108         return (acpi_hest_get_size(gdata) + acpi_hest_get_error_length(gdata));
109 }
110
111 static inline void *acpi_hest_get_next(struct acpi_hest_generic_data *gdata)
112 {
113         return (void *)(gdata) + acpi_hest_get_record_size(gdata);
114 }
115
116 int ghes_notify_sea(void);
117
118 #endif /* GHES_H */