^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * APEI Hardware Error Souce Table support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * HEST describes error sources in detail; communicates operational
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * parameters (i.e. severity levels, masking bits, and threshold
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * values) to Linux as necessary. It also allows the BIOS to report
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * non-standard error sources to Linux (for example, chipset-specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * error registers).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * For more information about HEST, please refer to ACPI Specification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * version 4.0, section 17.3.2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Copyright 2009 Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Author: Huang Ying <ying.huang@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/kdebug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/highmem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <acpi/apei.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <acpi/ghes.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include "apei-internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define HEST_PFX "HEST: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) int hest_disable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) EXPORT_SYMBOL_GPL(hest_disable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) /* HEST table parsing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static struct acpi_table_hest *__read_mostly hest_tab;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static const int hest_esrc_len_tab[ACPI_HEST_TYPE_RESERVED] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) [ACPI_HEST_TYPE_IA32_CHECK] = -1, /* need further calculation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) [ACPI_HEST_TYPE_IA32_CORRECTED_CHECK] = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) [ACPI_HEST_TYPE_IA32_NMI] = sizeof(struct acpi_hest_ia_nmi),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) [ACPI_HEST_TYPE_AER_ROOT_PORT] = sizeof(struct acpi_hest_aer_root),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) [ACPI_HEST_TYPE_AER_ENDPOINT] = sizeof(struct acpi_hest_aer),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) [ACPI_HEST_TYPE_AER_BRIDGE] = sizeof(struct acpi_hest_aer_bridge),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) [ACPI_HEST_TYPE_GENERIC_ERROR] = sizeof(struct acpi_hest_generic),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) [ACPI_HEST_TYPE_GENERIC_ERROR_V2] = sizeof(struct acpi_hest_generic_v2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) [ACPI_HEST_TYPE_IA32_DEFERRED_CHECK] = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) static int hest_esrc_len(struct acpi_hest_header *hest_hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) u16 hest_type = hest_hdr->type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) if (hest_type >= ACPI_HEST_TYPE_RESERVED)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) len = hest_esrc_len_tab[hest_type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) if (hest_type == ACPI_HEST_TYPE_IA32_CORRECTED_CHECK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct acpi_hest_ia_corrected *cmc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) cmc = (struct acpi_hest_ia_corrected *)hest_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) len = sizeof(*cmc) + cmc->num_hardware_banks *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) sizeof(struct acpi_hest_ia_error_bank);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) } else if (hest_type == ACPI_HEST_TYPE_IA32_CHECK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct acpi_hest_ia_machine_check *mc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) mc = (struct acpi_hest_ia_machine_check *)hest_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) len = sizeof(*mc) + mc->num_hardware_banks *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) sizeof(struct acpi_hest_ia_error_bank);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) } else if (hest_type == ACPI_HEST_TYPE_IA32_DEFERRED_CHECK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) struct acpi_hest_ia_deferred_check *mc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) mc = (struct acpi_hest_ia_deferred_check *)hest_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) len = sizeof(*mc) + mc->num_hardware_banks *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) sizeof(struct acpi_hest_ia_error_bank);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) BUG_ON(len == -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) int apei_hest_parse(apei_hest_func_t func, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct acpi_hest_header *hest_hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) int i, rc, len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) if (hest_disable || !hest_tab)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) hest_hdr = (struct acpi_hest_header *)(hest_tab + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) for (i = 0; i < hest_tab->error_source_count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) len = hest_esrc_len(hest_hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) if (!len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) pr_warn(FW_WARN HEST_PFX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) "Unknown or unused hardware error source "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) "type: %d for hardware error source: %d.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) hest_hdr->type, hest_hdr->source_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) if ((void *)hest_hdr + len >
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) (void *)hest_tab + hest_tab->header.length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) pr_warn(FW_BUG HEST_PFX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) "Table contents overflow for hardware error source: %d.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) hest_hdr->source_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) rc = func(hest_hdr, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) hest_hdr = (void *)hest_hdr + len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) EXPORT_SYMBOL_GPL(apei_hest_parse);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) * Check if firmware advertises firmware first mode. We need FF bit to be set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * along with a set of MC banks which work in FF mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) static int __init hest_parse_cmc(struct acpi_hest_header *hest_hdr, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) if (hest_hdr->type != ACPI_HEST_TYPE_IA32_CORRECTED_CHECK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) if (!acpi_disable_cmcff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) return !arch_apei_enable_cmcff(hest_hdr, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) struct ghes_arr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) struct platform_device **ghes_devs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) unsigned int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static int __init hest_parse_ghes_count(struct acpi_hest_header *hest_hdr, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) int *count = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) if (hest_hdr->type == ACPI_HEST_TYPE_GENERIC_ERROR ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) hest_hdr->type == ACPI_HEST_TYPE_GENERIC_ERROR_V2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) (*count)++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) static int __init hest_parse_ghes(struct acpi_hest_header *hest_hdr, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) struct platform_device *ghes_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) struct ghes_arr *ghes_arr = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) int rc, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) if (hest_hdr->type != ACPI_HEST_TYPE_GENERIC_ERROR &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) hest_hdr->type != ACPI_HEST_TYPE_GENERIC_ERROR_V2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (!((struct acpi_hest_generic *)hest_hdr)->enabled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) for (i = 0; i < ghes_arr->count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) struct acpi_hest_header *hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) ghes_dev = ghes_arr->ghes_devs[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) hdr = *(struct acpi_hest_header **)ghes_dev->dev.platform_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) if (hdr->source_id == hest_hdr->source_id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) pr_warn(FW_WARN HEST_PFX "Duplicated hardware error source ID: %d.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) hdr->source_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) ghes_dev = platform_device_alloc("GHES", hest_hdr->source_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) if (!ghes_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) rc = platform_device_add_data(ghes_dev, &hest_hdr, sizeof(void *));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) rc = platform_device_add(ghes_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) ghes_arr->ghes_devs[ghes_arr->count++] = ghes_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) platform_device_put(ghes_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) static int __init hest_ghes_dev_register(unsigned int ghes_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) int rc, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) struct ghes_arr ghes_arr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) ghes_arr.count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) ghes_arr.ghes_devs = kmalloc_array(ghes_count, sizeof(void *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if (!ghes_arr.ghes_devs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) rc = apei_hest_parse(hest_parse_ghes, &ghes_arr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) rc = ghes_estatus_pool_init(ghes_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) kfree(ghes_arr.ghes_devs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) for (i = 0; i < ghes_arr.count; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) platform_device_unregister(ghes_arr.ghes_devs[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) static int __init setup_hest_disable(char *str)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) hest_disable = HEST_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) __setup("hest_disable", setup_hest_disable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) void __init acpi_hest_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) acpi_status status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) unsigned int ghes_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) if (hest_disable) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) pr_info(HEST_PFX "Table parsing disabled.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) status = acpi_get_table(ACPI_SIG_HEST, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) (struct acpi_table_header **)&hest_tab);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) if (status == AE_NOT_FOUND) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) hest_disable = HEST_NOT_FOUND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) } else if (ACPI_FAILURE(status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) const char *msg = acpi_format_exception(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) pr_err(HEST_PFX "Failed to get table, %s\n", msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) hest_disable = HEST_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) rc = apei_hest_parse(hest_parse_cmc, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) if (!ghes_disable) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) rc = apei_hest_parse(hest_parse_ghes_count, &ghes_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) if (ghes_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) rc = hest_ghes_dev_register(ghes_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) goto err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) pr_info(HEST_PFX "Table parsing has been initialized.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) hest_disable = HEST_DISABLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) acpi_put_table((struct acpi_table_header *)hest_tab);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) }