Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI, CPER: Update cper info

We have a lot of confusing names of functions and data structures in
amongs the the error reporting code. In particular the "apei" prefix
has been applied to many objects that are not part of APEI. Since we
will be using these routines for extended error log reporting it will
be clearer if we fix up the names first.

Signed-off-by: Chen, Gong <gong.chen@linux.intel.com>
Acked-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>

authored by

Chen, Gong and committed by
Tony Luck
88f074f4 833ba4b1

+71 -71
+6 -6
drivers/acpi/apei/apei-internal.h
··· 122 122 struct dentry *apei_get_debugfs_dir(void); 123 123 124 124 #define apei_estatus_for_each_section(estatus, section) \ 125 - for (section = (struct acpi_hest_generic_data *)(estatus + 1); \ 125 + for (section = (struct acpi_generic_data *)(estatus + 1); \ 126 126 (void *)section - (void *)estatus < estatus->data_length; \ 127 127 section = (void *)(section+1) + section->error_data_length) 128 128 129 - static inline u32 apei_estatus_len(struct acpi_hest_generic_status *estatus) 129 + static inline u32 cper_estatus_len(struct acpi_generic_status *estatus) 130 130 { 131 131 if (estatus->raw_data_length) 132 132 return estatus->raw_data_offset + \ ··· 135 135 return sizeof(*estatus) + estatus->data_length; 136 136 } 137 137 138 - void apei_estatus_print(const char *pfx, 139 - const struct acpi_hest_generic_status *estatus); 140 - int apei_estatus_check_header(const struct acpi_hest_generic_status *estatus); 141 - int apei_estatus_check(const struct acpi_hest_generic_status *estatus); 138 + void cper_estatus_print(const char *pfx, 139 + const struct acpi_generic_status *estatus); 140 + int cper_estatus_check_header(const struct acpi_generic_status *estatus); 141 + int cper_estatus_check(const struct acpi_generic_status *estatus); 142 142 143 143 int apei_osc_setup(void); 144 144 #endif
+29 -29
drivers/acpi/apei/cper.c
··· 5 5 * Author: Huang Ying <ying.huang@intel.com> 6 6 * 7 7 * CPER is the format used to describe platform hardware error by 8 - * various APEI tables, such as ERST, BERT and HEST etc. 8 + * various tables, such as ERST, BERT and HEST etc. 9 9 * 10 10 * For more information about CPER, please refer to Appendix N of UEFI 11 11 * Specification version 2.3. ··· 73 73 * printed, with @pfx is printed at the beginning of each line. 74 74 */ 75 75 void cper_print_bits(const char *pfx, unsigned int bits, 76 - const char *strs[], unsigned int strs_size) 76 + const char * const strs[], unsigned int strs_size) 77 77 { 78 78 int i, len = 0; 79 79 const char *str; ··· 98 98 printk("%s\n", buf); 99 99 } 100 100 101 - static const char *cper_proc_type_strs[] = { 101 + static const char * const cper_proc_type_strs[] = { 102 102 "IA32/X64", 103 103 "IA64", 104 104 }; 105 105 106 - static const char *cper_proc_isa_strs[] = { 106 + static const char * const cper_proc_isa_strs[] = { 107 107 "IA32", 108 108 "IA64", 109 109 "X64", 110 110 }; 111 111 112 - static const char *cper_proc_error_type_strs[] = { 112 + static const char * const cper_proc_error_type_strs[] = { 113 113 "cache error", 114 114 "TLB error", 115 115 "bus error", 116 116 "micro-architectural error", 117 117 }; 118 118 119 - static const char *cper_proc_op_strs[] = { 119 + static const char * const cper_proc_op_strs[] = { 120 120 "unknown or generic", 121 121 "data read", 122 122 "data write", 123 123 "instruction execution", 124 124 }; 125 125 126 - static const char *cper_proc_flag_strs[] = { 126 + static const char * const cper_proc_flag_strs[] = { 127 127 "restartable", 128 128 "precise IP", 129 129 "overflow", ··· 248 248 }; 249 249 250 250 static void cper_print_pcie(const char *pfx, const struct cper_sec_pcie *pcie, 251 - const struct acpi_hest_generic_data *gdata) 251 + const struct acpi_generic_data *gdata) 252 252 { 253 253 if (pcie->validation_bits & CPER_PCIE_VALID_PORT_TYPE) 254 254 printk("%s""port_type: %d, %s\n", pfx, pcie->port_type, ··· 283 283 pfx, pcie->bridge.secondary_status, pcie->bridge.control); 284 284 } 285 285 286 - static const char *apei_estatus_section_flag_strs[] = { 286 + static const char * const cper_estatus_section_flag_strs[] = { 287 287 "primary", 288 288 "containment warning", 289 289 "reset", 290 - "threshold exceeded", 290 + "error threshold exceeded", 291 291 "resource not accessible", 292 292 "latent error", 293 293 }; 294 294 295 - static void apei_estatus_print_section( 296 - const char *pfx, const struct acpi_hest_generic_data *gdata, int sec_no) 295 + static void cper_estatus_print_section( 296 + const char *pfx, const struct acpi_generic_data *gdata, int sec_no) 297 297 { 298 298 uuid_le *sec_type = (uuid_le *)gdata->section_type; 299 299 __u16 severity; ··· 302 302 printk("%s""section: %d, severity: %d, %s\n", pfx, sec_no, severity, 303 303 cper_severity_str(severity)); 304 304 printk("%s""flags: 0x%02x\n", pfx, gdata->flags); 305 - cper_print_bits(pfx, gdata->flags, apei_estatus_section_flag_strs, 306 - ARRAY_SIZE(apei_estatus_section_flag_strs)); 305 + cper_print_bits(pfx, gdata->flags, cper_estatus_section_flag_strs, 306 + ARRAY_SIZE(cper_estatus_section_flag_strs)); 307 307 if (gdata->validation_bits & CPER_SEC_VALID_FRU_ID) 308 308 printk("%s""fru_id: %pUl\n", pfx, (uuid_le *)gdata->fru_id); 309 309 if (gdata->validation_bits & CPER_SEC_VALID_FRU_TEXT) ··· 339 339 pr_err(FW_WARN "error section length is too small\n"); 340 340 } 341 341 342 - void apei_estatus_print(const char *pfx, 343 - const struct acpi_hest_generic_status *estatus) 342 + void cper_estatus_print(const char *pfx, 343 + const struct acpi_generic_status *estatus) 344 344 { 345 - struct acpi_hest_generic_data *gdata; 345 + struct acpi_generic_data *gdata; 346 346 unsigned int data_len, gedata_len; 347 347 int sec_no = 0; 348 348 __u16 severity; 349 349 350 - printk("%s""APEI generic hardware error status\n", pfx); 350 + printk("%s""Generic Hardware Error Status\n", pfx); 351 351 severity = estatus->error_severity; 352 352 printk("%s""severity: %d, %s\n", pfx, severity, 353 353 cper_severity_str(severity)); 354 354 data_len = estatus->data_length; 355 - gdata = (struct acpi_hest_generic_data *)(estatus + 1); 355 + gdata = (struct acpi_generic_data *)(estatus + 1); 356 356 while (data_len >= sizeof(*gdata)) { 357 357 gedata_len = gdata->error_data_length; 358 - apei_estatus_print_section(pfx, gdata, sec_no); 358 + cper_estatus_print_section(pfx, gdata, sec_no); 359 359 data_len -= gedata_len + sizeof(*gdata); 360 360 gdata = (void *)(gdata + 1) + gedata_len; 361 361 sec_no++; 362 362 } 363 363 } 364 - EXPORT_SYMBOL_GPL(apei_estatus_print); 364 + EXPORT_SYMBOL_GPL(cper_estatus_print); 365 365 366 - int apei_estatus_check_header(const struct acpi_hest_generic_status *estatus) 366 + int cper_estatus_check_header(const struct acpi_generic_status *estatus) 367 367 { 368 368 if (estatus->data_length && 369 - estatus->data_length < sizeof(struct acpi_hest_generic_data)) 369 + estatus->data_length < sizeof(struct acpi_generic_data)) 370 370 return -EINVAL; 371 371 if (estatus->raw_data_length && 372 372 estatus->raw_data_offset < sizeof(*estatus) + estatus->data_length) ··· 374 374 375 375 return 0; 376 376 } 377 - EXPORT_SYMBOL_GPL(apei_estatus_check_header); 377 + EXPORT_SYMBOL_GPL(cper_estatus_check_header); 378 378 379 - int apei_estatus_check(const struct acpi_hest_generic_status *estatus) 379 + int cper_estatus_check(const struct acpi_generic_status *estatus) 380 380 { 381 - struct acpi_hest_generic_data *gdata; 381 + struct acpi_generic_data *gdata; 382 382 unsigned int data_len, gedata_len; 383 383 int rc; 384 384 385 - rc = apei_estatus_check_header(estatus); 385 + rc = cper_estatus_check_header(estatus); 386 386 if (rc) 387 387 return rc; 388 388 data_len = estatus->data_length; 389 - gdata = (struct acpi_hest_generic_data *)(estatus + 1); 389 + gdata = (struct acpi_generic_data *)(estatus + 1); 390 390 while (data_len >= sizeof(*gdata)) { 391 391 gedata_len = gdata->error_data_length; 392 392 if (gedata_len > data_len - sizeof(*gdata)) ··· 399 399 400 400 return 0; 401 401 } 402 - EXPORT_SYMBOL_GPL(apei_estatus_check); 402 + EXPORT_SYMBOL_GPL(cper_estatus_check);
+27 -27
drivers/acpi/apei/ghes.c
··· 75 75 #define GHES_ESTATUS_CACHE_LEN(estatus_len) \ 76 76 (sizeof(struct ghes_estatus_cache) + (estatus_len)) 77 77 #define GHES_ESTATUS_FROM_CACHE(estatus_cache) \ 78 - ((struct acpi_hest_generic_status *) \ 78 + ((struct acpi_generic_status *) \ 79 79 ((struct ghes_estatus_cache *)(estatus_cache) + 1)) 80 80 81 81 #define GHES_ESTATUS_NODE_LEN(estatus_len) \ 82 82 (sizeof(struct ghes_estatus_node) + (estatus_len)) 83 - #define GHES_ESTATUS_FROM_NODE(estatus_node) \ 84 - ((struct acpi_hest_generic_status *) \ 83 + #define GHES_ESTATUS_FROM_NODE(estatus_node) \ 84 + ((struct acpi_generic_status *) \ 85 85 ((struct ghes_estatus_node *)(estatus_node) + 1)) 86 86 87 87 bool ghes_disable; ··· 378 378 ghes->flags |= GHES_TO_CLEAR; 379 379 380 380 rc = -EIO; 381 - len = apei_estatus_len(ghes->estatus); 381 + len = cper_estatus_len(ghes->estatus); 382 382 if (len < sizeof(*ghes->estatus)) 383 383 goto err_read_block; 384 384 if (len > ghes->generic->error_block_length) 385 385 goto err_read_block; 386 - if (apei_estatus_check_header(ghes->estatus)) 386 + if (cper_estatus_check_header(ghes->estatus)) 387 387 goto err_read_block; 388 388 ghes_copy_tofrom_phys(ghes->estatus + 1, 389 389 buf_paddr + sizeof(*ghes->estatus), 390 390 len - sizeof(*ghes->estatus), 1); 391 - if (apei_estatus_check(ghes->estatus)) 391 + if (cper_estatus_check(ghes->estatus)) 392 392 goto err_read_block; 393 393 rc = 0; 394 394 ··· 409 409 ghes->flags &= ~GHES_TO_CLEAR; 410 410 } 411 411 412 - static void ghes_handle_memory_failure(struct acpi_hest_generic_data *gdata, int sev) 412 + static void ghes_handle_memory_failure(struct acpi_generic_data *gdata, int sev) 413 413 { 414 414 #ifdef CONFIG_ACPI_APEI_MEMORY_FAILURE 415 415 unsigned long pfn; ··· 438 438 } 439 439 440 440 static void ghes_do_proc(struct ghes *ghes, 441 - const struct acpi_hest_generic_status *estatus) 441 + const struct acpi_generic_status *estatus) 442 442 { 443 443 int sev, sec_sev; 444 - struct acpi_hest_generic_data *gdata; 444 + struct acpi_generic_data *gdata; 445 445 446 446 sev = ghes_severity(estatus->error_severity); 447 447 apei_estatus_for_each_section(estatus, gdata) { ··· 496 496 497 497 static void __ghes_print_estatus(const char *pfx, 498 498 const struct acpi_hest_generic *generic, 499 - const struct acpi_hest_generic_status *estatus) 499 + const struct acpi_generic_status *estatus) 500 500 { 501 501 static atomic_t seqno; 502 502 unsigned int curr_seqno; ··· 513 513 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno); 514 514 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n", 515 515 pfx_seq, generic->header.source_id); 516 - apei_estatus_print(pfx_seq, estatus); 516 + cper_estatus_print(pfx_seq, estatus); 517 517 } 518 518 519 519 static int ghes_print_estatus(const char *pfx, 520 520 const struct acpi_hest_generic *generic, 521 - const struct acpi_hest_generic_status *estatus) 521 + const struct acpi_generic_status *estatus) 522 522 { 523 523 /* Not more than 2 messages every 5 seconds */ 524 524 static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2); ··· 540 540 * GHES error status reporting throttle, to report more kinds of 541 541 * errors, instead of just most frequently occurred errors. 542 542 */ 543 - static int ghes_estatus_cached(struct acpi_hest_generic_status *estatus) 543 + static int ghes_estatus_cached(struct acpi_generic_status *estatus) 544 544 { 545 545 u32 len; 546 546 int i, cached = 0; 547 547 unsigned long long now; 548 548 struct ghes_estatus_cache *cache; 549 - struct acpi_hest_generic_status *cache_estatus; 549 + struct acpi_generic_status *cache_estatus; 550 550 551 - len = apei_estatus_len(estatus); 551 + len = cper_estatus_len(estatus); 552 552 rcu_read_lock(); 553 553 for (i = 0; i < GHES_ESTATUS_CACHES_SIZE; i++) { 554 554 cache = rcu_dereference(ghes_estatus_caches[i]); ··· 571 571 572 572 static struct ghes_estatus_cache *ghes_estatus_cache_alloc( 573 573 struct acpi_hest_generic *generic, 574 - struct acpi_hest_generic_status *estatus) 574 + struct acpi_generic_status *estatus) 575 575 { 576 576 int alloced; 577 577 u32 len, cache_len; 578 578 struct ghes_estatus_cache *cache; 579 - struct acpi_hest_generic_status *cache_estatus; 579 + struct acpi_generic_status *cache_estatus; 580 580 581 581 alloced = atomic_add_return(1, &ghes_estatus_cache_alloced); 582 582 if (alloced > GHES_ESTATUS_CACHE_ALLOCED_MAX) { 583 583 atomic_dec(&ghes_estatus_cache_alloced); 584 584 return NULL; 585 585 } 586 - len = apei_estatus_len(estatus); 586 + len = cper_estatus_len(estatus); 587 587 cache_len = GHES_ESTATUS_CACHE_LEN(len); 588 588 cache = (void *)gen_pool_alloc(ghes_estatus_pool, cache_len); 589 589 if (!cache) { ··· 603 603 { 604 604 u32 len; 605 605 606 - len = apei_estatus_len(GHES_ESTATUS_FROM_CACHE(cache)); 606 + len = cper_estatus_len(GHES_ESTATUS_FROM_CACHE(cache)); 607 607 len = GHES_ESTATUS_CACHE_LEN(len); 608 608 gen_pool_free(ghes_estatus_pool, (unsigned long)cache, len); 609 609 atomic_dec(&ghes_estatus_cache_alloced); ··· 619 619 620 620 static void ghes_estatus_cache_add( 621 621 struct acpi_hest_generic *generic, 622 - struct acpi_hest_generic_status *estatus) 622 + struct acpi_generic_status *estatus) 623 623 { 624 624 int i, slot = -1, count; 625 625 unsigned long long now, duration, period, max_period = 0; ··· 751 751 struct llist_node *llnode, *next; 752 752 struct ghes_estatus_node *estatus_node; 753 753 struct acpi_hest_generic *generic; 754 - struct acpi_hest_generic_status *estatus; 754 + struct acpi_generic_status *estatus; 755 755 u32 len, node_len; 756 756 757 757 llnode = llist_del_all(&ghes_estatus_llist); ··· 765 765 estatus_node = llist_entry(llnode, struct ghes_estatus_node, 766 766 llnode); 767 767 estatus = GHES_ESTATUS_FROM_NODE(estatus_node); 768 - len = apei_estatus_len(estatus); 768 + len = cper_estatus_len(estatus); 769 769 node_len = GHES_ESTATUS_NODE_LEN(len); 770 770 ghes_do_proc(estatus_node->ghes, estatus); 771 771 if (!ghes_estatus_cached(estatus)) { ··· 784 784 struct llist_node *llnode; 785 785 struct ghes_estatus_node *estatus_node; 786 786 struct acpi_hest_generic *generic; 787 - struct acpi_hest_generic_status *estatus; 787 + struct acpi_generic_status *estatus; 788 788 u32 len, node_len; 789 789 790 790 llnode = llist_del_all(&ghes_estatus_llist); ··· 797 797 estatus_node = llist_entry(llnode, struct ghes_estatus_node, 798 798 llnode); 799 799 estatus = GHES_ESTATUS_FROM_NODE(estatus_node); 800 - len = apei_estatus_len(estatus); 800 + len = cper_estatus_len(estatus); 801 801 node_len = GHES_ESTATUS_NODE_LEN(len); 802 802 generic = estatus_node->generic; 803 803 ghes_print_estatus(NULL, generic, estatus); ··· 843 843 #ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG 844 844 u32 len, node_len; 845 845 struct ghes_estatus_node *estatus_node; 846 - struct acpi_hest_generic_status *estatus; 846 + struct acpi_generic_status *estatus; 847 847 #endif 848 848 if (!(ghes->flags & GHES_TO_CLEAR)) 849 849 continue; ··· 851 851 if (ghes_estatus_cached(ghes->estatus)) 852 852 goto next; 853 853 /* Save estatus for further processing in IRQ context */ 854 - len = apei_estatus_len(ghes->estatus); 854 + len = cper_estatus_len(ghes->estatus); 855 855 node_len = GHES_ESTATUS_NODE_LEN(len); 856 856 estatus_node = (void *)gen_pool_alloc(ghes_estatus_pool, 857 857 node_len); ··· 923 923 924 924 rc = -EIO; 925 925 if (generic->error_block_length < 926 - sizeof(struct acpi_hest_generic_status)) { 926 + sizeof(struct acpi_generic_status)) { 927 927 pr_warning(FW_BUG GHES_PFX "Invalid error block length: %u for generic hardware error source: %d\n", 928 928 generic->error_block_length, 929 929 generic->header.source_id);
+7 -7
include/acpi/actbl1.h
··· 596 596 597 597 /* Generic Error Status block */ 598 598 599 - struct acpi_hest_generic_status { 599 + struct acpi_generic_status { 600 600 u32 block_status; 601 601 u32 raw_data_offset; 602 602 u32 raw_data_length; ··· 606 606 607 607 /* Values for block_status flags above */ 608 608 609 - #define ACPI_HEST_UNCORRECTABLE (1) 610 - #define ACPI_HEST_CORRECTABLE (1<<1) 611 - #define ACPI_HEST_MULTIPLE_UNCORRECTABLE (1<<2) 612 - #define ACPI_HEST_MULTIPLE_CORRECTABLE (1<<3) 613 - #define ACPI_HEST_ERROR_ENTRY_COUNT (0xFF<<4) /* 8 bits, error count */ 609 + #define ACPI_GEN_ERR_UC BIT(0) 610 + #define ACPI_GEN_ERR_CE BIT(1) 611 + #define ACPI_GEN_ERR_MULTI_UC BIT(2) 612 + #define ACPI_GEN_ERR_MULTI_CE BIT(3) 613 + #define ACPI_GEN_ERR_COUNT_SHIFT (0xFF<<4) /* 8 bits, error count */ 614 614 615 615 /* Generic Error Data entry */ 616 616 617 - struct acpi_hest_generic_data { 617 + struct acpi_generic_data { 618 618 u8 section_type[16]; 619 619 u32 error_severity; 620 620 u16 revision;
+1 -1
include/acpi/ghes.h
··· 14 14 15 15 struct ghes { 16 16 struct acpi_hest_generic *generic; 17 - struct acpi_hest_generic_status *estatus; 17 + struct acpi_generic_status *estatus; 18 18 u64 buffer_paddr; 19 19 unsigned long flags; 20 20 union {
+1 -1
include/linux/cper.h
··· 389 389 390 390 u64 cper_next_record_id(void); 391 391 void cper_print_bits(const char *prefix, unsigned int bits, 392 - const char *strs[], unsigned int strs_size); 392 + const char * const strs[], unsigned int strs_size); 393 393 394 394 #endif