at v6.19 133 lines 3.6 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef GHES_H 3#define GHES_H 4 5#include <acpi/apei.h> 6#include <acpi/hed.h> 7 8/* 9 * One struct ghes is created for each generic hardware error source. 10 * It provides the context for APEI hardware error timer/IRQ/SCI/NMI 11 * handler. 12 * 13 * estatus: memory buffer for error status block, allocated during 14 * HEST parsing. 15 */ 16#define GHES_EXITING 0x0002 17 18struct 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 unsigned long flags; 25 union { 26 struct list_head list; 27 struct timer_list timer; 28 unsigned int irq; 29 }; 30 struct device *dev; 31 struct list_head elist; 32}; 33 34struct ghes_estatus_node { 35 struct llist_node llnode; 36 struct acpi_hest_generic *generic; 37 struct ghes *ghes; 38}; 39 40struct ghes_estatus_cache { 41 u32 estatus_len; 42 atomic_t count; 43 struct acpi_hest_generic *generic; 44 unsigned long long time_in; 45 struct rcu_head rcu; 46}; 47 48enum { 49 GHES_SEV_NO = 0x0, 50 GHES_SEV_CORRECTED = 0x1, 51 GHES_SEV_RECOVERABLE = 0x2, 52 GHES_SEV_PANIC = 0x3, 53}; 54 55#ifdef CONFIG_ACPI_APEI_GHES 56/** 57 * ghes_register_vendor_record_notifier - register a notifier for vendor 58 * records that the kernel would otherwise ignore. 59 * @nb: pointer to the notifier_block structure of the event handler. 60 * 61 * return 0 : SUCCESS, non-zero : FAIL 62 */ 63int ghes_register_vendor_record_notifier(struct notifier_block *nb); 64 65/** 66 * ghes_unregister_vendor_record_notifier - unregister the previously 67 * registered vendor record notifier. 68 * @nb: pointer to the notifier_block structure of the vendor record handler. 69 */ 70void ghes_unregister_vendor_record_notifier(struct notifier_block *nb); 71 72struct list_head *ghes_get_devices(void); 73 74void ghes_estatus_pool_region_free(unsigned long addr, u32 size); 75#else 76static inline struct list_head *ghes_get_devices(void) { return NULL; } 77 78static inline void ghes_estatus_pool_region_free(unsigned long addr, u32 size) { return; } 79#endif 80 81int ghes_estatus_pool_init(unsigned int num_ghes); 82 83static inline int acpi_hest_get_version(struct acpi_hest_generic_data *gdata) 84{ 85 return gdata->revision >> 8; 86} 87 88static inline void *acpi_hest_get_payload(struct acpi_hest_generic_data *gdata) 89{ 90 if (acpi_hest_get_version(gdata) >= 3) 91 return (void *)(((struct acpi_hest_generic_data_v300 *)(gdata)) + 1); 92 93 return gdata + 1; 94} 95 96static inline int acpi_hest_get_error_length(struct acpi_hest_generic_data *gdata) 97{ 98 return ((struct acpi_hest_generic_data *)(gdata))->error_data_length; 99} 100 101static inline int acpi_hest_get_size(struct acpi_hest_generic_data *gdata) 102{ 103 if (acpi_hest_get_version(gdata) >= 3) 104 return sizeof(struct acpi_hest_generic_data_v300); 105 106 return sizeof(struct acpi_hest_generic_data); 107} 108 109static inline int acpi_hest_get_record_size(struct acpi_hest_generic_data *gdata) 110{ 111 return (acpi_hest_get_size(gdata) + acpi_hest_get_error_length(gdata)); 112} 113 114static inline void *acpi_hest_get_next(struct acpi_hest_generic_data *gdata) 115{ 116 return (void *)(gdata) + acpi_hest_get_record_size(gdata); 117} 118 119#define apei_estatus_for_each_section(estatus, section) \ 120 for (section = (struct acpi_hest_generic_data *)(estatus + 1); \ 121 (void *)section - (void *)(estatus + 1) < estatus->data_length; \ 122 section = acpi_hest_get_next(section)) 123 124#ifdef CONFIG_ACPI_APEI_SEA 125int ghes_notify_sea(void); 126#else 127static inline int ghes_notify_sea(void) { return -ENOENT; } 128#endif 129 130struct notifier_block; 131extern void ghes_register_report_chain(struct notifier_block *nb); 132extern void ghes_unregister_report_chain(struct notifier_block *nb); 133#endif /* GHES_H */