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

Commit 95052fd6 authored by Elliot Berman's avatar Elliot Berman
Browse files

hvc: haven: Prevent tty layer from closing SELF console



If HVC_HAVEN_CONSOLE is set, then kernel may be using the RM console for
printk. Thus, when userspace accesses the "self" console, we should not
be re-opening or closing this console along with userspace. In open
case, it is incorrect to open console when it is already open and may
result in an error from RM. In close case, this could cause printk
messages to be lost.

Change-Id: Ie73cc0d401c9feb45f952a3dcaaf7ec8cbfccbc9
Signed-off-by: default avatarElliot Berman <eberman@codeaurora.org>
parent a65504bf
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -173,6 +173,12 @@ static int hh_hvc_notify_add(struct hvc_struct *hp, int vm_name)
	int ret;
	hh_vmid_t vmid;

#ifdef CONFIG_HVC_HAVEN_CONSOLE
	/* tty layer is opening, but kernel has already opened for printk */
	if (vm_name == HH_SELF_VM)
		return 0;
#endif /* CONFIG_HVC_HAVEN_CONSOLE */

	ret = hh_rm_get_vmid(vm_name, &vmid);
	if (ret) {
		pr_err("%s: hh_rm_get_vmid failed for %d: %d\n", __func__,
@@ -191,6 +197,12 @@ static void hh_hvc_notify_del(struct hvc_struct *hp, int vm_name)
	if (vm_name < 0 || vm_name >= HH_VM_MAX)
		return;

#ifdef CONFIG_HVC_HAVEN_CONSOLE
	/* tty layer is closing, but kernel is still using for printk. */
	if (vm_name == HH_SELF_VM)
		return;
#endif /* CONFIG_HVC_HAVEN_CONSOLE */

	if (cancel_work_sync(&hh_hvc_data[vm_name].put_work)) {
		/* flush the fifo */
		hh_hvc_put_work_fn(&hh_hvc_data[vm_name].put_work);