Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jun 2018 09:04:24 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r335659 - in stable/11/sys: dev/uart kern sys x86/acpica
Message-ID:  <201806260904.w5Q94OLa091330@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Tue Jun 26 09:04:24 2018
New Revision: 335659
URL: https://svnweb.freebsd.org/changeset/base/335659

Log:
  MFC r334340: add support for console resuming, implement it for uart, use on x86

Modified:
  stable/11/sys/dev/uart/uart_tty.c
  stable/11/sys/kern/kern_cons.c
  stable/11/sys/sys/cons.h
  stable/11/sys/x86/acpica/acpi_wakeup.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/uart/uart_tty.c
==============================================================================
--- stable/11/sys/dev/uart/uart_tty.c	Tue Jun 26 08:56:34 2018	(r335658)
+++ stable/11/sys/dev/uart/uart_tty.c	Tue Jun 26 09:04:24 2018	(r335659)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
 
 static cn_probe_t uart_cnprobe;
 static cn_init_t uart_cninit;
+static cn_init_t uart_cnresume;
 static cn_term_t uart_cnterm;
 static cn_getc_t uart_cngetc;
 static cn_putc_t uart_cnputc;
@@ -67,7 +68,10 @@ static tsw_modem_t uart_tty_modem;
 static tsw_free_t uart_tty_free;
 static tsw_busy_t uart_tty_busy;
 
-CONSOLE_DRIVER(uart);
+CONSOLE_DRIVER(
+	uart,
+	.cn_resume = uart_cnresume,
+);
 
 static struct uart_devinfo uart_console;
 
@@ -110,6 +114,13 @@ uart_cninit(struct consdev *cp)
 	di->type = UART_DEV_CONSOLE;
 	uart_add_sysdev(di);
 	uart_init(di);
+}
+
+static void
+uart_cnresume(struct consdev *cp)
+{
+
+	uart_init(cp->cn_arg);
 }
 
 static void

Modified: stable/11/sys/kern/kern_cons.c
==============================================================================
--- stable/11/sys/kern/kern_cons.c	Tue Jun 26 08:56:34 2018	(r335658)
+++ stable/11/sys/kern/kern_cons.c	Tue Jun 26 09:04:24 2018	(r335659)
@@ -382,6 +382,19 @@ cnungrab()
 	}
 }
 
+void
+cnresume()
+{
+	struct cn_device *cnd;
+	struct consdev *cn;
+
+	STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) {
+		cn = cnd->cnd_cn;
+		if (cn->cn_ops->cn_resume != NULL)
+			cn->cn_ops->cn_resume(cn);
+	}
+}
+
 /*
  * Low level console routines.
  */

Modified: stable/11/sys/sys/cons.h
==============================================================================
--- stable/11/sys/sys/cons.h	Tue Jun 26 08:56:34 2018	(r335658)
+++ stable/11/sys/sys/cons.h	Tue Jun 26 09:04:24 2018	(r335659)
@@ -64,6 +64,8 @@ struct consdev_ops {
 				/* grab console for exclusive kernel use */
 	cn_ungrab_t	*cn_ungrab;
 				/* ungrab console */
+	cn_init_t	*cn_resume;
+				/* set up console after sleep, optional */
 };
 
 struct consdev {
@@ -103,8 +105,9 @@ extern	struct tty *constty;	/* Temporary virtual conso
 	};								\
 	DATA_SET(cons_set, name)
 
-#define	CONSOLE_DRIVER(name)						\
+#define	CONSOLE_DRIVER(name, ...)					\
 	static const struct consdev_ops name##_consdev_ops = {		\
+		/* Mandatory methods. */				\
 		.cn_probe = name##_cnprobe,				\
 		.cn_init = name##_cninit,				\
 		.cn_term = name##_cnterm,				\
@@ -112,6 +115,8 @@ extern	struct tty *constty;	/* Temporary virtual conso
 		.cn_putc = name##_cnputc,				\
 		.cn_grab = name##_cngrab,				\
 		.cn_ungrab = name##_cnungrab,				\
+		/* Optional fields. */					\
+		__VA_ARGS__						\
 	};								\
 	CONSOLE_DEVICE(name##_consdev, name##_consdev_ops, NULL)
 
@@ -124,6 +129,7 @@ void	cnremove(struct consdev *);
 void	cnselect(struct consdev *);
 void	cngrab(void);
 void	cnungrab(void);
+void	cnresume(void);
 int	cncheckc(void);
 int	cngetc(void);
 void	cngets(char *, size_t, int);

Modified: stable/11/sys/x86/acpica/acpi_wakeup.c
==============================================================================
--- stable/11/sys/x86/acpica/acpi_wakeup.c	Tue Jun 26 08:56:34 2018	(r335658)
+++ stable/11/sys/x86/acpica/acpi_wakeup.c	Tue Jun 26 09:04:24 2018	(r335659)
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/memrange.h>
 #include <sys/smp.h>
 #include <sys/systm.h>
+#include <sys/cons.h>
 
 #include <vm/vm.h>
 #include <vm/pmap.h>
@@ -265,6 +266,12 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state)
 		for (;;)
 			ia32_pause();
 	} else {
+		/*
+		 * Re-initialize console hardware as soon as possibe.
+		 * No console output (e.g. printf) is allowed before
+		 * this point.
+		 */
+		cnresume();
 #ifdef __amd64__
 		fpuresume(susppcbs[0]->sp_fpususpend);
 #else



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806260904.w5Q94OLa091330>