Commit 15d260b3 authored by Jim Keniston's avatar Jim Keniston Committed by Benjamin Herrenschmidt
Browse files

powerpc/nvram: Don't overwrite oops/panic report on normal shutdown



For normal halt, reboot, and poweroff events, refrain from overwriting
the lnx,oops-log partition.  Also, don't save the dmesg buffer on an
emergency-restart event if we've already saved it earlier in panic().

Signed-off-by: default avatarJim Keniston <jkenisto@us.ibm.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent ff56535d
Loading
Loading
Loading
Loading
+24 −0
Original line number Original line Diff line number Diff line
@@ -480,8 +480,32 @@ static void oops_to_nvram(struct kmsg_dumper *dumper,
		const char *new_msgs, unsigned long new_len)
		const char *new_msgs, unsigned long new_len)
{
{
	static unsigned int oops_count = 0;
	static unsigned int oops_count = 0;
	static bool panicking = false;
	size_t text_len;
	size_t text_len;


	switch (reason) {
	case KMSG_DUMP_RESTART:
	case KMSG_DUMP_HALT:
	case KMSG_DUMP_POWEROFF:
		/* These are almost always orderly shutdowns. */
		return;
	case KMSG_DUMP_OOPS:
	case KMSG_DUMP_KEXEC:
		break;
	case KMSG_DUMP_PANIC:
		panicking = true;
		break;
	case KMSG_DUMP_EMERG:
		if (panicking)
			/* Panic report already captured. */
			return;
		break;
	default:
		pr_err("%s: ignoring unrecognized KMSG_DUMP_* reason %d\n",
						__FUNCTION__, (int) reason);
		return;
	}

	if (clobbering_unread_rtas_event())
	if (clobbering_unread_rtas_event())
		return;
		return;