Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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