^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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * File: mca_drv.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Purpose: Define helpers for Generic MCA handling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Copyright (C) 2004 FUJITSU LIMITED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (C) 2004 Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Processor error section:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * +-sal_log_processor_info_t *info-------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * | sal_log_section_hdr_t header; |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * | ... |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * | sal_log_mod_error_info_t info[0]; |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * +-+----------------+-------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * | CACHE_CHECK | ^ num_cache_check v
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * +----------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * | TLB_CHECK | ^ num_tlb_check v
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * +----------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * | BUS_CHECK | ^ num_bus_check v
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * +----------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * | REG_FILE_CHECK | ^ num_reg_file_check v
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * +----------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * | MS_CHECK | ^ num_ms_check v
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * +-struct cpuid_info *id----------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * | regs[5]; |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * | reserved; |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * +-sal_processor_static_info_t *regs----------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * | valid; |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * | ... |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * | fr[128]; |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * +--------------------------------------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) /* peidx: index of processor error section */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) typedef struct peidx_table {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) sal_log_processor_info_t *info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct sal_cpuid_info *id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) sal_processor_static_info_t *regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) } peidx_table_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define peidx_head(p) (((p)->info))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define peidx_mid(p) (((p)->id))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define peidx_bottom(p) (((p)->regs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define peidx_psp(p) (&(peidx_head(p)->proc_state_parameter))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define peidx_field_valid(p) (&(peidx_head(p)->valid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define peidx_minstate_area(p) (&(peidx_bottom(p)->min_state_area))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define peidx_cache_check_num(p) (peidx_head(p)->valid.num_cache_check)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define peidx_tlb_check_num(p) (peidx_head(p)->valid.num_tlb_check)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define peidx_bus_check_num(p) (peidx_head(p)->valid.num_bus_check)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define peidx_reg_file_check_num(p) (peidx_head(p)->valid.num_reg_file_check)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define peidx_ms_check_num(p) (peidx_head(p)->valid.num_ms_check)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define peidx_cache_check_idx(p, n) (n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define peidx_tlb_check_idx(p, n) (peidx_cache_check_idx(p, peidx_cache_check_num(p)) + n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define peidx_bus_check_idx(p, n) (peidx_tlb_check_idx(p, peidx_tlb_check_num(p)) + n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define peidx_reg_file_check_idx(p, n) (peidx_bus_check_idx(p, peidx_bus_check_num(p)) + n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define peidx_ms_check_idx(p, n) (peidx_reg_file_check_idx(p, peidx_reg_file_check_num(p)) + n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define peidx_mod_error_info(p, name, n) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) ({ int __idx = peidx_##name##_idx(p, n); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) sal_log_mod_error_info_t *__ret = NULL; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) if (peidx_##name##_num(p) > n) /*BUG*/ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) __ret = &(peidx_head(p)->info[__idx]); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) __ret; })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #define peidx_cache_check(p, n) peidx_mod_error_info(p, cache_check, n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #define peidx_tlb_check(p, n) peidx_mod_error_info(p, tlb_check, n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #define peidx_bus_check(p, n) peidx_mod_error_info(p, bus_check, n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #define peidx_reg_file_check(p, n) peidx_mod_error_info(p, reg_file_check, n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #define peidx_ms_check(p, n) peidx_mod_error_info(p, ms_check, n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define peidx_check_info(proc, name, n) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) ({ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) sal_log_mod_error_info_t *__info = peidx_mod_error_info(proc, name, n);\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) u64 __temp = __info && __info->valid.check_info \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) ? __info->check_info : 0; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) __temp; })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /* slidx: index of SAL log error record */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) typedef struct slidx_list {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) sal_log_section_hdr_t *hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) } slidx_list_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) typedef struct slidx_table {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) sal_log_record_header_t *header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) int n_sections; /* # of section headers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct list_head proc_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) struct list_head mem_dev_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) struct list_head sel_dev_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) struct list_head pci_bus_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct list_head smbios_dev_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) struct list_head pci_comp_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct list_head plat_specific_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct list_head host_ctlr_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct list_head plat_bus_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct list_head unsupported; /* list of unsupported sections */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) } slidx_table_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #define slidx_foreach_entry(pos, head) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) list_for_each_entry(pos, head, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define slidx_first_entry(head) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) (((head)->next != (head)) ? list_entry((head)->next, typeof(slidx_list_t), list) : NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define slidx_count(slidx, sec) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) ({ int __count = 0; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) slidx_list_t *__pos; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) slidx_foreach_entry(__pos, &((slidx)->sec)) { __count++; }\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) __count; })
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) struct mca_table_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int start_addr; /* location-relative starting address of MCA recoverable range */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int end_addr; /* location-relative ending address of MCA recoverable range */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) extern const struct mca_table_entry *search_mca_tables (unsigned long addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) extern int mca_recover_range(unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) extern void ia64_mlogbuf_dump(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)