From a43b0fb9ea8aa46c45e42fb0b101ce2c05b4e2ce Mon Sep 17 00:00:00 2001 From: jmcneill Date: Mon, 15 Oct 2018 11:33:09 +0000 Subject: Do not attach a timecounter when PM_TMR_LEN is 0. According to ACPI 6.2 section 5.2.9 ("Fixed ACPI Description Table (FADT)"), a value of zero here means that the PM timer is not supported. --- sys/dev/acpi/acpi_timer.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/acpi/acpi_timer.c b/sys/dev/acpi/acpi_timer.c index 774082e9da0..ae8414a1c61 100644 --- a/sys/dev/acpi/acpi_timer.c +++ b/sys/dev/acpi/acpi_timer.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_timer.c,v 1.22 2013/12/27 18:51:44 christos Exp $ */ +/* $NetBSD: acpi_timer.c,v 1.23 2018/10/15 11:33:09 jmcneill Exp $ */ /*- * Copyright (c) 2006 Matthias Drochner @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_timer.c,v 1.22 2013/12/27 18:51:44 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_timer.c,v 1.23 2018/10/15 11:33:09 jmcneill Exp $"); #include #include @@ -52,6 +52,12 @@ static struct timecounter acpi_timecounter = { NULL, }; +static bool +acpitimer_supported(void) +{ + return AcpiGbl_FADT.PmTimerLength != 0; +} + int acpitimer_init(struct acpi_softc *sc) { @@ -59,6 +65,9 @@ acpitimer_init(struct acpi_softc *sc) uint32_t bits; int i, j; + if (!acpitimer_supported()) + return -1; + rv = AcpiGetTimerResolution(&bits); if (ACPI_FAILURE(rv)) @@ -88,6 +97,9 @@ int acpitimer_detach(void) { + if (!acpitimer_supported()) + return -1; + return tc_detach(&acpi_timecounter); } -- cgit