diff options
author | Len Brown <len.brown@intel.com> | 2011-08-03 11:30:42 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2011-08-03 11:30:42 -0400 |
commit | d0e323b47057f4492b8fa22345f38d80a469bf8d (patch) | |
tree | feb760c7e2cdb1e43640417409428ab858910ea3 /drivers/acpi | |
parent | c027a474a68065391c8773f6e83ed5412657e369 (diff) | |
parent | c3e6088e1036f8084bc7444b38437da136b7588b (diff) |
Merge branch 'apei' into apei-release
Some trivial conflicts due to other various merges
adding to the end of common lists sooner than this one.
arch/ia64/Kconfig
arch/powerpc/Kconfig
arch/x86/Kconfig
lib/Kconfig
lib/Makefile
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/apei/Kconfig | 11 | ||||
-rw-r--r-- | drivers/acpi/apei/apei-base.c | 35 | ||||
-rw-r--r-- | drivers/acpi/apei/apei-internal.h | 15 | ||||
-rw-r--r-- | drivers/acpi/apei/einj.c | 43 | ||||
-rw-r--r-- | drivers/acpi/apei/erst-dbg.c | 6 | ||||
-rw-r--r-- | drivers/acpi/apei/erst.c | 12 | ||||
-rw-r--r-- | drivers/acpi/apei/ghes.c | 431 | ||||
-rw-r--r-- | drivers/acpi/apei/hest.c | 17 | ||||
-rw-r--r-- | drivers/acpi/bus.c | 14 |
9 files changed, 516 insertions, 68 deletions
diff --git a/drivers/acpi/apei/Kconfig b/drivers/acpi/apei/Kconfig index f739a70b1c70..c34aa51af4ee 100644 --- a/drivers/acpi/apei/Kconfig +++ b/drivers/acpi/apei/Kconfig | |||
@@ -10,9 +10,11 @@ config ACPI_APEI | |||
10 | error injection. | 10 | error injection. |
11 | 11 | ||
12 | config ACPI_APEI_GHES | 12 | config ACPI_APEI_GHES |
13 | tristate "APEI Generic Hardware Error Source" | 13 | bool "APEI Generic Hardware Error Source" |
14 | depends on ACPI_APEI && X86 | 14 | depends on ACPI_APEI && X86 |
15 | select ACPI_HED | 15 | select ACPI_HED |
16 | select LLIST | ||
17 | select GENERIC_ALLOCATOR | ||
16 | help | 18 | help |
17 | Generic Hardware Error Source provides a way to report | 19 | Generic Hardware Error Source provides a way to report |
18 | platform hardware errors (such as that from chipset). It | 20 | platform hardware errors (such as that from chipset). It |
@@ -30,6 +32,13 @@ config ACPI_APEI_PCIEAER | |||
30 | PCIe AER errors may be reported via APEI firmware first mode. | 32 | PCIe AER errors may be reported via APEI firmware first mode. |
31 | Turn on this option to enable the corresponding support. | 33 | Turn on this option to enable the corresponding support. |
32 | 34 | ||
35 | config ACPI_APEI_MEMORY_FAILURE | ||
36 | bool "APEI memory error recovering support" | ||
37 | depends on ACPI_APEI && MEMORY_FAILURE | ||
38 | help | ||
39 | Memory errors may be reported via APEI firmware first mode. | ||
40 | Turn on this option to enable the memory recovering support. | ||
41 | |||
33 | config ACPI_APEI_EINJ | 42 | config ACPI_APEI_EINJ |
34 | tristate "APEI Error INJection (EINJ)" | 43 | tristate "APEI Error INJection (EINJ)" |
35 | depends on ACPI_APEI && DEBUG_FS | 44 | depends on ACPI_APEI && DEBUG_FS |
diff --git a/drivers/acpi/apei/apei-base.c b/drivers/acpi/apei/apei-base.c index 4a904a4bf05f..8041248fce9b 100644 --- a/drivers/acpi/apei/apei-base.c +++ b/drivers/acpi/apei/apei-base.c | |||
@@ -157,9 +157,10 @@ EXPORT_SYMBOL_GPL(apei_exec_noop); | |||
157 | * Interpret the specified action. Go through whole action table, | 157 | * Interpret the specified action. Go through whole action table, |
158 | * execute all instructions belong to the action. | 158 | * execute all instructions belong to the action. |
159 | */ | 159 | */ |
160 | int apei_exec_run(struct apei_exec_context *ctx, u8 action) | 160 | int __apei_exec_run(struct apei_exec_context *ctx, u8 action, |
161 | bool optional) | ||
161 | { | 162 | { |
162 | int rc; | 163 | int rc = -ENOENT; |
163 | u32 i, ip; | 164 | u32 i, ip; |
164 | struct acpi_whea_header *entry; | 165 | struct acpi_whea_header *entry; |
165 | apei_exec_ins_func_t run; | 166 | apei_exec_ins_func_t run; |
@@ -198,9 +199,9 @@ rewind: | |||
198 | goto rewind; | 199 | goto rewind; |
199 | } | 200 | } |
200 | 201 | ||
201 | return 0; | 202 | return !optional && rc < 0 ? rc : 0; |
202 | } | 203 | } |
203 | EXPORT_SYMBOL_GPL(apei_exec_run); | 204 | EXPORT_SYMBOL_GPL(__apei_exec_run); |
204 | 205 | ||
205 | typedef int (*apei_exec_entry_func_t)(struct apei_exec_context *ctx, | 206 | typedef int (*apei_exec_entry_func_t)(struct apei_exec_context *ctx, |
206 | struct acpi_whea_header *entry, | 207 | struct acpi_whea_header *entry, |
@@ -603,3 +604,29 @@ struct dentry *apei_get_debugfs_dir(void) | |||
603 | return dapei; | 604 | return dapei; |
604 | } | 605 | } |
605 | EXPORT_SYMBOL_GPL(apei_get_debugfs_dir); | 606 | EXPORT_SYMBOL_GPL(apei_get_debugfs_dir); |
607 | |||
608 | int apei_osc_setup(void) | ||
609 | { | ||
610 | static u8 whea_uuid_str[] = "ed855e0c-6c90-47bf-a62a-26de0fc5ad5c"; | ||
611 | acpi_handle handle; | ||
612 | u32 capbuf[3]; | ||
613 | struct acpi_osc_context context = { | ||
614 | .uuid_str = whea_uuid_str, | ||
615 | .rev = 1, | ||
616 | .cap.length = sizeof(capbuf), | ||
617 | .cap.pointer = capbuf, | ||
618 | }; | ||
619 | |||
620 | capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE; | ||
621 | capbuf[OSC_SUPPORT_TYPE] = 0; | ||
622 | capbuf[OSC_CONTROL_TYPE] = 0; | ||
623 | |||
624 | if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle)) | ||
625 | || ACPI_FAILURE(acpi_run_osc(handle, &context))) | ||
626 | return -EIO; | ||
627 | else { | ||
628 | kfree(context.ret.pointer); | ||
629 | return 0; | ||
630 | } | ||
631 | } | ||
632 | EXPORT_SYMBOL_GPL(apei_osc_setup); | ||
diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h index ef0581f2094d..f57050e7a5e7 100644 --- a/drivers/acpi/apei/apei-internal.h +++ b/drivers/acpi/apei/apei-internal.h | |||
@@ -50,7 +50,18 @@ static inline u64 apei_exec_ctx_get_output(struct apei_exec_context *ctx) | |||
50 | return ctx->value; | 50 | return ctx->value; |
51 | } | 51 | } |
52 | 52 | ||
53 | int apei_exec_run(struct apei_exec_context *ctx, u8 action); | 53 | int __apei_exec_run(struct apei_exec_context *ctx, u8 action, bool optional); |
54 | |||
55 | static inline int apei_exec_run(struct apei_exec_context *ctx, u8 action) | ||
56 | { | ||
57 | return __apei_exec_run(ctx, action, 0); | ||
58 | } | ||
59 | |||
60 | /* It is optional whether the firmware provides the action */ | ||
61 | static inline int apei_exec_run_optional(struct apei_exec_context *ctx, u8 action) | ||
62 | { | ||
63 | return __apei_exec_run(ctx, action, 1); | ||
64 | } | ||
54 | 65 | ||
55 | /* Common instruction implementation */ | 66 | /* Common instruction implementation */ |
56 | 67 | ||
@@ -113,4 +124,6 @@ void apei_estatus_print(const char *pfx, | |||
113 | const struct acpi_hest_generic_status *estatus); | 124 | const struct acpi_hest_generic_status *estatus); |
114 | int apei_estatus_check_header(const struct acpi_hest_generic_status *estatus); | 125 | int apei_estatus_check_header(const struct acpi_hest_generic_status *estatus); |
115 | int apei_estatus_check(const struct acpi_hest_generic_status *estatus); | 126 | int apei_estatus_check(const struct acpi_hest_generic_status *estatus); |
127 | |||
128 | int apei_osc_setup(void); | ||
116 | #endif | 129 | #endif |
diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c index f74b2ea11f21..589b96c38704 100644 --- a/drivers/acpi/apei/einj.c +++ b/drivers/acpi/apei/einj.c | |||
@@ -46,7 +46,8 @@ | |||
46 | * Some BIOSes allow parameters to the SET_ERROR_TYPE entries in the | 46 | * Some BIOSes allow parameters to the SET_ERROR_TYPE entries in the |
47 | * EINJ table through an unpublished extension. Use with caution as | 47 | * EINJ table through an unpublished extension. Use with caution as |
48 | * most will ignore the parameter and make their own choice of address | 48 | * most will ignore the parameter and make their own choice of address |
49 | * for error injection. | 49 | * for error injection. This extension is used only if |
50 | * param_extension module parameter is specified. | ||
50 | */ | 51 | */ |
51 | struct einj_parameter { | 52 | struct einj_parameter { |
52 | u64 type; | 53 | u64 type; |
@@ -65,6 +66,9 @@ struct einj_parameter { | |||
65 | ((struct acpi_whea_header *)((char *)(tab) + \ | 66 | ((struct acpi_whea_header *)((char *)(tab) + \ |
66 | sizeof(struct acpi_table_einj))) | 67 | sizeof(struct acpi_table_einj))) |
67 | 68 | ||
69 | static bool param_extension; | ||
70 | module_param(param_extension, bool, 0); | ||
71 | |||
68 | static struct acpi_table_einj *einj_tab; | 72 | static struct acpi_table_einj *einj_tab; |
69 | 73 | ||
70 | static struct apei_resources einj_resources; | 74 | static struct apei_resources einj_resources; |
@@ -285,7 +289,7 @@ static int __einj_error_inject(u32 type, u64 param1, u64 param2) | |||
285 | 289 | ||
286 | einj_exec_ctx_init(&ctx); | 290 | einj_exec_ctx_init(&ctx); |
287 | 291 | ||
288 | rc = apei_exec_run(&ctx, ACPI_EINJ_BEGIN_OPERATION); | 292 | rc = apei_exec_run_optional(&ctx, ACPI_EINJ_BEGIN_OPERATION); |
289 | if (rc) | 293 | if (rc) |
290 | return rc; | 294 | return rc; |
291 | apei_exec_ctx_set_input(&ctx, type); | 295 | apei_exec_ctx_set_input(&ctx, type); |
@@ -323,7 +327,7 @@ static int __einj_error_inject(u32 type, u64 param1, u64 param2) | |||
323 | rc = __einj_error_trigger(trigger_paddr); | 327 | rc = __einj_error_trigger(trigger_paddr); |
324 | if (rc) | 328 | if (rc) |
325 | return rc; | 329 | return rc; |
326 | rc = apei_exec_run(&ctx, ACPI_EINJ_END_OPERATION); | 330 | rc = apei_exec_run_optional(&ctx, ACPI_EINJ_END_OPERATION); |
327 | 331 | ||
328 | return rc; | 332 | return rc; |
329 | } | 333 | } |
@@ -489,14 +493,6 @@ static int __init einj_init(void) | |||
489 | einj_debug_dir, NULL, &error_type_fops); | 493 | einj_debug_dir, NULL, &error_type_fops); |
490 | if (!fentry) | 494 | if (!fentry) |
491 | goto err_cleanup; | 495 | goto err_cleanup; |
492 | fentry = debugfs_create_x64("param1", S_IRUSR | S_IWUSR, | ||
493 | einj_debug_dir, &error_param1); | ||
494 | if (!fentry) | ||
495 | goto err_cleanup; | ||
496 | fentry = debugfs_create_x64("param2", S_IRUSR | S_IWUSR, | ||
497 | einj_debug_dir, &error_param2); | ||
498 | if (!fentry) | ||
499 | goto err_cleanup; | ||
500 | fentry = debugfs_create_file("error_inject", S_IWUSR, | 496 | fentry = debugfs_create_file("error_inject", S_IWUSR, |
501 | einj_debug_dir, NULL, &error_inject_fops); | 497 | einj_debug_dir, NULL, &error_inject_fops); |
502 | if (!fentry) | 498 | if (!fentry) |
@@ -513,12 +509,23 @@ static int __init einj_init(void) | |||
513 | rc = apei_exec_pre_map_gars(&ctx); | 509 | rc = apei_exec_pre_map_gars(&ctx); |
514 | if (rc) | 510 | if (rc) |
515 | goto err_release; | 511 | goto err_release; |
516 | param_paddr = einj_get_parameter_address(); | 512 | if (param_extension) { |
517 | if (param_paddr) { | 513 | param_paddr = einj_get_parameter_address(); |
518 | einj_param = ioremap(param_paddr, sizeof(*einj_param)); | 514 | if (param_paddr) { |
519 | rc = -ENOMEM; | 515 | einj_param = ioremap(param_paddr, sizeof(*einj_param)); |
520 | if (!einj_param) | 516 | rc = -ENOMEM; |
521 | goto err_unmap; | 517 | if (!einj_param) |
518 | goto err_unmap; | ||
519 | fentry = debugfs_create_x64("param1", S_IRUSR | S_IWUSR, | ||
520 | einj_debug_dir, &error_param1); | ||
521 | if (!fentry) | ||
522 | goto err_unmap; | ||
523 | fentry = debugfs_create_x64("param2", S_IRUSR | S_IWUSR, | ||
524 | einj_debug_dir, &error_param2); | ||
525 | if (!fentry) | ||
526 | goto err_unmap; | ||
527 | } else | ||
528 | pr_warn(EINJ_PFX "Parameter extension is not supported.\n"); | ||
522 | } | 529 | } |
523 | 530 | ||
524 | pr_info(EINJ_PFX "Error INJection is initialized.\n"); | 531 | pr_info(EINJ_PFX "Error INJection is initialized.\n"); |
@@ -526,6 +533,8 @@ static int __init einj_init(void) | |||
526 | return 0; | 533 | return 0; |
527 | 534 | ||
528 | err_unmap: | 535 | err_unmap: |
536 | if (einj_param) | ||
537 | iounmap(einj_param); | ||
529 | apei_exec_post_unmap_gars(&ctx); | 538 | apei_exec_post_unmap_gars(&ctx); |
530 | err_release: | 539 | err_release: |
531 | apei_resources_release(&einj_resources); | 540 | apei_resources_release(&einj_resources); |
diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c index a4cfb64c86a1..903549df809b 100644 --- a/drivers/acpi/apei/erst-dbg.c +++ b/drivers/acpi/apei/erst-dbg.c | |||
@@ -33,7 +33,7 @@ | |||
33 | 33 | ||
34 | #define ERST_DBG_PFX "ERST DBG: " | 34 | #define ERST_DBG_PFX "ERST DBG: " |
35 | 35 | ||
36 | #define ERST_DBG_RECORD_LEN_MAX 4096 | 36 | #define ERST_DBG_RECORD_LEN_MAX 0x4000 |
37 | 37 | ||
38 | static void *erst_dbg_buf; | 38 | static void *erst_dbg_buf; |
39 | static unsigned int erst_dbg_buf_len; | 39 | static unsigned int erst_dbg_buf_len; |
@@ -213,6 +213,10 @@ static struct miscdevice erst_dbg_dev = { | |||
213 | 213 | ||
214 | static __init int erst_dbg_init(void) | 214 | static __init int erst_dbg_init(void) |
215 | { | 215 | { |
216 | if (erst_disable) { | ||
217 | pr_info(ERST_DBG_PFX "ERST support is disabled.\n"); | ||
218 | return -ENODEV; | ||
219 | } | ||
216 | return misc_register(&erst_dbg_dev); | 220 | return misc_register(&erst_dbg_dev); |
217 | } | 221 | } |
218 | 222 | ||
diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c index 6053f4780df9..2ca59dc69f7f 100644 --- a/drivers/acpi/apei/erst.c +++ b/drivers/acpi/apei/erst.c | |||
@@ -642,7 +642,7 @@ static int __erst_write_to_storage(u64 offset) | |||
642 | int rc; | 642 | int rc; |
643 | 643 | ||
644 | erst_exec_ctx_init(&ctx); | 644 | erst_exec_ctx_init(&ctx); |
645 | rc = apei_exec_run(&ctx, ACPI_ERST_BEGIN_WRITE); | 645 | rc = apei_exec_run_optional(&ctx, ACPI_ERST_BEGIN_WRITE); |
646 | if (rc) | 646 | if (rc) |
647 | return rc; | 647 | return rc; |
648 | apei_exec_ctx_set_input(&ctx, offset); | 648 | apei_exec_ctx_set_input(&ctx, offset); |
@@ -666,7 +666,7 @@ static int __erst_write_to_storage(u64 offset) | |||
666 | if (rc) | 666 | if (rc) |
667 | return rc; | 667 | return rc; |
668 | val = apei_exec_ctx_get_output(&ctx); | 668 | val = apei_exec_ctx_get_output(&ctx); |
669 | rc = apei_exec_run(&ctx, ACPI_ERST_END); | 669 | rc = apei_exec_run_optional(&ctx, ACPI_ERST_END); |
670 | if (rc) | 670 | if (rc) |
671 | return rc; | 671 | return rc; |
672 | 672 | ||
@@ -681,7 +681,7 @@ static int __erst_read_from_storage(u64 record_id, u64 offset) | |||
681 | int rc; | 681 | int rc; |
682 | 682 | ||
683 | erst_exec_ctx_init(&ctx); | 683 | erst_exec_ctx_init(&ctx); |
684 | rc = apei_exec_run(&ctx, ACPI_ERST_BEGIN_READ); | 684 | rc = apei_exec_run_optional(&ctx, ACPI_ERST_BEGIN_READ); |
685 | if (rc) | 685 | if (rc) |
686 | return rc; | 686 | return rc; |
687 | apei_exec_ctx_set_input(&ctx, offset); | 687 | apei_exec_ctx_set_input(&ctx, offset); |
@@ -709,7 +709,7 @@ static int __erst_read_from_storage(u64 record_id, u64 offset) | |||
709 | if (rc) | 709 | if (rc) |
710 | return rc; | 710 | return rc; |
711 | val = apei_exec_ctx_get_output(&ctx); | 711 | val = apei_exec_ctx_get_output(&ctx); |
712 | rc = apei_exec_run(&ctx, ACPI_ERST_END); | 712 | rc = apei_exec_run_optional(&ctx, ACPI_ERST_END); |
713 | if (rc) | 713 | if (rc) |
714 | return rc; | 714 | return rc; |
715 | 715 | ||
@@ -724,7 +724,7 @@ static int __erst_clear_from_storage(u64 record_id) | |||
724 | int rc; | 724 | int rc; |
725 | 725 | ||
726 | erst_exec_ctx_init(&ctx); | 726 | erst_exec_ctx_init(&ctx); |
727 | rc = apei_exec_run(&ctx, ACPI_ERST_BEGIN_CLEAR); | 727 | rc = apei_exec_run_optional(&ctx, ACPI_ERST_BEGIN_CLEAR); |
728 | if (rc) | 728 | if (rc) |
729 | return rc; | 729 | return rc; |
730 | apei_exec_ctx_set_input(&ctx, record_id); | 730 | apei_exec_ctx_set_input(&ctx, record_id); |
@@ -748,7 +748,7 @@ static int __erst_clear_from_storage(u64 record_id) | |||
748 | if (rc) | 748 | if (rc) |
749 | return rc; | 749 | return rc; |
750 | val = apei_exec_ctx_get_output(&ctx); | 750 | val = apei_exec_ctx_get_output(&ctx); |
751 | rc = apei_exec_run(&ctx, ACPI_ERST_END); | 751 | rc = apei_exec_run_optional(&ctx, ACPI_ERST_END); |
752 | if (rc) | 752 | if (rc) |
753 | return rc; | 753 | return rc; |
754 | 754 | ||
diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index f703b2881153..0784f99a4665 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c | |||
@@ -12,7 +12,7 @@ | |||
12 | * For more information about Generic Hardware Error Source, please | 12 | * For more information about Generic Hardware Error Source, please |
13 | * refer to ACPI Specification version 4.0, section 17.3.2.6 | 13 | * refer to ACPI Specification version 4.0, section 17.3.2.6 |
14 | * | 14 | * |
15 | * Copyright 2010 Intel Corp. | 15 | * Copyright 2010,2011 Intel Corp. |
16 | * Author: Huang Ying <ying.huang@intel.com> | 16 | * Author: Huang Ying <ying.huang@intel.com> |
17 | * | 17 | * |
18 | * This program is free software; you can redistribute it and/or | 18 | * This program is free software; you can redistribute it and/or |
@@ -42,6 +42,9 @@ | |||
42 | #include <linux/mutex.h> | 42 | #include <linux/mutex.h> |
43 | #include <linux/ratelimit.h> | 43 | #include <linux/ratelimit.h> |
44 | #include <linux/vmalloc.h> | 44 | #include <linux/vmalloc.h> |
45 | #include <linux/irq_work.h> | ||
46 | #include <linux/llist.h> | ||
47 | #include <linux/genalloc.h> | ||
45 | #include <acpi/apei.h> | 48 | #include <acpi/apei.h> |
46 | #include <acpi/atomicio.h> | 49 | #include <acpi/atomicio.h> |
47 | #include <acpi/hed.h> | 50 | #include <acpi/hed.h> |
@@ -53,6 +56,30 @@ | |||
53 | #define GHES_PFX "GHES: " | 56 | #define GHES_PFX "GHES: " |
54 | 57 | ||
55 | #define GHES_ESTATUS_MAX_SIZE 65536 | 58 | #define GHES_ESTATUS_MAX_SIZE 65536 |
59 | #define GHES_ESOURCE_PREALLOC_MAX_SIZE 65536 | ||
60 | |||
61 | #define GHES_ESTATUS_POOL_MIN_ALLOC_ORDER 3 | ||
62 | |||
63 | /* This is just an estimation for memory pool allocation */ | ||
64 | #define GHES_ESTATUS_CACHE_AVG_SIZE 512 | ||
65 | |||
66 | #define GHES_ESTATUS_CACHES_SIZE 4 | ||
67 | |||
68 | #define GHES_ESTATUS_IN_CACHE_MAX_NSEC 10000000000ULL | ||
69 | /* Prevent too many caches are allocated because of RCU */ | ||
70 | #define GHES_ESTATUS_CACHE_ALLOCED_MAX (GHES_ESTATUS_CACHES_SIZE * 3 / 2) | ||
71 | |||
72 | #define GHES_ESTATUS_CACHE_LEN(estatus_len) \ | ||
73 | (sizeof(struct ghes_estatus_cache) + (estatus_len)) | ||
74 | #define GHES_ESTATUS_FROM_CACHE(estatus_cache) \ | ||
75 | ((struct acpi_hest_generic_status *) \ | ||
76 | ((struct ghes_estatus_cache *)(estatus_cache) + 1)) | ||
77 | |||
78 | #define GHES_ESTATUS_NODE_LEN(estatus_len) \ | ||
79 | (sizeof(struct ghes_estatus_node) + (estatus_len)) | ||
80 | #define GHES_ESTATUS_FROM_NODE(estatus_node) \ | ||
81 | ((struct acpi_hest_generic_status *) \ | ||
82 | ((struct ghes_estatus_node *)(estatus_node) + 1)) | ||
56 | 83 | ||
57 | /* | 84 | /* |
58 | * One struct ghes is created for each generic hardware error source. | 85 | * One struct ghes is created for each generic hardware error source. |
@@ -77,6 +104,22 @@ struct ghes { | |||
77 | }; | 104 | }; |
78 | }; | 105 | }; |
79 | 106 | ||
107 | struct ghes_estatus_node { | ||
108 | struct llist_node llnode; | ||
109 | struct acpi_hest_generic *generic; | ||
110 | }; | ||
111 | |||
112 | struct ghes_estatus_cache { | ||
113 | u32 estatus_len; | ||
114 | atomic_t count; | ||
115 | struct acpi_hest_generic *generic; | ||
116 | unsigned long long time_in; | ||
117 | struct rcu_head rcu; | ||
118 | }; | ||
119 | |||
120 | int ghes_disable; | ||
121 | module_param_named(disable, ghes_disable, bool, 0); | ||
122 | |||
80 | static int ghes_panic_timeout __read_mostly = 30; | 123 | static int ghes_panic_timeout __read_mostly = 30; |
81 | 124 | ||
82 | /* | 125 | /* |
@@ -121,6 +164,22 @@ static struct vm_struct *ghes_ioremap_area; | |||
121 | static DEFINE_RAW_SPINLOCK(ghes_ioremap_lock_nmi); | 164 | static DEFINE_RAW_SPINLOCK(ghes_ioremap_lock_nmi); |
122 | static DEFINE_SPINLOCK(ghes_ioremap_lock_irq); | 165 | static DEFINE_SPINLOCK(ghes_ioremap_lock_irq); |
123 | 166 | ||
167 | /* | ||
168 | * printk is not safe in NMI context. So in NMI handler, we allocate | ||
169 | * required memory from lock-less memory allocator | ||
170 | * (ghes_estatus_pool), save estatus into it, put them into lock-less | ||
171 | * list (ghes_estatus_llist), then delay printk into IRQ context via | ||
172 | * irq_work (ghes_proc_irq_work). ghes_estatus_size_request record | ||
173 | * required pool size by all NMI error source. | ||
174 | */ | ||
175 | static struct gen_pool *ghes_estatus_pool; | ||
176 | static unsigned long ghes_estatus_pool_size_request; | ||
177 | static struct llist_head ghes_estatus_llist; | ||
178 | static struct irq_work ghes_proc_irq_work; | ||
179 | |||
180 | struct ghes_estatus_cache *ghes_estatus_caches[GHES_ESTATUS_CACHES_SIZE]; | ||
181 | static atomic_t ghes_estatus_cache_alloced; | ||
182 | |||
124 | static int ghes_ioremap_init(void) | 183 | static int ghes_ioremap_init(void) |
125 | { | 184 | { |
126 | ghes_ioremap_area = __get_vm_area(PAGE_SIZE * GHES_IOREMAP_PAGES, | 185 | ghes_ioremap_area = __get_vm_area(PAGE_SIZE * GHES_IOREMAP_PAGES, |
@@ -180,6 +239,55 @@ static void ghes_iounmap_irq(void __iomem *vaddr_ptr) | |||
180 | __flush_tlb_one(vaddr); | 239 | __flush_tlb_one(vaddr); |
181 | } | 240 | } |
182 | 241 | ||
242 | static int ghes_estatus_pool_init(void) | ||
243 | { | ||
244 | ghes_estatus_pool = gen_pool_create(GHES_ESTATUS_POOL_MIN_ALLOC_ORDER, -1); | ||
245 | if (!ghes_estatus_pool) | ||
246 | return -ENOMEM; | ||
247 | return 0; | ||
248 | } | ||
249 | |||
250 | static void ghes_estatus_pool_free_chunk_page(struct gen_pool *pool, | ||
251 | struct gen_pool_chunk *chunk, | ||
252 | void *data) | ||
253 | { | ||
254 | free_page(chunk->start_addr); | ||
255 | } | ||
256 | |||
257 | static void ghes_estatus_pool_exit(void) | ||
258 | { | ||
259 | gen_pool_for_each_chunk(ghes_estatus_pool, | ||
260 | ghes_estatus_pool_free_chunk_page, NULL); | ||
261 | gen_pool_destroy(ghes_estatus_pool); | ||
262 | } | ||
263 | |||
264 | static int ghes_estatus_pool_expand(unsigned long len) | ||
265 | { | ||
266 | unsigned long i, pages, size, addr; | ||
267 | int ret; | ||
268 | |||
269 | ghes_estatus_pool_size_request += PAGE_ALIGN(len); | ||
270 | size = gen_pool_size(ghes_estatus_pool); | ||
271 | if (size >= ghes_estatus_pool_size_request) | ||
272 | return 0; | ||
273 | pages = (ghes_estatus_pool_size_request - size) / PAGE_SIZE; | ||
274 | for (i = 0; i < pages; i++) { | ||
275 | addr = __get_free_page(GFP_KERNEL); | ||
276 | if (!addr) | ||
277 | return -ENOMEM; | ||
278 | ret = gen_pool_add(ghes_estatus_pool, addr, PAGE_SIZE, -1); | ||
279 | if (ret) | ||
280 | return ret; | ||
281 | } | ||
282 | |||
283 | return 0; | ||
284 | } | ||
285 | |||
286 | static void ghes_estatus_pool_shrink(unsigned long len) | ||
287 | { | ||
288 | ghes_estatus_pool_size_request -= PAGE_ALIGN(len); | ||
289 | } | ||
290 | |||
183 | static struct ghes *ghes_new(struct acpi_hest_generic *generic) | 291 | static struct ghes *ghes_new(struct acpi_hest_generic *generic) |
184 | { | 292 | { |
185 | struct ghes *ghes; | 293 | struct ghes *ghes; |
@@ -341,43 +449,196 @@ static void ghes_clear_estatus(struct ghes *ghes) | |||
341 | ghes->flags &= ~GHES_TO_CLEAR; | 449 | ghes->flags &= ~GHES_TO_CLEAR; |
342 | } | 450 | } |
343 | 451 | ||
344 | static void ghes_do_proc(struct ghes *ghes) | 452 | static void ghes_do_proc(const struct acpi_hest_generic_status *estatus) |
345 | { | 453 | { |
346 | int sev, processed = 0; | 454 | int sev, sec_sev; |
347 | struct acpi_hest_generic_data *gdata; | 455 | struct acpi_hest_generic_data *gdata; |
348 | 456 | ||
349 | sev = ghes_severity(ghes->estatus->error_severity); | 457 | sev = ghes_severity(estatus->error_severity); |
350 | apei_estatus_for_each_section(ghes->estatus, gdata) { | 458 | apei_estatus_for_each_section(estatus, gdata) { |
351 | #ifdef CONFIG_X86_MCE | 459 | sec_sev = ghes_severity(gdata->error_severity); |
352 | if (!uuid_le_cmp(*(uuid_le *)gdata->section_type, | 460 | if (!uuid_le_cmp(*(uuid_le *)gdata->section_type, |
353 | CPER_SEC_PLATFORM_MEM)) { | 461 | CPER_SEC_PLATFORM_MEM)) { |
354 | apei_mce_report_mem_error( | 462 | struct cper_sec_mem_err *mem_err; |
355 | sev == GHES_SEV_CORRECTED, | 463 | mem_err = (struct cper_sec_mem_err *)(gdata+1); |
356 | (struct cper_sec_mem_err *)(gdata+1)); | 464 | #ifdef CONFIG_X86_MCE |
357 | processed = 1; | 465 | apei_mce_report_mem_error(sev == GHES_SEV_CORRECTED, |
358 | } | 466 | mem_err); |
359 | #endif | 467 | #endif |
468 | #ifdef CONFIG_ACPI_APEI_MEMORY_FAILURE | ||
469 | if (sev == GHES_SEV_RECOVERABLE && | ||
470 | sec_sev == GHES_SEV_RECOVERABLE && | ||
471 | mem_err->validation_bits & CPER_MEM_VALID_PHYSICAL_ADDRESS) { | ||
472 | unsigned long pfn; | ||
473 | pfn = mem_err->physical_addr >> PAGE_SHIFT; | ||
474 | memory_failure_queue(pfn, 0, 0); | ||
475 | } | ||
476 | #endif | ||
477 | } | ||
360 | } | 478 | } |
361 | } | 479 | } |
362 | 480 | ||
363 | static void ghes_print_estatus(const char *pfx, struct ghes *ghes) | 481 | static void __ghes_print_estatus(const char *pfx, |
482 | const struct acpi_hest_generic *generic, | ||
483 | const struct acpi_hest_generic_status *estatus) | ||
364 | { | 484 | { |
365 | /* Not more than 2 messages every 5 seconds */ | ||
366 | static DEFINE_RATELIMIT_STATE(ratelimit, 5*HZ, 2); | ||
367 | |||
368 | if (pfx == NULL) { | 485 | if (pfx == NULL) { |
369 | if (ghes_severity(ghes->estatus->error_severity) <= | 486 | if (ghes_severity(estatus->error_severity) <= |
370 | GHES_SEV_CORRECTED) | 487 | GHES_SEV_CORRECTED) |
371 | pfx = KERN_WARNING HW_ERR; | 488 | pfx = KERN_WARNING HW_ERR; |
372 | else | 489 | else |
373 | pfx = KERN_ERR HW_ERR; | 490 | pfx = KERN_ERR HW_ERR; |
374 | } | 491 | } |
375 | if (__ratelimit(&ratelimit)) { | 492 | printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n", |
376 | printk( | 493 | pfx, generic->header.source_id); |
377 | "%s""Hardware error from APEI Generic Hardware Error Source: %d\n", | 494 | apei_estatus_print(pfx, estatus); |
378 | pfx, ghes->generic->header.source_id); | 495 | } |
379 | apei_estatus_print(pfx, ghes->estatus); | 496 | |
497 | static int ghes_print_estatus(const char *pfx, | ||
498 | const struct acpi_hest_generic *generic, | ||
499 | const struct acpi_hest_generic_status *estatus) | ||
500 | { | ||
501 | /* Not more than 2 messages every 5 seconds */ | ||
502 | static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2); | ||
503 | static DEFINE_RATELIMIT_STATE(ratelimit_uncorrected, 5*HZ, 2); | ||
504 | struct ratelimit_state *ratelimit; | ||
505 | |||
506 | if (ghes_severity(estatus->error_severity) <= GHES_SEV_CORRECTED) | ||
507 | ratelimit = &ratelimit_corrected; | ||
508 | else | ||
509 | ratelimit = &ratelimit_uncorrected; | ||
510 | if (__ratelimit(ratelimit)) { | ||
511 | __ghes_print_estatus(pfx, generic, estatus); | ||
512 | return 1; | ||
380 | } | 513 | } |
514 | return 0; | ||
515 | } | ||
516 | |||
517 | /* | ||
518 | * GHES error status reporting throttle, to report more kinds of | ||
519 | * errors, instead of just most frequently occurred errors. | ||
520 | */ | ||
521 | static int ghes_estatus_cached(struct acpi_hest_generic_status *estatus) | ||
522 | { | ||
523 | u32 len; | ||
524 | int i, cached = 0; | ||
525 | unsigned long long now; | ||
526 | struct ghes_estatus_cache *cache; | ||
527 | struct acpi_hest_generic_status *cache_estatus; | ||
528 | |||
529 | len = apei_estatus_len(estatus); | ||
530 | rcu_read_lock(); | ||
531 | for (i = 0; i < GHES_ESTATUS_CACHES_SIZE; i++) { | ||
532 | cache = rcu_dereference(ghes_estatus_caches[i]); | ||
533 | if (cache == NULL) | ||
534 | continue; | ||
535 | if (len != cache->estatus_len) | ||
536 | continue; | ||
537 | cache_estatus = GHES_ESTATUS_FROM_CACHE(cache); | ||
538 | if (memcmp(estatus, cache_estatus, len)) | ||
539 | continue; | ||
540 | atomic_inc(&cache->count); | ||
541 | now = sched_clock(); | ||
542 | if (now - cache->time_in < GHES_ESTATUS_IN_CACHE_MAX_NSEC) | ||
543 | cached = 1; | ||
544 | break; | ||
545 | } | ||
546 | rcu_read_unlock(); | ||
547 | return cached; | ||
548 | } | ||
549 | |||
550 | static struct ghes_estatus_cache *ghes_estatus_cache_alloc( | ||
551 | struct acpi_hest_generic *generic, | ||
552 | struct acpi_hest_generic_status *estatus) | ||
553 | { | ||
554 | int alloced; | ||
555 | u32 len, cache_len; | ||
556 | struct ghes_estatus_cache *cache; | ||
557 | struct acpi_hest_generic_status *cache_estatus; | ||
558 | |||
559 | alloced = atomic_add_return(1, &ghes_estatus_cache_alloced); | ||
560 | if (alloced > GHES_ESTATUS_CACHE_ALLOCED_MAX) { | ||
561 | atomic_dec(&ghes_estatus_cache_alloced); | ||
562 | return NULL; | ||
563 | } | ||
564 | len = apei_estatus_len(estatus); | ||
565 | cache_len = GHES_ESTATUS_CACHE_LEN(len); | ||
566 | cache = (void *)gen_pool_alloc(ghes_estatus_pool, cache_len); | ||
567 | if (!cache) { | ||
568 | atomic_dec(&ghes_estatus_cache_alloced); | ||
569 | return NULL; | ||
570 | } | ||
571 | cache_estatus = GHES_ESTATUS_FROM_CACHE(cache); | ||
572 | memcpy(cache_estatus, estatus, len); | ||
573 | cache->estatus_len = len; | ||
574 | atomic_set(&cache->count, 0); | ||
575 | cache->generic = generic; | ||
576 | cache->time_in = sched_clock(); | ||
577 | return cache; | ||
578 | } | ||
579 | |||
580 | static void ghes_estatus_cache_free(struct ghes_estatus_cache *cache) | ||
581 | { | ||
582 | u32 len; | ||
583 | |||
584 | len = apei_estatus_len(GHES_ESTATUS_FROM_CACHE(cache)); | ||
585 | len = GHES_ESTATUS_CACHE_LEN(len); | ||
586 | gen_pool_free(ghes_estatus_pool, (unsigned long)cache, len); | ||
587 | atomic_dec(&ghes_estatus_cache_alloced); | ||
588 | } | ||
589 | |||
590 | static void ghes_estatus_cache_rcu_free(struct rcu_head *head) | ||
591 | { | ||
592 | struct ghes_estatus_cache *cache; | ||
593 | |||
594 | cache = container_of(head, struct ghes_estatus_cache, rcu); | ||
595 | ghes_estatus_cache_free(cache); | ||
596 | } | ||
597 | |||
598 | static void ghes_estatus_cache_add( | ||
599 | struct acpi_hest_generic *generic, | ||
600 | struct acpi_hest_generic_status *estatus) | ||
601 | { | ||
602 | int i, slot = -1, count; | ||
603 | unsigned long long now, duration, period, max_period = 0; | ||
604 | struct ghes_estatus_cache *cache, *slot_cache = NULL, *new_cache; | ||
605 | |||
606 | new_cache = ghes_estatus_cache_alloc(generic, estatus); | ||
607 | if (new_cache == NULL) | ||
608 | return; | ||
609 | rcu_read_lock(); | ||
610 | now = sched_clock(); | ||
611 | for (i = 0; i < GHES_ESTATUS_CACHES_SIZE; i++) { | ||
612 | cache = rcu_dereference(ghes_estatus_caches[i]); | ||
613 | if (cache == NULL) { | ||
614 | slot = i; | ||
615 | slot_cache = NULL; | ||
616 | break; | ||
617 | } | ||
618 | duration = now - cache->time_in; | ||
619 | if (duration >= GHES_ESTATUS_IN_CACHE_MAX_NSEC) { | ||
620 | slot = i; | ||
621 | slot_cache = cache; | ||
622 | break; | ||
623 | } | ||
624 | count = atomic_read(&cache->count); | ||
625 | period = duration; | ||
626 | do_div(period, (count + 1)); | ||
627 | if (period > max_period) { | ||
628 | max_period = period; | ||
629 | slot = i; | ||
630 | slot_cache = cache; | ||
631 | } | ||
632 | } | ||
633 | /* new_cache must be put into array after its contents are written */ | ||
634 | smp_wmb(); | ||
635 | if (slot != -1 && cmpxchg(ghes_estatus_caches + slot, | ||
636 | slot_cache, new_cache) == slot_cache) { | ||
637 | if (slot_cache) | ||
638 | call_rcu(&slot_cache->rcu, ghes_estatus_cache_rcu_free); | ||
639 | } else | ||
640 | ghes_estatus_cache_free(new_cache); | ||
641 | rcu_read_unlock(); | ||
381 | } | 642 | } |
382 | 643 | ||
383 | static int ghes_proc(struct ghes *ghes) | 644 | static int ghes_proc(struct ghes *ghes) |
@@ -387,9 +648,11 @@ static int ghes_proc(struct ghes *ghes) | |||
387 | rc = ghes_read_estatus(ghes, 0); | 648 | rc = ghes_read_estatus(ghes, 0); |
388 | if (rc) | 649 | if (rc) |
389 | goto out; | 650 | goto out; |
390 | ghes_print_estatus(NULL, ghes); | 651 | if (!ghes_estatus_cached(ghes->estatus)) { |
391 | ghes_do_proc(ghes); | 652 | if (ghes_print_estatus(NULL, ghes->generic, ghes->estatus)) |
392 | 653 | ghes_estatus_cache_add(ghes->generic, ghes->estatus); | |
654 | } | ||
655 | ghes_do_proc(ghes->estatus); | ||
393 | out: | 656 | out: |
394 | ghes_clear_estatus(ghes); | 657 | ghes_clear_estatus(ghes); |
395 | return 0; | 658 | return 0; |
@@ -447,6 +710,45 @@ static int ghes_notify_sci(struct notifier_block *this, | |||
447 | return ret; | 710 | return ret; |
448 | } | 711 | } |
449 | 712 | ||
713 | static void ghes_proc_in_irq(struct irq_work *irq_work) | ||
714 | { | ||
715 | struct llist_node *llnode, *next, *tail = NULL; | ||
716 | struct ghes_estatus_node *estatus_node; | ||
717 | struct acpi_hest_generic *generic; | ||
718 | struct acpi_hest_generic_status *estatus; | ||
719 | u32 len, node_len; | ||
720 | |||
721 | /* | ||
722 | * Because the time order of estatus in list is reversed, | ||
723 | * revert it back to proper order. | ||
724 | */ | ||
725 | llnode = llist_del_all(&ghes_estatus_llist); | ||
726 | while (llnode) { | ||
727 | next = llnode->next; | ||
728 | llnode->next = tail; | ||
729 | tail = llnode; | ||
730 | llnode = next; | ||
731 | } | ||
732 | llnode = tail; | ||
733 | while (llnode) { | ||
734 | next = llnode->next; | ||
735 | estatus_node = llist_entry(llnode, struct ghes_estatus_node, | ||
736 | llnode); | ||
737 | estatus = GHES_ESTATUS_FROM_NODE(estatus_node); | ||
738 | len = apei_estatus_len(estatus); | ||
739 | node_len = GHES_ESTATUS_NODE_LEN(len); | ||
740 | ghes_do_proc(estatus); | ||
741 | if (!ghes_estatus_cached(estatus)) { | ||
742 | generic = estatus_node->generic; | ||
743 | if (ghes_print_estatus(NULL, generic, estatus)) | ||
744 | ghes_estatus_cache_add(generic, estatus); | ||
745 | } | ||
746 | gen_pool_free(ghes_estatus_pool, (unsigned long)estatus_node, | ||
747 | node_len); | ||
748 | llnode = next; | ||
749 | } | ||
750 | } | ||
751 | |||
450 | static int ghes_notify_nmi(struct notifier_block *this, | 752 | static int ghes_notify_nmi(struct notifier_block *this, |
451 | unsigned long cmd, void *data) | 753 | unsigned long cmd, void *data) |
452 | { | 754 | { |
@@ -476,7 +778,8 @@ static int ghes_notify_nmi(struct notifier_block *this, | |||
476 | 778 | ||
477 | if (sev_global >= GHES_SEV_PANIC) { | 779 | if (sev_global >= GHES_SEV_PANIC) { |
478 | oops_begin(); | 780 | oops_begin(); |
479 | ghes_print_estatus(KERN_EMERG HW_ERR, ghes_global); | 781 | __ghes_print_estatus(KERN_EMERG HW_ERR, ghes_global->generic, |
782 | ghes_global->estatus); | ||
480 | /* reboot to log the error! */ | 783 | /* reboot to log the error! */ |
481 | if (panic_timeout == 0) | 784 | if (panic_timeout == 0) |
482 | panic_timeout = ghes_panic_timeout; | 785 | panic_timeout = ghes_panic_timeout; |
@@ -484,12 +787,34 @@ static int ghes_notify_nmi(struct notifier_block *this, | |||
484 | } | 787 | } |
485 | 788 | ||
486 | list_for_each_entry_rcu(ghes, &ghes_nmi, list) { | 789 | list_for_each_entry_rcu(ghes, &ghes_nmi, list) { |
790 | #ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG | ||
791 | u32 len, node_len; | ||
792 | struct ghes_estatus_node *estatus_node; | ||
793 | struct acpi_hest_generic_status *estatus; | ||
794 | #endif | ||
487 | if (!(ghes->flags & GHES_TO_CLEAR)) | 795 | if (!(ghes->flags & GHES_TO_CLEAR)) |
488 | continue; | 796 | continue; |
489 | /* Do not print estatus because printk is not NMI safe */ | 797 | #ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG |
490 | ghes_do_proc(ghes); | 798 | if (ghes_estatus_cached(ghes->estatus)) |
799 | goto next; | ||
800 | /* Save estatus for further processing in IRQ context */ | ||
801 | len = apei_estatus_len(ghes->estatus); | ||
802 | node_len = GHES_ESTATUS_NODE_LEN(len); | ||
803 | estatus_node = (void *)gen_pool_alloc(ghes_estatus_pool, | ||
804 | node_len); | ||
805 | if (estatus_node) { | ||
806 | estatus_node->generic = ghes->generic; | ||
807 | estatus = GHES_ESTATUS_FROM_NODE(estatus_node); | ||
808 | memcpy(estatus, ghes->estatus, len); | ||
809 | llist_add(&estatus_node->llnode, &ghes_estatus_llist); | ||
810 | } | ||
811 | next: | ||
812 | #endif | ||
491 | ghes_clear_estatus(ghes); | 813 | ghes_clear_estatus(ghes); |
492 | } | 814 | } |
815 | #ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG | ||
816 | irq_work_queue(&ghes_proc_irq_work); | ||
817 | #endif | ||
493 | 818 | ||
494 | out: | 819 | out: |
495 | raw_spin_unlock(&ghes_nmi_lock); | 820 | raw_spin_unlock(&ghes_nmi_lock); |
@@ -504,10 +829,26 @@ static struct notifier_block ghes_notifier_nmi = { | |||
504 | .notifier_call = ghes_notify_nmi, | 829 | .notifier_call = ghes_notify_nmi, |
505 | }; | 830 | }; |
506 | 831 | ||
832 | static unsigned long ghes_esource_prealloc_size( | ||
833 | const struct acpi_hest_generic *generic) | ||
834 | { | ||
835 | unsigned long block_length, prealloc_records, prealloc_size; | ||
836 | |||
837 | block_length = min_t(unsigned long, generic->error_block_length, | ||
838 | GHES_ESTATUS_MAX_SIZE); | ||
839 | prealloc_records = max_t(unsigned long, | ||
840 | generic->records_to_preallocate, 1); | ||
841 | prealloc_size = min_t(unsigned long, block_length * prealloc_records, | ||
842 | GHES_ESOURCE_PREALLOC_MAX_SIZE); | ||
843 | |||
844 | return prealloc_size; | ||
845 | } | ||
846 | |||
507 | static int __devinit ghes_probe(struct platform_device *ghes_dev) | 847 | static int __devinit ghes_probe(struct platform_device *ghes_dev) |
508 | { | 848 | { |
509 | struct acpi_hest_generic *generic; | 849 | struct acpi_hest_generic *generic; |
510 | struct ghes *ghes = NULL; | 850 | struct ghes *ghes = NULL; |
851 | unsigned long len; | ||
511 | int rc = -EINVAL; | 852 | int rc = -EINVAL; |
512 | 853 | ||
513 | generic = *(struct acpi_hest_generic **)ghes_dev->dev.platform_data; | 854 | generic = *(struct acpi_hest_generic **)ghes_dev->dev.platform_data; |
@@ -573,6 +914,8 @@ static int __devinit ghes_probe(struct platform_device *ghes_dev) | |||
573 | mutex_unlock(&ghes_list_mutex); | 914 | mutex_unlock(&ghes_list_mutex); |
574 | break; | 915 | break; |
575 | case ACPI_HEST_NOTIFY_NMI: | 916 | case ACPI_HEST_NOTIFY_NMI: |
917 | len = ghes_esource_prealloc_size(generic); | ||
918 | ghes_estatus_pool_expand(len); | ||
576 | mutex_lock(&ghes_list_mutex); | 919 | mutex_lock(&ghes_list_mutex); |
577 | if (list_empty(&ghes_nmi)) | 920 | if (list_empty(&ghes_nmi)) |
578 | register_die_notifier(&ghes_notifier_nmi); | 921 | register_die_notifier(&ghes_notifier_nmi); |
@@ -597,6 +940,7 @@ static int __devexit ghes_remove(struct platform_device *ghes_dev) | |||
597 | { | 940 | { |
598 | struct ghes *ghes; | 941 | struct ghes *ghes; |
599 | struct acpi_hest_generic *generic; | 942 | struct acpi_hest_generic *generic; |
943 | unsigned long len; | ||
600 | 944 | ||
601 | ghes = platform_get_drvdata(ghes_dev); | 945 | ghes = platform_get_drvdata(ghes_dev); |
602 | generic = ghes->generic; | 946 | generic = ghes->generic; |
@@ -627,6 +971,8 @@ static int __devexit ghes_remove(struct platform_device *ghes_dev) | |||
627 | * freed after NMI handler finishes. | 971 | * freed after NMI handler finishes. |
628 | */ | 972 | */ |
629 | synchronize_rcu(); | 973 | synchronize_rcu(); |
974 | len = ghes_esource_prealloc_size(generic); | ||
975 | ghes_estatus_pool_shrink(len); | ||
630 | break; | 976 | break; |
631 | default: | 977 | default: |
632 | BUG(); | 978 | BUG(); |
@@ -662,15 +1008,43 @@ static int __init ghes_init(void) | |||
662 | return -EINVAL; | 1008 | return -EINVAL; |
663 | } | 1009 | } |
664 | 1010 | ||
1011 | if (ghes_disable) { | ||
1012 | pr_info(GHES_PFX "GHES is not enabled!\n"); | ||
1013 | return -EINVAL; | ||
1014 | } | ||
1015 | |||
1016 | init_irq_work(&ghes_proc_irq_work, ghes_proc_in_irq); | ||
1017 | |||
665 | rc = ghes_ioremap_init(); | 1018 | rc = ghes_ioremap_init(); |
666 | if (rc) | 1019 | if (rc) |
667 | goto err; | 1020 | goto err; |
668 | 1021 | ||
669 | rc = platform_driver_register(&ghes_platform_driver); | 1022 | rc = ghes_estatus_pool_init(); |
670 | if (rc) | 1023 | if (rc) |
671 | goto err_ioremap_exit; | 1024 | goto err_ioremap_exit; |
672 | 1025 | ||
1026 | rc = ghes_estatus_pool_expand(GHES_ESTATUS_CACHE_AVG_SIZE * | ||
1027 | GHES_ESTATUS_CACHE_ALLOCED_MAX); | ||
1028 | if (rc) | ||
1029 | goto err_pool_exit; | ||
1030 | |||
1031 | rc = platform_driver_register(&ghes_platform_driver); | ||
1032 | if (rc) | ||
1033 | goto err_pool_exit; | ||
1034 | |||
1035 | rc = apei_osc_setup(); | ||
1036 | if (rc == 0 && osc_sb_apei_support_acked) | ||
1037 | pr_info(GHES_PFX "APEI firmware first mode is enabled by APEI bit and WHEA _OSC.\n"); | ||
1038 | else if (rc == 0 && !osc_sb_apei_support_acked) | ||
1039 | pr_info(GHES_PFX "APEI firmware first mode is enabled by WHEA _OSC.\n"); | ||
1040 | else if (rc && osc_sb_apei_support_acked) | ||
1041 | pr_info(GHES_PFX "APEI firmware first mode is enabled by APEI bit.\n"); | ||
1042 | else | ||
1043 | pr_info(GHES_PFX "Failed to enable APEI firmware first mode.\n"); | ||
1044 | |||
673 | return 0; | 1045 | return 0; |
1046 | err_pool_exit: | ||
1047 | ghes_estatus_pool_exit(); | ||
674 | err_ioremap_exit: | 1048 | err_ioremap_exit: |
675 | ghes_ioremap_exit(); | 1049 | ghes_ioremap_exit(); |
676 | err: | 1050 | err: |
@@ -680,6 +1054,7 @@ err: | |||
680 | static void __exit ghes_exit(void) | 1054 | static void __exit ghes_exit(void) |
681 | { | 1055 | { |
682 | platform_driver_unregister(&ghes_platform_driver); | 1056 | platform_driver_unregister(&ghes_platform_driver); |
1057 | ghes_estatus_pool_exit(); | ||
683 | ghes_ioremap_exit(); | 1058 | ghes_ioremap_exit(); |
684 | } | 1059 | } |
685 | 1060 | ||
diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c index 181bc2f7bb74..05fee06f4d6e 100644 --- a/drivers/acpi/apei/hest.c +++ b/drivers/acpi/apei/hest.c | |||
@@ -231,16 +231,17 @@ void __init acpi_hest_init(void) | |||
231 | goto err; | 231 | goto err; |
232 | } | 232 | } |
233 | 233 | ||
234 | rc = apei_hest_parse(hest_parse_ghes_count, &ghes_count); | 234 | if (!ghes_disable) { |
235 | if (rc) | 235 | rc = apei_hest_parse(hest_parse_ghes_count, &ghes_count); |
236 | goto err; | 236 | if (rc) |
237 | 237 | goto err; | |
238 | rc = hest_ghes_dev_register(ghes_count); | 238 | rc = hest_ghes_dev_register(ghes_count); |
239 | if (!rc) { | 239 | if (rc) |
240 | pr_info(HEST_PFX "Table parsing has been initialized.\n"); | 240 | goto err; |
241 | return; | ||
242 | } | 241 | } |
243 | 242 | ||
243 | pr_info(HEST_PFX "Table parsing has been initialized.\n"); | ||
244 | return; | ||
244 | err: | 245 | err: |
245 | hest_disable = 1; | 246 | hest_disable = 1; |
246 | } | 247 | } |
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index d1e06c182cdb..437ddbf0c49a 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
40 | #include <acpi/acpi_bus.h> | 40 | #include <acpi/acpi_bus.h> |
41 | #include <acpi/acpi_drivers.h> | 41 | #include <acpi/acpi_drivers.h> |
42 | #include <acpi/apei.h> | ||
42 | #include <linux/dmi.h> | 43 | #include <linux/dmi.h> |
43 | #include <linux/suspend.h> | 44 | #include <linux/suspend.h> |
44 | 45 | ||
@@ -519,6 +520,7 @@ out_kfree: | |||
519 | } | 520 | } |
520 | EXPORT_SYMBOL(acpi_run_osc); | 521 | EXPORT_SYMBOL(acpi_run_osc); |
521 | 522 | ||
523 | bool osc_sb_apei_support_acked; | ||
522 | static u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48"; | 524 | static u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48"; |
523 | static void acpi_bus_osc_support(void) | 525 | static void acpi_bus_osc_support(void) |
524 | { | 526 | { |
@@ -541,11 +543,19 @@ static void acpi_bus_osc_support(void) | |||
541 | #if defined(CONFIG_ACPI_PROCESSOR) || defined(CONFIG_ACPI_PROCESSOR_MODULE) | 543 | #if defined(CONFIG_ACPI_PROCESSOR) || defined(CONFIG_ACPI_PROCESSOR_MODULE) |
542 | capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_PPC_OST_SUPPORT; | 544 | capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_PPC_OST_SUPPORT; |
543 | #endif | 545 | #endif |
546 | |||
547 | if (!ghes_disable) | ||
548 | capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_APEI_SUPPORT; | ||
544 | if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle))) | 549 | if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle))) |
545 | return; | 550 | return; |
546 | if (ACPI_SUCCESS(acpi_run_osc(handle, &context))) | 551 | if (ACPI_SUCCESS(acpi_run_osc(handle, &context))) { |
552 | u32 *capbuf_ret = context.ret.pointer; | ||
553 | if (context.ret.length > OSC_SUPPORT_TYPE) | ||
554 | osc_sb_apei_support_acked = | ||
555 | capbuf_ret[OSC_SUPPORT_TYPE] & OSC_SB_APEI_SUPPORT; | ||
547 | kfree(context.ret.pointer); | 556 | kfree(context.ret.pointer); |
548 | /* do we need to check the returned cap? Sounds no */ | 557 | } |
558 | /* do we need to check other returned cap? Sounds no */ | ||
549 | } | 559 | } |
550 | 560 | ||
551 | /* -------------------------------------------------------------------------- | 561 | /* -------------------------------------------------------------------------- |