1 /* SPDX-License-Identifier: GPL-2.0 */ << 2 #ifndef GHES_H 1 #ifndef GHES_H 3 #define GHES_H 2 #define GHES_H 4 3 5 #include <acpi/apei.h> 4 #include <acpi/apei.h> 6 #include <acpi/hed.h> 5 #include <acpi/hed.h> 7 6 8 /* 7 /* 9 * One struct ghes is created for each generic 8 * One struct ghes is created for each generic hardware error source. 10 * It provides the context for APEI hardware e 9 * It provides the context for APEI hardware error timer/IRQ/SCI/NMI 11 * handler. 10 * handler. 12 * 11 * 13 * estatus: memory buffer for error status blo 12 * estatus: memory buffer for error status block, allocated during 14 * HEST parsing. 13 * HEST parsing. 15 */ 14 */ >> 15 #define GHES_TO_CLEAR 0x0001 16 #define GHES_EXITING 0x0002 16 #define GHES_EXITING 0x0002 17 17 18 struct ghes { 18 struct ghes { 19 union { 19 union { 20 struct acpi_hest_generic *gene 20 struct acpi_hest_generic *generic; 21 struct acpi_hest_generic_v2 *g 21 struct acpi_hest_generic_v2 *generic_v2; 22 }; 22 }; 23 struct acpi_hest_generic_status *estat 23 struct acpi_hest_generic_status *estatus; >> 24 u64 buffer_paddr; 24 unsigned long flags; 25 unsigned long flags; 25 union { 26 union { 26 struct list_head list; 27 struct list_head list; 27 struct timer_list timer; 28 struct timer_list timer; 28 unsigned int irq; 29 unsigned int irq; 29 }; 30 }; 30 struct device *dev; << 31 struct list_head elist; << 32 }; 31 }; 33 32 34 struct ghes_estatus_node { 33 struct ghes_estatus_node { 35 struct llist_node llnode; 34 struct llist_node llnode; 36 struct acpi_hest_generic *generic; 35 struct acpi_hest_generic *generic; 37 struct ghes *ghes; 36 struct ghes *ghes; 38 << 39 int task_work_cpu; << 40 struct callback_head task_work; << 41 }; 37 }; 42 38 43 struct ghes_estatus_cache { 39 struct ghes_estatus_cache { 44 u32 estatus_len; 40 u32 estatus_len; 45 atomic_t count; 41 atomic_t count; 46 struct acpi_hest_generic *generic; 42 struct acpi_hest_generic *generic; 47 unsigned long long time_in; 43 unsigned long long time_in; 48 struct rcu_head rcu; 44 struct rcu_head rcu; 49 }; 45 }; 50 46 51 enum { 47 enum { 52 GHES_SEV_NO = 0x0, 48 GHES_SEV_NO = 0x0, 53 GHES_SEV_CORRECTED = 0x1, 49 GHES_SEV_CORRECTED = 0x1, 54 GHES_SEV_RECOVERABLE = 0x2, 50 GHES_SEV_RECOVERABLE = 0x2, 55 GHES_SEV_PANIC = 0x3, 51 GHES_SEV_PANIC = 0x3, 56 }; 52 }; 57 53 58 #ifdef CONFIG_ACPI_APEI_GHES !! 54 /* From drivers/edac/ghes_edac.c */ 59 /** << 60 * ghes_register_vendor_record_notifier - regi << 61 * records that the kernel would otherwise ign << 62 * @nb: pointer to the notifier_block structur << 63 * << 64 * return 0 : SUCCESS, non-zero : FAIL << 65 */ << 66 int ghes_register_vendor_record_notifier(struc << 67 55 68 /** !! 56 #ifdef CONFIG_EDAC_GHES 69 * ghes_unregister_vendor_record_notifier - un !! 57 void ghes_edac_report_mem_error(struct ghes *ghes, int sev, 70 * registered vendor record notifier. !! 58 struct cper_sec_mem_err *mem_err); 71 * @nb: pointer to the notifier_block structur << 72 */ << 73 void ghes_unregister_vendor_record_notifier(st << 74 59 75 struct list_head *ghes_get_devices(void); !! 60 int ghes_edac_register(struct ghes *ghes, struct device *dev); >> 61 >> 62 void ghes_edac_unregister(struct ghes *ghes); 76 63 77 void ghes_estatus_pool_region_free(unsigned lo << 78 #else 64 #else 79 static inline struct list_head *ghes_get_devic !! 65 static inline void ghes_edac_report_mem_error(struct ghes *ghes, int sev, >> 66 struct cper_sec_mem_err *mem_err) >> 67 { >> 68 } 80 69 81 static inline void ghes_estatus_pool_region_fr !! 70 static inline int ghes_edac_register(struct ghes *ghes, struct device *dev) 82 #endif !! 71 { >> 72 return 0; >> 73 } 83 74 84 int ghes_estatus_pool_init(unsigned int num_gh !! 75 static inline void ghes_edac_unregister(struct ghes *ghes) >> 76 { >> 77 } >> 78 #endif 85 79 86 static inline int acpi_hest_get_version(struct 80 static inline int acpi_hest_get_version(struct acpi_hest_generic_data *gdata) 87 { 81 { 88 return gdata->revision >> 8; 82 return gdata->revision >> 8; 89 } 83 } 90 84 91 static inline void *acpi_hest_get_payload(stru 85 static inline void *acpi_hest_get_payload(struct acpi_hest_generic_data *gdata) 92 { 86 { 93 if (acpi_hest_get_version(gdata) >= 3) 87 if (acpi_hest_get_version(gdata) >= 3) 94 return (void *)(((struct acpi_ 88 return (void *)(((struct acpi_hest_generic_data_v300 *)(gdata)) + 1); 95 89 96 return gdata + 1; 90 return gdata + 1; 97 } 91 } 98 92 99 static inline int acpi_hest_get_error_length(s 93 static inline int acpi_hest_get_error_length(struct acpi_hest_generic_data *gdata) 100 { 94 { 101 return ((struct acpi_hest_generic_data 95 return ((struct acpi_hest_generic_data *)(gdata))->error_data_length; 102 } 96 } 103 97 104 static inline int acpi_hest_get_size(struct ac 98 static inline int acpi_hest_get_size(struct acpi_hest_generic_data *gdata) 105 { 99 { 106 if (acpi_hest_get_version(gdata) >= 3) 100 if (acpi_hest_get_version(gdata) >= 3) 107 return sizeof(struct acpi_hest 101 return sizeof(struct acpi_hest_generic_data_v300); 108 102 109 return sizeof(struct acpi_hest_generic 103 return sizeof(struct acpi_hest_generic_data); 110 } 104 } 111 105 112 static inline int acpi_hest_get_record_size(st 106 static inline int acpi_hest_get_record_size(struct acpi_hest_generic_data *gdata) 113 { 107 { 114 return (acpi_hest_get_size(gdata) + ac 108 return (acpi_hest_get_size(gdata) + acpi_hest_get_error_length(gdata)); 115 } 109 } 116 110 117 static inline void *acpi_hest_get_next(struct 111 static inline void *acpi_hest_get_next(struct acpi_hest_generic_data *gdata) 118 { 112 { 119 return (void *)(gdata) + acpi_hest_get 113 return (void *)(gdata) + acpi_hest_get_record_size(gdata); 120 } 114 } 121 115 122 #define apei_estatus_for_each_section(estatus, << 123 for (section = (struct acpi_hest_gener << 124 (void *)section - (void *)(estatu << 125 section = acpi_hest_get_next(sect << 126 << 127 #ifdef CONFIG_ACPI_APEI_SEA << 128 int ghes_notify_sea(void); 116 int ghes_notify_sea(void); 129 #else << 130 static inline int ghes_notify_sea(void) { retu << 131 #endif << 132 117 133 struct notifier_block; << 134 extern void ghes_register_report_chain(struct << 135 extern void ghes_unregister_report_chain(struc << 136 #endif /* GHES_H */ 118 #endif /* GHES_H */ 137 119
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.