1 /* SPDX-License-Identifier: GPL-2.0 */
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
13 * estatus: memory buffer for error status block, allocated during
16 #define GHES_EXITING 0x0002
20 struct acpi_hest_generic
*generic
;
21 struct acpi_hest_generic_v2
*generic_v2
;
23 struct acpi_hest_generic_status
*estatus
;
26 struct list_head list
;
27 struct timer_list timer
;
32 struct ghes_estatus_node
{
33 struct llist_node llnode
;
34 struct acpi_hest_generic
*generic
;
38 struct callback_head task_work
;
41 struct ghes_estatus_cache
{
44 struct acpi_hest_generic
*generic
;
45 unsigned long long time_in
;
51 GHES_SEV_CORRECTED
= 0x1,
52 GHES_SEV_RECOVERABLE
= 0x2,
56 #ifdef CONFIG_ACPI_APEI_GHES
58 * ghes_register_vendor_record_notifier - register a notifier for vendor
59 * records that the kernel would otherwise ignore.
60 * @nb: pointer to the notifier_block structure of the event handler.
62 * return 0 : SUCCESS, non-zero : FAIL
64 int ghes_register_vendor_record_notifier(struct notifier_block
*nb
);
67 * ghes_unregister_vendor_record_notifier - unregister the previously
68 * registered vendor record notifier.
69 * @nb: pointer to the notifier_block structure of the vendor record handler.
71 void ghes_unregister_vendor_record_notifier(struct notifier_block
*nb
);
74 int ghes_estatus_pool_init(int num_ghes
);
76 /* From drivers/edac/ghes_edac.c */
78 #ifdef CONFIG_EDAC_GHES
79 void ghes_edac_report_mem_error(int sev
, struct cper_sec_mem_err
*mem_err
);
81 int ghes_edac_register(struct ghes
*ghes
, struct device
*dev
);
83 void ghes_edac_unregister(struct ghes
*ghes
);
86 static inline void ghes_edac_report_mem_error(int sev
,
87 struct cper_sec_mem_err
*mem_err
)
91 static inline int ghes_edac_register(struct ghes
*ghes
, struct device
*dev
)
96 static inline void ghes_edac_unregister(struct ghes
*ghes
)
101 static inline int acpi_hest_get_version(struct acpi_hest_generic_data
*gdata
)
103 return gdata
->revision
>> 8;
106 static inline void *acpi_hest_get_payload(struct acpi_hest_generic_data
*gdata
)
108 if (acpi_hest_get_version(gdata
) >= 3)
109 return (void *)(((struct acpi_hest_generic_data_v300
*)(gdata
)) + 1);
114 static inline int acpi_hest_get_error_length(struct acpi_hest_generic_data
*gdata
)
116 return ((struct acpi_hest_generic_data
*)(gdata
))->error_data_length
;
119 static inline int acpi_hest_get_size(struct acpi_hest_generic_data
*gdata
)
121 if (acpi_hest_get_version(gdata
) >= 3)
122 return sizeof(struct acpi_hest_generic_data_v300
);
124 return sizeof(struct acpi_hest_generic_data
);
127 static inline int acpi_hest_get_record_size(struct acpi_hest_generic_data
*gdata
)
129 return (acpi_hest_get_size(gdata
) + acpi_hest_get_error_length(gdata
));
132 static inline void *acpi_hest_get_next(struct acpi_hest_generic_data
*gdata
)
134 return (void *)(gdata
) + acpi_hest_get_record_size(gdata
);
137 #define apei_estatus_for_each_section(estatus, section) \
138 for (section = (struct acpi_hest_generic_data *)(estatus + 1); \
139 (void *)section - (void *)(estatus + 1) < estatus->data_length; \
140 section = acpi_hest_get_next(section))
142 #ifdef CONFIG_ACPI_APEI_SEA
143 int ghes_notify_sea(void);
145 static inline int ghes_notify_sea(void) { return -ENOENT
; }