From owner-svn-src-head@freebsd.org Tue Mar 13 09:42:34 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 6531CF334FD; Tue, 13 Mar 2018 09:42:34 +0000 (UTC) (envelope-from royger@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 17673736DF; Tue, 13 Mar 2018 09:42:34 +0000 (UTC) (envelope-from royger@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 12383184FF; Tue, 13 Mar 2018 09:42:34 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2D9gXXY003965; Tue, 13 Mar 2018 09:42:33 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2D9gXhn003963; Tue, 13 Mar 2018 09:42:33 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201803130942.w2D9gXhn003963@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Tue, 13 Mar 2018 09:42:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330835 - in head: share/man/man4 sys/x86/isa X-SVN-Group: head X-SVN-Commit-Author: royger X-SVN-Commit-Paths: in head: share/man/man4 sys/x86/isa X-SVN-Commit-Revision: 330835 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.25 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: Tue, 13 Mar 2018 09:42:34 -0000 Author: royger Date: Tue Mar 13 09:42:33 2018 New Revision: 330835 URL: https://svnweb.freebsd.org/changeset/base/330835 Log: at_rtc: check in ACPI FADT boot flags if the RTC is present Or else disable the device. Note that the detection can be bypassed by setting the hw.atrtc.enable option in the loader configuration file. More information can be found on atrtc(4). Sponsored by: Citrix Systems R&D Reviewed by: ian Differential revision: https://reviews.freebsd.org/D14399 Modified: head/share/man/man4/atrtc.4 head/sys/x86/isa/atrtc.c Modified: head/share/man/man4/atrtc.4 ============================================================================== --- head/share/man/man4/atrtc.4 Tue Mar 13 09:38:53 2018 (r330834) +++ head/share/man/man4/atrtc.4 Tue Mar 13 09:42:33 2018 (r330835) @@ -33,13 +33,18 @@ .Sh SYNOPSIS This driver is a mandatory part of i386/amd64 kernels. .Pp -The following tunable is settable from the +The following tunables are settable from the .Xr loader 8 : .Bl -ohang .It Va hint.atrtc. Ns Ar X Ns Va .clock controls event timers functionality support. Setting to 0, disables it. Default value is 1. +.It Va hw.atrtc.enable +Forces enabling or disabling of the device(s). +Setting to 0 disables it, setting to 1 enables it, bypassing any platform +configuration hints. +Default value is -1 (autodetect). .El .Sh DESCRIPTION This driver uses RTC hardware to supply kernel with time-of-day clock Modified: head/sys/x86/isa/atrtc.c ============================================================================== --- head/sys/x86/isa/atrtc.c Tue Mar 13 09:38:53 2018 (r330834) +++ head/sys/x86/isa/atrtc.c Tue Mar 13 09:42:33 2018 (r330835) @@ -32,6 +32,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_acpi.h" #include "opt_isa.h" #include @@ -55,6 +56,10 @@ __FBSDID("$FreeBSD$"); #include #include "clock_if.h" +#ifdef DEV_ACPI +#include +#endif + /* * atrtc_lock protects low-level access to individual hardware registers. * atrtc_time_lock protects the entire sequence of accessing multiple registers @@ -63,6 +68,10 @@ __FBSDID("$FreeBSD$"); static struct mtx atrtc_lock; MTX_SYSINIT(atrtc_lock_init, &atrtc_lock, "atrtc", MTX_SPIN); +/* Force RTC enabled/disabled. */ +static int atrtc_enabled = -1; +TUNABLE_INT("hw.atrtc.enabled", &atrtc_enabled); + struct mtx atrtc_time_lock; MTX_SYSINIT(atrtc_time_lock_init, &atrtc_time_lock, "atrtc_time", MTX_DEF); @@ -249,11 +258,43 @@ static struct isa_pnp_id atrtc_ids[] = { { 0 } }; +static bool +atrtc_acpi_disabled(void) +{ +#ifdef DEV_ACPI + ACPI_TABLE_FADT *fadt; + vm_paddr_t physaddr; + uint16_t flags; + + physaddr = acpi_find_table(ACPI_SIG_FADT); + if (physaddr == 0) + return (false); + + fadt = acpi_map_table(physaddr, ACPI_SIG_FADT); + if (fadt == NULL) { + printf("at_rtc: unable to map FADT ACPI table\n"); + return (false); + } + + flags = fadt->BootFlags; + acpi_unmap_table(fadt); + + if (flags & ACPI_FADT_NO_CMOS_RTC) + return (true); +#endif + + return (false); +} + static int atrtc_probe(device_t dev) { int result; - + + if ((atrtc_enabled == -1 && atrtc_acpi_disabled()) || + (atrtc_enabled == 0)) + return (ENXIO); + result = ISA_PNP_PROBE(device_get_parent(dev), dev, atrtc_ids); /* ENOENT means no PnP-ID, device is hinted. */ if (result == ENOENT) {