File Index
Files and directories
Sign in
FILE

ghes.h

File preview with syntax highlighting.

linux-6.19.14/include/acpi/ghes.h C
  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 int estatus_length;
 25	unsigned long flags;
 26	union {
 27		struct list_head list;
 28		struct timer_list timer;
 29		unsigned int irq;
 30	};
 31	struct device *dev;
 32	struct list_head elist;
 33};
 34
 35struct ghes_estatus_node {
 36	struct llist_node llnode;
 37	struct acpi_hest_generic *generic;
 38	struct ghes *ghes;
 39};
 40
 41struct ghes_estatus_cache {
 42	u32 estatus_len;
 43	atomic_t count;
 44	struct acpi_hest_generic *generic;
 45	unsigned long long time_in;
 46	struct rcu_head rcu;
 47};
 48
 49enum {
 50	GHES_SEV_NO = 0x0,
 51	GHES_SEV_CORRECTED = 0x1,
 52	GHES_SEV_RECOVERABLE = 0x2,
 53	GHES_SEV_PANIC = 0x3,
 54};
 55
 56#ifdef CONFIG_ACPI_APEI_GHES
 57/**
 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.
 61 *
 62 * return 0 : SUCCESS, non-zero : FAIL
 63 */
 64int ghes_register_vendor_record_notifier(struct notifier_block *nb);
 65
 66/**
 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.
 70 */
 71void ghes_unregister_vendor_record_notifier(struct notifier_block *nb);
 72
 73struct list_head *ghes_get_devices(void);
 74
 75void ghes_estatus_pool_region_free(unsigned long addr, u32 size);
 76#else
 77static inline struct list_head *ghes_get_devices(void) { return NULL; }
 78
 79static inline void ghes_estatus_pool_region_free(unsigned long addr, u32 size) { return; }
 80#endif
 81
 82int ghes_estatus_pool_init(unsigned int num_ghes);
 83
 84static inline int acpi_hest_get_version(struct acpi_hest_generic_data *gdata)
 85{
 86	return gdata->revision >> 8;
 87}
 88
 89static inline void *acpi_hest_get_payload(struct acpi_hest_generic_data *gdata)
 90{
 91	if (acpi_hest_get_version(gdata) >= 3)
 92		return (void *)(((struct acpi_hest_generic_data_v300 *)(gdata)) + 1);
 93
 94	return gdata + 1;
 95}
 96
 97static inline int acpi_hest_get_error_length(struct acpi_hest_generic_data *gdata)
 98{
 99	return ((struct acpi_hest_generic_data *)(gdata))->error_data_length;
100}
101
102static inline int acpi_hest_get_size(struct acpi_hest_generic_data *gdata)
103{
104	if (acpi_hest_get_version(gdata) >= 3)
105		return sizeof(struct acpi_hest_generic_data_v300);
106
107	return sizeof(struct acpi_hest_generic_data);
108}
109
110static inline int acpi_hest_get_record_size(struct acpi_hest_generic_data *gdata)
111{
112	return (acpi_hest_get_size(gdata) + acpi_hest_get_error_length(gdata));
113}
114
115static inline void *acpi_hest_get_next(struct acpi_hest_generic_data *gdata)
116{
117	return (void *)(gdata) + acpi_hest_get_record_size(gdata);
118}
119
120#define apei_estatus_for_each_section(estatus, section)			\
121	for (section = (struct acpi_hest_generic_data *)(estatus + 1);	\
122	     (void *)section - (void *)(estatus + 1) < estatus->data_length; \
123	     section = acpi_hest_get_next(section))
124
125#ifdef CONFIG_ACPI_APEI_SEA
126int ghes_notify_sea(void);
127#else
128static inline int ghes_notify_sea(void) { return -ENOENT; }
129#endif
130
131struct notifier_block;
132extern void ghes_register_report_chain(struct notifier_block *nb);
133extern void ghes_unregister_report_chain(struct notifier_block *nb);
134#endif /* GHES_H */
~/ Read-only file preview.