2 * APEI Generic Hardware Error Source support
4 * Generic Hardware Error Source provides a way to report platform
5 * hardware errors (such as that from chipset). It works in so called
6 * "Firmware First" mode, that is, hardware errors are reported to
7 * firmware firstly, then reported to Linux by firmware. This way,
8 * some non-standard hardware error registers or non-standard hardware
9 * link can be checked by firmware to produce more hardware error
10 * information for Linux.
12 * For more information about Generic Hardware Error Source, please
13 * refer to ACPI Specification version 4.0, section 17.3.2.6
15 * Copyright 2010,2011 Intel Corp.
16 * Author: Huang Ying <ying.huang@intel.com>
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License version
20 * 2 as published by the Free Software Foundation;
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include <linux/kernel.h>
33 #include <linux/module.h>
34 #include <linux/init.h>
35 #include <linux/acpi.h>
37 #include <linux/interrupt.h>
38 #include <linux/timer.h>
39 #include <linux/cper.h>
40 #include <linux/kdebug.h>
41 #include <linux/platform_device.h>
42 #include <linux/mutex.h>
43 #include <linux/ratelimit.h>
44 #include <linux/vmalloc.h>
45 #include <linux/irq_work.h>
46 #include <linux/llist.h>
47 #include <linux/genalloc.h>
48 #include <acpi/apei.h>
49 #include <acpi/atomicio.h>
52 #include <asm/tlbflush.h>
54 #include "apei-internal.h"
56 #define GHES_PFX "GHES: "
58 #define GHES_ESTATUS_MAX_SIZE 65536
59 #define GHES_ESOURCE_PREALLOC_MAX_SIZE 65536
61 #define GHES_ESTATUS_POOL_MIN_ALLOC_ORDER 3
63 #define GHES_ESTATUS_NODE_LEN(estatus_len) \
64 (sizeof(struct ghes_estatus_node) + (estatus_len))
65 #define GHES_ESTATUS_FROM_NODE(estatus_node) \
66 ((struct acpi_hest_generic_status *) \
67 ((struct ghes_estatus_node *)(estatus_node) + 1))
70 * One struct ghes is created for each generic hardware error source.
71 * It provides the context for APEI hardware error timer/IRQ/SCI/NMI
74 * estatus: memory buffer for error status block, allocated during
77 #define GHES_TO_CLEAR 0x0001
78 #define GHES_EXITING 0x0002
81 struct acpi_hest_generic *generic;
82 struct acpi_hest_generic_status *estatus;
86 struct list_head list;
87 struct timer_list timer;
92 struct ghes_estatus_node {
93 struct llist_node llnode;
94 struct acpi_hest_generic *generic;
98 module_param_named(disable, ghes_disable, bool, 0);
100 static int ghes_panic_timeout __read_mostly = 30;
103 * All error sources notified with SCI shares one notifier function,
104 * so they need to be linked and checked one by one. This is applied
107 * RCU is used for these lists, so ghes_list_mutex is only used for
108 * list changing, not for traversing.
110 static LIST_HEAD(ghes_sci);
111 static LIST_HEAD(ghes_nmi);
112 static DEFINE_MUTEX(ghes_list_mutex);
115 * NMI may be triggered on any CPU, so ghes_nmi_lock is used for
118 static DEFINE_RAW_SPINLOCK(ghes_nmi_lock);
121 * Because the memory area used to transfer hardware error information
122 * from BIOS to Linux can be determined only in NMI, IRQ or timer
123 * handler, but general ioremap can not be used in atomic context, so
124 * a special version of atomic ioremap is implemented for that.
128 * Two virtual pages are used, one for NMI context, the other for
129 * IRQ/PROCESS context
131 #define GHES_IOREMAP_PAGES 2
132 #define GHES_IOREMAP_NMI_PAGE(base) (base)
133 #define GHES_IOREMAP_IRQ_PAGE(base) ((base) + PAGE_SIZE)
135 /* virtual memory area for atomic ioremap */
136 static struct vm_struct *ghes_ioremap_area;
138 * These 2 spinlock is used to prevent atomic ioremap virtual memory
139 * area from being mapped simultaneously.
141 static DEFINE_RAW_SPINLOCK(ghes_ioremap_lock_nmi);
142 static DEFINE_SPINLOCK(ghes_ioremap_lock_irq);
145 * printk is not safe in NMI context. So in NMI handler, we allocate
146 * required memory from lock-less memory allocator
147 * (ghes_estatus_pool), save estatus into it, put them into lock-less
148 * list (ghes_estatus_llist), then delay printk into IRQ context via
149 * irq_work (ghes_proc_irq_work). ghes_estatus_size_request record
150 * required pool size by all NMI error source.
152 static struct gen_pool *ghes_estatus_pool;
153 static unsigned long ghes_estatus_pool_size_request;
154 static struct llist_head ghes_estatus_llist;
155 static struct irq_work ghes_proc_irq_work;
157 static int ghes_ioremap_init(void)
159 ghes_ioremap_area = __get_vm_area(PAGE_SIZE * GHES_IOREMAP_PAGES,
160 VM_IOREMAP, VMALLOC_START, VMALLOC_END);
161 if (!ghes_ioremap_area) {
162 pr_err(GHES_PFX "Failed to allocate virtual memory area for atomic ioremap.\n");
169 static void ghes_ioremap_exit(void)
171 free_vm_area(ghes_ioremap_area);
174 static void __iomem *ghes_ioremap_pfn_nmi(u64 pfn)
178 vaddr = (unsigned long)GHES_IOREMAP_NMI_PAGE(ghes_ioremap_area->addr);
179 ioremap_page_range(vaddr, vaddr + PAGE_SIZE,
180 pfn << PAGE_SHIFT, PAGE_KERNEL);
182 return (void __iomem *)vaddr;
185 static void __iomem *ghes_ioremap_pfn_irq(u64 pfn)
189 vaddr = (unsigned long)GHES_IOREMAP_IRQ_PAGE(ghes_ioremap_area->addr);
190 ioremap_page_range(vaddr, vaddr + PAGE_SIZE,
191 pfn << PAGE_SHIFT, PAGE_KERNEL);
193 return (void __iomem *)vaddr;
196 static void ghes_iounmap_nmi(void __iomem *vaddr_ptr)
198 unsigned long vaddr = (unsigned long __force)vaddr_ptr;
199 void *base = ghes_ioremap_area->addr;
201 BUG_ON(vaddr != (unsigned long)GHES_IOREMAP_NMI_PAGE(base));
202 unmap_kernel_range_noflush(vaddr, PAGE_SIZE);
203 __flush_tlb_one(vaddr);
206 static void ghes_iounmap_irq(void __iomem *vaddr_ptr)
208 unsigned long vaddr = (unsigned long __force)vaddr_ptr;
209 void *base = ghes_ioremap_area->addr;
211 BUG_ON(vaddr != (unsigned long)GHES_IOREMAP_IRQ_PAGE(base));
212 unmap_kernel_range_noflush(vaddr, PAGE_SIZE);
213 __flush_tlb_one(vaddr);
216 static int ghes_estatus_pool_init(void)
218 ghes_estatus_pool = gen_pool_create(GHES_ESTATUS_POOL_MIN_ALLOC_ORDER, -1);
219 if (!ghes_estatus_pool)
224 static void ghes_estatus_pool_free_chunk_page(struct gen_pool *pool,
225 struct gen_pool_chunk *chunk,
228 free_page(chunk->start_addr);
231 static void ghes_estatus_pool_exit(void)
233 gen_pool_for_each_chunk(ghes_estatus_pool,
234 ghes_estatus_pool_free_chunk_page, NULL);
235 gen_pool_destroy(ghes_estatus_pool);
238 static int ghes_estatus_pool_expand(unsigned long len)
240 unsigned long i, pages, size, addr;
243 ghes_estatus_pool_size_request += PAGE_ALIGN(len);
244 size = gen_pool_size(ghes_estatus_pool);
245 if (size >= ghes_estatus_pool_size_request)
247 pages = (ghes_estatus_pool_size_request - size) / PAGE_SIZE;
248 for (i = 0; i < pages; i++) {
249 addr = __get_free_page(GFP_KERNEL);
252 ret = gen_pool_add(ghes_estatus_pool, addr, PAGE_SIZE, -1);
260 static void ghes_estatus_pool_shrink(unsigned long len)
262 ghes_estatus_pool_size_request -= PAGE_ALIGN(len);
265 static struct ghes *ghes_new(struct acpi_hest_generic *generic)
268 unsigned int error_block_length;
271 ghes = kzalloc(sizeof(*ghes), GFP_KERNEL);
273 return ERR_PTR(-ENOMEM);
274 ghes->generic = generic;
275 rc = acpi_pre_map_gar(&generic->error_status_address);
278 error_block_length = generic->error_block_length;
279 if (error_block_length > GHES_ESTATUS_MAX_SIZE) {
280 pr_warning(FW_WARN GHES_PFX
281 "Error status block length is too long: %u for "
282 "generic hardware error source: %d.\n",
283 error_block_length, generic->header.source_id);
284 error_block_length = GHES_ESTATUS_MAX_SIZE;
286 ghes->estatus = kmalloc(error_block_length, GFP_KERNEL);
287 if (!ghes->estatus) {
295 acpi_post_unmap_gar(&generic->error_status_address);
301 static void ghes_fini(struct ghes *ghes)
303 kfree(ghes->estatus);
304 acpi_post_unmap_gar(&ghes->generic->error_status_address);
309 GHES_SEV_CORRECTED = 0x1,
310 GHES_SEV_RECOVERABLE = 0x2,
311 GHES_SEV_PANIC = 0x3,
314 static inline int ghes_severity(int severity)
317 case CPER_SEV_INFORMATIONAL:
319 case CPER_SEV_CORRECTED:
320 return GHES_SEV_CORRECTED;
321 case CPER_SEV_RECOVERABLE:
322 return GHES_SEV_RECOVERABLE;
324 return GHES_SEV_PANIC;
326 /* Unknown, go panic */
327 return GHES_SEV_PANIC;
331 static void ghes_copy_tofrom_phys(void *buffer, u64 paddr, u32 len,
335 unsigned long flags = 0;
336 int in_nmi = in_nmi();
341 offset = paddr - (paddr & PAGE_MASK);
343 raw_spin_lock(&ghes_ioremap_lock_nmi);
344 vaddr = ghes_ioremap_pfn_nmi(paddr >> PAGE_SHIFT);
346 spin_lock_irqsave(&ghes_ioremap_lock_irq, flags);
347 vaddr = ghes_ioremap_pfn_irq(paddr >> PAGE_SHIFT);
349 trunk = PAGE_SIZE - offset;
350 trunk = min(trunk, len);
352 memcpy_fromio(buffer, vaddr + offset, trunk);
354 memcpy_toio(vaddr + offset, buffer, trunk);
359 ghes_iounmap_nmi(vaddr);
360 raw_spin_unlock(&ghes_ioremap_lock_nmi);
362 ghes_iounmap_irq(vaddr);
363 spin_unlock_irqrestore(&ghes_ioremap_lock_irq, flags);
368 static int ghes_read_estatus(struct ghes *ghes, int silent)
370 struct acpi_hest_generic *g = ghes->generic;
375 rc = acpi_atomic_read(&buf_paddr, &g->error_status_address);
377 if (!silent && printk_ratelimit())
378 pr_warning(FW_WARN GHES_PFX
379 "Failed to read error status block address for hardware error source: %d.\n",
380 g->header.source_id);
386 ghes_copy_tofrom_phys(ghes->estatus, buf_paddr,
387 sizeof(*ghes->estatus), 1);
388 if (!ghes->estatus->block_status)
391 ghes->buffer_paddr = buf_paddr;
392 ghes->flags |= GHES_TO_CLEAR;
395 len = apei_estatus_len(ghes->estatus);
396 if (len < sizeof(*ghes->estatus))
398 if (len > ghes->generic->error_block_length)
400 if (apei_estatus_check_header(ghes->estatus))
402 ghes_copy_tofrom_phys(ghes->estatus + 1,
403 buf_paddr + sizeof(*ghes->estatus),
404 len - sizeof(*ghes->estatus), 1);
405 if (apei_estatus_check(ghes->estatus))
410 if (rc && !silent && printk_ratelimit())
411 pr_warning(FW_WARN GHES_PFX
412 "Failed to read error status block!\n");
416 static void ghes_clear_estatus(struct ghes *ghes)
418 ghes->estatus->block_status = 0;
419 if (!(ghes->flags & GHES_TO_CLEAR))
421 ghes_copy_tofrom_phys(ghes->estatus, ghes->buffer_paddr,
422 sizeof(ghes->estatus->block_status), 0);
423 ghes->flags &= ~GHES_TO_CLEAR;
426 static void ghes_do_proc(const struct acpi_hest_generic_status *estatus)
428 int sev, processed = 0;
429 struct acpi_hest_generic_data *gdata;
431 sev = ghes_severity(estatus->error_severity);
432 apei_estatus_for_each_section(estatus, gdata) {
433 #ifdef CONFIG_X86_MCE
434 if (!uuid_le_cmp(*(uuid_le *)gdata->section_type,
435 CPER_SEC_PLATFORM_MEM)) {
436 apei_mce_report_mem_error(
437 sev == GHES_SEV_CORRECTED,
438 (struct cper_sec_mem_err *)(gdata+1));
445 static void __ghes_print_estatus(const char *pfx,
446 const struct acpi_hest_generic *generic,
447 const struct acpi_hest_generic_status *estatus)
450 if (ghes_severity(estatus->error_severity) <=
452 pfx = KERN_WARNING HW_ERR;
454 pfx = KERN_ERR HW_ERR;
456 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
457 pfx, generic->header.source_id);
458 apei_estatus_print(pfx, estatus);
461 static void ghes_print_estatus(const char *pfx,
462 const struct acpi_hest_generic *generic,
463 const struct acpi_hest_generic_status *estatus)
465 /* Not more than 2 messages every 5 seconds */
466 static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2);
467 static DEFINE_RATELIMIT_STATE(ratelimit_uncorrected, 5*HZ, 2);
468 struct ratelimit_state *ratelimit;
470 if (ghes_severity(estatus->error_severity) <= GHES_SEV_CORRECTED)
471 ratelimit = &ratelimit_corrected;
473 ratelimit = &ratelimit_uncorrected;
474 if (__ratelimit(ratelimit))
475 __ghes_print_estatus(pfx, generic, estatus);
478 static int ghes_proc(struct ghes *ghes)
482 rc = ghes_read_estatus(ghes, 0);
485 ghes_print_estatus(NULL, ghes->generic, ghes->estatus);
486 ghes_do_proc(ghes->estatus);
489 ghes_clear_estatus(ghes);
493 static void ghes_add_timer(struct ghes *ghes)
495 struct acpi_hest_generic *g = ghes->generic;
496 unsigned long expire;
498 if (!g->notify.poll_interval) {
499 pr_warning(FW_WARN GHES_PFX "Poll interval is 0 for generic hardware error source: %d, disabled.\n",
500 g->header.source_id);
503 expire = jiffies + msecs_to_jiffies(g->notify.poll_interval);
504 ghes->timer.expires = round_jiffies_relative(expire);
505 add_timer(&ghes->timer);
508 static void ghes_poll_func(unsigned long data)
510 struct ghes *ghes = (void *)data;
513 if (!(ghes->flags & GHES_EXITING))
514 ghes_add_timer(ghes);
517 static irqreturn_t ghes_irq_func(int irq, void *data)
519 struct ghes *ghes = data;
522 rc = ghes_proc(ghes);
529 static int ghes_notify_sci(struct notifier_block *this,
530 unsigned long event, void *data)
533 int ret = NOTIFY_DONE;
536 list_for_each_entry_rcu(ghes, &ghes_sci, list) {
537 if (!ghes_proc(ghes))
545 static void ghes_proc_in_irq(struct irq_work *irq_work)
547 struct llist_node *llnode, *next, *tail = NULL;
548 struct ghes_estatus_node *estatus_node;
549 struct acpi_hest_generic_status *estatus;
553 * Because the time order of estatus in list is reversed,
554 * revert it back to proper order.
556 llnode = llist_del_all(&ghes_estatus_llist);
566 estatus_node = llist_entry(llnode, struct ghes_estatus_node,
568 estatus = GHES_ESTATUS_FROM_NODE(estatus_node);
569 len = apei_estatus_len(estatus);
570 node_len = GHES_ESTATUS_NODE_LEN(len);
571 ghes_do_proc(estatus);
572 ghes_print_estatus(NULL, estatus_node->generic, estatus);
573 gen_pool_free(ghes_estatus_pool, (unsigned long)estatus_node,
579 static int ghes_notify_nmi(struct notifier_block *this,
580 unsigned long cmd, void *data)
582 struct ghes *ghes, *ghes_global = NULL;
583 int sev, sev_global = -1;
584 int ret = NOTIFY_DONE;
589 raw_spin_lock(&ghes_nmi_lock);
590 list_for_each_entry_rcu(ghes, &ghes_nmi, list) {
591 if (ghes_read_estatus(ghes, 1)) {
592 ghes_clear_estatus(ghes);
595 sev = ghes_severity(ghes->estatus->error_severity);
596 if (sev > sev_global) {
603 if (ret == NOTIFY_DONE)
606 if (sev_global >= GHES_SEV_PANIC) {
608 __ghes_print_estatus(KERN_EMERG HW_ERR, ghes_global->generic,
609 ghes_global->estatus);
610 /* reboot to log the error! */
611 if (panic_timeout == 0)
612 panic_timeout = ghes_panic_timeout;
613 panic("Fatal hardware error!");
616 list_for_each_entry_rcu(ghes, &ghes_nmi, list) {
617 #ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG
619 struct ghes_estatus_node *estatus_node;
620 struct acpi_hest_generic_status *estatus;
622 if (!(ghes->flags & GHES_TO_CLEAR))
624 #ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG
625 /* Save estatus for further processing in IRQ context */
626 len = apei_estatus_len(ghes->estatus);
627 node_len = GHES_ESTATUS_NODE_LEN(len);
628 estatus_node = (void *)gen_pool_alloc(ghes_estatus_pool,
631 estatus_node->generic = ghes->generic;
632 estatus = GHES_ESTATUS_FROM_NODE(estatus_node);
633 memcpy(estatus, ghes->estatus, len);
634 llist_add(&estatus_node->llnode, &ghes_estatus_llist);
637 ghes_clear_estatus(ghes);
639 #ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG
640 irq_work_queue(&ghes_proc_irq_work);
644 raw_spin_unlock(&ghes_nmi_lock);
648 static struct notifier_block ghes_notifier_sci = {
649 .notifier_call = ghes_notify_sci,
652 static struct notifier_block ghes_notifier_nmi = {
653 .notifier_call = ghes_notify_nmi,
656 static unsigned long ghes_esource_prealloc_size(
657 const struct acpi_hest_generic *generic)
659 unsigned long block_length, prealloc_records, prealloc_size;
661 block_length = min_t(unsigned long, generic->error_block_length,
662 GHES_ESTATUS_MAX_SIZE);
663 prealloc_records = max_t(unsigned long,
664 generic->records_to_preallocate, 1);
665 prealloc_size = min_t(unsigned long, block_length * prealloc_records,
666 GHES_ESOURCE_PREALLOC_MAX_SIZE);
668 return prealloc_size;
671 static int __devinit ghes_probe(struct platform_device *ghes_dev)
673 struct acpi_hest_generic *generic;
674 struct ghes *ghes = NULL;
678 generic = *(struct acpi_hest_generic **)ghes_dev->dev.platform_data;
679 if (!generic->enabled)
682 switch (generic->notify.type) {
683 case ACPI_HEST_NOTIFY_POLLED:
684 case ACPI_HEST_NOTIFY_EXTERNAL:
685 case ACPI_HEST_NOTIFY_SCI:
686 case ACPI_HEST_NOTIFY_NMI:
688 case ACPI_HEST_NOTIFY_LOCAL:
689 pr_warning(GHES_PFX "Generic hardware error source: %d notified via local interrupt is not supported!\n",
690 generic->header.source_id);
693 pr_warning(FW_WARN GHES_PFX "Unknown notification type: %u for generic hardware error source: %d\n",
694 generic->notify.type, generic->header.source_id);
699 if (generic->error_block_length <
700 sizeof(struct acpi_hest_generic_status)) {
701 pr_warning(FW_BUG GHES_PFX "Invalid error block length: %u for generic hardware error source: %d\n",
702 generic->error_block_length,
703 generic->header.source_id);
706 ghes = ghes_new(generic);
712 switch (generic->notify.type) {
713 case ACPI_HEST_NOTIFY_POLLED:
714 ghes->timer.function = ghes_poll_func;
715 ghes->timer.data = (unsigned long)ghes;
716 init_timer_deferrable(&ghes->timer);
717 ghes_add_timer(ghes);
719 case ACPI_HEST_NOTIFY_EXTERNAL:
720 /* External interrupt vector is GSI */
721 if (acpi_gsi_to_irq(generic->notify.vector, &ghes->irq)) {
722 pr_err(GHES_PFX "Failed to map GSI to IRQ for generic hardware error source: %d\n",
723 generic->header.source_id);
726 if (request_irq(ghes->irq, ghes_irq_func,
727 0, "GHES IRQ", ghes)) {
728 pr_err(GHES_PFX "Failed to register IRQ for generic hardware error source: %d\n",
729 generic->header.source_id);
733 case ACPI_HEST_NOTIFY_SCI:
734 mutex_lock(&ghes_list_mutex);
735 if (list_empty(&ghes_sci))
736 register_acpi_hed_notifier(&ghes_notifier_sci);
737 list_add_rcu(&ghes->list, &ghes_sci);
738 mutex_unlock(&ghes_list_mutex);
740 case ACPI_HEST_NOTIFY_NMI:
741 len = ghes_esource_prealloc_size(generic);
742 ghes_estatus_pool_expand(len);
743 mutex_lock(&ghes_list_mutex);
744 if (list_empty(&ghes_nmi))
745 register_die_notifier(&ghes_notifier_nmi);
746 list_add_rcu(&ghes->list, &ghes_nmi);
747 mutex_unlock(&ghes_list_mutex);
752 platform_set_drvdata(ghes_dev, ghes);
763 static int __devexit ghes_remove(struct platform_device *ghes_dev)
766 struct acpi_hest_generic *generic;
769 ghes = platform_get_drvdata(ghes_dev);
770 generic = ghes->generic;
772 ghes->flags |= GHES_EXITING;
773 switch (generic->notify.type) {
774 case ACPI_HEST_NOTIFY_POLLED:
775 del_timer_sync(&ghes->timer);
777 case ACPI_HEST_NOTIFY_EXTERNAL:
778 free_irq(ghes->irq, ghes);
780 case ACPI_HEST_NOTIFY_SCI:
781 mutex_lock(&ghes_list_mutex);
782 list_del_rcu(&ghes->list);
783 if (list_empty(&ghes_sci))
784 unregister_acpi_hed_notifier(&ghes_notifier_sci);
785 mutex_unlock(&ghes_list_mutex);
787 case ACPI_HEST_NOTIFY_NMI:
788 mutex_lock(&ghes_list_mutex);
789 list_del_rcu(&ghes->list);
790 if (list_empty(&ghes_nmi))
791 unregister_die_notifier(&ghes_notifier_nmi);
792 mutex_unlock(&ghes_list_mutex);
794 * To synchronize with NMI handler, ghes can only be
795 * freed after NMI handler finishes.
798 len = ghes_esource_prealloc_size(generic);
799 ghes_estatus_pool_shrink(len);
809 platform_set_drvdata(ghes_dev, NULL);
814 static struct platform_driver ghes_platform_driver = {
817 .owner = THIS_MODULE,
820 .remove = ghes_remove,
823 static int __init ghes_init(void)
831 pr_info(GHES_PFX "HEST is not enabled!\n");
836 pr_info(GHES_PFX "GHES is not enabled!\n");
840 init_irq_work(&ghes_proc_irq_work, ghes_proc_in_irq);
842 rc = ghes_ioremap_init();
846 rc = ghes_estatus_pool_init();
848 goto err_ioremap_exit;
850 rc = platform_driver_register(&ghes_platform_driver);
854 rc = apei_osc_setup();
855 if (rc == 0 && osc_sb_apei_support_acked)
856 pr_info(GHES_PFX "APEI firmware first mode is enabled by APEI bit and WHEA _OSC.\n");
857 else if (rc == 0 && !osc_sb_apei_support_acked)
858 pr_info(GHES_PFX "APEI firmware first mode is enabled by WHEA _OSC.\n");
859 else if (rc && osc_sb_apei_support_acked)
860 pr_info(GHES_PFX "APEI firmware first mode is enabled by APEI bit.\n");
862 pr_info(GHES_PFX "Failed to enable APEI firmware first mode.\n");
866 ghes_estatus_pool_exit();
873 static void __exit ghes_exit(void)
875 platform_driver_unregister(&ghes_platform_driver);
876 ghes_estatus_pool_exit();
880 module_init(ghes_init);
881 module_exit(ghes_exit);
883 MODULE_AUTHOR("Huang Ying");
884 MODULE_DESCRIPTION("APEI Generic Hardware Error Source support");
885 MODULE_LICENSE("GPL");
886 MODULE_ALIAS("platform:GHES");