WIP FPC-III support
[linux/fpc-iii.git] / arch / powerpc / platforms / powernv / opal-kmsg.c
blob6c3bc4b4da9834966f7fd19eb28454ac33988b9e
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * kmsg dumper that ensures the OPAL console fully flushes panic messages
5 * Author: Russell Currey <ruscur@russell.cc>
7 * Copyright 2015 IBM Corporation.
8 */
10 #include <linux/kmsg_dump.h>
12 #include <asm/opal.h>
13 #include <asm/opal-api.h>
16 * Console output is controlled by OPAL firmware. The kernel regularly calls
17 * OPAL_POLL_EVENTS, which flushes some console output. In a panic state,
18 * however, the kernel no longer calls OPAL_POLL_EVENTS and the panic message
19 * may not be completely printed. This function does not actually dump the
20 * message, it just ensures that OPAL completely flushes the console buffer.
22 static void kmsg_dump_opal_console_flush(struct kmsg_dumper *dumper,
23 enum kmsg_dump_reason reason)
26 * Outside of a panic context the pollers will continue to run,
27 * so we don't need to do any special flushing.
29 if (reason != KMSG_DUMP_PANIC)
30 return;
32 opal_flush_console(0);
35 static struct kmsg_dumper opal_kmsg_dumper = {
36 .dump = kmsg_dump_opal_console_flush
39 void __init opal_kmsg_init(void)
41 int rc;
43 /* Add our dumper to the list */
44 rc = kmsg_dump_register(&opal_kmsg_dumper);
45 if (rc != 0)
46 pr_err("opal: kmsg_dump_register failed; returned %d\n", rc);