From owner-svn-src-head@freebsd.org Mon May 21 20:23:05 2018 Return-Path: Delivered-To: svn-src-head@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 72443EFD835; Mon, 21 May 2018 20:23:05 +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 1F9C86EC9A; Mon, 21 May 2018 20:23:05 +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 DB5861BE8; Mon, 21 May 2018 20:23:04 +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 w4LKN4Ia086420; Mon, 21 May 2018 20:23:04 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w4LKN4vj086415; Mon, 21 May 2018 20:23:04 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201805212023.w4LKN4vj086415@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Mon, 21 May 2018 20:23:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333994 - in head/sys: dev/acpica kern sys X-SVN-Group: head X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in head/sys: dev/acpica kern sys X-SVN-Commit-Revision: 333994 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 May 2018 20:23:05 -0000 Author: avg Date: Mon May 21 20:23:04 2018 New Revision: 333994 URL: https://svnweb.freebsd.org/changeset/base/333994 Log: stop and restart kernel event timers in the suspend / resume cycle I have a system that is very unstable after resuming from suspend-to-RAM but only if HPET is used as the event timer. The theory is that SMM code / firmware could be enabling HPET for its own uses and unexpected interrupts cause a trouble for it. Originally I wanted to solve the problem in hpet_suspend() method, but that was insufficient as the event timer could get reprogrammed again. So, it's better, for my case and in general, to stop the event timer(s) before entering the hardware suspend. MFC after: 4 weeks Differential Revision: https://reviews.freebsd.org/D15413 Modified: head/sys/dev/acpica/acpi.c head/sys/kern/kern_clocksource.c head/sys/sys/systm.h Modified: head/sys/dev/acpica/acpi.c ============================================================================== --- head/sys/dev/acpica/acpi.c Mon May 21 20:20:28 2018 (r333993) +++ head/sys/dev/acpica/acpi.c Mon May 21 20:23:04 2018 (r333994) @@ -2958,6 +2958,7 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state) if (sc->acpi_sleep_delay > 0) DELAY(sc->acpi_sleep_delay * 1000000); + suspendclock(); intr = intr_disable(); if (state != ACPI_STATE_S1) { sleep_result = acpi_sleep_machdep(sc, state); @@ -3028,6 +3029,8 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state) * process. This handles both the error and success cases. */ backout: + if (slp_state >= ACPI_SS_SLP_PREP) + resumeclock(); if (slp_state >= ACPI_SS_GPE_SET) { acpi_wake_prep_walk(state); sc->acpi_sstate = ACPI_STATE_S0; Modified: head/sys/kern/kern_clocksource.c ============================================================================== --- head/sys/kern/kern_clocksource.c Mon May 21 20:20:28 2018 (r333993) +++ head/sys/kern/kern_clocksource.c Mon May 21 20:23:04 2018 (r333994) @@ -698,6 +698,22 @@ cpu_initclocks_ap(void) spinlock_exit(); } +void +suspendclock(void) +{ + ET_LOCK(); + configtimer(0); + ET_UNLOCK(); +} + +void +resumeclock(void) +{ + ET_LOCK(); + configtimer(1); + ET_UNLOCK(); +} + /* * Switch to profiling clock rates. */ Modified: head/sys/sys/systm.h ============================================================================== --- head/sys/sys/systm.h Mon May 21 20:20:28 2018 (r333993) +++ head/sys/sys/systm.h Mon May 21 20:23:04 2018 (r333994) @@ -333,6 +333,8 @@ void startprofclock(struct proc *); void stopprofclock(struct proc *); void cpu_startprofclock(void); void cpu_stopprofclock(void); +void suspendclock(void); +void resumeclock(void); sbintime_t cpu_idleclock(void); void cpu_activeclock(void); void cpu_new_callout(int cpu, sbintime_t bt, sbintime_t bt_opt);