From owner-svn-src-stable@freebsd.org Tue Jun 26 09:04:26 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DC87A101D0CE; Tue, 26 Jun 2018 09:04:25 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8E16388493; Tue, 26 Jun 2018 09:04:25 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6EC0412338; Tue, 26 Jun 2018 09:04:25 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5Q94PHN091334; Tue, 26 Jun 2018 09:04:25 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5Q94OLa091330; Tue, 26 Jun 2018 09:04:24 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201806260904.w5Q94OLa091330@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 26 Jun 2018 09:04:24 +0000 (UTC) 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 X-SVN-Group: stable-11 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/11/sys: dev/uart kern sys x86/acpica X-SVN-Commit-Revision: 335659 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jun 2018 09:04:26 -0000 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 #include #include +#include #include #include @@ -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