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