Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit a745d774 authored by derfelot's avatar derfelot
Browse files

arm64: process: Add Sony force flush the console on restart

Taken from Sony 47.2.A.10.107 stock kernel
parent f59f70f1
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -979,6 +979,15 @@ config ARM64_LSE_ATOMICS
	  not support these instructions and requires the kernel to be
	  built with binutils >= 2.25.

config ARM64_FLUSH_CONSOLE_ON_RESTART
	bool "Force flush the console on restart"
	help
	  If the console is locked while the system is rebooted, the messages
	  in the temporary logbuffer would not have propogated to all the
	  console drivers. This option forces the console lock to be
	  released if it failed to be acquired, which will cause all the
	  pending messages to be flushed.

endmenu

config ARM64_UAO
+39 −1
Original line number Diff line number Diff line
@@ -17,6 +17,11 @@
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/*
 * NOTE: This file has been modified by Sony Mobile Communications Inc.
 * Modifications are Copyright (c) 2016 Sony Mobile Communications Inc,
 * and licensed under the license of the file.
 */

#include <stdarg.h>

@@ -31,6 +36,7 @@
#include <linux/user.h>
#include <linux/delay.h>
#include <linux/reboot.h>
#include <linux/console.h>
#include <linux/interrupt.h>
#include <linux/kallsyms.h>
#include <linux/init.h>
@@ -64,6 +70,34 @@ unsigned long __stack_chk_guard __read_mostly;
EXPORT_SYMBOL(__stack_chk_guard);
#endif

#ifdef CONFIG_ARM64_FLUSH_CONSOLE_ON_RESTART
void arm_machine_flush_console(void)
{
	printk("\n");
	pr_emerg("Restarting %s\n", linux_banner);
	if (console_trylock()) {
		console_unlock();
		return;
	}

	mdelay(50);

	local_irq_disable();
	if (!console_trylock())
		pr_emerg("arm_restart: Console was locked! Busting\n");
	else
		pr_emerg("arm_restart: Console was locked!\n");
	if (is_console_suspended())
		resume_console();
	else
		console_unlock();
}
#else
void arm_machine_flush_console(void)
{
}
#endif

/*
 * Function pointers to optional machine specific functions
 */
@@ -166,6 +200,10 @@ void machine_restart(char *cmd)
	if (efi_enabled(EFI_RUNTIME_SERVICES))
		efi_reboot(reboot_mode, NULL);

	/* Flush the console to make sure all the relevant messages make it
	 * out to the console drivers */
	arm_machine_flush_console();

	/* Now call the architecture specific reboot code. */
	if (arm_pm_restart)
		arm_pm_restart(reboot_mode, cmd);
@@ -416,7 +454,7 @@ static void entry_task_switch(struct task_struct *next)
/*
 * Thread switching.
 */
struct task_struct *__switch_to(struct task_struct *prev,
__notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev,
				struct task_struct *next)
{
	struct task_struct *last;
+6 −0
Original line number Diff line number Diff line
@@ -10,6 +10,11 @@
 * Changed:
 * 10-Mar-94: Arno Griffioen: Conversion for vt100 emulator port from PC LINUX
 */
/*
 * NOTE: This file has been modified by Sony Mobile Communications Inc.
 * Modifications are Copyright (c) 2016 Sony Mobile Communications Inc,
 * and licensed under the license of the file.
 */

#ifndef _LINUX_CONSOLE_H_
#define _LINUX_CONSOLE_H_ 1
@@ -168,6 +173,7 @@ extern bool console_suspend_enabled;

/* Suspend and resume console messages over PM events */
extern void suspend_console(void);
extern int is_console_suspended(void);
extern void resume_console(void);

int mda_console_init(void);
+12 −0
Original line number Diff line number Diff line
@@ -15,6 +15,11 @@
 * Rewrote bits to get rid of console_lock
 *	01Mar01 Andrew Morton
 */
/*
 * NOTE: This file has been modified by Sony Mobile Communications Inc.
 * Modifications are Copyright (c) 2016 Sony Mobile Communications Inc,
 * and licensed under the license of the file.
 */

#include <linux/kernel.h>
#include <linux/mm.h>
@@ -2121,6 +2126,13 @@ void suspend_console(void)
	up_console_sem();
}

int is_console_suspended(void)
{
	if (!console_suspend_enabled)
		return 0;
	return console_suspended;
}

void resume_console(void)
{
	if (!console_suspend_enabled)